From 519a86d1ddcfb8f0fe264174e62e5424e1efba1f Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 28 Nov 2014 15:59:46 +0100 Subject: [PATCH] Mass replace CRLF->LF Windows EOLs generate a checkstyle warning. Eliminate them to silence the build a bit. Change-Id: I16281420a51e237f516decd64ed46bbe7b4b1461 Signed-off-by: Robert Varga --- .../api/connection/ThreadConfiguration.java | 52 +- .../api/connection/TlsConfiguration.java | 130 +- .../api/connection/TlsConfigurationImpl.java | 182 +- .../DeserializerExtensionProvider.java | 230 +- .../extensibility/DeserializerRegistry.java | 102 +- .../DeserializerRegistryInjector.java | 42 +- .../extensibility/EnhancedMessageCodeKey.java | 118 +- .../extensibility/EnhancedMessageTypeKey.java | 130 +- .../api/extensibility/HeaderDeserializer.java | 54 +- .../api/extensibility/HeaderSerializer.java | 54 +- .../api/extensibility/MessageCodeKey.java | 144 +- .../extensibility/OFGeneralDeserializer.java | 34 +- .../extensibility/OFGeneralSerializer.java | 34 +- .../SerializerExtensionProvider.java | 198 +- .../api/extensibility/SerializerRegistry.java | 108 +- .../SerializerRegistryInjector.java | 44 +- .../api/keys/ActionDeserializerKey.java | 130 +- .../api/keys/ActionSerializerKey.java | 154 +- .../api/keys/InstructionDeserializerKey.java | 130 +- .../api/keys/InstructionSerializerKey.java | 160 +- .../api/keys/MatchEntryDeserializerKey.java | 160 +- .../api/keys/MatchEntrySerializerKey.java | 198 +- .../ExperimenterActionDeserializerKey.java | 56 +- .../ExperimenterActionSerializerKey.java | 122 +- .../ExperimenterDeserializerKey.java | 34 +- .../ExperimenterIdDeserializerKey.java | 138 +- .../ExperimenterIdSerializerKey.java | 134 +- ...xperimenterInstructionDeserializerKey.java | 56 +- .../ExperimenterInstructionSerializerKey.java | 54 +- .../ExperimenterSerializerKey.java | 34 +- .../protocol/api/util/OxmMatchConstants.java | 232 +- .../src/main/yang/openflow-augments.yang | 812 ++--- .../src/main/yang/openflow-configuration.yang | 116 +- .../src/main/yang/openflow-protocol.yang | 2856 ++++++++--------- .../connection/TlsConfigurationImplTest.java | 78 +- .../EnhancedMessageCodeKeyTest.java | 146 +- .../EnhancedMessageTypeKeyTest.java | 168 +- .../api/extensibility/MessageCodeKeyTest.java | 152 +- .../api/extensibility/MessageTypeKeyTest.java | 150 +- .../api/keys/ActionDeserializerKeyTest.java | 138 +- .../api/keys/ActionSerializerKeyTest.java | 160 +- .../keys/InstructionDeserializerKeyTest.java | 138 +- .../keys/InstructionSerializerKeyTest.java | 168 +- .../keys/MatchEntryDeserializerKeyTest.java | 164 +- .../api/keys/MatchEntrySerializerKeyTest.java | 212 +- ...ExperimenterActionDeserializerKeyTest.java | 82 +- .../ExperimenterActionSerializerKeyTest.java | 144 +- .../ExperimenterIdDeserializerKeyTest.java | 132 +- .../ExperimenterIdSerializerKeyTest.java | 132 +- ...imenterInstructionDeserializerKeyTest.java | 82 +- ...erimenterInstructionSerializerKeyTest.java | 84 +- .../impl/core/ChannelInitializerFactory.java | 172 +- .../impl/core/OFDatagramPacketDecoder.java | 122 +- .../impl/core/OFDatagramPacketEncoder.java | 110 +- .../impl/core/OFDatagramPacketHandler.java | 208 +- .../protocol/impl/core/PipelineHandlers.java | 124 +- .../impl/core/ProtocolChannelInitializer.java | 200 +- .../impl/core/UdpChannelInitializer.java | 62 +- .../protocol/impl/core/UdpConnectionMap.java | 122 +- .../protocol/impl/core/UdpHandler.java | 296 +- .../impl/core/VersionMessageUdpWrapper.java | 78 +- .../connection/MessageListenerWrapper.java | 98 +- .../connection/UdpMessageListenerWrapper.java | 88 +- .../ActionDeserializerInitializer.java | 182 +- .../InstructionDeserializerInitializer.java | 90 +- .../MatchEntryDeserializerInitializer.java | 254 +- .../MessageDeserializerInitializer.java | 202 +- .../TypeToClassMapInitializer.java | 160 +- .../action/AbstractActionDeserializer.java | 76 +- .../AbstractEthertypeActionDeserializer.java | 76 +- .../AbstractHeaderActionDeserializer.java | 66 +- ...10AbstractIpAddressActionDeserializer.java | 90 +- ...0AbstractMacAddressActionDeserializer.java | 92 +- .../OF10AbstractPortActionDeserializer.java | 86 +- .../action/OF10EnqueueActionDeserializer.java | 94 +- .../action/OF10OutputActionDeserializer.java | 90 +- .../OF10SetDlDstActionDeserializer.java | 50 +- .../OF10SetDlSrcActionDeserializer.java | 50 +- .../OF10SetNwDstActionDeserializer.java | 50 +- .../OF10SetNwSrcActionDeserializer.java | 50 +- .../OF10SetNwTosActionDeserializer.java | 92 +- .../OF10SetTpDstActionDeserializer.java | 50 +- .../OF10SetTpSrcActionDeserializer.java | 50 +- .../OF10SetVlanPcpActionDeserializer.java | 92 +- .../OF10SetVlanVidActionDeserializer.java | 92 +- .../OF10StripVlanActionDeserializer.java | 50 +- .../OF13CopyTtlInActionDeserializer.java | 50 +- .../OF13CopyTtlOutActionDeserializer.java | 50 +- .../OF13DecMplsTtlActionDeserializer.java | 50 +- .../OF13DecNwTtlActionDeserializer.java | 50 +- .../action/OF13GroupActionDeserializer.java | 86 +- .../action/OF13OutputActionDeserializer.java | 102 +- .../action/OF13PopMplsActionDeserializer.java | 50 +- .../action/OF13PopPbbActionDeserializer.java | 50 +- .../action/OF13PopVlanActionDeserializer.java | 50 +- .../OF13PushMplsActionDeserializer.java | 50 +- .../action/OF13PushPbbActionDeserializer.java | 50 +- .../OF13PushVlanActionDeserializer.java | 50 +- .../OF13SetFieldActionDeserializer.java | 156 +- .../OF13SetMplsTtlActionDeserializer.java | 90 +- .../OF13SetNwTtlActionDeserializer.java | 90 +- .../OF13SetQueueActionDeserializer.java | 86 +- .../factories/ExperimenterMessageFactory.java | 86 +- .../factories/VendorMessageFactory.java | 84 +- ...AbstractActionInstructionDeserializer.java | 130 +- .../AbstractInstructionDeserializer.java | 132 +- .../ApplyActionsInstructionDeserializer.java | 50 +- .../ClearActionsInstructionDeserializer.java | 82 +- .../GoToTableInstructionDeserializer.java | 78 +- .../MeterInstructionDeserializer.java | 76 +- .../WriteActionsInstructionDeserializer.java | 50 +- .../WriteMetadataInstructionDeserializer.java | 88 +- .../AbstractOxmIpv4AddressDeserializer.java | 86 +- .../AbstractOxmIpv6AddressDeserializer.java | 88 +- .../AbstractOxmMacAddressDeserializer.java | 90 +- .../AbstractOxmMatchEntryDeserializer.java | 128 +- .../AbstractOxmMetadataDeserializer.java | 86 +- .../match/AbstractOxmPortDeserializer.java | 76 +- .../AbstractOxmPortNumberDeserializer.java | 68 +- .../match/NxmTcpFlagDeserializer.java | 104 +- .../match/OxmArpOpDeserializer.java | 102 +- .../match/OxmArpShaDeserializer.java | 60 +- .../match/OxmArpSpaDeserializer.java | 60 +- .../match/OxmArpThaDeserializer.java | 60 +- .../match/OxmArpTpaDeserializer.java | 60 +- .../match/OxmEthDstDeserializer.java | 62 +- .../match/OxmEthSrcDeserializer.java | 62 +- .../match/OxmEthTypeDeserializer.java | 104 +- .../match/OxmIcmpv4CodeDeserializer.java | 106 +- .../match/OxmIcmpv4TypeDeserializer.java | 104 +- .../match/OxmIcmpv6CodeDeserializer.java | 104 +- .../match/OxmIcmpv6TypeDeserializer.java | 94 +- .../match/OxmInPhyPortDeserializer.java | 60 +- .../match/OxmInPortDeserializer.java | 60 +- .../match/OxmIpDscpDeserializer.java | 104 +- .../match/OxmIpEcnDeserializer.java | 102 +- .../match/OxmIpProtoDeserializer.java | 102 +- .../match/OxmIpv4DstDeserializer.java | 60 +- .../match/OxmIpv4SrcDeserializer.java | 60 +- .../match/OxmIpv6DstDeserializer.java | 60 +- .../match/OxmIpv6ExtHdrDeserializer.java | 132 +- .../match/OxmIpv6FlabelDeserializer.java | 116 +- .../match/OxmIpv6NdSllDeserializer.java | 60 +- .../match/OxmIpv6NdTargetDeserializer.java | 60 +- .../match/OxmIpv6NdTllDeserializer.java | 62 +- .../match/OxmIpv6SrcDeserializer.java | 60 +- .../match/OxmMaskDeserializer.java | 80 +- .../match/OxmMetadataDeserializer.java | 60 +- .../match/OxmMplsBosDeserializer.java | 114 +- .../match/OxmMplsLabelDeserializer.java | 104 +- .../match/OxmMplsTcDeserializer.java | 102 +- .../match/OxmPbbIsidDeserializer.java | 112 +- .../match/OxmSctpDstDeserializer.java | 60 +- .../match/OxmSctpSrcDeserializer.java | 60 +- .../match/OxmTcpDstDeserializer.java | 60 +- .../match/OxmTcpSrcDeserializer.java | 60 +- .../match/OxmTunnelIdDeserializer.java | 60 +- .../match/OxmUdpDstDeserializer.java | 60 +- .../match/OxmUdpSrcDeserializer.java | 60 +- .../match/OxmVlanPcpDeserializer.java | 102 +- .../match/OxmVlanVidDeserializer.java | 114 +- .../serialization/ActionsInitializer.java | 236 +- .../InstructionsInitializer.java | 104 +- .../MatchEntriesInitializer.java | 344 +- .../MessageFactoryInitializer.java | 226 +- .../action/AbstractActionSerializer.java | 94 +- .../AbstractEthertypeActionSerializer.java | 70 +- .../AbstractHeaderActionSerializer.java | 64 +- ...OF10AbstractIpAddressActionSerializer.java | 64 +- ...F10AbstractMacAddressActionSerializer.java | 64 +- .../OF10AbstractPortActionSerializer.java | 60 +- .../action/OF10EnqueueActionSerializer.java | 88 +- .../action/OF10OutputActionSerializer.java | 86 +- .../action/OF10SetDlDstActionSerializer.java | 58 +- .../action/OF10SetDlSrcActionSerializer.java | 58 +- .../action/OF10SetNwDstActionSerializer.java | 58 +- .../action/OF10SetNwSrcActionSerializer.java | 54 +- .../action/OF10SetNwTosActionSerializer.java | 80 +- .../action/OF10SetTpDstActionSerializer.java | 58 +- .../action/OF10SetTpSrcActionSerializer.java | 58 +- .../OF10SetVlanPcpActionSerializer.java | 80 +- .../OF10SetVlanVidActionSerializer.java | 80 +- .../action/OF10StripVlanActionSerializer.java | 50 +- .../action/OF13CopyTtlInActionSerializer.java | 48 +- .../OF13CopyTtlOutActionSerializer.java | 48 +- .../OF13DecMplsTtlActionSerializer.java | 48 +- .../action/OF13DecNwTtlActionSerializer.java | 50 +- .../action/OF13GroupActionSerializer.java | 80 +- .../action/OF13OutputActionSerializer.java | 88 +- .../action/OF13PopMplsActionSerializer.java | 48 +- .../action/OF13PopPbbActionSerializer.java | 48 +- .../action/OF13PopVlanActionSerializer.java | 48 +- .../action/OF13PushMplsActionSerializer.java | 48 +- .../action/OF13PushPbbActionSerializer.java | 48 +- .../action/OF13PushVlanActionSerializer.java | 50 +- .../action/OF13SetFieldActionSerializer.java | 142 +- .../OF13SetMplsTtlActionSerializer.java | 86 +- .../action/OF13SetNwTtlActionSerializer.java | 82 +- .../action/OF13SetQueueActionSerializer.java | 80 +- .../AbstractActionInstructionSerializer.java | 128 +- .../AbstractInstructionSerializer.java | 72 +- .../ApplyActionsInstructionSerializer.java | 48 +- .../ClearActionsInstructionSerializer.java | 48 +- .../GoToTableInstructionSerializer.java | 72 +- .../MeterInstructionSerializer.java | 72 +- .../WriteActionsInstructionSerializer.java | 48 +- .../WriteMetadataInstructionSerializer.java | 76 +- .../AbstractOxmIpv4AddressSerializer.java | 74 +- .../AbstractOxmIpv6AddressSerializer.java | 166 +- .../AbstractOxmMacAddressSerializer.java | 58 +- .../AbstractOxmMatchEntrySerializer.java | 146 +- .../match/AbstractOxmMetadataSerializer.java | 54 +- .../AbstractOxmPortNumberSerializer.java | 52 +- .../match/AbstractOxmPortSerializer.java | 52 +- .../match/NxmTcpFlagSerializer.java | 90 +- .../match/OxmArpOpSerializer.java | 86 +- .../match/OxmArpShaSerializer.java | 66 +- .../match/OxmArpSpaSerializer.java | 66 +- .../match/OxmArpThaSerializer.java | 66 +- .../match/OxmArpTpaSerializer.java | 66 +- .../match/OxmEthDstSerializer.java | 66 +- .../match/OxmEthSrcSerializer.java | 66 +- .../match/OxmEthTypeSerializer.java | 86 +- .../match/OxmIcmpv4CodeSerializer.java | 86 +- .../match/OxmIcmpv4TypeSerializer.java | 86 +- .../match/OxmIcmpv6CodeSerializer.java | 86 +- .../match/OxmIcmpv6TypeSerializer.java | 86 +- .../match/OxmInPhyPortSerializer.java | 66 +- .../match/OxmInPortSerializer.java | 66 +- .../match/OxmIpDscpSerializer.java | 86 +- .../match/OxmIpEcnSerializer.java | 86 +- .../match/OxmIpProtoSerializer.java | 86 +- .../match/OxmIpv4DstSerializer.java | 66 +- .../match/OxmIpv4SrcSerializer.java | 66 +- .../match/OxmIpv6DstSerializer.java | 66 +- .../match/OxmIpv6ExtHdrSerializer.java | 114 +- .../match/OxmIpv6FlabelSerializer.java | 88 +- .../match/OxmIpv6NdSllSerializer.java | 66 +- .../match/OxmIpv6NdTargetSerializer.java | 66 +- .../match/OxmIpv6NdTllSerializer.java | 66 +- .../match/OxmIpv6SrcSerializer.java | 66 +- .../match/OxmMetadataSerializer.java | 66 +- .../match/OxmMplsBosSerializer.java | 86 +- .../match/OxmMplsLabelSerializer.java | 86 +- .../match/OxmMplsTcSerializer.java | 86 +- .../match/OxmPbbIsidSerializer.java | 88 +- .../match/OxmSctpDstSerializer.java | 66 +- .../match/OxmSctpSrcSerializer.java | 66 +- .../match/OxmTcpDstSerializer.java | 66 +- .../match/OxmTcpSrcSerializer.java | 66 +- .../match/OxmTunnelIdSerializer.java | 66 +- .../match/OxmUdpDstSerializer.java | 66 +- .../match/OxmUdpSrcSerializer.java | 68 +- .../match/OxmVlanPcpSerializer.java | 88 +- .../match/OxmVlanVidSerializer.java | 104 +- .../impl/util/AbstractCodeKeyMaker.java | 70 +- .../impl/util/AbstractTypeKeyMaker.java | 70 +- .../protocol/impl/util/ActionConstants.java | 214 +- .../ActionDeserializerRegistryHelper.java | 84 +- .../util/ActionSerializerRegistryHelper.java | 84 +- .../protocol/impl/util/CodeKeyMaker.java | 52 +- .../impl/util/CodeKeyMakerFactory.java | 180 +- .../util/CommonMessageRegistryHelper.java | 78 +- .../impl/util/InstructionConstants.java | 96 +- ...InstructionDeserializerRegistryHelper.java | 84 +- .../InstructionSerializerRegistryHelper.java | 82 +- .../protocol/impl/util/ListDeserializer.java | 156 +- .../protocol/impl/util/ListSerializer.java | 122 +- .../MatchEntryDeserializerRegistryHelper.java | 92 +- .../MatchEntrySerializerRegistryHelper.java | 98 +- .../protocol/impl/util/OpenflowUtils.java | 150 +- .../SimpleDeserializerRegistryHelper.java | 88 +- .../protocol/impl/util/TypeKeyMaker.java | 52 +- .../impl/util/TypeKeyMakerFactory.java | 184 +- .../impl/util/TypeToClassInitHelper.java | 80 +- .../protocol/impl/util/TypeToClassKey.java | 112 +- .../openflowjava/statistics/Counter.java | 166 +- .../statistics/CounterEventTypes.java | 104 +- .../src/main/resources/log4j.xml | 56 +- .../core/OFDatagramPacketEncoderTest.java | 174 +- .../connection/ChannelOutboundQueueTest.java | 108 +- .../connection/ConnectionAdapterImplTest.java | 358 +-- .../MessageListenerWrapperTest.java | 70 +- .../ResponseExpectedRpcListenerTest.java | 262 +- .../connection/SimpleRpcListenerTest.java | 214 +- .../SwitchConnectionProviderImplTest.java | 362 +-- .../DeserializationFactoryTest.java | 110 +- .../TypeToClassMapInitializerTest.java | 160 +- .../ExperimenterMessageFactoryTest.java | 116 +- .../OF10StatsReplyMessageFactoryTest.java | 634 ++-- .../factories/VendorMessageFactoryTest.java | 94 +- .../MultipartReplyExperimenterTest.java | 104 +- .../multipart/MultipartReplyFlowTest.java | 270 +- .../MultipartReplyGroupFeaturesTest.java | 206 +- .../MultipartReplyMeterFeaturesTest.java | 158 +- .../multipart/MultipartReplyPortDescTest.java | 242 +- .../MultipartReplyTableFeaturesTest.java | 372 +-- .../OF10StatsReplyExperimenterTest.java | 102 +- .../AbstractInstructionDeserializerTest.java | 128 +- .../match/OxmIpv6ExtHdrDeserializerTest.java | 96 +- .../match/OxmIpv6FlabelDeserializerTest.java | 86 +- .../match/OxmMetadataDeserializerTest.java | 88 +- .../match/OxmMplsBosDeserializerTest.java | 84 +- .../match/OxmPbbIsidDeserializerTest.java | 84 +- .../match/OxmVlanVidDeserializerTest.java | 90 +- .../SerializationFactoryTest.java | 118 +- .../ExperimenterInputMessageFactoryTest.java | 256 +- .../OF10StatsRequestInputFactoryTest.java | 604 ++-- .../VendorInputMessageFactoryTest.java | 112 +- .../MultipartRequestExperimenterTest.java | 156 +- .../MultipartRequestGroupDescTest.java | 152 +- .../MultipartRequestGroupFeaturesTest.java | 152 +- .../MultipartRequestMeterFeaturesTest.java | 152 +- .../MultipartRequestPortDescTest.java | 152 +- .../MultipartRequestTableFeaturesTest.java | 932 +++--- .../multipart/MultipartRequestTableTest.java | 152 +- .../OF10StatsRequestAggregateTest.java | 202 +- .../OF10StatsRequestExperimenterTest.java | 156 +- .../match/OxmArpOpSerializerTest.java | 216 +- .../match/OxmArpShaSerializerTest.java | 316 +- .../match/OxmArpSpaSerializerTest.java | 316 +- .../match/OxmArpThaSerializerTest.java | 316 +- .../match/OxmArpTpaSerializerTest.java | 316 +- .../match/OxmEthDstSerializerTest.java | 316 +- .../match/OxmEthSrcSerializerTest.java | 316 +- .../match/OxmEthTypeSerializerTest.java | 220 +- .../match/OxmIcmpv4CodeSerializerTest.java | 218 +- .../match/OxmIcmpv4TypeSerializerTest.java | 218 +- .../match/OxmIcmpv6CodeSerializerTest.java | 216 +- .../match/OxmIcmpv6TypeSerializerTest.java | 218 +- .../match/OxmIpDscpSerializerTest.java | 218 +- .../match/OxmIpProtoSerializerTest.java | 216 +- .../match/OxmIpv4DstSerializerTest.java | 316 +- .../match/OxmIpv4SrcSerializerTest.java | 316 +- .../match/OxmIpv6ExtHdrSerializerTest.java | 312 +- .../match/OxmIpv6NdSllSerializerTest.java | 238 +- .../match/OxmIpv6NdTllSerializerTest.java | 238 +- .../match/OxmMetadataSerializerTest.java | 314 +- .../match/OxmMplsBosSerializerTest.java | 218 +- .../match/OxmMplsLabelSerializerTest.java | 216 +- .../match/OxmMplsTcSerializerTest.java | 216 +- .../match/OxmPbbIsidSerializerTest.java | 306 +- .../match/OxmSctpDstSerializerTest.java | 218 +- .../match/OxmSctpSrcSerializerTest.java | 218 +- .../match/OxmTcpDstSerializerTest.java | 218 +- .../match/OxmTcpSrcSerializerTest.java | 218 +- .../match/OxmTunnelIdSerializerTest.java | 314 +- .../match/OxmUdpDstSerializerTest.java | 218 +- .../match/OxmUdpSrcSerializerTest.java | 218 +- .../match/OxmVlanPcpSerializerTest.java | 216 +- .../match/OxmVlanVidSerializerTest.java | 306 +- .../impl/util/ActionsDeserializerTest.java | 332 +- .../impl/util/CodeKeyMakerFactoryTest.java | 268 +- .../util/InstructionsDeserializerTest.java | 224 +- .../impl/util/ListDeserializerTest.java | 114 +- .../impl/util/ListSerializerTest.java | 88 +- .../impl/util/MatchDeserializerTest.java | 1030 +++--- .../util/OF10ActionsDeserializerTest.java | 270 +- .../impl/util/OF10ActionsSerializerTest.java | 436 +-- .../impl/util/OF13ActionsSerializerTest.java | 572 ++-- .../util/OF13InstructionsSerializerTest.java | 392 +-- .../impl/util/OF13MatchSerializer02Test.java | 1586 ++++----- .../protocol/impl/util/OpenflowUtilsTest.java | 134 +- .../impl/util/TypeKeyMakerFactoryTest.java | 360 +-- .../src/test/resources/log4j.xml | 48 +- .../spi/statistics/StatisticsHandler.java | 54 +- openflowjava-config/pom.xml | 102 +- .../main/resources/45-openflowjava-stats.xml | 80 +- .../protocol/impl/clients/OFClient.java | 78 +- .../ExperimenterDeserializerKeyFactory.java | 166 +- .../ExperimenterSerializerKeyFactory.java | 122 +- ...xperimenterDeserializerKeyFactoryTest.java | 186 +- .../ExperimenterSerializerKeyFactoryTest.java | 142 +- 373 files changed, 26372 insertions(+), 26372 deletions(-) diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java index 89dae4a2..e3d1fb66 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/ThreadConfiguration.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2014 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; - -/** - * @author michal.polkorab - * - */ -public interface ThreadConfiguration { - - /** - * @return desired number of workerThreads processing the Openflow I/O - */ - int getWorkerThreadCount(); - - /** - * @return desired number of bossThreads registering incomming Openflow connections - */ - int getBossThreadCount(); -} +/* + * Copyright (c) 2014 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; + +/** + * @author michal.polkorab + * + */ +public interface ThreadConfiguration { + + /** + * @return desired number of workerThreads processing the Openflow I/O + */ + int getWorkerThreadCount(); + + /** + * @return desired number of bossThreads registering incomming Openflow connections + */ + int getBossThreadCount(); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java index fde44efb..84eeab3e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfiguration.java @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2014 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; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; - - -/** - * @author michal.polkorab - * - */ -public interface TlsConfiguration { - - /** - * @return keystore location - */ - String getTlsKeystore(); - - /** - * @return keystore type - */ - KeystoreType getTlsKeystoreType(); - - /** - * @return truststore location - */ - String getTlsTruststore(); - - /** - * @return truststore type - */ - KeystoreType getTlsTruststoreType(); - - /** - * @return keystore path type (CLASSPATH or PATH) - */ - PathType getTlsKeystorePathType(); - - /** - * @return truststore path type (CLASSPATH or PATH) - */ - PathType getTlsTruststorePathType(); - - /** - * @return password protecting specified keystore - */ - String getKeystorePassword(); - - /** - * @return password protecting certificate - */ - String getCertificatePassword(); - - /** - * @return password protecting specified truststore - */ - String getTruststorePassword(); -} +/* + * Copyright (c) 2014 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; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + + +/** + * @author michal.polkorab + * + */ +public interface TlsConfiguration { + + /** + * @return keystore location + */ + String getTlsKeystore(); + + /** + * @return keystore type + */ + KeystoreType getTlsKeystoreType(); + + /** + * @return truststore location + */ + String getTlsTruststore(); + + /** + * @return truststore type + */ + KeystoreType getTlsTruststoreType(); + + /** + * @return keystore path type (CLASSPATH or PATH) + */ + PathType getTlsKeystorePathType(); + + /** + * @return truststore path type (CLASSPATH or PATH) + */ + PathType getTlsTruststorePathType(); + + /** + * @return password protecting specified keystore + */ + String getKeystorePassword(); + + /** + * @return password protecting certificate + */ + String getCertificatePassword(); + + /** + * @return password protecting specified truststore + */ + String getTruststorePassword(); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java index 4d6fa87d..78a6c6b8 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImpl.java @@ -1,91 +1,91 @@ -/* - * Copyright (c) 2014 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; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; - -/** - * Class is used only for testing purposes - passwords are hardcoded - * @author michal.polkorab - */ -public class TlsConfigurationImpl implements TlsConfiguration { - - private KeystoreType trustStoreType; - private String trustStore; - private KeystoreType keyStoreType; - private String keyStore; - private PathType keystorePathType; - private PathType truststorePathType; - - /** - * Default constructor - * @param trustStoreType JKS or PKCS12 - * @param trustStore path to trustStore file - * @param trustStorePathType truststore path type (classpath or path) - * @param keyStoreType JKS or PKCS12 - * @param keyStore path to keyStore file - * @param keyStorePathType keystore path type (classpath or path) - */ - public TlsConfigurationImpl(KeystoreType trustStoreType, String trustStore, - PathType trustStorePathType, KeystoreType keyStoreType, - String keyStore, PathType keyStorePathType) { - this.trustStoreType = trustStoreType; - this.trustStore = trustStore; - this.truststorePathType = trustStorePathType; - this.keyStoreType = keyStoreType; - this.keyStore = keyStore; - this.keystorePathType = keyStorePathType; - } - - @Override - public KeystoreType getTlsTruststoreType() { - return trustStoreType; - } - - @Override - public String getTlsTruststore() { - return trustStore; - } - - @Override - public KeystoreType getTlsKeystoreType() { - return keyStoreType; - } - - @Override - public String getTlsKeystore() { - return keyStore; - } - - @Override - public PathType getTlsKeystorePathType() { - return keystorePathType; - } - - @Override - public PathType getTlsTruststorePathType() { - return truststorePathType; - } - - @Override - public String getKeystorePassword() { - return "opendaylight"; - } - - @Override - public String getCertificatePassword() { - return "opendaylight"; - } - - @Override - public String getTruststorePassword() { - return "opendaylight"; - } -} +/* + * Copyright (c) 2014 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; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * Class is used only for testing purposes - passwords are hardcoded + * @author michal.polkorab + */ +public class TlsConfigurationImpl implements TlsConfiguration { + + private KeystoreType trustStoreType; + private String trustStore; + private KeystoreType keyStoreType; + private String keyStore; + private PathType keystorePathType; + private PathType truststorePathType; + + /** + * Default constructor + * @param trustStoreType JKS or PKCS12 + * @param trustStore path to trustStore file + * @param trustStorePathType truststore path type (classpath or path) + * @param keyStoreType JKS or PKCS12 + * @param keyStore path to keyStore file + * @param keyStorePathType keystore path type (classpath or path) + */ + public TlsConfigurationImpl(KeystoreType trustStoreType, String trustStore, + PathType trustStorePathType, KeystoreType keyStoreType, + String keyStore, PathType keyStorePathType) { + this.trustStoreType = trustStoreType; + this.trustStore = trustStore; + this.truststorePathType = trustStorePathType; + this.keyStoreType = keyStoreType; + this.keyStore = keyStore; + this.keystorePathType = keyStorePathType; + } + + @Override + public KeystoreType getTlsTruststoreType() { + return trustStoreType; + } + + @Override + public String getTlsTruststore() { + return trustStore; + } + + @Override + public KeystoreType getTlsKeystoreType() { + return keyStoreType; + } + + @Override + public String getTlsKeystore() { + return keyStore; + } + + @Override + public PathType getTlsKeystorePathType() { + return keystorePathType; + } + + @Override + public PathType getTlsTruststorePathType() { + return truststorePathType; + } + + @Override + public String getKeystorePassword() { + return "opendaylight"; + } + + @Override + public String getCertificatePassword() { + return "opendaylight"; + } + + @Override + public String getTruststorePassword() { + return "opendaylight"; + } +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java index 0fd529db..f8f3c1b3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerExtensionProvider.java @@ -1,116 +1,116 @@ -/* - * Copyright (c) 2014 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.extensibility; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; -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.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; - -/** - * Provides methods for deserialization part of extensibility. - * In case of handling multiple multiple structures of same type (actions, - * instructions, match entries, ... ) which are differentiated by - * vendor / experimenter subtype, vendor has to switch / choose between - * these subtypes.
- * - * This has to be done in this way because of experimenter headers, which - * provide only vendor / experimenter ID. Subtype position may be different - * for different vendors (or not present at all) - that's why vendor has to - * handle it in his own implementations. - * @author michal.polkorab - */ -public interface DeserializerExtensionProvider { - - /** - * Unregisters custom deserializer - * @param key used for deserializer lookup - * @return true if deserializer was removed, - * false if no deserializer was found under specified key - */ - boolean unregisterDeserializer(ExperimenterDeserializerKey key); - - /** - * Registers action deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerActionDeserializer(ExperimenterActionDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers instruction deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers match entry deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers error message deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerErrorDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); - - /** - * Registers experimenter (vendor) message deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); - - /** - * Registers multipart-reply (stats) message deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); - - /** - * Registers multipart-reply table-features message deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerMultipartReplyTFDeserializer(ExperimenterIdDeserializerKey key, - OFGeneralDeserializer deserializer); - - /** - * Registers meter band deserializer (used in multipart-reply meter-config) - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); - - /** - * Registers queue property (QUEUE_GET_CONFIG_REPLY message) deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, - OFDeserializer deserializer); +/* + * Copyright (c) 2014 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.extensibility; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +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.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; + +/** + * Provides methods for deserialization part of extensibility. + * In case of handling multiple multiple structures of same type (actions, + * instructions, match entries, ... ) which are differentiated by + * vendor / experimenter subtype, vendor has to switch / choose between + * these subtypes.
+ * + * This has to be done in this way because of experimenter headers, which + * provide only vendor / experimenter ID. Subtype position may be different + * for different vendors (or not present at all) - that's why vendor has to + * handle it in his own implementations. + * @author michal.polkorab + */ +public interface DeserializerExtensionProvider { + + /** + * Unregisters custom deserializer + * @param key used for deserializer lookup + * @return true if deserializer was removed, + * false if no deserializer was found under specified key + */ + boolean unregisterDeserializer(ExperimenterDeserializerKey key); + + /** + * Registers action deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerActionDeserializer(ExperimenterActionDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers instruction deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerInstructionDeserializer(ExperimenterInstructionDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers match entry deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMatchEntryDeserializer(MatchEntryDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers error message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerErrorDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers experimenter (vendor) message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerExperimenterMessageDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers multipart-reply (stats) message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMultipartReplyMessageDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers multipart-reply table-features message deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMultipartReplyTFDeserializer(ExperimenterIdDeserializerKey key, + OFGeneralDeserializer deserializer); + + /** + * Registers meter band deserializer (used in multipart-reply meter-config) + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerMeterBandDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); + + /** + * Registers queue property (QUEUE_GET_CONFIG_REPLY message) deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerQueuePropertyDeserializer(ExperimenterIdDeserializerKey key, + OFDeserializer deserializer); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java index 646f4e08..3b647a49 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistry.java @@ -1,51 +1,51 @@ -/* - * 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.extensibility; - - -/** - * @author michal.polkorab - * - */ -public interface DeserializerRegistry { - - /** - * Initializes deserializers - */ - void init(); - - /** - * @param key used for deserializer lookup - * @return deserializer found - */ - - SERIALIZERTYPE getDeserializer(MessageCodeKey key); - - /** - * Registers deserializer. - * Throws IllegalStateException when there is - * a deserializer already registered under given key. - * - * If the deserializer implements {@link DeserializerRegistryInjector} interface, - * the deserializer is injected with DeserializerRegistry instance. - * - * @param key used for deserializer lookup - * @param deserializer deserializer instance - */ - void registerDeserializer(MessageCodeKey key, - OFGeneralDeserializer deserializer); - - /** - * Unregisters deserializer - * @param key used for deserializer lookup - * @param deserializer deserializer instance - * @return true if deserializer was removed, - * false if no deserializer was found under specified key - */ - boolean unregisterDeserializer(MessageCodeKey key); -} +/* + * 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.extensibility; + + +/** + * @author michal.polkorab + * + */ +public interface DeserializerRegistry { + + /** + * Initializes deserializers + */ + void init(); + + /** + * @param key used for deserializer lookup + * @return deserializer found + */ + + SERIALIZERTYPE getDeserializer(MessageCodeKey key); + + /** + * Registers deserializer. + * Throws IllegalStateException when there is + * a deserializer already registered under given key. + * + * If the deserializer implements {@link DeserializerRegistryInjector} interface, + * the deserializer is injected with DeserializerRegistry instance. + * + * @param key used for deserializer lookup + * @param deserializer deserializer instance + */ + void registerDeserializer(MessageCodeKey key, + OFGeneralDeserializer deserializer); + + /** + * Unregisters deserializer + * @param key used for deserializer lookup + * @param deserializer deserializer instance + * @return true if deserializer was removed, + * false if no deserializer was found under specified key + */ + boolean unregisterDeserializer(MessageCodeKey key); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java index 662ac802..0b291af3 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/DeserializerRegistryInjector.java @@ -1,21 +1,21 @@ -/* - * 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.extensibility; - -/** - * Injects registry - * @author michal.polkorab - */ -public interface DeserializerRegistryInjector { - - /** - * Injects deserializer registry into deserializer - * @param deserializerRegistry - */ - void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry); -} +/* + * 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.extensibility; + +/** + * Injects registry + * @author michal.polkorab + */ +public interface DeserializerRegistryInjector { + + /** + * Injects deserializer registry into deserializer + * @param deserializerRegistry + */ + void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java index 08db5a01..4ecec614 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKey.java @@ -1,60 +1,60 @@ -/* - * 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.extensibility; - -/** - * @author michal.polkorab - * - */ -public class EnhancedMessageCodeKey extends MessageCodeKey { - - private int msgType2; - - /** - * Constructor - * @param version wire protocol version - * @param value used as distinguisher - * @param value2 used as detailed distinguisher - * @param clazz class of object that is going to be deserialized - */ - public EnhancedMessageCodeKey(short version, int value, int value2, Class clazz) { - super(version, value, clazz); - this.msgType2 = value2; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + msgType2; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - EnhancedMessageCodeKey other = (EnhancedMessageCodeKey) obj; - if (msgType2 != other.msgType2) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " msgType2: " + msgType2; - } +/* + * 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.extensibility; + +/** + * @author michal.polkorab + * + */ +public class EnhancedMessageCodeKey extends MessageCodeKey { + + private int msgType2; + + /** + * Constructor + * @param version wire protocol version + * @param value used as distinguisher + * @param value2 used as detailed distinguisher + * @param clazz class of object that is going to be deserialized + */ + public EnhancedMessageCodeKey(short version, int value, int value2, Class clazz) { + super(version, value, clazz); + this.msgType2 = value2; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + msgType2; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + EnhancedMessageCodeKey other = (EnhancedMessageCodeKey) obj; + if (msgType2 != other.msgType2) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " msgType2: " + msgType2; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java index d2ce5a91..c0f17c6a 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKey.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - - -/** - * More specific key for {@link SerializerRegistry} - * @author michal.polkorab - * @param main type - * @param specific type - */ -public class EnhancedMessageTypeKey extends MessageTypeKey { - - private final Class msgType2; - - /** - * @param msgVersion - * @param msgType - * @param msgType2 - */ - public EnhancedMessageTypeKey(short msgVersion, Class msgType, Class msgType2) { - super(msgVersion, msgType); - this.msgType2 = msgType2; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((msgType2 == null) ? 0 : msgType2.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - @SuppressWarnings("rawtypes") - EnhancedMessageTypeKey other = (EnhancedMessageTypeKey) obj; - if (msgType2 == null) { - if (other.msgType2 != null) { - return false; - } - } else if (!msgType2.getName().equals(other.msgType2.getName())) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " msgType2: " + msgType2.getName(); - } +/* + * 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.extensibility; + + +/** + * More specific key for {@link SerializerRegistry} + * @author michal.polkorab + * @param main type + * @param specific type + */ +public class EnhancedMessageTypeKey extends MessageTypeKey { + + private final Class msgType2; + + /** + * @param msgVersion + * @param msgType + * @param msgType2 + */ + public EnhancedMessageTypeKey(short msgVersion, Class msgType, Class msgType2) { + super(msgVersion, msgType); + this.msgType2 = msgType2; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((msgType2 == null) ? 0 : msgType2.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + @SuppressWarnings("rawtypes") + EnhancedMessageTypeKey other = (EnhancedMessageTypeKey) obj; + if (msgType2 == null) { + if (other.msgType2 != null) { + return false; + } + } else if (!msgType2.getName().equals(other.msgType2.getName())) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " msgType2: " + msgType2.getName(); + } } diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java index 594f3d02..855b2f69 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderDeserializer.java @@ -1,27 +1,27 @@ -/* - * 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.extensibility; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * @param - */ -public interface HeaderDeserializer extends OFGeneralDeserializer { - - /** - * Deserializes byte message headers - * - * @param rawMessage message as bytes in ByteBuf - * @return POJO/DTO - */ - E deserializeHeader(ByteBuf rawMessage); -} +/* + * 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.extensibility; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * @param + */ +public interface HeaderDeserializer extends OFGeneralDeserializer { + + /** + * Deserializes byte message headers + * + * @param rawMessage message as bytes in ByteBuf + * @return POJO/DTO + */ + E deserializeHeader(ByteBuf rawMessage); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java index cd8cf038..d1966fb1 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/HeaderSerializer.java @@ -1,27 +1,27 @@ -/* - * 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.extensibility; - -import org.opendaylight.yangtools.yang.binding.DataObject; - -import io.netty.buffer.ByteBuf; - -/** - * Does only-header serialization (such as oxm_ids, action_ids, instruction_ids) - * @author michal.polkorab - * @param - */ -public interface HeaderSerializer extends OFGeneralSerializer { - - /** - * Serializes object headers (e.g. for Multipart message - Table Features) - * @param input object whose headers should be serialized - * @param outBuffer output buffer - */ - void serializeHeader(SERIALIZER_TYPE input, ByteBuf outBuffer); -} +/* + * 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.extensibility; + +import org.opendaylight.yangtools.yang.binding.DataObject; + +import io.netty.buffer.ByteBuf; + +/** + * Does only-header serialization (such as oxm_ids, action_ids, instruction_ids) + * @author michal.polkorab + * @param + */ +public interface HeaderSerializer extends OFGeneralSerializer { + + /** + * Serializes object headers (e.g. for Multipart message - Table Features) + * @param input object whose headers should be serialized + * @param outBuffer output buffer + */ + void serializeHeader(SERIALIZER_TYPE input, ByteBuf outBuffer); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java index 56b6bb1a..ea487ea6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKey.java @@ -1,73 +1,73 @@ -/* - * 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.extensibility; - -/** - * @author michal.polkorab - */ -public class MessageCodeKey { - - private short msgVersion; - private int msgType; - private Class clazz; - - /** - * Constructor - * @param version wire protocol version - * @param value used as distinguisher (read from binary data / buffer) - * @param clazz class of object that is going to be deserialized - */ - public MessageCodeKey(short version, int value, Class clazz) { - this.msgVersion = version; - this.msgType = value; - this.clazz = clazz; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((clazz == null) ? 0 : clazz.hashCode()); - 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 (!(obj instanceof MessageCodeKey)) { - return false; - } - MessageCodeKey other = (MessageCodeKey) obj; - if (clazz == null) { - if (other.clazz != null) { - return false; - } - } else if (!clazz.equals(other.clazz)) { - return false; - } - if (msgType != other.msgType) { - return false; - } - if (msgVersion != other.msgVersion) { - return false; - } - return true; - } - - @Override - public String toString() { - return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType; - } +/* + * 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.extensibility; + +/** + * @author michal.polkorab + */ +public class MessageCodeKey { + + private short msgVersion; + private int msgType; + private Class clazz; + + /** + * Constructor + * @param version wire protocol version + * @param value used as distinguisher (read from binary data / buffer) + * @param clazz class of object that is going to be deserialized + */ + public MessageCodeKey(short version, int value, Class clazz) { + this.msgVersion = version; + this.msgType = value; + this.clazz = clazz; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((clazz == null) ? 0 : clazz.hashCode()); + 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 (!(obj instanceof MessageCodeKey)) { + return false; + } + MessageCodeKey other = (MessageCodeKey) obj; + if (clazz == null) { + if (other.clazz != null) { + return false; + } + } else if (!clazz.equals(other.clazz)) { + return false; + } + if (msgType != other.msgType) { + return false; + } + if (msgVersion != other.msgVersion) { + return false; + } + return true; + } + + @Override + public String toString() { + return "msgVersion: " + msgVersion + " objectClass: " + clazz.getName() + " msgType: " + msgType; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java index bedb267a..c4132cc6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralDeserializer.java @@ -1,17 +1,17 @@ -/* - * 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.extensibility; - - -/** - * @author michal.polkorab - */ -public interface OFGeneralDeserializer { - - // empty unifying interface -} +/* + * 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.extensibility; + + +/** + * @author michal.polkorab + */ +public interface OFGeneralDeserializer { + + // empty unifying interface +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralSerializer.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralSerializer.java index 0001c3e9..6dd5d3f0 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralSerializer.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/OFGeneralSerializer.java @@ -1,17 +1,17 @@ -/* - * 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.extensibility; - -/** - * Unifying superinterface - * @author michal.polkorab - * */ -public interface OFGeneralSerializer { - - // empty unifying superinterface -} +/* + * 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.extensibility; + +/** + * Unifying superinterface + * @author michal.polkorab + * */ +public interface OFGeneralSerializer { + + // empty unifying superinterface +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java index f658f5f1..b5bb0c2c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerExtensionProvider.java @@ -1,100 +1,100 @@ -/* - * Copyright (c) 2014 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.extensibility; - -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - - -/** - * Provides methods for serialization part of extensibility. - * In case of handling multiple structures of same type (actions, - * instructions, match entries, ... ) which are differentiated by - * vendor / experimenter subtype, vendor has to switch / choose between - * these subtypes.
- * - * This has to be done in this way because of unknown augmentations - * - that's why vendor has to handle it in his own implementations. - * @author michal.polkorab - */ -public interface SerializerExtensionProvider { - - /** - * Unregisters custom serializer - * @param key used for serializer lookup - * @return true if serializer was removed, - * false if no serializer was found under specified key - */ - boolean unregisterSerializer(ExperimenterSerializerKey key); - - /** - * Registers action serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerActionSerializer(ExperimenterActionSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers instruction serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers match entry serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerMatchEntrySerializer( - MatchEntrySerializerKey key,OFGeneralSerializer serializer); - - /** - * Registers experimenter (vendor) message serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer); - - /** - * Registers multipart-request (stats-request) serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer); - - /** - * Registers multipart-request table-features serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, - OFGeneralSerializer serializer); - - /** - * Registers meter band serializer (used in meter-mod messages) - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerMeterBandSerializer(ExperimenterIdSerializerKey key, - OFSerializer serializer); +/* + * Copyright (c) 2014 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.extensibility; + +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + + +/** + * Provides methods for serialization part of extensibility. + * In case of handling multiple structures of same type (actions, + * instructions, match entries, ... ) which are differentiated by + * vendor / experimenter subtype, vendor has to switch / choose between + * these subtypes.
+ * + * This has to be done in this way because of unknown augmentations + * - that's why vendor has to handle it in his own implementations. + * @author michal.polkorab + */ +public interface SerializerExtensionProvider { + + /** + * Unregisters custom serializer + * @param key used for serializer lookup + * @return true if serializer was removed, + * false if no serializer was found under specified key + */ + boolean unregisterSerializer(ExperimenterSerializerKey key); + + /** + * Registers action serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerActionSerializer(ExperimenterActionSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers instruction serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerInstructionSerializer(ExperimenterInstructionSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers match entry serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMatchEntrySerializer( + MatchEntrySerializerKey key,OFGeneralSerializer serializer); + + /** + * Registers experimenter (vendor) message serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerExperimenterMessageSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); + + /** + * Registers multipart-request (stats-request) serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMultipartRequestSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); + + /** + * Registers multipart-request table-features serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMultipartRequestTFSerializer(ExperimenterIdSerializerKey key, + OFGeneralSerializer serializer); + + /** + * Registers meter band serializer (used in meter-mod messages) + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerMeterBandSerializer(ExperimenterIdSerializerKey key, + OFSerializer serializer); } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java index c0590140..30141911 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistry.java @@ -1,54 +1,54 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.api.extensibility; - - - - -/** - * Stores and handles serializers - * @author michal.polkorab - * - */ -public interface SerializerRegistry { - - /** - * Serializer registry provisioning - */ - public void init(); - - /** - * @param msgTypeKey lookup key - * @return serializer or NullPointerException if no serializer was found - */ - SERIALIZERTYPE - getSerializer(MessageTypeKey msgTypeKey); - - /** - * Registers serializer - * Throws IllegalStateException when there is - * a serializer already registered under given key. - * - * If the serializer implements {@link SerializerRegistryInjector} interface, - * the serializer is injected with SerializerRegistry instance. - * - * @param key used for serializer lookup - * @param serializer serializer implementation - */ - void registerSerializer(MessageTypeKey key, - OFGeneralSerializer serializer); - - /** - * Unregisters serializer - * @param key used for serializer lookup - * @param serializer serializer implementation - * @return true if serializer was removed, - * false if no serializer was found under specified key - */ - boolean unregisterSerializer(MessageTypeKey key); -} +/* + * 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.extensibility; + + + + +/** + * Stores and handles serializers + * @author michal.polkorab + * + */ +public interface SerializerRegistry { + + /** + * Serializer registry provisioning + */ + public void init(); + + /** + * @param msgTypeKey lookup key + * @return serializer or NullPointerException if no serializer was found + */ + SERIALIZERTYPE + getSerializer(MessageTypeKey msgTypeKey); + + /** + * Registers serializer + * Throws IllegalStateException when there is + * a serializer already registered under given key. + * + * If the serializer implements {@link SerializerRegistryInjector} interface, + * the serializer is injected with SerializerRegistry instance. + * + * @param key used for serializer lookup + * @param serializer serializer implementation + */ + void registerSerializer(MessageTypeKey key, + OFGeneralSerializer serializer); + + /** + * Unregisters serializer + * @param key used for serializer lookup + * @param serializer serializer implementation + * @return true if serializer was removed, + * false if no serializer was found under specified key + */ + boolean unregisterSerializer(MessageTypeKey key); +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java index 1204055e..b074b15f 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/extensibility/SerializerRegistryInjector.java @@ -1,22 +1,22 @@ -/* - * 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.extensibility; - -/** - * Serializer registry injector - * @author michal.polkorab - */ -public interface SerializerRegistryInjector { - - /** - * Injects serializer registry - * @param serializerRegistry registry instance - */ - void injectSerializerRegistry(SerializerRegistry serializerRegistry); - -} +/* + * 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.extensibility; + +/** + * Serializer registry injector + * @author michal.polkorab + */ +public interface SerializerRegistryInjector { + + /** + * Injects serializer registry + * @param serializerRegistry registry instance + */ + void injectSerializerRegistry(SerializerRegistry serializerRegistry); + +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java index d7363fbb..a80bd7ae 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKey.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class ActionDeserializerKey extends MessageCodeKey { - - private Long experimenterId; - /** - * @param version protocol wire version - * @param type action type - * @param experimenterId experimenter / vendor ID - */ - public ActionDeserializerKey(short version, - int type, Long experimenterId) { - super(version, type, Action.class); - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof ActionDeserializerKey)) { - return false; - } - ActionDeserializerKey other = (ActionDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 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.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerKey extends MessageCodeKey { + + private Long experimenterId; + /** + * @param version protocol wire version + * @param type action type + * @param experimenterId experimenter / vendor ID + */ + public ActionDeserializerKey(short version, + int type, Long experimenterId) { + super(version, type, Action.class); + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ActionDeserializerKey)) { + return false; + } + ActionDeserializerKey other = (ActionDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java index 4e33c56c..d1120467 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKey.java @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * @param action type - */ -public class ActionSerializerKey extends MessageTypeKey { - - private Class actionType; - private Long experimenterId; - - /** - * @param msgVersion protocol wire version - * @param actionType type of action - * @param experimenterId experimenter / vendor ID - */ - public ActionSerializerKey(short msgVersion, Class actionType, - Long experimenterId) { - super(msgVersion, Action.class); - this.actionType = actionType; - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((actionType == null) ? 0 : actionType.hashCode()); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ActionSerializerKey other = (ActionSerializerKey) obj; - if (actionType == null) { - if (other.actionType != null) { - return false; - } - } else if (!actionType.equals(other.actionType)) { - return false; - } - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 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.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * @param action type + */ +public class ActionSerializerKey extends MessageTypeKey { + + private Class actionType; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param actionType type of action + * @param experimenterId experimenter / vendor ID + */ + public ActionSerializerKey(short msgVersion, Class actionType, + Long experimenterId) { + super(msgVersion, Action.class); + this.actionType = actionType; + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((actionType == null) ? 0 : actionType.hashCode()); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ActionSerializerKey other = (ActionSerializerKey) obj; + if (actionType == null) { + if (other.actionType != null) { + return false; + } + } else if (!actionType.equals(other.actionType)) { + return false; + } + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " action type: " + actionType.getName() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java index c2160878..f7ebcb3c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKey.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class InstructionDeserializerKey extends MessageCodeKey { - - private Long experimenterId; - /** - * @param version protocol wire version - * @param type instruction type - * @param experimenterId - */ - public InstructionDeserializerKey(short version, int type, - Long experimenterId) { - super(version, type, Instruction.class); - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof InstructionDeserializerKey)) { - return false; - } - InstructionDeserializerKey other = (InstructionDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 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.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerKey extends MessageCodeKey { + + private Long experimenterId; + /** + * @param version protocol wire version + * @param type instruction type + * @param experimenterId + */ + public InstructionDeserializerKey(short version, int type, + Long experimenterId) { + super(version, type, Instruction.class); + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof InstructionDeserializerKey)) { + return false; + } + InstructionDeserializerKey other = (InstructionDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java index 7759c0bf..73d0f153 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKey.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - * @param action type - */ -public class InstructionSerializerKey - extends MessageTypeKey{ - - private Class instructionType; - private Long experimenterId; - - /** - * @param msgVersion protocol wire version - * @param objectType class of serialized object (Instruction.class) - * @param instructionType type of instruction - * @param experimenterId experimenter / vendor ID - */ - public InstructionSerializerKey(short msgVersion, Class instructionType, - Long experimenterId) { - super(msgVersion, Instruction.class); - this.instructionType = instructionType; - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - result = prime * result + ((instructionType == null) ? 0 : instructionType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof InstructionSerializerKey)) { - return false; - } - InstructionSerializerKey other = (InstructionSerializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - if (instructionType == null) { - if (other.instructionType != null) { - return false; - } - } else if (!instructionType.equals(other.instructionType)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " instructionType type: " + instructionType.getName() - + " vendorID: " + experimenterId; - } +/* + * Copyright (c) 2014 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.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * @param action type + */ +public class InstructionSerializerKey + extends MessageTypeKey{ + + private Class instructionType; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param objectType class of serialized object (Instruction.class) + * @param instructionType type of instruction + * @param experimenterId experimenter / vendor ID + */ + public InstructionSerializerKey(short msgVersion, Class instructionType, + Long experimenterId) { + super(msgVersion, Instruction.class); + this.instructionType = instructionType; + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + ((instructionType == null) ? 0 : instructionType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof InstructionSerializerKey)) { + return false; + } + InstructionSerializerKey other = (InstructionSerializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + if (instructionType == null) { + if (other.instructionType != null) { + return false; + } + } else if (!instructionType.equals(other.instructionType)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " instructionType type: " + instructionType.getName() + + " vendorID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java index d50d9fb1..ebd16ad7 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKey.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public final class MatchEntryDeserializerKey extends MessageCodeKey - implements ExperimenterDeserializerKey { - - private int oxmField; - private Long experimenterId; - - /** - * @param version protocol wire version - * @param oxmClass oxm_class (see specification) - * @param oxmField oxm_field (see specification) - */ - public MatchEntryDeserializerKey(short version, - int oxmClass, int oxmField) { - super(version, oxmClass, MatchEntries.class); - this.oxmField = oxmField; - } - - /** - * @param experimenterId experimenter / vendor ID - */ - public void setExperimenterId(Long experimenterId) { - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - result = prime * result + oxmField; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MatchEntryDeserializerKey other = (MatchEntryDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - if (oxmField != other.oxmField) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " oxm_field: " + oxmField + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 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.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterDeserializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public final class MatchEntryDeserializerKey extends MessageCodeKey + implements ExperimenterDeserializerKey { + + private int oxmField; + private Long experimenterId; + + /** + * @param version protocol wire version + * @param oxmClass oxm_class (see specification) + * @param oxmField oxm_field (see specification) + */ + public MatchEntryDeserializerKey(short version, + int oxmClass, int oxmField) { + super(version, oxmClass, MatchEntries.class); + this.oxmField = oxmField; + } + + /** + * @param experimenterId experimenter / vendor ID + */ + public void setExperimenterId(Long experimenterId) { + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + oxmField; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MatchEntryDeserializerKey other = (MatchEntryDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + if (oxmField != other.oxmField) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " oxm_field: " + oxmField + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java index 55d67e56..fddc35c6 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKey.java @@ -1,100 +1,100 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * @param oxm_class (see specification) - * @param oxm_field (see specification) - */ -public final class MatchEntrySerializerKey - extends MessageTypeKey implements ExperimenterSerializerKey { - - private Class oxmClass; - private Class oxmField; - private Long experimenterId; - - /** - * @param msgVersion protocol wire version - * @param objectType class of serialized object - * @param oxmClass oxm_class (see specification) - * @param oxmField oxm_field (see specification) - */ - public MatchEntrySerializerKey(short msgVersion, Class oxmClass, - Class oxmField) { - super(msgVersion, MatchEntries.class); - this.oxmClass = oxmClass; - this.oxmField = oxmField; - } - - /** - * @param experimenterId experimenter / vendor ID - */ - public void setExperimenterId(Long experimenterId) { - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - result = prime * result + ((oxmClass == null) ? 0 : oxmClass.hashCode()); - result = prime * result + ((oxmField == null) ? 0 : oxmField.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - if (oxmClass == null) { - if (other.oxmClass != null) { - return false; - } - } else if (!oxmClass.equals(other.oxmClass)) { - return false; - } - if (oxmField == null) { - if (other.oxmField != null) { - return false; - } - } else if (!oxmField.equals(other.oxmField)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " oxm_class: " + oxmClass.getName() + " oxm_field: " - + oxmField.getName() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 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.keys; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * @param oxm_class (see specification) + * @param oxm_field (see specification) + */ +public final class MatchEntrySerializerKey + extends MessageTypeKey implements ExperimenterSerializerKey { + + private Class oxmClass; + private Class oxmField; + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param objectType class of serialized object + * @param oxmClass oxm_class (see specification) + * @param oxmField oxm_field (see specification) + */ + public MatchEntrySerializerKey(short msgVersion, Class oxmClass, + Class oxmField) { + super(msgVersion, MatchEntries.class); + this.oxmClass = oxmClass; + this.oxmField = oxmField; + } + + /** + * @param experimenterId experimenter / vendor ID + */ + public void setExperimenterId(Long experimenterId) { + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + result = prime * result + ((oxmClass == null) ? 0 : oxmClass.hashCode()); + result = prime * result + ((oxmField == null) ? 0 : oxmField.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MatchEntrySerializerKey other = (MatchEntrySerializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + if (oxmClass == null) { + if (other.oxmClass != null) { + return false; + } + } else if (!oxmClass.equals(other.oxmClass)) { + return false; + } + if (oxmField == null) { + if (other.oxmField != null) { + return false; + } + } else if (!oxmField.equals(other.oxmField)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " oxm_class: " + oxmClass.getName() + " oxm_field: " + + oxmField.getName() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java index b700f04b..3b599b43 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKey.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey - implements ExperimenterDeserializerKey { - - /** - * @param version protocol wire version - * @param experimenterId experimenter / vendor ID - */ - public ExperimenterActionDeserializerKey(short version, Long experimenterId) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); - } - +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public final class ExperimenterActionDeserializerKey extends ActionDeserializerKey + implements ExperimenterDeserializerKey { + + /** + * @param version protocol wire version + * @param experimenterId experimenter / vendor ID + */ + public ExperimenterActionDeserializerKey(short version, Long experimenterId) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java index 45b2d02a..e5c9c806 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKey.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -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.ExperimenterActionSubType; - -/** - * @author michal.polkorab - */ -public final class ExperimenterActionSerializerKey extends ActionSerializerKey - implements ExperimenterSerializerKey { - - private Class actionSubType; - - /** - * @param msgVersion protocol wire version - * @param experimenterId experimenter / vendor ID - * @param actionSubType vendor defined subtype - */ - public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId, Class actionSubType) { - super(msgVersion, Experimenter.class, experimenterId); - this.actionSubType = actionSubType; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((actionSubType == null) ? 0 : actionSubType.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; - if (actionSubType == null) { - if (other.actionSubType != null) { - return false; - } - } else if (!actionSubType.equals(other.actionSubType)) { - return false; - } - return true; - } +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +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.ExperimenterActionSubType; + +/** + * @author michal.polkorab + */ +public final class ExperimenterActionSerializerKey extends ActionSerializerKey + implements ExperimenterSerializerKey { + + private Class actionSubType; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param actionSubType vendor defined subtype + */ + public ExperimenterActionSerializerKey(short msgVersion, Long experimenterId, Class actionSubType) { + super(msgVersion, Experimenter.class, experimenterId); + this.actionSubType = actionSubType; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((actionSubType == null) ? 0 : actionSubType.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ExperimenterActionSerializerKey other = (ExperimenterActionSerializerKey) obj; + if (actionSubType == null) { + if (other.actionSubType != null) { + return false; + } + } else if (!actionSubType.equals(other.actionSubType)) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java index 2b73858d..770a9162 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterDeserializerKey.java @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -/** - * Marker interface - marks keys appropriate for experimenter deserializer registration - * @author michal.polkorab - */ -public interface ExperimenterDeserializerKey { - // only empty marker interface - to ease extensions registration -} +/* + * Copyright (c) 2014 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.keys.experimenter; + +/** + * Marker interface - marks keys appropriate for experimenter deserializer registration + * @author michal.polkorab + */ +public interface ExperimenterDeserializerKey { + // only empty marker interface - to ease extensions registration +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java index 1682d6d3..cb00362e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKey.java @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * - */ -public final class ExperimenterIdDeserializerKey extends MessageCodeKey - implements ExperimenterDeserializerKey { - - private Long experimenterId; - - /** - * @param version protocol wire version - * @param experimenterId experimenter / vendor ID - * @param objectClass class of created object - */ - public ExperimenterIdDeserializerKey(short version, - Long experimenterId, Class objectClass) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass); - this.experimenterId = experimenterId; - } - - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof ExperimenterIdDeserializerKey)) { - return false; - } - ExperimenterIdDeserializerKey other = (ExperimenterIdDeserializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * + */ +public final class ExperimenterIdDeserializerKey extends MessageCodeKey + implements ExperimenterDeserializerKey { + + private Long experimenterId; + + /** + * @param version protocol wire version + * @param experimenterId experimenter / vendor ID + * @param objectClass class of created object + */ + public ExperimenterIdDeserializerKey(short version, + Long experimenterId, Class objectClass) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, objectClass); + this.experimenterId = experimenterId; + } + + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ExperimenterIdDeserializerKey)) { + return false; + } + ExperimenterIdDeserializerKey other = (ExperimenterIdDeserializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java index 2336e9a8..1718246c 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKey.java @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * @param class of object to be serialized - */ -public class ExperimenterIdSerializerKey extends MessageTypeKey - implements ExperimenterSerializerKey { - - private Long experimenterId; - - /** - * @param msgVersion protocol wire version - * @param experimenterId experimenter / vendor ID - * @param objectClass class of object to be serialized - */ - public ExperimenterIdSerializerKey(short msgVersion, - Long experimenterId, Class objectClass) { - super(msgVersion, objectClass); - this.experimenterId = experimenterId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (!super.equals(obj)) { - return false; - } - if (!(obj instanceof ExperimenterIdSerializerKey)) { - return false; - } - ExperimenterIdSerializerKey other = (ExperimenterIdSerializerKey) obj; - if (experimenterId == null) { - if (other.experimenterId != null) { - return false; - } - } else if (!experimenterId.equals(other.experimenterId)) { - return false; - } - return true; - } - - @Override - public String toString() { - return super.toString() + " experimenterID: " + experimenterId; - } +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * @param class of object to be serialized + */ +public class ExperimenterIdSerializerKey extends MessageTypeKey + implements ExperimenterSerializerKey { + + private Long experimenterId; + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + * @param objectClass class of object to be serialized + */ + public ExperimenterIdSerializerKey(short msgVersion, + Long experimenterId, Class objectClass) { + super(msgVersion, objectClass); + this.experimenterId = experimenterId; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((experimenterId == null) ? 0 : experimenterId.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ExperimenterIdSerializerKey)) { + return false; + } + ExperimenterIdSerializerKey other = (ExperimenterIdSerializerKey) obj; + if (experimenterId == null) { + if (other.experimenterId != null) { + return false; + } + } else if (!experimenterId.equals(other.experimenterId)) { + return false; + } + return true; + } + + @Override + public String toString() { + return super.toString() + " experimenterID: " + experimenterId; + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java index cfe99569..b15a1173 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKey.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public final class ExperimenterInstructionDeserializerKey extends InstructionDeserializerKey - implements ExperimenterDeserializerKey { - - /** - * @param version protocol wire version - * @param experimenterId - */ - public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { - super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); - } - +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public final class ExperimenterInstructionDeserializerKey extends InstructionDeserializerKey + implements ExperimenterDeserializerKey { + + /** + * @param version protocol wire version + * @param experimenterId + */ + public ExperimenterInstructionDeserializerKey(short version, Long experimenterId) { + super(version, EncodeConstants.EXPERIMENTER_VALUE, experimenterId); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java index 28201506..7d46b590 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKey.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; - -/** - * @author michal.polkorab - */ -public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey - implements ExperimenterSerializerKey { - - /** - * @param msgVersion protocol wire version - * @param experimenterId experimenter / vendor ID - */ - public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) { - super(msgVersion, Experimenter.class, experimenterId); - } - +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Experimenter; + +/** + * @author michal.polkorab + */ +public final class ExperimenterInstructionSerializerKey extends InstructionSerializerKey + implements ExperimenterSerializerKey { + + /** + * @param msgVersion protocol wire version + * @param experimenterId experimenter / vendor ID + */ + public ExperimenterInstructionSerializerKey(short msgVersion, Long experimenterId) { + super(msgVersion, Experimenter.class, experimenterId); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java index a99990fe..8ce152bc 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterSerializerKey.java @@ -1,17 +1,17 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -/** - * Marker interface - marks keys appropriate for experimenter serializer registration - * @author michal.polkorab - */ -public interface ExperimenterSerializerKey { - // only empty marker interface - to ease extensions registration -} +/* + * Copyright (c) 2014 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.keys.experimenter; + +/** + * Marker interface - marks keys appropriate for experimenter serializer registration + * @author michal.polkorab + */ +public interface ExperimenterSerializerKey { + // only empty marker interface - to ease extensions registration +} diff --git a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java index 499e95c5..3bc7558e 100644 --- a/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java +++ b/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/util/OxmMatchConstants.java @@ -1,117 +1,117 @@ -/* - * 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; - -/** - * Stores oxm_match constants - * @author michal.polkorab - * - */ -public abstract class OxmMatchConstants { - - /** Backward compatibility with NXM */ - public static final int NXM_0_CLASS = 0x0000; - /** Backward compatibility with NXM */ - public static final int NXM_1_CLASS = 0x0001; - /** Basic class for OpenFlow */ - public static final int OPENFLOW_BASIC_CLASS = 0x8000; - /** Experimenter class */ - public static final int EXPERIMENTER_CLASS = 0xFFFF; - - /** Switch input port */ - public static final int IN_PORT = 0; - /** Switch physical input port */ - public static final int IN_PHY_PORT = 1; - /** Metadata passed between tables */ - public static final int METADATA = 2; - /** Ethernet destination address */ - public static final int ETH_DST = 3; - /** Ethernet source address */ - public static final int ETH_SRC = 4; - /** Ethernet frame type */ - public static final int ETH_TYPE = 5; - /** VLAN id. */ - public static final int VLAN_VID = 6; - /** VLAN priority. */ - public static final int VLAN_PCP = 7; - /** IP DSCP (6 bits in ToS field). */ - public static final int IP_DSCP = 8; - /** IP ECN (2 bits in ToS field). */ - public static final int IP_ECN = 9; - /** IP protocol. */ - public static final int IP_PROTO = 10; - /** IPv4 source address. */ - public static final int IPV4_SRC = 11; - /** IPv4 destination address. */ - public static final int IPV4_DST = 12; - /** TCP source port. */ - public static final int TCP_SRC = 13; - /** TCP destination port. */ - public static final int TCP_DST = 14; - /** UDP source port. */ - public static final int UDP_SRC = 15; - /** UDP destination port. */ - public static final int UDP_DST = 16; - /** SCTP source port. */ - public static final int SCTP_SRC = 17; - /** SCTP destination port. */ - public static final int SCTP_DST = 18; - /** ICMP type. */ - public static final int ICMPV4_TYPE = 19; - /** ICMP code. */ - public static final int ICMPV4_CODE = 20; - /** ARP opcode. */ - public static final int ARP_OP = 21; - /** ARP source IPv4 address. */ - public static final int ARP_SPA = 22; - /** ARP target IPv4 address. */ - public static final int ARP_TPA = 23; - /** ARP source hardware address. */ - public static final int ARP_SHA = 24; - /** ARP target hardware address. */ - public static final int ARP_THA = 25; - /** IPv6 source address. */ - public static final int IPV6_SRC = 26; - /** IPv6 destination address. */ - public static final int IPV6_DST = 27; - /** IPv6 Flow Label */ - public static final int IPV6_FLABEL = 28; - /** ICMPv6 type. */ - public static final int ICMPV6_TYPE = 29; - /** ICMPv6 code. */ - public static final int ICMPV6_CODE = 30; - /** Target address for ND. */ - public static final int IPV6_ND_TARGET = 31; - /** Source link-layer for ND. */ - public static final int IPV6_ND_SLL = 32; - /** Target link-layer for ND. */ - public static final int IPV6_ND_TLL = 33; - /** MPLS label. */ - public static final int MPLS_LABEL = 34; - /** MPLS TC. */ - public static final int MPLS_TC = 35; - /** MPLS BoS bit. */ - public static final int MPLS_BOS = 36; - /** PBB I-SID. */ - public static final int PBB_ISID = 37; - /** Logical Port Metadata. */ - public static final int TUNNEL_ID = 38; - /** IPv6 Extension Header pseudo-field */ - public static final int IPV6_EXTHDR = 39; - - /** - * OFPXMC_NXM_1 class Constants - */ - - /** NXM IPv4 Tunnel Endpoint Source */ - public static final int NXM_NX_TUN_IPV4_SRC = 31; - /** NXM IPv4 Tunnel Endpoint Destination */ - public static final int NXM_NX_TUN_IPV4_DST = 32; - /** NXM TCP_Flag value */ - public static final int NXM_NX_TCP_FLAG = 34; +/* + * 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; + +/** + * Stores oxm_match constants + * @author michal.polkorab + * + */ +public abstract class OxmMatchConstants { + + /** Backward compatibility with NXM */ + public static final int NXM_0_CLASS = 0x0000; + /** Backward compatibility with NXM */ + public static final int NXM_1_CLASS = 0x0001; + /** Basic class for OpenFlow */ + public static final int OPENFLOW_BASIC_CLASS = 0x8000; + /** Experimenter class */ + public static final int EXPERIMENTER_CLASS = 0xFFFF; + + /** Switch input port */ + public static final int IN_PORT = 0; + /** Switch physical input port */ + public static final int IN_PHY_PORT = 1; + /** Metadata passed between tables */ + public static final int METADATA = 2; + /** Ethernet destination address */ + public static final int ETH_DST = 3; + /** Ethernet source address */ + public static final int ETH_SRC = 4; + /** Ethernet frame type */ + public static final int ETH_TYPE = 5; + /** VLAN id. */ + public static final int VLAN_VID = 6; + /** VLAN priority. */ + public static final int VLAN_PCP = 7; + /** IP DSCP (6 bits in ToS field). */ + public static final int IP_DSCP = 8; + /** IP ECN (2 bits in ToS field). */ + public static final int IP_ECN = 9; + /** IP protocol. */ + public static final int IP_PROTO = 10; + /** IPv4 source address. */ + public static final int IPV4_SRC = 11; + /** IPv4 destination address. */ + public static final int IPV4_DST = 12; + /** TCP source port. */ + public static final int TCP_SRC = 13; + /** TCP destination port. */ + public static final int TCP_DST = 14; + /** UDP source port. */ + public static final int UDP_SRC = 15; + /** UDP destination port. */ + public static final int UDP_DST = 16; + /** SCTP source port. */ + public static final int SCTP_SRC = 17; + /** SCTP destination port. */ + public static final int SCTP_DST = 18; + /** ICMP type. */ + public static final int ICMPV4_TYPE = 19; + /** ICMP code. */ + public static final int ICMPV4_CODE = 20; + /** ARP opcode. */ + public static final int ARP_OP = 21; + /** ARP source IPv4 address. */ + public static final int ARP_SPA = 22; + /** ARP target IPv4 address. */ + public static final int ARP_TPA = 23; + /** ARP source hardware address. */ + public static final int ARP_SHA = 24; + /** ARP target hardware address. */ + public static final int ARP_THA = 25; + /** IPv6 source address. */ + public static final int IPV6_SRC = 26; + /** IPv6 destination address. */ + public static final int IPV6_DST = 27; + /** IPv6 Flow Label */ + public static final int IPV6_FLABEL = 28; + /** ICMPv6 type. */ + public static final int ICMPV6_TYPE = 29; + /** ICMPv6 code. */ + public static final int ICMPV6_CODE = 30; + /** Target address for ND. */ + public static final int IPV6_ND_TARGET = 31; + /** Source link-layer for ND. */ + public static final int IPV6_ND_SLL = 32; + /** Target link-layer for ND. */ + public static final int IPV6_ND_TLL = 33; + /** MPLS label. */ + public static final int MPLS_LABEL = 34; + /** MPLS TC. */ + public static final int MPLS_TC = 35; + /** MPLS BoS bit. */ + public static final int MPLS_BOS = 36; + /** PBB I-SID. */ + public static final int PBB_ISID = 37; + /** Logical Port Metadata. */ + public static final int TUNNEL_ID = 38; + /** IPv6 Extension Header pseudo-field */ + public static final int IPV6_EXTHDR = 39; + + /** + * OFPXMC_NXM_1 class Constants + */ + + /** NXM IPv4 Tunnel Endpoint Source */ + public static final int NXM_NX_TUN_IPV4_SRC = 31; + /** NXM IPv4 Tunnel Endpoint Destination */ + public static final int NXM_NX_TUN_IPV4_DST = 32; + /** NXM TCP_Flag value */ + public static final int NXM_NX_TCP_FLAG = 34; } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang index a2e69293..9a545416 100644 --- a/openflow-protocol-api/src/main/yang/openflow-augments.yang +++ b/openflow-protocol-api/src/main/yang/openflow-augments.yang @@ -1,407 +1,407 @@ -/* - * 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 - */ - - module openflow-augments { - namespace "urn:opendaylight:openflow:augments"; - prefix "aug"; - - import yang-ext {prefix ext;} - import ietf-inet-types {prefix inet;} - import ietf-yang-types {prefix yang;} - - import openflow-types {prefix oft;} - import openflow-protocol {prefix ofproto;} - import openflow-action {prefix ofaction;} - import openflow-instruction {prefix ofinstruction;} - import openflow-extensible-match {prefix oxm;} - - revision "2013-10-02" { - description "OpenFlow 1.3 - augments model. - Please visit - https://wiki.opendaylight.org/view/File:OpenFlow_Protocol_Library_-_Project_documentation.pdf - - Augmentation Tables chapter"; - } - -// OFP_MATCH AUGMENTS - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "port-number-match-entry"; - leaf port-number { - type oft:port-number; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "metadata-match-entry"; - leaf metadata { - type binary; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mask-match-entry"; - leaf mask { - type binary; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mac-address-match-entry"; - leaf mac-address { - type yang:mac-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "eth-type-match-entry"; - leaf eth-type { - type oft:ether-type; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "vlan-vid-match-entry"; - leaf vlan-vid { - type uint16; - } - leaf cfi-bit { - type boolean; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "vlan-pcp-match-entry"; - leaf vlan-pcp { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "dscp-match-entry"; - leaf dscp { - type inet:dscp; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ecn-match-entry"; - leaf ecn { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "protocol-number-match-entry"; - leaf protocol-number { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "port-match-entry"; - leaf port { - type inet:port-number; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv4-type-match-entry"; - leaf icmpv4-type { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv4-code-match-entry"; - leaf icmpv4-code { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "op-code-match-entry"; - leaf op-code { - type uint16; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv6-flabel-match-entry"; - leaf ipv6-flabel { - type inet:ipv6-flow-label; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv6-type-match-entry"; - leaf icmpv6-type { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "icmpv6-code-match-entry"; - leaf icmpv6-code { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv6-address-match-entry"; - leaf ipv6-address { - type inet:ipv6-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "ipv4-address-match-entry"; - leaf ipv4-address { - type inet:ipv4-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "mpls-label-match-entry"; - leaf mpls-label { - type uint32; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tc-match-entry"; - leaf tc { - type uint8; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "bos-match-entry"; - leaf bos { - type boolean; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "isid-match-entry"; - leaf isid { - type uint32; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "pseudo-field-match-entry"; - leaf pseudo-field { - type oft:ipv6-exthdr-flags; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "experimenter-id-match-entry"; - leaf experimenter { - type oft:experimenter-id; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tcp-flag-match-entry"; - leaf tcp-flag { - type uint16; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tunnel-ipv4-dst-match-entry"; - leaf tunnel-ipv4-dst { - type inet:ipv4-address; - } - } - augment "/oxm:oxm-container/oxm:match-entries" { - ext:augment-identifier "tunnel-ipv4-src-match-entry"; - leaf tunnel-ipv4-src { - type inet:ipv4-address; - } - } - -// OFP_ACTION AUGMENTS - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "port-action"; - leaf port { - type oft:port-number; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "max-length-action"; - leaf max-length { - type uint16; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "mpls-ttl-action"; - leaf mpls-ttl { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "ethertype-action"; - leaf ethertype { - type oft:ether-type; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "queue-id-action"; - leaf queue-id { - type uint32; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "group-id-action"; - leaf group-id { - type uint32; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "nw-ttl-action"; - leaf nw-ttl { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "oxm-fields-action"; - uses oxm:oxm-fields-grouping; - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "experimenter-id-action"; - leaf experimenter { - type oft:experimenter-id; - } - leaf sub-type { - type identityref { - base ofaction:experimenter-action-sub-type; - } - } - } - // OF1.0 structures - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "vlan-vid-action"; - leaf vlan-vid { - type uint16; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "vlan-pcp-action"; - leaf vlan-pcp { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "dl-address-action"; - leaf dl-address { - type yang:mac-address; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "nw-tos-action"; - leaf nw-tos { - type uint8; - } - } - augment "/ofaction:actions-container/ofaction:action" { - ext:augment-identifier "ip-address-action"; - leaf ip-address { - type inet:ipv4-address; - } - } - -// OFP_TABLE_FEATURES_PROPERTIES AUGMENTS - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "instruction-related-table-feature-property"; - uses ofinstruction:instructions-grouping; - } - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "next-table-related-table-feature-property"; - list next-table-ids { - config false; - leaf table-id { - type uint8; - } - } - } - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "action-related-table-feature-property"; - uses ofaction:actions-grouping; - } - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "oxm-related-table-feature-property"; - uses oxm:oxm-fields-grouping; - } - augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { - ext:augment-identifier "experimenter-id-table-feature-property"; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - } - -// OFP_INSTRUCTION AUGMENTS - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "table-id-instruction"; - leaf table-id { - type uint8; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "metadata-instruction"; - leaf metadata { - type binary; - } - leaf metadata-mask { - type binary; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "actions-instruction"; - uses ofaction:actions-grouping; - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "meter-id-instruction"; - leaf meter-id { - type uint32; - } - } - augment "/ofinstruction:instruction-container/ofinstruction:instruction" { - ext:augment-identifier "experimenter-id-instruction"; - leaf experimenter { - type oft:experimenter-id; - } - } - -// OFP_QUEUE_PROP AUGMENTS - augment "/ofproto:queue-prop-container/ofproto:queue-property" { - ext:augment-identifier "rate-queue-property"; - leaf rate { - type uint16; - } - } - augment "/ofproto:queue-prop-container/ofproto:queue-property" { - ext:augment-identifier "experimenter-id-queue-property"; - leaf experimenter { - type oft:experimenter-id; - } - } - -// OFP_ERROR_AUGMENTS (only experimenter till OpenFlow v1.3) - augment "/ofproto:error-message" { - ext:augment-identifier "experimenter-id-error"; - leaf experimenter { - type oft:experimenter-id; - } - } - -// OFP_MULTIPART AUGMENTS - augment "/ofproto:multipart-request/input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" { - ext:augment-identifier "experimenter-id-multipart-request"; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - } - augment "/ofproto:multipart-reply-message/ofproto:multipart-reply-body/ofproto:multipart-reply-experimenter-case/ofproto:multipart-reply-experimenter" { - ext:augment-identifier "experimenter-id-multipart-reply"; - leaf experimenter { - type oft:experimenter-id; - } - leaf exp-type { - type uint32; - } - } - -// OFP_METER_BAND AUGMENTS - augment "/ofproto:meter-band-container/ofproto:meter-band/ofproto:meter-band-experimenter-case/ofproto:meter-band-experimenter" { - ext:augment-identifier "experimenter-id-meter-band"; - leaf experimenter { - type oft:experimenter-id; - } - } +/* + * 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 + */ + + module openflow-augments { + namespace "urn:opendaylight:openflow:augments"; + prefix "aug"; + + import yang-ext {prefix ext;} + import ietf-inet-types {prefix inet;} + import ietf-yang-types {prefix yang;} + + import openflow-types {prefix oft;} + import openflow-protocol {prefix ofproto;} + import openflow-action {prefix ofaction;} + import openflow-instruction {prefix ofinstruction;} + import openflow-extensible-match {prefix oxm;} + + revision "2013-10-02" { + description "OpenFlow 1.3 - augments model. + Please visit + https://wiki.opendaylight.org/view/File:OpenFlow_Protocol_Library_-_Project_documentation.pdf + - Augmentation Tables chapter"; + } + +// OFP_MATCH AUGMENTS + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "port-number-match-entry"; + leaf port-number { + type oft:port-number; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "metadata-match-entry"; + leaf metadata { + type binary; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "mask-match-entry"; + leaf mask { + type binary; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "mac-address-match-entry"; + leaf mac-address { + type yang:mac-address; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "eth-type-match-entry"; + leaf eth-type { + type oft:ether-type; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "vlan-vid-match-entry"; + leaf vlan-vid { + type uint16; + } + leaf cfi-bit { + type boolean; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "vlan-pcp-match-entry"; + leaf vlan-pcp { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "dscp-match-entry"; + leaf dscp { + type inet:dscp; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "ecn-match-entry"; + leaf ecn { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "protocol-number-match-entry"; + leaf protocol-number { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "port-match-entry"; + leaf port { + type inet:port-number; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "icmpv4-type-match-entry"; + leaf icmpv4-type { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "icmpv4-code-match-entry"; + leaf icmpv4-code { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "op-code-match-entry"; + leaf op-code { + type uint16; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "ipv6-flabel-match-entry"; + leaf ipv6-flabel { + type inet:ipv6-flow-label; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "icmpv6-type-match-entry"; + leaf icmpv6-type { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "icmpv6-code-match-entry"; + leaf icmpv6-code { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "ipv6-address-match-entry"; + leaf ipv6-address { + type inet:ipv6-address; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "ipv4-address-match-entry"; + leaf ipv4-address { + type inet:ipv4-address; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "mpls-label-match-entry"; + leaf mpls-label { + type uint32; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "tc-match-entry"; + leaf tc { + type uint8; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "bos-match-entry"; + leaf bos { + type boolean; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "isid-match-entry"; + leaf isid { + type uint32; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "pseudo-field-match-entry"; + leaf pseudo-field { + type oft:ipv6-exthdr-flags; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "experimenter-id-match-entry"; + leaf experimenter { + type oft:experimenter-id; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "tcp-flag-match-entry"; + leaf tcp-flag { + type uint16; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "tunnel-ipv4-dst-match-entry"; + leaf tunnel-ipv4-dst { + type inet:ipv4-address; + } + } + augment "/oxm:oxm-container/oxm:match-entries" { + ext:augment-identifier "tunnel-ipv4-src-match-entry"; + leaf tunnel-ipv4-src { + type inet:ipv4-address; + } + } + +// OFP_ACTION AUGMENTS + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "port-action"; + leaf port { + type oft:port-number; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "max-length-action"; + leaf max-length { + type uint16; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "mpls-ttl-action"; + leaf mpls-ttl { + type uint8; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "ethertype-action"; + leaf ethertype { + type oft:ether-type; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "queue-id-action"; + leaf queue-id { + type uint32; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "group-id-action"; + leaf group-id { + type uint32; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "nw-ttl-action"; + leaf nw-ttl { + type uint8; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "oxm-fields-action"; + uses oxm:oxm-fields-grouping; + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "experimenter-id-action"; + leaf experimenter { + type oft:experimenter-id; + } + leaf sub-type { + type identityref { + base ofaction:experimenter-action-sub-type; + } + } + } + // OF1.0 structures + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "vlan-vid-action"; + leaf vlan-vid { + type uint16; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "vlan-pcp-action"; + leaf vlan-pcp { + type uint8; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "dl-address-action"; + leaf dl-address { + type yang:mac-address; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "nw-tos-action"; + leaf nw-tos { + type uint8; + } + } + augment "/ofaction:actions-container/ofaction:action" { + ext:augment-identifier "ip-address-action"; + leaf ip-address { + type inet:ipv4-address; + } + } + +// OFP_TABLE_FEATURES_PROPERTIES AUGMENTS + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "instruction-related-table-feature-property"; + uses ofinstruction:instructions-grouping; + } + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "next-table-related-table-feature-property"; + list next-table-ids { + config false; + leaf table-id { + type uint8; + } + } + } + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "action-related-table-feature-property"; + uses ofaction:actions-grouping; + } + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "oxm-related-table-feature-property"; + uses oxm:oxm-fields-grouping; + } + augment "/ofproto:table-features-properties-container/ofproto:table-feature-properties" { + ext:augment-identifier "experimenter-id-table-feature-property"; + leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { + type uint32; + } + } + +// OFP_INSTRUCTION AUGMENTS + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "table-id-instruction"; + leaf table-id { + type uint8; + } + } + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "metadata-instruction"; + leaf metadata { + type binary; + } + leaf metadata-mask { + type binary; + } + } + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "actions-instruction"; + uses ofaction:actions-grouping; + } + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "meter-id-instruction"; + leaf meter-id { + type uint32; + } + } + augment "/ofinstruction:instruction-container/ofinstruction:instruction" { + ext:augment-identifier "experimenter-id-instruction"; + leaf experimenter { + type oft:experimenter-id; + } + } + +// OFP_QUEUE_PROP AUGMENTS + augment "/ofproto:queue-prop-container/ofproto:queue-property" { + ext:augment-identifier "rate-queue-property"; + leaf rate { + type uint16; + } + } + augment "/ofproto:queue-prop-container/ofproto:queue-property" { + ext:augment-identifier "experimenter-id-queue-property"; + leaf experimenter { + type oft:experimenter-id; + } + } + +// OFP_ERROR_AUGMENTS (only experimenter till OpenFlow v1.3) + augment "/ofproto:error-message" { + ext:augment-identifier "experimenter-id-error"; + leaf experimenter { + type oft:experimenter-id; + } + } + +// OFP_MULTIPART AUGMENTS + augment "/ofproto:multipart-request/input/ofproto:multipart-request-body/ofproto:multipart-request-experimenter-case/ofproto:multipart-request-experimenter" { + ext:augment-identifier "experimenter-id-multipart-request"; + leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { + type uint32; + } + } + augment "/ofproto:multipart-reply-message/ofproto:multipart-reply-body/ofproto:multipart-reply-experimenter-case/ofproto:multipart-reply-experimenter" { + ext:augment-identifier "experimenter-id-multipart-reply"; + leaf experimenter { + type oft:experimenter-id; + } + leaf exp-type { + type uint32; + } + } + +// OFP_METER_BAND AUGMENTS + augment "/ofproto:meter-band-container/ofproto:meter-band/ofproto:meter-band-experimenter-case/ofproto:meter-band-experimenter" { + ext:augment-identifier "experimenter-id-meter-band"; + leaf experimenter { + type oft:experimenter-id; + } + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-configuration.yang b/openflow-protocol-api/src/main/yang/openflow-configuration.yang index 8a1f8bbc..38d8d58b 100644 --- a/openflow-protocol-api/src/main/yang/openflow-configuration.yang +++ b/openflow-protocol-api/src/main/yang/openflow-configuration.yang @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2014 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 - */ - - module openflow-configuration { - namespace "urn:opendaylight:openflow:config"; - prefix "of-config"; - - revision "2014-06-30" { - description "Library configuration classes"; - } - - typedef path-type { - type enumeration { - enum CLASSPATH { - value 0; - description "Keystore file is located on classpath."; - } - enum PATH { - value 1; - description "Keystore file is located on absolute or relative path."; - } - } - } - - typedef keystore-type { - type enumeration { - enum JKS { - value 0; - description "Keystore type - JKS."; - } - enum PKCS12 { - value 1; - description "Keystore type - PKCS12."; - } - } - } - - typedef transport-protocol { - type enumeration { - enum TCP { - value 0; - description "Communication over TCP protocol."; - } - enum TLS { - value 1; - description "Communication over TLS protocol."; - } - enum UDP { - value 2; - description "Communication over UDP protocol."; - } - } - } +/* + * Copyright (c) 2014 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 + */ + + module openflow-configuration { + namespace "urn:opendaylight:openflow:config"; + prefix "of-config"; + + revision "2014-06-30" { + description "Library configuration classes"; + } + + typedef path-type { + type enumeration { + enum CLASSPATH { + value 0; + description "Keystore file is located on classpath."; + } + enum PATH { + value 1; + description "Keystore file is located on absolute or relative path."; + } + } + } + + typedef keystore-type { + type enumeration { + enum JKS { + value 0; + description "Keystore type - JKS."; + } + enum PKCS12 { + value 1; + description "Keystore type - PKCS12."; + } + } + } + + typedef transport-protocol { + type enumeration { + enum TCP { + value 0; + description "Communication over TCP protocol."; + } + enum TLS { + value 1; + description "Communication over TLS protocol."; + } + enum UDP { + value 2; + description "Communication over UDP protocol."; + } + } + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/main/yang/openflow-protocol.yang b/openflow-protocol-api/src/main/yang/openflow-protocol.yang index 32070d14..9330fac6 100644 --- a/openflow-protocol-api/src/main/yang/openflow-protocol.yang +++ b/openflow-protocol-api/src/main/yang/openflow-protocol.yang @@ -1,1429 +1,1429 @@ -/* - * 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 - */ - - module openflow-protocol { - namespace "urn:opendaylight:openflow:protocol"; - prefix "ofproto"; - - import ietf-yang-types {prefix yang;} - - import openflow-types {prefix oft;} - import openflow-extensible-match { prefix oxm;} - import openflow-instruction { prefix ofinstruction;} - import openflow-action {prefix ofaction;} - - revision "2013-07-31" { - description "OpenFlow 1.3 - protocol objects model"; - } - - // Generic Structures - grouping port-grouping { - reference "ofp_port"; - leaf port-no { - type uint32; - } - leaf hw-addr { - type yang:mac-address; - } - leaf name { - type string; - } - leaf config { - description "Bitmap of OFPPC_* flags."; - type oft:port-config; - } - leaf state { - description "Bitmap of OFPPS_* flags."; - type oft:port-state; - } - leaf current-features { - description "Current features."; - type oft:port-features; - } - leaf advertised-features { - description "Features being advertised by the port."; - type oft:port-features; - } - leaf supported-features { - description "Features supported by the port."; - type oft:port-features; - } - leaf peer-features { - description "Features advertised by peer."; - type oft:port-features; - } - leaf curr-speed { - description "Current port bitrate in kbps."; - type uint32; - units "kbps"; - } - leaf max-speed { - description "Max port bitrate in kbps"; - type uint32; - units "kbps"; - } - - // OF1.0 structures - leaf config-v10 { - type oft:port-config-v10; - } - leaf state-v10 { - type oft:port-state-v10; - } - leaf current-features-v10 { - description "Current features."; - type oft:port-features-v10; - } - leaf advertised-features-v10 { - description "Features being advertised by the port."; - type oft:port-features-v10; - } - leaf supported-features-v10 { - description "Features supported by the port."; - type oft:port-features-v10; - } - leaf peer-features-v10 { - description "Features advertised by peer."; - type oft:port-features-v10; - } - } - - grouping buckets-grouping { - list buckets-list { - uses bucket-grouping; - } - } - - grouping bucket-grouping { - description "Bucket for use in groups."; - leaf weight { - description "Relative weight of bucket. Only - defined for select groups."; - type uint16; - } - leaf watch-port { - description "Port whose state affects whether this - bucket is live. Only required for fast - failover groups."; - type oft:port-number; - } - leaf watch-group { - description "Group whose state affects whether this - bucket is live. Only required for fast - failover groups."; - type uint32; - } - - uses ofaction:actions-grouping; - } - - container table-features-properties-container { - uses table-features-properties-grouping; - } - - grouping table-features-properties-grouping { - list table-feature-properties { - config false; - leaf type { - type oft:table-features-prop-type; - } - } - } - - // # MESSAGE Structures - /* Immutable messages. */ - grouping ofHeader { - reference "ofp_header struct in Openflow Switch 1.3 Spec"; - leaf version { - type uint8; - description "OpenFlow version"; - } - leaf xid { - type uint32; - description "Transaction ID"; - } - } - grouping ofHelloElementHeader { - reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec"; - leaf type { - type oft:hello-element-type; - //reference "OpenFlow Header element type - OFPHET_*"; - } - } - grouping hello { - reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - list elements { - uses ofHelloElementHeader; - - leaf-list version-bitmap { - type boolean; - } - } - } - grouping error { - reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - leaf type { - type uint16; - } - leaf code { - type uint16; - } - leaf type-string { - type string; - } - leaf code-string { - type string; - } - leaf data { - type binary; - } - } - grouping echo-request { - reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - leaf data { - type binary; - } - } - grouping echo-reply { - reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - leaf data { - type binary; - } - } - grouping experimenter { - reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; - /* Symmetric message */ - uses ofHeader; - - leaf experimenter { - type oft:experimenter-id; - } - leaf exp_type { - type uint32; - } - } - /* Switch configuration messages. */ - grouping features-request { - reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - } - grouping features-reply { - reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - - leaf datapathId { - type uint64; - } - leaf buffers { - type uint32; - } - leaf tables { - type uint8; - } - leaf auxiliaryId { - type uint8; - } - leaf capabilities { - type oft:capabilities; - } - leaf reserved { - type uint32; - } - // OF1.0 structures - leaf capabilities-v10 { - type oft:capabilities-v10; - } - leaf actions-v10 { - type oft:action-type-v10; - } - list phy-port { - uses port-grouping; - } - } - grouping get-config-request { - reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - } - grouping get-config-reply { - reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - - leaf flags { - type oft:switch-config-flag; - } - leaf miss-send-len { - type uint16; - } - } - grouping set-config { - reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf flags { - type oft:switch-config-flag; - } - leaf miss-send-len { - type uint16; - } - } - /* Asynchronous messages. */ - grouping packet-in { - reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"; - /* Async message */ - - uses ofHeader; - - leaf buffer-id { - // ID assigned by datapath. - type uint32; - } - leaf total-len { - // Full length of frame. - type uint16; - } - leaf reason { - // Reason packet is being sent (one of OFPR_*) - type oft:packet-in-reason; - } - leaf table-id { - // ID of the table that was looked up - type oft:table-id; - } - leaf cookie { - // Cookie of the flow entry that was looked up. - type uint64; - } - uses oxm:match-grouping; - - leaf data { - type binary; - } - - // OF1.0 structures - leaf in-port { - type uint16; - } - } - grouping flow-removed { - reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"; - /* Async message */ - uses ofHeader; - - leaf cookie { - type uint64; - } - leaf priority { - type uint16; - } - leaf reason { - type oft:flow-removed-reason; - } - leaf table-id { - type oft:table-id; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - leaf idle-timeout { - type uint16; - } - leaf hard-timeout { - type uint16; - } - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - uses oxm:match-grouping; - - // OF1.0 structures - uses oxm:match-v10-grouping; - } - grouping port-status { - reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"; - - uses ofHeader; - - uses port-grouping; - - leaf reason { - type oft:port-reason; - } - } - /* Controller command messages. */ - grouping packet-out { - reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - uses ofaction:actions-grouping; - - leaf data { - type binary; - } - leaf buffer-id { - type uint32; - } - leaf in-port { - type oft:port-number; - } - } - grouping flow-mod { - reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf cookie { - type uint64; - } - leaf cookie-mask { - type uint64; - } - leaf table-id { - type oft:table-id; - } - leaf command { - type oft:flow-mod-command; - } - leaf idle-timeout { - type uint16; - } - leaf hard-timeout { - type uint16; - } - leaf priority { - type uint16; - } - leaf buffer-id { - type uint32; - } - leaf out-port { - type oft:port-number; - } - leaf out-group { - type uint32; - } - leaf flags { - type oft:flow-mod-flags; - } - uses oxm:match-grouping; - - uses ofinstruction:instructions-grouping; - - // OF1.0 structures - leaf flags-v10 { - type oft:flow-mod-flags-v10; - } - uses oxm:match-v10-grouping; - uses ofaction:actions-grouping; - } - grouping group-mod { - reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf command { - type oft:group-mod-command; - } - leaf type { - type oft:group-type; - } - leaf group-id { - type oft:group-id; - } - - uses buckets-grouping; - } - - grouping port-mod { - reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf port-no { - type oft:port-number; - } - leaf hw-address { - type yang:mac-address; - } - leaf config { - type oft:port-config; - } - leaf mask { - type oft:port-config; - } - leaf advertise { - type oft:port-features; - } - // OF1.0 structures - leaf config-v10 { - type oft:port-config-v10; - } - leaf mask-v10 { - type oft:port-config-v10; - } - leaf advertise-v10 { - type oft:port-features-v10; - } - } - grouping table-mod { - reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf table-id { - type oft:table-id; - } - leaf config { - type oft:table-config; - } - } - - /* Multipart messages. */ - grouping multipart-request { - reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf type { - type oft:multipart-type; - } - leaf flags { - type oft:multipart-request-flags; - } - choice multipart-request-body { - case multipart-request-desc-case { - container multipart-request-desc { - leaf empty { - type empty; - } - } - } - case multipart-request-flow-case { - container multipart-request-flow { - leaf table-id { - type uint8; - } - leaf out-port { - type uint32; - } - leaf out-group { - type uint32; - } - leaf cookie { - type uint64; - } - leaf cookie-mask { - type uint64; - } - uses oxm:match-grouping; - - // OF1.0 structures - uses oxm:match-v10-grouping; - } - } - case multipart-request-aggregate-case { - container multipart-request-aggregate { - leaf table-id { - type uint8; - } - leaf out-port { - type uint32; - } - leaf out-group { - type uint32; - } - leaf cookie { - type uint64; - } - leaf cookie-mask { - type uint64; - } - uses oxm:match-grouping; - - // OF1.0 structures - uses oxm:match-v10-grouping; - } - } - case multipart-request-table-case { - container multipart-request-table { - leaf empty { - type empty; - } - } - } - case multipart-request-port-stats-case { - container multipart-request-port-stats { - leaf port-no { - type uint32; - } - } - } - case multipart-request-queue-case { - container multipart-request-queue { - leaf port-no { - type uint32; - } - leaf queue-id { - type uint32; - } - } - } - case multipart-request-group-case { - container multipart-request-group { - leaf group-id { - type oft:group-id; - } - } - } - case multipart-request-group-desc-case { - container multipart-request-group-desc { - leaf empty { - type empty; - } - } - } - case multipart-request-group-features-case { - container multipart-request-group-features { - leaf empty { - type empty; - } - } - } - case multipart-request-meter-case { - container multipart-request-meter { - leaf meter-id { - type oft:meter-id; - } - } - } - case multipart-request-meter-config-case { - container multipart-request-meter-config { - leaf meter-id { - type oft:meter-id; - } - } - } - case multipart-request-meter-features-case { - container multipart-request-meter-features { - leaf empty { - type empty; - } - } - } - case multipart-request-table-features-case { - container multipart-request-table-features { - list table-features { - leaf table-id { - type uint8; - } - leaf name { - type string; - } - leaf metadata-match { - type uint64; - } - leaf metadata-write { - type uint64; - } - leaf config { - type oft:table-config; - } - leaf max-entries { - type uint32; - } - uses table-features-properties-grouping; - } - } - } - case multipart-request-port-desc-case { - container multipart-request-port-desc { - leaf empty { - type empty; - } - } - } - case multipart-request-experimenter-case { - container multipart-request-experimenter { - // empty body - used for experimenter augmentation - } - } - } - } - grouping multipart-reply { - reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf type { - type oft:multipart-type; - } - leaf flags { - type oft:multipart-request-flags; - } - choice multipart-reply-body { - case multipart-reply-desc-case { - container multipart-reply-desc { - leaf mfr_desc { - type string; - } - leaf hw_desc { - type string; - } - leaf sw_desc { - type string; - } - leaf serial_num { - type string; - } - leaf dp_desc { - type string; - } - } - } - case multipart-reply-flow-case { - container multipart-reply-flow { - list flow-stats { - leaf table-id { - type uint8; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - leaf priority { - type uint16; - } - leaf idle-timeout { - type uint16; - } - leaf hard-timeout { - type uint16; - } - leaf flags { - type oft:flow-mod-flags; - } - leaf cookie { - type uint64; - } - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - uses oxm:match-grouping; - - uses ofinstruction:instructions-grouping; - - // OF1.0 structures - uses oxm:match-v10-grouping; - uses ofaction:actions-grouping; - } - } - } - case multipart-reply-aggregate-case { - container multipart-reply-aggregate { - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - leaf flow-count { - type uint32; - } - } - } - case multipart-reply-table-case { - container multipart-reply-table { - list table-stats { - leaf table-id { - type uint8; - } - leaf active-count { - type uint32; - } - leaf lookup-count { - type uint64; - } - leaf matched-count { - type uint64; - } - - // OF1.0 structures - leaf name { - type string; - } - leaf wildcards { - type oft:flow-wildcards-v10; - } - leaf nw-src-mask { - type uint8; - } - leaf nw-dst-mask { - type uint8; - } - leaf max-entries { - type uint32; - } - } - } - } - case multipart-reply-port-stats-case { - container multipart-reply-port-stats { - list port-stats { - leaf port-no { - type uint32; - } - leaf rx-packets { - type uint64; - } - leaf tx-packets { - type uint64; - } - leaf rx-bytes { - type uint64; - } - leaf tx-bytes { - type uint64; - } - leaf rx-dropped { - type uint64; - } - leaf tx-dropped { - type uint64; - } - leaf rx-errors { - type uint64; - } - leaf tx-errors { - type uint64; - } - leaf rx-frame-err { - type uint64; - } - leaf rx-over-err { - type uint64; - } - leaf rx-crc-err { - type uint64; - } - leaf collisions { - type uint64; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - } - } - } - case multipart-reply-queue-case { - container multipart-reply-queue { - list queue-stats { - leaf port-no { - type uint32; - } - leaf queue-id { - type uint32; - } - leaf tx-bytes { - type uint64; - } - leaf tx-packets { - type uint64; - } - leaf tx-errors { - type uint64; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - } - } - } - case multipart-reply-group-case { - container multipart-reply-group { - list group-stats { - leaf group-id { - type oft:group-id; - } - leaf ref-count { - type uint32; - } - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - list bucket-stats { - leaf packet-count { - type uint64; - } - leaf byte-count { - type uint64; - } - } - } - } - } - case multipart-reply-group-desc-case { - container multipart-reply-group-desc { - list group-desc { - leaf type { - type oft:group-type; - } - leaf group-id { - type oft:group-id; - } - uses buckets-grouping; - } - } - } - case multipart-reply-group-features-case { - container multipart-reply-group-features { - leaf types { - type oft:group-types; - } - leaf capabilities { - type oft:group-capabilities; - } - leaf-list max_groups { - type uint32; - } - leaf-list actions-bitmap { - type oft:action-type; - } - } - } - case multipart-reply-meter-case { - container multipart-reply-meter { - list meter-stats { - leaf meter-id { - type oft:meter-id; - } - leaf flow-count { - type uint32; - } - leaf packet-in-count { - type uint64; - } - leaf byte-in-count { - type uint64; - } - leaf duration-sec { - type uint32; - } - leaf duration-nsec { - type uint32; - } - list meter-band-stats { - leaf packet-band-count { - type uint64; - } - leaf byte-band-count { - type uint64; - } - } - } - } - } - case multipart-reply-meter-config-case { - container multipart-reply-meter-config { - list meter-config { - leaf flags { - type oft:meter-flags; - } - leaf meter-id { - type oft:meter-id; - } - list bands { - uses meter-band-header; - } - } - } - } - case multipart-reply-meter-features-case { - container multipart-reply-meter-features { - leaf max-meter { - type uint32; - } - leaf band-types { - type oft:meter-band-type-bitmap; - } - leaf capabilities { - type oft:meter-flags; - } - leaf max-bands { - type uint8; - } - leaf max-color { - type uint8; - } - } - } - case multipart-reply-table-features-case { - container multipart-reply-table-features { - list table-features { - leaf table-id { - type uint8; - } - leaf name { - type string; - } - leaf metadata-match { - type binary; - } - leaf metadata-write { - type binary; - } - leaf config { - type oft:table-config; - } - leaf max-entries { - type uint32; - } - uses table-features-properties-grouping; - } - } - } - case multipart-reply-port-desc-case { - container multipart-reply-port-desc { - list ports { - uses port-grouping; - } - } - } - case multipart-reply-experimenter-case { - container multipart-reply-experimenter { - // empty body - used for experimenter augmentation - } - } - } - } - /* Barrier messages. */ - grouping barrier-request { - reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - } - grouping barrier-reply { - reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - uses ofHeader; - } - /* Queue Configuration messages. */ - grouping queue-get-config-request { - reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf port { - type oft:port-number; - } - } - grouping queue-get-config-reply { - reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf port { - type oft:port-number; - } - list queues { - uses packet-queue; - } - } - grouping packet-queue { - leaf queue-id { - type oft:queue-id; - } - leaf port { - type oft:port-number; - } - uses queue-property-header; - } - container queue-prop-container { - uses queue-property-header; - } - grouping queue-property-header { - list queue-property { - config false; - leaf property { - type oft:queue-properties; - } - } - } - /* Controller role change request messages. */ - grouping role-request { - reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf role { - type oft:controller-role; - } - leaf generation-id { - type uint64; - } - } - grouping role-reply { - reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf role { - type oft:controller-role; - } - leaf generation-id { - type uint64; - } - } - /* Asynchronous message configuration. */ - grouping get-async-request { - reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - } - grouping get-async-reply { - reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - uses async-body-grouping; - } - grouping set-async { - reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - uses async-body-grouping; - } - - grouping async-body-grouping { - list packet-in-mask { - leaf-list mask { - type oft:packet-in-reason; - } - } - list port-status-mask { - leaf-list mask { - type oft:port-reason; - } - } - list flow-removed-mask { - leaf-list mask { - type oft:flow-removed-reason; - } - } - } - /* Meters and rate limiters configuration messages. */ - grouping meter-mod { - reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"; - /* Controller/switch message */ - - uses ofHeader; - - leaf command { - type oft:meter-mod-command; - } - leaf flags { - type oft:meter-flags; - } - leaf meter-id { - type oft:meter-id; - } - list bands { - uses meter-band-header; - } - } - - container meter-band-container { - uses meter-band-header; - } - grouping meter-band-header { - choice meter-band { - case meter-band-drop-case { - container meter-band-drop { - uses meter-band-commons; - } - } - case meter-band-dscp-remark-case { - container meter-band-dscp-remark { - uses meter-band-commons; - leaf prec-level { - type uint8; - } - } - } - case meter-band-experimenter-case { - container meter-band-experimenter { - uses meter-band-commons; - } - } - } - } - - grouping meter-band-commons { - leaf type { - type oft:meter-band-type; - } - leaf rate { - type uint32; - } - leaf burst-size { - type uint32; - } - } - - /* Immutable messages. */ - notification hello-message { - uses hello; - reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; - - /* Symmetric message */ - } - notification error-message { - uses error; - reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; - - /* Symmetric message */ - } - notification echo-request-message { - uses echo-request; - reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; - - /* Symmetric message */ - } - notification experimenter-message { - uses experimenter; - reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; - // TODO:: does switch send this when understood experimenter msg from lib? - /* Symmetric message */ - } - // # Notification and RPCs - /* Symmetric RPC. */ - rpc echo { - input { - uses echo-request; - } - /* Controller/switch message */ - output { - uses echo-reply; - } - } - - rpc echo-reply { - input { - uses echo-reply; - } - } - - rpc hello { - input { - uses hello; - } - } - - rpc experimenter { - input { - uses experimenter; - } - } - - /* Switch configuration messages. */ - rpc get-features { - input { - uses features-request; - } - /* Controller/switch message */ - output { - uses features-reply; - } - } - - rpc get-config { - input { - uses get-config-request; - } - output { - uses get-config-reply; - } - /* Controller/switch message */ - } - - rpc set-config { - input { - uses set-config; - } - /* Controller/switch message */ - } - /* Asynchronous messages. */ - notification packet-in-message { - uses packet-in; - - /* Async message */ - } - notification flow-removed-message { - uses flow-removed; - - /* Async message */ - } - notification port-status-message { - uses port-status; - - } /* Async message */ - - /* Controller command messages. */ - rpc packet-out { - input { - uses packet-out; - } - /* Controller/switch message */ - } - rpc flow-mod { - input { - uses flow-mod; - } - /* Controller/switch message */ - } - rpc group-mod { - input { - uses group-mod; - } - /* Controller/switch message */ - } - rpc port-mod { - input { - uses port-mod; - } - } /* Controller/switch message */ - - rpc table-mod { - input { - uses table-mod; - } - } /* Controller/switch message */ - - /* Multipart messages. */ - - rpc multipart-request { - input { - uses multipart-request; - } - } - - /* Controller/switch message */ - notification multipart-reply-message { - uses multipart-reply; - // notification because of multiple following responses - } /* Controller/switch message */ - - - /* Barrier messages. */ - rpc barrier { - input { - uses barrier-request; - } - output { - uses barrier-reply; - } - } - /* Queue Configuration messages. */ - rpc get-queue-config { - input { - uses queue-get-config-request; - } - output { - uses queue-get-config-reply; - } - } - - /* Controller role change request messages. */ - rpc role-request { - input { - uses role-request; - } - output { - uses role-reply; - } - } /* Controller/switch message */ - - /* Asynchronous message configuration. */ - rpc get-async { - input { - uses get-async-request; - } - output { - uses get-async-reply; - } - } - /* Controller/switch message */ - rpc set-async { - input { - uses set-async; - } - - } - /* Meters and rate limiters configuration messages. */ - rpc meter-mod { - input { - uses meter-mod; - } - } /* Controller/switch message */ +/* + * 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 + */ + + module openflow-protocol { + namespace "urn:opendaylight:openflow:protocol"; + prefix "ofproto"; + + import ietf-yang-types {prefix yang;} + + import openflow-types {prefix oft;} + import openflow-extensible-match { prefix oxm;} + import openflow-instruction { prefix ofinstruction;} + import openflow-action {prefix ofaction;} + + revision "2013-07-31" { + description "OpenFlow 1.3 - protocol objects model"; + } + + // Generic Structures + grouping port-grouping { + reference "ofp_port"; + leaf port-no { + type uint32; + } + leaf hw-addr { + type yang:mac-address; + } + leaf name { + type string; + } + leaf config { + description "Bitmap of OFPPC_* flags."; + type oft:port-config; + } + leaf state { + description "Bitmap of OFPPS_* flags."; + type oft:port-state; + } + leaf current-features { + description "Current features."; + type oft:port-features; + } + leaf advertised-features { + description "Features being advertised by the port."; + type oft:port-features; + } + leaf supported-features { + description "Features supported by the port."; + type oft:port-features; + } + leaf peer-features { + description "Features advertised by peer."; + type oft:port-features; + } + leaf curr-speed { + description "Current port bitrate in kbps."; + type uint32; + units "kbps"; + } + leaf max-speed { + description "Max port bitrate in kbps"; + type uint32; + units "kbps"; + } + + // OF1.0 structures + leaf config-v10 { + type oft:port-config-v10; + } + leaf state-v10 { + type oft:port-state-v10; + } + leaf current-features-v10 { + description "Current features."; + type oft:port-features-v10; + } + leaf advertised-features-v10 { + description "Features being advertised by the port."; + type oft:port-features-v10; + } + leaf supported-features-v10 { + description "Features supported by the port."; + type oft:port-features-v10; + } + leaf peer-features-v10 { + description "Features advertised by peer."; + type oft:port-features-v10; + } + } + + grouping buckets-grouping { + list buckets-list { + uses bucket-grouping; + } + } + + grouping bucket-grouping { + description "Bucket for use in groups."; + leaf weight { + description "Relative weight of bucket. Only + defined for select groups."; + type uint16; + } + leaf watch-port { + description "Port whose state affects whether this + bucket is live. Only required for fast + failover groups."; + type oft:port-number; + } + leaf watch-group { + description "Group whose state affects whether this + bucket is live. Only required for fast + failover groups."; + type uint32; + } + + uses ofaction:actions-grouping; + } + + container table-features-properties-container { + uses table-features-properties-grouping; + } + + grouping table-features-properties-grouping { + list table-feature-properties { + config false; + leaf type { + type oft:table-features-prop-type; + } + } + } + + // # MESSAGE Structures + /* Immutable messages. */ + grouping ofHeader { + reference "ofp_header struct in Openflow Switch 1.3 Spec"; + leaf version { + type uint8; + description "OpenFlow version"; + } + leaf xid { + type uint32; + description "Transaction ID"; + } + } + grouping ofHelloElementHeader { + reference "ofpt_hello_elem_header struct in Openflow Switch 1.3 Spec"; + leaf type { + type oft:hello-element-type; + //reference "OpenFlow Header element type - OFPHET_*"; + } + } + grouping hello { + reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + list elements { + uses ofHelloElementHeader; + + leaf-list version-bitmap { + type boolean; + } + } + } + grouping error { + reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + leaf type { + type uint16; + } + leaf code { + type uint16; + } + leaf type-string { + type string; + } + leaf code-string { + type string; + } + leaf data { + type binary; + } + } + grouping echo-request { + reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + leaf data { + type binary; + } + } + grouping echo-reply { + reference "OFPT_ECHO_REPLY message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + leaf data { + type binary; + } + } + grouping experimenter { + reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; + /* Symmetric message */ + uses ofHeader; + + leaf experimenter { + type oft:experimenter-id; + } + leaf exp_type { + type uint32; + } + } + /* Switch configuration messages. */ + grouping features-request { + reference "OFPT_FEATURES_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + } + grouping features-reply { + reference "OFPT_FEATURES_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + + leaf datapathId { + type uint64; + } + leaf buffers { + type uint32; + } + leaf tables { + type uint8; + } + leaf auxiliaryId { + type uint8; + } + leaf capabilities { + type oft:capabilities; + } + leaf reserved { + type uint32; + } + // OF1.0 structures + leaf capabilities-v10 { + type oft:capabilities-v10; + } + leaf actions-v10 { + type oft:action-type-v10; + } + list phy-port { + uses port-grouping; + } + } + grouping get-config-request { + reference "OFPT_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + } + grouping get-config-reply { + reference "OFPT_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + + leaf flags { + type oft:switch-config-flag; + } + leaf miss-send-len { + type uint16; + } + } + grouping set-config { + reference "OFPT_SET_CONFIG message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf flags { + type oft:switch-config-flag; + } + leaf miss-send-len { + type uint16; + } + } + /* Asynchronous messages. */ + grouping packet-in { + reference "OFPT_PACKET_IN message in Openflow Switch 1.3 Spec"; + /* Async message */ + + uses ofHeader; + + leaf buffer-id { + // ID assigned by datapath. + type uint32; + } + leaf total-len { + // Full length of frame. + type uint16; + } + leaf reason { + // Reason packet is being sent (one of OFPR_*) + type oft:packet-in-reason; + } + leaf table-id { + // ID of the table that was looked up + type oft:table-id; + } + leaf cookie { + // Cookie of the flow entry that was looked up. + type uint64; + } + uses oxm:match-grouping; + + leaf data { + type binary; + } + + // OF1.0 structures + leaf in-port { + type uint16; + } + } + grouping flow-removed { + reference "OFPT_FLOW_REMOVED message in Openflow Switch 1.3 Spec"; + /* Async message */ + uses ofHeader; + + leaf cookie { + type uint64; + } + leaf priority { + type uint16; + } + leaf reason { + type oft:flow-removed-reason; + } + leaf table-id { + type oft:table-id; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + leaf idle-timeout { + type uint16; + } + leaf hard-timeout { + type uint16; + } + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + uses oxm:match-grouping; + + // OF1.0 structures + uses oxm:match-v10-grouping; + } + grouping port-status { + reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"; + + uses ofHeader; + + uses port-grouping; + + leaf reason { + type oft:port-reason; + } + } + /* Controller command messages. */ + grouping packet-out { + reference "OFPT_PACKET_OUT message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + uses ofaction:actions-grouping; + + leaf data { + type binary; + } + leaf buffer-id { + type uint32; + } + leaf in-port { + type oft:port-number; + } + } + grouping flow-mod { + reference "OFPT_FLOW_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf cookie { + type uint64; + } + leaf cookie-mask { + type uint64; + } + leaf table-id { + type oft:table-id; + } + leaf command { + type oft:flow-mod-command; + } + leaf idle-timeout { + type uint16; + } + leaf hard-timeout { + type uint16; + } + leaf priority { + type uint16; + } + leaf buffer-id { + type uint32; + } + leaf out-port { + type oft:port-number; + } + leaf out-group { + type uint32; + } + leaf flags { + type oft:flow-mod-flags; + } + uses oxm:match-grouping; + + uses ofinstruction:instructions-grouping; + + // OF1.0 structures + leaf flags-v10 { + type oft:flow-mod-flags-v10; + } + uses oxm:match-v10-grouping; + uses ofaction:actions-grouping; + } + grouping group-mod { + reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf command { + type oft:group-mod-command; + } + leaf type { + type oft:group-type; + } + leaf group-id { + type oft:group-id; + } + + uses buckets-grouping; + } + + grouping port-mod { + reference "OFPT_PORT_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf port-no { + type oft:port-number; + } + leaf hw-address { + type yang:mac-address; + } + leaf config { + type oft:port-config; + } + leaf mask { + type oft:port-config; + } + leaf advertise { + type oft:port-features; + } + // OF1.0 structures + leaf config-v10 { + type oft:port-config-v10; + } + leaf mask-v10 { + type oft:port-config-v10; + } + leaf advertise-v10 { + type oft:port-features-v10; + } + } + grouping table-mod { + reference "OFPT_TABLE_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf table-id { + type oft:table-id; + } + leaf config { + type oft:table-config; + } + } + + /* Multipart messages. */ + grouping multipart-request { + reference "OFPT_MULTIPART_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf type { + type oft:multipart-type; + } + leaf flags { + type oft:multipart-request-flags; + } + choice multipart-request-body { + case multipart-request-desc-case { + container multipart-request-desc { + leaf empty { + type empty; + } + } + } + case multipart-request-flow-case { + container multipart-request-flow { + leaf table-id { + type uint8; + } + leaf out-port { + type uint32; + } + leaf out-group { + type uint32; + } + leaf cookie { + type uint64; + } + leaf cookie-mask { + type uint64; + } + uses oxm:match-grouping; + + // OF1.0 structures + uses oxm:match-v10-grouping; + } + } + case multipart-request-aggregate-case { + container multipart-request-aggregate { + leaf table-id { + type uint8; + } + leaf out-port { + type uint32; + } + leaf out-group { + type uint32; + } + leaf cookie { + type uint64; + } + leaf cookie-mask { + type uint64; + } + uses oxm:match-grouping; + + // OF1.0 structures + uses oxm:match-v10-grouping; + } + } + case multipart-request-table-case { + container multipart-request-table { + leaf empty { + type empty; + } + } + } + case multipart-request-port-stats-case { + container multipart-request-port-stats { + leaf port-no { + type uint32; + } + } + } + case multipart-request-queue-case { + container multipart-request-queue { + leaf port-no { + type uint32; + } + leaf queue-id { + type uint32; + } + } + } + case multipart-request-group-case { + container multipart-request-group { + leaf group-id { + type oft:group-id; + } + } + } + case multipart-request-group-desc-case { + container multipart-request-group-desc { + leaf empty { + type empty; + } + } + } + case multipart-request-group-features-case { + container multipart-request-group-features { + leaf empty { + type empty; + } + } + } + case multipart-request-meter-case { + container multipart-request-meter { + leaf meter-id { + type oft:meter-id; + } + } + } + case multipart-request-meter-config-case { + container multipart-request-meter-config { + leaf meter-id { + type oft:meter-id; + } + } + } + case multipart-request-meter-features-case { + container multipart-request-meter-features { + leaf empty { + type empty; + } + } + } + case multipart-request-table-features-case { + container multipart-request-table-features { + list table-features { + leaf table-id { + type uint8; + } + leaf name { + type string; + } + leaf metadata-match { + type uint64; + } + leaf metadata-write { + type uint64; + } + leaf config { + type oft:table-config; + } + leaf max-entries { + type uint32; + } + uses table-features-properties-grouping; + } + } + } + case multipart-request-port-desc-case { + container multipart-request-port-desc { + leaf empty { + type empty; + } + } + } + case multipart-request-experimenter-case { + container multipart-request-experimenter { + // empty body - used for experimenter augmentation + } + } + } + } + grouping multipart-reply { + reference "OFPT_MULTIPART_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf type { + type oft:multipart-type; + } + leaf flags { + type oft:multipart-request-flags; + } + choice multipart-reply-body { + case multipart-reply-desc-case { + container multipart-reply-desc { + leaf mfr_desc { + type string; + } + leaf hw_desc { + type string; + } + leaf sw_desc { + type string; + } + leaf serial_num { + type string; + } + leaf dp_desc { + type string; + } + } + } + case multipart-reply-flow-case { + container multipart-reply-flow { + list flow-stats { + leaf table-id { + type uint8; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + leaf priority { + type uint16; + } + leaf idle-timeout { + type uint16; + } + leaf hard-timeout { + type uint16; + } + leaf flags { + type oft:flow-mod-flags; + } + leaf cookie { + type uint64; + } + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + uses oxm:match-grouping; + + uses ofinstruction:instructions-grouping; + + // OF1.0 structures + uses oxm:match-v10-grouping; + uses ofaction:actions-grouping; + } + } + } + case multipart-reply-aggregate-case { + container multipart-reply-aggregate { + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + leaf flow-count { + type uint32; + } + } + } + case multipart-reply-table-case { + container multipart-reply-table { + list table-stats { + leaf table-id { + type uint8; + } + leaf active-count { + type uint32; + } + leaf lookup-count { + type uint64; + } + leaf matched-count { + type uint64; + } + + // OF1.0 structures + leaf name { + type string; + } + leaf wildcards { + type oft:flow-wildcards-v10; + } + leaf nw-src-mask { + type uint8; + } + leaf nw-dst-mask { + type uint8; + } + leaf max-entries { + type uint32; + } + } + } + } + case multipart-reply-port-stats-case { + container multipart-reply-port-stats { + list port-stats { + leaf port-no { + type uint32; + } + leaf rx-packets { + type uint64; + } + leaf tx-packets { + type uint64; + } + leaf rx-bytes { + type uint64; + } + leaf tx-bytes { + type uint64; + } + leaf rx-dropped { + type uint64; + } + leaf tx-dropped { + type uint64; + } + leaf rx-errors { + type uint64; + } + leaf tx-errors { + type uint64; + } + leaf rx-frame-err { + type uint64; + } + leaf rx-over-err { + type uint64; + } + leaf rx-crc-err { + type uint64; + } + leaf collisions { + type uint64; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + } + } + } + case multipart-reply-queue-case { + container multipart-reply-queue { + list queue-stats { + leaf port-no { + type uint32; + } + leaf queue-id { + type uint32; + } + leaf tx-bytes { + type uint64; + } + leaf tx-packets { + type uint64; + } + leaf tx-errors { + type uint64; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + } + } + } + case multipart-reply-group-case { + container multipart-reply-group { + list group-stats { + leaf group-id { + type oft:group-id; + } + leaf ref-count { + type uint32; + } + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + list bucket-stats { + leaf packet-count { + type uint64; + } + leaf byte-count { + type uint64; + } + } + } + } + } + case multipart-reply-group-desc-case { + container multipart-reply-group-desc { + list group-desc { + leaf type { + type oft:group-type; + } + leaf group-id { + type oft:group-id; + } + uses buckets-grouping; + } + } + } + case multipart-reply-group-features-case { + container multipart-reply-group-features { + leaf types { + type oft:group-types; + } + leaf capabilities { + type oft:group-capabilities; + } + leaf-list max_groups { + type uint32; + } + leaf-list actions-bitmap { + type oft:action-type; + } + } + } + case multipart-reply-meter-case { + container multipart-reply-meter { + list meter-stats { + leaf meter-id { + type oft:meter-id; + } + leaf flow-count { + type uint32; + } + leaf packet-in-count { + type uint64; + } + leaf byte-in-count { + type uint64; + } + leaf duration-sec { + type uint32; + } + leaf duration-nsec { + type uint32; + } + list meter-band-stats { + leaf packet-band-count { + type uint64; + } + leaf byte-band-count { + type uint64; + } + } + } + } + } + case multipart-reply-meter-config-case { + container multipart-reply-meter-config { + list meter-config { + leaf flags { + type oft:meter-flags; + } + leaf meter-id { + type oft:meter-id; + } + list bands { + uses meter-band-header; + } + } + } + } + case multipart-reply-meter-features-case { + container multipart-reply-meter-features { + leaf max-meter { + type uint32; + } + leaf band-types { + type oft:meter-band-type-bitmap; + } + leaf capabilities { + type oft:meter-flags; + } + leaf max-bands { + type uint8; + } + leaf max-color { + type uint8; + } + } + } + case multipart-reply-table-features-case { + container multipart-reply-table-features { + list table-features { + leaf table-id { + type uint8; + } + leaf name { + type string; + } + leaf metadata-match { + type binary; + } + leaf metadata-write { + type binary; + } + leaf config { + type oft:table-config; + } + leaf max-entries { + type uint32; + } + uses table-features-properties-grouping; + } + } + } + case multipart-reply-port-desc-case { + container multipart-reply-port-desc { + list ports { + uses port-grouping; + } + } + } + case multipart-reply-experimenter-case { + container multipart-reply-experimenter { + // empty body - used for experimenter augmentation + } + } + } + } + /* Barrier messages. */ + grouping barrier-request { + reference "OFPT_BARRIER_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + } + grouping barrier-reply { + reference "OFPT_BARRIER_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + uses ofHeader; + } + /* Queue Configuration messages. */ + grouping queue-get-config-request { + reference "OFPT_QUEUE_GET_CONFIG_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf port { + type oft:port-number; + } + } + grouping queue-get-config-reply { + reference "OFPT_QUEUE_GET_CONFIG_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf port { + type oft:port-number; + } + list queues { + uses packet-queue; + } + } + grouping packet-queue { + leaf queue-id { + type oft:queue-id; + } + leaf port { + type oft:port-number; + } + uses queue-property-header; + } + container queue-prop-container { + uses queue-property-header; + } + grouping queue-property-header { + list queue-property { + config false; + leaf property { + type oft:queue-properties; + } + } + } + /* Controller role change request messages. */ + grouping role-request { + reference "OFPT_ROLE_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf role { + type oft:controller-role; + } + leaf generation-id { + type uint64; + } + } + grouping role-reply { + reference "OFPT_ROLE_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf role { + type oft:controller-role; + } + leaf generation-id { + type uint64; + } + } + /* Asynchronous message configuration. */ + grouping get-async-request { + reference "OFPT_GET_ASYNC_REQUEST message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + } + grouping get-async-reply { + reference "OFPT_GET_ASYNC_REPLY message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + uses async-body-grouping; + } + grouping set-async { + reference "OFPT_SET_ASYNC message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + uses async-body-grouping; + } + + grouping async-body-grouping { + list packet-in-mask { + leaf-list mask { + type oft:packet-in-reason; + } + } + list port-status-mask { + leaf-list mask { + type oft:port-reason; + } + } + list flow-removed-mask { + leaf-list mask { + type oft:flow-removed-reason; + } + } + } + /* Meters and rate limiters configuration messages. */ + grouping meter-mod { + reference "OFPT_METER_MOD message in Openflow Switch 1.3 Spec"; + /* Controller/switch message */ + + uses ofHeader; + + leaf command { + type oft:meter-mod-command; + } + leaf flags { + type oft:meter-flags; + } + leaf meter-id { + type oft:meter-id; + } + list bands { + uses meter-band-header; + } + } + + container meter-band-container { + uses meter-band-header; + } + grouping meter-band-header { + choice meter-band { + case meter-band-drop-case { + container meter-band-drop { + uses meter-band-commons; + } + } + case meter-band-dscp-remark-case { + container meter-band-dscp-remark { + uses meter-band-commons; + leaf prec-level { + type uint8; + } + } + } + case meter-band-experimenter-case { + container meter-band-experimenter { + uses meter-band-commons; + } + } + } + } + + grouping meter-band-commons { + leaf type { + type oft:meter-band-type; + } + leaf rate { + type uint32; + } + leaf burst-size { + type uint32; + } + } + + /* Immutable messages. */ + notification hello-message { + uses hello; + reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"; + + /* Symmetric message */ + } + notification error-message { + uses error; + reference "OFPT_ERROR message in Openflow Switch 1.3 Spec"; + + /* Symmetric message */ + } + notification echo-request-message { + uses echo-request; + reference "OFPT_ECHO_REQUEST message in Openflow Switch 1.3 Spec"; + + /* Symmetric message */ + } + notification experimenter-message { + uses experimenter; + reference "OFPT_EXPERIMENTER message in Openflow Switch 1.3 Spec"; + // TODO:: does switch send this when understood experimenter msg from lib? + /* Symmetric message */ + } + // # Notification and RPCs + /* Symmetric RPC. */ + rpc echo { + input { + uses echo-request; + } + /* Controller/switch message */ + output { + uses echo-reply; + } + } + + rpc echo-reply { + input { + uses echo-reply; + } + } + + rpc hello { + input { + uses hello; + } + } + + rpc experimenter { + input { + uses experimenter; + } + } + + /* Switch configuration messages. */ + rpc get-features { + input { + uses features-request; + } + /* Controller/switch message */ + output { + uses features-reply; + } + } + + rpc get-config { + input { + uses get-config-request; + } + output { + uses get-config-reply; + } + /* Controller/switch message */ + } + + rpc set-config { + input { + uses set-config; + } + /* Controller/switch message */ + } + /* Asynchronous messages. */ + notification packet-in-message { + uses packet-in; + + /* Async message */ + } + notification flow-removed-message { + uses flow-removed; + + /* Async message */ + } + notification port-status-message { + uses port-status; + + } /* Async message */ + + /* Controller command messages. */ + rpc packet-out { + input { + uses packet-out; + } + /* Controller/switch message */ + } + rpc flow-mod { + input { + uses flow-mod; + } + /* Controller/switch message */ + } + rpc group-mod { + input { + uses group-mod; + } + /* Controller/switch message */ + } + rpc port-mod { + input { + uses port-mod; + } + } /* Controller/switch message */ + + rpc table-mod { + input { + uses table-mod; + } + } /* Controller/switch message */ + + /* Multipart messages. */ + + rpc multipart-request { + input { + uses multipart-request; + } + } + + /* Controller/switch message */ + notification multipart-reply-message { + uses multipart-reply; + // notification because of multiple following responses + } /* Controller/switch message */ + + + /* Barrier messages. */ + rpc barrier { + input { + uses barrier-request; + } + output { + uses barrier-reply; + } + } + /* Queue Configuration messages. */ + rpc get-queue-config { + input { + uses queue-get-config-request; + } + output { + uses queue-get-config-reply; + } + } + + /* Controller role change request messages. */ + rpc role-request { + input { + uses role-request; + } + output { + uses role-reply; + } + } /* Controller/switch message */ + + /* Asynchronous message configuration. */ + rpc get-async { + input { + uses get-async-request; + } + output { + uses get-async-reply; + } + } + /* Controller/switch message */ + rpc set-async { + input { + uses set-async; + } + + } + /* Meters and rate limiters configuration messages. */ + rpc meter-mod { + input { + uses meter-mod; + } + } /* Controller/switch message */ } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java index 9816c250..f71d2302 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/connection/TlsConfigurationImplTest.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2014 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; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; - -/** - * @author michal.polkorab - * - */ -public class TlsConfigurationImplTest { - - /** - * Test correct TlsConfigurationImpl creation - */ - @Test - public void test() { - TlsConfigurationImpl config = new TlsConfigurationImpl(KeystoreType.JKS, - "user/dir", PathType.CLASSPATH, KeystoreType.PKCS12, "/var/lib", PathType.PATH); - assertEquals("Wrong keystore location", "/var/lib", config.getTlsKeystore()); - assertEquals("Wrong truststore location", "user/dir", config.getTlsTruststore()); - assertEquals("Wrong keystore type", KeystoreType.PKCS12, config.getTlsKeystoreType()); - assertEquals("Wrong truststore type", KeystoreType.JKS, config.getTlsTruststoreType()); - assertEquals("Wrong keystore path type", PathType.PATH, config.getTlsKeystorePathType()); - assertEquals("Wrong truststore path type", PathType.CLASSPATH, config.getTlsTruststorePathType()); - assertEquals("Wrong certificate password", "opendaylight", config.getCertificatePassword()); - assertEquals("Wrong keystore password", "opendaylight", config.getKeystorePassword()); - assertEquals("Wrong truststore password", "opendaylight", config.getTruststorePassword()); - } +/* + * Copyright (c) 2014 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; + +import static org.junit.Assert.*; + +import org.junit.Test; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; + +/** + * @author michal.polkorab + * + */ +public class TlsConfigurationImplTest { + + /** + * Test correct TlsConfigurationImpl creation + */ + @Test + public void test() { + TlsConfigurationImpl config = new TlsConfigurationImpl(KeystoreType.JKS, + "user/dir", PathType.CLASSPATH, KeystoreType.PKCS12, "/var/lib", PathType.PATH); + assertEquals("Wrong keystore location", "/var/lib", config.getTlsKeystore()); + assertEquals("Wrong truststore location", "user/dir", config.getTlsTruststore()); + assertEquals("Wrong keystore type", KeystoreType.PKCS12, config.getTlsKeystoreType()); + assertEquals("Wrong truststore type", KeystoreType.JKS, config.getTlsTruststoreType()); + assertEquals("Wrong keystore path type", PathType.PATH, config.getTlsKeystorePathType()); + assertEquals("Wrong truststore path type", PathType.CLASSPATH, config.getTlsTruststorePathType()); + assertEquals("Wrong certificate password", "opendaylight", config.getCertificatePassword()); + assertEquals("Wrong keystore password", "opendaylight", config.getKeystorePassword()); + assertEquals("Wrong truststore password", "opendaylight", config.getTruststorePassword()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java index 7b350d55..82377828 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageCodeKeyTest.java @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2014 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.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; - -/** - * @author michal.polkorab - * - */ -public class EnhancedMessageCodeKeyTest { - - /** - * Test EnhancedMessageCodeKey equals and hashCode - */ - @Test - public void test() { - EnhancedMessageCodeKey key1 = - new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - EnhancedMessageCodeKey key2 = - new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, 8, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierOutput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, 8, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 16, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test EnhancedMessageTypeKey equals - additional test - */ - @Test - public void testEquals() { - EnhancedMessageCodeKey key1 = - new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - } - - /** - * Test EnhancedMessageCodeKey toString() - */ - @Test - public void testToString() { - EnhancedMessageCodeKey key1 = - new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.protocol.rev130731.BarrierInput msgType: 4 msgType2: 8", key1.toString()); - } +/* + * Copyright (c) 2014 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.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class EnhancedMessageCodeKeyTest { + + /** + * Test EnhancedMessageCodeKey equals and hashCode + */ + @Test + public void test() { + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + EnhancedMessageCodeKey key2 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, 8, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, 8, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 16, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test EnhancedMessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + } + + /** + * Test EnhancedMessageCodeKey toString() + */ + @Test + public void testToString() { + EnhancedMessageCodeKey key1 = + new EnhancedMessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, 8, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.protocol.rev130731.BarrierInput msgType: 4 msgType2: 8", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java index e6be8a8d..40ff08cc 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/EnhancedMessageTypeKeyTest.java @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2014 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.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class EnhancedMessageTypeKeyTest { - - /** - * Test EnhancedMessageTypeKey equals and hashCode - */ - @Test - public void test() { - EnhancedMessageTypeKey key1 = - new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - EnhancedMessageTypeKey key2 = - new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, Output.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null, Output.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Instruction.class, Output.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, SetField.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test EnhancedMessageTypeKey equals - additional test - */ - @Test - public void testEquals() { - EnhancedMessageTypeKey key1; - EnhancedMessageTypeKey key2; - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null); - Assert.assertFalse("Wrong equal by msgType2.", key1.equals(key2)); - key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); - key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, SetField.class); - Assert.assertFalse("Wrong equal by msgType2 class name.", key1.equals(key2)); - } - - /** - * Test EnhancedMessageTypeKey toString() - */ - @Test - public void testToString() { - EnhancedMessageTypeKey key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, - Action.class, Output.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.actions.grouping.Action msgType2: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.Output", key1.toString()); - } +/* + * Copyright (c) 2014 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.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.SetField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class EnhancedMessageTypeKeyTest { + + /** + * Test EnhancedMessageTypeKey equals and hashCode + */ + @Test + public void test() { + EnhancedMessageTypeKey key1 = + new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + EnhancedMessageTypeKey key2 = + new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Instruction.class, Output.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Action.class, SetField.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test EnhancedMessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + EnhancedMessageTypeKey key1; + EnhancedMessageTypeKey key2; + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, null); + Assert.assertFalse("Wrong equal by msgType2.", key1.equals(key2)); + key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, Output.class); + key2 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, Action.class, SetField.class); + Assert.assertFalse("Wrong equal by msgType2 class name.", key1.equals(key2)); + } + + /** + * Test EnhancedMessageTypeKey toString() + */ + @Test + public void testToString() { + EnhancedMessageTypeKey key1 = new EnhancedMessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, + Action.class, Output.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.actions.grouping.Action msgType2: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.Output", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java index 4087a55b..2c0425f4 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageCodeKeyTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 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.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; - -/** - * @author michal.polkorab - * - */ -public class MessageCodeKeyTest { - - /** - * Test MessageCodeKey equals and hashCode - */ - @Test - public void test() { - MessageCodeKey key1 = - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - MessageCodeKey key2 = - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierOutput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MessageCodeKey equals - additional test - */ - @Test - public void testEquals() { - MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to null.", key1.equals(null)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); - MessageCodeKey key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - Assert.assertFalse("Wrong equal by clazz.", key1.equals(key2)); - - key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); - Assert.assertTrue("Wrong equal by clazz.", key1.equals(key2)); - } - - /** - * Test MessageCodeKey toString() - */ - @Test - public void testToString() { - MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.protocol.rev130731.BarrierInput msgType: 4", key1.toString()); - } +/* + * Copyright (c) 2014 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.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class MessageCodeKeyTest { + + /** + * Test MessageCodeKey equals and hashCode + */ + @Test + public void test() { + MessageCodeKey key1 = + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + MessageCodeKey key2 = + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 4, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 6, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MessageCodeKey equals - additional test + */ + @Test + public void testEquals() { + MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + MessageCodeKey key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + Assert.assertFalse("Wrong equal by clazz.", key1.equals(key2)); + + key2 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, null); + Assert.assertTrue("Wrong equal by clazz.", key1.equals(key2)); + } + + /** + * Test MessageCodeKey toString() + */ + @Test + public void testToString() { + MessageCodeKey key1 = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 4, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.protocol.rev130731.BarrierInput msgType: 4", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java index 4dbd5541..83f426c4 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/extensibility/MessageTypeKeyTest.java @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2014 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.extensibility; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; - -/** - * @author michal.polkorab - * - */ -public class MessageTypeKeyTest { - - /** - * Test MessageTypeKey equals and hashCode - */ - @Test - public void test() { - MessageTypeKey key1 = - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - MessageTypeKey key2 = - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierInput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MessageTypeKey equals - additional test - */ - @Test - public void testEquals() { - MessageTypeKey key1; - MessageTypeKey key2; - key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to null.", key1.equals(null)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); - - key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertTrue("Wrong equal by msgType.", key1.equals(key2)); - } - - /** - * Test MessageTypeKey toString() - */ - @Test - public void testToString() { - MessageTypeKey key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.protocol.rev130731.BarrierInput", key1.toString()); - } +/* + * Copyright (c) 2014 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.extensibility; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; + +/** + * @author michal.polkorab + * + */ +public class MessageTypeKeyTest { + + /** + * Test MessageTypeKey equals and hashCode + */ + @Test + public void test() { + MessageTypeKey key1 = + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + MessageTypeKey key2 = + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, BarrierInput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierOutput.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MessageTypeKey equals - additional test + */ + @Test + public void testEquals() { + MessageTypeKey key1; + MessageTypeKey key2; + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to null.", key1.equals(null)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + Assert.assertFalse("Wrong equal by msgType.", key1.equals(key2)); + + key2 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertTrue("Wrong equal by msgType.", key1.equals(key2)); + } + + /** + * Test MessageTypeKey toString() + */ + @Test + public void testToString() { + MessageTypeKey key1 = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, BarrierInput.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.protocol.rev130731.BarrierInput", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java index 66a09fe9..6ba052b7 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionDeserializerKeyTest.java @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class ActionDeserializerKeyTest { - - /** - * Test ActionDeserializerKey equals and hashCode - */ - @Test - public void test() { - ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ActionDeserializerKey equals - additional test - */ - @Test - public void testEquals(){ - ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); - } - - /** - * Test InstructionDeserializerKey toString() - */ - @Test - public void testToString(){ - ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.actions.grouping.Action msgType: 11" - + " experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 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.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerKeyTest { + + /** + * Test ActionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ActionDeserializerKey equals - additional test + */ + @Test + public void testEquals(){ + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + ActionDeserializerKey key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test InstructionDeserializerKey toString() + */ + @Test + public void testToString(){ + ActionDeserializerKey key1 = new ActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.actions.grouping.Action msgType: 11" + + " experimenterID: null", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java index f9c5225d..043a3cfb 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/ActionSerializerKeyTest.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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; - -/** - * @author michal.polkorab - * - */ -public class ActionSerializerKeyTest { - - /** - * Test ActionSerializerKey equals and hashCode - */ - @Test - public void test() { - ActionSerializerKey key1 = - new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - ActionSerializerKey key2 = - new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOut.class, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlIn.class, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ActionSerializerKey equals - additional test - */ - @Test - public void testEquals(){ - ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); - - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); - key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); - Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); - } - - /** - * Test ActionSerializerKey toString() - */ - @Test - public void testToString(){ - ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.actions.grouping.Action action type: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.common.action.rev130731.CopyTtlIn experimenterID: 42", key1.toString()); - } +/* + * Copyright (c) 2014 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.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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; + +/** + * @author michal.polkorab + * + */ +public class ActionSerializerKeyTest { + + /** + * Test ActionSerializerKey equals and hashCode + */ + @Test + public void test() { + ActionSerializerKey key1 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + ActionSerializerKey key2 = + new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlOut.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, CopyTtlIn.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ActionSerializerKey equals - additional test + */ + @Test + public void testEquals(){ + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + ActionSerializerKey key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal by actionType", key1.equals(key2)); + + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertTrue("Wrong equal by action type", key1.equals(key2)); + key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test ActionSerializerKey toString() + */ + @Test + public void testToString(){ + ActionSerializerKey key1 = new ActionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, CopyTtlIn.class, 42L); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.actions.grouping.Action action type: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.common.action.rev130731.CopyTtlIn experimenterID: 42", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java index 2497413a..208b4ff7 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionDeserializerKeyTest.java @@ -1,70 +1,70 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class InstructionDeserializerKeyTest { - - /** - * Test InstructionDeserializerKey equals and hashCode - */ - @Test - public void test() { - InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test InstructionDeserializerKey equals - additional test - */ - @Test - public void testEquals(){ - InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 24L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); - } - - /** - * Test InstructionDeserializerKey toString() - */ - @Test - public void testToString(){ - InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction msgType: 11" - + " experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 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.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerKeyTest { + + /** + * Test InstructionDeserializerKey equals and hashCode + */ + @Test + public void test() { + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 11, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test InstructionDeserializerKey equals - additional test + */ + @Test + public void testEquals(){ + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + InstructionDeserializerKey key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, 24L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key2 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + Assert.assertTrue("Wrong equal by experimenterId", key1.equals(key2)); + } + + /** + * Test InstructionDeserializerKey toString() + */ + @Test + public void testToString(){ + InstructionDeserializerKey key1 = new InstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 11, null); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction msgType: 11" + + " experimenterID: null", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java index 8e7d1f5f..23aecd79 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/InstructionSerializerKeyTest.java @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.WriteActions; - -/** - * @author michal.polkorab - * - */ -public class InstructionSerializerKeyTest { - - /** - * Test InstructionSerializerKey equals and hashCode - */ - @Test - public void test() { - InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - InstructionSerializerKey key2 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test InstructionSerializerKey equals - additional test - */ - @Test - public void testEquals(){ - InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - InstructionSerializerKey key2 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); - Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - - key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); - Assert.assertTrue("Wrong equal by instructionType.", key1.equals(key2)); - } - - /** - * Test InstructionSerializerKey toString() - */ - @Test - public void testToString(){ - InstructionSerializerKey key1 = - new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); - - Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction" - + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" - + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString()); - } +/* + * Copyright (c) 2014 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.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.WriteActions; + +/** + * @author michal.polkorab + * + */ +public class InstructionSerializerKeyTest { + + /** + * Test InstructionSerializerKey equals and hashCode + */ + @Test + public void test() { + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + InstructionSerializerKey key2 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, WriteActions.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActions.class, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test InstructionSerializerKey equals - additional test + */ + @Test + public void testEquals(){ + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + InstructionSerializerKey key2 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, null); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + + key1 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + key2 = new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, 42L); + Assert.assertTrue("Wrong equal by instructionType.", key1.equals(key2)); + } + + /** + * Test InstructionSerializerKey toString() + */ + @Test + public void testToString(){ + InstructionSerializerKey key1 = + new InstructionSerializerKey<>(EncodeConstants.OF10_VERSION_ID, ApplyActions.class, 42L); + + Assert.assertEquals("Wrong toString()", "msgVersion: 1 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.instruction.rev130731.instructions.grouping.Instruction" + + " instructionType type: org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + + ".instruction.rev130731.ApplyActions vendorID: 42", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java index be87d557..5c69cc65 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntryDeserializerKeyTest.java @@ -1,83 +1,83 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class MatchEntryDeserializerKeyTest { - - /** - * Test MatchEntryDeserializerKey equals and hashCode - */ - @Test - public void test() { - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 0); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - key2.setExperimenterId(158L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - key2.setExperimenterId(158L); - key1.setExperimenterId(158L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MatchEntryDeserializerKey equals - additional test - */ - @Test - public void testEquals() { - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); - - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - Long expId1=123456L; - Long expId2=654321L; - key1.setExperimenterId(null); - key2.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - - key1.setExperimenterId(expId1); - Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); - Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); - } - - /** - * Test MatchEntryDeserializerKey toString() - */ - @Test - public void testToString(){ - MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); - - Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries msgType: 32768 oxm_field: 42" - + " experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 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.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class MatchEntryDeserializerKeyTest { + + /** + * Test MatchEntryDeserializerKey equals and hashCode + */ + @Test + public void test() { + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0, 42); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 0); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + key2.setExperimenterId(158L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + key2.setExperimenterId(158L); + key1.setExperimenterId(158L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MatchEntryDeserializerKey equals - additional test + */ + @Test + public void testEquals() { + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + MatchEntryDeserializerKey key2 = new MatchEntryDeserializerKey(EncodeConstants.OF10_VERSION_ID, 0x8000, 42); + + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + Long expId1=123456L; + Long expId2=654321L; + key1.setExperimenterId(null); + key2.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + + key1.setExperimenterId(expId1); + Assert.assertFalse("Wrong equal by experimeterId.", key1.equals(key2)); + Assert.assertFalse("Wrong equals with different object class", key1.equals(key2)); + } + + /** + * Test MatchEntryDeserializerKey toString() + */ + @Test + public void testToString(){ + MatchEntryDeserializerKey key1 = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 0x8000, 42); + + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectClass: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries msgType: 32768 oxm_field: 42" + + " experimenterID: null", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java index 576c446f..0863db37 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/MatchEntrySerializerKeyTest.java @@ -1,107 +1,107 @@ -/* - * Copyright (c) 2014 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.keys; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.Nxm0Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; - -/** - * @author michal.polkorab - * - */ -public class MatchEntrySerializerKeyTest { - - /** - * Test MatchEntrySerializerKey equals and hashCode - */ - @Test - public void test() { - MatchEntrySerializerKey key1 = new MatchEntrySerializerKey<> - (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - MatchEntrySerializerKey key2 = new MatchEntrySerializerKey<> - (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - OpenflowBasicClass.class, InPhyPort.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - Nxm0Class.class, InPort.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF10_VERSION_ID, - OpenflowBasicClass.class, InPhyPort.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - OpenflowBasicClass.class, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - null, InPhyPort.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - key2.setExperimenterId(42L); - Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test MatchEntrySerializerKey equals - additional test - */ - @Test - public void testEquals(){ - MatchEntrySerializerKey key1; - MatchEntrySerializerKey key2; - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); - - Long expId1 = 987654331L; - Long expId2 = 123456789L; - - key1.setExperimenterId(null); - key2.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key1.setExperimenterId(expId1); - Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); - key1.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2)); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); - key2.setExperimenterId(expId2); - Assert.assertTrue("Wrong equal by oxmClass", key1.equals(key2)); - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); - key1.setExperimenterId(expId2); - Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2)); - key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); - key2.setExperimenterId(expId2); - Assert.assertTrue("Wrong equal by oxmField", key1.equals(key2)); - } - - /** - * Test MatchEntrySerializerKey toString() - */ - @Test - public void testToString(){ - MatchEntrySerializerKey key1; - key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); - - Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn" - + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString()); - } +/* + * Copyright (c) 2014 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.keys; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.Nxm0Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; + +/** + * @author michal.polkorab + * + */ +public class MatchEntrySerializerKeyTest { + + /** + * Test MatchEntrySerializerKey equals and hashCode + */ + @Test + public void test() { + MatchEntrySerializerKey key1 = new MatchEntrySerializerKey<> + (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + MatchEntrySerializerKey key2 = new MatchEntrySerializerKey<> + (EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + Nxm0Class.class, InPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF10_VERSION_ID, + OpenflowBasicClass.class, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + null, InPhyPort.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + key2.setExperimenterId(42L); + Assert.assertFalse("Wrong hashCode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test MatchEntrySerializerKey equals - additional test + */ + @Test + public void testEquals(){ + MatchEntrySerializerKey key1; + MatchEntrySerializerKey key2; + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + Assert.assertFalse("Wrong equal to different class.", key1.equals(new Object())); + + Long expId1 = 987654331L; + Long expId2 = 123456789L; + + key1.setExperimenterId(null); + key2.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key1.setExperimenterId(expId1); + Assert.assertFalse("Wrong equal by experimenterId", key1.equals(key2)); + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); + key1.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by oxmClass", key1.equals(key2)); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, null, InPort.class); + key2.setExperimenterId(expId2); + Assert.assertTrue("Wrong equal by oxmClass", key1.equals(key2)); + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); + key1.setExperimenterId(expId2); + Assert.assertFalse("Wrong equal by oxmField", key1.equals(key2)); + key2 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, null); + key2.setExperimenterId(expId2); + Assert.assertTrue("Wrong equal by oxmField", key1.equals(key2)); + } + + /** + * Test MatchEntrySerializerKey toString() + */ + @Test + public void testToString(){ + MatchEntrySerializerKey key1; + key1 = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, OpenflowBasicClass.class, InPort.class); + + Assert.assertEquals("Wrong toString()", "msgVersion: 4 objectType: org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries oxm_class: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev130731.OpenflowBasicClass oxm_field: org.opendaylight.yang.gen.v1.urn" + + ".opendaylight.openflow.oxm.rev130731.InPort experimenterID: null", key1.toString()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java index 47c59033..2357c71a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionDeserializerKeyTest.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterActionDeserializerKeyTest { - - /** - * Test ExperimenterActionDeserializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterActionDeserializerKey key1 = - new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterActionDeserializerKey key2 = - new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterActionDeserializerKeyTest { + + /** + * Test ExperimenterActionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterActionDeserializerKey key1 = + new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterActionDeserializerKey key2 = + new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java index 761698d3..c8111fbd 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterActionSerializerKeyTest.java @@ -1,73 +1,73 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterActionSerializerKeyTest { - - - /** - * Test ExperimenterActionSerializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterActionSerializerKey key1 = - new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); - ExperimenterActionSerializerKey key2 = - new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, null, TestSubType.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType2.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - @Test - public void testEquals() { - ExperimenterActionSerializerKey key1; - ExperimenterActionSerializerKey key2; - key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class); - Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); - key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); - Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); - } - - - private static class TestSubType extends ExperimenterActionSubType { - // empty class - only used in test for comparation - } - - private static class TestSubType2 extends ExperimenterActionSubType { - // empty class - only used in test for comparation - } - - +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.ExperimenterActionSubType; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterActionSerializerKeyTest { + + + /** + * Test ExperimenterActionSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterActionSerializerKey key1 = + new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + ExperimenterActionSerializerKey key2 = + new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, null, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L, TestSubType2.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + @Test + public void testEquals() { + ExperimenterActionSerializerKey key1; + ExperimenterActionSerializerKey key2; + key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, null); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + key2 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType2.class); + Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); + key1 = new ExperimenterActionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L, TestSubType.class); + Assert.assertFalse("Wrong equal by actionSubType.", key1.equals(key2)); + } + + + private static class TestSubType extends ExperimenterActionSubType { + // empty class - only used in test for comparation + } + + private static class TestSubType2 extends ExperimenterActionSubType { + // empty class - only used in test for comparation + } + + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java index dc3e956b..6938223a 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdDeserializerKeyTest.java @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterIdDeserializerKeyTest { - - /** - * Test ExperimenterIdDeserializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterIdDeserializerKey key1 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - ExperimenterIdDeserializerKey key2 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ExperimenterIdDeserializerKey equals - additional test - */ - @Test - public void testEquals() { - ExperimenterIdDeserializerKey key1 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class); - Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); - ExperimenterIdDeserializerKey key2 = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - } - +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterIdDeserializerKeyTest { + + /** + * Test ExperimenterIdDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterIdDeserializerKey key1 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + ExperimenterIdDeserializerKey key2 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ExperimenterIdDeserializerKey equals - additional test + */ + @Test + public void testEquals() { + ExperimenterIdDeserializerKey key1 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + MessageCodeKey mk = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID,EncodeConstants.EXPERIMENTER_VALUE, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); + ExperimenterIdDeserializerKey key2 = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java index 97fd73e1..06f06cbf 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterIdSerializerKeyTest.java @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterIdSerializerKeyTest { - - /** - * Test ExperimenterIdSerializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterIdSerializerKey key1 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - ExperimenterIdSerializerKey key2 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } - - /** - * Test ExperimenterIdSerializerKey equals - additional test - */ - @Test - public void testEquals() { - ExperimenterIdSerializerKey key1 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); - Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); - MessageTypeKeymk = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID,ExperimenterMessage.class); - Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); - ExperimenterIdSerializerKey key2 = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); - Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); - } - +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterIdSerializerKeyTest { + + /** + * Test ExperimenterIdSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterIdSerializerKey key1 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + ExperimenterIdSerializerKey key2 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF13_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 55L, ErrorMessage.class); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } + + /** + * Test ExperimenterIdSerializerKey equals - additional test + */ + @Test + public void testEquals() { + ExperimenterIdSerializerKey key1 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, null, ExperimenterMessage.class); + Assert.assertTrue("Wrong equal to identical object.", key1.equals(key1)); + MessageTypeKeymk = new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID,ExperimenterMessage.class); + Assert.assertFalse("Wrong equal to different class.", key1.equals(mk)); + ExperimenterIdSerializerKey key2 = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterMessage.class); + Assert.assertFalse("Wrong equal by experimenterId.", key1.equals(key2)); + } + } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java index 563cb562..fa924f91 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionDeserializerKeyTest.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterInstructionDeserializerKeyTest { - - /** - * Test ExperimenterInstructionDeserializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterInstructionDeserializerKey key1 = - new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterInstructionDeserializerKey key2 = - new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - } +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInstructionDeserializerKeyTest { + + /** + * Test ExperimenterInstructionDeserializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterInstructionDeserializerKey key1 = + new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterInstructionDeserializerKey key2 = + new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + } } \ No newline at end of file diff --git a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java index 58c535f8..db78e28c 100644 --- a/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java +++ b/openflow-protocol-api/src/test/java/org/opendaylight/openflowjava/protocol/api/keys/experimenter/ExperimenterInstructionSerializerKeyTest.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2014 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.keys.experimenter; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterInstructionSerializerKeyTest { - - /** - * Test ExperimenterInstructionSerializerKey equals and hashCode - */ - @Test - public void test() { - ExperimenterInstructionSerializerKey key1 = - new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterInstructionSerializerKey key2 = - new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - Assert.assertTrue("Wrong equals", key1.equals(key2)); - Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, null); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L); - Assert.assertFalse("Wrong equals", key1.equals(key2)); - Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); - - } +/* + * Copyright (c) 2014 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.keys.experimenter; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterInstructionSerializerKeyTest { + + /** + * Test ExperimenterInstructionSerializerKey equals and hashCode + */ + @Test + public void test() { + ExperimenterInstructionSerializerKey key1 = + new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterInstructionSerializerKey key2 = + new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + Assert.assertTrue("Wrong equals", key1.equals(key2)); + Assert.assertTrue("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, null); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + key2 = new ExperimenterInstructionSerializerKey(EncodeConstants.OF10_VERSION_ID, 55L); + Assert.assertFalse("Wrong equals", key1.equals(key2)); + Assert.assertFalse("Wrong hashcode", key1.hashCode() == key2.hashCode()); + + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java index c453b0b0..7328f8c7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ChannelInitializerFactory.java @@ -1,87 +1,87 @@ -/* - * Copyright (c) 2014 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 org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; - -/** - * @author michal.polkorab - * - */ -public class ChannelInitializerFactory { - - private long switchIdleTimeOut; - private DeserializationFactory deserializationFactory; - private SerializationFactory serializationFactory; - private TlsConfiguration tlsConfig; - private SwitchConnectionHandler switchConnectionHandler; - - /** - * @return PublishingChannelInitializer that initializes new channels - */ - public TcpChannelInitializer createPublishingChannelInitializer() { - TcpChannelInitializer initializer = new TcpChannelInitializer(); - initializer.setSwitchIdleTimeout(switchIdleTimeOut); - initializer.setDeserializationFactory(deserializationFactory); - initializer.setSerializationFactory(serializationFactory); - initializer.setTlsConfiguration(tlsConfig); - initializer.setSwitchConnectionHandler(switchConnectionHandler); - return initializer; - } - - /** - * @return PublishingChannelInitializer that initializes new channels - */ - public UdpChannelInitializer createUdpChannelInitializer() { - UdpChannelInitializer initializer = new UdpChannelInitializer(); - initializer.setSwitchIdleTimeout(switchIdleTimeOut); - initializer.setDeserializationFactory(deserializationFactory); - initializer.setSerializationFactory(serializationFactory); - initializer.setSwitchConnectionHandler(switchConnectionHandler); - return initializer; - } - - /** - * @param switchIdleTimeOut - */ - public void setSwitchIdleTimeout(long switchIdleTimeOut) { - this.switchIdleTimeOut = switchIdleTimeOut; - } - - /** - * @param deserializationFactory - */ - public void setDeserializationFactory(DeserializationFactory deserializationFactory) { - this.deserializationFactory = deserializationFactory; - } - - /** - * @param serializationFactory - */ - public void setSerializationFactory(SerializationFactory serializationFactory) { - this.serializationFactory = serializationFactory; - } - - /** - * @param tlsConfig - */ - public void setTlsConfig(TlsConfiguration tlsConfig) { - this.tlsConfig = tlsConfig; - } - - /** - * @param switchConnectionHandler - */ - public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionHandler) { - this.switchConnectionHandler = switchConnectionHandler; - } +/* + * Copyright (c) 2014 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 org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; + +/** + * @author michal.polkorab + * + */ +public class ChannelInitializerFactory { + + private long switchIdleTimeOut; + private DeserializationFactory deserializationFactory; + private SerializationFactory serializationFactory; + private TlsConfiguration tlsConfig; + private SwitchConnectionHandler switchConnectionHandler; + + /** + * @return PublishingChannelInitializer that initializes new channels + */ + public TcpChannelInitializer createPublishingChannelInitializer() { + TcpChannelInitializer initializer = new TcpChannelInitializer(); + initializer.setSwitchIdleTimeout(switchIdleTimeOut); + initializer.setDeserializationFactory(deserializationFactory); + initializer.setSerializationFactory(serializationFactory); + initializer.setTlsConfiguration(tlsConfig); + initializer.setSwitchConnectionHandler(switchConnectionHandler); + return initializer; + } + + /** + * @return PublishingChannelInitializer that initializes new channels + */ + public UdpChannelInitializer createUdpChannelInitializer() { + UdpChannelInitializer initializer = new UdpChannelInitializer(); + initializer.setSwitchIdleTimeout(switchIdleTimeOut); + initializer.setDeserializationFactory(deserializationFactory); + initializer.setSerializationFactory(serializationFactory); + initializer.setSwitchConnectionHandler(switchConnectionHandler); + return initializer; + } + + /** + * @param switchIdleTimeOut + */ + public void setSwitchIdleTimeout(long switchIdleTimeOut) { + this.switchIdleTimeOut = switchIdleTimeOut; + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } + + /** + * @param tlsConfig + */ + public void setTlsConfig(TlsConfiguration tlsConfig) { + this.tlsConfig = tlsConfig; + } + + /** + * @param switchConnectionHandler + */ + public void setSwitchConnectionHandler(SwitchConnectionHandler switchConnectionHandler) { + this.switchConnectionHandler = switchConnectionHandler; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java index f4240bcc..670f552c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketDecoder.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2014 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.SimpleChannelInboundHandler; - -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author michal.polkorab - * - */ -public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler{ - - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class); - private DeserializationFactory deserializationFactory; - - @Override - public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg) - throws Exception { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("UdpVersionMessageWrapper received"); - LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); - } - DataObject dataObject = null; - try { - dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion()); - if (dataObject == null) { - LOGGER.warn("Translated POJO is null"); - } else { - MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress()); - consumer.consume(dataObject); - } - } catch(Exception e) { - LOGGER.warn("Message deserialization failed"); - LOGGER.warn(e.getMessage(), e); - // TODO: delegate exception to allow easier deserialization - // debugging / deserialization problem awareness - } finally { - msg.getMessageBuffer().release(); - } - } - - /** - * @param deserializationFactory - */ - public void setDeserializationFactory(DeserializationFactory deserializationFactory) { - this.deserializationFactory = deserializationFactory; - } +/* + * Copyright (c) 2014 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.SimpleChannelInboundHandler; + +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketDecoder extends SimpleChannelInboundHandler{ + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketDecoder.class); + private DeserializationFactory deserializationFactory; + + @Override + public void channelRead0(ChannelHandlerContext ctx, VersionMessageUdpWrapper msg) + throws Exception { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("UdpVersionMessageWrapper received"); + LOGGER.debug("<< " + ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); + } + DataObject dataObject = null; + try { + dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(),msg.getVersion()); + if (dataObject == null) { + LOGGER.warn("Translated POJO is null"); + } else { + MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.getAddress()); + consumer.consume(dataObject); + } + } catch(Exception e) { + LOGGER.warn("Message deserialization failed"); + LOGGER.warn(e.getMessage(), e); + // TODO: delegate exception to allow easier deserialization + // debugging / deserialization problem awareness + } finally { + msg.getMessageBuffer().release(); + } + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java index ab455f37..73a7a00e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoder.java @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2014 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.List; - -import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.socket.DatagramPacket; -import io.netty.handler.codec.MessageToMessageEncoder; -import io.netty.util.concurrent.Future; - -/** - * @author michal.polkorab - * - */ -public class OFDatagramPacketEncoder extends MessageToMessageEncoder { - - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class); - private SerializationFactory serializationFactory; - - @Override - protected void encode(ChannelHandlerContext ctx, - UdpMessageListenerWrapper wrapper, List out) throws Exception { - LOGGER.trace("Encoding"); - try { - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg()); - out.add(new DatagramPacket(buffer, wrapper.getAddress())); - } catch(Exception e) { - LOGGER.warn("Message serialization failed: {}", e.getMessage()); - Future newFailedFuture = ctx.newFailedFuture(e); - wrapper.getListener().operationComplete(newFailedFuture); - return; - } - } - - /** - * @param serializationFactory - */ - public void setSerializationFactory(SerializationFactory serializationFactory) { - this.serializationFactory = serializationFactory; - } +/* + * Copyright (c) 2014 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.List; + +import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.socket.DatagramPacket; +import io.netty.handler.codec.MessageToMessageEncoder; +import io.netty.util.concurrent.Future; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketEncoder extends MessageToMessageEncoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketEncoder.class); + private SerializationFactory serializationFactory; + + @Override + protected void encode(ChannelHandlerContext ctx, + UdpMessageListenerWrapper wrapper, List out) throws Exception { + LOGGER.trace("Encoding"); + try { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg()); + out.add(new DatagramPacket(buffer, wrapper.getAddress())); + } catch(Exception e) { + LOGGER.warn("Message serialization failed: {}", e.getMessage()); + Future newFailedFuture = ctx.newFailedFuture(e); + wrapper.getListener().operationComplete(newFailedFuture); + return; + } + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java index 3bda7b21..74e9c3a3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketHandler.java @@ -1,105 +1,105 @@ -/* - * Copyright (c) 2014 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.channel.socket.DatagramPacket; -import io.netty.handler.codec.MessageToMessageDecoder; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author michal.polkorab - * - */ -public class OFDatagramPacketHandler extends MessageToMessageDecoder { - - private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketHandler.class); - - /** Length of OpenFlow 1.3 header */ - public static final byte LENGTH_OF_HEADER = 8; - private static final byte LENGTH_INDEX_IN_HEADER = 2; - private ConnectionAdapterFactory adapterFactory = new ConnectionAdapterFactoryImpl(); - private SwitchConnectionHandler connectionHandler; - - /** - * Default constructor - * @param sch the switchConnectionHandler that decides - * what to do with incomming message / channel - */ - public OFDatagramPacketHandler(SwitchConnectionHandler sch) { - this.connectionHandler = sch; - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - LOGGER.warn("Unexpected exception from downstream.", cause); - LOGGER.warn("Closing connection."); - ctx.close(); - } - - @Override - protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, - List out) throws Exception { - LOGGER.debug("OFDatagramPacketFramer"); - MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender()); - if (consumer == null) { - ConnectionFacade connectionFacade = - adapterFactory.createConnectionFacade(ctx.channel(), msg.sender()); - connectionHandler.onSwitchConnected(connectionFacade); - connectionFacade.checkListeners(); - UdpConnectionMap.addConnection(msg.sender(), connectionFacade); - } - ByteBuf bb = msg.content(); - int readableBytes = bb.readableBytes(); - if (readableBytes < LENGTH_OF_HEADER) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); - LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); - } - return; - } - - int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); - LOGGER.debug("length of actual message: {}", length); - - if (readableBytes < length) { - if (LOGGER.isDebugEnabled()) { - LOGGER.debug("skipping bytebuf - too few bytes for msg: " + - readableBytes + " < " + length); - LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb)); - } - return; - } - LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); - - - byte version = bb.readByte(); - if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) { - LOGGER.debug("detected version: " + version); - ByteBuf messageBuffer = bb.slice(); - out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender())); - messageBuffer.retain(); - } else { - LOGGER.warn("detected version: " + version + " - currently not supported"); - } - bb.skipBytes(bb.readableBytes()); - } +/* + * Copyright (c) 2014 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.channel.socket.DatagramPacket; +import io.netty.handler.codec.MessageToMessageDecoder; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactory; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterFactoryImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionFacade; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class OFDatagramPacketHandler extends MessageToMessageDecoder { + + private static final Logger LOGGER = LoggerFactory.getLogger(OFDatagramPacketHandler.class); + + /** Length of OpenFlow 1.3 header */ + public static final byte LENGTH_OF_HEADER = 8; + private static final byte LENGTH_INDEX_IN_HEADER = 2; + private ConnectionAdapterFactory adapterFactory = new ConnectionAdapterFactoryImpl(); + private SwitchConnectionHandler connectionHandler; + + /** + * Default constructor + * @param sch the switchConnectionHandler that decides + * what to do with incomming message / channel + */ + public OFDatagramPacketHandler(SwitchConnectionHandler sch) { + this.connectionHandler = sch; + } + + @Override + public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { + LOGGER.warn("Unexpected exception from downstream.", cause); + LOGGER.warn("Closing connection."); + ctx.close(); + } + + @Override + protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, + List out) throws Exception { + LOGGER.debug("OFDatagramPacketFramer"); + MessageConsumer consumer = UdpConnectionMap.getMessageConsumer(msg.sender()); + if (consumer == null) { + ConnectionFacade connectionFacade = + adapterFactory.createConnectionFacade(ctx.channel(), msg.sender()); + connectionHandler.onSwitchConnected(connectionFacade); + connectionFacade.checkListeners(); + UdpConnectionMap.addConnection(msg.sender(), connectionFacade); + } + ByteBuf bb = msg.content(); + int readableBytes = bb.readableBytes(); + if (readableBytes < LENGTH_OF_HEADER) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("skipping bytebuf - too few bytes for header: " + readableBytes + " < " + LENGTH_OF_HEADER ); + LOGGER.debug("bb: " + ByteBufUtils.byteBufToHexString(bb)); + } + return; + } + + int length = bb.getUnsignedShort(bb.readerIndex() + LENGTH_INDEX_IN_HEADER); + LOGGER.debug("length of actual message: {}", length); + + if (readableBytes < length) { + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("skipping bytebuf - too few bytes for msg: " + + readableBytes + " < " + length); + LOGGER.debug("bytebuffer: " + ByteBufUtils.byteBufToHexString(bb)); + } + return; + } + LOGGER.debug("OF Protocol message received, type:{}", bb.getByte(bb.readerIndex() + 1)); + + + byte version = bb.readByte(); + if ((version == EncodeConstants.OF13_VERSION_ID) || (version == EncodeConstants.OF10_VERSION_ID)) { + LOGGER.debug("detected version: " + version); + ByteBuf messageBuffer = bb.slice(); + out.add(new VersionMessageUdpWrapper(version, messageBuffer, msg.sender())); + messageBuffer.retain(); + } else { + LOGGER.warn("detected version: " + version + " - currently not supported"); + } + bb.skipBytes(bb.readableBytes()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java index 9a9bf3c4..26dad6d1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/PipelineHandlers.java @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2014 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; - -/** - * Stores names of handlers used in pipeline. - * - * @author michal.polkorab - */ -public enum PipelineHandlers { - - /** - * Detects switch idle state - */ - IDLE_HANDLER, - /** - * Component for handling TLS frames - */ - SSL_HANDLER, - /** - * Decodes incoming messages into message frames - */ - OF_FRAME_DECODER, - /** - * Detects version of incoming OpenFlow Protocol message - */ - OF_VERSION_DETECTOR, - /** - * Transforms OpenFlow Protocol byte messages into POJOs - */ - OF_DECODER, - /** - * Transforms POJOs into OpenFlow Protocol byte messages - */ - OF_ENCODER, - /** - * Delegates translated POJOs into MessageConsumer - */ - DELEGATING_INBOUND_HANDLER, - /** - * Performs efficient flushing - */ - CHANNEL_OUTBOUNF_QUEUE, - /** - * Decodes incoming messages into message frames - * and filters them based on version supported - */ - OF_DATAGRAMPACKET_HANDLER, - /** - * Transforms OpenFlow Protocol datagram messages into POJOs - */ - OF_DATAGRAMPACKET_DECODER, - /** - * Transforms POJOs into OpenFlow Protocol datagrams - */ - OF_DATAGRAMPACKET_ENCODER +/* + * Copyright (c) 2014 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; + +/** + * Stores names of handlers used in pipeline. + * + * @author michal.polkorab + */ +public enum PipelineHandlers { + + /** + * Detects switch idle state + */ + IDLE_HANDLER, + /** + * Component for handling TLS frames + */ + SSL_HANDLER, + /** + * Decodes incoming messages into message frames + */ + OF_FRAME_DECODER, + /** + * Detects version of incoming OpenFlow Protocol message + */ + OF_VERSION_DETECTOR, + /** + * Transforms OpenFlow Protocol byte messages into POJOs + */ + OF_DECODER, + /** + * Transforms POJOs into OpenFlow Protocol byte messages + */ + OF_ENCODER, + /** + * Delegates translated POJOs into MessageConsumer + */ + DELEGATING_INBOUND_HANDLER, + /** + * Performs efficient flushing + */ + CHANNEL_OUTBOUNF_QUEUE, + /** + * Decodes incoming messages into message frames + * and filters them based on version supported + */ + OF_DATAGRAMPACKET_HANDLER, + /** + * Transforms OpenFlow Protocol datagram messages into POJOs + */ + OF_DATAGRAMPACKET_DECODER, + /** + * Transforms POJOs into OpenFlow Protocol datagrams + */ + OF_DATAGRAMPACKET_ENCODER } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java index 2c486f00..2c1d7899 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/ProtocolChannelInitializer.java @@ -1,101 +1,101 @@ -/* - * Copyright (c) 2014 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; -import io.netty.channel.ChannelInitializer; - -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; - -/** - * @param Channel type - * @author michal.polkorab - */ -public abstract class ProtocolChannelInitializer - extends ChannelInitializer { - - private SwitchConnectionHandler switchConnectionHandler; - private long switchIdleTimeout; - private SerializationFactory serializationFactory; - private DeserializationFactory deserializationFactory; - private TlsConfiguration tlsConfiguration; - - /** - * @param switchConnectionHandler the switchConnectionHandler to set - */ - public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { - this.switchConnectionHandler = switchConnectionHandler; - } - - /** - * @param switchIdleTimeout the switchIdleTimeout to set - */ - public void setSwitchIdleTimeout(final long switchIdleTimeout) { - this.switchIdleTimeout = switchIdleTimeout; - } - - /** - * @param serializationFactory - */ - public void setSerializationFactory(final SerializationFactory serializationFactory) { - this.serializationFactory = serializationFactory; - } - - /** - * @param deserializationFactory - */ - public void setDeserializationFactory(final DeserializationFactory deserializationFactory) { - this.deserializationFactory = deserializationFactory; - } - - /** - * @param tlsConfiguration - */ - public void setTlsConfiguration(TlsConfiguration tlsConfiguration) { - this.tlsConfiguration = tlsConfiguration; - } - - /** - * @return switch connection handler - */ - public SwitchConnectionHandler getSwitchConnectionHandler() { - return switchConnectionHandler; - } - - /** - * @return switch idle timeout - */ - public long getSwitchIdleTimeout() { - return switchIdleTimeout; - } - - /** - * @return serialization factory - */ - public SerializationFactory getSerializationFactory() { - return serializationFactory; - } - - /** - * @return deserialization factory - */ - public DeserializationFactory getDeserializationFactory() { - return deserializationFactory; - } - - /** - * @return TLS configuration - */ - public TlsConfiguration getTlsConfiguration() { - return tlsConfiguration; - } +/* + * Copyright (c) 2014 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; +import io.netty.channel.ChannelInitializer; + +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializationFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; + +/** + * @param Channel type + * @author michal.polkorab + */ +public abstract class ProtocolChannelInitializer + extends ChannelInitializer { + + private SwitchConnectionHandler switchConnectionHandler; + private long switchIdleTimeout; + private SerializationFactory serializationFactory; + private DeserializationFactory deserializationFactory; + private TlsConfiguration tlsConfiguration; + + /** + * @param switchConnectionHandler the switchConnectionHandler to set + */ + public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) { + this.switchConnectionHandler = switchConnectionHandler; + } + + /** + * @param switchIdleTimeout the switchIdleTimeout to set + */ + public void setSwitchIdleTimeout(final long switchIdleTimeout) { + this.switchIdleTimeout = switchIdleTimeout; + } + + /** + * @param serializationFactory + */ + public void setSerializationFactory(final SerializationFactory serializationFactory) { + this.serializationFactory = serializationFactory; + } + + /** + * @param deserializationFactory + */ + public void setDeserializationFactory(final DeserializationFactory deserializationFactory) { + this.deserializationFactory = deserializationFactory; + } + + /** + * @param tlsConfiguration + */ + public void setTlsConfiguration(TlsConfiguration tlsConfiguration) { + this.tlsConfiguration = tlsConfiguration; + } + + /** + * @return switch connection handler + */ + public SwitchConnectionHandler getSwitchConnectionHandler() { + return switchConnectionHandler; + } + + /** + * @return switch idle timeout + */ + public long getSwitchIdleTimeout() { + return switchIdleTimeout; + } + + /** + * @return serialization factory + */ + public SerializationFactory getSerializationFactory() { + return serializationFactory; + } + + /** + * @return deserialization factory + */ + public DeserializationFactory getDeserializationFactory() { + return deserializationFactory; + } + + /** + * @return TLS configuration + */ + public TlsConfiguration getTlsConfiguration() { + return tlsConfiguration; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java index 51871440..9ff7d65b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpChannelInitializer.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2014 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.socket.nio.NioDatagramChannel; - -/** - * @author michal.polkorab - * - */ -public class UdpChannelInitializer extends ProtocolChannelInitializer { - - @Override - protected void initChannel(NioDatagramChannel ch) throws Exception { - ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_HANDLER.name(), - new OFDatagramPacketHandler(getSwitchConnectionHandler())); - OFDatagramPacketDecoder ofDatagramPacketDecoder = new OFDatagramPacketDecoder(); - ofDatagramPacketDecoder.setDeserializationFactory(getDeserializationFactory()); - ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_DECODER.name(), - ofDatagramPacketDecoder); - OFDatagramPacketEncoder ofDatagramPacketEncoder = new OFDatagramPacketEncoder(); - ofDatagramPacketEncoder.setSerializationFactory(getSerializationFactory()); - ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofDatagramPacketEncoder); -// connectionFacade.fireConnectionReadyNotification(); - } +/* + * Copyright (c) 2014 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.socket.nio.NioDatagramChannel; + +/** + * @author michal.polkorab + * + */ +public class UdpChannelInitializer extends ProtocolChannelInitializer { + + @Override + protected void initChannel(NioDatagramChannel ch) throws Exception { + ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_HANDLER.name(), + new OFDatagramPacketHandler(getSwitchConnectionHandler())); + OFDatagramPacketDecoder ofDatagramPacketDecoder = new OFDatagramPacketDecoder(); + ofDatagramPacketDecoder.setDeserializationFactory(getDeserializationFactory()); + ch.pipeline().addLast(PipelineHandlers.OF_DATAGRAMPACKET_DECODER.name(), + ofDatagramPacketDecoder); + OFDatagramPacketEncoder ofDatagramPacketEncoder = new OFDatagramPacketEncoder(); + ofDatagramPacketEncoder.setSerializationFactory(getSerializationFactory()); + ch.pipeline().addLast(PipelineHandlers.OF_ENCODER.name(), ofDatagramPacketEncoder); +// connectionFacade.fireConnectionReadyNotification(); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java index d33f3a0b..d23d5ada 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpConnectionMap.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2014 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.net.InetSocketAddress; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; - -/** - * As UDP communication is handled only by one channel, it is needed - * to store MessageConsumers, so that we know which consumer handles which channel - - * @author michal.polkorab - */ -public final class UdpConnectionMap { - - private static Map connectionMap = new ConcurrentHashMap<>(); - - private UdpConnectionMap() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * @param address sender's address - * @return corresponding MessageConsumer - */ - public static MessageConsumer getMessageConsumer(InetSocketAddress address) { - if(address == null){ - throw new IllegalArgumentException("Address can not be null"); - } - return connectionMap.get(address); - } - - /** - * @param address sender's address - * @param consumer MessageConsumer to be added / paired with specified address - */ - public static void addConnection(InetSocketAddress address, MessageConsumer consumer) { - if(address == null){ - throw new IllegalArgumentException("Address can not be null"); - } - connectionMap.put(address, consumer); - } - - /** - * @param address sender's address - */ - public static void removeConnection(InetSocketAddress address) { - if(address == null){ - throw new IllegalArgumentException("Address can not be null"); - } - connectionMap.remove(address); - } +/* + * Copyright (c) 2014 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.net.InetSocketAddress; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageConsumer; + +/** + * As UDP communication is handled only by one channel, it is needed + * to store MessageConsumers, so that we know which consumer handles which channel + + * @author michal.polkorab + */ +public final class UdpConnectionMap { + + private static Map connectionMap = new ConcurrentHashMap<>(); + + private UdpConnectionMap() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * @param address sender's address + * @return corresponding MessageConsumer + */ + public static MessageConsumer getMessageConsumer(InetSocketAddress address) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } + return connectionMap.get(address); + } + + /** + * @param address sender's address + * @param consumer MessageConsumer to be added / paired with specified address + */ + public static void addConnection(InetSocketAddress address, MessageConsumer consumer) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } + connectionMap.put(address, consumer); + } + + /** + * @param address sender's address + */ + public static void removeConnection(InetSocketAddress address) { + if(address == null){ + throw new IllegalArgumentException("Address can not be null"); + } + connectionMap.remove(address); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java index 2ebeec76..0d7bb4e5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -1,149 +1,149 @@ -/* - * Copyright (c) 2014 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.Bootstrap; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.nio.NioDatagramChannel; -import io.netty.util.concurrent.GenericFutureListener; - -import java.net.InetAddress; -import java.net.InetSocketAddress; - -import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.SettableFuture; - -/** - * Class implementing server over UDP for handling incoming connections. - * - * @author michal.polkorab - */ -public final class UdpHandler implements ServerFacade { - - private static final Logger LOGGER = LoggerFactory - .getLogger(UdpHandler.class); - private int port; - private EventLoopGroup group; - private final InetAddress startupAddress; - private final SettableFuture isOnlineFuture; - private UdpChannelInitializer channelInitializer; - private ThreadConfiguration threadConfig; - - /** - * Constructor of UdpHandler that listens on selected port. - * - * @param port listening port of UdpHandler server - */ - public UdpHandler(final int port) { - this(null, port); - } - - /** - * Constructor of UdpHandler that listens on selected address and port. - * @param address listening address of UdpHandler server - * @param port listening port of UdpHandler server - */ - public UdpHandler(final InetAddress address, final int port) { - this.port = port; - this.startupAddress = address; - isOnlineFuture = SettableFuture.create(); - } - - @Override - public void run() { - if (threadConfig != null) { - group = new NioEventLoopGroup(threadConfig.getWorkerThreadCount()); - } else { - group = new NioEventLoopGroup(); - } - final ChannelFuture f; - try { - Bootstrap b = new Bootstrap(); - b.group(group) - .channel(NioDatagramChannel.class) - .option(ChannelOption.SO_BROADCAST, false) - .handler(channelInitializer); - - if (startupAddress != null) { - f = b.bind(startupAddress.getHostAddress(), port).sync(); - } else { - f = b.bind(port).sync(); - } - } catch (InterruptedException e) { - LOGGER.error("Interrupted while binding port {}", port, e); - return; - } - - try { - InetSocketAddress isa = (InetSocketAddress) f.channel().localAddress(); - String address = isa.getHostString(); - - // Update port, as it may have been specified as 0 - this.port = isa.getPort(); - - LOGGER.debug("Address from udpHandler: {}", address); - isOnlineFuture.set(true); - LOGGER.info("Switch listener started and ready to accept incoming udp connections on port: {}", port); - f.channel().closeFuture().sync(); - } catch (InterruptedException e) { - LOGGER.error("Interrupted while waiting for port {} shutdown", port, e); - } finally { - shutdown(); - } - } - - @Override - public ListenableFuture shutdown() { - final SettableFuture result = SettableFuture.create(); - group.shutdownGracefully().addListener(new GenericFutureListener>() { - - @Override - public void operationComplete( - final io.netty.util.concurrent.Future downResult) throws Exception { - result.set(downResult.isSuccess()); - if (downResult.cause() != null) { - result.setException(downResult.cause()); - } - } - - }); - return result; - } - - @Override - public ListenableFuture getIsOnlineFuture() { - return isOnlineFuture; - } - - /** - * @return the port - */ - public int getPort() { - return port; - } - - /** - * @param channelInitializer - */ - public void setChannelInitializer(UdpChannelInitializer channelInitializer) { - this.channelInitializer = channelInitializer; - } - - @Override - public void setThreadConfig(ThreadConfiguration threadConfig) { - this.threadConfig = threadConfig; - } +/* + * Copyright (c) 2014 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.Bootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelOption; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioDatagramChannel; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetAddress; +import java.net.InetSocketAddress; + +import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.SettableFuture; + +/** + * Class implementing server over UDP for handling incoming connections. + * + * @author michal.polkorab + */ +public final class UdpHandler implements ServerFacade { + + private static final Logger LOGGER = LoggerFactory + .getLogger(UdpHandler.class); + private int port; + private EventLoopGroup group; + private final InetAddress startupAddress; + private final SettableFuture isOnlineFuture; + private UdpChannelInitializer channelInitializer; + private ThreadConfiguration threadConfig; + + /** + * Constructor of UdpHandler that listens on selected port. + * + * @param port listening port of UdpHandler server + */ + public UdpHandler(final int port) { + this(null, port); + } + + /** + * Constructor of UdpHandler that listens on selected address and port. + * @param address listening address of UdpHandler server + * @param port listening port of UdpHandler server + */ + public UdpHandler(final InetAddress address, final int port) { + this.port = port; + this.startupAddress = address; + isOnlineFuture = SettableFuture.create(); + } + + @Override + public void run() { + if (threadConfig != null) { + group = new NioEventLoopGroup(threadConfig.getWorkerThreadCount()); + } else { + group = new NioEventLoopGroup(); + } + final ChannelFuture f; + try { + Bootstrap b = new Bootstrap(); + b.group(group) + .channel(NioDatagramChannel.class) + .option(ChannelOption.SO_BROADCAST, false) + .handler(channelInitializer); + + if (startupAddress != null) { + f = b.bind(startupAddress.getHostAddress(), port).sync(); + } else { + f = b.bind(port).sync(); + } + } catch (InterruptedException e) { + LOGGER.error("Interrupted while binding port {}", port, e); + return; + } + + try { + InetSocketAddress isa = (InetSocketAddress) f.channel().localAddress(); + String address = isa.getHostString(); + + // Update port, as it may have been specified as 0 + this.port = isa.getPort(); + + LOGGER.debug("Address from udpHandler: {}", address); + isOnlineFuture.set(true); + LOGGER.info("Switch listener started and ready to accept incoming udp connections on port: {}", port); + f.channel().closeFuture().sync(); + } catch (InterruptedException e) { + LOGGER.error("Interrupted while waiting for port {} shutdown", port, e); + } finally { + shutdown(); + } + } + + @Override + public ListenableFuture shutdown() { + final SettableFuture result = SettableFuture.create(); + group.shutdownGracefully().addListener(new GenericFutureListener>() { + + @Override + public void operationComplete( + final io.netty.util.concurrent.Future downResult) throws Exception { + result.set(downResult.isSuccess()); + if (downResult.cause() != null) { + result.setException(downResult.cause()); + } + } + + }); + return result; + } + + @Override + public ListenableFuture getIsOnlineFuture() { + return isOnlineFuture; + } + + /** + * @return the port + */ + public int getPort() { + return port; + } + + /** + * @param channelInitializer + */ + public void setChannelInitializer(UdpChannelInitializer channelInitializer) { + this.channelInitializer = channelInitializer; + } + + @Override + public void setThreadConfig(ThreadConfiguration threadConfig) { + this.threadConfig = threadConfig; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java index 087bcb6b..e9a8bf98 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/VersionMessageUdpWrapper.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2014 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 java.net.InetSocketAddress; - -/** - * Wraps received messages (includes version) and sender address - - * @author michal.polkorab - */ -public class VersionMessageUdpWrapper extends VersionMessageWrapper { - - private InetSocketAddress address; - - /** - * @param version Openflow wire version - * @param messageBuffer ByteBuf containing binary message - * @param address sender address - */ - public VersionMessageUdpWrapper(short version, ByteBuf messageBuffer, InetSocketAddress address) { - super(version, messageBuffer); - this.address = address; - } - - /** - * @return sender address - */ - public InetSocketAddress getAddress() { - return address; - } +/* + * Copyright (c) 2014 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 java.net.InetSocketAddress; + +/** + * Wraps received messages (includes version) and sender address + + * @author michal.polkorab + */ +public class VersionMessageUdpWrapper extends VersionMessageWrapper { + + private InetSocketAddress address; + + /** + * @param version Openflow wire version + * @param messageBuffer ByteBuf containing binary message + * @param address sender address + */ + public VersionMessageUdpWrapper(short version, ByteBuf messageBuffer, InetSocketAddress address) { + super(version, messageBuffer); + this.address = address; + } + + /** + * @return sender address + */ + public InetSocketAddress getAddress() { + return address; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java index 51ab4b82..ec415b38 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapper.java @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2014 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.connection; - -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; - -/** - * Wraps outgoing message and includes listener attached to this message. This object - * is sent to OFEncoder. When OFEncoder fails to serialize the message, - * listener is filled with exception. The exception is then delegated to upper ODL layers. - * @author michal.polkorab - */ -public class MessageListenerWrapper { - - private OfHeader msg; - private GenericFutureListener> listener; - - /** - * @param msg outgoing message - * @param listener listener attached to channel.write(msg) Future - */ - public MessageListenerWrapper(Object msg, GenericFutureListener> listener) { - this.msg = (OfHeader) msg; - this.listener = listener; - } - - /** - * @return outgoing message (downstream) - */ - public OfHeader getMsg() { - return msg; - } - - - /** - * @return listener listening on message sending success / failure - */ - public GenericFutureListener> getListener() { - return listener; - } +/* + * Copyright (c) 2014 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.connection; + +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; + +/** + * Wraps outgoing message and includes listener attached to this message. This object + * is sent to OFEncoder. When OFEncoder fails to serialize the message, + * listener is filled with exception. The exception is then delegated to upper ODL layers. + * @author michal.polkorab + */ +public class MessageListenerWrapper { + + private OfHeader msg; + private GenericFutureListener> listener; + + /** + * @param msg outgoing message + * @param listener listener attached to channel.write(msg) Future + */ + public MessageListenerWrapper(Object msg, GenericFutureListener> listener) { + this.msg = (OfHeader) msg; + this.listener = listener; + } + + /** + * @return outgoing message (downstream) + */ + public OfHeader getMsg() { + return msg; + } + + + /** + * @return listener listening on message sending success / failure + */ + public GenericFutureListener> getListener() { + return listener; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java index 56d004bd..a946cf54 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpMessageListenerWrapper.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2014 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.connection; - -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; - -import java.net.InetSocketAddress; - -/** - * Wraps outgoing message and includes listener attached to this message. This object - * is sent to OFEncoder. When OFEncoder fails to serialize the message, - * listener is filled with exception. The exception is then delegated to upper ODL layers. - * This object is used for UDP communication - it also carries recipient address - - * @author michal.polkorab - */ -public class UdpMessageListenerWrapper extends MessageListenerWrapper { - - private InetSocketAddress address; - - /** - * @param msg message to be sent - * @param listener listener attached to channel.write(msg) Future - * @param address recipient's address - */ - public UdpMessageListenerWrapper(Object msg, GenericFutureListener> listener, - InetSocketAddress address) { - super(msg, listener); - this.address = address; - } - - /** - * @return recipient address - */ - public InetSocketAddress getAddress() { - return address; - } +/* + * Copyright (c) 2014 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.connection; + +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetSocketAddress; + +/** + * Wraps outgoing message and includes listener attached to this message. This object + * is sent to OFEncoder. When OFEncoder fails to serialize the message, + * listener is filled with exception. The exception is then delegated to upper ODL layers. + * This object is used for UDP communication - it also carries recipient address + + * @author michal.polkorab + */ +public class UdpMessageListenerWrapper extends MessageListenerWrapper { + + private InetSocketAddress address; + + /** + * @param msg message to be sent + * @param listener listener attached to channel.write(msg) Future + * @param address recipient's address + */ + public UdpMessageListenerWrapper(Object msg, GenericFutureListener> listener, + InetSocketAddress address) { + super(msg, listener); + this.address = address; + } + + /** + * @return recipient address + */ + public InetSocketAddress getAddress() { + return address; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java index cbec7394..e946f30f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/ActionDeserializerInitializer.java @@ -1,92 +1,92 @@ -/* - * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10EnqueueActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10OutputActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlDstActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlSrcActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwDstActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwSrcActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwTosActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpDstActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpSrcActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanPcpActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanVidActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10StripVlanActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlInActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlOutActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecMplsTtlActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecNwTtlActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13GroupActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13OutputActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopMplsActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopPbbActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopVlanActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushMplsActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushPbbActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushVlanActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetFieldActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetMplsTtlActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetNwTtlActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.ActionDeserializerRegistryHelper; - -/** - * @author michal.polkorab - * - */ -public final class ActionDeserializerInitializer { - - private ActionDeserializerInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers action deserializers - * @param registry registry to be filled with deserializers - */ - public static void registerDeserializers(DeserializerRegistry registry) { - // register OF v1.0 action deserializers - ActionDeserializerRegistryHelper helper = - new ActionDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); - helper.registerDeserializer(0, new OF10OutputActionDeserializer()); - helper.registerDeserializer(1, new OF10SetVlanVidActionDeserializer()); - helper.registerDeserializer(2, new OF10SetVlanPcpActionDeserializer()); - helper.registerDeserializer(3, new OF10StripVlanActionDeserializer()); - helper.registerDeserializer(4, new OF10SetDlSrcActionDeserializer()); - helper.registerDeserializer(5, new OF10SetDlDstActionDeserializer()); - helper.registerDeserializer(6, new OF10SetNwSrcActionDeserializer()); - helper.registerDeserializer(7, new OF10SetNwDstActionDeserializer()); - helper.registerDeserializer(8, new OF10SetNwTosActionDeserializer()); - helper.registerDeserializer(9, new OF10SetTpSrcActionDeserializer()); - helper.registerDeserializer(10, new OF10SetTpDstActionDeserializer()); - helper.registerDeserializer(11, new OF10EnqueueActionDeserializer()); - // register OF v1.3 action deserializers - helper = new ActionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(0, new OF13OutputActionDeserializer()); - helper.registerDeserializer(11, new OF13CopyTtlOutActionDeserializer()); - helper.registerDeserializer(12, new OF13CopyTtlInActionDeserializer()); - helper.registerDeserializer(15, new OF13SetMplsTtlActionDeserializer()); - helper.registerDeserializer(16, new OF13DecMplsTtlActionDeserializer()); - helper.registerDeserializer(17, new OF13PushVlanActionDeserializer()); - helper.registerDeserializer(18, new OF13PopVlanActionDeserializer()); - helper.registerDeserializer(19, new OF13PushMplsActionDeserializer()); - helper.registerDeserializer(20, new OF13PopMplsActionDeserializer()); - helper.registerDeserializer(21, new OF13SetQueueActionDeserializer()); - helper.registerDeserializer(22, new OF13GroupActionDeserializer()); - helper.registerDeserializer(23, new OF13SetNwTtlActionDeserializer()); - helper.registerDeserializer(24, new OF13DecNwTtlActionDeserializer()); - helper.registerDeserializer(25, new OF13SetFieldActionDeserializer()); - helper.registerDeserializer(26, new OF13PushPbbActionDeserializer()); - helper.registerDeserializer(27, new OF13PopPbbActionDeserializer()); - } +/* + * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10EnqueueActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10OutputActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlDstActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetDlSrcActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwDstActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwSrcActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetNwTosActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpDstActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetTpSrcActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanPcpActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10SetVlanVidActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF10StripVlanActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlInActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13CopyTtlOutActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecMplsTtlActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13DecNwTtlActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13GroupActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13OutputActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopMplsActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopPbbActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PopVlanActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushMplsActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushPbbActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13PushVlanActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetFieldActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetMplsTtlActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetNwTtlActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.OF13SetQueueActionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.util.ActionDeserializerRegistryHelper; + +/** + * @author michal.polkorab + * + */ +public final class ActionDeserializerInitializer { + + private ActionDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers action deserializers + * @param registry registry to be filled with deserializers + */ + public static void registerDeserializers(DeserializerRegistry registry) { + // register OF v1.0 action deserializers + ActionDeserializerRegistryHelper helper = + new ActionDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); + helper.registerDeserializer(0, new OF10OutputActionDeserializer()); + helper.registerDeserializer(1, new OF10SetVlanVidActionDeserializer()); + helper.registerDeserializer(2, new OF10SetVlanPcpActionDeserializer()); + helper.registerDeserializer(3, new OF10StripVlanActionDeserializer()); + helper.registerDeserializer(4, new OF10SetDlSrcActionDeserializer()); + helper.registerDeserializer(5, new OF10SetDlDstActionDeserializer()); + helper.registerDeserializer(6, new OF10SetNwSrcActionDeserializer()); + helper.registerDeserializer(7, new OF10SetNwDstActionDeserializer()); + helper.registerDeserializer(8, new OF10SetNwTosActionDeserializer()); + helper.registerDeserializer(9, new OF10SetTpSrcActionDeserializer()); + helper.registerDeserializer(10, new OF10SetTpDstActionDeserializer()); + helper.registerDeserializer(11, new OF10EnqueueActionDeserializer()); + // register OF v1.3 action deserializers + helper = new ActionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(0, new OF13OutputActionDeserializer()); + helper.registerDeserializer(11, new OF13CopyTtlOutActionDeserializer()); + helper.registerDeserializer(12, new OF13CopyTtlInActionDeserializer()); + helper.registerDeserializer(15, new OF13SetMplsTtlActionDeserializer()); + helper.registerDeserializer(16, new OF13DecMplsTtlActionDeserializer()); + helper.registerDeserializer(17, new OF13PushVlanActionDeserializer()); + helper.registerDeserializer(18, new OF13PopVlanActionDeserializer()); + helper.registerDeserializer(19, new OF13PushMplsActionDeserializer()); + helper.registerDeserializer(20, new OF13PopMplsActionDeserializer()); + helper.registerDeserializer(21, new OF13SetQueueActionDeserializer()); + helper.registerDeserializer(22, new OF13GroupActionDeserializer()); + helper.registerDeserializer(23, new OF13SetNwTtlActionDeserializer()); + helper.registerDeserializer(24, new OF13DecNwTtlActionDeserializer()); + helper.registerDeserializer(25, new OF13SetFieldActionDeserializer()); + helper.registerDeserializer(26, new OF13PushPbbActionDeserializer()); + helper.registerDeserializer(27, new OF13PopPbbActionDeserializer()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java index 9fcfd4d6..40cae2c4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/InstructionDeserializerInitializer.java @@ -1,46 +1,46 @@ -/* - * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ApplyActionsInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ClearActionsInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.GoToTableInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.MeterInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteActionsInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteMetadataInstructionDeserializer; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionDeserializerRegistryHelper; - -/** - * @author michal.polkorab - * - */ -public final class InstructionDeserializerInitializer { - - private InstructionDeserializerInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers instruction deserializers - * @param registry registry to be filled with deserializers - */ - public static void registerDeserializers(DeserializerRegistry registry) { - // register OF v1.3 instruction deserializers - InstructionDeserializerRegistryHelper helper = - new InstructionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(1, new GoToTableInstructionDeserializer()); - helper.registerDeserializer(2, new WriteMetadataInstructionDeserializer()); - helper.registerDeserializer(3, new WriteActionsInstructionDeserializer()); - helper.registerDeserializer(4, new ApplyActionsInstructionDeserializer()); - helper.registerDeserializer(5, new ClearActionsInstructionDeserializer()); - helper.registerDeserializer(6, new MeterInstructionDeserializer()); - } +/* + * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ApplyActionsInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.ClearActionsInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.GoToTableInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.MeterInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteActionsInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.instruction.WriteMetadataInstructionDeserializer; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionDeserializerRegistryHelper; + +/** + * @author michal.polkorab + * + */ +public final class InstructionDeserializerInitializer { + + private InstructionDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers instruction deserializers + * @param registry registry to be filled with deserializers + */ + public static void registerDeserializers(DeserializerRegistry registry) { + // register OF v1.3 instruction deserializers + InstructionDeserializerRegistryHelper helper = + new InstructionDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(1, new GoToTableInstructionDeserializer()); + helper.registerDeserializer(2, new WriteMetadataInstructionDeserializer()); + helper.registerDeserializer(3, new WriteActionsInstructionDeserializer()); + helper.registerDeserializer(4, new ApplyActionsInstructionDeserializer()); + helper.registerDeserializer(5, new ClearActionsInstructionDeserializer()); + helper.registerDeserializer(6, new MeterInstructionDeserializer()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java index 28f87a4c..46273e89 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MatchEntryDeserializerInitializer.java @@ -1,127 +1,127 @@ -/* - * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTcpFlagDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4DstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4SrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpThaDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpTpaDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthDstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthSrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthTypeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4CodeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4TypeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6CodeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6TypeDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPhyPortDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPortDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpDscpDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpEcnDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpProtoDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4DstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4SrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6DstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6ExtHdrDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6FlabelDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdSllDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTargetDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTllDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6SrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMetadataDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsBosDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsLabelDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsTcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmPbbIsidDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpDstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpSrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpDstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpSrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTunnelIdDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpDstDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpSrcDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer; -import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public final class MatchEntryDeserializerInitializer { - - private MatchEntryDeserializerInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers match entry deserializers - * @param registry registry to be filled with deserializers - */ - public static void registerMatchEntryDeserializers(DeserializerRegistry registry) { - // register OpenflowBasicClass match entry deserializers - MatchEntryDeserializerRegistryHelper helper = - new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, - OxmMatchConstants.OPENFLOW_BASIC_CLASS, registry); - helper.register(OxmMatchConstants.IN_PORT, new OxmInPortDeserializer()); - helper.register(OxmMatchConstants.IN_PHY_PORT, new OxmInPhyPortDeserializer()); - helper.register(OxmMatchConstants.METADATA, new OxmMetadataDeserializer()); - helper.register(OxmMatchConstants.ETH_DST, new OxmEthDstDeserializer()); - helper.register(OxmMatchConstants.ETH_SRC, new OxmEthSrcDeserializer()); - helper.register(OxmMatchConstants.ETH_TYPE, new OxmEthTypeDeserializer()); - helper.register(OxmMatchConstants.VLAN_VID, new OxmVlanVidDeserializer()); - helper.register(OxmMatchConstants.VLAN_PCP, new OxmVlanPcpDeserializer()); - helper.register(OxmMatchConstants.IP_DSCP, new OxmIpDscpDeserializer()); - helper.register(OxmMatchConstants.IP_ECN, new OxmIpEcnDeserializer()); - helper.register(OxmMatchConstants.IP_PROTO, new OxmIpProtoDeserializer()); - helper.register(OxmMatchConstants.IPV4_SRC, new OxmIpv4SrcDeserializer()); - helper.register(OxmMatchConstants.IPV4_DST, new OxmIpv4DstDeserializer()); - helper.register(OxmMatchConstants.TCP_SRC, new OxmTcpSrcDeserializer()); - helper.register(OxmMatchConstants.TCP_DST, new OxmTcpDstDeserializer()); - helper.register(OxmMatchConstants.UDP_SRC, new OxmUdpSrcDeserializer()); - helper.register(OxmMatchConstants.UDP_DST, new OxmUdpDstDeserializer()); - helper.register(OxmMatchConstants.SCTP_SRC, new OxmSctpSrcDeserializer()); - helper.register(OxmMatchConstants.SCTP_DST, new OxmSctpDstDeserializer()); - helper.register(OxmMatchConstants.ICMPV4_TYPE, new OxmIcmpv4TypeDeserializer()); - helper.register(OxmMatchConstants.ICMPV4_CODE, new OxmIcmpv4CodeDeserializer()); - helper.register(OxmMatchConstants.ARP_OP, new OxmArpOpDeserializer()); - helper.register(OxmMatchConstants.ARP_SPA, new OxmArpSpaDeserializer()); - helper.register(OxmMatchConstants.ARP_TPA, new OxmArpTpaDeserializer()); - helper.register(OxmMatchConstants.ARP_SHA, new OxmArpShaDeserializer()); - helper.register(OxmMatchConstants.ARP_THA, new OxmArpThaDeserializer()); - helper.register(OxmMatchConstants.IPV6_SRC, new OxmIpv6SrcDeserializer()); - helper.register(OxmMatchConstants.IPV6_DST, new OxmIpv6DstDeserializer()); - helper.register(OxmMatchConstants.IPV6_FLABEL, new OxmIpv6FlabelDeserializer()); - helper.register(OxmMatchConstants.ICMPV6_TYPE, new OxmIcmpv6TypeDeserializer()); - helper.register(OxmMatchConstants.ICMPV6_CODE, new OxmIcmpv6CodeDeserializer()); - helper.register(OxmMatchConstants.IPV6_ND_TARGET, new OxmIpv6NdTargetDeserializer()); - helper.register(OxmMatchConstants.IPV6_ND_SLL, new OxmIpv6NdSllDeserializer()); - helper.register(OxmMatchConstants.IPV6_ND_TLL, new OxmIpv6NdTllDeserializer()); - helper.register(OxmMatchConstants.MPLS_LABEL, new OxmMplsLabelDeserializer()); - helper.register(OxmMatchConstants.MPLS_TC, new OxmMplsTcDeserializer()); - helper.register(OxmMatchConstants.MPLS_BOS, new OxmMplsBosDeserializer()); - helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer()); - helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer()); - helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer()); - - // Register NXM1Class match entry deserializers - MatchEntryDeserializerRegistryHelper nxm1helper = - new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, - OxmMatchConstants.NXM_1_CLASS, registry); - nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_SRC, new NxmTunnelIpv4SrcDeserializer()); - nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_DST, new NxmTunnelIpv4DstDeserializer()); - nxm1helper.register(OxmMatchConstants.NXM_NX_TCP_FLAG, new NxmTcpFlagDeserializer()); - - } -} +/* + * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTcpFlagDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4DstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.NxmTunnelIpv4SrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpOpDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpShaDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpSpaDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpThaDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmArpTpaDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthDstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthSrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmEthTypeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4CodeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv4TypeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6CodeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIcmpv6TypeDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPhyPortDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmInPortDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpDscpDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpEcnDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpProtoDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4DstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv4SrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6DstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6ExtHdrDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6FlabelDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdSllDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTargetDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6NdTllDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmIpv6SrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMetadataDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsBosDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsLabelDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmMplsTcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmPbbIsidDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpDstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmSctpSrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpDstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTcpSrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmTunnelIdDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpDstDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmUdpSrcDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanPcpDeserializer; +import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmVlanVidDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.MatchEntryDeserializerRegistryHelper; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public final class MatchEntryDeserializerInitializer { + + private MatchEntryDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers match entry deserializers + * @param registry registry to be filled with deserializers + */ + public static void registerMatchEntryDeserializers(DeserializerRegistry registry) { + // register OpenflowBasicClass match entry deserializers + MatchEntryDeserializerRegistryHelper helper = + new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, + OxmMatchConstants.OPENFLOW_BASIC_CLASS, registry); + helper.register(OxmMatchConstants.IN_PORT, new OxmInPortDeserializer()); + helper.register(OxmMatchConstants.IN_PHY_PORT, new OxmInPhyPortDeserializer()); + helper.register(OxmMatchConstants.METADATA, new OxmMetadataDeserializer()); + helper.register(OxmMatchConstants.ETH_DST, new OxmEthDstDeserializer()); + helper.register(OxmMatchConstants.ETH_SRC, new OxmEthSrcDeserializer()); + helper.register(OxmMatchConstants.ETH_TYPE, new OxmEthTypeDeserializer()); + helper.register(OxmMatchConstants.VLAN_VID, new OxmVlanVidDeserializer()); + helper.register(OxmMatchConstants.VLAN_PCP, new OxmVlanPcpDeserializer()); + helper.register(OxmMatchConstants.IP_DSCP, new OxmIpDscpDeserializer()); + helper.register(OxmMatchConstants.IP_ECN, new OxmIpEcnDeserializer()); + helper.register(OxmMatchConstants.IP_PROTO, new OxmIpProtoDeserializer()); + helper.register(OxmMatchConstants.IPV4_SRC, new OxmIpv4SrcDeserializer()); + helper.register(OxmMatchConstants.IPV4_DST, new OxmIpv4DstDeserializer()); + helper.register(OxmMatchConstants.TCP_SRC, new OxmTcpSrcDeserializer()); + helper.register(OxmMatchConstants.TCP_DST, new OxmTcpDstDeserializer()); + helper.register(OxmMatchConstants.UDP_SRC, new OxmUdpSrcDeserializer()); + helper.register(OxmMatchConstants.UDP_DST, new OxmUdpDstDeserializer()); + helper.register(OxmMatchConstants.SCTP_SRC, new OxmSctpSrcDeserializer()); + helper.register(OxmMatchConstants.SCTP_DST, new OxmSctpDstDeserializer()); + helper.register(OxmMatchConstants.ICMPV4_TYPE, new OxmIcmpv4TypeDeserializer()); + helper.register(OxmMatchConstants.ICMPV4_CODE, new OxmIcmpv4CodeDeserializer()); + helper.register(OxmMatchConstants.ARP_OP, new OxmArpOpDeserializer()); + helper.register(OxmMatchConstants.ARP_SPA, new OxmArpSpaDeserializer()); + helper.register(OxmMatchConstants.ARP_TPA, new OxmArpTpaDeserializer()); + helper.register(OxmMatchConstants.ARP_SHA, new OxmArpShaDeserializer()); + helper.register(OxmMatchConstants.ARP_THA, new OxmArpThaDeserializer()); + helper.register(OxmMatchConstants.IPV6_SRC, new OxmIpv6SrcDeserializer()); + helper.register(OxmMatchConstants.IPV6_DST, new OxmIpv6DstDeserializer()); + helper.register(OxmMatchConstants.IPV6_FLABEL, new OxmIpv6FlabelDeserializer()); + helper.register(OxmMatchConstants.ICMPV6_TYPE, new OxmIcmpv6TypeDeserializer()); + helper.register(OxmMatchConstants.ICMPV6_CODE, new OxmIcmpv6CodeDeserializer()); + helper.register(OxmMatchConstants.IPV6_ND_TARGET, new OxmIpv6NdTargetDeserializer()); + helper.register(OxmMatchConstants.IPV6_ND_SLL, new OxmIpv6NdSllDeserializer()); + helper.register(OxmMatchConstants.IPV6_ND_TLL, new OxmIpv6NdTllDeserializer()); + helper.register(OxmMatchConstants.MPLS_LABEL, new OxmMplsLabelDeserializer()); + helper.register(OxmMatchConstants.MPLS_TC, new OxmMplsTcDeserializer()); + helper.register(OxmMatchConstants.MPLS_BOS, new OxmMplsBosDeserializer()); + helper.register(OxmMatchConstants.PBB_ISID, new OxmPbbIsidDeserializer()); + helper.register(OxmMatchConstants.TUNNEL_ID, new OxmTunnelIdDeserializer()); + helper.register(OxmMatchConstants.IPV6_EXTHDR, new OxmIpv6ExtHdrDeserializer()); + + // Register NXM1Class match entry deserializers + MatchEntryDeserializerRegistryHelper nxm1helper = + new MatchEntryDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, + OxmMatchConstants.NXM_1_CLASS, registry); + nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_SRC, new NxmTunnelIpv4SrcDeserializer()); + nxm1helper.register(OxmMatchConstants.NXM_NX_TUN_IPV4_DST, new NxmTunnelIpv4DstDeserializer()); + nxm1helper.register(OxmMatchConstants.NXM_NX_TCP_FLAG, new NxmTcpFlagDeserializer()); + + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java index 525f5297..c82408bf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/MessageDeserializerInitializer.java @@ -1,101 +1,101 @@ -/* - * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; -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.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.OF10BarrierReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory; -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.OF10GetConfigReplyMessageFactory; -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.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.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; - -/** - * @author michal.polkorab - * - */ -public final class MessageDeserializerInitializer { - - private MessageDeserializerInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers message deserializers - * @param registry registry to be filled with deserializers - */ - public static void registerMessageDeserializers(DeserializerRegistry registry) { - // register OF v1.0 message deserializers - SimpleDeserializerRegistryHelper helper = - new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); - helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); - helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new OF10EchoReplyMessageFactory()); - helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); - helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory()); - helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); - helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory()); - helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); - helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); - helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); - // register Of v1.3 message deserializers - helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); - helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); - helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory()); - helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); - helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); - helper.registerDeserializer(6, null, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); - helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); - helper.registerDeserializer(10, null, PacketInMessage.class, new PacketInMessageFactory()); - helper.registerDeserializer(11, null, FlowRemovedMessage.class, new FlowRemovedMessageFactory()); - helper.registerDeserializer(12, null, PortStatusMessage.class, new PortStatusMessageFactory()); - helper.registerDeserializer(19, null, MultipartReplyMessage.class, new MultipartReplyMessageFactory()); - helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); - helper.registerDeserializer(23, null, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); - helper.registerDeserializer(25, null, RoleRequestOutput.class, new RoleReplyMessageFactory()); - helper.registerDeserializer(27, null, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); - } -} +/* + * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; +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.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.OF10BarrierReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10EchoRequestMessageFactory; +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.OF10GetConfigReplyMessageFactory; +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.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.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.SimpleDeserializerRegistryHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author michal.polkorab + * + */ +public final class MessageDeserializerInitializer { + + private MessageDeserializerInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers message deserializers + * @param registry registry to be filled with deserializers + */ + public static void registerMessageDeserializers(DeserializerRegistry registry) { + // register OF v1.0 message deserializers + SimpleDeserializerRegistryHelper helper = + new SimpleDeserializerRegistryHelper(EncodeConstants.OF10_VERSION_ID, registry); + helper.registerDeserializer(0, null, HelloMessage.class, new OF10HelloMessageFactory()); + helper.registerDeserializer(1, null, ErrorMessage.class, new OF10ErrorMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new OF10EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new OF10EchoReplyMessageFactory()); + helper.registerDeserializer(6, null, GetFeaturesOutput.class, new OF10FeaturesReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new OF10GetConfigReplyMessageFactory()); + helper.registerDeserializer(10, null, PacketInMessage.class, new OF10PacketInMessageFactory()); + helper.registerDeserializer(11, null, FlowRemovedMessage.class, new OF10FlowRemovedMessageFactory()); + helper.registerDeserializer(12, null, PortStatusMessage.class, new OF10PortStatusMessageFactory()); + helper.registerDeserializer(17, null, MultipartReplyMessage.class, new OF10StatsReplyMessageFactory()); + helper.registerDeserializer(19, null, BarrierOutput.class, new OF10BarrierReplyMessageFactory()); + helper.registerDeserializer(21, null, GetQueueConfigOutput.class, new OF10QueueGetConfigReplyMessageFactory()); + // register Of v1.3 message deserializers + helper = new SimpleDeserializerRegistryHelper(EncodeConstants.OF13_VERSION_ID, registry); + helper.registerDeserializer(0, null, HelloMessage.class, new HelloMessageFactory()); + helper.registerDeserializer(1, null, ErrorMessage.class, new ErrorMessageFactory()); + helper.registerDeserializer(2, null, EchoRequestMessage.class, new EchoRequestMessageFactory()); + helper.registerDeserializer(3, null, EchoOutput.class, new EchoReplyMessageFactory()); + helper.registerDeserializer(6, null, GetFeaturesOutput.class, new FeaturesReplyMessageFactory()); + helper.registerDeserializer(8, null, GetConfigOutput.class, new GetConfigReplyMessageFactory()); + helper.registerDeserializer(10, null, PacketInMessage.class, new PacketInMessageFactory()); + helper.registerDeserializer(11, null, FlowRemovedMessage.class, new FlowRemovedMessageFactory()); + helper.registerDeserializer(12, null, PortStatusMessage.class, new PortStatusMessageFactory()); + helper.registerDeserializer(19, null, MultipartReplyMessage.class, new MultipartReplyMessageFactory()); + helper.registerDeserializer(21, null, BarrierOutput.class, new BarrierReplyMessageFactory()); + helper.registerDeserializer(23, null, GetQueueConfigOutput.class, new QueueGetConfigReplyMessageFactory()); + helper.registerDeserializer(25, null, RoleRequestOutput.class, new RoleReplyMessageFactory()); + helper.registerDeserializer(27, null, GetAsyncOutput.class, new GetAsyncReplyMessageFactory()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java index fa110c09..b0b4d047 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializer.java @@ -1,80 +1,80 @@ -/* - * 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.Map; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; - -/** - * @author michal.polkorab - * - */ -public final class TypeToClassMapInitializer { - - private TypeToClassMapInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Initializes type to class map - * @param messageClassMap - */ - public static void initializeTypeToClassMap(Map> messageClassMap) { - // init OF v1.0 mapping - TypeToClassInitHelper helper = - new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); - helper.registerTypeToClass((short) 0, HelloMessage.class); - helper.registerTypeToClass((short) 1, ErrorMessage.class); - helper.registerTypeToClass((short) 2, EchoRequestMessage.class); - helper.registerTypeToClass((short) 3, EchoOutput.class); - helper.registerTypeToClass((short) 4, ExperimenterMessage.class); - helper.registerTypeToClass((short) 6, GetFeaturesOutput.class); - helper.registerTypeToClass((short) 8, GetConfigOutput.class); - helper.registerTypeToClass((short) 10, PacketInMessage.class); - helper.registerTypeToClass((short) 11, FlowRemovedMessage.class); - helper.registerTypeToClass((short) 12, PortStatusMessage.class); - helper.registerTypeToClass((short) 17, MultipartReplyMessage.class); - helper.registerTypeToClass((short) 19, BarrierOutput.class); - helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class); - // init OF v1.0 mapping - helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap); - helper.registerTypeToClass((short) 0, HelloMessage.class); - helper.registerTypeToClass((short) 1, ErrorMessage.class); - helper.registerTypeToClass((short) 2, EchoRequestMessage.class); - helper.registerTypeToClass((short) 3, EchoOutput.class); - helper.registerTypeToClass((short) 4, ExperimenterMessage.class); - helper.registerTypeToClass((short) 6, GetFeaturesOutput.class); - helper.registerTypeToClass((short) 8, GetConfigOutput.class); - helper.registerTypeToClass((short) 10, PacketInMessage.class); - helper.registerTypeToClass((short) 11, FlowRemovedMessage.class); - helper.registerTypeToClass((short) 12, PortStatusMessage.class); - helper.registerTypeToClass((short) 19, MultipartReplyMessage.class); - helper.registerTypeToClass((short) 21, BarrierOutput.class); - helper.registerTypeToClass((short) 23, GetQueueConfigOutput.class); - helper.registerTypeToClass((short) 25, RoleRequestOutput.class); - helper.registerTypeToClass((short) 27, GetAsyncOutput.class); - } -} +/* + * 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.Map; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassInitHelper; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author michal.polkorab + * + */ +public final class TypeToClassMapInitializer { + + private TypeToClassMapInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Initializes type to class map + * @param messageClassMap + */ + public static void initializeTypeToClassMap(Map> messageClassMap) { + // init OF v1.0 mapping + TypeToClassInitHelper helper = + new TypeToClassInitHelper(EncodeConstants.OF10_VERSION_ID, messageClassMap); + helper.registerTypeToClass((short) 0, HelloMessage.class); + helper.registerTypeToClass((short) 1, ErrorMessage.class); + helper.registerTypeToClass((short) 2, EchoRequestMessage.class); + helper.registerTypeToClass((short) 3, EchoOutput.class); + helper.registerTypeToClass((short) 4, ExperimenterMessage.class); + helper.registerTypeToClass((short) 6, GetFeaturesOutput.class); + helper.registerTypeToClass((short) 8, GetConfigOutput.class); + helper.registerTypeToClass((short) 10, PacketInMessage.class); + helper.registerTypeToClass((short) 11, FlowRemovedMessage.class); + helper.registerTypeToClass((short) 12, PortStatusMessage.class); + helper.registerTypeToClass((short) 17, MultipartReplyMessage.class); + helper.registerTypeToClass((short) 19, BarrierOutput.class); + helper.registerTypeToClass((short) 21, GetQueueConfigOutput.class); + // init OF v1.0 mapping + helper = new TypeToClassInitHelper(EncodeConstants.OF13_VERSION_ID, messageClassMap); + helper.registerTypeToClass((short) 0, HelloMessage.class); + helper.registerTypeToClass((short) 1, ErrorMessage.class); + helper.registerTypeToClass((short) 2, EchoRequestMessage.class); + helper.registerTypeToClass((short) 3, EchoOutput.class); + helper.registerTypeToClass((short) 4, ExperimenterMessage.class); + helper.registerTypeToClass((short) 6, GetFeaturesOutput.class); + helper.registerTypeToClass((short) 8, GetConfigOutput.class); + helper.registerTypeToClass((short) 10, PacketInMessage.class); + helper.registerTypeToClass((short) 11, FlowRemovedMessage.class); + helper.registerTypeToClass((short) 12, PortStatusMessage.class); + helper.registerTypeToClass((short) 19, MultipartReplyMessage.class); + helper.registerTypeToClass((short) 21, BarrierOutput.class); + helper.registerTypeToClass((short) 23, GetQueueConfigOutput.class); + helper.registerTypeToClass((short) 25, RoleRequestOutput.class); + helper.registerTypeToClass((short) 27, GetAsyncOutput.class); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java index 4ff7c307..9dbd5790 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractActionDeserializer.java @@ -1,38 +1,38 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractActionDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Action deserializeHeader(ByteBuf input) { - ActionBuilder actionBuilder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - actionBuilder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return actionBuilder.build(); - } - - protected abstract Class getType(); - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractActionDeserializer implements OFDeserializer, + HeaderDeserializer { + + @Override + public Action deserializeHeader(ByteBuf input) { + ActionBuilder actionBuilder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + actionBuilder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return actionBuilder.build(); + } + + protected abstract Class getType(); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java index 0fae6a61..cddf6f2d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractEthertypeActionDeserializer.java @@ -1,38 +1,38 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.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.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractEthertypeActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - EthertypeActionBuilder etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(input.readUnsignedShort())); - builder.addAugmentation(EthertypeAction.class, etherType.build()); - input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); - return builder.build(); - } -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.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.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractEthertypeActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + EthertypeActionBuilder etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(input.readUnsignedShort())); + builder.addAugmentation(EthertypeAction.class, etherType.build()); + input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java index b295ec3c..664dfbe3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/AbstractHeaderActionDeserializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractHeaderActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); - return builder.build(); - } -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractHeaderActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(ActionConstants.PADDING_IN_ACTION_HEADER); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java index 058d0870..97c10e5c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractIpAddressActionDeserializer.java @@ -1,45 +1,45 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.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.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.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yangtools.yang.binding.Augmentation; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractIpAddressActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(final ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.addAugmentation(IpAddressAction.class, - createNwAddressAugmentationAndPad(input)); - return builder.build(); - } - - private static Augmentation createNwAddressAugmentationAndPad(final ByteBuf input) { - IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); - return ipBuilder.build(); - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.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.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.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yangtools.yang.binding.Augmentation; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractIpAddressActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(final ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.addAugmentation(IpAddressAction.class, + createNwAddressAugmentationAndPad(input)); + return builder.build(); + } + + private static Augmentation createNwAddressAugmentationAndPad(final ByteBuf input) { + IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); + ipBuilder.setIpAddress(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + return ipBuilder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java index 14a1c843..cdbc69e2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractMacAddressActionDeserializer.java @@ -1,46 +1,46 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractMacAddressActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input)); - 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(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); - return dlBuilder.build(); - } -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractMacAddressActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.addAugmentation(DlAddressAction.class, createDlAugmentationAndPad(input)); + 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(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); + return dlBuilder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java index c284fc5e..9c7476d5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10AbstractPortActionDeserializer.java @@ -1,43 +1,43 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractPortActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); - input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); - return builder.build(); - } - - protected static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) { - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - } -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractPortActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + createPortAugmentation(input, builder); + input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); + return builder.build(); + } + + protected static void createPortAugmentation(ByteBuf input, ActionBuilder actionBuilder) { + PortActionBuilder portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java index 41c989eb..9316971e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java @@ -1,47 +1,47 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.Enqueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10EnqueueActionDeserializer extends OF10AbstractPortActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); - input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION); - QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); - queueBuilder.setQueueId(input.readUnsignedInt()); - builder.addAugmentation(QueueIdAction.class, queueBuilder.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return Enqueue.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.Enqueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10EnqueueActionDeserializer extends OF10AbstractPortActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + createPortAugmentation(input, builder); + input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION); + QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); + queueBuilder.setQueueId(input.readUnsignedInt()); + builder.addAugmentation(QueueIdAction.class, queueBuilder.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return Enqueue.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java index cfbcbe27..64707081 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java @@ -1,45 +1,45 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.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.common.action.rev130731.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10OutputActionDeserializer extends OF10AbstractPortActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - createPortAugmentation(input, builder); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(input.readUnsignedShort()); - builder.addAugmentation(MaxLengthAction.class, maxLen.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return Output.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.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.common.action.rev130731.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10OutputActionDeserializer extends OF10AbstractPortActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + createPortAugmentation(input, builder); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(input.readUnsignedShort()); + builder.addAugmentation(MaxLengthAction.class, maxLen.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return Output.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java index 2cdc5d0d..95762dc1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlDstActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetDlDstActionDeserializer extends OF10AbstractMacAddressActionDeserializer { - - @Override - protected Class getType() { - return SetDlDst.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetDlDstActionDeserializer extends OF10AbstractMacAddressActionDeserializer { + + @Override + protected Class getType() { + return SetDlDst.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java index 34b16b4b..9d3d9c80 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetDlSrcActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetDlSrcActionDeserializer extends OF10AbstractMacAddressActionDeserializer { - - @Override - protected Class getType() { - return SetDlSrc.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetDlSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetDlSrcActionDeserializer extends OF10AbstractMacAddressActionDeserializer { + + @Override + protected Class getType() { + return SetDlSrc.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java index c41021d8..97e1c6bb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwDstActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwDstActionDeserializer extends OF10AbstractIpAddressActionDeserializer { - - @Override - protected Class getType() { - return SetNwDst.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwDstActionDeserializer extends OF10AbstractIpAddressActionDeserializer { + + @Override + protected Class getType() { + return SetNwDst.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java index 31550133..55d1e76d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwSrcActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwSrcActionDeserializer extends OF10AbstractIpAddressActionDeserializer { - - @Override - protected Class getType() { - return SetNwSrc.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetNwSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwSrcActionDeserializer extends OF10AbstractIpAddressActionDeserializer { + + @Override + protected Class getType() { + return SetNwSrc.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java index 70589117..925ecfec 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java @@ -1,46 +1,46 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.common.action.rev130731.SetNwTos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwTosActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); - tosBuilder.setNwTos(input.readUnsignedByte()); - builder.addAugmentation(NwTosAction.class, tosBuilder.build()); - input.skipBytes(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); - return builder.build(); - } - - @Override - protected Class getType() { - return SetNwTos.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.common.action.rev130731.SetNwTos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwTosActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); + tosBuilder.setNwTos(input.readUnsignedByte()); + builder.addAugmentation(NwTosAction.class, tosBuilder.build()); + input.skipBytes(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); + return builder.build(); + } + + @Override + protected Class getType() { + return SetNwTos.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java index 96a41ffd..0bb20dbf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetTpDstActionDeserializer extends OF10AbstractPortActionDeserializer { - - @Override - protected Class getType() { - return SetTpDst.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetTpDstActionDeserializer extends OF10AbstractPortActionDeserializer { + + @Override + protected Class getType() { + return SetTpDst.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java index 31271a4a..3fce85bd 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetTpSrcActionDeserializer extends OF10AbstractPortActionDeserializer { - - @Override - protected Class getType() { - return SetTpSrc.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetTpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetTpSrcActionDeserializer extends OF10AbstractPortActionDeserializer { + + @Override + protected Class getType() { + return SetTpSrc.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java index cb888a4c..ac511552 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java @@ -1,46 +1,46 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; -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.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder(); - vlanBuilder.setVlanPcp(input.readUnsignedByte()); - input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); - builder.addAugmentation(VlanPcpAction.class, vlanBuilder.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return SetVlanPcp.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpActionBuilder; +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.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + VlanPcpActionBuilder vlanBuilder = new VlanPcpActionBuilder(); + vlanBuilder.setVlanPcp(input.readUnsignedByte()); + input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); + builder.addAugmentation(VlanPcpAction.class, vlanBuilder.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return SetVlanPcp.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java index 4fb33a73..623341a9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java @@ -1,46 +1,46 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10SetVlanVidActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); - vlanBuilder.setVlanVid(input.readUnsignedShort()); - input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); - builder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return SetVlanVid.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.SetVlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10SetVlanVidActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); + vlanBuilder.setVlanVid(input.readUnsignedShort()); + input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); + builder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return SetVlanVid.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java index bb5c4a48..dea7afa5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10StripVlanActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF10StripVlanActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return StripVlan.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.StripVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF10StripVlanActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return StripVlan.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java index e56c5818..a869084d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlInActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13CopyTtlInActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return CopyTtlIn.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlIn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13CopyTtlInActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return CopyTtlIn.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java index 731a82ad..b066b215 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13CopyTtlOutActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13CopyTtlOutActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return CopyTtlOut.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.CopyTtlOut; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13CopyTtlOutActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return CopyTtlOut.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java index bab50a98..6467e1e6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecMplsTtlActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13DecMplsTtlActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return DecMplsTtl.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecMplsTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13DecMplsTtlActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return DecMplsTtl.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java index 8f112ff2..f920f577 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13DecNwTtlActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13DecNwTtlActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return DecNwTtl.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.DecNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13DecNwTtlActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return DecNwTtl.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java index ab186fa8..dbf147d2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java @@ -1,43 +1,43 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.common.action.rev130731.Group; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13GroupActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - GroupIdActionBuilder group = new GroupIdActionBuilder(); - group.setGroupId(input.readUnsignedInt()); - builder.addAugmentation(GroupIdAction.class, group.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return Group.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.common.action.rev130731.Group; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13GroupActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + GroupIdActionBuilder group = new GroupIdActionBuilder(); + group.setGroupId(input.readUnsignedInt()); + builder.addAugmentation(GroupIdAction.class, group.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return Group.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java index e47980f4..9e9d54f3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java @@ -1,51 +1,51 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.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.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; - -/** - * @author michal.polkorab - * - */ -public class OF13OutputActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(input.readUnsignedInt())); - builder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(input.readUnsignedShort()); - builder.addAugmentation(MaxLengthAction.class, maxLen.build()); - input.skipBytes(ActionConstants.OUTPUT_PADDING); - return builder.build(); - } - - @Override - protected Class getType() { - return Output.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.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.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; + +/** + * @author michal.polkorab + * + */ +public class OF13OutputActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + PortActionBuilder port = new PortActionBuilder(); + port.setPort(new PortNumber(input.readUnsignedInt())); + builder.addAugmentation(PortAction.class, port.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(input.readUnsignedShort()); + builder.addAugmentation(MaxLengthAction.class, maxLen.build()); + input.skipBytes(ActionConstants.OUTPUT_PADDING); + return builder.build(); + } + + @Override + protected Class getType() { + return Output.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java index 408e5b30..218bedbb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PopMplsActionDeserializer extends AbstractEthertypeActionDeserializer { - - @Override - protected Class getType() { - return PopMpls.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopMpls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PopMplsActionDeserializer extends AbstractEthertypeActionDeserializer { + + @Override + protected Class getType() { + return PopMpls.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java index 99ec0380..7ba8e324 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopPbbActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PopPbbActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return PopPbb.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PopPbbActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return PopPbb.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java index e31a9bfe..69543ede 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopVlanActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PopVlanActionDeserializer extends AbstractHeaderActionDeserializer { - - @Override - protected Class getType() { - return PopVlan.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PopVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PopVlanActionDeserializer extends AbstractHeaderActionDeserializer { + + @Override + protected Class getType() { + return PopVlan.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java index 121e1e96..38ac1821 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PushMplsActionDeserializer extends AbstractEthertypeActionDeserializer { - - @Override - protected Class getType() { - return PushMpls.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushMpls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PushMplsActionDeserializer extends AbstractEthertypeActionDeserializer { + + @Override + protected Class getType() { + return PushMpls.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java index 6a44f04f..40cf71dc 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PushPbbActionDeserializer extends AbstractEthertypeActionDeserializer { - - @Override - protected Class getType() { - return PushPbb.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushPbb; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PushPbbActionDeserializer extends AbstractEthertypeActionDeserializer { + + @Override + protected Class getType() { + return PushPbb.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java index eb0b059d..8b9bbdda 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13PushVlanActionDeserializer extends AbstractEthertypeActionDeserializer { - - @Override - protected Class getType() { - return PushVlan.class; - } - -} +/* + * 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.action; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.PushVlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13PushVlanActionDeserializer extends AbstractEthertypeActionDeserializer { + + @Override + protected Class getType() { + return PushVlan.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java index 0182e8c7..190c3b80 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetFieldActionDeserializer.java @@ -1,78 +1,78 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.common.action.rev130731.SetField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer - implements DeserializerRegistryInjector { - - private DeserializerRegistry registry; - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - int startIndex = input.readerIndex(); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); - int oxmClass = input.getUnsignedShort(input.readerIndex()); - // get oxm_field & hasMask byte and extract the field value - int oxmField = input.getUnsignedByte(input.readerIndex() - + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - oxmClass, oxmField); - if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { - long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES - + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - key.setExperimenterId(expId); - } - OFDeserializer matchDeserializer = registry.getDeserializer(key); - List entry = new ArrayList<>(); - entry.add(matchDeserializer.deserialize(input)); - matchEntries.setMatchEntries(entry); - builder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); - int paddingRemainder = (input.readerIndex() - startIndex) % EncodeConstants.PADDING; - if (paddingRemainder != 0) { - input.skipBytes(EncodeConstants.PADDING - paddingRemainder); - } - return builder.build(); - } - - @Override - protected Class getType() { - return SetField.class; - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.registry = deserializerRegistry; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.common.action.rev130731.SetField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OF13SetFieldActionDeserializer extends AbstractActionDeserializer + implements DeserializerRegistryInjector { + + private DeserializerRegistry registry; + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + int startIndex = input.readerIndex(); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + int oxmClass = input.getUnsignedShort(input.readerIndex()); + // get oxm_field & hasMask byte and extract the field value + int oxmField = input.getUnsignedByte(input.readerIndex() + + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + oxmClass, oxmField); + if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { + long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + key.setExperimenterId(expId); + } + OFDeserializer matchDeserializer = registry.getDeserializer(key); + List entry = new ArrayList<>(); + entry.add(matchDeserializer.deserialize(input)); + matchEntries.setMatchEntries(entry); + builder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + int paddingRemainder = (input.readerIndex() - startIndex) % EncodeConstants.PADDING; + if (paddingRemainder != 0) { + input.skipBytes(EncodeConstants.PADDING - paddingRemainder); + } + return builder.build(); + } + + @Override + protected Class getType() { + return SetField.class; + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.registry = deserializerRegistry; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java index 15877640..0a22ae73 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java @@ -1,45 +1,45 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.common.action.rev130731.SetMplsTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13SetMplsTtlActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); - mplsTtl.setMplsTtl(input.readUnsignedByte()); - builder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); - input.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING); - return builder.build(); - } - - @Override - protected Class getType() { - return SetMplsTtl.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.common.action.rev130731.SetMplsTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13SetMplsTtlActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); + mplsTtl.setMplsTtl(input.readUnsignedByte()); + builder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); + input.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING); + return builder.build(); + } + + @Override + protected Class getType() { + return SetMplsTtl.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java index a9a08aa6..f247c3a7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java @@ -1,45 +1,45 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.common.action.rev130731.SetNwTtl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13SetNwTtlActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl(input.readUnsignedByte()); - builder.addAugmentation(NwTtlAction.class, nwTtl.build()); - input.skipBytes(ActionConstants.SET_NW_TTL_PADDING); - return builder.build(); - } - - @Override - protected Class getType() { - return SetNwTtl.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.common.action.rev130731.SetNwTtl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13SetNwTtlActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); + nwTtl.setNwTtl(input.readUnsignedByte()); + builder.addAugmentation(NwTtlAction.class, nwTtl.build()); + input.skipBytes(ActionConstants.SET_NW_TTL_PADDING); + return builder.build(); + } + + @Override + protected Class getType() { + return SetNwTtl.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java index 0e68c0b0..1df22b1b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java @@ -1,43 +1,43 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.SetQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - * - */ -public class OF13SetQueueActionDeserializer extends AbstractActionDeserializer { - - @Override - public Action deserialize(ByteBuf input) { - ActionBuilder builder = new ActionBuilder(); - builder.setType(getType()); - input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - QueueIdActionBuilder queueId = new QueueIdActionBuilder(); - queueId.setQueueId(input.readUnsignedInt()); - builder.addAugmentation(QueueIdAction.class, queueId.build()); - return builder.build(); - } - - @Override - protected Class getType() { - return SetQueue.class; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.SetQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + * + */ +public class OF13SetQueueActionDeserializer extends AbstractActionDeserializer { + + @Override + public Action deserialize(ByteBuf input) { + ActionBuilder builder = new ActionBuilder(); + builder.setType(getType()); + input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + QueueIdActionBuilder queueId = new QueueIdActionBuilder(); + queueId.setQueueId(input.readUnsignedInt()); + builder.addAugmentation(QueueIdAction.class, queueId.build()); + return builder.build(); + } + + @Override + protected Class getType() { + return SetQueue.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java index 97db922a..269976ff 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterMessageFactory implements OFDeserializer, - DeserializerRegistryInjector { - - /** Experimenter ID index after version, message type and length were read */ - private static final byte EXPERIMENTER_ID_INDEX = 4; - private DeserializerRegistry deserializerRegistry; - - @Override - public ExperimenterMessage deserialize(ByteBuf message) { - long expId = message.getUnsignedInt(message.readerIndex() + EXPERIMENTER_ID_INDEX); - OFDeserializer deserializer = deserializerRegistry.getDeserializer( - ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF13_VERSION_ID, expId)); - return deserializer.deserialize(message); - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.deserializerRegistry = deserializerRegistry; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterMessageFactory implements OFDeserializer, + DeserializerRegistryInjector { + + /** Experimenter ID index after version, message type and length were read */ + private static final byte EXPERIMENTER_ID_INDEX = 4; + private DeserializerRegistry deserializerRegistry; + + @Override + public ExperimenterMessage deserialize(ByteBuf message) { + long expId = message.getUnsignedInt(message.readerIndex() + EXPERIMENTER_ID_INDEX); + OFDeserializer deserializer = deserializerRegistry.getDeserializer( + ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF13_VERSION_ID, expId)); + return deserializer.deserialize(message); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.deserializerRegistry = deserializerRegistry; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java index 7c421538..be6d0004 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactory.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class VendorMessageFactory implements OFDeserializer, - DeserializerRegistryInjector { - - private static final byte VENDOR_ID_INDEX = 8; - private DeserializerRegistry deserializerRegistry; - - @Override - public ExperimenterMessage deserialize(ByteBuf message) { - long expId = message.getUnsignedInt(message.readerIndex() + VENDOR_ID_INDEX); - OFDeserializer deserializer = deserializerRegistry.getDeserializer( - ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, expId)); - return deserializer.deserialize(message); - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.deserializerRegistry = deserializerRegistry; - } +/* + * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class VendorMessageFactory implements OFDeserializer, + DeserializerRegistryInjector { + + private static final byte VENDOR_ID_INDEX = 8; + private DeserializerRegistry deserializerRegistry; + + @Override + public ExperimenterMessage deserialize(ByteBuf message) { + long expId = message.getUnsignedInt(message.readerIndex() + VENDOR_ID_INDEX); + OFDeserializer deserializer = deserializerRegistry.getDeserializer( + ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, expId)); + return deserializer.deserialize(message); + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.deserializerRegistry = deserializerRegistry; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java index 3f4126ba..78d868a0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractActionInstructionDeserializer.java @@ -1,65 +1,65 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; -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.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer - implements DeserializerRegistryInjector { - - private DeserializerRegistry registry; - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(getType()); - int instructionLength = input.readUnsignedShort(); - input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); - int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH; - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - List actions = ListDeserializer.deserializeList( - EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - return builder.build(); - } - - protected abstract Class getType(); - - protected DeserializerRegistry getRegistry() { - return registry; - } - - @Override - public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { - this.registry = deserializerRegistry; - } -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.CodeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ListDeserializer; +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.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractActionInstructionDeserializer extends AbstractInstructionDeserializer + implements DeserializerRegistryInjector { + + private DeserializerRegistry registry; + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(getType()); + int instructionLength = input.readUnsignedShort(); + input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); + int length = instructionLength - InstructionConstants.STANDARD_INSTRUCTION_LENGTH; + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeList( + EncodeConstants.OF13_VERSION_ID, length, input, keyMaker, getRegistry()); + actionsBuilder.setAction(actions); + builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + return builder.build(); + } + + protected abstract Class getType(); + + protected DeserializerRegistry getRegistry() { + return registry; + } + + @Override + public void injectDeserializerRegistry(DeserializerRegistry deserializerRegistry) { + this.registry = deserializerRegistry; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java index f15409f3..38a66452 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializer.java @@ -1,66 +1,66 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.deserialization.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.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.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractInstructionDeserializer implements OFDeserializer, - HeaderDeserializer { - - @Override - public Instruction deserializeHeader(ByteBuf rawMessage) { - InstructionBuilder builder = processHeader(rawMessage); - rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return builder.build(); - } - - protected InstructionBuilder processHeader(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - int type = input.readUnsignedShort(); - switch (type) { - case 1: - builder.setType(GotoTable.class); - break; - case 2: - builder.setType(WriteMetadata.class); - break; - case 3: - builder.setType(WriteActions.class); - break; - case 4: - builder.setType(ApplyActions.class); - break; - case 5: - builder.setType(ClearActions.class); - break; - case 6: - builder.setType(Meter.class); - break; - default: - throw new IllegalStateException("Unknown instruction type received, type: " + type); - } - return builder; - } -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.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.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractInstructionDeserializer implements OFDeserializer, + HeaderDeserializer { + + @Override + public Instruction deserializeHeader(ByteBuf rawMessage) { + InstructionBuilder builder = processHeader(rawMessage); + rawMessage.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return builder.build(); + } + + protected InstructionBuilder processHeader(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + int type = input.readUnsignedShort(); + switch (type) { + case 1: + builder.setType(GotoTable.class); + break; + case 2: + builder.setType(WriteMetadata.class); + break; + case 3: + builder.setType(WriteActions.class); + break; + case 4: + builder.setType(ApplyActions.class); + break; + case 5: + builder.setType(ClearActions.class); + break; + case 6: + builder.setType(Meter.class); + break; + default: + throw new IllegalStateException("Unknown instruction type received, type: " + type); + } + return builder; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java index 7b6319c9..c55aacea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ApplyActionsInstructionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.instruction; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - * - */ -public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { - - @Override - protected Class getType() { - return ApplyActions.class; - } - -} +/* + * 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.instruction; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.ApplyActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * + */ +public class ApplyActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { + + @Override + protected Class getType() { + return ApplyActions.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java index cc2ef5e8..9fd7cec9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/ClearActionsInstructionDeserializer.java @@ -1,42 +1,42 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -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.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class ClearActionsInstructionDeserializer extends AbstractInstructionDeserializer { - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = super.processHeader(input); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ActionsInstructionBuilder actionsBuilder = - new ActionsInstructionBuilder(); - List actions = new ArrayList<>(); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - return builder.build(); - } +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +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.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class ClearActionsInstructionDeserializer extends AbstractInstructionDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = super.processHeader(input); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + ActionsInstructionBuilder actionsBuilder = + new ActionsInstructionBuilder(); + List actions = new ArrayList<>(); + actionsBuilder.setAction(actions); + builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + return builder.build(); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java index 21af10fb..317e69c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java @@ -1,39 +1,39 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -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.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer { - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(GotoTable.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder(); - tableBuilder.setTableId(input.readUnsignedByte()); - builder.addAugmentation(TableIdInstruction.class, tableBuilder.build()); - input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE); - return builder.build(); - } -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +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.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class GoToTableInstructionDeserializer extends AbstractInstructionDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(GotoTable.class); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + TableIdInstructionBuilder tableBuilder = new TableIdInstructionBuilder(); + tableBuilder.setTableId(input.readUnsignedByte()); + builder.addAugmentation(TableIdInstruction.class, tableBuilder.build()); + input.skipBytes(InstructionConstants.PADDING_IN_GOTO_TABLE); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java index ebd626d3..1021987f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/MeterInstructionDeserializer.java @@ -1,38 +1,38 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class MeterInstructionDeserializer extends AbstractInstructionDeserializer { - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(Meter.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); - meterBuilder.setMeterId(input.readUnsignedInt()); - builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); - return builder.build(); - } - -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class MeterInstructionDeserializer extends AbstractInstructionDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(Meter.class); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); + meterBuilder.setMeterId(input.readUnsignedInt()); + builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); + return builder.build(); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java index 311e5ea7..c60532b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteActionsInstructionDeserializer.java @@ -1,25 +1,25 @@ -/* - * 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.instruction; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - * - */ -public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { - - @Override - protected Class getType() { - return WriteActions.class; - } - -} +/* + * 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.instruction; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + * + */ +public class WriteActionsInstructionDeserializer extends AbstractActionInstructionDeserializer { + + @Override + protected Class getType() { + return WriteActions.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java index 419dc974..9412413b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/WriteMetadataInstructionDeserializer.java @@ -1,44 +1,44 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -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.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; - -/** - * @author michal.polkorab - * - */ -public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer { - - @Override - public Instruction deserialize(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setType(WriteMetadata.class); - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA); - MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder(); - byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadata); - metadataBuilder.setMetadata(metadata); - byte[] metadataMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadataMask); - metadataBuilder.setMetadataMask(metadataMask); - builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build()); - return builder.build(); - } -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +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.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; + +/** + * @author michal.polkorab + * + */ +public class WriteMetadataInstructionDeserializer extends AbstractInstructionDeserializer { + + @Override + public Instruction deserialize(ByteBuf input) { + InstructionBuilder builder = new InstructionBuilder(); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setType(WriteMetadata.class); + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + input.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA); + MetadataInstructionBuilder metadataBuilder = new MetadataInstructionBuilder(); + byte[] metadata = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadata); + metadataBuilder.setMetadata(metadata); + byte[] metadataMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataMask); + metadataBuilder.setMetadataMask(metadataMask); + builder.addAugmentation(MetadataInstruction.class, metadataBuilder.build()); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java index 9d7329fb..510b5da3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv4AddressDeserializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.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.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.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmIpv4AddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(final ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv4AddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv4AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { - Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder(); - ipv4AddressBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); - builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.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.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.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmIpv4AddressDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(final ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv4AddressAugmentation(builder, input); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); + } + return builder.build(); + } + + private static void addIpv4AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { + Ipv4AddressMatchEntryBuilder ipv4AddressBuilder = new Ipv4AddressMatchEntryBuilder(); + ipv4AddressBuilder.setIpv4Address(new Ipv4Address(ByteBufUtils.readIpv4Address(input))); + builder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4AddressBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java index d6c4d2b1..ca5ac7ea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmIpv6AddressDeserializer.java @@ -1,44 +1,44 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(final ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6AddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, - EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv6AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { - Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder(); - ipv6AddressBuilder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); - builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.Ipv6AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(final ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6AddressAugmentation(builder, input); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, + EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES); + } + return builder.build(); + } + + private static void addIpv6AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) { + Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder(); + ipv6AddressBuilder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input))); + builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java index 32383b2f..aa4b5884 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMacAddressDeserializer.java @@ -1,45 +1,45 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmMacAddressDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMacAddressAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.MAC_ADDRESS_LENGTH); - } - return builder.build(); - } - - private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder(); - byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - input.readBytes(address); - macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); - builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmMacAddressDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMacAddressAugmentation(builder, input); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.MAC_ADDRESS_LENGTH); + } + return builder.build(); + } + + private static void addMacAddressAugmentation(MatchEntriesBuilder builder, ByteBuf input) { + MacAddressMatchEntryBuilder macAddress = new MacAddressMatchEntryBuilder(); + byte[] address = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + input.readBytes(address); + macAddress.setMacAddress(new MacAddress(ByteBufUtils.macAddressToString(address))); + builder.addAugmentation(MacAddressMatchEntry.class, macAddress.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java index d512b59e..1d737b09 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMatchEntryDeserializer.java @@ -1,64 +1,64 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmMatchEntryDeserializer implements HeaderDeserializer { - - @Override - public MatchEntries deserializeHeader(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - return builder.build(); - } - - /** - * @return oxm_field class - */ - protected abstract Class getOxmField(); - - /** - * @return oxm_class class - */ - protected abstract Class getOxmClass(); - - /** - * Prepares match entry header - sets oxm_class, oxm_field, hasMask - * + sets the buffer.readerIndex() to the end of match entry - * - where augmentation starts - * @param oxmClass oxm class type - * @param oxmField oxm field type - * @param input input bytebuf - * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation - */ - protected MatchEntriesBuilder processHeader(Class oxmClass, - Class oxmField, ByteBuf input) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(oxmClass); - // skip oxm_class (provided) - input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setOxmMatchField(oxmField); - boolean hasMask = (input.readUnsignedByte() & 1) != 0; - builder.setHasMask(hasMask); - // skip match entry length - not needed - input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - return builder; - } - -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmMatchEntryDeserializer implements HeaderDeserializer { + + @Override + public MatchEntries deserializeHeader(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + return builder.build(); + } + + /** + * @return oxm_field class + */ + protected abstract Class getOxmField(); + + /** + * @return oxm_class class + */ + protected abstract Class getOxmClass(); + + /** + * Prepares match entry header - sets oxm_class, oxm_field, hasMask + * + sets the buffer.readerIndex() to the end of match entry + * - where augmentation starts + * @param oxmClass oxm class type + * @param oxmField oxm field type + * @param input input bytebuf + * @return MatchEntriesBuilder which can be filled with MatchEntry augmentation + */ + protected MatchEntriesBuilder processHeader(Class oxmClass, + Class oxmField, ByteBuf input) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(oxmClass); + // skip oxm_class (provided) + input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + builder.setOxmMatchField(oxmField); + boolean hasMask = (input.readUnsignedByte() & 1) != 0; + builder.setHasMask(hasMask); + // skip match entry length - not needed + input.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + return builder; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java index d38b82ed..4de031f7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmMetadataDeserializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMetadataAugmentation(builder, input); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_LONG_IN_BYTES); - } - return builder.build(); - } - - private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder(); - byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadataBytes); - metadata.setMetadata(metadataBytes); - builder.addAugmentation(MetadataMatchEntry.class, metadata.build()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmMetadataDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMetadataAugmentation(builder, input); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_LONG_IN_BYTES); + } + return builder.build(); + } + + private static void addMetadataAugmentation(MatchEntriesBuilder builder, ByteBuf input) { + MetadataMatchEntryBuilder metadata = new MetadataMatchEntryBuilder(); + byte[] metadataBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + input.readBytes(metadataBytes); + metadata.setMetadata(metadataBytes); + builder.addAugmentation(MetadataMatchEntry.class, metadata.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java index 43203006..0b3530db 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortDeserializer.java @@ -1,38 +1,38 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -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.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmPortDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addPortAugmentation(builder, input); - return builder.build(); - } - - private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf input) { - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(input.readUnsignedShort())); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +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.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmPortDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addPortAugmentation(builder, input); + return builder.build(); + } + + private static void addPortAugmentation(MatchEntriesBuilder builder, ByteBuf input) { + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(input.readUnsignedShort())); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java index bd88623c..35895a9b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/AbstractOxmPortNumberDeserializer.java @@ -1,34 +1,34 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractOxmPortNumberDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder(); - port.setPortNumber(new PortNumber(input.readUnsignedInt())); - builder.addAugmentation(PortNumberMatchEntry.class, port.build()); - return builder.build(); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractOxmPortNumberDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + PortNumberMatchEntryBuilder port = new PortNumberMatchEntryBuilder(); + port.setPortNumber(new PortNumber(input.readUnsignedInt())); + builder.addAugmentation(PortNumberMatchEntry.class, port.build()); + return builder.build(); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java index 41fde206..7a287238 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/NxmTcpFlagDeserializer.java @@ -1,53 +1,53 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author brent.salisbury - * - */ -public class NxmTcpFlagDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagDeserializer.class); - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addTcpFlagAugmentation(input, builder); - return builder.build(); - } - - private static void addTcpFlagAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - TcpFlagMatchEntryBuilder tcpFlagMatchEntryBuilder = new TcpFlagMatchEntryBuilder(); - tcpFlagMatchEntryBuilder.setTcpFlag(input.readUnsignedShort()); - } - - @Override - protected Class getOxmField() { - return TcpFlag.class; - } - - @Override - protected Class getOxmClass() { - return Nxm1Class.class; - } +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpFlag; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author brent.salisbury + * + */ +public class NxmTcpFlagDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagDeserializer.class); + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addTcpFlagAugmentation(input, builder); + return builder.build(); + } + + private static void addTcpFlagAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + TcpFlagMatchEntryBuilder tcpFlagMatchEntryBuilder = new TcpFlagMatchEntryBuilder(); + tcpFlagMatchEntryBuilder.setTcpFlag(input.readUnsignedShort()); + } + + @Override + protected Class getOxmField() { + return TcpFlag.class; + } + + @Override + protected Class getOxmClass() { + return Nxm1Class.class; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java index c2532ab0..2d438398 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java @@ -1,51 +1,51 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpOpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addArpOpAugmentation(input, builder); - return builder.build(); - } - - private static void addArpOpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder(); - opcodeBuilder.setOpCode(input.readUnsignedShort()); - builder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return ArpOp.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpOpDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addArpOpAugmentation(input, builder); + return builder.build(); + } + + private static void addArpOpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + OpCodeMatchEntryBuilder opcodeBuilder = new OpCodeMatchEntryBuilder(); + opcodeBuilder.setOpCode(input.readUnsignedShort()); + builder.addAugmentation(OpCodeMatchEntry.class, opcodeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return ArpOp.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java index 09744aca..b26b9e3a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpShaDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmArpShaDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return ArpSha.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmArpShaDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return ArpSha.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java index 8d99b44d..cb83cb24 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpSpaDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmArpSpaDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return ArpSpa.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmArpSpaDeserializer extends AbstractOxmIpv4AddressDeserializer { + + @Override + protected Class getOxmField() { + return ArpSpa.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java index cba0642e..69ce30a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpThaDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmArpThaDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return ArpTha.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmArpThaDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return ArpTha.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java index dddb3ef4..dd7b27c9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpTpaDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmArpTpaDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return ArpTpa.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmArpTpaDeserializer extends AbstractOxmIpv4AddressDeserializer { + + @Override + protected Class getOxmField() { + return ArpTpa.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java index 257fde06..9e1e6e20 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthDstDeserializer.java @@ -1,31 +1,31 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmEthDstDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return EthDst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmEthDstDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return EthDst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java index ebcd01f8..3302a650 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthSrcDeserializer.java @@ -1,31 +1,31 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmEthSrcDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return EthSrc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmEthSrcDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return EthSrc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java index ce4ea0c4..94d08706 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java @@ -1,52 +1,52 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmEthTypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addEthTypeAugmentation(input, builder); - return builder.build(); - } - - private static void addEthTypeAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder(); - ethertypeBuilder.setEthType(new EtherType(input.readUnsignedShort())); - builder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return EthType.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthTypeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addEthTypeAugmentation(input, builder); + return builder.build(); + } + + private static void addEthTypeAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + EthTypeMatchEntryBuilder ethertypeBuilder = new EthTypeMatchEntryBuilder(); + ethertypeBuilder.setEthType(new EtherType(input.readUnsignedShort())); + builder.addAugmentation(EthTypeMatchEntry.class, ethertypeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return EthType.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java index c0df85bd..8ac68433 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java @@ -1,53 +1,53 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv4CodeAugmentation(input, builder); - return builder.build(); - } - - private static void addIcmpv4CodeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); - icmpv4CodeBuilder.setIcmpv4Code(input.readUnsignedByte()); - builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Icmpv4Code.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv4CodeAugmentation(input, builder); + return builder.build(); + } + + private static void addIcmpv4CodeAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); + icmpv4CodeBuilder.setIcmpv4Code(input.readUnsignedByte()); + builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Icmpv4Code.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java index 05f81a3f..4134bb1c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java @@ -1,52 +1,52 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4TypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv4TypeAugmentation(input, builder); - return builder.build(); - } - - private static void addIcmpv4TypeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4TypeBuilder.setIcmpv4Type(input.readUnsignedByte()); - builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Icmpv4Type.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4TypeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv4TypeAugmentation(input, builder); + return builder.build(); + } + + private static void addIcmpv4TypeAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + Icmpv4TypeMatchEntryBuilder icmpv4TypeBuilder = new Icmpv4TypeMatchEntryBuilder(); + icmpv4TypeBuilder.setIcmpv4Type(input.readUnsignedByte()); + builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4TypeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Icmpv4Type.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java index 930a4b31..7cc38f19 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java @@ -1,52 +1,52 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6CodeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv6CodeAugmentation(input, builder); - return builder.build(); - } - - private static void addIcmpv6CodeAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6CodeBuilder.setIcmpv6Code(input.readUnsignedByte()); - builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Icmpv6Code.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6CodeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIcmpv6CodeAugmentation(input, builder); + return builder.build(); + } + + private static void addIcmpv6CodeAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); + icmpv6CodeBuilder.setIcmpv6Code(input.readUnsignedByte()); + builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Icmpv6Code.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java index 11f9336c..de155fcb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java @@ -1,47 +1,47 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6TypeDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); - icmpv6TypeBuilder.setIcmpv6Type(input.readUnsignedByte()); - builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); - return builder.build(); - } - - @Override - protected Class getOxmField() { - return Icmpv6Type.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6TypeDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); + icmpv6TypeBuilder.setIcmpv6Type(input.readUnsignedByte()); + builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); + return builder.build(); + } + + @Override + protected Class getOxmField() { + return Icmpv6Type.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java index d9685796..54b826f8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmInPhyPortDeserializer extends AbstractOxmPortNumberDeserializer { - - @Override - protected Class getOxmField() { - return InPhyPort.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmInPhyPortDeserializer extends AbstractOxmPortNumberDeserializer { + + @Override + protected Class getOxmField() { + return InPhyPort.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java index 4f9af4fa..342d2a33 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmInPortDeserializer extends AbstractOxmPortNumberDeserializer { - - @Override - protected Class getOxmField() { - return InPort.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmInPortDeserializer extends AbstractOxmPortNumberDeserializer { + + @Override + protected Class getOxmField() { + return InPort.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java index eb92d143..e4880ba9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java @@ -1,52 +1,52 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -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.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpDscpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpDscpAugmentation(input, builder); - return builder.build(); - } - - private static void addIpDscpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); - dscpBuilder.setDscp(new Dscp(input.readUnsignedByte())); - builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); - } - - @Override - protected Class getOxmField() { - return IpDscp.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +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.oxm.rev130731.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpDscpDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpDscpAugmentation(input, builder); + return builder.build(); + } + + private static void addIpDscpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + dscpBuilder.setDscp(new Dscp(input.readUnsignedByte())); + builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + } + + @Override + protected Class getOxmField() { + return IpDscp.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java index 7a534756..150c6dc6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java @@ -1,51 +1,51 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.IpEcn; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpEcnDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpEcnAugmentation(input, builder); - return builder.build(); - } - - private static void addIpEcnAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); - ecnBuilder.setEcn(input.readUnsignedByte()); - builder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); - } - - @Override - protected Class getOxmField() { - return IpEcn.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.IpEcn; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpEcnDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpEcnAugmentation(input, builder); + return builder.build(); + } + + private static void addIpEcnAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); + ecnBuilder.setEcn(input.readUnsignedByte()); + builder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); + } + + @Override + protected Class getOxmField() { + return IpEcn.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java index f99ecba8..9e67af39 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java @@ -1,51 +1,51 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpProtoDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpProtoAugmentation(input, builder); - return builder.build(); - } - - private static void addIpProtoAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder(); - protoNumberBuilder.setProtocolNumber(input.readUnsignedByte()); - builder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build()); - } - - @Override - protected Class getOxmField() { - return IpProto.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpProtoDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpProtoAugmentation(input, builder); + return builder.build(); + } + + private static void addIpProtoAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + ProtocolNumberMatchEntryBuilder protoNumberBuilder = new ProtocolNumberMatchEntryBuilder(); + protoNumberBuilder.setProtocolNumber(input.readUnsignedByte()); + builder.addAugmentation(ProtocolNumberMatchEntry.class, protoNumberBuilder.build()); + } + + @Override + protected Class getOxmField() { + return IpProto.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java index ae63c9d6..9939fed9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4DstDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv4Dst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4DstDeserializer extends AbstractOxmIpv4AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv4Dst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java index b03ca001..a84b2fa3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv4SrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv4Src.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4SrcDeserializer extends AbstractOxmIpv4AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv4Src.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java index f4170d8c..11b5cc3a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6DstDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6DstDeserializer extends AbstractOxmIpv6AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6Dst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6DstDeserializer extends AbstractOxmIpv6AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6Dst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java index 26f7f839..7267333c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializer.java @@ -1,67 +1,67 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6ExtHdrDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6ExtHdrAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv6ExtHdrAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); - int bitmap = input.readUnsignedShort(); - final Boolean nonext = ((bitmap) & (1<<0)) != 0; - final Boolean esp = ((bitmap) & (1<<1)) != 0; - final Boolean auth = ((bitmap) & (1<<2)) != 0; - final Boolean dest = ((bitmap) & (1<<3)) != 0; - final Boolean frag = ((bitmap) & (1<<4)) != 0; - final Boolean router = ((bitmap) & (1<<5)) != 0; - final Boolean hop = ((bitmap) & (1<<6)) != 0; - final Boolean unrep = ((bitmap) & (1<<7)) != 0; - final Boolean unseq = ((bitmap) & (1<<8)) != 0; - pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(auth, dest, esp, frag, hop, nonext, router, unrep, unseq)); - builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Ipv6Exthdr.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6ExtHdrAugmentation(input, builder); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + } + return builder.build(); + } + + private static void addIpv6ExtHdrAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); + int bitmap = input.readUnsignedShort(); + final Boolean nonext = ((bitmap) & (1<<0)) != 0; + final Boolean esp = ((bitmap) & (1<<1)) != 0; + final Boolean auth = ((bitmap) & (1<<2)) != 0; + final Boolean dest = ((bitmap) & (1<<3)) != 0; + final Boolean frag = ((bitmap) & (1<<4)) != 0; + final Boolean router = ((bitmap) & (1<<5)) != 0; + final Boolean hop = ((bitmap) & (1<<6)) != 0; + final Boolean unrep = ((bitmap) & (1<<7)) != 0; + final Boolean unseq = ((bitmap) & (1<<8)) != 0; + pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(auth, dest, esp, frag, hop, nonext, router, unrep, unseq)); + builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Ipv6Exthdr.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java index bcb7643e..15c8aa07 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java @@ -1,58 +1,58 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; -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.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6FlabelDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIpv6FlabelAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); - } - return builder.build(); - } - - private static void addIpv6FlabelAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder(); - ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt())); - builder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build()); - } - - @Override - protected Class getOxmField() { - return Ipv6Flabel.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; +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.oxm.rev130731.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6FlabelDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addIpv6FlabelAugmentation(input, builder); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_INT_IN_BYTES); + } + return builder.build(); + } + + private static void addIpv6FlabelAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + Ipv6FlabelMatchEntryBuilder ipv6FlabelBuilder = new Ipv6FlabelMatchEntryBuilder(); + ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt())); + builder.addAugmentation(Ipv6FlabelMatchEntry.class, ipv6FlabelBuilder.build()); + } + + @Override + protected Class getOxmField() { + return Ipv6Flabel.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java index 9e9c5ab4..3ca7b686 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdSllDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdSllDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6NdSll.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdSllDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6NdSll.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java index 01c7dc8c..5b2543c1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTargetDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTargetDeserializer extends AbstractOxmIpv6AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6NdTarget.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTarget; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTargetDeserializer extends AbstractOxmIpv6AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6NdTarget.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java index 9b7f4b80..fabc8d45 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6NdTllDeserializer.java @@ -1,31 +1,31 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTllDeserializer extends AbstractOxmMacAddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6NdTll.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } - -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTllDeserializer extends AbstractOxmMacAddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6NdTll.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java index bb7942a0..59152b45 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6SrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -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.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6SrcDeserializer extends AbstractOxmIpv6AddressDeserializer { - - @Override - protected Class getOxmField() { - return Ipv6Src.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +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.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6SrcDeserializer extends AbstractOxmIpv6AddressDeserializer { + + @Override + protected Class getOxmField() { + return Ipv6Src.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java index 728d42fa..ff8b7ff0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMaskDeserializer.java @@ -1,40 +1,40 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -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.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public final class OxmMaskDeserializer { - - private OxmMaskDeserializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Appends mask to match entry (match entry builder) - * @param builder builder which the mask will append to - * @param input input ByteBuf - * @param matchEntryLength mask length - */ - public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input, - int matchEntryLength) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - byte[] mask = new byte[matchEntryLength]; - input.readBytes(mask); - maskBuilder.setMask(mask); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +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.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public final class OxmMaskDeserializer { + + private OxmMaskDeserializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Appends mask to match entry (match entry builder) + * @param builder builder which the mask will append to + * @param input input ByteBuf + * @param matchEntryLength mask length + */ + public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input, + int matchEntryLength) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + byte[] mask = new byte[matchEntryLength]; + input.readBytes(mask); + maskBuilder.setMask(mask); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java index b5dcf47c..ae34635b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -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.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * - */ -public class OxmMetadataDeserializer extends AbstractOxmMetadataDeserializer { - - @Override - protected Class getOxmField() { - return Metadata.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +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.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataDeserializer extends AbstractOxmMetadataDeserializer { + + @Override + protected Class getOxmField() { + return Metadata.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java index 3fbd2ea0..65ebac39 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializer.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsBosDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsBosDeserializer(input, builder); - return builder.build(); - } - - - private static void addMplsBosDeserializer(ByteBuf input, - MatchEntriesBuilder builder) { - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); - if (input.readUnsignedByte() != 0) { - bosBuilder.setBos(true); - } else { - bosBuilder.setBos(false); - } - builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); - } - - @Override - protected Class getOxmField() { - return MplsBos.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsBosDeserializer(input, builder); + return builder.build(); + } + + + private static void addMplsBosDeserializer(ByteBuf input, + MatchEntriesBuilder builder) { + BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); + if (input.readUnsignedByte() != 0) { + bosBuilder.setBos(true); + } else { + bosBuilder.setBos(false); + } + builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + } + + @Override + protected Class getOxmField() { + return MplsBos.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java index fdc657a8..d7c4fe4f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java @@ -1,52 +1,52 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsLabelDeserializer extends AbstractOxmMatchEntryDeserializer -implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsLabelAugmentation(input, builder); - return builder.build(); - } - - private static void addMplsLabelAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder(); - mplsLabelBuilder.setMplsLabel(input.readUnsignedInt()); - builder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build()); - } - - @Override - protected Class getOxmField() { - return MplsLabel.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsLabelDeserializer extends AbstractOxmMatchEntryDeserializer +implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsLabelAugmentation(input, builder); + return builder.build(); + } + + private static void addMplsLabelAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + MplsLabelMatchEntryBuilder mplsLabelBuilder = new MplsLabelMatchEntryBuilder(); + mplsLabelBuilder.setMplsLabel(input.readUnsignedInt()); + builder.addAugmentation(MplsLabelMatchEntry.class, mplsLabelBuilder.build()); + } + + @Override + protected Class getOxmField() { + return MplsLabel.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java index f7a06339..10cb8d28 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java @@ -1,52 +1,52 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsTcDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addMplsTcAugmentation(input, builder); - return builder.build(); - } - - private static void addMplsTcAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); - tcBuilder.setTc(input.readUnsignedByte()); - builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); - } - - @Override - protected Class getOxmField() { - return MplsTc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsTcDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addMplsTcAugmentation(input, builder); + return builder.build(); + } + + private static void addMplsTcAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); + tcBuilder.setTc(input.readUnsignedByte()); + builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + } + + @Override + protected Class getOxmField() { + return MplsTc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java index f6378763..e400ba36 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializer.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmPbbIsidDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addPbbIsidAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_3_BYTES); - } - return builder.build(); - } - - private static void addPbbIsidAugmentation(ByteBuf input, - MatchEntriesBuilder builder) { - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); - Integer isid = input.readUnsignedMedium(); - isidBuilder.setIsid(isid.longValue()); - builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); - } - - @Override - protected Class getOxmField() { - return PbbIsid.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addPbbIsidAugmentation(input, builder); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_3_BYTES); + } + return builder.build(); + } + + private static void addPbbIsidAugmentation(ByteBuf input, + MatchEntriesBuilder builder) { + IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); + Integer isid = input.readUnsignedMedium(); + isidBuilder.setIsid(isid.longValue()); + builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + } + + @Override + protected Class getOxmField() { + return PbbIsid.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java index e608ea63..0985b752 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpDstDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return SctpDst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpDstDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return SctpDst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java index 03e9bf91..087e86b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpSrcDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return SctpSrc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpSrcDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return SctpSrc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java index 3a2f1612..1ab75029 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpDstDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return TcpDst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpDstDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return TcpDst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java index 5d213431..e1509dc7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpSrcDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return TcpSrc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpSrcDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return TcpSrc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java index bba63ca5..84a407af 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTunnelIdDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; - -/** - * @author michal.polkorab - * - */ -public class OxmTunnelIdDeserializer extends AbstractOxmMetadataDeserializer { - - @Override - protected Class getOxmField() { - return TunnelId.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; + +/** + * @author michal.polkorab + * + */ +public class OxmTunnelIdDeserializer extends AbstractOxmMetadataDeserializer { + + @Override + protected Class getOxmField() { + return TunnelId.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java index 201266e1..01d37beb 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpDstDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return UdpDst.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpDstDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return UdpDst.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java index 626d9d40..d4da0752 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java @@ -1,30 +1,30 @@ -/* - * 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.match; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpSrcDeserializer extends AbstractOxmPortDeserializer { - - @Override - protected Class getOxmField() { - return UdpSrc.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpSrcDeserializer extends AbstractOxmPortDeserializer { + + @Override + protected Class getOxmField() { + return UdpSrc.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java index 0600d296..332fa751 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java @@ -1,51 +1,51 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -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.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addVlanPcpAugmentation(input, builder); - return builder.build(); - } - - private static void addVlanPcpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder(); - vlanPcpBuilder.setVlanPcp(input.readUnsignedByte()); - builder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build()); - } - - @Override - protected Class getOxmField() { - return VlanPcp.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +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.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addVlanPcpAugmentation(input, builder); + return builder.build(); + } + + private static void addVlanPcpAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + VlanPcpMatchEntryBuilder vlanPcpBuilder = new VlanPcpMatchEntryBuilder(); + vlanPcpBuilder.setVlanPcp(input.readUnsignedByte()); + builder.addAugmentation(VlanPcpMatchEntry.class, vlanPcpBuilder.build()); + } + + @Override + protected Class getOxmField() { + return VlanPcp.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java index 7ba99e2b..0508dbab 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.deserialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; -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.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer - implements OFDeserializer { - - @Override - public MatchEntries deserialize(ByteBuf input) { - MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addVlanVidAugmentation(input, builder); - if (builder.isHasMask()) { - OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - } - return builder.build(); - } - - private static void addVlanVidAugmentation(ByteBuf input, MatchEntriesBuilder builder) { - VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder(); - int vidEntryValue = input.readUnsignedShort(); - vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit - vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit - builder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build()); - } - - @Override - protected Class getOxmField() { - return VlanVid.class; - } - - @Override - protected Class getOxmClass() { - return OpenflowBasicClass.class; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; +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.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer + implements OFDeserializer { + + @Override + public MatchEntries deserialize(ByteBuf input) { + MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input); + addVlanVidAugmentation(input, builder); + if (builder.isHasMask()) { + OxmMaskDeserializer.addMaskAugmentation(builder, input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + } + return builder.build(); + } + + private static void addVlanVidAugmentation(ByteBuf input, MatchEntriesBuilder builder) { + VlanVidMatchEntryBuilder vlanVidBuilder = new VlanVidMatchEntryBuilder(); + int vidEntryValue = input.readUnsignedShort(); + vlanVidBuilder.setCfiBit((vidEntryValue & (1 << 12)) != 0); // cfi is 13-th bit + vlanVidBuilder.setVlanVid(vidEntryValue & ((1 << 12) - 1)); // value without 13-th bit + builder.addAugmentation(VlanVidMatchEntry.class, vlanVidBuilder.build()); + } + + @Override + protected Class getOxmField() { + return VlanVid.class; + } + + @Override + protected Class getOxmClass() { + return OpenflowBasicClass.class; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java index d3e74b5c..51539db5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/ActionsInitializer.java @@ -1,119 +1,119 @@ -/* - * 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.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10EnqueueActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10OutputActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlDstActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlSrcActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwDstActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwSrcActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwTosActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetTpDstActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetTpSrcActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetVlanPcpActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetVlanVidActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10StripVlanActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13CopyTtlInActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13CopyTtlOutActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13DecMplsTtlActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13DecNwTtlActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13GroupActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13OutputActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopMplsActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopPbbActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopVlanActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushMplsActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushPbbActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushVlanActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetFieldActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetMplsTtlActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetNwTtlActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetQueueActionSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ActionSerializerRegistryHelper; -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.Enqueue; -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.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.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.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.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.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; - -/** - * Initializes serializer registry with action serializers - * @author michal.polkorab - */ -public final class ActionsInitializer { - - private ActionsInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers action serializers into provided registry - * @param serializerRegistry registry to be initialized with action serializers - */ - public static void registerActionSerializers(SerializerRegistry serializerRegistry) { - // register OF v1.0 action serializers - ActionSerializerRegistryHelper helper = new ActionSerializerRegistryHelper( - EncodeConstants.OF10_VERSION_ID, serializerRegistry); - helper.registerSerializer(Output.class, new OF10OutputActionSerializer()); - helper.registerSerializer(SetVlanVid.class, new OF10SetVlanVidActionSerializer()); - helper.registerSerializer(SetVlanPcp.class, new OF10SetVlanPcpActionSerializer()); - helper.registerSerializer(StripVlan.class, new OF10StripVlanActionSerializer()); - helper.registerSerializer(SetDlSrc.class, new OF10SetDlSrcActionSerializer()); - helper.registerSerializer(SetDlDst.class, new OF10SetDlDstActionSerializer()); - helper.registerSerializer(SetNwSrc.class, new OF10SetNwSrcActionSerializer()); - helper.registerSerializer(SetNwDst.class, new OF10SetNwDstActionSerializer()); - helper.registerSerializer(SetNwTos.class, new OF10SetNwTosActionSerializer()); - helper.registerSerializer(SetTpSrc.class, new OF10SetTpSrcActionSerializer()); - helper.registerSerializer(SetTpDst.class, new OF10SetTpDstActionSerializer()); - helper.registerSerializer(Enqueue.class, new OF10EnqueueActionSerializer()); - // register OF v1.0 action serializers - helper = new ActionSerializerRegistryHelper( - EncodeConstants.OF13_VERSION_ID, serializerRegistry); - helper.registerSerializer(Output.class, new OF13OutputActionSerializer()); - helper.registerSerializer(CopyTtlOut.class, new OF13CopyTtlOutActionSerializer()); - helper.registerSerializer(CopyTtlIn.class, new OF13CopyTtlInActionSerializer()); - helper.registerSerializer(SetMplsTtl.class, new OF13SetMplsTtlActionSerializer()); - helper.registerSerializer(DecMplsTtl.class, new OF13DecMplsTtlActionSerializer()); - helper.registerSerializer(PushVlan.class, new OF13PushVlanActionSerializer()); - helper.registerSerializer(PopVlan.class, new OF13PopVlanActionSerializer()); - helper.registerSerializer(PushMpls.class, new OF13PushMplsActionSerializer()); - helper.registerSerializer(PopMpls.class, new OF13PopMplsActionSerializer()); - helper.registerSerializer(SetQueue.class, new OF13SetQueueActionSerializer()); - helper.registerSerializer(Group.class, new OF13GroupActionSerializer()); - helper.registerSerializer(SetNwTtl.class, new OF13SetNwTtlActionSerializer()); - helper.registerSerializer(DecNwTtl.class, new OF13DecNwTtlActionSerializer()); - helper.registerSerializer(SetField.class, new OF13SetFieldActionSerializer()); - helper.registerSerializer(PushPbb.class, new OF13PushPbbActionSerializer()); - helper.registerSerializer(PopPbb.class, new OF13PopPbbActionSerializer()); - } +/* + * 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.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10EnqueueActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10OutputActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlDstActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetDlSrcActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwDstActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwSrcActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetNwTosActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetTpDstActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetTpSrcActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetVlanPcpActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10SetVlanVidActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF10StripVlanActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13CopyTtlInActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13CopyTtlOutActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13DecMplsTtlActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13DecNwTtlActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13GroupActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13OutputActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopMplsActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopPbbActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PopVlanActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushMplsActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushPbbActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13PushVlanActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetFieldActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetMplsTtlActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetNwTtlActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.action.OF13SetQueueActionSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.ActionSerializerRegistryHelper; +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.Enqueue; +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.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.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.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.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.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; + +/** + * Initializes serializer registry with action serializers + * @author michal.polkorab + */ +public final class ActionsInitializer { + + private ActionsInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers action serializers into provided registry + * @param serializerRegistry registry to be initialized with action serializers + */ + public static void registerActionSerializers(SerializerRegistry serializerRegistry) { + // register OF v1.0 action serializers + ActionSerializerRegistryHelper helper = new ActionSerializerRegistryHelper( + EncodeConstants.OF10_VERSION_ID, serializerRegistry); + helper.registerSerializer(Output.class, new OF10OutputActionSerializer()); + helper.registerSerializer(SetVlanVid.class, new OF10SetVlanVidActionSerializer()); + helper.registerSerializer(SetVlanPcp.class, new OF10SetVlanPcpActionSerializer()); + helper.registerSerializer(StripVlan.class, new OF10StripVlanActionSerializer()); + helper.registerSerializer(SetDlSrc.class, new OF10SetDlSrcActionSerializer()); + helper.registerSerializer(SetDlDst.class, new OF10SetDlDstActionSerializer()); + helper.registerSerializer(SetNwSrc.class, new OF10SetNwSrcActionSerializer()); + helper.registerSerializer(SetNwDst.class, new OF10SetNwDstActionSerializer()); + helper.registerSerializer(SetNwTos.class, new OF10SetNwTosActionSerializer()); + helper.registerSerializer(SetTpSrc.class, new OF10SetTpSrcActionSerializer()); + helper.registerSerializer(SetTpDst.class, new OF10SetTpDstActionSerializer()); + helper.registerSerializer(Enqueue.class, new OF10EnqueueActionSerializer()); + // register OF v1.0 action serializers + helper = new ActionSerializerRegistryHelper( + EncodeConstants.OF13_VERSION_ID, serializerRegistry); + helper.registerSerializer(Output.class, new OF13OutputActionSerializer()); + helper.registerSerializer(CopyTtlOut.class, new OF13CopyTtlOutActionSerializer()); + helper.registerSerializer(CopyTtlIn.class, new OF13CopyTtlInActionSerializer()); + helper.registerSerializer(SetMplsTtl.class, new OF13SetMplsTtlActionSerializer()); + helper.registerSerializer(DecMplsTtl.class, new OF13DecMplsTtlActionSerializer()); + helper.registerSerializer(PushVlan.class, new OF13PushVlanActionSerializer()); + helper.registerSerializer(PopVlan.class, new OF13PopVlanActionSerializer()); + helper.registerSerializer(PushMpls.class, new OF13PushMplsActionSerializer()); + helper.registerSerializer(PopMpls.class, new OF13PopMplsActionSerializer()); + helper.registerSerializer(SetQueue.class, new OF13SetQueueActionSerializer()); + helper.registerSerializer(Group.class, new OF13GroupActionSerializer()); + helper.registerSerializer(SetNwTtl.class, new OF13SetNwTtlActionSerializer()); + helper.registerSerializer(DecNwTtl.class, new OF13DecNwTtlActionSerializer()); + helper.registerSerializer(SetField.class, new OF13SetFieldActionSerializer()); + helper.registerSerializer(PushPbb.class, new OF13PushPbbActionSerializer()); + helper.registerSerializer(PopPbb.class, new OF13PopPbbActionSerializer()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java index f60898ed..46674e52 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/InstructionsInitializer.java @@ -1,52 +1,52 @@ -/* - * 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.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ApplyActionsInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ClearActionsInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.GoToTableInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.MeterInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionSerializerRegistryHelper; -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.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; - -/** - * @author michal.polkorab - * - */ -public final class InstructionsInitializer { - - private InstructionsInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers instruction serializers into provided registry - * @param serializerRegistry registry to be initialized with instruction serializers - */ - public static void registerInstructionSerializers(SerializerRegistry serializerRegistry) { - // register OF v1.3 instruction serializers - InstructionSerializerRegistryHelper helper= new InstructionSerializerRegistryHelper( - EncodeConstants.OF13_VERSION_ID, serializerRegistry); - helper.registerSerializer(GotoTable.class, new GoToTableInstructionSerializer()); - helper.registerSerializer(WriteMetadata.class, new WriteMetadataInstructionSerializer()); - helper.registerSerializer(WriteActions.class, new WriteActionsInstructionSerializer()); - helper.registerSerializer(ApplyActions.class, new ApplyActionsInstructionSerializer()); - helper.registerSerializer(ClearActions.class, new ClearActionsInstructionSerializer()); - helper.registerSerializer(Meter.class, new MeterInstructionSerializer()); - } -} +/* + * 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.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ApplyActionsInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.ClearActionsInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.GoToTableInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.MeterInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteActionsInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.instruction.WriteMetadataInstructionSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionSerializerRegistryHelper; +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.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; + +/** + * @author michal.polkorab + * + */ +public final class InstructionsInitializer { + + private InstructionsInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers instruction serializers into provided registry + * @param serializerRegistry registry to be initialized with instruction serializers + */ + public static void registerInstructionSerializers(SerializerRegistry serializerRegistry) { + // register OF v1.3 instruction serializers + InstructionSerializerRegistryHelper helper= new InstructionSerializerRegistryHelper( + EncodeConstants.OF13_VERSION_ID, serializerRegistry); + helper.registerSerializer(GotoTable.class, new GoToTableInstructionSerializer()); + helper.registerSerializer(WriteMetadata.class, new WriteMetadataInstructionSerializer()); + helper.registerSerializer(WriteActions.class, new WriteActionsInstructionSerializer()); + helper.registerSerializer(ApplyActions.class, new ApplyActionsInstructionSerializer()); + helper.registerSerializer(ClearActions.class, new ClearActionsInstructionSerializer()); + helper.registerSerializer(Meter.class, new MeterInstructionSerializer()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java index 4889fcbd..884617fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MatchEntriesInitializer.java @@ -1,172 +1,172 @@ -/* - * 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.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTcpFlagSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4DstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4SrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpThaSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpTpaSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthDstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthSrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthTypeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4CodeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4TypeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv6CodeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv6TypeSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmInPhyPortSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmInPortSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpDscpSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpEcnSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpProtoSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv4DstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv4SrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6DstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6ExtHdrSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6FlabelSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdSllSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdTargetSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdTllSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6SrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMetadataSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsBosSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsLabelSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsTcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmPbbIsidSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpDstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpSrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpDstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpSrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTunnelIdSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpDstSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer; -import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper; -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.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.Nxm1Class; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -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.TcpFlag; -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.TunnelIpv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src; -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; - -/** - * Initializes serializer registry with match entry serializers - * @author michal.polkorab - */ -public final class MatchEntriesInitializer { - - private MatchEntriesInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers match entry serializers into provided registry - * @param serializerRegistry registry to be initialized with match entry serializers - */ - public static void registerMatchEntrySerializers(SerializerRegistry serializerRegistry) { - // register OF v1.3 OpenflowBasicClass match entry serializers - Class oxmClass = OpenflowBasicClass.class; - MatchEntrySerializerRegistryHelper helper = - new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, - oxmClass, serializerRegistry); - helper.registerSerializer(InPort.class, new OxmInPortSerializer()); - helper.registerSerializer(InPhyPort.class, new OxmInPhyPortSerializer()); - helper.registerSerializer(Metadata.class, new OxmMetadataSerializer()); - helper.registerSerializer(EthDst.class, new OxmEthDstSerializer()); - helper.registerSerializer(EthSrc.class, new OxmEthSrcSerializer()); - helper.registerSerializer(EthType.class, new OxmEthTypeSerializer()); - helper.registerSerializer(VlanVid.class, new OxmVlanVidSerializer()); - helper.registerSerializer(VlanPcp.class, new OxmVlanPcpSerializer()); - helper.registerSerializer(IpDscp.class, new OxmIpDscpSerializer()); - helper.registerSerializer(IpEcn.class, new OxmIpEcnSerializer()); - helper.registerSerializer(IpProto.class, new OxmIpProtoSerializer()); - helper.registerSerializer(Ipv4Src.class, new OxmIpv4SrcSerializer()); - helper.registerSerializer(Ipv4Dst.class, new OxmIpv4DstSerializer()); - helper.registerSerializer(TcpSrc.class, new OxmTcpSrcSerializer()); - helper.registerSerializer(TcpDst.class, new OxmTcpDstSerializer()); - helper.registerSerializer(UdpSrc.class, new OxmUdpSrcSerializer()); - helper.registerSerializer(UdpDst.class, new OxmUdpDstSerializer()); - helper.registerSerializer(SctpSrc.class, new OxmSctpSrcSerializer()); - helper.registerSerializer(SctpDst.class, new OxmSctpDstSerializer()); - helper.registerSerializer(Icmpv4Type.class, new OxmIcmpv4TypeSerializer()); - helper.registerSerializer(Icmpv4Code.class, new OxmIcmpv4CodeSerializer()); - helper.registerSerializer(ArpOp.class, new OxmArpOpSerializer()); - helper.registerSerializer(ArpSpa.class, new OxmArpSpaSerializer()); - helper.registerSerializer(ArpTpa.class, new OxmArpTpaSerializer()); - helper.registerSerializer(ArpSha.class, new OxmArpShaSerializer()); - helper.registerSerializer(ArpTha.class, new OxmArpThaSerializer()); - helper.registerSerializer(Ipv6Src.class, new OxmIpv6SrcSerializer()); - helper.registerSerializer(Ipv6Dst.class, new OxmIpv6DstSerializer()); - helper.registerSerializer(Ipv6Flabel.class, new OxmIpv6FlabelSerializer()); - helper.registerSerializer(Icmpv6Type.class, new OxmIcmpv6TypeSerializer()); - helper.registerSerializer(Icmpv6Code.class, new OxmIcmpv6CodeSerializer()); - helper.registerSerializer(Ipv6NdTarget.class, new OxmIpv6NdTargetSerializer()); - helper.registerSerializer(Ipv6NdSll.class, new OxmIpv6NdSllSerializer()); - helper.registerSerializer(Ipv6NdTll.class, new OxmIpv6NdTllSerializer()); - helper.registerSerializer(MplsLabel.class, new OxmMplsLabelSerializer()); - helper.registerSerializer(MplsTc.class, new OxmMplsTcSerializer()); - helper.registerSerializer(MplsBos.class, new OxmMplsBosSerializer()); - helper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer()); - helper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer()); - helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); - - // Register OpenFlow NXM1Class match entry serializer - Class nxm1Class = Nxm1Class.class; - MatchEntrySerializerRegistryHelper nxm1RegistryHelper = - new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, - nxm1Class, serializerRegistry); - nxm1RegistryHelper.registerSerializer(TunnelIpv4Dst.class, new NxmTunnelIpv4DstSerializer()); - nxm1RegistryHelper.registerSerializer(TunnelIpv4Src.class, new NxmTunnelIpv4SrcSerializer()); - nxm1RegistryHelper.registerSerializer(TcpFlag.class, new NxmTcpFlagSerializer()); - } -} +/* + * 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.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTcpFlagSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4DstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.NxmTunnelIpv4SrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpOpSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpShaSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpSpaSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpThaSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmArpTpaSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthDstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthSrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmEthTypeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4CodeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv4TypeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv6CodeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIcmpv6TypeSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmInPhyPortSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmInPortSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpDscpSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpEcnSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpProtoSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv4DstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv4SrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6DstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6ExtHdrSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6FlabelSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdSllSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdTargetSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6NdTllSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmIpv6SrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMetadataSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsBosSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsLabelSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmMplsTcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmPbbIsidSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpDstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmSctpSrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpDstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpSrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTunnelIdSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpDstSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializer; +import org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.MatchEntrySerializerRegistryHelper; +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.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.Nxm1Class; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +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.TcpFlag; +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.TunnelIpv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelIpv4Src; +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; + +/** + * Initializes serializer registry with match entry serializers + * @author michal.polkorab + */ +public final class MatchEntriesInitializer { + + private MatchEntriesInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers match entry serializers into provided registry + * @param serializerRegistry registry to be initialized with match entry serializers + */ + public static void registerMatchEntrySerializers(SerializerRegistry serializerRegistry) { + // register OF v1.3 OpenflowBasicClass match entry serializers + Class oxmClass = OpenflowBasicClass.class; + MatchEntrySerializerRegistryHelper helper = + new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, + oxmClass, serializerRegistry); + helper.registerSerializer(InPort.class, new OxmInPortSerializer()); + helper.registerSerializer(InPhyPort.class, new OxmInPhyPortSerializer()); + helper.registerSerializer(Metadata.class, new OxmMetadataSerializer()); + helper.registerSerializer(EthDst.class, new OxmEthDstSerializer()); + helper.registerSerializer(EthSrc.class, new OxmEthSrcSerializer()); + helper.registerSerializer(EthType.class, new OxmEthTypeSerializer()); + helper.registerSerializer(VlanVid.class, new OxmVlanVidSerializer()); + helper.registerSerializer(VlanPcp.class, new OxmVlanPcpSerializer()); + helper.registerSerializer(IpDscp.class, new OxmIpDscpSerializer()); + helper.registerSerializer(IpEcn.class, new OxmIpEcnSerializer()); + helper.registerSerializer(IpProto.class, new OxmIpProtoSerializer()); + helper.registerSerializer(Ipv4Src.class, new OxmIpv4SrcSerializer()); + helper.registerSerializer(Ipv4Dst.class, new OxmIpv4DstSerializer()); + helper.registerSerializer(TcpSrc.class, new OxmTcpSrcSerializer()); + helper.registerSerializer(TcpDst.class, new OxmTcpDstSerializer()); + helper.registerSerializer(UdpSrc.class, new OxmUdpSrcSerializer()); + helper.registerSerializer(UdpDst.class, new OxmUdpDstSerializer()); + helper.registerSerializer(SctpSrc.class, new OxmSctpSrcSerializer()); + helper.registerSerializer(SctpDst.class, new OxmSctpDstSerializer()); + helper.registerSerializer(Icmpv4Type.class, new OxmIcmpv4TypeSerializer()); + helper.registerSerializer(Icmpv4Code.class, new OxmIcmpv4CodeSerializer()); + helper.registerSerializer(ArpOp.class, new OxmArpOpSerializer()); + helper.registerSerializer(ArpSpa.class, new OxmArpSpaSerializer()); + helper.registerSerializer(ArpTpa.class, new OxmArpTpaSerializer()); + helper.registerSerializer(ArpSha.class, new OxmArpShaSerializer()); + helper.registerSerializer(ArpTha.class, new OxmArpThaSerializer()); + helper.registerSerializer(Ipv6Src.class, new OxmIpv6SrcSerializer()); + helper.registerSerializer(Ipv6Dst.class, new OxmIpv6DstSerializer()); + helper.registerSerializer(Ipv6Flabel.class, new OxmIpv6FlabelSerializer()); + helper.registerSerializer(Icmpv6Type.class, new OxmIcmpv6TypeSerializer()); + helper.registerSerializer(Icmpv6Code.class, new OxmIcmpv6CodeSerializer()); + helper.registerSerializer(Ipv6NdTarget.class, new OxmIpv6NdTargetSerializer()); + helper.registerSerializer(Ipv6NdSll.class, new OxmIpv6NdSllSerializer()); + helper.registerSerializer(Ipv6NdTll.class, new OxmIpv6NdTllSerializer()); + helper.registerSerializer(MplsLabel.class, new OxmMplsLabelSerializer()); + helper.registerSerializer(MplsTc.class, new OxmMplsTcSerializer()); + helper.registerSerializer(MplsBos.class, new OxmMplsBosSerializer()); + helper.registerSerializer(PbbIsid.class, new OxmPbbIsidSerializer()); + helper.registerSerializer(TunnelId.class, new OxmTunnelIdSerializer()); + helper.registerSerializer(Ipv6Exthdr.class, new OxmIpv6ExtHdrSerializer()); + + // Register OpenFlow NXM1Class match entry serializer + Class nxm1Class = Nxm1Class.class; + MatchEntrySerializerRegistryHelper nxm1RegistryHelper = + new MatchEntrySerializerRegistryHelper<>(EncodeConstants.OF13_VERSION_ID, + nxm1Class, serializerRegistry); + nxm1RegistryHelper.registerSerializer(TunnelIpv4Dst.class, new NxmTunnelIpv4DstSerializer()); + nxm1RegistryHelper.registerSerializer(TunnelIpv4Src.class, new NxmTunnelIpv4SrcSerializer()); + nxm1RegistryHelper.registerSerializer(TcpFlag.class, new NxmTcpFlagSerializer()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java index 70db90be..c3610c13 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/MessageFactoryInitializer.java @@ -1,113 +1,113 @@ -/* - * 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.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.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.CommonMessageRegistryHelper; -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; - -/** - * @author michal.polkorab - * - */ -public final class MessageFactoryInitializer { - - private MessageFactoryInitializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Registers message serializers into provided registry - * @param serializerRegistry registry to be initialized with message serializers - */ - public static void registerMessageSerializers(SerializerRegistry serializerRegistry) { - // register OF v1.0 message serializers - short version = EncodeConstants.OF10_VERSION_ID; - CommonMessageRegistryHelper registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); - registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory()); - registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); - registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); - registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); - registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory()); - registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); - registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); - registryHelper.registerSerializer(GetQueueConfigInput.class, new OF10QueueGetConfigInputMessageFactory()); - registryHelper.registerSerializer(HelloInput.class, new OF10HelloInputMessageFactory()); - registryHelper.registerSerializer(MultipartRequestInput.class, new OF10StatsRequestInputFactory()); - registryHelper.registerSerializer(PacketOutInput.class, new OF10PacketOutInputMessageFactory()); - registryHelper.registerSerializer(PortModInput.class, new OF10PortModInputMessageFactory()); - registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); - // register OF v1.3 message serializers - version = EncodeConstants.OF13_VERSION_ID; - registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); - registryHelper.registerSerializer(BarrierInput.class, new BarrierInputMessageFactory()); - registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); - registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); - registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); - registryHelper.registerSerializer(FlowModInput.class, new FlowModInputMessageFactory()); - registryHelper.registerSerializer(GetAsyncInput.class, new GetAsyncRequestMessageFactory()); - registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); - registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); - registryHelper.registerSerializer(GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory()); - registryHelper.registerSerializer(GroupModInput.class, new GroupModInputMessageFactory()); - registryHelper.registerSerializer(HelloInput.class, new HelloInputMessageFactory()); - registryHelper.registerSerializer(MeterModInput.class, new MeterModInputMessageFactory()); - registryHelper.registerSerializer(MultipartRequestInput.class, new MultipartRequestInputFactory()); - registryHelper.registerSerializer(PacketOutInput.class, new PacketOutInputMessageFactory()); - registryHelper.registerSerializer(PortModInput.class, new PortModInputMessageFactory()); - registryHelper.registerSerializer(RoleRequestInput.class, new RoleRequestInputMessageFactory()); - registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory()); - registryHelper.registerSerializer( SetConfigInput.class, new SetConfigMessageFactory()); - registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory()); - } -} +/* + * 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.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.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.CommonMessageRegistryHelper; +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; + +/** + * @author michal.polkorab + * + */ +public final class MessageFactoryInitializer { + + private MessageFactoryInitializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Registers message serializers into provided registry + * @param serializerRegistry registry to be initialized with message serializers + */ + public static void registerMessageSerializers(SerializerRegistry serializerRegistry) { + // register OF v1.0 message serializers + short version = EncodeConstants.OF10_VERSION_ID; + CommonMessageRegistryHelper registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); + registryHelper.registerSerializer(BarrierInput.class, new OF10BarrierInputMessageFactory()); + registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); + registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); + registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); + registryHelper.registerSerializer(FlowModInput.class, new OF10FlowModInputMessageFactory()); + registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); + registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); + registryHelper.registerSerializer(GetQueueConfigInput.class, new OF10QueueGetConfigInputMessageFactory()); + registryHelper.registerSerializer(HelloInput.class, new OF10HelloInputMessageFactory()); + registryHelper.registerSerializer(MultipartRequestInput.class, new OF10StatsRequestInputFactory()); + registryHelper.registerSerializer(PacketOutInput.class, new OF10PacketOutInputMessageFactory()); + registryHelper.registerSerializer(PortModInput.class, new OF10PortModInputMessageFactory()); + registryHelper.registerSerializer(SetConfigInput.class, new SetConfigMessageFactory()); + // register OF v1.3 message serializers + version = EncodeConstants.OF13_VERSION_ID; + registryHelper = new CommonMessageRegistryHelper(version, serializerRegistry); + registryHelper.registerSerializer(BarrierInput.class, new BarrierInputMessageFactory()); + registryHelper.registerSerializer(EchoInput.class, new EchoInputMessageFactory()); + registryHelper.registerSerializer(EchoReplyInput.class, new EchoReplyInputMessageFactory()); + registryHelper.registerSerializer(ExperimenterInput.class, new ExperimenterInputMessageFactory()); + registryHelper.registerSerializer(FlowModInput.class, new FlowModInputMessageFactory()); + registryHelper.registerSerializer(GetAsyncInput.class, new GetAsyncRequestMessageFactory()); + registryHelper.registerSerializer(GetConfigInput.class, new GetConfigInputMessageFactory()); + registryHelper.registerSerializer(GetFeaturesInput.class, new GetFeaturesInputMessageFactory()); + registryHelper.registerSerializer(GetQueueConfigInput.class, new GetQueueConfigInputMessageFactory()); + registryHelper.registerSerializer(GroupModInput.class, new GroupModInputMessageFactory()); + registryHelper.registerSerializer(HelloInput.class, new HelloInputMessageFactory()); + registryHelper.registerSerializer(MeterModInput.class, new MeterModInputMessageFactory()); + registryHelper.registerSerializer(MultipartRequestInput.class, new MultipartRequestInputFactory()); + registryHelper.registerSerializer(PacketOutInput.class, new PacketOutInputMessageFactory()); + registryHelper.registerSerializer(PortModInput.class, new PortModInputMessageFactory()); + registryHelper.registerSerializer(RoleRequestInput.class, new RoleRequestInputMessageFactory()); + registryHelper.registerSerializer(SetAsyncInput.class, new SetAsyncInputMessageFactory()); + registryHelper.registerSerializer( SetConfigInput.class, new SetConfigMessageFactory()); + registryHelper.registerSerializer(TableModInput.class, new TableModInputMessageFactory()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java index 8babf572..0ab44159 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractActionSerializer.java @@ -1,47 +1,47 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractActionSerializer implements OFSerializer, - HeaderSerializer{ - - @Override - public void serialize(Action input, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(getLength()); - } - - @Override - public void serializeHeader(Action input, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); - } - - /** - * @return numeric representation of action type - */ - protected abstract int getType(); - - /** - * @return action length - */ - protected abstract int getLength(); - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractActionSerializer implements OFSerializer, + HeaderSerializer{ + + @Override + public void serialize(Action input, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(getLength()); + } + + @Override + public void serializeHeader(Action input, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); + } + + /** + * @return numeric representation of action type + */ + protected abstract int getType(); + + /** + * @return action length + */ + protected abstract int getLength(); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java index 9c4117a4..33858e33 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractEthertypeActionSerializer.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractEthertypeActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class); - outBuffer.writeShort(ethertype.getEthertype().getValue()); - outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractEthertypeActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + EthertypeAction ethertype = action.getAugmentation(EthertypeAction.class); + outBuffer.writeShort(ethertype.getEthertype().getValue()); + outBuffer.writeZero(ActionConstants.ETHERTYPE_ACTION_PADDING); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java index aa82f49e..335d19e4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/AbstractHeaderActionSerializer.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractHeaderActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractHeaderActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeZero(ActionConstants.PADDING_IN_ACTION_HEADER); + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java index d7bf73aa..fd7c4b5f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractIpAddressActionSerializer.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractIpAddressActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(final Action action, final ByteBuf outBuffer) { - super.serialize(action, outBuffer); - Iterable addressGroups = ByteBufUtils.DOT_SPLITTER - .split(action.getAugmentation(IpAddressAction.class).getIpAddress().getValue()); - for (String group : addressGroups) { - outBuffer.writeByte(Short.parseShort(group)); - } - } -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IpAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractIpAddressActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(final Action action, final ByteBuf outBuffer) { + super.serialize(action, outBuffer); + Iterable addressGroups = ByteBufUtils.DOT_SPLITTER + .split(action.getAugmentation(IpAddressAction.class).getIpAddress().getValue()); + for (String group : addressGroups) { + outBuffer.writeByte(Short.parseShort(group)); + } + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java index f8c47352..770d1892 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractMacAddressActionSerializer.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.serialization.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractMacAddressActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(action - .getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractMacAddressActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(action + .getAugmentation(DlAddressAction.class).getDlAddress().getValue())); + outBuffer.writeZero(ActionConstants.PADDING_IN_DL_ADDRESS_ACTION); + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java index a02df47e..194669a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10AbstractPortActionSerializer.java @@ -1,30 +1,30 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public abstract class OF10AbstractPortActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); - outBuffer.writeZero(ActionConstants.PADDING_IN_TP_PORT_ACTION); - } -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public abstract class OF10AbstractPortActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + PortAction port = action.getAugmentation(PortAction.class); + outBuffer.writeShort(port.getPort().getValue().intValue()); + outBuffer.writeZero(ActionConstants.PADDING_IN_TP_PORT_ACTION); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java index dfc79768..59ec7d61 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10EnqueueActionSerializer.java @@ -1,44 +1,44 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -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.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10EnqueueActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); - outBuffer.writeZero(ActionConstants.PADDING_IN_ENQUEUE_ACTION); - QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); - outBuffer.writeInt(queueId.getQueueId().intValue()); - } - - @Override - protected int getType() { - return ActionConstants.ENQUEUE_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.LARGER_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +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.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10EnqueueActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + PortAction port = action.getAugmentation(PortAction.class); + outBuffer.writeShort(port.getPort().getValue().intValue()); + outBuffer.writeZero(ActionConstants.PADDING_IN_ENQUEUE_ACTION); + QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); + outBuffer.writeInt(queueId.getQueueId().intValue()); + } + + @Override + protected int getType() { + return ActionConstants.ENQUEUE_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.LARGER_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java index b6231cd4..38e45587 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10OutputActionSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10OutputActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeShort(port.getPort().getValue().intValue()); - MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); - outBuffer.writeShort(maxlength.getMaxLength()); - } - - @Override - protected int getType() { - return ActionConstants.OUTPUT_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10OutputActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + PortAction port = action.getAugmentation(PortAction.class); + outBuffer.writeShort(port.getPort().getValue().intValue()); + MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); + outBuffer.writeShort(maxlength.getMaxLength()); + } + + @Override + protected int getType() { + return ActionConstants.OUTPUT_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java index 2e013323..b174b0f9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlDstActionSerializer.java @@ -1,29 +1,29 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetDlDstActionSerializer extends OF10AbstractMacAddressActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_DL_DST_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.LARGER_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetDlDstActionSerializer extends OF10AbstractMacAddressActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_DL_DST_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.LARGER_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java index 623767c7..e9f002da 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetDlSrcActionSerializer.java @@ -1,29 +1,29 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetDlSrcActionSerializer extends OF10AbstractMacAddressActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_DL_SRC_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.LARGER_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetDlSrcActionSerializer extends OF10AbstractMacAddressActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_DL_SRC_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.LARGER_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java index 35a85611..2494ced3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwDstActionSerializer.java @@ -1,29 +1,29 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwDstActionSerializer extends OF10AbstractIpAddressActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_NW_DST_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwDstActionSerializer extends OF10AbstractIpAddressActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_NW_DST_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java index c4f259a7..b708b163 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwSrcActionSerializer.java @@ -1,27 +1,27 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwSrcActionSerializer extends OF10AbstractIpAddressActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_NW_SRC_CODE; - } - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwSrcActionSerializer extends OF10AbstractIpAddressActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_NW_SRC_CODE; + } + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java index 0d668248..c75335c2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetNwTosActionSerializer.java @@ -1,40 +1,40 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10SetNwTosActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeByte(action.getAugmentation(NwTosAction.class).getNwTos()); - outBuffer.writeZero(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); - } - - @Override - protected int getType() { - return ActionConstants.SET_NW_TOS_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTosAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10SetNwTosActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeByte(action.getAugmentation(NwTosAction.class).getNwTos()); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); + } + + @Override + protected int getType() { + return ActionConstants.SET_NW_TOS_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java index 3000de79..929db82b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpDstActionSerializer.java @@ -1,29 +1,29 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetTpDstActionSerializer extends OF10AbstractPortActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_TP_DST_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetTpDstActionSerializer extends OF10AbstractPortActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_TP_DST_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java index 0280145c..7c062eae 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetTpSrcActionSerializer.java @@ -1,29 +1,29 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF10SetTpSrcActionSerializer extends OF10AbstractPortActionSerializer { - - @Override - protected int getType() { - return ActionConstants.SET_TP_SRC_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF10SetTpSrcActionSerializer extends OF10AbstractPortActionSerializer { + + @Override + protected int getType() { + return ActionConstants.SET_TP_SRC_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java index 29fdafe0..973d026c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanPcpActionSerializer.java @@ -1,40 +1,40 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10SetVlanPcpActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeByte(action.getAugmentation(VlanPcpAction.class).getVlanPcp()); - outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); - } - - @Override - protected int getType() { - return ActionConstants.SET_VLAN_PCP_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10SetVlanPcpActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeByte(action.getAugmentation(VlanPcpAction.class).getVlanPcp()); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); + } + + @Override + protected int getType() { + return ActionConstants.SET_VLAN_PCP_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java index e788f8d4..afe000c9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10SetVlanVidActionSerializer.java @@ -1,40 +1,40 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10SetVlanVidActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - outBuffer.writeShort(action.getAugmentation(VlanVidAction.class).getVlanVid()); - outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); - } - - @Override - protected int getType() { - return ActionConstants.SET_VLAN_VID_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10SetVlanVidActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + outBuffer.writeShort(action.getAugmentation(VlanVidAction.class).getVlanVid()); + outBuffer.writeZero(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); + } + + @Override + protected int getType() { + return ActionConstants.SET_VLAN_VID_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java index 4bfc2c16..d3903233 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF10StripVlanActionSerializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - - -/** - * @author michal.polkorab - * - */ -public class OF10StripVlanActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.STRIP_VLAN_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + + +/** + * @author michal.polkorab + * + */ +public class OF10StripVlanActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.STRIP_VLAN_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java index 69d70e59..59020cd1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlInActionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13CopyTtlInActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.COPY_TTL_IN_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13CopyTtlInActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.COPY_TTL_IN_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java index a5b3059a..da6cf058 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13CopyTtlOutActionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13CopyTtlOutActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.COPY_TTL_OUT_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13CopyTtlOutActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.COPY_TTL_OUT_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java index 9f6f741b..6d7be277 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecMplsTtlActionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13DecMplsTtlActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.DEC_MPLS_TTL_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13DecMplsTtlActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.DEC_MPLS_TTL_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java index f1610b76..d1f44369 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13DecNwTtlActionSerializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - - -/** - * @author michal.polkorab - * - */ -public class OF13DecNwTtlActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.DEC_NW_TTL_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + + +/** + * @author michal.polkorab + * + */ +public class OF13DecNwTtlActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.DEC_NW_TTL_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java index a36fa554..6e87760a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13GroupActionSerializer.java @@ -1,40 +1,40 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13GroupActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - GroupIdAction groupId = action.getAugmentation(GroupIdAction.class); - outBuffer.writeInt(groupId.getGroupId().intValue()); - } - - @Override - protected int getType() { - return ActionConstants.GROUP_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.GroupIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13GroupActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + GroupIdAction groupId = action.getAugmentation(GroupIdAction.class); + outBuffer.writeInt(groupId.getGroupId().intValue()); + } + + @Override + protected int getType() { + return ActionConstants.GROUP_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java index 2ac79f7d..0b6c5658 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13OutputActionSerializer.java @@ -1,44 +1,44 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13OutputActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - PortAction port = action.getAugmentation(PortAction.class); - outBuffer.writeInt(port.getPort().getValue().intValue()); - MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); - outBuffer.writeShort(maxlength.getMaxLength()); - outBuffer.writeZero(ActionConstants.OUTPUT_PADDING); - } - - @Override - protected int getType() { - return ActionConstants.OUTPUT_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.LARGER_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13OutputActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + PortAction port = action.getAugmentation(PortAction.class); + outBuffer.writeInt(port.getPort().getValue().intValue()); + MaxLengthAction maxlength = action.getAugmentation(MaxLengthAction.class); + outBuffer.writeShort(maxlength.getMaxLength()); + outBuffer.writeZero(ActionConstants.OUTPUT_PADDING); + } + + @Override + protected int getType() { + return ActionConstants.OUTPUT_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.LARGER_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java index bd3fac22..2857b4a0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopMplsActionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PopMplsActionSerializer extends AbstractEthertypeActionSerializer { - - @Override - protected int getType() { - return ActionConstants.POP_MPLS_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PopMplsActionSerializer extends AbstractEthertypeActionSerializer { + + @Override + protected int getType() { + return ActionConstants.POP_MPLS_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java index ecf8bea5..8187f226 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopPbbActionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PopPbbActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.POP_PBB_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PopPbbActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.POP_PBB_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java index 960e5fb3..39ffd1a5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PopVlanActionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PopVlanActionSerializer extends AbstractHeaderActionSerializer { - - @Override - protected int getType() { - return ActionConstants.POP_VLAN_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PopVlanActionSerializer extends AbstractHeaderActionSerializer { + + @Override + protected int getType() { + return ActionConstants.POP_VLAN_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java index ca992eec..8c2bd764 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushMplsActionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PushMplsActionSerializer extends AbstractEthertypeActionSerializer { - - @Override - protected int getType() { - return ActionConstants.PUSH_MPLS_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PushMplsActionSerializer extends AbstractEthertypeActionSerializer { + + @Override + protected int getType() { + return ActionConstants.PUSH_MPLS_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java index 746c2b4e..732a73cf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushPbbActionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - -/** - * @author michal.polkorab - * - */ -public class OF13PushPbbActionSerializer extends AbstractEthertypeActionSerializer { - - @Override - protected int getType() { - return ActionConstants.PUSH_PBB_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + +/** + * @author michal.polkorab + * + */ +public class OF13PushPbbActionSerializer extends AbstractEthertypeActionSerializer { + + @Override + protected int getType() { + return ActionConstants.PUSH_PBB_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java index 71795ec6..1dedb85b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13PushVlanActionSerializer.java @@ -1,25 +1,25 @@ -/* - * 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.action; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; - - -/** - * @author michal.polkorab - * - */ -public class OF13PushVlanActionSerializer extends AbstractEthertypeActionSerializer { - - @Override - protected int getType() { - return ActionConstants.PUSH_VLAN_CODE; - } - -} +/* + * 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.action; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; + + +/** + * @author michal.polkorab + * + */ +public class OF13PushVlanActionSerializer extends AbstractEthertypeActionSerializer { + + @Override + protected int getType() { + return ActionConstants.PUSH_VLAN_CODE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java index 6b56fd09..65eefec9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetFieldActionSerializer.java @@ -1,71 +1,71 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OF13SetFieldActionSerializer implements OFSerializer, - HeaderSerializer, SerializerRegistryInjector { - - private SerializerRegistry registry; - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class); - MatchEntries entry = oxmField.getMatchEntries().get(0); - MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( - EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); - if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) - .getExperimenter().getValue()); - } else { - key.setExperimenterId(null); - } - OFSerializer serializer = registry.getSerializer(key); - serializer.serialize(entry, outBuffer); - int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING; - if (paddingRemainder != 0) { - outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder); - } - outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); - } - - @Override - public void serializeHeader(Action input, ByteBuf outBuffer) { - outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); - outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); - } - - @Override - public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { - registry = serializerRegistry; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmFieldsAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OF13SetFieldActionSerializer implements OFSerializer, + HeaderSerializer, SerializerRegistryInjector { + + private SerializerRegistry registry; + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + int startIndex = outBuffer.writerIndex(); + outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); + int lengthIndex = outBuffer.writerIndex(); + outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + OxmFieldsAction oxmField = action.getAugmentation(OxmFieldsAction.class); + MatchEntries entry = oxmField.getMatchEntries().get(0); + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>( + EncodeConstants.OF13_VERSION_ID, entry.getOxmClass(), entry.getOxmMatchField()); + if (entry.getOxmClass().equals(ExperimenterClass.class)) { + key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) + .getExperimenter().getValue()); + } else { + key.setExperimenterId(null); + } + OFSerializer serializer = registry.getSerializer(key); + serializer.serialize(entry, outBuffer); + int paddingRemainder = (outBuffer.writerIndex() - startIndex) % EncodeConstants.PADDING; + if (paddingRemainder != 0) { + outBuffer.writeZero(EncodeConstants.PADDING - paddingRemainder); + } + outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex); + } + + @Override + public void serializeHeader(Action input, ByteBuf outBuffer) { + outBuffer.writeShort(ActionConstants.SET_FIELD_CODE); + outBuffer.writeShort(ActionConstants.ACTION_IDS_LENGTH); + } + + @Override + public void injectSerializerRegistry(SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java index 480bc931..aacebf2f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetMplsTtlActionSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13SetMplsTtlActionSerializer extends AbstractActionSerializer { - - - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class); - outBuffer.writeByte(mplsTtl.getMplsTtl()); - outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING); - } - - @Override - protected int getType() { - return ActionConstants.SET_MPLS_TTL_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13SetMplsTtlActionSerializer extends AbstractActionSerializer { + + + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + MplsTtlAction mplsTtl = action.getAugmentation(MplsTtlAction.class); + outBuffer.writeByte(mplsTtl.getMplsTtl()); + outBuffer.writeZero(ActionConstants.SET_MPLS_TTL_PADDING); + } + + @Override + protected int getType() { + return ActionConstants.SET_MPLS_TTL_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java index b30cf5d5..70796dc5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetNwTtlActionSerializer.java @@ -1,41 +1,41 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13SetNwTtlActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class); - outBuffer.writeByte(nwTtl.getNwTtl()); - outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING); - } - - @Override - protected int getType() { - return ActionConstants.SET_NW_TTL_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13SetNwTtlActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + NwTtlAction nwTtl = action.getAugmentation(NwTtlAction.class); + outBuffer.writeByte(nwTtl.getNwTtl()); + outBuffer.writeZero(ActionConstants.SET_NW_TTL_PADDING); + } + + @Override + protected int getType() { + return ActionConstants.SET_NW_TTL_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java index c11d14fb..4586b926 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/action/OF13SetQueueActionSerializer.java @@ -1,40 +1,40 @@ -/* - * 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.action; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF13SetQueueActionSerializer extends AbstractActionSerializer { - - @Override - public void serialize(Action action, ByteBuf outBuffer) { - super.serialize(action, outBuffer); - QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); - outBuffer.writeInt(queueId.getQueueId().intValue()); - } - - @Override - protected int getType() { - return ActionConstants.SET_QUEUE_CODE; - } - - @Override - protected int getLength() { - return ActionConstants.GENERAL_ACTION_LENGTH; - } - -} +/* + * 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.action; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.QueueIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF13SetQueueActionSerializer extends AbstractActionSerializer { + + @Override + public void serialize(Action action, ByteBuf outBuffer) { + super.serialize(action, outBuffer); + QueueIdAction queueId = action.getAugmentation(QueueIdAction.class); + outBuffer.writeInt(queueId.getQueueId().intValue()); + } + + @Override + protected int getType() { + return ActionConstants.SET_QUEUE_CODE; + } + + @Override + protected int getLength() { + return ActionConstants.GENERAL_ACTION_LENGTH; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java index 4b381d3b..217fb120 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractActionInstructionSerializer.java @@ -1,64 +1,64 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; -import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractActionInstructionSerializer extends AbstractInstructionSerializer - implements SerializerRegistryInjector { - - private static final TypeKeyMaker ACTION_KEY_MAKER = - TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); - - private SerializerRegistry registry; - - @Override - public void serialize(final Instruction instruction, final ByteBuf outBuffer) { - int startIndex = outBuffer.writerIndex(); - outBuffer.writeShort(getType()); - if (instruction.getAugmentation(ActionsInstruction.class) != null) { - List actions = instruction.getAugmentation(ActionsInstruction.class).getAction(); - int lengthIndex = outBuffer.writerIndex(); - outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); - outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer); - int instructionLength = outBuffer.writerIndex() - startIndex; - outBuffer.setShort(lengthIndex, instructionLength); - } else { - outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); - } - } - - protected SerializerRegistry getRegistry() { - return registry; - } - - @Override - public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { - registry = serializerRegistry; - } -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMaker; +import org.opendaylight.openflowjava.protocol.impl.util.TypeKeyMakerFactory; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.openflowjava.protocol.impl.util.ListSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractActionInstructionSerializer extends AbstractInstructionSerializer + implements SerializerRegistryInjector { + + private static final TypeKeyMaker ACTION_KEY_MAKER = + TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + + private SerializerRegistry registry; + + @Override + public void serialize(final Instruction instruction, final ByteBuf outBuffer) { + int startIndex = outBuffer.writerIndex(); + outBuffer.writeShort(getType()); + if (instruction.getAugmentation(ActionsInstruction.class) != null) { + List actions = instruction.getAugmentation(ActionsInstruction.class).getAction(); + int lengthIndex = outBuffer.writerIndex(); + outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + ListSerializer.serializeList(actions, ACTION_KEY_MAKER, getRegistry(), outBuffer); + int instructionLength = outBuffer.writerIndex() - startIndex; + outBuffer.setShort(lengthIndex, instructionLength); + } else { + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_ACTIONS_INSTRUCTION); + } + } + + protected SerializerRegistry getRegistry() { + return registry; + } + + @Override + public void injectSerializerRegistry(final SerializerRegistry serializerRegistry) { + registry = serializerRegistry; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractInstructionSerializer.java index f672016e..c5d33317 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/AbstractInstructionSerializer.java @@ -1,36 +1,36 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public abstract class AbstractInstructionSerializer implements OFSerializer, - HeaderSerializer { - - @Override - public void serializeHeader(Instruction input, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(InstructionConstants.INSTRUCTION_IDS_LENGTH); - } - - /** - * @return numeric representation of action type - */ - protected abstract int getType(); - -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public abstract class AbstractInstructionSerializer implements OFSerializer, + HeaderSerializer { + + @Override + public void serializeHeader(Instruction input, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.INSTRUCTION_IDS_LENGTH); + } + + /** + * @return numeric representation of action type + */ + protected abstract int getType(); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java index f2f4c271..2aaae19b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ApplyActionsInstructionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.instruction; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; - -/** - * @author michal.polkorab - * - */ -public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer { - - @Override - protected int getType() { - return InstructionConstants.APPLY_ACTIONS_TYPE; - } - -} +/* + * 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.instruction; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; + +/** + * @author michal.polkorab + * + */ +public class ApplyActionsInstructionSerializer extends AbstractActionInstructionSerializer { + + @Override + protected int getType() { + return InstructionConstants.APPLY_ACTIONS_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java index 85e27d23..00162502 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/ClearActionsInstructionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.instruction; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; - -/** - * @author michal.polkorab - * - */ -public class ClearActionsInstructionSerializer extends AbstractActionInstructionSerializer { - - @Override - protected int getType() { - return InstructionConstants.CLEAR_ACTIONS_TYPE; - } - -} +/* + * 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.instruction; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; + +/** + * @author michal.polkorab + * + */ +public class ClearActionsInstructionSerializer extends AbstractActionInstructionSerializer { + + @Override + protected int getType() { + return InstructionConstants.CLEAR_ACTIONS_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java index 3c65edff..9e18a12f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/GoToTableInstructionSerializer.java @@ -1,36 +1,36 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class GoToTableInstructionSerializer extends AbstractInstructionSerializer { - - @Override - public void serialize(Instruction instruction, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId()); - outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE); - } - - @Override - protected int getType() { - return InstructionConstants.GOTO_TABLE_TYPE; - } - -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class GoToTableInstructionSerializer extends AbstractInstructionSerializer { + + @Override + public void serialize(Instruction instruction, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeByte(instruction.getAugmentation(TableIdInstruction.class).getTableId()); + outBuffer.writeZero(InstructionConstants.PADDING_IN_GOTO_TABLE); + } + + @Override + protected int getType() { + return InstructionConstants.GOTO_TABLE_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java index c171f50f..5a8f5ab8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/MeterInstructionSerializer.java @@ -1,36 +1,36 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class MeterInstructionSerializer extends AbstractInstructionSerializer { - - @Override - public void serialize(Instruction instruction, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); - outBuffer.writeInt(instruction. - getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); - } - - @Override - protected int getType() { - return InstructionConstants.METER_TYPE; - } - -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class MeterInstructionSerializer extends AbstractInstructionSerializer { + + @Override + public void serialize(Instruction instruction, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.STANDARD_INSTRUCTION_LENGTH); + outBuffer.writeInt(instruction. + getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); + } + + @Override + protected int getType() { + return InstructionConstants.METER_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java index f4de32c4..10e20504 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteActionsInstructionSerializer.java @@ -1,24 +1,24 @@ -/* - * 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.instruction; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; - -/** - * @author michal.polkorab - * - */ -public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer { - - @Override - protected int getType() { - return InstructionConstants.WRITE_ACTIONS_TYPE; - } - -} +/* + * 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.instruction; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; + +/** + * @author michal.polkorab + * + */ +public class WriteActionsInstructionSerializer extends AbstractActionInstructionSerializer { + + @Override + protected int getType() { + return InstructionConstants.WRITE_ACTIONS_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java index 6c16ea39..43d3e27a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/instruction/WriteMetadataInstructionSerializer.java @@ -1,38 +1,38 @@ -/* - * 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.instruction; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class WriteMetadataInstructionSerializer extends AbstractInstructionSerializer { - - @Override - public void serialize(Instruction instruction, ByteBuf outBuffer) { - outBuffer.writeShort(getType()); - outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH); - outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA); - MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class); - outBuffer.writeBytes(metadata.getMetadata()); - outBuffer.writeBytes(metadata.getMetadataMask()); - } - - @Override - protected int getType() { - return InstructionConstants.WRITE_METADATA_TYPE; - } - -} +/* + * 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class WriteMetadataInstructionSerializer extends AbstractInstructionSerializer { + + @Override + public void serialize(Instruction instruction, ByteBuf outBuffer) { + outBuffer.writeShort(getType()); + outBuffer.writeShort(InstructionConstants.WRITE_METADATA_LENGTH); + outBuffer.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA); + MetadataInstruction metadata = instruction.getAugmentation(MetadataInstruction.class); + outBuffer.writeBytes(metadata.getMetadata()); + outBuffer.writeBytes(metadata.getMetadataMask()); + } + + @Override + protected int getType() { + return InstructionConstants.WRITE_METADATA_TYPE; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java index 1d1907af..4ce543e6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv4AddressSerializer.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for Ipv4 address based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmIpv4AddressSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - writeIpv4Address(entry, outBuffer); - writeMask(entry, outBuffer, getValueLength()); - } - - private static void writeIpv4Address(final MatchEntries entry, final ByteBuf out) { - Iterable addressGroups = ByteBufUtils.DOT_SPLITTER - .split(entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().getValue()); - for (String group : addressGroups) { - out.writeByte(Short.parseShort(group)); - } - } - -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for Ipv4 address based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmIpv4AddressSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + writeIpv4Address(entry, outBuffer); + writeMask(entry, outBuffer, getValueLength()); + } + + private static void writeIpv4Address(final MatchEntries entry, final ByteBuf out) { + Iterable addressGroups = ByteBufUtils.DOT_SPLITTER + .split(entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address().getValue()); + for (String group : addressGroups) { + out.writeByte(Short.parseShort(group)); + } + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java index c83f9d90..496505b8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmIpv6AddressSerializer.java @@ -1,83 +1,83 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -import com.google.common.collect.Lists; - -/** - * Parent for Ipv6 address based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - String textAddress = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue(); - List address; - if (textAddress.equals("::")) { - String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; - Arrays.fill(tmp, "0"); - address = Arrays.asList(tmp); - } else { - address = parseIpv6Address(Lists.newArrayList(ByteBufUtils.COLON_SPLITTER.split(textAddress))); - } - for (String group : address) { - outBuffer.writeShort(Integer.parseInt(group, 16)); - } - writeMask(entry, outBuffer, getValueLength()); - } - - private static List parseIpv6Address(final List addressGroups) { - int countEmpty = 0; - for (String group : addressGroups) { - if (group.equals("")) { - countEmpty++; - } - } - List ready = new ArrayList<>(EncodeConstants.GROUPS_IN_IPV6_ADDRESS); - switch (countEmpty) { - case 0: - ready = addressGroups; - break; - case 1: - int zerosToBePushed = EncodeConstants.GROUPS_IN_IPV6_ADDRESS - addressGroups.size() + 1; - for (String group : addressGroups) { - if (group.equals("")) { - for (int j = 0; j < zerosToBePushed; j++) { - ready.add("0"); - } - } else { - ready.add(group); - } - } - break; - case 2: - String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; - Arrays.fill(tmp, "0"); - tmp[EncodeConstants.GROUPS_IN_IPV6_ADDRESS - 1] = - addressGroups.get(addressGroups.size() - 1); - ready = Arrays.asList(tmp); - break; - default: - throw new IllegalStateException("Incorrect ipv6 address"); - } - return ready; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +import com.google.common.collect.Lists; + +/** + * Parent for Ipv6 address based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmIpv6AddressSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + String textAddress = entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address().getValue(); + List address; + if (textAddress.equals("::")) { + String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; + Arrays.fill(tmp, "0"); + address = Arrays.asList(tmp); + } else { + address = parseIpv6Address(Lists.newArrayList(ByteBufUtils.COLON_SPLITTER.split(textAddress))); + } + for (String group : address) { + outBuffer.writeShort(Integer.parseInt(group, 16)); + } + writeMask(entry, outBuffer, getValueLength()); + } + + private static List parseIpv6Address(final List addressGroups) { + int countEmpty = 0; + for (String group : addressGroups) { + if (group.equals("")) { + countEmpty++; + } + } + List ready = new ArrayList<>(EncodeConstants.GROUPS_IN_IPV6_ADDRESS); + switch (countEmpty) { + case 0: + ready = addressGroups; + break; + case 1: + int zerosToBePushed = EncodeConstants.GROUPS_IN_IPV6_ADDRESS - addressGroups.size() + 1; + for (String group : addressGroups) { + if (group.equals("")) { + for (int j = 0; j < zerosToBePushed; j++) { + ready.add("0"); + } + } else { + ready.add(group); + } + } + break; + case 2: + String[] tmp = new String[EncodeConstants.GROUPS_IN_IPV6_ADDRESS]; + Arrays.fill(tmp, "0"); + tmp[EncodeConstants.GROUPS_IN_IPV6_ADDRESS - 1] = + addressGroups.get(addressGroups.size() - 1); + ready = Arrays.asList(tmp); + break; + default: + throw new IllegalStateException("Incorrect ipv6 address"); + } + return ready; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java index 847a0409..51b62df9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMacAddressSerializer.java @@ -1,29 +1,29 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for MAC address based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmMacAddressSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue(); - outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(macAddress)); // 48 b + mask [OF 1.3.2 spec] - writeMask(entry, outBuffer, getValueLength()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for MAC address based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmMacAddressSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + String macAddress = entry.getAugmentation(MacAddressMatchEntry.class).getMacAddress().getValue(); + outBuffer.writeBytes(ByteBufUtils.macAddressToBytes(macAddress)); // 48 b + mask [OF 1.3.2 spec] + writeMask(entry, outBuffer, getValueLength()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java index 8b84a88c..5c669647 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMatchEntrySerializer.java @@ -1,73 +1,73 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for all match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmMatchEntrySerializer - implements OFSerializer, HeaderSerializer{ - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - serializeHeader(entry, outBuffer); - } - - @Override - public void serializeHeader(MatchEntries entry, ByteBuf outBuffer) { - outBuffer.writeShort(getOxmClassCode()); - writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(), - getValueLength()); - } - - protected static void writeMask(MatchEntries entry, ByteBuf out, int length) { - if (entry.isHasMask()) { - byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask(); - if (mask != null && mask.length != length) { - throw new IllegalArgumentException("incorrect length of mask: "+ - mask.length + ", expected: " + length); - } - out.writeBytes(mask); - } - } - - protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) { - int fieldAndMask = fieldValue << 1; - int length = lengthArg; - if (hasMask) { - fieldAndMask |= 1; - length *= 2; - } - out.writeByte(fieldAndMask); - out.writeByte(length); - } - - /** - * @return numeric representation of oxm_field - */ - protected abstract int getOxmFieldCode(); - - /** - * @return numeric representation of oxm_class - */ - protected abstract int getOxmClassCode(); - - /** - * @return match entry value length (without mask length) - */ - protected abstract int getValueLength(); - -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for all match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmMatchEntrySerializer + implements OFSerializer, HeaderSerializer{ + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + serializeHeader(entry, outBuffer); + } + + @Override + public void serializeHeader(MatchEntries entry, ByteBuf outBuffer) { + outBuffer.writeShort(getOxmClassCode()); + writeOxmFieldAndLength(outBuffer, getOxmFieldCode(), entry.isHasMask(), + getValueLength()); + } + + protected static void writeMask(MatchEntries entry, ByteBuf out, int length) { + if (entry.isHasMask()) { + byte[] mask = entry.getAugmentation(MaskMatchEntry.class).getMask(); + if (mask != null && mask.length != length) { + throw new IllegalArgumentException("incorrect length of mask: "+ + mask.length + ", expected: " + length); + } + out.writeBytes(mask); + } + } + + protected static void writeOxmFieldAndLength(ByteBuf out, int fieldValue, boolean hasMask, int lengthArg) { + int fieldAndMask = fieldValue << 1; + int length = lengthArg; + if (hasMask) { + fieldAndMask |= 1; + length *= 2; + } + out.writeByte(fieldAndMask); + out.writeByte(length); + } + + /** + * @return numeric representation of oxm_field + */ + protected abstract int getOxmFieldCode(); + + /** + * @return numeric representation of oxm_class + */ + protected abstract int getOxmClassCode(); + + /** + * @return match entry value length (without mask length) + */ + protected abstract int getValueLength(); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java index 0218beb8..b3fedcc6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmMetadataSerializer.java @@ -1,27 +1,27 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for metadata based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmMetadataSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); - writeMask(entry, outBuffer, getValueLength()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for metadata based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmMetadataSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeBytes(entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); + writeMask(entry, outBuffer, getValueLength()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java index ce972033..394d8c40 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortNumberSerializer.java @@ -1,26 +1,26 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for port(32-bit) based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmPortNumberSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for port(32-bit) based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmPortNumberSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeInt(entry.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java index b1c4671c..9dd6a55f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/AbstractOxmPortSerializer.java @@ -1,26 +1,26 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Parent for port(16-bit) based match entry serializers - * @author michal.polkorab - */ -public abstract class AbstractOxmPortSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Parent for port(16-bit) based match entry serializers + * @author michal.polkorab + */ +public abstract class AbstractOxmPortSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeShort(entry.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java index d59e16f3..7d963b8b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/NxmTcpFlagSerializer.java @@ -1,46 +1,46 @@ -/* - * Copyright (C) 2014 Red Hat, Inc. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 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.match; - -import io.netty.buffer.ByteBuf; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author brent.salisbury - * - */ -public class NxmTcpFlagSerializer extends AbstractOxmMatchEntrySerializer { - - private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagSerializer.class); - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(TcpFlagMatchEntry.class).getTcpFlag()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.NXM_1_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.NXM_NX_TCP_FLAG; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } +/* + * Copyright (C) 2014 Red Hat, Inc. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 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.match; + +import io.netty.buffer.ByteBuf; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcpFlagMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author brent.salisbury + * + */ +public class NxmTcpFlagSerializer extends AbstractOxmMatchEntrySerializer { + + private static final Logger logger = LoggerFactory.getLogger(NxmTcpFlagSerializer.class); + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeShort(entry.getAugmentation(TcpFlagMatchEntry.class).getTcpFlag()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.NXM_1_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.NXM_NX_TCP_FLAG; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java index 4520d9c7..1a37f284 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmArpOpSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(OpCodeMatchEntry.class).getOpCode()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_OP; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmArpOpSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeShort(entry.getAugmentation(OpCodeMatchEntry.class).getOpCode()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_OP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java index 8836d0ea..d4e8c3c0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmArpShaSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_SHA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmArpShaSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_SHA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java index bad5995f..505cf052 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmArpSpaSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_SPA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmArpSpaSerializer extends AbstractOxmIpv4AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_SPA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java index 637ca043..531b21c6 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmArpThaSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_THA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmArpThaSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_THA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java index 25e6417f..ec6ee771 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmArpTpaSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ARP_TPA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmArpTpaSerializer extends AbstractOxmIpv4AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ARP_TPA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java index 8ac6b9d6..c6c07bad 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmEthDstSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ETH_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmEthDstSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java index 74d75304..5a2df0a8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmEthSrcSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ETH_SRC; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmEthSrcSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_SRC; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java index 70bf999a..6bd7b575 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmEthTypeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeShort(entry.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().shortValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ETH_TYPE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmEthTypeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeShort(entry.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().shortValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ETH_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java index 82722fc5..664b68b0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4CodeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ICMPV4_CODE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4CodeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV4_CODE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java index a5f367fb..6ae6dfaa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4TypeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ICMPV4_TYPE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4TypeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV4_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java index 303b116e..7e38d36f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6CodeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ICMPV6_CODE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6CodeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV6_CODE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java index feafa962..adc06c22 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6TypeSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.ICMPV6_TYPE; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6TypeSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.ICMPV6_TYPE; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java index 2aba7e8c..7e6d7a86 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPhyPortSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmInPhyPortSerializer extends AbstractOxmPortNumberSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IN_PHY_PORT; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmInPhyPortSerializer extends AbstractOxmPortNumberSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IN_PHY_PORT; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java index 2c955077..7a3422e0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmInPortSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmInPortSerializer extends AbstractOxmPortNumberSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IN_PORT; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmInPortSerializer extends AbstractOxmPortNumberSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IN_PORT; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java index dc1ba5ec..d2cb0416 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpDscpSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(DscpMatchEntry.class).getDscp().getValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IP_DSCP; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpDscpSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(DscpMatchEntry.class).getDscp().getValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_DSCP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java index 65bea297..3270eeea 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpEcnSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpEcnSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(EcnMatchEntry.class).getEcn()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IP_ECN; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpEcnSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(EcnMatchEntry.class).getEcn()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_ECN; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java index 7193f504..d24c0f87 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpProtoSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IP_PROTO; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpProtoSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IP_PROTO; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java index df717c18..a7d23c94 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4DstSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV4_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4DstSerializer extends AbstractOxmIpv4AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV4_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java index 2c92d022..4b8ddbc7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4SrcSerializer extends AbstractOxmIpv4AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV4_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4SrcSerializer extends AbstractOxmIpv4AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV4_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java index 4d6299ef..cc892b8d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6DstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6DstSerializer extends AbstractOxmIpv6AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6DstSerializer extends AbstractOxmIpv6AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java index 4852a4fa..fa7ef802 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializer.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6ExtHdrSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - Ipv6ExthdrFlags pseudoField = entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField(); - int bitmap = ByteBufUtils.fillBitMask(0, - pseudoField.isNonext(), - pseudoField.isEsp(), - pseudoField.isAuth(), - pseudoField.isDest(), - pseudoField.isFrag(), - pseudoField.isRouter(), - pseudoField.isHop(), - pseudoField.isUnrep(), - pseudoField.isUnseq()); - outBuffer.writeShort(bitmap); - writeMask(entry, outBuffer, getValueLength()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_EXTHDR; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(final MatchEntries entry, final ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + Ipv6ExthdrFlags pseudoField = entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField(); + int bitmap = ByteBufUtils.fillBitMask(0, + pseudoField.isNonext(), + pseudoField.isEsp(), + pseudoField.isAuth(), + pseudoField.isDest(), + pseudoField.isFrag(), + pseudoField.isRouter(), + pseudoField.isHop(), + pseudoField.isUnrep(), + pseudoField.isUnseq()); + outBuffer.writeShort(bitmap); + writeMask(entry, outBuffer, getValueLength()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_EXTHDR; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java index 1e049929..bb6c0450 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6FlabelSerializer.java @@ -1,44 +1,44 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6FlabelSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); - writeMask(entry, outBuffer, getValueLength()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_FLABEL; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6FlabelSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeInt(entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); + writeMask(entry, outBuffer, getValueLength()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_FLABEL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java index fed6402f..f5952b8b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdSllSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_ND_SLL; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdSllSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_SLL; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java index 9037ee6f..a8f32b11 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTargetSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTargetSerializer extends AbstractOxmIpv6AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_ND_TARGET; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTargetSerializer extends AbstractOxmIpv6AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_TARGET; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java index c0864da9..e215a2f3 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTllSerializer extends AbstractOxmMacAddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_ND_TLL; - } - - @Override - protected int getValueLength() { - return EncodeConstants.MAC_ADDRESS_LENGTH; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTllSerializer extends AbstractOxmMacAddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_ND_TLL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.MAC_ADDRESS_LENGTH; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java index 7057fe30..9aeca979 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6SrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6SrcSerializer extends AbstractOxmIpv6AddressSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.IPV6_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6SrcSerializer extends AbstractOxmIpv6AddressSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.IPV6_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java index 6b0e27de..09099c54 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmMetadataSerializer extends AbstractOxmMetadataSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.METADATA; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_LONG_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataSerializer extends AbstractOxmMetadataSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.METADATA; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_LONG_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java index 12f2ec63..52e41c93 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsBosSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.MPLS_BOS; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeBoolean(entry.getAugmentation(BosMatchEntry.class).isBos().booleanValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_BOS; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java index c27936a5..85ec956b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsLabelSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeInt(entry.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.MPLS_LABEL; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_INT_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsLabelSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeInt(entry.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_LABEL; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_INT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java index 7a80f40e..ff2b6fe4 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializer.java @@ -1,43 +1,43 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsTcSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(TcMatchEntry.class).getTc()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.MPLS_TC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsTcSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(TcMatchEntry.class).getTc()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.MPLS_TC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java index ca740dd5..96c24a68 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializer.java @@ -1,44 +1,44 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmPbbIsidSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeMedium(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); - writeMask(entry, outBuffer, getValueLength()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.PBB_ISID; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_3_BYTES; - } -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeMedium(entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + writeMask(entry, outBuffer, getValueLength()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.PBB_ISID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_3_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java index 9327b566..4e3e2738 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpDstSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.SCTP_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpDstSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.SCTP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java index 1d50c383..96629ff1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpSrcSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.SCTP_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpSrcSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.SCTP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java index 22b5093a..c7b42281 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpDstSerializer extends AbstractOxmPortSerializer{ - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.TCP_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpDstSerializer extends AbstractOxmPortSerializer{ + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TCP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java index e7bcfd6e..0a8a01e7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpSrcSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.TCP_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpSrcSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TCP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java index 033f7f79..035bb7ff 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmTunnelIdSerializer extends AbstractOxmMetadataSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.TUNNEL_ID; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_LONG_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmTunnelIdSerializer extends AbstractOxmMetadataSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.TUNNEL_ID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_LONG_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java index 5f110390..bd4e705f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializer.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.serialization.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpDstSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.UDP_DST; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpDstSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.UDP_DST; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java index 2e091b44..5929909a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializer.java @@ -1,34 +1,34 @@ -/* - * 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.match; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpSrcSerializer extends AbstractOxmPortSerializer { - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.UDP_SRC; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } - -} +/* + * 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.match; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpSrcSerializer extends AbstractOxmPortSerializer { + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.UDP_SRC; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java index ba181fa0..ad7e9643 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializer.java @@ -1,44 +1,44 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanPcpSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - outBuffer.writeByte(entry.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().byteValue()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.VLAN_PCP; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; - } - -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanPcpSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + outBuffer.writeByte(entry.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().byteValue()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.VLAN_PCP; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_BYTE_IN_BYTES; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java index 775b91a8..975cc3d0 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializer.java @@ -1,52 +1,52 @@ -/* - * 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.match; - -import io.netty.buffer.ByteBuf; - -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanVidSerializer extends AbstractOxmMatchEntrySerializer { - - @Override - public void serialize(MatchEntries entry, ByteBuf outBuffer) { - super.serialize(entry, outBuffer); - VlanVidMatchEntry vlanVid = entry.getAugmentation(VlanVidMatchEntry.class); - int vlanVidValue = vlanVid.getVlanVid(); - if (vlanVid.isCfiBit()) { - short cfi = 1 << 12; // 13-th bit - vlanVidValue = vlanVidValue | cfi; - } - - outBuffer.writeShort(vlanVidValue); - writeMask(entry, outBuffer, getValueLength()); - } - - @Override - protected int getOxmClassCode() { - return OxmMatchConstants.OPENFLOW_BASIC_CLASS; - } - - @Override - protected int getOxmFieldCode() { - return OxmMatchConstants.VLAN_VID; - } - - @Override - protected int getValueLength() { - return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; - } - -} +/* + * 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.match; + +import io.netty.buffer.ByteBuf; + +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidSerializer extends AbstractOxmMatchEntrySerializer { + + @Override + public void serialize(MatchEntries entry, ByteBuf outBuffer) { + super.serialize(entry, outBuffer); + VlanVidMatchEntry vlanVid = entry.getAugmentation(VlanVidMatchEntry.class); + int vlanVidValue = vlanVid.getVlanVid(); + if (vlanVid.isCfiBit()) { + short cfi = 1 << 12; // 13-th bit + vlanVidValue = vlanVidValue | cfi; + } + + outBuffer.writeShort(vlanVidValue); + writeMask(entry, outBuffer, getValueLength()); + } + + @Override + protected int getOxmClassCode() { + return OxmMatchConstants.OPENFLOW_BASIC_CLASS; + } + + @Override + protected int getOxmFieldCode() { + return OxmMatchConstants.VLAN_VID; + } + + @Override + protected int getValueLength() { + return EncodeConstants.SIZE_OF_SHORT_IN_BYTES; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java index 490251cc..05812e8b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractCodeKeyMaker.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - - -/** - * @author michal.polkorab - * @param type the key maker is based on - */ -public abstract class AbstractCodeKeyMaker implements CodeKeyMaker { - - private short version; - - /** - * @param version openflow wire version - */ - public AbstractCodeKeyMaker(short version) { - this.version = version; - - } - - /** - * @return the version - */ - public short getVersion() { - return version; - } - -} +/* + * 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; + + +/** + * @author michal.polkorab + * @param type the key maker is based on + */ +public abstract class AbstractCodeKeyMaker implements CodeKeyMaker { + + private short version; + + /** + * @param version openflow wire version + */ + public AbstractCodeKeyMaker(short version) { + this.version = version; + + } + + /** + * @return the version + */ + public short getVersion() { + return version; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java index 3a804afc..f2e736fa 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/AbstractTypeKeyMaker.java @@ -1,35 +1,35 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - - -/** - * @author michal.polkorab - * @param type the key maker is based on - */ -public abstract class AbstractTypeKeyMaker implements TypeKeyMaker { - - private short version; - - /** - * @param version openflow wire version - */ - public AbstractTypeKeyMaker(short version) { - this.version = version; - - } - - /** - * @return the version - */ - public short getVersion() { - return version; - } - -} +/* + * 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; + + +/** + * @author michal.polkorab + * @param type the key maker is based on + */ +public abstract class AbstractTypeKeyMaker implements TypeKeyMaker { + + private short version; + + /** + * @param version openflow wire version + */ + public AbstractTypeKeyMaker(short version) { + this.version = version; + + } + + /** + * @return the version + */ + public short getVersion() { + return version; + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java index cb7b051e..d05b8cd8 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionConstants.java @@ -1,107 +1,107 @@ -/* - * 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; - -/** - * @author michal.polkorab - * - */ -public final class ActionConstants { - - /** Openflow v1.0 & v1.3 OFPAT_OUTPUT code */ - public static final byte OUTPUT_CODE = 0; - /** Openflow v1.0 OFPAT_SET_VLAN_VID code */ - public static final byte SET_VLAN_VID_CODE = 1; - /** Openflow v1.0 OFPAT_SET_VLAN_PCP code */ - public static final byte SET_VLAN_PCP_CODE = 2; - /** Openflow v1.0 OFPAT_STRIP_VLAN code */ - public static final byte STRIP_VLAN_CODE = 3; - /** Openflow v1.0 OFPAT_SET_DL_SRC code */ - public static final byte SET_DL_SRC_CODE = 4; - /** Openflow v1.0 OFPAT_SET_DL_DST code */ - public static final byte SET_DL_DST_CODE = 5; - /** Openflow v1.0 OFPAT_SET_NW_SRC code */ - public static final byte SET_NW_SRC_CODE = 6; - /** Openflow v1.0 OFPAT_SET_NW_DST code */ - public static final byte SET_NW_DST_CODE = 7; - /** Openflow v1.0 OFPAT_SET_NW_TOS code */ - public static final byte SET_NW_TOS_CODE = 8; - /** Openflow v1.0 OFPAT_SET_TP_SRC code */ - public static final byte SET_TP_SRC_CODE = 9; - /** Openflow v1.0 OFPAT_SET_TP_DST code */ - public static final byte SET_TP_DST_CODE = 10; - /** Openflow v1.0 OFPAT_ENQUEUE code */ - public static final byte ENQUEUE_CODE = 11; - /** Openflow v1.3 OFPAT_COPY_TTL_OUT code */ - public static final byte COPY_TTL_OUT_CODE = 11; - /** Openflow v1.3 OFPAT_COPY_TTL_IN code */ - public static final byte COPY_TTL_IN_CODE = 12; - /** Openflow v1.3 OFPAT_SET_MPLS_TTL code */ - public static final byte SET_MPLS_TTL_CODE = 15; - /** Openflow v1.3 OFPAT_DEC_MPLS_TTL code */ - public static final byte DEC_MPLS_TTL_CODE = 16; - /** Openflow v1.3 OFPAT_PUSH_VLAN code */ - public static final byte PUSH_VLAN_CODE = 17; - /** Openflow v1.3 OFPAT_POP_VLAN code */ - public static final byte POP_VLAN_CODE = 18; - /** Openflow v1.3 OFPAT_PUSH_MPLS code */ - public static final byte PUSH_MPLS_CODE = 19; - /** Openflow v1.3 OFPAT_POP_MPLS code */ - public static final byte POP_MPLS_CODE = 20; - /** Openflow v1.3 OFPAT_SET_QUEUE code */ - public static final byte SET_QUEUE_CODE = 21; - /** Openflow v1.3 OFPAT_GROUP code */ - public static final byte GROUP_CODE = 22; - /** Openflow v1.3 OFPAT_SET_NW_TTL code */ - public static final byte SET_NW_TTL_CODE = 23; - /** Openflow v1.3 OFPAT_DEC_NW_TTL code */ - public static final byte DEC_NW_TTL_CODE = 24; - /** Openflow v1.3 OFPAT_SET_FIELD code */ - public static final int SET_FIELD_CODE = 25; - /** Openflow v1.3 OFPAT_PUSH_PBB code */ - public static final byte PUSH_PBB_CODE = 26; - /** Openflow v1.3 OFPAT_POP_PBB code */ - public static final byte POP_PBB_CODE = 27; - - /** Padding in OFPAT_OUTPUT (OF v1.3) */ - public static final byte OUTPUT_PADDING = 6; - /** Padding in OFPAT_SET_VLAN_VID (OF v1.3) */ - public static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2; - /** Padding in OFPAT_SET_VLAN_PCP (OF v1.3) */ - public static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3; - /** Padding in OFPAT_SET_NW_TOS (OF v1.3) */ - public static final byte PADDING_IN_SET_NW_TOS_ACTION = 3; - /** Padding in OFPAT_ENQUEUE (OF v1.3) */ - public static final int PADDING_IN_ENQUEUE_ACTION = 6; - /** Padding in OFPAT_SET_MPLS_TTL (OF v1.3) */ - public static final byte SET_MPLS_TTL_PADDING = 3; - /** Padding in OFPAT_SET_NW_TTL (OF v1.3) */ - public static final byte SET_NW_TTL_PADDING = 3; - /** Padding in OFPAT_SET_DL_SRC and OFPAT_SET_DL_DST (OF v1.3) */ - public static final byte PADDING_IN_DL_ADDRESS_ACTION = 6; - /** Padding in OFPAT_SET_TP_SRC and OFPAT_SET_TP_DST (OF v1.3) */ - public static final byte PADDING_IN_TP_PORT_ACTION = 2; - /** Padding in action header (OF v1.3) */ - public static final byte PADDING_IN_ACTION_HEADER = 4; - /** Padding in OFPAT_PUSH_VLAN, OFPAT_PUSH_MPLS, OFPAT_POP_MPLS - * and OFPAT_PUSH_PBB (OF v1.3) */ - public static final byte ETHERTYPE_ACTION_PADDING = 2; - - /** Most common action length */ - public static final byte GENERAL_ACTION_LENGTH = 8; - /** Action larger than GENERAL_ACTION_LENGTH - currently - * only 16 bytes long actions for both OF v1.0 & v1.3*/ - public static final byte LARGER_ACTION_LENGTH = 16; - /** Action header size */ - public static final byte ACTION_IDS_LENGTH = 4; - - private ActionConstants() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } -} +/* + * 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; + +/** + * @author michal.polkorab + * + */ +public final class ActionConstants { + + /** Openflow v1.0 & v1.3 OFPAT_OUTPUT code */ + public static final byte OUTPUT_CODE = 0; + /** Openflow v1.0 OFPAT_SET_VLAN_VID code */ + public static final byte SET_VLAN_VID_CODE = 1; + /** Openflow v1.0 OFPAT_SET_VLAN_PCP code */ + public static final byte SET_VLAN_PCP_CODE = 2; + /** Openflow v1.0 OFPAT_STRIP_VLAN code */ + public static final byte STRIP_VLAN_CODE = 3; + /** Openflow v1.0 OFPAT_SET_DL_SRC code */ + public static final byte SET_DL_SRC_CODE = 4; + /** Openflow v1.0 OFPAT_SET_DL_DST code */ + public static final byte SET_DL_DST_CODE = 5; + /** Openflow v1.0 OFPAT_SET_NW_SRC code */ + public static final byte SET_NW_SRC_CODE = 6; + /** Openflow v1.0 OFPAT_SET_NW_DST code */ + public static final byte SET_NW_DST_CODE = 7; + /** Openflow v1.0 OFPAT_SET_NW_TOS code */ + public static final byte SET_NW_TOS_CODE = 8; + /** Openflow v1.0 OFPAT_SET_TP_SRC code */ + public static final byte SET_TP_SRC_CODE = 9; + /** Openflow v1.0 OFPAT_SET_TP_DST code */ + public static final byte SET_TP_DST_CODE = 10; + /** Openflow v1.0 OFPAT_ENQUEUE code */ + public static final byte ENQUEUE_CODE = 11; + /** Openflow v1.3 OFPAT_COPY_TTL_OUT code */ + public static final byte COPY_TTL_OUT_CODE = 11; + /** Openflow v1.3 OFPAT_COPY_TTL_IN code */ + public static final byte COPY_TTL_IN_CODE = 12; + /** Openflow v1.3 OFPAT_SET_MPLS_TTL code */ + public static final byte SET_MPLS_TTL_CODE = 15; + /** Openflow v1.3 OFPAT_DEC_MPLS_TTL code */ + public static final byte DEC_MPLS_TTL_CODE = 16; + /** Openflow v1.3 OFPAT_PUSH_VLAN code */ + public static final byte PUSH_VLAN_CODE = 17; + /** Openflow v1.3 OFPAT_POP_VLAN code */ + public static final byte POP_VLAN_CODE = 18; + /** Openflow v1.3 OFPAT_PUSH_MPLS code */ + public static final byte PUSH_MPLS_CODE = 19; + /** Openflow v1.3 OFPAT_POP_MPLS code */ + public static final byte POP_MPLS_CODE = 20; + /** Openflow v1.3 OFPAT_SET_QUEUE code */ + public static final byte SET_QUEUE_CODE = 21; + /** Openflow v1.3 OFPAT_GROUP code */ + public static final byte GROUP_CODE = 22; + /** Openflow v1.3 OFPAT_SET_NW_TTL code */ + public static final byte SET_NW_TTL_CODE = 23; + /** Openflow v1.3 OFPAT_DEC_NW_TTL code */ + public static final byte DEC_NW_TTL_CODE = 24; + /** Openflow v1.3 OFPAT_SET_FIELD code */ + public static final int SET_FIELD_CODE = 25; + /** Openflow v1.3 OFPAT_PUSH_PBB code */ + public static final byte PUSH_PBB_CODE = 26; + /** Openflow v1.3 OFPAT_POP_PBB code */ + public static final byte POP_PBB_CODE = 27; + + /** Padding in OFPAT_OUTPUT (OF v1.3) */ + public static final byte OUTPUT_PADDING = 6; + /** Padding in OFPAT_SET_VLAN_VID (OF v1.3) */ + public static final byte PADDING_IN_SET_VLAN_VID_ACTION = 2; + /** Padding in OFPAT_SET_VLAN_PCP (OF v1.3) */ + public static final byte PADDING_IN_SET_VLAN_PCP_ACTION = 3; + /** Padding in OFPAT_SET_NW_TOS (OF v1.3) */ + public static final byte PADDING_IN_SET_NW_TOS_ACTION = 3; + /** Padding in OFPAT_ENQUEUE (OF v1.3) */ + public static final int PADDING_IN_ENQUEUE_ACTION = 6; + /** Padding in OFPAT_SET_MPLS_TTL (OF v1.3) */ + public static final byte SET_MPLS_TTL_PADDING = 3; + /** Padding in OFPAT_SET_NW_TTL (OF v1.3) */ + public static final byte SET_NW_TTL_PADDING = 3; + /** Padding in OFPAT_SET_DL_SRC and OFPAT_SET_DL_DST (OF v1.3) */ + public static final byte PADDING_IN_DL_ADDRESS_ACTION = 6; + /** Padding in OFPAT_SET_TP_SRC and OFPAT_SET_TP_DST (OF v1.3) */ + public static final byte PADDING_IN_TP_PORT_ACTION = 2; + /** Padding in action header (OF v1.3) */ + public static final byte PADDING_IN_ACTION_HEADER = 4; + /** Padding in OFPAT_PUSH_VLAN, OFPAT_PUSH_MPLS, OFPAT_POP_MPLS + * and OFPAT_PUSH_PBB (OF v1.3) */ + public static final byte ETHERTYPE_ACTION_PADDING = 2; + + /** Most common action length */ + public static final byte GENERAL_ACTION_LENGTH = 8; + /** Action larger than GENERAL_ACTION_LENGTH - currently + * only 16 bytes long actions for both OF v1.0 & v1.3*/ + public static final byte LARGER_ACTION_LENGTH = 16; + /** Action header size */ + public static final byte ACTION_IDS_LENGTH = 4; + + private ActionConstants() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java index a3fb7113..2f48763a 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionDeserializerRegistryHelper.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2014 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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; - -/** - * @author michal.polkorab - * - */ -public class ActionDeserializerRegistryHelper { - - private short version; - private DeserializerRegistry registry; - - /** - * @param version wire protocol version - * @param deserializerRegistry registry to be filled with message deserializers - */ - public ActionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { - this.version = version; - this.registry = deserializerRegistry; - } - - /** - * @param code code / value to distinguish between deserializers - * @param deserializer deserializer instance - * @param deserializedObjectClass class of object that will be deserialized - * by given deserializer - */ - public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { - registry.registerDeserializer(new ActionDeserializerKey(version, code, - null), deserializer); - } -} +/* + * Copyright (c) 2014 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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; + +/** + * @author michal.polkorab + * + */ +public class ActionDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + + /** + * @param version wire protocol version + * @param deserializerRegistry registry to be filled with message deserializers + */ + public ActionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { + this.version = version; + this.registry = deserializerRegistry; + } + + /** + * @param code code / value to distinguish between deserializers + * @param deserializer deserializer instance + * @param deserializedObjectClass class of object that will be deserialized + * by given deserializer + */ + public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new ActionDeserializerKey(version, code, + null), deserializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java index d941f547..912ec8b7 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ActionSerializerRegistryHelper.java @@ -1,43 +1,43 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; - -/** - * @author michal.polkorab - */ -public class ActionSerializerRegistryHelper { - - private short version; - private SerializerRegistry serializerRegistry; - - /** - * @param version Openflow wire version - * @param objectType - * @param serializerRegistry - */ - public ActionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { - this.version = version; - this.serializerRegistry = serializerRegistry; - } - - /** - * Registers given serializer - * @param actionType - * @param serializer - */ - public void registerSerializer(Class actionType, - OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, - actionType, null), serializer); - } +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionBase; + +/** + * @author michal.polkorab + */ +public class ActionSerializerRegistryHelper { + + private short version; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param objectType + * @param serializerRegistry + */ + public ActionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { + this.version = version; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param actionType + * @param serializer + */ + public void registerSerializer(Class actionType, + OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new ActionSerializerKey<>(version, + actionType, null), serializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java index 52c2a4de..f5be1f6c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMaker.java @@ -1,26 +1,26 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; - -import io.netty.buffer.ByteBuf; - -/** - * @author michal.polkorab - */ -public interface CodeKeyMaker { - - /** - * @param input buffer that will be the needed data gathered from - * @return key for deserializer lookup - */ - abstract MessageCodeKey make(ByteBuf input); - -} +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; + +import io.netty.buffer.ByteBuf; + +/** + * @author michal.polkorab + */ +public interface CodeKeyMaker { + + /** + * @param input buffer that will be the needed data gathered from + * @return key for deserializer lookup + */ + abstract MessageCodeKey make(ByteBuf input); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java index 9b21226b..7713e355 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactory.java @@ -1,90 +1,90 @@ -/* - * 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.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public abstract class CodeKeyMakerFactory { - - /** - * @param version - * @return - */ - public static CodeKeyMaker createMatchEntriesKeyMaker(short version) { - return new AbstractCodeKeyMaker(version) { - @Override - public MessageCodeKey make(ByteBuf input) { - int oxmClass = input.getUnsignedShort(input.readerIndex()); - int oxmField = input.getUnsignedByte(input.readerIndex() - + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(getVersion(), - oxmClass, oxmField); - if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { - long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES - + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); - key.setExperimenterId(expId); - return key; - } - key.setExperimenterId(null); - return key; - } - }; - } - - /** - * @param version - * @return - */ - public static CodeKeyMaker createActionsKeyMaker(short version) { - return new AbstractCodeKeyMaker(version) { - @Override - public MessageCodeKey make(ByteBuf input) { - int type = input.getUnsignedShort(input.readerIndex()); - if (type == EncodeConstants.EXPERIMENTER_VALUE) { - Long expId = input.getUnsignedInt(input.readerIndex() - + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return new ExperimenterActionDeserializerKey(getVersion(), expId); - } - ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null); - return actionDeserializerKey; - } - }; - } - - /** - * @param version - * @return - */ - public static CodeKeyMaker createInstructionsKeyMaker(short version) { - return new AbstractCodeKeyMaker(version) { - @Override - public MessageCodeKey make(ByteBuf input) { - int type = input.getUnsignedShort(input.readerIndex()); - if (type == EncodeConstants.EXPERIMENTER_VALUE) { - Long expId = input.getUnsignedInt(input.readerIndex() - + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - return new ExperimenterInstructionDeserializerKey(getVersion(), expId); - } - return new InstructionDeserializerKey(getVersion(), type, null); - } - }; - } -} +/* + * 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.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public abstract class CodeKeyMakerFactory { + + /** + * @param version + * @return + */ + public static CodeKeyMaker createMatchEntriesKeyMaker(short version) { + return new AbstractCodeKeyMaker(version) { + @Override + public MessageCodeKey make(ByteBuf input) { + int oxmClass = input.getUnsignedShort(input.readerIndex()); + int oxmField = input.getUnsignedByte(input.readerIndex() + + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1; + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(getVersion(), + oxmClass, oxmField); + if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) { + long expId = input.getUnsignedInt(input.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES + + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES); + key.setExperimenterId(expId); + return key; + } + key.setExperimenterId(null); + return key; + } + }; + } + + /** + * @param version + * @return + */ + public static CodeKeyMaker createActionsKeyMaker(short version) { + return new AbstractCodeKeyMaker(version) { + @Override + public MessageCodeKey make(ByteBuf input) { + int type = input.getUnsignedShort(input.readerIndex()); + if (type == EncodeConstants.EXPERIMENTER_VALUE) { + Long expId = input.getUnsignedInt(input.readerIndex() + + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return new ExperimenterActionDeserializerKey(getVersion(), expId); + } + ActionDeserializerKey actionDeserializerKey = new ActionDeserializerKey(getVersion(), type, null); + return actionDeserializerKey; + } + }; + } + + /** + * @param version + * @return + */ + public static CodeKeyMaker createInstructionsKeyMaker(short version) { + return new AbstractCodeKeyMaker(version) { + @Override + public MessageCodeKey make(ByteBuf input) { + int type = input.getUnsignedShort(input.readerIndex()); + if (type == EncodeConstants.EXPERIMENTER_VALUE) { + Long expId = input.getUnsignedInt(input.readerIndex() + + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); + return new ExperimenterInstructionDeserializerKey(getVersion(), expId); + } + return new InstructionDeserializerKey(getVersion(), type, null); + } + }; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java index 0ce8d54e..35cfef79 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/CommonMessageRegistryHelper.java @@ -1,39 +1,39 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; - -/** - * @author michal.polkorab - * - */ -public class CommonMessageRegistryHelper { - - private short version; - private SerializerRegistry serializerRegistry; - - /** - * @param version - * @param serializerRegistry - */ - public CommonMessageRegistryHelper(short version, SerializerRegistry serializerRegistry) { - this.version = version; - this.serializerRegistry = serializerRegistry; - } - - /** - * @param msgType - * @param serializer - */ - public void registerSerializer(Class msgType, OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(new MessageTypeKey<>(version, msgType), serializer); - } -} +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; + +/** + * @author michal.polkorab + * + */ +public class CommonMessageRegistryHelper { + + private short version; + private SerializerRegistry serializerRegistry; + + /** + * @param version + * @param serializerRegistry + */ + public CommonMessageRegistryHelper(short version, SerializerRegistry serializerRegistry) { + this.version = version; + this.serializerRegistry = serializerRegistry; + } + + /** + * @param msgType + * @param serializer + */ + public void registerSerializer(Class msgType, OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new MessageTypeKey<>(version, msgType), serializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java index 2476c4e9..7d9479a1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionConstants.java @@ -1,48 +1,48 @@ -/* - * 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; - -/** - * @author michal.polkorab - * - */ -public final class InstructionConstants { - - /** Openflow v1.3 OFPIT_GOTO_TABLE code */ - public static final byte GOTO_TABLE_TYPE = 1; - /** Openflow v1.3 OFPIT_WRITE_METADATA code */ - public static final byte WRITE_METADATA_TYPE = 2; - /** Openflow v1.3 OFPIT_WRITE_ACTIONS code */ - public static final byte WRITE_ACTIONS_TYPE = 3; - /** Openflow v1.3 OFPIT_APPLY_ACTIONS code */ - public static final byte APPLY_ACTIONS_TYPE = 4; - /** Openflow v1.3 OFPIT_CLEAR_ACTIONS code */ - public static final byte CLEAR_ACTIONS_TYPE = 5; - /** Openflow v1.3 OFPIT_METER code */ - public static final byte METER_TYPE = 6; - - /** PADDING in OFPIT_GOTO_TABLE */ - public static final byte PADDING_IN_GOTO_TABLE = 3; - /** PADDING in OFPIT_WRITE_METADATA */ - public static final byte PADDING_IN_WRITE_METADATA = 4; - /** PADDING in OFPIT_WRITE_ACTIONS, OFPIT_APPLY_ACTIONS - * and OFPIT_CLEAR_ACTIONS */ - public static final byte PADDING_IN_ACTIONS_INSTRUCTION = 4; - - /** Openflow v1.3 header length (padded) */ - public static final byte STANDARD_INSTRUCTION_LENGTH = 8; - /** Openflow v1.3 OFPIT_WRITE_METADATA length */ - public static final byte WRITE_METADATA_LENGTH = 24; - /** Openflow v1.3 header length (only type and length fields) */ - public static final byte INSTRUCTION_IDS_LENGTH = 4; - - private InstructionConstants() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } -} +/* + * 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; + +/** + * @author michal.polkorab + * + */ +public final class InstructionConstants { + + /** Openflow v1.3 OFPIT_GOTO_TABLE code */ + public static final byte GOTO_TABLE_TYPE = 1; + /** Openflow v1.3 OFPIT_WRITE_METADATA code */ + public static final byte WRITE_METADATA_TYPE = 2; + /** Openflow v1.3 OFPIT_WRITE_ACTIONS code */ + public static final byte WRITE_ACTIONS_TYPE = 3; + /** Openflow v1.3 OFPIT_APPLY_ACTIONS code */ + public static final byte APPLY_ACTIONS_TYPE = 4; + /** Openflow v1.3 OFPIT_CLEAR_ACTIONS code */ + public static final byte CLEAR_ACTIONS_TYPE = 5; + /** Openflow v1.3 OFPIT_METER code */ + public static final byte METER_TYPE = 6; + + /** PADDING in OFPIT_GOTO_TABLE */ + public static final byte PADDING_IN_GOTO_TABLE = 3; + /** PADDING in OFPIT_WRITE_METADATA */ + public static final byte PADDING_IN_WRITE_METADATA = 4; + /** PADDING in OFPIT_WRITE_ACTIONS, OFPIT_APPLY_ACTIONS + * and OFPIT_CLEAR_ACTIONS */ + public static final byte PADDING_IN_ACTIONS_INSTRUCTION = 4; + + /** Openflow v1.3 header length (padded) */ + public static final byte STANDARD_INSTRUCTION_LENGTH = 8; + /** Openflow v1.3 OFPIT_WRITE_METADATA length */ + public static final byte WRITE_METADATA_LENGTH = 24; + /** Openflow v1.3 header length (only type and length fields) */ + public static final byte INSTRUCTION_IDS_LENGTH = 4; + + private InstructionConstants() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java index 2b4ea9da..44a6a884 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionDeserializerRegistryHelper.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2014 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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; - -/** - * @author michal.polkorab - * - */ -public class InstructionDeserializerRegistryHelper { - - private short version; - private DeserializerRegistry registry; - - /** - * @param version wire protocol version - * @param deserializerRegistry registry to be filled with message deserializers - */ - public InstructionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { - this.version = version; - this.registry = deserializerRegistry; - } - - /** - * @param code code / value to distinguish between deserializers - * @param deserializer deserializer instance - * @param deserializedObjectClass class of object that will be deserialized - * by given deserializer - */ - public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { - registry.registerDeserializer(new InstructionDeserializerKey(version, code, - null), deserializer); - } -} +/* + * Copyright (c) 2014 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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; + +/** + * @author michal.polkorab + * + */ +public class InstructionDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + + /** + * @param version wire protocol version + * @param deserializerRegistry registry to be filled with message deserializers + */ + public InstructionDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { + this.version = version; + this.registry = deserializerRegistry; + } + + /** + * @param code code / value to distinguish between deserializers + * @param deserializer deserializer instance + * @param deserializedObjectClass class of object that will be deserialized + * by given deserializer + */ + public void registerDeserializer(int code, OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new InstructionDeserializerKey(version, code, + null), deserializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java index 3ee13cb8..f89fd0a1 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionSerializerRegistryHelper.java @@ -1,42 +1,42 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; - -/** - * @author michal.polkorab - */ -public class InstructionSerializerRegistryHelper { - - private short version; - private SerializerRegistry serializerRegistry; - - /** - * @param version Openflow wire version - * @param serializerRegistry - */ - public InstructionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { - this.version = version; - this.serializerRegistry = serializerRegistry; - } - - /** - * Registers given serializer - * @param instructionType - * @param serializer - */ - public void registerSerializer(Class instructionType, - OFGeneralSerializer serializer) { - serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version, - instructionType, null), serializer); - } +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.InstructionBase; + +/** + * @author michal.polkorab + */ +public class InstructionSerializerRegistryHelper { + + private short version; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param serializerRegistry + */ + public InstructionSerializerRegistryHelper(short version, SerializerRegistry serializerRegistry) { + this.version = version; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param instructionType + * @param serializer + */ + public void registerSerializer(Class instructionType, + OFGeneralSerializer serializer) { + serializerRegistry.registerSerializer(new InstructionSerializerKey<>(version, + instructionType, null), serializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java index 6e32f86f..93d3c3e2 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializer.java @@ -1,78 +1,78 @@ -/* - * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * - */ -public final class ListDeserializer { - - private ListDeserializer() { - throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); - } - - /** - * Deserializes items into list - * @param version openflow wire version - * @param length length of list in ByteBuf (bytes) - * @param input input buffer - * @param keyMaker creates keys for deserializer lookup - * @param registry stores deserializers - * @return list of items - */ - public static List deserializeList(short version, int length, - ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) { - List items = null; - if (input.readableBytes() > 0) { - items = new ArrayList<>(); - int startIndex = input.readerIndex(); - while ((input.readerIndex() - startIndex) < length){ - OFDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); - E item = deserializer.deserialize(input); - items.add(item); - } - } - return items; - } - - /** - * Deserializes headers of items into list - * @param version openflow wire version - * @param length length of list in ByteBuf (bytes) - * @param input input buffer - * @param keyMaker creates keys for deserializer lookup - * @param registry stores deserializers - * @return list of items - */ - public static List deserializeHeaders(short version, int length, - ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) { - List items = null; - if (input.readableBytes() > 0) { - items = new ArrayList<>(); - int startIndex = input.readerIndex(); - while ((input.readerIndex() - startIndex) < length){ - HeaderDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); - E item = deserializer.deserializeHeader(input); - items.add(item); - } - } - return items; - } -} +/* + * 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.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * + */ +public final class ListDeserializer { + + private ListDeserializer() { + throw new UnsupportedOperationException("Utility class shouldn't be instantiated"); + } + + /** + * Deserializes items into list + * @param version openflow wire version + * @param length length of list in ByteBuf (bytes) + * @param input input buffer + * @param keyMaker creates keys for deserializer lookup + * @param registry stores deserializers + * @return list of items + */ + public static List deserializeList(short version, int length, + ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) { + List items = null; + if (input.readableBytes() > 0) { + items = new ArrayList<>(); + int startIndex = input.readerIndex(); + while ((input.readerIndex() - startIndex) < length){ + OFDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); + E item = deserializer.deserialize(input); + items.add(item); + } + } + return items; + } + + /** + * Deserializes headers of items into list + * @param version openflow wire version + * @param length length of list in ByteBuf (bytes) + * @param input input buffer + * @param keyMaker creates keys for deserializer lookup + * @param registry stores deserializers + * @return list of items + */ + public static List deserializeHeaders(short version, int length, + ByteBuf input, CodeKeyMaker keyMaker, DeserializerRegistry registry) { + List items = null; + if (input.readableBytes() > 0) { + items = new ArrayList<>(); + int startIndex = input.readerIndex(); + while ((input.readerIndex() - startIndex) < length){ + HeaderDeserializer deserializer = registry.getDeserializer(keyMaker.make(input)); + E item = deserializer.deserializeHeader(input); + items.add(item); + } + } + return items; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java index 58a96352..f085377f 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializer.java @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.openflowjava.protocol.impl.util; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * Serializes list items and their headers - * @author michal.polkorab - * @param - */ -public abstract class ListSerializer { - - /** - * Serializes item list - * @param list list of items to be serialized - * @param keyMaker creates key for registry lookup - * @param registry stores serializers - * @param outBuffer output buffer - */ - public static void serializeList(List list, - TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { - if (list != null) { - for (E item : list) { - OFSerializer serializer = registry.getSerializer(keyMaker.make(item)); - serializer.serialize(item, outBuffer); - } - } - } - - /** - * Serializes headers of items in list - * @param list list of items to be serialized - * @param keyMaker creates key for registry lookup - * @param registry stores serializers - * @param outBuffer output buffer - */ - public static void serializeHeaderList(List list, - TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { - if (list != null) { - for (E item : list) { - HeaderSerializer serializer = registry.getSerializer(keyMaker.make(item)); - serializer.serializeHeader(item, outBuffer); - } - } - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * Serializes list items and their headers + * @author michal.polkorab + * @param + */ +public abstract class ListSerializer { + + /** + * Serializes item list + * @param list list of items to be serialized + * @param keyMaker creates key for registry lookup + * @param registry stores serializers + * @param outBuffer output buffer + */ + public static void serializeList(List list, + TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { + if (list != null) { + for (E item : list) { + OFSerializer serializer = registry.getSerializer(keyMaker.make(item)); + serializer.serialize(item, outBuffer); + } + } + } + + /** + * Serializes headers of items in list + * @param list list of items to be serialized + * @param keyMaker creates key for registry lookup + * @param registry stores serializers + * @param outBuffer output buffer + */ + public static void serializeHeaderList(List list, + TypeKeyMaker keyMaker, SerializerRegistry registry, ByteBuf outBuffer) { + if (list != null) { + for (E item : list) { + HeaderSerializer serializer = registry.getSerializer(keyMaker.make(item)); + serializer.serializeHeader(item, outBuffer); + } + } + } + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java index e9e1c10e..e666f11e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntryDeserializerRegistryHelper.java @@ -1,47 +1,47 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; - -/** - * @author michal.polkorab - * - */ -public class MatchEntryDeserializerRegistryHelper { - - private short version; - private DeserializerRegistry registry; - private int oxmClass; - - /** - * @param version wire protocol version - * @param oxmClass oxm_class that will be used for match entry deserializer - * registration - * @param deserializerRegistry registry to be filled with message deserializers - */ - public MatchEntryDeserializerRegistryHelper(short version, int oxmClass, - DeserializerRegistry deserializerRegistry) { - this.version = version; - this.oxmClass = oxmClass; - this.registry = deserializerRegistry; - } - - /** - * Registers match entry deserializer under provided oxmfield () - * @param oxmField oxm_field value/code - * @param deserializer deserializer instance - */ - public void register(int oxmField, OFGeneralDeserializer deserializer) { - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, oxmClass, oxmField); - key.setExperimenterId(null); - registry.registerDeserializer(key, deserializer); - } +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; + +/** + * @author michal.polkorab + * + */ +public class MatchEntryDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + private int oxmClass; + + /** + * @param version wire protocol version + * @param oxmClass oxm_class that will be used for match entry deserializer + * registration + * @param deserializerRegistry registry to be filled with message deserializers + */ + public MatchEntryDeserializerRegistryHelper(short version, int oxmClass, + DeserializerRegistry deserializerRegistry) { + this.version = version; + this.oxmClass = oxmClass; + this.registry = deserializerRegistry; + } + + /** + * Registers match entry deserializer under provided oxmfield () + * @param oxmField oxm_field value/code + * @param deserializer deserializer instance + */ + public void register(int oxmField, OFGeneralDeserializer deserializer) { + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(version, oxmClass, oxmField); + key.setExperimenterId(null); + registry.registerDeserializer(key, deserializer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java index 0bbd6ab9..e3f49e30 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/MatchEntrySerializerRegistryHelper.java @@ -1,49 +1,49 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; - -/** - * @author michal.polkorab - * @param OXM class - */ -public class MatchEntrySerializerRegistryHelper { - - private short version; - private Class generalClass; - private SerializerRegistry serializerRegistry; - - /** - * @param version Openflow wire version - * @param generalClass - * @param serializerRegistry - */ - public MatchEntrySerializerRegistryHelper(short version, Class generalClass, - SerializerRegistry serializerRegistry) { - this.version = version; - this.generalClass = generalClass; - this.serializerRegistry = serializerRegistry; - } - - /** - * Registers given serializer - * @param specificClass - * @param serializer - */ - public void registerSerializer( - Class specificClass, OFGeneralSerializer serializer) { - MatchEntrySerializerKey key = new MatchEntrySerializerKey<>(version, generalClass, specificClass); - key.setExperimenterId(null); - serializerRegistry.registerSerializer(key, serializer); - } -} +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmClassBase; + +/** + * @author michal.polkorab + * @param OXM class + */ +public class MatchEntrySerializerRegistryHelper { + + private short version; + private Class generalClass; + private SerializerRegistry serializerRegistry; + + /** + * @param version Openflow wire version + * @param generalClass + * @param serializerRegistry + */ + public MatchEntrySerializerRegistryHelper(short version, Class generalClass, + SerializerRegistry serializerRegistry) { + this.version = version; + this.generalClass = generalClass; + this.serializerRegistry = serializerRegistry; + } + + /** + * Registers given serializer + * @param specificClass + * @param serializer + */ + public void registerSerializer( + Class specificClass, OFGeneralSerializer serializer) { + MatchEntrySerializerKey key = new MatchEntrySerializerKey<>(version, generalClass, specificClass); + key.setExperimenterId(null); + serializerRegistry.registerSerializer(key, serializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java index 78f27eac..9a608b2d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtils.java @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2014 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 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; - -/** - * Used for common structures translation / conversion - * - * @author michal.polkorab - */ -public abstract class OpenflowUtils { - - /** - * Creates PortState (OF v1.0) from input - * @param input value read from buffer - * @return port state - */ - public static PortStateV10 createPortState(long input){ - final Boolean psLinkDown = ((input) & (1<<0)) != 0; - final Boolean psBlocked = ((input) & (1<<1)) != 0; - final Boolean psLive = ((input) & (1<<2)) != 0; - final Boolean psStpListen = ((input) & (1<<8)) == 0; - final Boolean psStpLearn = ((input) & (1<<8)) != 0; - final Boolean psStpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 - final Boolean psStpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 - final Boolean psStpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 - return new PortStateV10(psBlocked, psLinkDown, psLive, psStpBlock, psStpForward, psStpLearn, psStpListen, psStpMask); - } - - /** - * Creates PortConfig (OF v1.0) from input - * @param input value read from buffer - * @return port state - */ - public static PortConfigV10 createPortConfig(long input){ - final Boolean pcPortDown = ((input) & (1<<0)) != 0; - final Boolean pcNoStp = ((input) & (1<<1)) != 0; - final Boolean pcNoRecv = ((input) & (1<<2)) != 0; - final Boolean pcNoRecvStp = ((input) & (1<<3)) != 0; - final Boolean pcNoFlood = ((input) & (1<<4)) != 0; - final Boolean pcNoFwd = ((input) & (1<<5)) != 0; - final Boolean pcNoPacketIn = ((input) & (1<<6)) != 0; - return new PortConfigV10(pcNoFlood, pcNoFwd, pcNoPacketIn, pcNoRecv, pcNoRecvStp, pcNoStp, pcPortDown); - } - - /** - * Creates PortFeatures (OF v1.0) from input - * @param input value read from buffer - * @return port state - */ - public static PortFeaturesV10 createPortFeatures(long input){ - final Boolean pf10mbHd = ((input) & (1<<0)) != 0; - final Boolean pf10mbFd = ((input) & (1<<1)) != 0; - final Boolean pf100mbHd = ((input) & (1<<2)) != 0; - final Boolean pf100mbFd = ((input) & (1<<3)) != 0; - final Boolean pf1gbHd = ((input) & (1<<4)) != 0; - final Boolean pf1gbFd = ((input) & (1<<5)) != 0; - final Boolean pf10gbFd = ((input) & (1<<6)) != 0; - final Boolean pfCopper = ((input) & (1<<7)) != 0; - final Boolean pfFiber = ((input) & (1<<8)) != 0; - final Boolean pfAutoneg = ((input) & (1<<9)) != 0; - final Boolean pfPause = ((input) & (1<<10)) != 0; - final Boolean pfPauseAsym = ((input) & (1<<11)) != 0; - return new PortFeaturesV10(pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, - pf1gbFd, pf1gbHd, pfAutoneg, pfCopper, pfFiber, pfPause, pfPauseAsym); - } +/* + * Copyright (c) 2014 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 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; + +/** + * Used for common structures translation / conversion + * + * @author michal.polkorab + */ +public abstract class OpenflowUtils { + + /** + * Creates PortState (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortStateV10 createPortState(long input){ + final Boolean psLinkDown = ((input) & (1<<0)) != 0; + final Boolean psBlocked = ((input) & (1<<1)) != 0; + final Boolean psLive = ((input) & (1<<2)) != 0; + final Boolean psStpListen = ((input) & (1<<8)) == 0; + final Boolean psStpLearn = ((input) & (1<<8)) != 0; + final Boolean psStpForward = ((input) & (1<<9)) != 0; // equals 2 << 8 + final Boolean psStpBlock = (((input) & (1<<9)) != 0) && (((input) & (1<<8)) != 0); // equals 3 << 8 + final Boolean psStpMask = ((input) & (1<<10)) != 0; // equals 4 << 8 + return new PortStateV10(psBlocked, psLinkDown, psLive, psStpBlock, psStpForward, psStpLearn, psStpListen, psStpMask); + } + + /** + * Creates PortConfig (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortConfigV10 createPortConfig(long input){ + final Boolean pcPortDown = ((input) & (1<<0)) != 0; + final Boolean pcNoStp = ((input) & (1<<1)) != 0; + final Boolean pcNoRecv = ((input) & (1<<2)) != 0; + final Boolean pcNoRecvStp = ((input) & (1<<3)) != 0; + final Boolean pcNoFlood = ((input) & (1<<4)) != 0; + final Boolean pcNoFwd = ((input) & (1<<5)) != 0; + final Boolean pcNoPacketIn = ((input) & (1<<6)) != 0; + return new PortConfigV10(pcNoFlood, pcNoFwd, pcNoPacketIn, pcNoRecv, pcNoRecvStp, pcNoStp, pcPortDown); + } + + /** + * Creates PortFeatures (OF v1.0) from input + * @param input value read from buffer + * @return port state + */ + public static PortFeaturesV10 createPortFeatures(long input){ + final Boolean pf10mbHd = ((input) & (1<<0)) != 0; + final Boolean pf10mbFd = ((input) & (1<<1)) != 0; + final Boolean pf100mbHd = ((input) & (1<<2)) != 0; + final Boolean pf100mbFd = ((input) & (1<<3)) != 0; + final Boolean pf1gbHd = ((input) & (1<<4)) != 0; + final Boolean pf1gbFd = ((input) & (1<<5)) != 0; + final Boolean pf10gbFd = ((input) & (1<<6)) != 0; + final Boolean pfCopper = ((input) & (1<<7)) != 0; + final Boolean pfFiber = ((input) & (1<<8)) != 0; + final Boolean pfAutoneg = ((input) & (1<<9)) != 0; + final Boolean pfPause = ((input) & (1<<10)) != 0; + final Boolean pfPauseAsym = ((input) & (1<<11)) != 0; + return new PortFeaturesV10(pf100mbFd, pf100mbHd, pf10gbFd, pf10mbFd, pf10mbHd, + pf1gbFd, pf1gbHd, pfAutoneg, pfCopper, pfFiber, pfPause, pfPauseAsym); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java index 0fc66083..7c9ec2b5 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/SimpleDeserializerRegistryHelper.java @@ -1,44 +1,44 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; - -/** - * @author michal.polkorab - * - */ -public class SimpleDeserializerRegistryHelper { - - private short version; - private DeserializerRegistry registry; - - /** - * @param version wire protocol version - * @param deserializerRegistry registry to be filled with message deserializers - */ - public SimpleDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { - this.version = version; - this.registry = deserializerRegistry; - } - - /** - * @param code code / value to distinguish between deserializers - * @param experimenterID TODO - * @param deserializedObjectClass class of object that will be deserialized - * by given deserializer - * @param deserializer deserializer instance - */ - public void registerDeserializer(int code, - Long experimenterID, Class deserializedObjectClass, OFGeneralDeserializer deserializer) { - registry.registerDeserializer(new MessageCodeKey(version, code, - deserializedObjectClass), deserializer); - } -} +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFGeneralDeserializer; + +/** + * @author michal.polkorab + * + */ +public class SimpleDeserializerRegistryHelper { + + private short version; + private DeserializerRegistry registry; + + /** + * @param version wire protocol version + * @param deserializerRegistry registry to be filled with message deserializers + */ + public SimpleDeserializerRegistryHelper(short version, DeserializerRegistry deserializerRegistry) { + this.version = version; + this.registry = deserializerRegistry; + } + + /** + * @param code code / value to distinguish between deserializers + * @param experimenterID TODO + * @param deserializedObjectClass class of object that will be deserialized + * by given deserializer + * @param deserializer deserializer instance + */ + public void registerDeserializer(int code, + Long experimenterID, Class deserializedObjectClass, OFGeneralDeserializer deserializer) { + registry.registerDeserializer(new MessageCodeKey(version, code, + deserializedObjectClass), deserializer); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java index a9dab19e..02b0307b 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMaker.java @@ -1,26 +1,26 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; - -/** - * @author michal.polkorab - * @param - */ -public interface TypeKeyMaker { - - /** - * @param entry - * @return key that will be used for serializer lookup in - * the serializer registry - */ - abstract MessageTypeKey make(T entry); - -} +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; + +/** + * @author michal.polkorab + * @param + */ +public interface TypeKeyMaker { + + /** + * @param entry + * @return key that will be used for serializer lookup in + * the serializer registry + */ + abstract MessageTypeKey make(T entry); + +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java index 1d3875df..2c5b7def 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactory.java @@ -1,92 +1,92 @@ -/* - * 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 org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -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.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * Creates KeyMakers - * @author michal.polkorab - */ -public abstract class TypeKeyMakerFactory { - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static TypeKeyMaker createMatchEntriesKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { - @Override - public MatchEntrySerializerKey make(MatchEntries entry) { - MatchEntrySerializerKey key; - key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(), - entry.getOxmMatchField()); - if (entry.getOxmClass().equals(ExperimenterClass.class)) { - key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) - .getExperimenter().getValue()); - return key; - } - key.setExperimenterId(null); - return key; - } - }; - } - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static TypeKeyMaker createActionKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { - @Override - public MessageTypeKey make(Action entry) { - if (entry.getType().equals(Experimenter.class)) { - return new ExperimenterActionSerializerKey(getVersion(), - entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue(), entry.getAugmentation(ExperimenterIdAction.class).getSubType()); - } - return new ActionSerializerKey<>(getVersion(), entry.getType(), null); - } - }; - } - - /** - * @param version openflow wire version that shall be used - * in lookup key - * @return lookup key - */ - public static TypeKeyMaker createInstructionKeyMaker(short version) { - return new AbstractTypeKeyMaker(version) { - @Override - public MessageTypeKey make(Instruction entry) { - if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common - .instruction.rev130731.Experimenter.class)) { - return new ExperimenterInstructionSerializerKey(getVersion(), - entry.getAugmentation(ExperimenterIdInstruction.class) - .getExperimenter().getValue()); - } - return new InstructionSerializerKey<>(getVersion(), entry.getType(), null); - } - }; - } -} +/* + * 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 org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +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.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * Creates KeyMakers + * @author michal.polkorab + */ +public abstract class TypeKeyMakerFactory { + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createMatchEntriesKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public MatchEntrySerializerKey make(MatchEntries entry) { + MatchEntrySerializerKey key; + key = new MatchEntrySerializerKey<>(getVersion(), entry.getOxmClass(), + entry.getOxmMatchField()); + if (entry.getOxmClass().equals(ExperimenterClass.class)) { + key.setExperimenterId(entry.getAugmentation(ExperimenterIdMatchEntry.class) + .getExperimenter().getValue()); + return key; + } + key.setExperimenterId(null); + return key; + } + }; + } + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createActionKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public MessageTypeKey make(Action entry) { + if (entry.getType().equals(Experimenter.class)) { + return new ExperimenterActionSerializerKey(getVersion(), + entry.getAugmentation(ExperimenterIdAction.class).getExperimenter().getValue(), entry.getAugmentation(ExperimenterIdAction.class).getSubType()); + } + return new ActionSerializerKey<>(getVersion(), entry.getType(), null); + } + }; + } + + /** + * @param version openflow wire version that shall be used + * in lookup key + * @return lookup key + */ + public static TypeKeyMaker createInstructionKeyMaker(short version) { + return new AbstractTypeKeyMaker(version) { + @Override + public MessageTypeKey make(Instruction entry) { + if (entry.getType().equals(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common + .instruction.rev130731.Experimenter.class)) { + return new ExperimenterInstructionSerializerKey(getVersion(), + entry.getAugmentation(ExperimenterIdInstruction.class) + .getExperimenter().getValue()); + } + return new InstructionSerializerKey<>(getVersion(), entry.getType(), null); + } + }; + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java index abf7695d..0484ea83 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassInitHelper.java @@ -1,40 +1,40 @@ -/* - * 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.Map; - -/** - * @author michal.polkorab - * - */ -public class TypeToClassInitHelper { - - private short version; - private Map> messageClassMap; - - /** - * Constructor - * @param version protocol wire version - * @param messageClassMap map which stores type to class mapping - */ - public TypeToClassInitHelper(short version, Map> messageClassMap) { - this.version = version; - this.messageClassMap = messageClassMap; - } - - /** - * Registers Class int the type to class mapping - * @param type code value for message type / class - * @param clazz corresponding code -> class - */ - public void registerTypeToClass(short type, Class clazz) { - messageClassMap.put(new TypeToClassKey(version, type), clazz); - } -} +/* + * 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.Map; + +/** + * @author michal.polkorab + * + */ +public class TypeToClassInitHelper { + + private short version; + private Map> messageClassMap; + + /** + * Constructor + * @param version protocol wire version + * @param messageClassMap map which stores type to class mapping + */ + public TypeToClassInitHelper(short version, Map> messageClassMap) { + this.version = version; + this.messageClassMap = messageClassMap; + } + + /** + * Registers Class int the type to class mapping + * @param type code value for message type / class + * @param clazz corresponding code -> class + */ + public void registerTypeToClass(short type, Class clazz) { + messageClassMap.put(new TypeToClassKey(version, type), clazz); + } +} diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java index 098f9322..0f6b9caf 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/TypeToClassKey.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.openflowjava.protocol.impl.util; - -/** - * @author michal.polkorab - * - */ -public class TypeToClassKey { - - private short version; - private int type; - - /** - * Constructor - * @param version wire protocol version - * @param type message type / code - */ - public TypeToClassKey(short version, int type) { - this.version = version; - this.type = type; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + type; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - TypeToClassKey other = (TypeToClassKey) obj; - if (type != other.type) { - return false; - } - if (version != other.version) { - return false; - } - return true; - } +/* + * 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; + +/** + * @author michal.polkorab + * + */ +public class TypeToClassKey { + + private short version; + private int type; + + /** + * Constructor + * @param version wire protocol version + * @param type message type / code + */ + public TypeToClassKey(short version, int type) { + this.version = version; + this.type = type; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + type; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + TypeToClassKey other = (TypeToClassKey) obj; + if (type != other.type) { + return false; + } + if (version != other.version) { + return false; + } + return true; + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java index c5f18729..aea5890e 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/Counter.java @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2014 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.statistics; - -import java.util.concurrent.atomic.AtomicLong; -/** - * Counts statistics - * - * @author madamjak - */ -public class Counter { - - private AtomicLong counterValue; - private AtomicLong counterLastReadValue; - - /** - * Default constructor - */ - public Counter() { - counterValue = new AtomicLong(0L); - counterLastReadValue = new AtomicLong(0L); - } - - /** - * Increment current counter value - */ - public void incrementCounter(){ - counterValue.incrementAndGet(); - } - - /** - * return the last read value of counter. This value can be set during the reading of current counter value, - * for detail see method getCounterValue(boolean modifyLastReadValue). - * @return the counterLastReadValue - */ - public long getCounterLastReadValue() { - return counterLastReadValue.get(); - } - - /** - * get current value of counter and rewrite CounterLastReadValue by current value - * @return the current value of counter - */ - public long getCounterValue() { - return getCounterValue(true); - } - - /** - * get current counter value - * @param modifyLastReadValue - * true - CounterLastReadValue will be rewritten by current CounterValue - * false - no change CounterLastReadValue - * @return the current value of counter - */ - public long getCounterValue(boolean modifyLastReadValue) { - if(modifyLastReadValue){ - counterLastReadValue.set(counterValue.get()); - } - return counterValue.get(); - } - - /** - * set current counter value and CounterLastReadValue to 0 (zero) - */ - public void reset(){ - counterValue.set(0l); - counterLastReadValue.set(0l); - } - - /** - * @return last and current count for specified statistic - */ - public String getStat() { - long cntPrevVal = getCounterLastReadValue(); - long cntCurValue = getCounterValue(); - return String.format("+%d | %d",cntCurValue-cntPrevVal,cntCurValue); - } +/* + * Copyright (c) 2014 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.statistics; + +import java.util.concurrent.atomic.AtomicLong; +/** + * Counts statistics + * + * @author madamjak + */ +public class Counter { + + private AtomicLong counterValue; + private AtomicLong counterLastReadValue; + + /** + * Default constructor + */ + public Counter() { + counterValue = new AtomicLong(0L); + counterLastReadValue = new AtomicLong(0L); + } + + /** + * Increment current counter value + */ + public void incrementCounter(){ + counterValue.incrementAndGet(); + } + + /** + * return the last read value of counter. This value can be set during the reading of current counter value, + * for detail see method getCounterValue(boolean modifyLastReadValue). + * @return the counterLastReadValue + */ + public long getCounterLastReadValue() { + return counterLastReadValue.get(); + } + + /** + * get current value of counter and rewrite CounterLastReadValue by current value + * @return the current value of counter + */ + public long getCounterValue() { + return getCounterValue(true); + } + + /** + * get current counter value + * @param modifyLastReadValue + * true - CounterLastReadValue will be rewritten by current CounterValue + * false - no change CounterLastReadValue + * @return the current value of counter + */ + public long getCounterValue(boolean modifyLastReadValue) { + if(modifyLastReadValue){ + counterLastReadValue.set(counterValue.get()); + } + return counterValue.get(); + } + + /** + * set current counter value and CounterLastReadValue to 0 (zero) + */ + public void reset(){ + counterValue.set(0l); + counterLastReadValue.set(0l); + } + + /** + * @return last and current count for specified statistic + */ + public String getStat() { + long cntPrevVal = getCounterLastReadValue(); + long cntCurValue = getCounterValue(); + return String.format("+%d | %d",cntCurValue-cntPrevVal,cntCurValue); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java index 0dd7faad..b021745d 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/statistics/CounterEventTypes.java @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2014 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.statistics; - -/** - * Enumeration of events to be counted with StatisticsCounters - * @author madamjak - * - */ -public enum CounterEventTypes { - /** - * enter message to OFJ and pass to downstream - */ - DS_ENTERED_OFJAVA, - /** - * flow-mod is entered - */ - DS_FLOW_MODS_ENTERED, - /** - * encode message successfully - */ - DS_ENCODE_SUCCESS, - /** - * fail encode message - */ - DS_ENCODE_FAIL, - /** - * flow-mod encoded and sent to downstream - */ - DS_FLOW_MODS_SENT, - /** - * receive message and pass to upstream - */ - US_RECEIVED_IN_OFJAVA, - /** - * decode message successfully - */ - US_DECODE_SUCCESS, - /** - * fail decode message - */ - US_DECODE_FAIL, - /** - * pass message to consumer (end of upstream) - */ - US_MESSAGE_PASS; +/* + * Copyright (c) 2014 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.statistics; + +/** + * Enumeration of events to be counted with StatisticsCounters + * @author madamjak + * + */ +public enum CounterEventTypes { + /** + * enter message to OFJ and pass to downstream + */ + DS_ENTERED_OFJAVA, + /** + * flow-mod is entered + */ + DS_FLOW_MODS_ENTERED, + /** + * encode message successfully + */ + DS_ENCODE_SUCCESS, + /** + * fail encode message + */ + DS_ENCODE_FAIL, + /** + * flow-mod encoded and sent to downstream + */ + DS_FLOW_MODS_SENT, + /** + * receive message and pass to upstream + */ + US_RECEIVED_IN_OFJAVA, + /** + * decode message successfully + */ + US_DECODE_SUCCESS, + /** + * fail decode message + */ + US_DECODE_FAIL, + /** + * pass message to consumer (end of upstream) + */ + US_MESSAGE_PASS; } \ No newline at end of file diff --git a/openflow-protocol-impl/src/main/resources/log4j.xml b/openflow-protocol-impl/src/main/resources/log4j.xml index 75e1faac..fff5292a 100644 --- a/openflow-protocol-impl/src/main/resources/log4j.xml +++ b/openflow-protocol-impl/src/main/resources/log4j.xml @@ -1,28 +1,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java index 3baeb944..7ab8bfcc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/OFDatagramPacketEncoderTest.java @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2014 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 static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import io.netty.channel.ChannelHandlerContext; -import io.netty.util.concurrent.Future; -import io.netty.util.concurrent.GenericFutureListener; - -import java.net.InetSocketAddress; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; -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 OFDatagramPacketEncoderTest { - - @Mock ChannelHandlerContext ctx; - @Mock GenericFutureListener> listener; - @Mock SerializationFactory factory; - - private UdpMessageListenerWrapper wrapper; - private InetSocketAddress address = new InetSocketAddress("10.0.0.1", 6653); - private List out; - - /** - * Initializes mocks and other objects - * @param version openflow protocol wire version - */ - public void startUp(Short version) { - MockitoAnnotations.initMocks(this); - out = new ArrayList<>(); - HelloInputBuilder builder = new HelloInputBuilder(); - builder.setVersion(version); - HelloInput hello = builder.build(); - wrapper = new UdpMessageListenerWrapper(hello, listener, address); - } - - /** - * Tests encoding - */ - @Test - public void testCorrectEncode() { - startUp((short) EncodeConstants.OF13_VERSION_ID); - OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); - encoder.setSerializationFactory(factory); - try { - encoder.encode(ctx, wrapper, out); - } catch (Exception e) { - Assert.fail(); - } - } - - /** - * Tests encoding - */ - @Test - public void testIncorrectEncode() { - startUp(null); - OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); - encoder.setSerializationFactory(factory); - try { - encoder.encode(ctx, wrapper, out); - } catch (Exception e) { - verify(wrapper, times(1)).getListener(); - Assert.assertEquals("List should be empty", 0, out.size()); - } - } +/* + * Copyright (c) 2014 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 static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import io.netty.channel.ChannelHandlerContext; +import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; + +import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.core.connection.UdpMessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactory; +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 OFDatagramPacketEncoderTest { + + @Mock ChannelHandlerContext ctx; + @Mock GenericFutureListener> listener; + @Mock SerializationFactory factory; + + private UdpMessageListenerWrapper wrapper; + private InetSocketAddress address = new InetSocketAddress("10.0.0.1", 6653); + private List out; + + /** + * Initializes mocks and other objects + * @param version openflow protocol wire version + */ + public void startUp(Short version) { + MockitoAnnotations.initMocks(this); + out = new ArrayList<>(); + HelloInputBuilder builder = new HelloInputBuilder(); + builder.setVersion(version); + HelloInput hello = builder.build(); + wrapper = new UdpMessageListenerWrapper(hello, listener, address); + } + + /** + * Tests encoding + */ + @Test + public void testCorrectEncode() { + startUp((short) EncodeConstants.OF13_VERSION_ID); + OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); + encoder.setSerializationFactory(factory); + try { + encoder.encode(ctx, wrapper, out); + } catch (Exception e) { + Assert.fail(); + } + } + + /** + * Tests encoding + */ + @Test + public void testIncorrectEncode() { + startUp(null); + OFDatagramPacketEncoder encoder = new OFDatagramPacketEncoder(); + encoder.setSerializationFactory(factory); + try { + encoder.encode(ctx, wrapper, out); + } catch (Exception e) { + verify(wrapper, times(1)).getListener(); + Assert.assertEquals("List should be empty", 0, out.size()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java index cf50b626..0b001d9b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ChannelOutboundQueueTest.java @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2014 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.connection; - -import io.netty.channel.Channel; - -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue; -import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; - -/** - * @author michal.polkorab - * - */ -public class ChannelOutboundQueueTest { - - @Mock Channel channel; - - /** - * Initialize mocks - */ - public ChannelOutboundQueueTest() { - MockitoAnnotations.initMocks(this); - } - - /** - * Test incorrect queue creation handling - */ - @Test(expected=IllegalArgumentException.class) - public void testIncorrectQueueCreation() { - new ChannelOutboundQueue(channel, 0, null); - } - - /** - * Test correct enqueue handling - */ - @Test - public void testEnqueue() { - ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1, null); - boolean enqueued; - enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); - Assert.assertTrue("Enqueue problem", enqueued); - enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); - Assert.assertFalse("Enqueue problem", enqueued); - } +/* + * Copyright (c) 2014 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.connection; + +import io.netty.channel.Channel; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ChannelOutboundQueue; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; + +/** + * @author michal.polkorab + * + */ +public class ChannelOutboundQueueTest { + + @Mock Channel channel; + + /** + * Initialize mocks + */ + public ChannelOutboundQueueTest() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test incorrect queue creation handling + */ + @Test(expected=IllegalArgumentException.class) + public void testIncorrectQueueCreation() { + new ChannelOutboundQueue(channel, 0, null); + } + + /** + * Test correct enqueue handling + */ + @Test + public void testEnqueue() { + ChannelOutboundQueue queue = new ChannelOutboundQueue(channel, 1, null); + boolean enqueued; + enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); + Assert.assertTrue("Enqueue problem", enqueued); + enqueued = queue.enqueue(new SimpleRpcListener("INPUT", "Failed to send INPUT")); + Assert.assertFalse("Enqueue problem", enqueued); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java index 77d9e912..c9f52772 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ConnectionAdapterImplTest.java @@ -1,185 +1,185 @@ -/* - * Copyright (c) 2014 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.connection; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelPipeline; -import io.netty.channel.socket.SocketChannel; - -import java.net.InetSocketAddress; -import java.util.concurrent.TimeUnit; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; -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.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; -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.PacketInMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; -import org.opendaylight.yangtools.yang.binding.DataObject; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; - -/** - * @author michal.polkorab - * @author madamjak - * - */ -public class ConnectionAdapterImplTest { - - private static final int RPC_RESPONSE_EXPIRATION = 1; - private static final RemovalListener> REMOVAL_LISTENER = - new RemovalListener>() { - @Override - public void onRemoval( - final RemovalNotification> notification) { - notification.getValue().discard(); - } - }; - - @Mock SocketChannel channel; - @Mock ChannelPipeline pipeline; - @Mock OpenflowProtocolListener messageListener; - @Mock SystemNotificationsListener systemListener; - @Mock ConnectionReadyListener readyListener; - @Mock Cache> mockCache; - @Mock ChannelFuture channelFuture; +/* + * Copyright (c) 2014 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 + */ - private ConnectionAdapterImpl adapter; - private Cache> cache; - - /** - * Initializes ConnectionAdapter - */ - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - when(channel.pipeline()).thenReturn(pipeline); - adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); - adapter.setMessageListener(messageListener); - adapter.setSystemListener(systemListener); - adapter.setConnectionReadyListener(readyListener); - cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) - .removalListener(REMOVAL_LISTENER).build(); +package org.opendaylight.openflowjava.protocol.impl.core.connection; + +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelPipeline; +import io.netty.channel.socket.SocketChannel; + +import java.net.InetSocketAddress; +import java.util.concurrent.TimeUnit; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyListener; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ConnectionAdapterImpl; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder; +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.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +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.PacketInMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEvent; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener; +import org.opendaylight.yangtools.yang.binding.DataObject; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; + +/** + * @author michal.polkorab + * @author madamjak + * + */ +public class ConnectionAdapterImplTest { + + private static final int RPC_RESPONSE_EXPIRATION = 1; + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + + @Mock SocketChannel channel; + @Mock ChannelPipeline pipeline; + @Mock OpenflowProtocolListener messageListener; + @Mock SystemNotificationsListener systemListener; + @Mock ConnectionReadyListener readyListener; + @Mock Cache> mockCache; + @Mock ChannelFuture channelFuture; + + private ConnectionAdapterImpl adapter; + private Cache> cache; + + /** + * Initializes ConnectionAdapter + */ + @Before + public void setUp() { + MockitoAnnotations.initMocks(this); + when(channel.pipeline()).thenReturn(pipeline); + adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653)); + adapter.setMessageListener(messageListener); + adapter.setSystemListener(systemListener); + adapter.setConnectionReadyListener(readyListener); + cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); adapter.setResponseCache(cache); when(channel.disconnect()).thenReturn(channelFuture); - } - - /** - * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications - */ - @Test - public void testConsume() { - DataObject message = new EchoRequestMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); - message = new ErrorMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message); - message = new ExperimenterMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message); - message = new FlowRemovedMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message); - message = new HelloMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onHelloMessage((HelloMessage) message); - message = new MultipartReplyMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message); - message = new PacketInMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message); - message = new PortStatusMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message); - message = new SwitchIdleEventBuilder().build(); - adapter.consume(message); - verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message); - message = new DisconnectEventBuilder().build(); - adapter.consume(message); - verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message); - message = new EchoRequestMessageBuilder().build(); - adapter.consume(message); - verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); - } - - /** - * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with unexpected rpc - */ - @Test - public void testConsume2() { - adapter.setResponseCache(mockCache); - BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); - barrierBuilder.setXid(42L); - BarrierOutput barrier = barrierBuilder.build(); - adapter.consume(barrier); - verify(mockCache, times(1)).getIfPresent(any(RpcResponseKey.class)); - } - - /** - * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with expected rpc - */ - @Test - public void testConsume3() { - BarrierInputBuilder inputBuilder = new BarrierInputBuilder(); - inputBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - inputBuilder.setXid(42L); - BarrierInput barrierInput = inputBuilder.build(); - RpcResponseKey key = new RpcResponseKey(42L, "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput"); - ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(barrierInput, - "failure", mockCache, key); - cache.put(key, listener); - BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); - barrierBuilder.setXid(42L); - BarrierOutput barrierOutput = barrierBuilder.build(); - adapter.consume(barrierOutput); - ResponseExpectedRpcListener ifPresent = cache.getIfPresent(key); - Assert.assertNull("Listener was not discarded", ifPresent); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications + */ + @Test + public void testConsume() { + DataObject message = new EchoRequestMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); + message = new ErrorMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message); + message = new ExperimenterMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message); + message = new FlowRemovedMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message); + message = new HelloMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onHelloMessage((HelloMessage) message); + message = new MultipartReplyMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message); + message = new PacketInMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message); + message = new PortStatusMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message); + message = new SwitchIdleEventBuilder().build(); + adapter.consume(message); + verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message); + message = new DisconnectEventBuilder().build(); + adapter.consume(message); + verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message); + message = new EchoRequestMessageBuilder().build(); + adapter.consume(message); + verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with unexpected rpc + */ + @Test + public void testConsume2() { + adapter.setResponseCache(mockCache); + BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); + barrierBuilder.setXid(42L); + BarrierOutput barrier = barrierBuilder.build(); + adapter.consume(barrier); + verify(mockCache, times(1)).getIfPresent(any(RpcResponseKey.class)); + } + + /** + * Tests {@link ConnectionAdapterImpl#consume(DataObject)} with expected rpc + */ + @Test + public void testConsume3() { + BarrierInputBuilder inputBuilder = new BarrierInputBuilder(); + inputBuilder.setVersion((short) EncodeConstants.OF13_VERSION_ID); + inputBuilder.setXid(42L); + BarrierInput barrierInput = inputBuilder.build(); + RpcResponseKey key = new RpcResponseKey(42L, "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput"); + ResponseExpectedRpcListener listener = new ResponseExpectedRpcListener<>(barrierInput, + "failure", mockCache, key); + cache.put(key, listener); + BarrierOutputBuilder barrierBuilder = new BarrierOutputBuilder(); + barrierBuilder.setXid(42L); + BarrierOutput barrierOutput = barrierBuilder.build(); + adapter.consume(barrierOutput); + ResponseExpectedRpcListener ifPresent = cache.getIfPresent(key); + Assert.assertNull("Listener was not discarded", ifPresent); } /** * Test IsAlive method diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java index 18992b62..3be4ba4f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/MessageListenerWrapperTest.java @@ -1,36 +1,36 @@ -/* - * Copyright (c) 2014 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.connection; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; -import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; -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 MessageListenerWrapperTest { - - /** - * Test MessageListenerWrapper creation - */ - @Test - public void test() { - HelloInputBuilder builder = new HelloInputBuilder(); - HelloInput hello = builder.build(); - SimpleRpcListener listener = new SimpleRpcListener(hello, "Error"); - MessageListenerWrapper wrapper = new MessageListenerWrapper(hello, listener); - Assert.assertEquals("Wrong message", hello, wrapper.getMsg()); - Assert.assertEquals("Wrong listener", listener, wrapper.getListener()); - } +/* + * Copyright (c) 2014 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.connection; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.core.connection.MessageListenerWrapper; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; +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 MessageListenerWrapperTest { + + /** + * Test MessageListenerWrapper creation + */ + @Test + public void test() { + HelloInputBuilder builder = new HelloInputBuilder(); + HelloInput hello = builder.build(); + SimpleRpcListener listener = new SimpleRpcListener(hello, "Error"); + MessageListenerWrapper wrapper = new MessageListenerWrapper(hello, listener); + Assert.assertEquals("Wrong message", hello, wrapper.getMsg()); + Assert.assertEquals("Wrong listener", listener, wrapper.getListener()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java index 32b6b931..ec57cb8f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/ResponseExpectedRpcListenerTest.java @@ -1,132 +1,132 @@ -/* - * Copyright (c) 2014 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.connection; - -import static org.junit.Assert.fail; - -import java.util.Collections; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.openflowjava.protocol.impl.core.connection.AbstractRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; -import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; -import org.opendaylight.yangtools.yang.common.RpcResult; - -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.RemovalListener; -import com.google.common.cache.RemovalNotification; -import com.google.common.util.concurrent.SettableFuture; - -/** - * @author michal.polkorab - * - */ -public class ResponseExpectedRpcListenerTest { - - private static final RemovalListener> REMOVAL_LISTENER = - new RemovalListener>() { - @Override - public void onRemoval( - final RemovalNotification> notification) { - notification.getValue().discard(); - } - }; - private static final int RPC_RESPONSE_EXPIRATION = 1; - private Cache> responseCache = CacheBuilder.newBuilder() - .concurrencyLevel(1) - .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) - .removalListener(REMOVAL_LISTENER).build(); - - /** - * Test object creation - */ - @Test(expected=NullPointerException.class) - public void testCreation() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", null, key); - } - - /** - * Test object creation - */ - @Test(expected=NullPointerException.class) - public void testCreation2() { - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, null); - } - - /** - * Test object creation - */ - @Test - public void testDiscard() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); - ResponseExpectedRpcListener listener = - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); - listener.discard(); - RpcError rpcError = AbstractRpcListener.buildRpcError("Failed to send message", - ErrorSeverity.ERROR, "check switch connection", new TimeoutException("Request timed out")); - SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(false, null, Collections.singletonList(rpcError))); - try { - Assert.assertEquals("Wrong result", result.get().getErrors().iterator().next().getMessage(), - listener.getResult().get().getErrors().iterator().next().getMessage()); - Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); - Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); - } catch (InterruptedException | ExecutionException e) { - fail("Problem accessing result"); - } - } - - /** - * Test object creation - */ - @Test - public void testCompleted() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); - ResponseExpectedRpcListener listener = - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); - BarrierInputBuilder barrierBuilder = new BarrierInputBuilder(); - BarrierInput barrierInput = barrierBuilder.build(); - listener.completed(barrierInput); - SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(true, barrierInput, Collections.emptyList())); - try { - Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); - Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); - Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); - } catch (InterruptedException | ExecutionException e) { - fail("Problem accessing result"); - } - } - - /** - * Test object creation - */ - @Test - public void testOperationSuccessful() { - RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); - ResponseExpectedRpcListener listener = - new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); - listener.operationSuccessful(); - ResponseExpectedRpcListener present = responseCache.getIfPresent(key); - Assert.assertEquals(present, listener); - } +/* + * Copyright (c) 2014 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.connection; + +import static org.junit.Assert.fail; + +import java.util.Collections; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.openflowjava.protocol.impl.core.connection.AbstractRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.ResponseExpectedRpcListener; +import org.opendaylight.openflowjava.protocol.impl.core.connection.RpcResponseKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.RemovalListener; +import com.google.common.cache.RemovalNotification; +import com.google.common.util.concurrent.SettableFuture; + +/** + * @author michal.polkorab + * + */ +public class ResponseExpectedRpcListenerTest { + + private static final RemovalListener> REMOVAL_LISTENER = + new RemovalListener>() { + @Override + public void onRemoval( + final RemovalNotification> notification) { + notification.getValue().discard(); + } + }; + private static final int RPC_RESPONSE_EXPIRATION = 1; + private Cache> responseCache = CacheBuilder.newBuilder() + .concurrencyLevel(1) + .expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES) + .removalListener(REMOVAL_LISTENER).build(); + + /** + * Test object creation + */ + @Test(expected=NullPointerException.class) + public void testCreation() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", null, key); + } + + /** + * Test object creation + */ + @Test(expected=NullPointerException.class) + public void testCreation2() { + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, null); + } + + /** + * Test object creation + */ + @Test + public void testDiscard() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + listener.discard(); + RpcError rpcError = AbstractRpcListener.buildRpcError("Failed to send message", + ErrorSeverity.ERROR, "check switch connection", new TimeoutException("Request timed out")); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(false, null, Collections.singletonList(rpcError))); + try { + Assert.assertEquals("Wrong result", result.get().getErrors().iterator().next().getMessage(), + listener.getResult().get().getErrors().iterator().next().getMessage()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } + + /** + * Test object creation + */ + @Test + public void testCompleted() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + BarrierInputBuilder barrierBuilder = new BarrierInputBuilder(); + BarrierInput barrierInput = barrierBuilder.build(); + listener.completed(barrierInput); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(true, barrierInput, Collections.emptyList())); + try { + Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } + + /** + * Test object creation + */ + @Test + public void testOperationSuccessful() { + RpcResponseKey key = new RpcResponseKey(12345L, BarrierOutput.class.getName()); + ResponseExpectedRpcListener listener = + new ResponseExpectedRpcListener<>("MESSAGE", "Failed to send message", responseCache, key); + listener.operationSuccessful(); + ResponseExpectedRpcListener present = responseCache.getIfPresent(key); + Assert.assertEquals(present, listener); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java index d5a7499c..fff2ea02 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SimpleRpcListenerTest.java @@ -1,108 +1,108 @@ -/* - * Copyright (c) 2014 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.connection; - -import static org.junit.Assert.fail; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import io.netty.util.concurrent.Future; - -import java.util.Collections; -import java.util.concurrent.ExecutionException; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; - -import com.google.common.util.concurrent.SettableFuture; - -/** - * @author michal.polkorab - * - */ -public class SimpleRpcListenerTest { - - @Mock Future future; - - /** - * Initializes mocks - */ - @Before - public void startUp() { - MockitoAnnotations.initMocks(this); - } - - /** - * Test SimpleRpcListener creation - */ - @Test - public void test() { - SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); - Assert.assertEquals("Wrong message", "MESSAGE", listener.takeMessage()); - Assert.assertEquals("Wrong message", listener, listener.takeListener()); - } - - /** - * Test rpc success - */ - @Test - public void testSuccessfulRpc() { - SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); - listener.operationSuccessful(); - SettableFuture> result = SettableFuture.create(); - result.set(Rpcs.getRpcResult(true, null, Collections.emptyList())); - try { - Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); - Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); - Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); - } catch (InterruptedException | ExecutionException e) { - fail("Problem accessing result"); - } - } - - /** - * Test rpc success - */ - @Test - public void testOperationComplete() { - when(future.isSuccess()).thenReturn(false); - SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); - listener.operationComplete(future); - verify(future, times(1)).cause(); - try { - Assert.assertEquals("Wrong result", 1, listener.getResult().get().getErrors().size()); - } catch (InterruptedException | ExecutionException e) { - Assert.fail(); - } - } - - /** - * Test rpc success - */ - @Test - public void testOperationComplete2() { - when(future.isSuccess()).thenReturn(true); - SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); - listener.operationComplete(future); - verify(future, times(0)).cause(); - try { - Assert.assertEquals("Wrong result", 0, listener.getResult().get().getErrors().size()); - Assert.assertEquals("Wrong result", true, listener.getResult().get().isSuccessful()); - } catch (InterruptedException | ExecutionException e) { - Assert.fail(); - } - } +/* + * Copyright (c) 2014 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.connection; + +import static org.junit.Assert.fail; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import io.netty.util.concurrent.Future; + +import java.util.Collections; +import java.util.concurrent.ExecutionException; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.controller.sal.common.util.Rpcs; +import org.opendaylight.openflowjava.protocol.impl.core.connection.SimpleRpcListener; +import org.opendaylight.yangtools.yang.common.RpcError; +import org.opendaylight.yangtools.yang.common.RpcResult; + +import com.google.common.util.concurrent.SettableFuture; + +/** + * @author michal.polkorab + * + */ +public class SimpleRpcListenerTest { + + @Mock Future future; + + /** + * Initializes mocks + */ + @Before + public void startUp() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test SimpleRpcListener creation + */ + @Test + public void test() { + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + Assert.assertEquals("Wrong message", "MESSAGE", listener.takeMessage()); + Assert.assertEquals("Wrong message", listener, listener.takeListener()); + } + + /** + * Test rpc success + */ + @Test + public void testSuccessfulRpc() { + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationSuccessful(); + SettableFuture> result = SettableFuture.create(); + result.set(Rpcs.getRpcResult(true, null, Collections.emptyList())); + try { + Assert.assertEquals("Wrong result", result.get().getErrors(), listener.getResult().get().getErrors()); + Assert.assertEquals("Wrong result", result.get().getResult(), listener.getResult().get().getResult()); + Assert.assertEquals("Wrong result", result.get().isSuccessful(), listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + fail("Problem accessing result"); + } + } + + /** + * Test rpc success + */ + @Test + public void testOperationComplete() { + when(future.isSuccess()).thenReturn(false); + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationComplete(future); + verify(future, times(1)).cause(); + try { + Assert.assertEquals("Wrong result", 1, listener.getResult().get().getErrors().size()); + } catch (InterruptedException | ExecutionException e) { + Assert.fail(); + } + } + + /** + * Test rpc success + */ + @Test + public void testOperationComplete2() { + when(future.isSuccess()).thenReturn(true); + SimpleRpcListener listener = new SimpleRpcListener("MESSAGE", "Failed to send message"); + listener.operationComplete(future); + verify(future, times(0)).cause(); + try { + Assert.assertEquals("Wrong result", 0, listener.getResult().get().getErrors().size()); + Assert.assertEquals("Wrong result", true, listener.getResult().get().isSuccessful()); + } catch (InterruptedException | ExecutionException e) { + Assert.fail(); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java index 0c792fa2..8fa76e80 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java @@ -1,182 +1,182 @@ -/* - * Copyright (c) 2014 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.connection; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.junit.Assert; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; -import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; -import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; -import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; - -import com.google.common.util.concurrent.ListenableFuture; - -/** - * @author michal.polkorab - * - */ -public class SwitchConnectionProviderImplTest { - - @Mock SwitchConnectionHandler handler; - - private static final int SWITCH_IDLE_TIMEOUT = 2000; - private static final int WAIT_TIMEOUT = 2000; - private InetAddress startupAddress; - private TlsConfiguration tlsConfiguration; - private SwitchConnectionProviderImpl provider; - private ConnectionConfigurationImpl config; - - /** - * Creates new {@link SwitchConnectionProvider} instance for each test - * @param protocol communication protocol - */ - public void startUp(TransportProtocol protocol) { - MockitoAnnotations.initMocks(this); - config = null; - if (protocol != null) { - createConfig(protocol); - } - provider = new SwitchConnectionProviderImpl(); - } - - private void createConfig(TransportProtocol protocol) { - try { - startupAddress = InetAddress.getLocalHost(); - } catch (UnknownHostException e) { - e.printStackTrace(); - } - tlsConfiguration = null; - if (protocol.equals(TransportProtocol.TLS)) { - tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, - "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, - "/selfSignedController", PathType.CLASSPATH) ; - } - config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); - config.setTransferProtocol(protocol); - } - - /** - * Tests provider startup - without configuration and {@link SwitchConnectionHandler} - */ - @Test - public void testStartup1() { - provider = new SwitchConnectionProviderImpl(); - ListenableFuture future = provider.startup(); - try { - future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); - } - } - - /** - * Tests provider startup - without configuration - */ - @Test - public void testStartup2() { - startUp(null); - provider.setSwitchConnectionHandler(handler); - ListenableFuture future = provider.startup(); - try { - future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); - } - } - - /** - * Tests provider startup - without {@link SwitchConnectionHandler} - */ - @Test - public void testStartup3() { - startUp(TransportProtocol.TCP); - provider.setConfiguration(config); - ListenableFuture future = provider.startup(); - try { - future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.assertEquals("Wrong state", "java.lang.IllegalStateException:" - + " SwitchConnectionHandler is not set", e.getMessage()); - } - } - - /** - * Tests correct provider startup - over TCP - */ - @Test - public void testStartup4() { - startUp(TransportProtocol.TCP); - provider.setConfiguration(config); - provider.setSwitchConnectionHandler(handler); - try { - Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.fail(); - } - } - - /** - * Tests correct provider startup - over TLS - */ - @Test - public void testStartup5() { - startUp(TransportProtocol.TLS); - provider.setConfiguration(config); - provider.setSwitchConnectionHandler(handler); - try { - Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.fail(); - } - } - - /** - * Tests correct provider startup - over UDP - */ - @Test - public void testStartup6() { - startUp(TransportProtocol.UDP); - provider.setConfiguration(config); - provider.setSwitchConnectionHandler(handler); - try { - Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - Assert.fail(); - } - } - - /** - * Tests correct provider shutdown - */ - @Test - public void testShutdown() { - startUp(TransportProtocol.TCP); - provider.setConfiguration(config); - provider.setSwitchConnectionHandler(handler); - try { - Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - Assert.assertTrue("Failed to stop", provider.shutdown().get(5 * WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); - } catch (InterruptedException | ExecutionException | TimeoutException e) { - e.printStackTrace(); - } - } - +/* + * Copyright (c) 2014 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.connection; + +import java.net.InetAddress; +import java.net.UnknownHostException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration; +import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl; +import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; +import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.KeystoreType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.PathType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.config.rev140630.TransportProtocol; + +import com.google.common.util.concurrent.ListenableFuture; + +/** + * @author michal.polkorab + * + */ +public class SwitchConnectionProviderImplTest { + + @Mock SwitchConnectionHandler handler; + + private static final int SWITCH_IDLE_TIMEOUT = 2000; + private static final int WAIT_TIMEOUT = 2000; + private InetAddress startupAddress; + private TlsConfiguration tlsConfiguration; + private SwitchConnectionProviderImpl provider; + private ConnectionConfigurationImpl config; + + /** + * Creates new {@link SwitchConnectionProvider} instance for each test + * @param protocol communication protocol + */ + public void startUp(TransportProtocol protocol) { + MockitoAnnotations.initMocks(this); + config = null; + if (protocol != null) { + createConfig(protocol); + } + provider = new SwitchConnectionProviderImpl(); + } + + private void createConfig(TransportProtocol protocol) { + try { + startupAddress = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + e.printStackTrace(); + } + tlsConfiguration = null; + if (protocol.equals(TransportProtocol.TLS)) { + tlsConfiguration = new TlsConfigurationImpl(KeystoreType.JKS, + "/selfSignedSwitch", PathType.CLASSPATH, KeystoreType.JKS, + "/selfSignedController", PathType.CLASSPATH) ; + } + config = new ConnectionConfigurationImpl(startupAddress, 0, tlsConfiguration, SWITCH_IDLE_TIMEOUT); + config.setTransferProtocol(protocol); + } + + /** + * Tests provider startup - without configuration and {@link SwitchConnectionHandler} + */ + @Test + public void testStartup1() { + provider = new SwitchConnectionProviderImpl(); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); + } + } + + /** + * Tests provider startup - without configuration + */ + @Test + public void testStartup2() { + startUp(null); + provider.setSwitchConnectionHandler(handler); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.NullPointerException", e.getMessage()); + } + } + + /** + * Tests provider startup - without {@link SwitchConnectionHandler} + */ + @Test + public void testStartup3() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + ListenableFuture future = provider.startup(); + try { + future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.assertEquals("Wrong state", "java.lang.IllegalStateException:" + + " SwitchConnectionHandler is not set", e.getMessage()); + } + } + + /** + * Tests correct provider startup - over TCP + */ + @Test + public void testStartup4() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider startup - over TLS + */ + @Test + public void testStartup5() { + startUp(TransportProtocol.TLS); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider startup - over UDP + */ + @Test + public void testStartup6() { + startUp(TransportProtocol.UDP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + Assert.fail(); + } + } + + /** + * Tests correct provider shutdown + */ + @Test + public void testShutdown() { + startUp(TransportProtocol.TCP); + provider.setConfiguration(config); + provider.setSwitchConnectionHandler(handler); + try { + Assert.assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + Assert.assertTrue("Failed to stop", provider.shutdown().get(5 * WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + e.printStackTrace(); + } + } + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java index d456332b..965e299b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/DeserializationFactoryTest.java @@ -1,56 +1,56 @@ -/* - * Copyright (c) 2014 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 static org.junit.Assert.assertEquals; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class DeserializationFactoryTest { - - /** - * Test deserializer lookup & deserialization - */ - @Test - public void test() { - DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); - registry.init(); - DeserializationFactory factory = new DeserializationFactory(); - factory.setRegistry(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeByte(0); - buffer.writeShort(EncodeConstants.OFHEADER_SIZE); - buffer.writeInt(1234); - factory.deserialize(buffer, EncodeConstants.OF13_VERSION_ID); - assertEquals("Deserialization failed", 0, buffer.readableBytes()); - } - - /** - * Test deserializer lookup & deserialization - */ - @Test(expected=NullPointerException.class) - public void testNotExistingDeserializer() { - DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); - registry.init(); - DeserializationFactory factory = new DeserializationFactory(); - factory.setRegistry(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - buffer.writeByte(0); - buffer.writeShort(EncodeConstants.OFHEADER_SIZE); - buffer.writeInt(1234); - factory.deserialize(buffer, (short) 0); - } +/* + * Copyright (c) 2014 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 static org.junit.Assert.assertEquals; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class DeserializationFactoryTest { + + /** + * Test deserializer lookup & deserialization + */ + @Test + public void test() { + DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); + registry.init(); + DeserializationFactory factory = new DeserializationFactory(); + factory.setRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeByte(0); + buffer.writeShort(EncodeConstants.OFHEADER_SIZE); + buffer.writeInt(1234); + factory.deserialize(buffer, EncodeConstants.OF13_VERSION_ID); + assertEquals("Deserialization failed", 0, buffer.readableBytes()); + } + + /** + * Test deserializer lookup & deserialization + */ + @Test(expected=NullPointerException.class) + public void testNotExistingDeserializer() { + DeserializerRegistryImpl registry = new DeserializerRegistryImpl(); + registry.init(); + DeserializationFactory factory = new DeserializationFactory(); + factory.setRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + buffer.writeByte(0); + buffer.writeShort(EncodeConstants.OFHEADER_SIZE); + buffer.writeInt(1234); + factory.deserialize(buffer, (short) 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java index fb65cee6..65395c16 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/TypeToClassMapInitializerTest.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2014 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 static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; - -/** - * @author michal.polkorab - * - */ -public class TypeToClassMapInitializerTest { - - private Map> messageClassMap; - - /** - * Tests correct map initialization - */ - @Test - public void test() { - messageClassMap = new HashMap<>(); - TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap); - short version = EncodeConstants.OF10_VERSION_ID; - assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); - assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); - assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); - assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); - assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); - assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); - assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); - assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); - assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); - assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); - assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 17))); - assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 19))); - assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); - version = EncodeConstants.OF13_VERSION_ID; - assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); - assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); - assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); - assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); - assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); - assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); - assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); - assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); - assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); - assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); - assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 19))); - assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); - assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 23))); - assertEquals("Wrong class", RoleRequestOutput.class, messageClassMap.get(new TypeToClassKey(version, 25))); - assertEquals("Wrong class", GetAsyncOutput.class, messageClassMap.get(new TypeToClassKey(version, 27))); - } +/* + * Copyright (c) 2014 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 static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.util.TypeToClassKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.RoleRequestOutput; + +/** + * @author michal.polkorab + * + */ +public class TypeToClassMapInitializerTest { + + private Map> messageClassMap; + + /** + * Tests correct map initialization + */ + @Test + public void test() { + messageClassMap = new HashMap<>(); + TypeToClassMapInitializer.initializeTypeToClassMap(messageClassMap); + short version = EncodeConstants.OF10_VERSION_ID; + assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); + assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); + assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); + assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); + assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); + assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); + assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); + assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); + assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); + assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 17))); + assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 19))); + assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); + version = EncodeConstants.OF13_VERSION_ID; + assertEquals("Wrong class", HelloMessage.class, messageClassMap.get(new TypeToClassKey(version, 0))); + assertEquals("Wrong class", ErrorMessage.class, messageClassMap.get(new TypeToClassKey(version, 1))); + assertEquals("Wrong class", EchoRequestMessage.class, messageClassMap.get(new TypeToClassKey(version, 2))); + assertEquals("Wrong class", EchoOutput.class, messageClassMap.get(new TypeToClassKey(version, 3))); + assertEquals("Wrong class", ExperimenterMessage.class, messageClassMap.get(new TypeToClassKey(version, 4))); + assertEquals("Wrong class", GetFeaturesOutput.class, messageClassMap.get(new TypeToClassKey(version, 6))); + assertEquals("Wrong class", GetConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 8))); + assertEquals("Wrong class", PacketInMessage.class, messageClassMap.get(new TypeToClassKey(version, 10))); + assertEquals("Wrong class", FlowRemovedMessage.class, messageClassMap.get(new TypeToClassKey(version, 11))); + assertEquals("Wrong class", PortStatusMessage.class, messageClassMap.get(new TypeToClassKey(version, 12))); + assertEquals("Wrong class", MultipartReplyMessage.class, messageClassMap.get(new TypeToClassKey(version, 19))); + assertEquals("Wrong class", BarrierOutput.class, messageClassMap.get(new TypeToClassKey(version, 21))); + assertEquals("Wrong class", GetQueueConfigOutput.class, messageClassMap.get(new TypeToClassKey(version, 23))); + assertEquals("Wrong class", RoleRequestOutput.class, messageClassMap.get(new TypeToClassKey(version, 25))); + assertEquals("Wrong class", GetAsyncOutput.class, messageClassMap.get(new TypeToClassKey(version, 27))); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java index ac167642..b05730f2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactoryTest.java @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2014 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 static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterMessageFactoryTest { - - @Mock DeserializerRegistry registry; - @Mock OFDeserializer deserializer; - @Mock ExperimenterMessage message; - - /** - * Initializes mocks - */ - @Before - public void startUp() { - MockitoAnnotations.initMocks(this); - } - - /** - * Test deserializer lookup correctness - */ - @Test - public void test() { - when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer); - when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message); - - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10"); - ExperimenterMessageFactory factory = new ExperimenterMessageFactory(); - factory.injectDeserializerRegistry(registry); - ExperimenterMessage deserializedMessage = factory.deserialize(buffer); - Assert.assertEquals("Wrong return value", message, deserializedMessage); - Assert.assertEquals("ByteBuf index moved", 0, buffer.readerIndex()); - } +/* + * Copyright (c) 2014 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 static org.mockito.Matchers.any; +import static org.mockito.Mockito.when; +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessage; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterMessageFactoryTest { + + @Mock DeserializerRegistry registry; + @Mock OFDeserializer deserializer; + @Mock ExperimenterMessage message; + + /** + * Initializes mocks + */ + @Before + public void startUp() { + MockitoAnnotations.initMocks(this); + } + + /** + * Test deserializer lookup correctness + */ + @Test + public void test() { + when(registry.getDeserializer(any(ExperimenterIdDeserializerKey.class))).thenReturn(deserializer); + when(deserializer.deserialize(any(ByteBuf.class))).thenReturn(message); + + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 02 03 00 00 00 10"); + ExperimenterMessageFactory factory = new ExperimenterMessageFactory(); + factory.injectDeserializerRegistry(registry); + ExperimenterMessage deserializedMessage = factory.deserialize(buffer); + Assert.assertEquals("Wrong return value", message, deserializedMessage); + Assert.assertEquals("ByteBuf index moved", 0, buffer.readerIndex()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java index d5a1c779..0e8813ea 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsReplyMessageFactoryTest.java @@ -1,317 +1,317 @@ -/* - * 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.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; -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.SetVlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsReplyMessageFactoryTest { - - private OFDeserializer statsFactory; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - statsFactory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 17, MultipartReplyMessage.class)); - } - - /** - * Testing OF10StatsReplyMessageFactory (Desc) for correct deserialization - */ - @Test - public void testDesc() { - final int DESC_STR_LEN = 256; - final int SERIAL_NUM_LEN = 32; - ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); - - String mfrDesc = "Manufacturer description"; - byte[] mfrDescBytes = new byte[256]; - mfrDescBytes = mfrDesc.getBytes(); - bb.writeBytes(mfrDescBytes); - bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); - - String hwDesc = "Hardware description"; - byte[] hwDescBytes = new byte[256]; - hwDescBytes = hwDesc.getBytes(); - bb.writeBytes(hwDescBytes); - bb.writeZero(DESC_STR_LEN - hwDescBytes.length); - - String swDesc = "Software description"; - byte[] swDescBytes = new byte[256]; - swDescBytes = swDesc.getBytes(); - bb.writeBytes(swDescBytes); - bb.writeZero(DESC_STR_LEN - swDescBytes.length); - - String serialNum = "SN0123456789"; - byte[] serialNumBytes = new byte[32]; - serialNumBytes = serialNum.getBytes(); - bb.writeBytes(serialNumBytes); - bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); - - String dpDesc = "switch3 in room 3120"; - byte[] dpDescBytes = new byte[256]; - dpDescBytes = dpDesc.getBytes(); - bb.writeBytes(dpDescBytes); - bb.writeZero(DESC_STR_LEN - dpDescBytes.length); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); - MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyDesc message = messageCase.getMultipartReplyDesc(); - 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()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Flow) for correct deserialization - */ - @Test - public void testFlow() { - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 68 01 00 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " - + "00 00 00 02 00 00 00 03 00 04 00 05 00 06 00 00 00 00 00 00 " - + "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 " - + "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); - MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); - Assert.assertEquals("Wrong tableId", 1, message.getFlowStats().get(0).getTableId().intValue()); - Assert.assertEquals("Wrong durationSec", 2, message.getFlowStats().get(0).getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 3, message.getFlowStats().get(0).getDurationNsec().intValue()); - Assert.assertEquals("Wrong priority", 4, message.getFlowStats().get(0).getPriority().intValue()); - Assert.assertEquals("Wrong idleTimeOut", 5, message.getFlowStats().get(0).getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeOut", 6, message.getFlowStats().get(0).getHardTimeout().intValue()); - Assert.assertEquals("Wrong cookie", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), - message.getFlowStats().get(0).getCookie()); - Assert.assertEquals("Wrong packetCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), - message.getFlowStats().get(0).getPacketCount()); - Assert.assertEquals("Wrong byteCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), - message.getFlowStats().get(0).getByteCount()); - Action action1 = message.getFlowStats().get(0).getAction().get(0); - Assert.assertEquals("Wrong action type", Output.class, action1.getType()); - Assert.assertEquals("Wrong action port", 1, action1.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Assert.assertEquals("Wrong action port", 2, action1.getAugmentation(MaxLengthAction.class) - .getMaxLength().intValue()); - Action action2 = message.getFlowStats().get(0).getAction().get(1); - Assert.assertEquals("Wrong action type", SetVlanVid.class, action2.getType()); - Assert.assertEquals("Wrong action port", 3, action2.getAugmentation(VlanVidAction.class) - .getVlanVid().intValue()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Aggregate) for correct deserialization - */ - @Test - public void testAggregate() { - ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 " - + "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); - MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); - Assert.assertEquals("Wrong packet-count", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), - message.getPacketCount()); - Assert.assertEquals("Wrong byte-count", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), - message.getByteCount()); - Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Table) for correct deserialization - */ - @Test - public void testTable() { - ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 " - + "08 00 00 00 4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00 00 00 00 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " - + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyTable message = messageCase.getMultipartReplyTable(); - Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue()); - Assert.assertEquals("Wrong name", "JAMES BOND", message.getTableStats().get(0).getName()); - Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, false, false, false, false, - false, false, false), message.getTableStats().get(0).getWildcards()); - Assert.assertEquals("Wrong src-mask", 32, message.getTableStats().get(0).getNwSrcMask().intValue()); - Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue()); - Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue()); - Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); - Assert.assertEquals("Wrong lookupCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getTableStats().get(0).getLookupCount()); - Assert.assertEquals("Wrong matchedCount", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}), - message.getTableStats().get(0).getMatchedCount()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Port) for correct deserialization - */ - @Test - public void testPort() { - ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 " - + "00 FF 00 00 00 00 00 00 " - + "FF 01 01 01 01 01 01 01 FF 02 02 02 02 02 02 02 " - + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " - + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " - + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " - + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " - + "FF 02 03 02 03 02 03 02"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); - Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); - Assert.assertEquals("Wrong rxPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), - message.getPortStats().get(0).getRxPackets()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), - message.getPortStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong rxBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxBytes()); - Assert.assertEquals("Wrong txBytes", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong rxDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxDropped()); - Assert.assertEquals("Wrong txDropped", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getTxDropped()); - Assert.assertEquals("Wrong rxErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxErrors()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getTxErrors()); - Assert.assertEquals("Wrong rxFrameErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxFrameErr()); - Assert.assertEquals("Wrong rxOverErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxOverErr()); - Assert.assertEquals("Wrong rxCrcErr", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getRxCrcErr()); - Assert.assertEquals("Wrong collisions", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getPortStats().get(0).getCollisions()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - - /** - * Testing OF10StatsReplyMessageFactory (Queue) for correct deserialization - */ - @Test - public void testQueue() { - ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 " - + "00 FF 00 00 00 00 00 10 " - + "FF 02 03 02 03 02 03 02 " - + "FF 02 02 02 02 02 02 02 " - + "FF 02 03 02 03 02 03 02"); - - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); - 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getQueueStats().get(0).getTxBytes()); - Assert.assertEquals("Wrong txPackets", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), - message.getQueueStats().get(0).getTxPackets()); - Assert.assertEquals("Wrong txErrors", - new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), - message.getQueueStats().get(0).getTxErrors()); - Assert.assertTrue("Unread data", bb.readableBytes() == 0); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; + +import io.netty.buffer.ByteBuf; + +import java.math.BigInteger; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaxLengthAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidAction; +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.SetVlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats._case.MultipartReplyPortStats; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue._case.MultipartReplyQueue; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsReplyMessageFactoryTest { + + private OFDeserializer statsFactory; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + statsFactory = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 17, MultipartReplyMessage.class)); + } + + /** + * Testing OF10StatsReplyMessageFactory (Desc) for correct deserialization + */ + @Test + public void testDesc() { + final int DESC_STR_LEN = 256; + final int SERIAL_NUM_LEN = 32; + ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); + + String mfrDesc = "Manufacturer description"; + byte[] mfrDescBytes = new byte[256]; + mfrDescBytes = mfrDesc.getBytes(); + bb.writeBytes(mfrDescBytes); + bb.writeZero(DESC_STR_LEN - mfrDescBytes.length); + + String hwDesc = "Hardware description"; + byte[] hwDescBytes = new byte[256]; + hwDescBytes = hwDesc.getBytes(); + bb.writeBytes(hwDescBytes); + bb.writeZero(DESC_STR_LEN - hwDescBytes.length); + + String swDesc = "Software description"; + byte[] swDescBytes = new byte[256]; + swDescBytes = swDesc.getBytes(); + bb.writeBytes(swDescBytes); + bb.writeZero(DESC_STR_LEN - swDescBytes.length); + + String serialNum = "SN0123456789"; + byte[] serialNumBytes = new byte[32]; + serialNumBytes = serialNum.getBytes(); + bb.writeBytes(serialNumBytes); + bb.writeZero(SERIAL_NUM_LEN - serialNumBytes.length); + + String dpDesc = "switch3 in room 3120"; + byte[] dpDescBytes = new byte[256]; + dpDescBytes = dpDesc.getBytes(); + bb.writeBytes(dpDescBytes); + bb.writeZero(DESC_STR_LEN - dpDescBytes.length); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); + MultipartReplyDescCase messageCase = (MultipartReplyDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyDesc message = messageCase.getMultipartReplyDesc(); + 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()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Flow) for correct deserialization + */ + @Test + public void testFlow() { + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 68 01 00 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + + "00 00 00 02 00 00 00 03 00 04 00 05 00 06 00 00 00 00 00 00 " + + "FF 01 02 03 04 05 06 07 FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 " + + "00 00 00 08 00 01 00 02 00 01 00 08 00 03 00 00"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + Assert.assertEquals("Wrong tableId", 1, message.getFlowStats().get(0).getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 2, message.getFlowStats().get(0).getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 3, message.getFlowStats().get(0).getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 4, message.getFlowStats().get(0).getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 5, message.getFlowStats().get(0).getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 6, message.getFlowStats().get(0).getHardTimeout().intValue()); + Assert.assertEquals("Wrong cookie", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + message.getFlowStats().get(0).getCookie()); + Assert.assertEquals("Wrong packetCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + message.getFlowStats().get(0).getPacketCount()); + Assert.assertEquals("Wrong byteCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), + message.getFlowStats().get(0).getByteCount()); + Action action1 = message.getFlowStats().get(0).getAction().get(0); + Assert.assertEquals("Wrong action type", Output.class, action1.getType()); + Assert.assertEquals("Wrong action port", 1, action1.getAugmentation(PortAction.class) + .getPort().getValue().intValue()); + Assert.assertEquals("Wrong action port", 2, action1.getAugmentation(MaxLengthAction.class) + .getMaxLength().intValue()); + Action action2 = message.getFlowStats().get(0).getAction().get(1); + Assert.assertEquals("Wrong action type", SetVlanVid.class, action2.getType()); + Assert.assertEquals("Wrong action port", 3, action2.getAugmentation(VlanVidAction.class) + .getVlanVid().intValue()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Aggregate) for correct deserialization + */ + @Test + public void testAggregate() { + ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 " + + "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue()); + MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate(); + Assert.assertEquals("Wrong packet-count", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}), + message.getPacketCount()); + Assert.assertEquals("Wrong byte-count", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20}), + message.getByteCount()); + Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Table) for correct deserialization + */ + @Test + public void testTable() { + ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 " + + "08 00 00 00 4A 41 4D 45 53 20 42 4F 4E 44 00 00 00 00 00 00 00 00 00 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " + + "00 00 00 30 00 00 00 10 FF 01 01 01 01 01 01 01 FF 01 01 01 01 01 01 00"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + + MultipartReplyTableCase messageCase = (MultipartReplyTableCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTable message = messageCase.getMultipartReplyTable(); + Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue()); + Assert.assertEquals("Wrong name", "JAMES BOND", message.getTableStats().get(0).getName()); + Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, false, false, false, false, false, + false, false, false), message.getTableStats().get(0).getWildcards()); + Assert.assertEquals("Wrong src-mask", 32, message.getTableStats().get(0).getNwSrcMask().intValue()); + Assert.assertEquals("Wrong dst-mask", 32, message.getTableStats().get(0).getNwDstMask().intValue()); + Assert.assertEquals("Wrong max-entries", 48, message.getTableStats().get(0).getMaxEntries().longValue()); + Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue()); + Assert.assertEquals("Wrong lookupCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + message.getTableStats().get(0).getLookupCount()); + Assert.assertEquals("Wrong matchedCount", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}), + message.getTableStats().get(0).getMatchedCount()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Port) for correct deserialization + */ + @Test + public void testPort() { + ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 " + + "00 FF 00 00 00 00 00 00 " + + "FF 01 01 01 01 01 01 01 FF 02 02 02 02 02 02 02 " + + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + + "FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 FF 02 03 02 03 02 03 02 " + + "FF 02 03 02 03 02 03 02"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyPortStatsCase messageCase = (MultipartReplyPortStatsCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortStats message = messageCase.getMultipartReplyPortStats(); + Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue()); + Assert.assertEquals("Wrong rxPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), + message.getPortStats().get(0).getRxPackets()); + Assert.assertEquals("Wrong txPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + message.getPortStats().get(0).getTxPackets()); + Assert.assertEquals("Wrong rxBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxBytes()); + Assert.assertEquals("Wrong txBytes", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getTxBytes()); + Assert.assertEquals("Wrong rxDropped", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxDropped()); + Assert.assertEquals("Wrong txDropped", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getTxDropped()); + Assert.assertEquals("Wrong rxErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxErrors()); + Assert.assertEquals("Wrong txErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getTxErrors()); + Assert.assertEquals("Wrong rxFrameErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxFrameErr()); + Assert.assertEquals("Wrong rxOverErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxOverErr()); + Assert.assertEquals("Wrong rxCrcErr", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getRxCrcErr()); + Assert.assertEquals("Wrong collisions", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getPortStats().get(0).getCollisions()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + + /** + * Testing OF10StatsReplyMessageFactory (Queue) for correct deserialization + */ + @Test + public void testQueue() { + ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 " + + "00 FF 00 00 00 00 00 10 " + + "FF 02 03 02 03 02 03 02 " + + "FF 02 02 02 02 02 02 02 " + + "FF 02 03 02 03 02 03 02"); + + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyQueueCase messageCase = (MultipartReplyQueueCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyQueue message = messageCase.getMultipartReplyQueue(); + 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(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getQueueStats().get(0).getTxBytes()); + Assert.assertEquals("Wrong txPackets", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), + message.getQueueStats().get(0).getTxPackets()); + Assert.assertEquals("Wrong txErrors", + new BigInteger(1, new byte[]{(byte) 0xFF, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), + message.getQueueStats().get(0).getTxErrors()); + Assert.assertTrue("Unread data", bb.readableBytes() == 0); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java index d293efcb..0c9707ca 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/VendorMessageFactoryTest.java @@ -1,48 +1,48 @@ -/* - * Copyright (c) 2014 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.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.util.ByteBufUtils; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class VendorMessageFactoryTest { - - @Mock DeserializerRegistry registry; - @Mock ExperimenterMessageFactory deserializer; - - /** - * Tests {@link VendorMessageFactory#deserialize(ByteBuf)} - */ - @Test - public void test() { - Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(deserializer); - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("04 04 00 10 01 02 03 04 FF FF FF FF 80 00 00 00"); - VendorMessageFactory factory = new VendorMessageFactory(); - factory.injectDeserializerRegistry(registry); - factory.deserialize(buffer); - - Mockito.verify(deserializer, Mockito.times(1)).deserialize(buffer); - Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); - } +/* + * Copyright (c) 2014 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.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.util.ByteBufUtils; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class VendorMessageFactoryTest { + + @Mock DeserializerRegistry registry; + @Mock ExperimenterMessageFactory deserializer; + + /** + * Tests {@link VendorMessageFactory#deserialize(ByteBuf)} + */ + @Test + public void test() { + Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(deserializer); + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("04 04 00 10 01 02 03 04 FF FF FF FF 80 00 00 00"); + VendorMessageFactory factory = new VendorMessageFactory(); + factory.injectDeserializerRegistry(registry); + factory.deserialize(buffer); + + Mockito.verify(deserializer, Mockito.times(1)).deserialize(buffer); + Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java index 6e4de3f9..28fecce1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyExperimenterTest.java @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class MultipartReplyExperimenterTest { - - @Mock DeserializerRegistry registry; - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyExperimenter() { - factory.injectDeserializerRegistry(registry); - ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " - + "00 00 00 01 00 00 00 02"); // expID, expType - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - - Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class MultipartReplyExperimenterTest { + + @Mock DeserializerRegistry registry; + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyExperimenter() { + factory.injectDeserializerRegistry(registry); + ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + + "00 00 00 01 00 00 00 02"); // expID, expType + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + + Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java index ecb206e4..d1c5e35f 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyFlowTest.java @@ -1,136 +1,136 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; - -import java.math.BigInteger; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyFlowTest { - - private OFDeserializer factory; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - DeserializerRegistry registry = new DeserializerRegistryImpl(); - registry.init(); - factory = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class)); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testEmptyMultipartReplyFlowBody(){ - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); - Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyFlowBody(){ - ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+ - // first flow stat - "00 48 08 00 "+ // length, tableId, padding - "00 00 00 09 "+//durationSec - "00 00 00 07 "+//durationNsec - "00 0C 00 0E 00 0F 00 1F "+//priority, idleTimeout, hardTimeout, flags - "00 00 00 00 "+//pad_02 - "FF 01 01 01 01 01 01 01 "+//cookie - "EF 01 01 01 01 01 01 01 "+//packetCount - "7F 01 01 01 01 01 01 01 "+//byteCount - "00 01 00 04 00 00 00 00 "+//empty match - "00 01 00 08 06 00 00 00 "+ - "00 01 00 08 06 00 00 00 "+ - // second flow stat - "00 48 08 00 "+ // length, tableId, padding - "00 00 00 09 "+//durationSec - "00 00 00 07 "+//durationNsec - "00 0C 00 0E 00 0F 00 00 "+//priority, idleTimeout, hardTimeout, flags - "00 00 00 00 "+//pad_02 - "FF 01 01 01 01 01 01 01 "+//cookie - "EF 01 01 01 01 01 01 01 "+//packetCount - "7F 01 01 01 01 01 01 01 "+//byteCount - "00 01 00 04 00 00 00 00 "+//empty match - "00 01 00 08 06 00 00 00 "+ - "00 01 00 08 06 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); - Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size()); - FlowStats flowStats1 = message.getFlowStats().get(0); - Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); - Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); - Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); - Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); - Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags()); - Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01}), flowStats1.getCookie()); - Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); - Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); - Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); - flowStats1 = message.getFlowStats().get(1); - Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); - Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); - Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); - Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); - Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); - Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); - Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags()); - Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01}), flowStats1.getCookie()); - Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); - Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); - Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; + +import java.math.BigInteger; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyFlowTest { + + private OFDeserializer factory; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + DeserializerRegistry registry = new DeserializerRegistryImpl(); + registry.init(); + factory = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 19, MultipartReplyMessage.class)); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyFlowBody(){ + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyFlowBody(){ + ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+ + // first flow stat + "00 48 08 00 "+ // length, tableId, padding + "00 00 00 09 "+//durationSec + "00 00 00 07 "+//durationNsec + "00 0C 00 0E 00 0F 00 1F "+//priority, idleTimeout, hardTimeout, flags + "00 00 00 00 "+//pad_02 + "FF 01 01 01 01 01 01 01 "+//cookie + "EF 01 01 01 01 01 01 01 "+//packetCount + "7F 01 01 01 01 01 01 01 "+//byteCount + "00 01 00 04 00 00 00 00 "+//empty match + "00 01 00 08 06 00 00 00 "+ + "00 01 00 08 06 00 00 00 "+ + // second flow stat + "00 48 08 00 "+ // length, tableId, padding + "00 00 00 09 "+//durationSec + "00 00 00 07 "+//durationNsec + "00 0C 00 0E 00 0F 00 00 "+//priority, idleTimeout, hardTimeout, flags + "00 00 00 00 "+//pad_02 + "FF 01 01 01 01 01 01 01 "+//cookie + "EF 01 01 01 01 01 01 01 "+//packetCount + "7F 01 01 01 01 01 01 01 "+//byteCount + "00 01 00 04 00 00 00 00 "+//empty match + "00 01 00 08 06 00 00 00 "+ + "00 01 00 08 06 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyFlow message = messageCase.getMultipartReplyFlow(); + Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size()); + FlowStats flowStats1 = message.getFlowStats().get(0); + Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); + Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags()); + Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01}), flowStats1.getCookie()); + Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); + Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); + Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); + flowStats1 = message.getFlowStats().get(1); + Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue()); + Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue()); + Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue()); + Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue()); + Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue()); + Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue()); + Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags()); + Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[]{(byte) 0xFF, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01}), flowStats1.getCookie()); + Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[]{(byte) 0xEF, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getPacketCount()); + Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[]{(byte) 0x7F, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01}), flowStats1.getByteCount()); + Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java index 906d87fd..5ac385c7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyGroupFeaturesTest.java @@ -1,104 +1,104 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyGroupFeaturesTest { - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyGroupFeatures() { - ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ - "00 00 00 0F "+// types - "00 00 00 0F "+// capabilities - "00 00 00 01 "+// max groups - "00 00 00 02 "+// max groups - "00 00 00 03 "+// max groups - "00 00 00 04 "+// max groups - "0F FF 98 01 "+// actions bitmap (all actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00"// actions bitmap (no actions included) - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyGroupFeaturesCase messageCase = - (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); - Assert.assertEquals("Wrong group types", new GroupTypes(true, true, true, true), message.getTypes()); - Assert.assertEquals("Wrong capabilities", new GroupCapabilities(true, true, true, true), - message.getCapabilities()); - Assert.assertEquals("Wrong max groups", 1, message.getMaxGroups().get(0).intValue()); - Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue()); - Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue()); - Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue()); - Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true, - true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0)); - Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1)); - Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2)); - Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3)); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - * (with different group types and capabilities) - */ - @Test - public void testMultipartReplyGroupFeatures2() { - ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ - "00 00 00 00 "+// types - "00 00 00 00 "+// capabilities - "00 00 00 01 "+// max groups - "00 00 00 02 "+// max groups - "00 00 00 03 "+// max groups - "00 00 00 04 "+// max groups - "00 00 00 00 "+// actions bitmap (all actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00 "+// actions bitmap (no actions included) - "00 00 00 00"// actions bitmap (no actions included) - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyGroupFeaturesCase messageCase = - (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); - Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes()); - Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), - message.getCapabilities()); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyGroupFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyGroupFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ + "00 00 00 0F "+// types + "00 00 00 0F "+// capabilities + "00 00 00 01 "+// max groups + "00 00 00 02 "+// max groups + "00 00 00 03 "+// max groups + "00 00 00 04 "+// max groups + "0F FF 98 01 "+// actions bitmap (all actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00"// actions bitmap (no actions included) + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyGroupFeaturesCase messageCase = + (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); + Assert.assertEquals("Wrong group types", new GroupTypes(true, true, true, true), message.getTypes()); + Assert.assertEquals("Wrong capabilities", new GroupCapabilities(true, true, true, true), + message.getCapabilities()); + Assert.assertEquals("Wrong max groups", 1, message.getMaxGroups().get(0).intValue()); + Assert.assertEquals("Wrong max groups", 2, message.getMaxGroups().get(1).intValue()); + Assert.assertEquals("Wrong max groups", 3, message.getMaxGroups().get(2).intValue()); + Assert.assertEquals("Wrong max groups", 4, message.getMaxGroups().get(3).intValue()); + Assert.assertEquals("Wrong actions bitmap", new ActionType(true, true, true, true, false, true, true, true, true, + true, true, true, true, true, true, true, true), message.getActionsBitmap().get(0)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(1)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(2)); + Assert.assertEquals("Wrong actions bitmap", new ActionType(false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), message.getActionsBitmap().get(3)); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + * (with different group types and capabilities) + */ + @Test + public void testMultipartReplyGroupFeatures2() { + ByteBuf bb = BufferHelper.buildBuffer("00 08 00 01 00 00 00 00 "+ + "00 00 00 00 "+// types + "00 00 00 00 "+// capabilities + "00 00 00 01 "+// max groups + "00 00 00 02 "+// max groups + "00 00 00 03 "+// max groups + "00 00 00 04 "+// max groups + "00 00 00 00 "+// actions bitmap (all actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00 "+// actions bitmap (no actions included) + "00 00 00 00"// actions bitmap (no actions included) + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyGroupFeaturesCase messageCase = + (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures(); + Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes()); + Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), + message.getCapabilities()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java index 208bea19..453c755d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyMeterFeaturesTest.java @@ -1,80 +1,80 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -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.protocol.rev130731.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyMeterFeaturesTest { - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyMeterFeatures(){ - ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ - "00 00 00 0A " + // maxMeter - "00 00 00 06 " + // bandTypes - "00 00 00 0F " + // capabilities - "07 08 00 00" // maxBands, maxColor, padding - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); - Assert.assertEquals("Wrong maxMeter", 10, message.getMaxMeter().intValue()); - Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, true), message.getBandTypes()); - Assert.assertEquals("Wrong capabilities", new MeterFlags(true, true, true, true), message.getCapabilities()); - Assert.assertEquals("Wrong maxBands", 7, message.getMaxBands().intValue()); - Assert.assertEquals("Wrong maxColor", 8, message.getMaxColor().intValue()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyMeterFeatures2(){ - ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ - "00 00 00 09 " + // maxMeter - "00 00 00 00 " + // bandTypes - "00 00 00 00 " + // capabilities - "03 04 00 00" // maxBands, maxColor, padding - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); - Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue()); - Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes()); - Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities()); - Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue()); - Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue()); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +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.protocol.rev130731.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyMeterFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyMeterFeatures(){ + ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ + "00 00 00 0A " + // maxMeter + "00 00 00 06 " + // bandTypes + "00 00 00 0F " + // capabilities + "07 08 00 00" // maxBands, maxColor, padding + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); + Assert.assertEquals("Wrong maxMeter", 10, message.getMaxMeter().intValue()); + Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(true, true), message.getBandTypes()); + Assert.assertEquals("Wrong capabilities", new MeterFlags(true, true, true, true), message.getCapabilities()); + Assert.assertEquals("Wrong maxBands", 7, message.getMaxBands().intValue()); + Assert.assertEquals("Wrong maxColor", 8, message.getMaxColor().intValue()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyMeterFeatures2(){ + ByteBuf bb = BufferHelper.buildBuffer("00 0B 00 01 00 00 00 00 "+ + "00 00 00 09 " + // maxMeter + "00 00 00 00 " + // bandTypes + "00 00 00 00 " + // capabilities + "03 04 00 00" // maxBands, maxColor, padding + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures(); + Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue()); + Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes()); + Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities()); + Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue()); + Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java index 139ea08a..f397831d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyPortDescTest.java @@ -1,122 +1,122 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -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.MultipartReplyMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyPortDescTest { - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testEmptyMultipartReplyPortDesc() { - ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); - Assert.assertEquals("Wrong table features size", 0, message.getPorts().size()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyPortDesc() { - ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " + - // first port desc - "00 01 02 03 00 00 00 00 " + // portNo, padding - "08 00 27 00 B0 EB 00 00 " + // mac address, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name - "00 00 00 65 " + //port config - "00 00 00 07 " + //port state - "00 00 00 81 " + //current features - "00 00 FF FF " + //advertised features - "00 00 C1 89 " + //supported features - "00 00 C5 8D " + //peer features - "00 00 00 81 " + //curr speed - "00 00 00 80 " + //max speed - // second port desc - "00 00 00 01 00 00 00 00 " + // portNo, padding - "08 00 27 00 B0 EB 00 00 " + // mac address, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name - "00 00 00 00 " + //port config - "00 00 00 00 " + //port state - "00 00 00 00 " + //current features - "00 00 00 00 " + //advertised features - "00 00 00 00 " + //supported features - "00 00 00 00 " + //peer features - "00 00 00 05 " + //curr speed - "00 00 00 06" //max speed - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); - Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size()); - Ports port = message.getPorts().get(0); - Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue()); - Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); - Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); - Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig()); - Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState()); - Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, - false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures()); - Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, - true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures()); - Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, - false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures()); - Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, - false, false, true, false, false, false, true, true, true), port.getPeerFeatures()); - Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue()); - Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue()); - port = message.getPorts().get(1); - Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue()); - Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); - Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); - Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig()); - Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState()); - Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), port.getCurrentFeatures()); - Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures()); - Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), port.getSupportedFeatures()); - Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, false), port.getPeerFeatures()); - Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue()); - Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue()); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +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.MultipartReplyMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyPortDescTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyPortDesc() { + ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); + Assert.assertEquals("Wrong table features size", 0, message.getPorts().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyPortDesc() { + ByteBuf bb = BufferHelper.buildBuffer("00 0D 00 00 00 00 00 00 " + + // first port desc + "00 01 02 03 00 00 00 00 " + // portNo, padding + "08 00 27 00 B0 EB 00 00 " + // mac address, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name + "00 00 00 65 " + //port config + "00 00 00 07 " + //port state + "00 00 00 81 " + //current features + "00 00 FF FF " + //advertised features + "00 00 C1 89 " + //supported features + "00 00 C5 8D " + //peer features + "00 00 00 81 " + //curr speed + "00 00 00 80 " + //max speed + // second port desc + "00 00 00 01 00 00 00 00 " + // portNo, padding + "08 00 27 00 B0 EB 00 00 " + // mac address, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name + "00 00 00 00 " + //port config + "00 00 00 00 " + //port state + "00 00 00 00 " + //current features + "00 00 00 00 " + //advertised features + "00 00 00 00 " + //supported features + "00 00 00 00 " + //peer features + "00 00 00 05 " + //curr speed + "00 00 00 06" //max speed + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc(); + Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size()); + Ports port = message.getPorts().get(0); + Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); + Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); + Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig()); + Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState()); + Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, + false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures()); + Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, + true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures()); + Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, + false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures()); + Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, + false, false, true, false, false, false, true, true, true), port.getPeerFeatures()); + Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue()); + Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue()); + port = message.getPorts().get(1); + Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue()); + Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:B0:EB"), port.getHwAddr()); + Assert.assertEquals("Wrong portName", "Opendaylight", port.getName()); + Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig()); + Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState()); + Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getCurrentFeatures()); + Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures()); + Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getSupportedFeatures()); + Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, false), port.getPeerFeatures()); + Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue()); + Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java index 64ad0970..2b223ca2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/MultipartReplyTableFeaturesTest.java @@ -1,187 +1,187 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; -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.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.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class MultipartReplyTableFeaturesTest { - - private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testEmptyMultipartReplyTableFeatures() { - ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00"); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); - Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyTableFeatures() { - ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ - // first table feature - "00 40 01 00 00 00 00 00 "+// length, tableId, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ - "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name - "00 00 00 00 00 00 00 01 "+// metadata match - "00 00 00 00 00 00 00 02 "+// metadata write - "00 00 00 00 "+// config - "00 00 00 2A "+// max entries - // second table feature - "00 40 02 00 00 00 00 00 "+// length, tableId, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" - + " 00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name - "00 00 00 00 00 00 00 03 "+// metadata match - "00 00 00 00 00 00 00 04 "+// metadata write - "00 00 00 03 "+// config - "00 00 00 2B" // max entries - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); - Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size()); - TableFeatures feature = message.getTableFeatures().get(0); - Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); - Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); - Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); - Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); - Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); - Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); - feature = message.getTableFeatures().get(1); - Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue()); - Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); - Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 3}, feature.getMetadataMatch()); - Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 4}, feature.getMetadataWrite()); - Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK()); - Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue()); - } - - /** - * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO - */ - @Test - public void testMultipartReplyTableFeatures2() { - ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ - "00 B0 01 00 00 00 00 00 "+// length, tableId, padding - "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ - "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name - "00 00 00 00 00 00 00 01 "+// metadata match - "00 00 00 00 00 00 00 02 "+// metadata write - "00 00 00 00 "+// config - "00 00 00 2A "+// max entries - "00 00 00 04 00 00 00 00 "+ - "00 01 00 04 00 00 00 00 "+ - "00 02 00 08 01 02 03 04 "+ - "00 03 00 07 05 06 07 00 "+ - "00 04 00 04 00 00 00 00 "+ - "00 05 00 04 00 00 00 00 "+ - "00 06 00 04 00 00 00 00 "+ - "00 07 00 04 00 00 00 00 "+ - "00 08 00 04 00 00 00 00 "+ - "00 0A 00 04 00 00 00 00 "+ - "00 0C 00 04 00 00 00 00 "+ - "00 0D 00 04 00 00 00 00 "+ - "00 0E 00 04 00 00 00 00 "+ - "00 0F 00 04 00 00 00 00" - ); - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV13(builtByFactory); - Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); - MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); - MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); - Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size()); - TableFeatures feature = message.getTableFeatures().get(0); - Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); - Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); - Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); - Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); - Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); - Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); - Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, - feature.getTableFeatureProperties().get(0).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, - feature.getTableFeatureProperties().get(1).getType()); - TableFeatureProperties property = feature.getTableFeatureProperties().get(2); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, - property.getType()); - List tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) - .getNextTableIds(); - Assert.assertEquals("Wrong next table id size", 4, tableIds.size()); - Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue()); - property = feature.getTableFeatureProperties().get(3); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, - property.getType()); - tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) - .getNextTableIds(); - Assert.assertEquals("Wrong next table id size", 3, tableIds.size()); - Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue()); - Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, - feature.getTableFeatureProperties().get(4).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, - feature.getTableFeatureProperties().get(5).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, - feature.getTableFeatureProperties().get(6).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, - feature.getTableFeatureProperties().get(7).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, - feature.getTableFeatureProperties().get(8).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, - feature.getTableFeatureProperties().get(9).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, - feature.getTableFeatureProperties().get(10).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, - feature.getTableFeatureProperties().get(11).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, - feature.getTableFeatureProperties().get(12).getType()); - Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, - feature.getTableFeatureProperties().get(13).getType()); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.MultipartReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NextTableRelatedTableFeatureProperty; +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.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.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class MultipartReplyTableFeaturesTest { + + private MultipartReplyMessageFactory factory = new MultipartReplyMessageFactory(); + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testEmptyMultipartReplyTableFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00"); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyTableFeatures() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ + // first table feature + "00 40 01 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ + "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 01 "+// metadata match + "00 00 00 00 00 00 00 02 "+// metadata write + "00 00 00 00 "+// config + "00 00 00 2A "+// max entries + // second table feature + "00 40 02 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" + + " 00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 03 "+// metadata match + "00 00 00 00 00 00 00 04 "+// metadata write + "00 00 00 03 "+// config + "00 00 00 2B" // max entries + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size()); + TableFeatures feature = message.getTableFeatures().get(0); + Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); + feature = message.getTableFeatures().get(1); + Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 3}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 4}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue()); + } + + /** + * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO + */ + @Test + public void testMultipartReplyTableFeatures2() { + ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00 "+ + "00 B0 01 00 00 00 00 00 "+// length, tableId, padding + "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 "+ + "00 00 00 00 00 00 00 00 00 00 00 00 00 "+// name + "00 00 00 00 00 00 00 01 "+// metadata match + "00 00 00 00 00 00 00 02 "+// metadata write + "00 00 00 00 "+// config + "00 00 00 2A "+// max entries + "00 00 00 04 00 00 00 00 "+ + "00 01 00 04 00 00 00 00 "+ + "00 02 00 08 01 02 03 04 "+ + "00 03 00 07 05 06 07 00 "+ + "00 04 00 04 00 00 00 00 "+ + "00 05 00 04 00 00 00 00 "+ + "00 06 00 04 00 00 00 00 "+ + "00 07 00 04 00 00 00 00 "+ + "00 08 00 04 00 00 00 00 "+ + "00 0A 00 04 00 00 00 00 "+ + "00 0C 00 04 00 00 00 00 "+ + "00 0D 00 04 00 00 00 00 "+ + "00 0E 00 04 00 00 00 00 "+ + "00 0F 00 04 00 00 00 00" + ); + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV13(builtByFactory); + Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE()); + MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody(); + MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures(); + Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size()); + TableFeatures feature = message.getTableFeatures().get(0); + Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue()); + Assert.assertEquals("Wrong name", "Opendaylight", feature.getName()); + Assert.assertArrayEquals("Wrong metadata match", new byte[]{0, 0, 0, 0, 0, 0, 0, 1}, feature.getMetadataMatch()); + Assert.assertArrayEquals("Wrong metadata write", new byte[]{0, 0, 0, 0, 0, 0, 0, 2}, feature.getMetadataWrite()); + Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK()); + Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue()); + Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, + feature.getTableFeatureProperties().get(0).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, + feature.getTableFeatureProperties().get(1).getType()); + TableFeatureProperties property = feature.getTableFeatureProperties().get(2); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, + property.getType()); + List tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) + .getNextTableIds(); + Assert.assertEquals("Wrong next table id size", 4, tableIds.size()); + Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue()); + property = feature.getTableFeatureProperties().get(3); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, + property.getType()); + tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class) + .getNextTableIds(); + Assert.assertEquals("Wrong next table id size", 3, tableIds.size()); + Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue()); + Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, + feature.getTableFeatureProperties().get(4).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, + feature.getTableFeatureProperties().get(5).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, + feature.getTableFeatureProperties().get(6).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, + feature.getTableFeatureProperties().get(7).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, + feature.getTableFeatureProperties().get(8).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, + feature.getTableFeatureProperties().get(9).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, + feature.getTableFeatureProperties().get(10).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, + feature.getTableFeatureProperties().get(11).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, + feature.getTableFeatureProperties().get(12).getType()); + Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, + feature.getTableFeatureProperties().get(13).getType()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java index 6ef4153d..0df462fe 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/multipart/OF10StatsReplyExperimenterTest.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class OF10StatsReplyExperimenterTest { - - @Mock DeserializerRegistry registry; - - /** - * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation - */ - @Test - public void test() { - OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory(); - factory.injectDeserializerRegistry(registry); - - ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " - + "00 00 00 01"); // expID - MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); - - BufferHelper.checkHeaderV10(builtByFactory); - Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); - Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); - Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.OF10StatsReplyMessageFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class OF10StatsReplyExperimenterTest { + + @Mock DeserializerRegistry registry; + + /** + * Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation + */ + @Test + public void test() { + OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory(); + factory.injectDeserializerRegistry(registry); + + ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + + "00 00 00 01"); // expID + MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb); + + BufferHelper.checkHeaderV10(builtByFactory); + Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue()); + Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE()); + Mockito.verify(registry, Mockito.times(1)).getDeserializer(Matchers.any(MessageCodeKey.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java index dcfbe924..b7a76b42 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/AbstractInstructionDeserializerTest.java @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2014 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.instruction; - -import io.netty.buffer.ByteBuf; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.util.ByteBufUtils; -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.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class AbstractInstructionDeserializerTest { - - /** - * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different - * instruction types - */ - @Test(expected=IllegalStateException.class) - public void test() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04"); - GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer(); - Instruction instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04"); - instruction = deserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong type", Meter.class, instruction.getType()); - - buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04"); - instruction = deserializer.deserializeHeader(buffer); - // exception expected - } +/* + * Copyright (c) 2014 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.instruction; + +import io.netty.buffer.ByteBuf; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.util.ByteBufUtils; +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.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class AbstractInstructionDeserializerTest { + + /** + * Tests {@link AbstractInstructionDeserializer#deserializeHeader(ByteBuf)} with different + * instruction types + */ + @Test(expected=IllegalStateException.class) + public void test() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 00 04"); + GoToTableInstructionDeserializer deserializer = new GoToTableInstructionDeserializer(); + Instruction instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", GotoTable.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 02 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", WriteMetadata.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 03 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", WriteActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 04 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", ApplyActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 05 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", ClearActions.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 06 00 04"); + instruction = deserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong type", Meter.class, instruction.getType()); + + buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 04"); + instruction = deserializer.deserializeHeader(buffer); + // exception expected + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java index 49b11872..3b464f39 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6ExtHdrDeserializerTest.java @@ -1,49 +1,49 @@ -/* - * Copyright (c) 2014 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.match; - -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.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6ExtHdrDeserializerTest { - - /** - * Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 4E 02 01 FF"); - - buffer.skipBytes(4); // skip XID - OxmIpv6ExtHdrDeserializer deserializer = new OxmIpv6ExtHdrDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", - new Ipv6ExthdrFlags(true, true, true, true, true, true, true, true, true), - entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); - Assert.assertEquals("Wrong entry mask", null, entry.getAugmentation(MaskMatchEntry.class)); - Assert.assertTrue("Unread data", buffer.readableBytes() == 0); - } +/* + * Copyright (c) 2014 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.match; + +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.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrDeserializerTest { + + /** + * Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 4E 02 01 FF"); + + buffer.skipBytes(4); // skip XID + OxmIpv6ExtHdrDeserializer deserializer = new OxmIpv6ExtHdrDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", + new Ipv6ExthdrFlags(true, true, true, true, true, true, true, true, true), + entry.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); + Assert.assertEquals("Wrong entry mask", null, entry.getAugmentation(MaskMatchEntry.class)); + Assert.assertTrue("Unread data", buffer.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java index 9b0d1a4d..2c29dce1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializerTest.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2014 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.match; - -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.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6FlabelDeserializerTest { - - /** - * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 38 04 00 00 00 02"); - - buffer.skipBytes(4); // skip XID - OxmIpv6FlabelDeserializer deserializer = new OxmIpv6FlabelDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, - entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); - } +/* + * Copyright (c) 2014 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.match; + +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.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Flabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6FlabelDeserializerTest { + + /** + * Tests {@link OxmIpv6FlabelDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 38 04 00 00 00 02"); + + buffer.skipBytes(4); // skip XID + OxmIpv6FlabelDeserializer deserializer = new OxmIpv6FlabelDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java index 0cf62839..d0983876 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMetadataDeserializerTest.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2014 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.match; - -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.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMetadataDeserializerTest { - - /** - * Tests {@link OxmMetadataDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 04 08 00 00 00 00 00 00 00 03"); - - buffer.skipBytes(4); // skip XID - OxmMetadataDeserializer deserializer = new OxmMetadataDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", Metadata.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), - entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); - } +/* + * Copyright (c) 2014 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.match; + +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.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataDeserializerTest { + + /** + * Tests {@link OxmMetadataDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 04 08 00 00 00 00 00 00 00 03"); + + buffer.skipBytes(4); // skip XID + OxmMetadataDeserializer deserializer = new OxmMetadataDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Metadata.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), + entry.getAugmentation(MetadataMatchEntry.class).getMetadata()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java index e8a379c7..728260e2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsBosDeserializerTest.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2014 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.match; - -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.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsBosDeserializerTest { - - /** - * Tests {@link OxmMplsBosDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 48 01 00"); - - buffer.skipBytes(4); // skip XID - OxmMplsBosDeserializer deserializer = new OxmMplsBosDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", MplsBos.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", false, entry.getAugmentation(BosMatchEntry.class).isBos()); - } +/* + * Copyright (c) 2014 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.match; + +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.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosDeserializerTest { + + /** + * Tests {@link OxmMplsBosDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 48 01 00"); + + buffer.skipBytes(4); // skip XID + OxmMplsBosDeserializer deserializer = new OxmMplsBosDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsBos.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", false, entry.getAugmentation(BosMatchEntry.class).isBos()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java index b33c8a26..ab3e125e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPbbIsidDeserializerTest.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2014 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.match; - -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.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmPbbIsidDeserializerTest { - - /** - * Tests {@link OxmPbbIsidDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 4A 03 00 00 02"); - - buffer.skipBytes(4); // skip XID - OxmPbbIsidDeserializer deserializer = new OxmPbbIsidDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", PbbIsid.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); - } +/* + * Copyright (c) 2014 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.match; + +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.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidDeserializerTest { + + /** + * Tests {@link OxmPbbIsidDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 4A 03 00 00 02"); + + buffer.skipBytes(4); // skip XID + OxmPbbIsidDeserializer deserializer = new OxmPbbIsidDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", PbbIsid.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, entry.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java index a51cc122..e765ba65 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializerTest.java @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2014 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.match; - -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.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -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.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanVidDeserializerTest { - - /** - * Tests {@link OxmVlanVidDeserializer#deserialize(ByteBuf)} - */ - @Test - public void test() { - ByteBuf buffer = BufferHelper.buildBuffer("80 00 0C 02 20 0A"); - - buffer.skipBytes(4); // skip XID - OxmVlanVidDeserializer deserializer = new OxmVlanVidDeserializer(); - MatchEntries entry = deserializer.deserialize(buffer); - - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", VlanVid.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong entry value", 10, - entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); - Assert.assertEquals("Wrong entry value", false, - entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); - } +/* + * Copyright (c) 2014 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.match; + +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.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +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.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidDeserializerTest { + + /** + * Tests {@link OxmVlanVidDeserializer#deserialize(ByteBuf)} + */ + @Test + public void test() { + ByteBuf buffer = BufferHelper.buildBuffer("80 00 0C 02 20 0A"); + + buffer.skipBytes(4); // skip XID + OxmVlanVidDeserializer deserializer = new OxmVlanVidDeserializer(); + MatchEntries entry = deserializer.deserialize(buffer); + + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", VlanVid.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong entry value", 10, + entry.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); + Assert.assertEquals("Wrong entry value", false, + entry.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java index 28add5c6..3ffbca70 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/SerializationFactoryTest.java @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2014 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 static org.junit.Assert.assertEquals; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; - -/** - * @author michal.polkorab - * - */ -public class SerializationFactoryTest { - - /** - * Test serializer lookup & serialization - */ - @Test - public void test() { - SerializerRegistry registry = new SerializerRegistryImpl(); - registry.init(); - SerializationFactory factory = new SerializationFactory(); - factory.setSerializerTable(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - HelloInputBuilder helloBuilder = new HelloInputBuilder(); - helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - helloBuilder.setXid(123456L); - helloBuilder.setElements(null); - factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, buffer, helloBuilder.build()); - assertEquals("Serialization failed", EncodeConstants.OFHEADER_SIZE, buffer.readableBytes()); - } - - /** - * Test serializer not found scenario - */ - @Test(expected=IllegalStateException.class) - public void testNotExistingSerializer() { - SerializerRegistry registry = new SerializerRegistryImpl(); - registry.init(); - SerializationFactory factory = new SerializationFactory(); - factory.setSerializerTable(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - HelloInputBuilder helloBuilder = new HelloInputBuilder(); - helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - helloBuilder.setXid(123456L); - helloBuilder.setElements(null); - factory.messageToBuffer((short) 0, buffer, helloBuilder.build()); - } +/* + * Copyright (c) 2014 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 static org.junit.Assert.assertEquals; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder; + +/** + * @author michal.polkorab + * + */ +public class SerializationFactoryTest { + + /** + * Test serializer lookup & serialization + */ + @Test + public void test() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + SerializationFactory factory = new SerializationFactory(); + factory.setSerializerTable(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + HelloInputBuilder helloBuilder = new HelloInputBuilder(); + helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + helloBuilder.setXid(123456L); + helloBuilder.setElements(null); + factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, buffer, helloBuilder.build()); + assertEquals("Serialization failed", EncodeConstants.OFHEADER_SIZE, buffer.readableBytes()); + } + + /** + * Test serializer not found scenario + */ + @Test(expected=IllegalStateException.class) + public void testNotExistingSerializer() { + SerializerRegistry registry = new SerializerRegistryImpl(); + registry.init(); + SerializationFactory factory = new SerializationFactory(); + factory.setSerializerTable(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + HelloInputBuilder helloBuilder = new HelloInputBuilder(); + helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + helloBuilder.setXid(123456L); + helloBuilder.setElements(null); + factory.messageToBuffer((short) 0, buffer, helloBuilder.build()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java index 17b3f7ad..77cc5c32 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactoryTest.java @@ -1,129 +1,129 @@ -/* - * Copyright (c) 2014 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.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -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 ExperimenterInputMessageFactoryTest { - - @Mock SerializerRegistry registry; - @Mock OFSerializer serializer; - private OFSerializer expFactory; - - /** - * Sets up ExperimenterInputMessageFactory - * @param real true if setup should use real registry, false when mock is desired - */ - public void startUp(boolean real) { - MockitoAnnotations.initMocks(this); - expFactory = new ExperimenterInputMessageFactory(); - if (real) { - SerializerRegistry realRegistry = new SerializerRegistryImpl(); - realRegistry.init(); - ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(realRegistry); - } else { - ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(registry); - } - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct serializer - * lookup and serialization - * @throws Exception - */ - @Test(expected=IllegalStateException.class) - public void testV10Real() throws Exception { - startUp(true); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setExperimenter(new ExperimenterId(42L)); - ExperimenterInput input = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(input, out); - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct serializer - * lookup and serialization - * @throws Exception - */ - @Test(expected=IllegalStateException.class) - public void testV13Real() throws Exception { - startUp(true); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setExperimenter(new ExperimenterId(42L)); - ExperimenterInput input = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(input, out); - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct serializer - * lookup and serialization - * @throws Exception - */ - @Test - public void testV10() throws Exception { - startUp(false); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setExperimenter(new ExperimenterId(42L)); - ExperimenterInput input = builder.build(); - - Mockito.when(registry.getSerializer( - (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(input, out); - } - - /** - * Testing of {@link ExperimenterInputMessageFactory} for correct serializer - * lookup and serialization - * @throws Exception - */ - @Test - public void testV13() throws Exception { - startUp(false); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setExperimenter(new ExperimenterId(42L)); - ExperimenterInput input = builder.build(); - - Mockito.when(registry.getSerializer( - (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - expFactory.serialize(input, out); - } +/* + * Copyright (c) 2014 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.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +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 ExperimenterInputMessageFactoryTest { + + @Mock SerializerRegistry registry; + @Mock OFSerializer serializer; + private OFSerializer expFactory; + + /** + * Sets up ExperimenterInputMessageFactory + * @param real true if setup should use real registry, false when mock is desired + */ + public void startUp(boolean real) { + MockitoAnnotations.initMocks(this); + expFactory = new ExperimenterInputMessageFactory(); + if (real) { + SerializerRegistry realRegistry = new SerializerRegistryImpl(); + realRegistry.init(); + ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(realRegistry); + } else { + ((SerializerRegistryInjector) expFactory).injectSerializerRegistry(registry); + } + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test(expected=IllegalStateException.class) + public void testV10Real() throws Exception { + startUp(true); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test(expected=IllegalStateException.class) + public void testV13Real() throws Exception { + startUp(true); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test + public void testV10() throws Exception { + startUp(false); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + Mockito.when(registry.getSerializer( + (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } + + /** + * Testing of {@link ExperimenterInputMessageFactory} for correct serializer + * lookup and serialization + * @throws Exception + */ + @Test + public void testV13() throws Exception { + startUp(false); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setExperimenter(new ExperimenterId(42L)); + ExperimenterInput input = builder.build(); + + Mockito.when(registry.getSerializer( + (ExperimenterIdSerializerKey) Matchers.any())).thenReturn(serializer); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + expFactory.serialize(input, out); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java index 9e38a5c6..cfb64acc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/OF10StatsRequestInputFactoryTest.java @@ -1,303 +1,303 @@ -/* - * 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.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsRequestInputFactoryTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Testing OF10StatsRequestInputFactory (Desc) for correct serialization - * @throws Exception - */ - @Test - public void testDesc() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPDESC); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder(); - MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder(); - caseBuilder.setMultipartRequestDesc(descBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 12); - Assert.assertEquals("Wrong type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Flow) for correct serialization - * @throws Exception - */ - @Test - public void testFlow() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPFLOW); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); - MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); - MatchV10Builder matchBuilder = new MatchV10Builder(); - matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, - true, true, true, true)); - matchBuilder.setNwSrcMask((short) 8); - matchBuilder.setNwDstMask((short) 16); - matchBuilder.setInPort(51); - matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); - matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); - matchBuilder.setDlVlan(52); - matchBuilder.setDlVlanPcp((short) 53); - matchBuilder.setDlType(54); - matchBuilder.setNwTos((short) 55); - matchBuilder.setNwProto((short) 56); - matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); - matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); - matchBuilder.setTpSrc(57); - matchBuilder.setTpDst(58); - flowBuilder.setMatchV10(matchBuilder.build()); - flowBuilder.setTableId((short) 1); - flowBuilder.setOutPort(42L); - caseBuilder.setMultipartRequestFlow(flowBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 56); - Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong wildcards", 3414271, out.readUnsignedInt()); - Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort()); - byte[] dlSrc = new byte[6]; - out.readBytes(dlSrc); - Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc)); - byte[] dlDst = new byte[6]; - out.readBytes(dlDst); - Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst)); - Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort()); - Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort()); - Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte()); - Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte()); - out.skipBytes(2); - Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt()); - Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt()); - Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort()); - Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort()); - Assert.assertEquals("Wrong table-id", 1, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong out-port", 42, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Aggregate) for correct serialization - * @throws Exception - */ - @Test - public void testAggregate() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPAGGREGATE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); - MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); - MatchV10Builder matchBuilder = new MatchV10Builder(); - matchBuilder.setWildcards(new FlowWildcardsV10(false, false, false, false, - false, false, false, false, false, false)); - matchBuilder.setNwSrcMask((short) 32); - matchBuilder.setNwDstMask((short) 32); - matchBuilder.setInPort(51); - matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); - matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); - matchBuilder.setDlVlan(52); - matchBuilder.setDlVlanPcp((short) 53); - matchBuilder.setDlType(54); - matchBuilder.setNwTos((short) 55); - matchBuilder.setNwProto((short) 56); - matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); - matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); - matchBuilder.setTpSrc(57); - matchBuilder.setTpDst(58); - flowBuilder.setMatchV10(matchBuilder.build()); - flowBuilder.setTableId((short) 42); - flowBuilder.setOutPort(6653L); - caseBuilder.setMultipartRequestFlow(flowBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 56); - Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong wildcards", 0, out.readUnsignedInt()); - Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort()); - byte[] dlSrc = new byte[6]; - out.readBytes(dlSrc); - Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc)); - byte[] dlDst = new byte[6]; - out.readBytes(dlDst); - Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst)); - Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort()); - Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort()); - Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte()); - Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte()); - out.skipBytes(2); - Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt()); - Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt()); - Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort()); - Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort()); - Assert.assertEquals("Wrong table-id", 42, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong out-port", 6653, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Table) for correct serialization - * @throws Exception - */ - @Test - public void testTable() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPTABLE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); - MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder(); - caseBuilder.setMultipartRequestTable(tableBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 12); - Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Port) for correct serialization - * @throws Exception - */ - @Test - public void testPort() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPPORTSTATS); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); - MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); - portBuilder.setPortNo(15L); - caseBuilder.setMultipartRequestPortStats(portBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 20); - Assert.assertEquals("Wrong type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort()); - out.skipBytes(6); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing OF10StatsRequestInputFactory (Queue) for correct serialization - * @throws Exception - */ - @Test - public void testQueue() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPQUEUE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); - MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); - queueBuilder.setPortNo(15L); - queueBuilder.setQueueId(16L); - caseBuilder.setMultipartRequestQueue(queueBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 20); - Assert.assertEquals("Wrong type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong queue-id", 16, out.readUnsignedInt()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.serialization.factories; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.v10.grouping.MatchV10Builder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortStatsCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.desc._case.MultipartRequestDescBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.flow._case.MultipartRequestFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.stats._case.MultipartRequestPortStatsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsRequestInputFactoryTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Testing OF10StatsRequestInputFactory (Desc) for correct serialization + * @throws Exception + */ + @Test + public void testDesc() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPDESC); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestDescCaseBuilder caseBuilder = new MultipartRequestDescCaseBuilder(); + MultipartRequestDescBuilder descBuilder = new MultipartRequestDescBuilder(); + caseBuilder.setMultipartRequestDesc(descBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 12); + Assert.assertEquals("Wrong type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Flow) for correct serialization + * @throws Exception + */ + @Test + public void testFlow() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPFLOW); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); + MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, + true, true, true, true)); + matchBuilder.setNwSrcMask((short) 8); + matchBuilder.setNwDstMask((short) 16); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + flowBuilder.setMatchV10(matchBuilder.build()); + flowBuilder.setTableId((short) 1); + flowBuilder.setOutPort(42L); + caseBuilder.setMultipartRequestFlow(flowBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 56); + Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong wildcards", 3414271, out.readUnsignedInt()); + Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort()); + byte[] dlSrc = new byte[6]; + out.readBytes(dlSrc); + Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc)); + byte[] dlDst = new byte[6]; + out.readBytes(dlDst); + Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst)); + Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort()); + Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort()); + Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte()); + Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte()); + out.skipBytes(2); + Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt()); + Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt()); + Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort()); + Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort()); + Assert.assertEquals("Wrong table-id", 1, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong out-port", 42, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Aggregate) for correct serialization + * @throws Exception + */ + @Test + public void testAggregate() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPAGGREGATE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); + MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(false, false, false, false, + false, false, false, false, false, false)); + matchBuilder.setNwSrcMask((short) 32); + matchBuilder.setNwDstMask((short) 32); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + flowBuilder.setMatchV10(matchBuilder.build()); + flowBuilder.setTableId((short) 42); + flowBuilder.setOutPort(6653L); + caseBuilder.setMultipartRequestFlow(flowBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 56); + Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong wildcards", 0, out.readUnsignedInt()); + Assert.assertEquals("Wrong in-port", 51, out.readUnsignedShort()); + byte[] dlSrc = new byte[6]; + out.readBytes(dlSrc); + Assert.assertEquals("Wrong dl-src", "00:01:02:03:04:05", ByteBufUtils.macAddressToString(dlSrc)); + byte[] dlDst = new byte[6]; + out.readBytes(dlDst); + Assert.assertEquals("Wrong dl-dst", "05:04:03:02:01:00", ByteBufUtils.macAddressToString(dlDst)); + Assert.assertEquals("Wrong dl-vlan", 52, out.readUnsignedShort()); + Assert.assertEquals("Wrong dl-vlan-pcp", 53, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong dl-type", 54, out.readUnsignedShort()); + Assert.assertEquals("Wrong nw-tos", 55, out.readUnsignedByte()); + Assert.assertEquals("Wrong nw-proto", 56, out.readUnsignedByte()); + out.skipBytes(2); + Assert.assertEquals("Wrong nw-src", 167772161, out.readUnsignedInt()); + Assert.assertEquals("Wrong nw-dst", 167772162, out.readUnsignedInt()); + Assert.assertEquals("Wrong tp-src", 57, out.readUnsignedShort()); + Assert.assertEquals("Wrong tp-dst", 58, out.readUnsignedShort()); + Assert.assertEquals("Wrong table-id", 42, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong out-port", 6653, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Table) for correct serialization + * @throws Exception + */ + @Test + public void testTable() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPTABLE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); + MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder(); + caseBuilder.setMultipartRequestTable(tableBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 12); + Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Port) for correct serialization + * @throws Exception + */ + @Test + public void testPort() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPPORTSTATS); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); + MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); + portBuilder.setPortNo(15L); + caseBuilder.setMultipartRequestPortStats(portBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 20); + Assert.assertEquals("Wrong type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort()); + out.skipBytes(6); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing OF10StatsRequestInputFactory (Queue) for correct serialization + * @throws Exception + */ + @Test + public void testQueue() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPQUEUE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); + MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); + queueBuilder.setPortNo(15L); + queueBuilder.setQueueId(16L); + caseBuilder.setMultipartRequestQueue(queueBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 20); + Assert.assertEquals("Wrong type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong port-no", 15, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong queue-id", 16, out.readUnsignedInt()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java index df1c3455..c14e4dc3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/VendorInputMessageFactoryTest.java @@ -1,57 +1,57 @@ -/* - * Copyright (c) 2014 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.PooledByteBufAllocator; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -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 - * - */ -@RunWith(MockitoJUnitRunner.class) -public class VendorInputMessageFactoryTest { - - @Mock SerializerRegistry registry; - @Mock ExperimenterInputMessageFactory serializer; - - /** - * Tests {@link VendorInputMessageFactory#serialize(ExperimenterInput, ByteBuf)} - */ - @Test - public void test() { - Mockito.when(registry.getSerializer((MessageTypeKey) Matchers.any(MessageTypeKey.class))) - .thenReturn(serializer); - VendorInputMessageFactory factory = new VendorInputMessageFactory(); - factory.injectSerializerRegistry(registry); - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); - builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(12345L); - builder.setExperimenter(new ExperimenterId(42L)); - builder.setExpType(84L); - ExperimenterInput experimenterInput = builder.build(); - - factory.serialize(experimenterInput, buffer); - Mockito.verify(serializer, Mockito.times(1)).serialize(experimenterInput, buffer); - } +/* + * Copyright (c) 2014 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.PooledByteBufAllocator; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +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 + * + */ +@RunWith(MockitoJUnitRunner.class) +public class VendorInputMessageFactoryTest { + + @Mock SerializerRegistry registry; + @Mock ExperimenterInputMessageFactory serializer; + + /** + * Tests {@link VendorInputMessageFactory#serialize(ExperimenterInput, ByteBuf)} + */ + @Test + public void test() { + Mockito.when(registry.getSerializer((MessageTypeKey) Matchers.any(MessageTypeKey.class))) + .thenReturn(serializer); + VendorInputMessageFactory factory = new VendorInputMessageFactory(); + factory.injectSerializerRegistry(registry); + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); + builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); + builder.setXid(12345L); + builder.setExperimenter(new ExperimenterId(42L)); + builder.setExpType(84L); + ExperimenterInput experimenterInput = builder.build(); + + factory.serialize(experimenterInput, buffer); + Mockito.verify(serializer, Mockito.times(1)).serialize(experimenterInput, buffer); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java index b5b93b89..4b476037 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestExperimenterTest.java @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -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.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class MultipartRequestExperimenterTest { - - @Mock SerializerRegistry mockRegistry; - @Mock OFSerializer serializer; - - /** - * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization - * @throws Exception - */ - @Test - public void testExperimenter() throws Exception { - Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) - .thenReturn(serializer); - MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory(); - multipartFactory.injectSerializerRegistry(mockRegistry); - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPEXPERIMENTER); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); - caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +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.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class MultipartRequestExperimenterTest { + + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + + /** + * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization + * @throws Exception + */ + @Test + public void testExperimenter() throws Exception { + Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) + .thenReturn(serializer); + MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory(); + multipartFactory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPEXPERIMENTER); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); + caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java index db068d71..b747e3e7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupDescTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.desc._case.MultipartRequestGroupDescBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestGroupDescTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - GroupDesc case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPGROUPDESC); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestGroupDescCaseBuilder caseBuilder = new MultipartRequestGroupDescCaseBuilder(); - MultipartRequestGroupDescBuilder descBuilder = new MultipartRequestGroupDescBuilder(); - descBuilder.setEmpty(true); - caseBuilder.setMultipartRequestGroupDesc(descBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 7, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.desc._case.MultipartRequestGroupDescBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestGroupDescTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - GroupDesc case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPGROUPDESC); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestGroupDescCaseBuilder caseBuilder = new MultipartRequestGroupDescCaseBuilder(); + MultipartRequestGroupDescBuilder descBuilder = new MultipartRequestGroupDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestGroupDesc(descBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 7, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java index 2097974a..ff0012e0 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestGroupFeaturesTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.features._case.MultipartRequestGroupFeaturesBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestGroupFeaturesTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - GroupFeatures case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPGROUPFEATURES); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestGroupFeaturesCaseBuilder caseBuilder = new MultipartRequestGroupFeaturesCaseBuilder(); - MultipartRequestGroupFeaturesBuilder featuresBuilder = new MultipartRequestGroupFeaturesBuilder(); - featuresBuilder.setEmpty(true); - caseBuilder.setMultipartRequestGroupFeatures(featuresBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestGroupFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.group.features._case.MultipartRequestGroupFeaturesBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestGroupFeaturesTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - GroupFeatures case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPGROUPFEATURES); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestGroupFeaturesCaseBuilder caseBuilder = new MultipartRequestGroupFeaturesCaseBuilder(); + MultipartRequestGroupFeaturesBuilder featuresBuilder = new MultipartRequestGroupFeaturesBuilder(); + featuresBuilder.setEmpty(true); + caseBuilder.setMultipartRequestGroupFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java index 3eb74b1b..7f04ba49 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestMeterFeaturesTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.features._case.MultipartRequestMeterFeaturesBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestMeterFeaturesTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - MeterFeatures case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPMETERFEATURES); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestMeterFeaturesCaseBuilder caseBuilder = new MultipartRequestMeterFeaturesCaseBuilder(); - MultipartRequestMeterFeaturesBuilder featuresBuilder = new MultipartRequestMeterFeaturesBuilder(); - featuresBuilder.setEmpty(true); - caseBuilder.setMultipartRequestMeterFeatures(featuresBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 11, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestMeterFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.meter.features._case.MultipartRequestMeterFeaturesBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestMeterFeaturesTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - MeterFeatures case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPMETERFEATURES); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestMeterFeaturesCaseBuilder caseBuilder = new MultipartRequestMeterFeaturesCaseBuilder(); + MultipartRequestMeterFeaturesBuilder featuresBuilder = new MultipartRequestMeterFeaturesBuilder(); + featuresBuilder.setEmpty(true); + caseBuilder.setMultipartRequestMeterFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 11, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java index 2172e822..fd8365d2 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestPortDescTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestPortDescTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - PortDesc case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPPORTDESC); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder(); - MultipartRequestPortDescBuilder descBuilder = new MultipartRequestPortDescBuilder(); - descBuilder.setEmpty(true); - caseBuilder.setMultipartRequestPortDesc(descBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 13, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestPortDescCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.port.desc._case.MultipartRequestPortDescBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestPortDescTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - PortDesc case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPPORTDESC); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestPortDescCaseBuilder caseBuilder = new MultipartRequestPortDescCaseBuilder(); + MultipartRequestPortDescBuilder descBuilder = new MultipartRequestPortDescBuilder(); + descBuilder.setEmpty(true); + caseBuilder.setMultipartRequestPortDesc(descBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 13, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java index 86f0fef4..6ece7679 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableFeaturesTest.java @@ -1,467 +1,467 @@ -/* - * 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.openflowjava.util.ByteBufUtils; -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.ExperimenterIdTableFeatureProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeaturePropertyBuilder; -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.Output; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -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.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -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.InPhyPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -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.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class MultipartRequestTableFeaturesTest { - - private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = - MultipartRequestInputFactoryTest.PADDING_IN_MULTIPART_REQUEST_MESSAGE; - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - @Mock SerializerRegistry mockRegistry; - @Mock OFSerializer serializer; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - Mockito.when(mockRegistry.getSerializer((MessageTypeKey)Matchers.any())) - .thenReturn(serializer); - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * @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)); - MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); - MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); - List tableFeaturesList = new ArrayList<>(); - TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); - tableFeaturesBuilder.setTableId((short) 8); - tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); - tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); - tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); - tableFeaturesBuilder.setConfig(new TableConfig(true)); - tableFeaturesBuilder.setMaxEntries(65L); - List properties = new ArrayList<>(); - TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES); - NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = - new NextTableRelatedTableFeaturePropertyBuilder(); - List nextIds = new ArrayList<>(); - nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build()); - nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build()); - nextPropBuilder.setNextTableIds(nextIds); - propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS); - nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); - nextIds = new ArrayList<>(); - nextPropBuilder.setNextTableIds(nextIds); - propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS); - InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = - new InstructionRelatedTableFeaturePropertyBuilder(); - List insIds = new ArrayList<>(); - InstructionBuilder insBuilder = new InstructionBuilder(); - insBuilder.setType(WriteActions.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(GotoTable.class); - insIds.add(insBuilder.build()); - insPropBuilder.setInstruction(insIds); - propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS); - insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); - insIds = new ArrayList<>(); - insBuilder = new InstructionBuilder(); - insBuilder.setType(WriteMetadata.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(ApplyActions.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(Meter.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(ClearActions.class); - insIds.add(insBuilder.build()); - insBuilder = new InstructionBuilder(); - insBuilder.setType(GotoTable.class); - insIds.add(insBuilder.build()); - insPropBuilder.setInstruction(insIds); - propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); - properties.add(propBuilder.build()); - tableFeaturesBuilder.setTableFeatureProperties(properties); - tableFeaturesList.add(tableFeaturesBuilder.build()); - tableFeaturesBuilder = new TableFeaturesBuilder(); - tableFeaturesBuilder.setTableId((short) 8); - tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); - tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); - tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); - tableFeaturesBuilder.setConfig(new TableConfig(true)); - tableFeaturesBuilder.setMaxEntries(67L); - properties = new ArrayList<>(); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS); - ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - actions.add(actionBuilder.build()); - actBuilder.setAction(actions); - propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS); - actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); - actions = new ArrayList<>(); - actBuilder.setAction(actions); - propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS); - actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); - actions = new ArrayList<>(); - actBuilder.setAction(actions); - propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS); - actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); - actions = new ArrayList<>(); - actBuilder.setAction(actions); - propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH); - OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(InPhyPort.class); - entriesBuilder.setHasMask(false); - entries.add(entriesBuilder.build()); - entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(InPort.class); - entriesBuilder.setHasMask(false); - entries.add(entriesBuilder.build()); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(IpProto.class); - entriesBuilder.setHasMask(false); - entries.add(entriesBuilder.build()); - entriesBuilder = new MatchEntriesBuilder(); - entriesBuilder.setOxmClass(OpenflowBasicClass.class); - entriesBuilder.setOxmMatchField(IpEcn.class); - entriesBuilder.setHasMask(false); - entries.add(entriesBuilder.build()); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS); - oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); - entries = new ArrayList<>(); - oxmBuilder.setMatchEntries(entries); - propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); - properties.add(propBuilder.build()); - tableFeaturesBuilder.setTableFeatureProperties(properties); - tableFeaturesList.add(tableFeaturesBuilder.build()); - featuresBuilder.setTableFeatures(tableFeaturesList); - caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 296); - Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); - out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); - Assert.assertEquals("Wrong length", 120, out.readUnsignedShort()); - Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); - out.skipBytes(5); - Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", - ByteBufUtils.decodeNullTerminatedString(out, 32)); - byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataMatch); - Assert.assertArrayEquals("Wrong metadata-match", - new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); - byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataWrite); - Assert.assertArrayEquals("Wrong metadata-write", - new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); - Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); - Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); - Assert.assertEquals("Wrong property type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong next-registry-id", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong next-registry-id", 2, out.readUnsignedByte()); - out.skipBytes(2); - Assert.assertEquals("Wrong property type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 24, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong length", 160, out.readUnsignedShort()); - Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); - out.skipBytes(5); - Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", - ByteBufUtils.decodeNullTerminatedString(out, 32)); - metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataMatch); - Assert.assertArrayEquals("Wrong metadata-match", - new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); - metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataWrite); - Assert.assertArrayEquals("Wrong metadata-write", - new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); - Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); - Assert.assertEquals("Wrong max-entries", 67, out.readUnsignedInt()); - Assert.assertEquals("Wrong property type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong property type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 7, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match field&mask", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match field&mask", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 10, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 13, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 14, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match field&mask", 20, out.readUnsignedByte()); - Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match field&mask", 18, out.readUnsignedByte()); - Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); - out.skipBytes(4); - Assert.assertEquals("Wrong property type", 15, out.readUnsignedShort()); - Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * @throws Exception - * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO - */ - @Test - public void testMultipartRequestTableFeaturesExperimenter() throws Exception { - MultipartRequestInputFactory factory = new MultipartRequestInputFactory(); - factory.injectSerializerRegistry(mockRegistry); - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.forValue(12)); - builder.setFlags(new MultipartRequestFlags(true)); - MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); - MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); - List tableFeaturesList = new ArrayList<>(); - TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); - tableFeaturesBuilder.setTableId((short) 8); - tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); - tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); - tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); - tableFeaturesBuilder.setConfig(new TableConfig(true)); - tableFeaturesBuilder.setMaxEntries(65L); - List properties = new ArrayList<>(); - TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); - ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); - expBuilder.setExperimenter(new ExperimenterId(42L)); - propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); - properties.add(propBuilder.build()); - propBuilder = new TableFeaturePropertiesBuilder(); - propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); - expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); - expBuilder.setExperimenter(new ExperimenterId(43L)); - propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); - properties.add(propBuilder.build()); - tableFeaturesBuilder.setTableFeatureProperties(properties); - tableFeaturesList.add(tableFeaturesBuilder.build()); - featuresBuilder.setTableFeatures(tableFeaturesList); - caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - factory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 80); - Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); - out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); - Assert.assertEquals("Wrong length", 64, out.readUnsignedShort()); - Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); - out.skipBytes(5); - Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", - ByteBufUtils.decodeNullTerminatedString(out, 32)); - byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataMatch); - Assert.assertArrayEquals("Wrong metadata-match", - new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); - byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - out.readBytes(metadataWrite); - Assert.assertArrayEquals("Wrong metadata-write", - new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); - Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); - Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); - Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), - Matchers.any(ByteBuf.class)); - } +/* + * 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.openflowjava.util.ByteBufUtils; +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.ExperimenterIdTableFeatureProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdTableFeaturePropertyBuilder; +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.Output; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +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.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +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.InPhyPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +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.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class MultipartRequestTableFeaturesTest { + + private static final byte PADDING_IN_MULTIPART_REQUEST_MESSAGE = + MultipartRequestInputFactoryTest.PADDING_IN_MULTIPART_REQUEST_MESSAGE; + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + Mockito.when(mockRegistry.getSerializer((MessageTypeKey)Matchers.any())) + .thenReturn(serializer); + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * @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)); + MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); + MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); + List tableFeaturesList = new ArrayList<>(); + TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); + tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(65L); + List properties = new ArrayList<>(); + TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES); + NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = + new NextTableRelatedTableFeaturePropertyBuilder(); + List nextIds = new ArrayList<>(); + nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build()); + nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build()); + nextPropBuilder.setNextTableIds(nextIds); + propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS); + nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder(); + nextIds = new ArrayList<>(); + nextPropBuilder.setNextTableIds(nextIds); + propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS); + InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = + new InstructionRelatedTableFeaturePropertyBuilder(); + List insIds = new ArrayList<>(); + InstructionBuilder insBuilder = new InstructionBuilder(); + insBuilder.setType(WriteActions.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(GotoTable.class); + insIds.add(insBuilder.build()); + insPropBuilder.setInstruction(insIds); + propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS); + insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder(); + insIds = new ArrayList<>(); + insBuilder = new InstructionBuilder(); + insBuilder.setType(WriteMetadata.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(ApplyActions.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(Meter.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(ClearActions.class); + insIds.add(insBuilder.build()); + insBuilder = new InstructionBuilder(); + insBuilder.setType(GotoTable.class); + insIds.add(insBuilder.build()); + insPropBuilder.setInstruction(insIds); + propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); + tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(67L); + properties = new ArrayList<>(); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS); + ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + actions.add(actionBuilder.build()); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS); + actBuilder = new ActionRelatedTableFeaturePropertyBuilder(); + actions = new ArrayList<>(); + actBuilder.setAction(actions); + propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH); + OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + List entries = new ArrayList<>(); + MatchEntriesBuilder entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPhyPort.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(InPort.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpProto.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + entriesBuilder = new MatchEntriesBuilder(); + entriesBuilder.setOxmClass(OpenflowBasicClass.class); + entriesBuilder.setOxmMatchField(IpEcn.class); + entriesBuilder.setHasMask(false); + entries.add(entriesBuilder.build()); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS); + oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder(); + entries = new ArrayList<>(); + oxmBuilder.setMatchEntries(entries); + propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + featuresBuilder.setTableFeatures(tableFeaturesList); + caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 296); + Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); + out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); + Assert.assertEquals("Wrong length", 120, out.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); + out.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(out, 32)); + byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataMatch); + Assert.assertArrayEquals("Wrong metadata-match", + new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); + byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataWrite); + Assert.assertArrayEquals("Wrong metadata-write", + new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); + Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); + Assert.assertEquals("Wrong property type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong next-registry-id", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong next-registry-id", 2, out.readUnsignedByte()); + out.skipBytes(2); + Assert.assertEquals("Wrong property type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 24, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong length", 160, out.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); + out.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(out, 32)); + metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataMatch); + Assert.assertArrayEquals("Wrong metadata-match", + new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); + metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataWrite); + Assert.assertArrayEquals("Wrong metadata-write", + new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); + Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 67, out.readUnsignedInt()); + Assert.assertEquals("Wrong property type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong property type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 7, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 4, out.readUnsignedByte()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 10, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 13, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 14, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 20, out.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match field&mask", 18, out.readUnsignedByte()); + Assert.assertEquals("Wrong match length", 1, out.readUnsignedByte()); + out.skipBytes(4); + Assert.assertEquals("Wrong property type", 15, out.readUnsignedShort()); + Assert.assertEquals("Wrong property length", 4, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * @throws Exception + * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO + */ + @Test + public void testMultipartRequestTableFeaturesExperimenter() throws Exception { + MultipartRequestInputFactory factory = new MultipartRequestInputFactory(); + factory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.forValue(12)); + builder.setFlags(new MultipartRequestFlags(true)); + MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder(); + MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder(); + List tableFeaturesList = new ArrayList<>(); + TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder(); + tableFeaturesBuilder.setTableId((short) 8); + tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG"); + tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01})); + tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01})); + tableFeaturesBuilder.setConfig(new TableConfig(true)); + tableFeaturesBuilder.setMaxEntries(65L); + List properties = new ArrayList<>(); + TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER); + ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); + expBuilder.setExperimenter(new ExperimenterId(42L)); + propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); + properties.add(propBuilder.build()); + propBuilder = new TableFeaturePropertiesBuilder(); + propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS); + expBuilder = new ExperimenterIdTableFeaturePropertyBuilder(); + expBuilder.setExperimenter(new ExperimenterId(43L)); + propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build()); + properties.add(propBuilder.build()); + tableFeaturesBuilder.setTableFeatureProperties(properties); + tableFeaturesList.add(tableFeaturesBuilder.build()); + featuresBuilder.setTableFeatures(tableFeaturesList); + caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + factory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 80); + Assert.assertEquals("Wrong type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort()); + out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); + Assert.assertEquals("Wrong length", 64, out.readUnsignedShort()); + Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte()); + out.skipBytes(5); + Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", + ByteBufUtils.decodeNullTerminatedString(out, 32)); + byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataMatch); + Assert.assertArrayEquals("Wrong metadata-match", + new byte[] {0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01}, metadataMatch); + byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; + out.readBytes(metadataWrite); + Assert.assertArrayEquals("Wrong metadata-write", + new byte[] {0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01}, metadataWrite); + Assert.assertEquals("Wrong config", 8, out.readUnsignedInt()); + Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt()); + Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), + Matchers.any(ByteBuf.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java index 8ffcdd7d..724b55e5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/MultipartRequestTableTest.java @@ -1,77 +1,77 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; - -/** - * @author michal.polkorab - * - */ -public class MultipartRequestTableTest { - - private SerializerRegistry registry; - private OFSerializer multipartFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - multipartFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link MultipartRequestInputFactory} - Table case - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); - builder.setType(MultipartType.OFPMPTABLE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); - MultipartRequestTableBuilder tablesBuilder = new MultipartRequestTableBuilder(); - tablesBuilder.setEmpty(true); - caseBuilder.setMultipartRequestTable(tablesBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV13(out, (byte) 18, 16); - Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(4); // skip padding - Assert.assertTrue("Unexpected data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table._case.MultipartRequestTableBuilder; + +/** + * @author michal.polkorab + * + */ +public class MultipartRequestTableTest { + + private SerializerRegistry registry; + private OFSerializer multipartFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + multipartFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link MultipartRequestInputFactory} - Table case + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); + builder.setType(MultipartType.OFPMPTABLE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder(); + MultipartRequestTableBuilder tablesBuilder = new MultipartRequestTableBuilder(); + tablesBuilder.setEmpty(true); + caseBuilder.setMultipartRequestTable(tablesBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV13(out, (byte) 18, 16); + Assert.assertEquals("Wrong type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(4); // skip padding + Assert.assertTrue("Unexpected data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java index 448c5298..2831e6d5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestAggregateTest.java @@ -1,102 +1,102 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; -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.MultipartRequestInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF10StatsRequestAggregateTest { - - private SerializerRegistry registry; - private OFSerializer statsFactory; - - /** - * Initializes serializer registry and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - statsFactory = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); - } - - /** - * Tests {@link OF10StatsRequestInputFactory} for correct serialization - * @throws Exception - */ - @Test - public void test() throws Exception { - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPAGGREGATE); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); - MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder(); - MatchV10Builder matchBuilder = new MatchV10Builder(); - matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, - true, true, true, true)); - matchBuilder.setNwSrcMask((short) 8); - matchBuilder.setNwDstMask((short) 16); - matchBuilder.setInPort(51); - matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); - matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); - matchBuilder.setDlVlan(52); - matchBuilder.setDlVlanPcp((short) 53); - matchBuilder.setDlType(54); - matchBuilder.setNwTos((short) 55); - matchBuilder.setNwProto((short) 56); - matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); - matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); - matchBuilder.setTpSrc(57); - matchBuilder.setTpDst(58); - aggBuilder.setMatchV10(matchBuilder.build()); - aggBuilder.setTableId((short) 5); - aggBuilder.setOutPort(42L); - caseBuilder.setMultipartRequestAggregate(aggBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - statsFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 56); - Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - out.skipBytes(40); // skip match check - Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte()); - out.skipBytes(1); - Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort()); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType; +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.MultipartRequestInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestAggregateCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.aggregate._case.MultipartRequestAggregateBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF10StatsRequestAggregateTest { + + private SerializerRegistry registry; + private OFSerializer statsFactory; + + /** + * Initializes serializer registry and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + statsFactory = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF10_VERSION_ID, MultipartRequestInput.class)); + } + + /** + * Tests {@link OF10StatsRequestInputFactory} for correct serialization + * @throws Exception + */ + @Test + public void test() throws Exception { + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPAGGREGATE); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); + MultipartRequestAggregateBuilder aggBuilder = new MultipartRequestAggregateBuilder(); + MatchV10Builder matchBuilder = new MatchV10Builder(); + matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, + true, true, true, true)); + matchBuilder.setNwSrcMask((short) 8); + matchBuilder.setNwDstMask((short) 16); + matchBuilder.setInPort(51); + matchBuilder.setDlSrc(new MacAddress("00:01:02:03:04:05")); + matchBuilder.setDlDst(new MacAddress("05:04:03:02:01:00")); + matchBuilder.setDlVlan(52); + matchBuilder.setDlVlanPcp((short) 53); + matchBuilder.setDlType(54); + matchBuilder.setNwTos((short) 55); + matchBuilder.setNwProto((short) 56); + matchBuilder.setNwSrc(new Ipv4Address("10.0.0.1")); + matchBuilder.setNwDst(new Ipv4Address("10.0.0.2")); + matchBuilder.setTpSrc(57); + matchBuilder.setTpDst(58); + aggBuilder.setMatchV10(matchBuilder.build()); + aggBuilder.setTableId((short) 5); + aggBuilder.setOutPort(42L); + caseBuilder.setMultipartRequestAggregate(aggBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + statsFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 56); + Assert.assertEquals("Wrong type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + out.skipBytes(40); // skip match check + Assert.assertEquals("Wrong table-id", 5, out.readUnsignedByte()); + out.skipBytes(1); + Assert.assertEquals("Wrong out port", 42, out.readUnsignedShort()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java index b26d4ffe..00a76683 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/multipart/OF10StatsRequestExperimenterTest.java @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2014 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.multipart; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Matchers; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; -import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -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.MultipartRequestInputBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class OF10StatsRequestExperimenterTest { - - @Mock SerializerRegistry mockRegistry; - @Mock OFSerializer serializer; - - /** - * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization - * @throws Exception - */ - @Test - public void testExperimenter() throws Exception { - Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) - .thenReturn(serializer); - OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory(); - multipartFactory.injectSerializerRegistry(mockRegistry); - MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); - BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); - builder.setType(MultipartType.OFPMPEXPERIMENTER); - builder.setFlags(new MultipartRequestFlags(false)); - MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); - MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); - ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); - caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); - builder.setMultipartRequestBody(caseBuilder.build()); - MultipartRequestInput message = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - multipartFactory.serialize(message, out); - - BufferHelper.checkHeaderV10(out, (byte) 16, 12); - Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); - Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); - Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); - } +/* + * Copyright (c) 2014 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.multipart; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Matchers; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10StatsRequestInputFactory; +import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequest; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMultipartRequestBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +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.MultipartRequestInputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class OF10StatsRequestExperimenterTest { + + @Mock SerializerRegistry mockRegistry; + @Mock OFSerializer serializer; + + /** + * Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization + * @throws Exception + */ + @Test + public void testExperimenter() throws Exception { + Mockito.when(mockRegistry.getSerializer(Matchers.any(ExperimenterIdSerializerKey.class))) + .thenReturn(serializer); + OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory(); + multipartFactory.injectSerializerRegistry(mockRegistry); + MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); + BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); + builder.setType(MultipartType.OFPMPEXPERIMENTER); + builder.setFlags(new MultipartRequestFlags(false)); + MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder(); + MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder(); + ExperimenterIdMultipartRequestBuilder expIdBuilder = new ExperimenterIdMultipartRequestBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expBuilder.addAugmentation(ExperimenterIdMultipartRequest.class, expIdBuilder.build()); + caseBuilder.setMultipartRequestExperimenter(expBuilder.build()); + builder.setMultipartRequestBody(caseBuilder.build()); + MultipartRequestInput message = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + multipartFactory.serialize(message, out); + + BufferHelper.checkHeaderV10(out, (byte) 16, 12); + Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort()); + Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort()); + Mockito.verify(serializer, Mockito.times(1)).serialize(Matchers.any(MultipartRequestExperimenterCase.class), Matchers.any(ByteBuf.class)); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java index 78b15e9e..1f1c8bf8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpOpSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.ArpOp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpOpSerializerTest { - - OxmArpOpSerializer serializer = new OxmArpOpSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareArpOpMatchEntry(1402); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 1402, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareArpOpHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_OP, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareArpOpMatchEntry(int value) { - MatchEntriesBuilder builder = prepareArpOpHeader(false); - OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); - opBuilder.setOpCode(value); - builder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareArpOpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpOp.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_OP, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.ArpOp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpOpSerializerTest { + + OxmArpOpSerializer serializer = new OxmArpOpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareArpOpMatchEntry(1402); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1402, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareArpOpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_OP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareArpOpMatchEntry(int value) { + MatchEntriesBuilder builder = prepareArpOpHeader(false); + OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); + opBuilder.setOpCode(value); + builder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareArpOpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpOp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_OP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java index c23b9dbd..b0dc9276 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpShaSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.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.oxm.rev130731.ArpTha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpShaSerializerTest { - - OxmArpThaSerializer serializer = new OxmArpThaSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); - byte[] tmp = new byte[6]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_THA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpTha.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_THA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.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.oxm.rev130731.ArpTha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpShaSerializerTest { + + OxmArpThaSerializer serializer = new OxmArpThaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_THA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpTha.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_THA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java index 7af95a1b..83d6afe7 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpSpaSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -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.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpSpaSerializerTest { - - OxmArpSpaSerializer serializer = new OxmArpSpaSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); - byte[] tmp = new byte[4]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SPA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpSpa.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SPA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +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.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpSpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpSpaSerializerTest { + + OxmArpSpaSerializer serializer = new OxmArpSpaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SPA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpSpa.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SPA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java index 714d6973..cc0f5d4c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpThaSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.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.oxm.rev130731.ArpSha; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpThaSerializerTest { - - OxmArpShaSerializer serializer = new OxmArpShaSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); - byte[] tmp = new byte[6]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SHA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpSha.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SHA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.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.oxm.rev130731.ArpSha; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpThaSerializerTest { + + OxmArpShaSerializer serializer = new OxmArpShaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_SHA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpSha.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_SHA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java index 8a68a4c4..90b51395 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmArpTpaSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -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.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmArpTpaSerializerTest { - - OxmArpTpaSerializer serializer = new OxmArpTpaSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); - byte[] tmp = new byte[4]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_TPA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(ArpTpa.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_TPA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +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.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ArpTpa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmArpTpaSerializerTest { + + OxmArpTpaSerializer serializer = new OxmArpTpaSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ARP_TPA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(ArpTpa.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ARP_TPA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java index 3f0d6837..3a34fdde 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthDstSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.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.oxm.rev130731.EthDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmEthDstSerializerTest { - - OxmEthDstSerializer serializer = new OxmEthDstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); - byte[] tmp = new byte[6]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(EthDst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.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.oxm.rev130731.EthDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthDstSerializerTest { + + OxmEthDstSerializer serializer = new OxmEthDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java index 4aed8e13..984899c1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthSrcSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.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.oxm.rev130731.EthSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmEthSrcSerializerTest { - - OxmEthSrcSerializer serializer = new OxmEthSrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); - byte[] tmp = new byte[6]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(EthSrc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.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.oxm.rev130731.EthSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthSrcSerializerTest { + + OxmEthSrcSerializer serializer = new OxmEthSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "00:01:02:03:04:0A"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 10}, address); + byte[] tmp = new byte[6]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0, 10, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java index 23f32491..ae82abc9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmEthTypeSerializerTest.java @@ -1,111 +1,111 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmEthTypeSerializerTest { - - OxmEthTypeSerializer serializer = new OxmEthTypeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareEthTypeMatchEntry(65535); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 65535, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareEthTypeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_TYPE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareEthTypeMatchEntry(int type) { - MatchEntriesBuilder builder = prepareEthTypeHeader(false); - EthTypeMatchEntryBuilder typeBuilder = new EthTypeMatchEntryBuilder(); - typeBuilder.setEthType(new EtherType(type)); - builder.addAugmentation(EthTypeMatchEntry.class, typeBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareEthTypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(EthType.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_TYPE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.EthType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmEthTypeSerializerTest { + + OxmEthTypeSerializer serializer = new OxmEthTypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareEthTypeMatchEntry(65535); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 65535, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareEthTypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ETH_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareEthTypeMatchEntry(int type) { + MatchEntriesBuilder builder = prepareEthTypeHeader(false); + EthTypeMatchEntryBuilder typeBuilder = new EthTypeMatchEntryBuilder(); + typeBuilder.setEthType(new EtherType(type)); + builder.addAugmentation(EthTypeMatchEntry.class, typeBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareEthTypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(EthType.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ETH_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java index 69dbad6c..ec559978 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4CodeSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.Icmpv4Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4CodeSerializerTest { - - OxmIcmpv4CodeSerializer serializer = new OxmIcmpv4CodeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 200, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_CODE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); - Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder(); - icmpv4Builder.setIcmpv4Code(value); - builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4Builder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIcmpv4CodeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Icmpv4Code.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_CODE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.Icmpv4Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4CodeSerializerTest { + + OxmIcmpv4CodeSerializer serializer = new OxmIcmpv4CodeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv4CodeMatchEntry((short) 200); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 200, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_CODE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv4CodeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv4CodeHeader(false); + Icmpv4CodeMatchEntryBuilder icmpv4Builder = new Icmpv4CodeMatchEntryBuilder(); + icmpv4Builder.setIcmpv4Code(value); + builder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv4CodeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv4Code.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_CODE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java index 3b9d2109..1c0c08ba 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv4TypeSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.Icmpv4Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv4TypeSerializerTest { - - OxmIcmpv4TypeSerializer serializer = new OxmIcmpv4TypeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 128, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_TYPE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareIcmpv4TypeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); - Icmpv4TypeMatchEntryBuilder icmpv4Builder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4Builder.setIcmpv4Type(value); - builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4Builder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIcmpv4TypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Icmpv4Type.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_TYPE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.Icmpv4Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv4TypeSerializerTest { + + OxmIcmpv4TypeSerializer serializer = new OxmIcmpv4TypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv4TypeMatchEntry((short) 128); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 128, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV4_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv4TypeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv4TypeHeader(false); + Icmpv4TypeMatchEntryBuilder icmpv4Builder = new Icmpv4TypeMatchEntryBuilder(); + icmpv4Builder.setIcmpv4Type(value); + builder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv4TypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv4Type.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV4_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java index ed3089c0..f4525441 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6CodeSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.Icmpv6Code; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6CodeSerializerTest { - - OxmIcmpv6CodeSerializer serializer = new OxmIcmpv6CodeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 101, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_CODE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareIcmpv6CodeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); - Icmpv6CodeMatchEntryBuilder icmpv6Builder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6Builder.setIcmpv6Code(value); - builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6Builder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIcmpv6CodeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Icmpv6Code.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_CODE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.Icmpv6Code; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6CodeSerializerTest { + + OxmIcmpv6CodeSerializer serializer = new OxmIcmpv6CodeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv6CodeMatchEntry((short) 101); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 101, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_CODE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareIcmpv6CodeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv6CodeHeader(false); + Icmpv6CodeMatchEntryBuilder icmpv6Builder = new Icmpv6CodeMatchEntryBuilder(); + icmpv6Builder.setIcmpv6Code(value); + builder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv6CodeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv6Code.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_CODE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java index 2c2a60ea..1c4240ad 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIcmpv6TypeSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.Icmpv6Type; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIcmpv6TypeSerializerTest { - - OxmIcmpv6TypeSerializer serializer = new OxmIcmpv6TypeSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 123, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_TYPE, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareIcmpv6TypeMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); - Icmpv6TypeMatchEntryBuilder icmpv6Builder = new Icmpv6TypeMatchEntryBuilder(); - icmpv6Builder.setIcmpv6Type(value); - builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6Builder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIcmpv6TypeHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Icmpv6Type.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_TYPE, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.Icmpv6Type; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIcmpv6TypeSerializerTest { + + OxmIcmpv6TypeSerializer serializer = new OxmIcmpv6TypeSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIcmpv6TypeMatchEntry((short) 123); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 123, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.ICMPV6_TYPE, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIcmpv6TypeMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIcmpv6TypeHeader(false); + Icmpv6TypeMatchEntryBuilder icmpv6Builder = new Icmpv6TypeMatchEntryBuilder(); + icmpv6Builder.setIcmpv6Type(value); + builder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6Builder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIcmpv6TypeHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Icmpv6Type.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.ICMPV6_TYPE, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java index 34d9a9f2..0373589c 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpDscpSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -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.oxm.rev130731.IpDscp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpDscpSerializerTest { - - OxmIpDscpSerializer serializer = new OxmIpDscpSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareIpDscpMatchEntry((short) 58); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 58, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareIpDscpHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IP_DSCP, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareIpDscpMatchEntry(short value) { - MatchEntriesBuilder builder = prepareIpDscpHeader(false); - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); - dscpBuilder.setDscp(new Dscp(value)); - builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIpDscpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(IpDscp.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IP_DSCP, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +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.oxm.rev130731.IpDscp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpDscpSerializerTest { + + OxmIpDscpSerializer serializer = new OxmIpDscpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareIpDscpMatchEntry((short) 58); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 58, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareIpDscpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IP_DSCP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareIpDscpMatchEntry(short value) { + MatchEntriesBuilder builder = prepareIpDscpHeader(false); + DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + dscpBuilder.setDscp(new Dscp(value)); + builder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIpDscpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(IpDscp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IP_DSCP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java index fbeb425a..2672e807 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpProtoSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.IpProto; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpProtoSerializerTest { - - OxmIpProtoSerializer serializer = new OxmIpProtoSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry((short) 123); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 123, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IP_PROTO, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(short value) { - MatchEntriesBuilder builder = prepareHeader(false); - ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); - protoBuilder.setProtocolNumber(value); - builder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(IpProto.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IP_PROTO, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.IpProto; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpProtoSerializerTest { + + OxmIpProtoSerializer serializer = new OxmIpProtoSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry((short) 123); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 123, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IP_PROTO, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(short value) { + MatchEntriesBuilder builder = prepareHeader(false); + ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); + protoBuilder.setProtocolNumber(value); + builder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(IpProto.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IP_PROTO, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java index 00c3dc87..69499578 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4DstSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -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.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4DstSerializerTest { - - OxmIpv4DstSerializer serializer = new OxmIpv4DstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); - byte[] tmp = new byte[4]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv4Dst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +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.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Dst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4DstSerializerTest { + + OxmIpv4DstSerializer serializer = new OxmIpv4DstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv4Dst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java index 5b2834b9..69866caa 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv4SrcSerializerTest.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -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.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv4SrcSerializerTest { - - OxmIpv4SrcSerializer serializer = new OxmIpv4SrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[4]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); - byte[] tmp = new byte[4]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); - addressBuilder.setIpv4Address(new Ipv4Address(value)); - builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv4Src.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +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.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv4Src; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv4SrcSerializerTest { + + OxmIpv4SrcSerializer serializer = new OxmIpv4SrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "10.0.0.1"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{10, 0, 0, 1}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, "120.121.122.0"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[4]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{120, 121, 122, 0}, address); + byte[] tmp = new byte[4]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV4_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + Ipv4AddressMatchEntryBuilder addressBuilder = new Ipv4AddressMatchEntryBuilder(); + addressBuilder.setIpv4Address(new Ipv4Address(value)); + builder.addAugmentation(Ipv4AddressMatchEntry.class, addressBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv4Src.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV4_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java index 1983b1d9..0924f100 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6ExtHdrSerializerTest.java @@ -1,157 +1,157 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6ExtHdrSerializerTest { - - OxmIpv6ExtHdrSerializer serializer = new OxmIpv6ExtHdrSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(false, - new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 358, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(true, - new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false)); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - assertEquals("Wrong value", 153, buffer.readUnsignedShort()); - byte[] tmp = new byte[2]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_EXTHDR, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) { - MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0, 15}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); - pseudoBuilder.setPseudoField(flags); - builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareIpv6ExtHdrHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv6Exthdr.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_EXTHDR, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.Ipv6Exthdr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6ExtHdrSerializerTest { + + OxmIpv6ExtHdrSerializer serializer = new OxmIpv6ExtHdrSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(false, + new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 358, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrMatchEntry(true, + new Ipv6ExthdrFlags(false, true, false, true, false, true, false, true, false)); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 153, buffer.readUnsignedShort()); + byte[] tmp = new byte[2]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_EXTHDR, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareIpv6ExtHdrMatchEntry(boolean hasMask, Ipv6ExthdrFlags flags) { + MatchEntriesBuilder builder = prepareIpv6ExtHdrHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0, 15}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); + pseudoBuilder.setPseudoField(flags); + builder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareIpv6ExtHdrHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6Exthdr.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_EXTHDR, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java index a3e4ff63..52df5db1 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdSllSerializerTest.java @@ -1,120 +1,120 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.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.oxm.rev130731.Ipv6NdSll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdSllSerializerTest { - - OxmIpv6NdSllSerializer serializer = new OxmIpv6NdSllSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_SLL, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv6NdSll.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_SLL, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.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.oxm.rev130731.Ipv6NdSll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdSllSerializerTest { + + OxmIpv6NdSllSerializer serializer = new OxmIpv6NdSllSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_SLL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6NdSll.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_SLL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java index 017652d9..6c6e8d31 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmIpv6NdTllSerializerTest.java @@ -1,120 +1,120 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.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.oxm.rev130731.Ipv6NdTll; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmIpv6NdTllSerializerTest { - - OxmIpv6NdTllSerializer serializer = new OxmIpv6NdTllSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[6]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_TLL, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress(value)); - builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Ipv6NdTll.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_TLL, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.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.oxm.rev130731.Ipv6NdTll; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmIpv6NdTllSerializerTest { + + OxmIpv6NdTllSerializer serializer = new OxmIpv6NdTllSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(false, "00:01:02:03:04:05"); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[6]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.IPV6_ND_TLL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.MAC_ADDRESS_LENGTH, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, String value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15, 0, 0, 10, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress(value)); + builder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Ipv6NdTll.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.IPV6_ND_TLL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.MAC_ADDRESS_LENGTH, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java index e8e53f17..fbe202dc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMetadataSerializerTest.java @@ -1,158 +1,158 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.Metadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMetadataSerializerTest { - - OxmMetadataSerializer serializer = new OxmMetadataSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[8]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[8]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); - byte[] tmp = new byte[8]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.METADATA, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(value); - builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(Metadata.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.METADATA, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.Metadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMetadataSerializerTest { + + OxmMetadataSerializer serializer = new OxmMetadataSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); + byte[] tmp = new byte[8]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.METADATA, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(value); + builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(Metadata.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.METADATA, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java index 27c5d504..6c22ec4a 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsBosSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.MplsBos; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsBosSerializerTest { - - OxmMplsBosSerializer serializer = new OxmMplsBosSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsBosMatchEntry(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 1, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsBosHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_BOS, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder prepareMplsBosMatchEntry(boolean bos) { - MatchEntriesBuilder builder = prepareMplsBosHeader(false); - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); - bosBuilder.setBos(bos); - builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareMplsBosHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(MplsBos.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_BOS, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.MplsBos; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsBosSerializerTest { + + OxmMplsBosSerializer serializer = new OxmMplsBosSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsBosMatchEntry(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsBosHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_BOS, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder prepareMplsBosMatchEntry(boolean bos) { + MatchEntriesBuilder builder = prepareMplsBosHeader(false); + BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); + bosBuilder.setBos(bos); + builder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsBosHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsBos.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_BOS, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java index 77e07f8a..c20890b9 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsLabelSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.MplsLabel; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsLabelSerializerTest { - - OxmMplsLabelSerializer serializer = new OxmMplsLabelSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsLabelMatchEntry(168535); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 168535, buffer.readUnsignedInt()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsLabelHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_LABEL, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMplsLabelMatchEntry(long label) { - MatchEntriesBuilder builder = prepareMplsLabelHeader(false); - MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); - labelBuilder.setMplsLabel(label); - builder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareMplsLabelHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(MplsLabel.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_LABEL, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.MplsLabel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsLabelSerializerTest { + + OxmMplsLabelSerializer serializer = new OxmMplsLabelSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsLabelMatchEntry(168535); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 168535, buffer.readUnsignedInt()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsLabelHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_LABEL, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_INT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMplsLabelMatchEntry(long label) { + MatchEntriesBuilder builder = prepareMplsLabelHeader(false); + MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); + labelBuilder.setMplsLabel(label); + builder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsLabelHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsLabel.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_LABEL, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java index 8a387b6c..d851b755 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmMplsTcSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.MplsTc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmMplsTcSerializerTest { - - OxmMplsTcSerializer serializer = new OxmMplsTcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMplsTcMatchEntry((short) 16); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 16, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareMplsTcHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_TC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMplsTcMatchEntry(short value) { - MatchEntriesBuilder builder = prepareMplsTcHeader(false); - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); - tcBuilder.setTc(value); - builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareMplsTcHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(MplsTc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_TC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.MplsTc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmMplsTcSerializerTest { + + OxmMplsTcSerializer serializer = new OxmMplsTcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMplsTcMatchEntry((short) 16); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 16, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareMplsTcHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.MPLS_TC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMplsTcMatchEntry(short value) { + MatchEntriesBuilder builder = prepareMplsTcHeader(false); + TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); + tcBuilder.setTc(value); + builder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareMplsTcHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(MplsTc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.MPLS_TC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java index 974ecb76..f2cbf897 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmPbbIsidSerializerTest.java @@ -1,154 +1,154 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmPbbIsidSerializerTest { - - OxmPbbIsidSerializer serializer = new OxmPbbIsidSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = preparePbbIsidMatchEntry(false, 12345); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 12345, buffer.readUnsignedMedium()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = preparePbbIsidMatchEntry(true, 6789); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - assertEquals("Wrong value", 6789, buffer.readUnsignedMedium()); - byte[] tmp = new byte[3]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15, 10}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = preparePbbIsidHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = preparePbbIsidHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.PBB_ISID, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_3_BYTES, serializer.getValueLength()); - } - - - private static MatchEntriesBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) { - MatchEntriesBuilder builder = preparePbbIsidHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0, 15, 10}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); - isidBuilder.setIsid(value); - builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder preparePbbIsidHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(PbbIsid.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.PBB_ISID, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmPbbIsidSerializerTest { + + OxmPbbIsidSerializer serializer = new OxmPbbIsidSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = preparePbbIsidMatchEntry(false, 12345); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 12345, buffer.readUnsignedMedium()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = preparePbbIsidMatchEntry(true, 6789); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 6789, buffer.readUnsignedMedium()); + byte[] tmp = new byte[3]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{0, 15, 10}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = preparePbbIsidHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = preparePbbIsidHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.PBB_ISID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_3_BYTES, serializer.getValueLength()); + } + + + private static MatchEntriesBuilder preparePbbIsidMatchEntry(boolean hasMask, long value) { + MatchEntriesBuilder builder = preparePbbIsidHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0, 15, 10}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); + isidBuilder.setIsid(value); + builder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder preparePbbIsidHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(PbbIsid.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.PBB_ISID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_3_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java index 606696c8..e56c5c0d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpDstSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -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.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpDstSerializerTest { - - OxmSctpDstSerializer serializer = new OxmSctpDstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(SctpDst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +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.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpDstSerializerTest { + + OxmSctpDstSerializer serializer = new OxmSctpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(SctpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java index a28c60fe..6c3890c4 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmSctpSrcSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -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.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmSctpSrcSerializerTest { - - OxmSctpSrcSerializer serializer = new OxmSctpSrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(SctpSrc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +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.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmSctpSrcSerializerTest { + + OxmSctpSrcSerializer serializer = new OxmSctpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.SCTP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(SctpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.SCTP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java index fb560554..b912aed3 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpDstSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -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.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpDstSerializerTest { - - OxmTcpDstSerializer serializer = new OxmTcpDstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(4096); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(TcpDst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +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.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpDstSerializerTest { + + OxmTcpDstSerializer serializer = new OxmTcpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(4096); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4096, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TcpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java index 9e532640..c156b2f5 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTcpSrcSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -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.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmTcpSrcSerializerTest { - - OxmTcpSrcSerializer serializer = new OxmTcpSrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(512); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 512, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(TcpSrc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +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.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTcpSrcSerializerTest { + + OxmTcpSrcSerializer serializer = new OxmTcpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(512); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 512, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TCP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TcpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TCP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java index cd4029ec..35f2986e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmTunnelIdSerializerTest.java @@ -1,158 +1,158 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmTunnelIdSerializerTest { - - OxmTunnelIdSerializer serializer = new OxmTunnelIdSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutMask() { - MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - byte[] address = new byte[8]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithMask() { - MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - - byte[] address = new byte[8]; - buffer.readBytes(address); - Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); - byte[] tmp = new byte[8]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.TUNNEL_ID, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { - MatchEntriesBuilder builder = prepareHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(value); - builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(TunnelId.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.TUNNEL_ID, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmTunnelIdSerializerTest { + + OxmTunnelIdSerializer serializer = new OxmTunnelIdSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutMask() { + MatchEntriesBuilder builder = prepareMatchEntry(false, new byte[]{0, 1, 2, 3, 4, 5, 6, 7}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{0, 1, 2, 3, 4, 5, 6, 7}, address); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithMask() { + MatchEntriesBuilder builder = prepareMatchEntry(true, new byte[]{8, 9, 10, 11, 12, 13, 14, 15}); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + + byte[] address = new byte[8]; + buffer.readBytes(address); + Assert.assertArrayEquals("Wrong address", new byte[]{8, 9, 10, 11, 12, 13, 14, 15}, address); + byte[] tmp = new byte[8]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{30, 30, 25, 25, 15, 15, 0, 0}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.TUNNEL_ID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(boolean hasMask, byte[] value) { + MatchEntriesBuilder builder = prepareHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{30, 30, 25, 25, 15, 15, 0, 0}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(value); + builder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(TunnelId.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.TUNNEL_ID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", 2 * EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_LONG_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java index 4cf55588..1cafb491 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpDstSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -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.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpDstSerializerTest { - - OxmUdpDstSerializer serializer = new OxmUdpDstSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(2048); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 2048, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_DST, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(UdpDst.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_DST, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +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.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpDstSerializerTest { + + OxmUdpDstSerializer serializer = new OxmUdpDstSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(2048); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 2048, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_DST, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(UdpDst.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_DST, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java index 7348307d..d4989830 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmUdpSrcSerializerTest.java @@ -1,110 +1,110 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; -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.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmUdpSrcSerializerTest { - - OxmUdpSrcSerializer serializer = new OxmUdpSrcSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareMatchEntry(1024); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 1024, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_SRC, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareMatchEntry(int value) { - MatchEntriesBuilder builder = prepareHeader(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new PortNumber(value)); - builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(UdpSrc.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_SRC, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber; +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.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmUdpSrcSerializerTest { + + OxmUdpSrcSerializer serializer = new OxmUdpSrcSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareMatchEntry(1024); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 1024, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.UDP_SRC, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareMatchEntry(int value) { + MatchEntriesBuilder builder = prepareHeader(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new PortNumber(value)); + builder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(UdpSrc.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.UDP_SRC, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java index 0ce0f64a..ba08ad08 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanPcpSerializerTest.java @@ -1,109 +1,109 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanPcpSerializerTest { - - OxmVlanPcpSerializer serializer = new OxmVlanPcpSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerialize() { - MatchEntriesBuilder builder = prepareVlanPcpMatchEntry((short) 42); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 42, buffer.readUnsignedByte()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeader() { - MatchEntriesBuilder builder = prepareVlanPcpHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_PCP, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareVlanPcpMatchEntry(short value) { - MatchEntriesBuilder builder = prepareVlanPcpHeader(false); - VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); - pcpBuilder.setVlanPcp(value); - builder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareVlanPcpHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(VlanPcp.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_PCP, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanPcpSerializerTest { + + OxmVlanPcpSerializer serializer = new OxmVlanPcpSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerialize() { + MatchEntriesBuilder builder = prepareVlanPcpMatchEntry((short) 42); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 42, buffer.readUnsignedByte()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeader() { + MatchEntriesBuilder builder = prepareVlanPcpHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_PCP, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareVlanPcpMatchEntry(short value) { + MatchEntriesBuilder builder = prepareVlanPcpHeader(false); + VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); + pcpBuilder.setVlanPcp(value); + builder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareVlanPcpHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(VlanPcp.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_PCP, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + assertEquals("Wrong length", EncodeConstants.SIZE_OF_BYTE_IN_BYTES, buffer.readUnsignedByte()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java index 3e9bf62c..f0ae6dea 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/match/OxmVlanVidSerializerTest.java @@ -1,154 +1,154 @@ -/* - * Copyright (c) 2014 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.match; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; -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.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -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.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OxmVlanVidSerializerTest { - - OxmVlanVidSerializer serializer = new OxmVlanVidSerializer(); - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithCfiBitSet() { - MatchEntriesBuilder builder = prepareVlanVidMatchEntry(false, true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, false); - assertEquals("Wrong value", 4596, buffer.readUnsignedShort()); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct serialization - */ - @Test - public void testSerializeWithoutCfiBitSet() { - MatchEntriesBuilder builder = prepareVlanVidMatchEntry(true, false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serialize(builder.build(), buffer); - - checkHeader(buffer, true); - assertEquals("Wrong value", 500, buffer.readUnsignedShort()); - byte[] tmp = new byte[2]; - buffer.readBytes(tmp); - Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15}, tmp); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithoutMask() { - MatchEntriesBuilder builder = prepareVlanVidHeader(false); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, false); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct header serialization - */ - @Test - public void testSerializeHeaderWithMask() { - MatchEntriesBuilder builder = prepareVlanVidHeader(true); - - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - serializer.serializeHeader(builder.build(), buffer); - - checkHeader(buffer, true); - assertTrue("Unexpected data", buffer.readableBytes() == 0); - } - - /** - * Test correct oxm-class return value - */ - @Test - public void testGetOxmClassCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); - } - - /** - * Test correct oxm-field return value - */ - @Test - public void getOxmFieldCode() { - assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_VID, serializer.getOxmFieldCode()); - } - - /** - * Test correct value length return value - */ - @Test - public void testGetValueLength() { - assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); - } - - private static MatchEntriesBuilder prepareVlanVidMatchEntry(boolean hasMask, boolean cfiBit) { - MatchEntriesBuilder builder = prepareVlanVidHeader(hasMask); - if (hasMask) { - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{15, 15}); - builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - } - VlanVidMatchEntryBuilder vlanBuilder = new VlanVidMatchEntryBuilder(); - vlanBuilder.setVlanVid(500); - vlanBuilder.setCfiBit(cfiBit); - builder.addAugmentation(VlanVidMatchEntry.class, vlanBuilder.build()); - return builder; - } - - private static MatchEntriesBuilder prepareVlanVidHeader(boolean hasMask) { - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(VlanVid.class); - builder.setHasMask(hasMask); - return builder; - } - - private static void checkHeader(ByteBuf buffer, boolean hasMask) { - assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); - short fieldAndMask = buffer.readUnsignedByte(); - assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_VID, fieldAndMask >>> 1); - assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); - if (hasMask) { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); - } else { - assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); - } - } +/* + * Copyright (c) 2014 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.match; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; +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.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +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.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OxmVlanVidSerializerTest { + + OxmVlanVidSerializer serializer = new OxmVlanVidSerializer(); + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithCfiBitSet() { + MatchEntriesBuilder builder = prepareVlanVidMatchEntry(false, true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, false); + assertEquals("Wrong value", 4596, buffer.readUnsignedShort()); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct serialization + */ + @Test + public void testSerializeWithoutCfiBitSet() { + MatchEntriesBuilder builder = prepareVlanVidMatchEntry(true, false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serialize(builder.build(), buffer); + + checkHeader(buffer, true); + assertEquals("Wrong value", 500, buffer.readUnsignedShort()); + byte[] tmp = new byte[2]; + buffer.readBytes(tmp); + Assert.assertArrayEquals("Wrong mask", new byte[]{15, 15}, tmp); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithoutMask() { + MatchEntriesBuilder builder = prepareVlanVidHeader(false); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, false); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct header serialization + */ + @Test + public void testSerializeHeaderWithMask() { + MatchEntriesBuilder builder = prepareVlanVidHeader(true); + + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + serializer.serializeHeader(builder.build(), buffer); + + checkHeader(buffer, true); + assertTrue("Unexpected data", buffer.readableBytes() == 0); + } + + /** + * Test correct oxm-class return value + */ + @Test + public void testGetOxmClassCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, serializer.getOxmClassCode()); + } + + /** + * Test correct oxm-field return value + */ + @Test + public void getOxmFieldCode() { + assertEquals("Wrong oxm-class", OxmMatchConstants.VLAN_VID, serializer.getOxmFieldCode()); + } + + /** + * Test correct value length return value + */ + @Test + public void testGetValueLength() { + assertEquals("Wrong value length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, serializer.getValueLength()); + } + + private static MatchEntriesBuilder prepareVlanVidMatchEntry(boolean hasMask, boolean cfiBit) { + MatchEntriesBuilder builder = prepareVlanVidHeader(hasMask); + if (hasMask) { + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{15, 15}); + builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + } + VlanVidMatchEntryBuilder vlanBuilder = new VlanVidMatchEntryBuilder(); + vlanBuilder.setVlanVid(500); + vlanBuilder.setCfiBit(cfiBit); + builder.addAugmentation(VlanVidMatchEntry.class, vlanBuilder.build()); + return builder; + } + + private static MatchEntriesBuilder prepareVlanVidHeader(boolean hasMask) { + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(VlanVid.class); + builder.setHasMask(hasMask); + return builder; + } + + private static void checkHeader(ByteBuf buffer, boolean hasMask) { + assertEquals("Wrong oxm-class", OxmMatchConstants.OPENFLOW_BASIC_CLASS, buffer.readUnsignedShort()); + short fieldAndMask = buffer.readUnsignedByte(); + assertEquals("Wrong oxm-field", OxmMatchConstants.VLAN_VID, fieldAndMask >>> 1); + assertEquals("Wrong hasMask", hasMask, (fieldAndMask & 1) != 0); + if (hasMask) { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_INT_IN_BYTES, buffer.readUnsignedByte()); + } else { + assertEquals("Wrong length", EncodeConstants.SIZE_OF_SHORT_IN_BYTES, buffer.readUnsignedByte()); + } + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java index e0dfb8f7..d7d29d84 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ActionsDeserializerTest.java @@ -1,166 +1,166 @@ -/* - * 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.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer; -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.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author michal.polkorab - * - */ -public class ActionsDeserializerTest { - - private static final Logger LOGGER = LoggerFactory - .getLogger(ActionsDeserializerTest.class); - private DeserializerRegistry registry; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - registry = new DeserializerRegistryImpl(); - registry.init(); - } - - /** - * Testing actions deserialization - */ - @Test - public void test() { - ByteBuf message = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00 " - + "00 0B 00 08 00 00 00 00 " - + "00 0C 00 08 00 00 00 00 " - + "00 0F 00 08 03 00 00 00 " - + "00 10 00 08 00 00 00 00 " - + "00 11 00 08 00 04 00 00 " - + "00 12 00 08 00 00 00 00 " - + "00 13 00 08 00 05 00 00 " - + "00 14 00 08 00 06 00 00 " - + "00 15 00 08 00 00 00 07 " - + "00 16 00 08 00 00 00 08 " - + "00 17 00 08 09 00 00 00 " - + "00 18 00 08 00 00 00 00 " - + "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 " - + "00 1A 00 08 00 0A 00 00 " - + "00 1B 00 08 00 00 00 00"); - - message.skipBytes(4); // skip XID - LOGGER.info("bytes: " + message.readableBytes()); - - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, - message.readableBytes(), message, keyMaker, registry); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); - Assert.assertEquals("Wrong action port", 1, - actions.get(0).getAugmentation(PortAction.class).getPort().getValue().intValue()); - Assert.assertEquals("Wrong action max-length", 2, - actions.get(0).getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.CopyTtlOut", actions.get(1).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.CopyTtlIn", actions.get(2).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetMplsTtl", actions.get(3).getType().getName()); - Assert.assertEquals("Wrong action value", 3, - actions.get(3).getAugmentation(MplsTtlAction.class).getMplsTtl().shortValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.DecMplsTtl", actions.get(4).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushVlan", actions.get(5).getType().getName()); - Assert.assertEquals("Wrong action value", 4, - actions.get(5).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopVlan", actions.get(6).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushMpls", actions.get(7).getType().getName()); - Assert.assertEquals("Wrong action value", 5, - actions.get(7).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopMpls", actions.get(8).getType().getName()); - Assert.assertEquals("Wrong action value", 6, - actions.get(8).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetQueue", actions.get(9).getType().getName()); - Assert.assertEquals("Wrong action value", 7, - actions.get(9).getAugmentation(QueueIdAction.class).getQueueId().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Group", actions.get(10).getType().getName()); - Assert.assertEquals("Wrong action value", 8, - actions.get(10).getAugmentation(GroupIdAction.class).getGroupId().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetNwTtl", actions.get(11).getType().getName()); - Assert.assertEquals("Wrong action value", 9, - actions.get(11).getAugmentation(NwTtlAction.class).getNwTtl().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.DecNwTtl", actions.get(12).getType().getName()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetField", actions.get(13).getType().getName()); - List entries = actions.get(13).getAugmentation(OxmFieldsAction.class).getMatchEntries(); - Assert.assertEquals("Wrong number of fields", 1, entries.size()); - Assert.assertEquals("Wrong match entry class", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." - + "oxm.rev130731.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); - Assert.assertEquals("Wrong match entry field", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." - + "oxm.rev130731.InPhyPort", entries.get(0).getOxmMatchField().getName()); - Assert.assertEquals("Wrong match entry mask", false, entries.get(0).isHasMask()); - Assert.assertEquals("Wrong match entry value", 11, - entries.get(0).getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName()); - Assert.assertEquals("Wrong action value", 10, - actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName()); - Assert.assertTrue("Unread data in message", message.readableBytes() == 0); - } - - /** - * Tests {@link AbstractActionDeserializer#deserializeHeader(ByteBuf)} - */ - @Test - public void testDeserializeHeader() { - ByteBuf message = BufferHelper.buildBuffer("00 00 00 04 00 19 00 04"); - - message.skipBytes(4); // skip XID - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - List actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, - message.readableBytes(), message, keyMaker, registry); - - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); - Assert.assertEquals("Wrong action port", null, actions.get(0).getAugmentation(PortAction.class)); - Assert.assertEquals("Wrong action max-length", null, actions.get(0).getAugmentation(MaxLengthAction.class)); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." - + "openflow.common.action.rev130731.SetField", actions.get(1).getType().getName()); - Assert.assertEquals("Wrong action oxm field", null, actions.get(1).getAugmentation(OxmFieldsAction.class)); - } -} +/* + * 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.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.protocol.impl.deserialization.action.AbstractActionDeserializer; +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.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author michal.polkorab + * + */ +public class ActionsDeserializerTest { + + private static final Logger LOGGER = LoggerFactory + .getLogger(ActionsDeserializerTest.class); + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + } + + /** + * Testing actions deserialization + */ + @Test + public void test() { + ByteBuf message = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00 " + + "00 0B 00 08 00 00 00 00 " + + "00 0C 00 08 00 00 00 00 " + + "00 0F 00 08 03 00 00 00 " + + "00 10 00 08 00 00 00 00 " + + "00 11 00 08 00 04 00 00 " + + "00 12 00 08 00 00 00 00 " + + "00 13 00 08 00 05 00 00 " + + "00 14 00 08 00 06 00 00 " + + "00 15 00 08 00 00 00 07 " + + "00 16 00 08 00 00 00 08 " + + "00 17 00 08 09 00 00 00 " + + "00 18 00 08 00 00 00 00 " + + "00 19 00 10 80 00 02 04 00 00 00 0B 00 00 00 00 " + + "00 1A 00 08 00 0A 00 00 " + + "00 1B 00 08 00 00 00 00"); + + message.skipBytes(4); // skip XID + LOGGER.info("bytes: " + message.readableBytes()); + + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); + Assert.assertEquals("Wrong action port", 1, + actions.get(0).getAugmentation(PortAction.class).getPort().getValue().intValue()); + Assert.assertEquals("Wrong action max-length", 2, + actions.get(0).getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.CopyTtlOut", actions.get(1).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.CopyTtlIn", actions.get(2).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetMplsTtl", actions.get(3).getType().getName()); + Assert.assertEquals("Wrong action value", 3, + actions.get(3).getAugmentation(MplsTtlAction.class).getMplsTtl().shortValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.DecMplsTtl", actions.get(4).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PushVlan", actions.get(5).getType().getName()); + Assert.assertEquals("Wrong action value", 4, + actions.get(5).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PopVlan", actions.get(6).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PushMpls", actions.get(7).getType().getName()); + Assert.assertEquals("Wrong action value", 5, + actions.get(7).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PopMpls", actions.get(8).getType().getName()); + Assert.assertEquals("Wrong action value", 6, + actions.get(8).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetQueue", actions.get(9).getType().getName()); + Assert.assertEquals("Wrong action value", 7, + actions.get(9).getAugmentation(QueueIdAction.class).getQueueId().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.Group", actions.get(10).getType().getName()); + Assert.assertEquals("Wrong action value", 8, + actions.get(10).getAugmentation(GroupIdAction.class).getGroupId().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetNwTtl", actions.get(11).getType().getName()); + Assert.assertEquals("Wrong action value", 9, + actions.get(11).getAugmentation(NwTtlAction.class).getNwTtl().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.DecNwTtl", actions.get(12).getType().getName()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetField", actions.get(13).getType().getName()); + List entries = actions.get(13).getAugmentation(OxmFieldsAction.class).getMatchEntries(); + Assert.assertEquals("Wrong number of fields", 1, entries.size()); + Assert.assertEquals("Wrong match entry class", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." + + "oxm.rev130731.OpenflowBasicClass", entries.get(0).getOxmClass().getName()); + Assert.assertEquals("Wrong match entry field", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow." + + "oxm.rev130731.InPhyPort", entries.get(0).getOxmMatchField().getName()); + Assert.assertEquals("Wrong match entry mask", false, entries.get(0).isHasMask()); + Assert.assertEquals("Wrong match entry value", 11, + entries.get(0).getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PushPbb", actions.get(14).getType().getName()); + Assert.assertEquals("Wrong action value", 10, + actions.get(14).getAugmentation(EthertypeAction.class).getEthertype().getValue().intValue()); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.PopPbb", actions.get(15).getType().getName()); + Assert.assertTrue("Unread data in message", message.readableBytes() == 0); + } + + /** + * Tests {@link AbstractActionDeserializer#deserializeHeader(ByteBuf)} + */ + @Test + public void testDeserializeHeader() { + ByteBuf message = BufferHelper.buildBuffer("00 00 00 04 00 19 00 04"); + + message.skipBytes(4); // skip XID + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List actions = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.Output", actions.get(0).getType().getName()); + Assert.assertEquals("Wrong action port", null, actions.get(0).getAugmentation(PortAction.class)); + Assert.assertEquals("Wrong action max-length", null, actions.get(0).getAugmentation(MaxLengthAction.class)); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight." + + "openflow.common.action.rev130731.SetField", actions.get(1).getType().getName()); + Assert.assertEquals("Wrong action oxm field", null, actions.get(1).getAugmentation(OxmFieldsAction.class)); + } +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java index 06bbf1e4..fcae5712 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/CodeKeyMakerFactoryTest.java @@ -1,135 +1,135 @@ -/* - * Copyright (c) 2014 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.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; - -/** - * @author michal.polkorab - * - */ -public class CodeKeyMakerFactoryTest { - - /** - * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} - */ - @Test - public void testMatchEntriesKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("80 00 00 04 00 00 00 01"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 32768, 0), codeKey); - Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} - */ - @Test - public void testExperimenterMatchEntriesKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 04 00 00 00 01"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - MatchEntryDeserializerKey comparationKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 65535, 0); - comparationKey.setExperimenterId(1L); - Assert.assertEquals("Wrong key", comparationKey, codeKey); - Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} - */ - @Test - public void testActionKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0, null), codeKey); - Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} - */ - @Test - public void testExperimenterActionKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 65535, 1L), codeKey); - Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} - */ - @Test - public void testInstructionKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 08"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0, null), codeKey); - Assert.assertEquals("Buffer index modified", 4, buffer.readableBytes()); - } - - /** - * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} - */ - @Test - public void testExperimenterInstructionKeyMaker() { - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null key maker", keyMaker); - - ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); - buffer.skipBytes(4); // skip XID - MessageCodeKey codeKey = keyMaker.make(buffer); - - Assert.assertNotNull("Null key", codeKey); - Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 65535, 1L), codeKey); - Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); - } +/* + * Copyright (c) 2014 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.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; + +/** + * @author michal.polkorab + * + */ +public class CodeKeyMakerFactoryTest { + + /** + * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testMatchEntriesKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("80 00 00 04 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 32768, 0), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testExperimenterMatchEntriesKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 04 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + MatchEntryDeserializerKey comparationKey = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, 65535, 0); + comparationKey.setExperimenterId(1L); + Assert.assertEquals("Wrong key", comparationKey, codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} + */ + @Test + public void testActionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 10 00 00 00 01 00 02 00 00 00 00 00 00"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0, null), codeKey); + Assert.assertEquals("Buffer index modified", 16, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createActionsKeyMaker(short)} + */ + @Test + public void testExperimenterActionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new ActionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 65535, 1L), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} + */ + @Test + public void testInstructionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("00 00 00 08"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0, null), codeKey); + Assert.assertEquals("Buffer index modified", 4, buffer.readableBytes()); + } + + /** + * Tests {@link CodeKeyMakerFactory#createInstructionsKeyMaker(short)} + */ + @Test + public void testExperimenterInstructionKeyMaker() { + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null key maker", keyMaker); + + ByteBuf buffer = BufferHelper.buildBuffer("FF FF 00 08 00 00 00 01"); + buffer.skipBytes(4); // skip XID + MessageCodeKey codeKey = keyMaker.make(buffer); + + Assert.assertNotNull("Null key", codeKey); + Assert.assertEquals("Wrong key", new InstructionDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 65535, 1L), codeKey); + Assert.assertEquals("Buffer index modified", 8, buffer.readableBytes()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java index 112437b5..adb6941e 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/InstructionsDeserializerTest.java @@ -1,112 +1,112 @@ -/* - * 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.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; -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.MetadataInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; -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.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; - -/** - * @author michal.polkorab - * - */ -public class InstructionsDeserializerTest { - - - private DeserializerRegistry registry; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - registry = new DeserializerRegistryImpl(); - registry.init(); - } - - /** - * Testing instructions translation - */ - @Test - public void test() { - ByteBuf message = BufferHelper.buildBuffer("00 01 00 08 0A 00 00 00 00 02 00 18 00 00 00 00 " - + "00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 30 00 05 00 08 00 00 00 00 00 06 00 08 " - + "00 01 02 03 00 03 00 20 00 00 00 00 00 00 00 10 00 00 00 25 00 35 00 00 00 00 00 00 " - + "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00"); - - message.skipBytes(4); // skip XID - - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); - List instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, - message.readableBytes(), message, keyMaker, registry); - Instruction i1 = instructions.get(0); - Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName()); - Assert.assertEquals("Wrong table-id - i1", 10, i1.getAugmentation(TableIdInstruction.class).getTableId().intValue()); - Instruction i2 = instructions.get(1); - Assert.assertEquals("Wrong type - i2", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.WriteMetadata", i2.getType().getName()); - Assert.assertArrayEquals("Wrong metadata - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 20"), - i2.getAugmentation(MetadataInstruction.class).getMetadata()); - Assert.assertArrayEquals("Wrong metadata-mask - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 30"), - i2.getAugmentation(MetadataInstruction.class).getMetadataMask()); - Instruction i3 = instructions.get(2); - Assert.assertEquals("Wrong type - i3", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.ClearActions", i3.getType().getName()); - Assert.assertEquals("Wrong instructions - i3", 0, i3.getAugmentation(ActionsInstruction.class).getAction().size()); - Instruction i4 = instructions.get(3); - Assert.assertEquals("Wrong type - i4", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.Meter", i4.getType().getName()); - Assert.assertEquals("Wrong meterId - i4", 66051, i4.getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); - Instruction i5 = instructions.get(4); - Assert.assertEquals("Wrong type - i5", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.WriteActions", i5.getType().getName()); - Assert.assertEquals("Wrong instructions - i5", 2, i5.getAugmentation(ActionsInstruction.class).getAction().size()); - Action action1 = i5.getAugmentation(ActionsInstruction.class).getAction().get(0); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output", - action1.getType().getName()); - Assert.assertEquals("Wrong action", 37, action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); - Assert.assertEquals("Wrong action", 53, action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Action action2 = i5.getAugmentation(ActionsInstruction.class).getAction().get(1); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group", - action2.getType().getName()); - Assert.assertEquals("Wrong action", 80, action2.getAugmentation(GroupIdAction.class).getGroupId().intValue()); - Instruction i6 = instructions.get(5); - Assert.assertEquals("Wrong type - i6", "org.opendaylight.yang.gen.v1.urn." - + "opendaylight.openflow.common.instruction.rev130731.ApplyActions", i6.getType().getName()); - Assert.assertEquals("Wrong instructions - i6", 2, i6.getAugmentation(ActionsInstruction.class).getAction().size()); - action1 = i6.getAugmentation(ActionsInstruction.class).getAction().get(0); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue", - action1.getType().getName()); - Assert.assertEquals("Wrong action", 37, action1.getAugmentation(QueueIdAction.class).getQueueId().intValue()); - action2 = i6.getAugmentation(ActionsInstruction.class).getAction().get(1); - Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl", - action2.getType().getName()); - Assert.assertEquals("Wrong action", 5, action2.getAugmentation(MplsTtlAction.class).getMplsTtl().intValue()); - } - -} +/* + * 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.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionsInstruction; +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.MetadataInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MeterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsTtlAction; +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.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; + +/** + * @author michal.polkorab + * + */ +public class InstructionsDeserializerTest { + + + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + } + + /** + * Testing instructions translation + */ + @Test + public void test() { + ByteBuf message = BufferHelper.buildBuffer("00 01 00 08 0A 00 00 00 00 02 00 18 00 00 00 00 " + + "00 00 00 00 00 00 00 20 00 00 00 00 00 00 00 30 00 05 00 08 00 00 00 00 00 06 00 08 " + + "00 01 02 03 00 03 00 20 00 00 00 00 00 00 00 10 00 00 00 25 00 35 00 00 00 00 00 00 " + + "00 16 00 08 00 00 00 50 00 04 00 18 00 00 00 00 00 15 00 08 00 00 00 25 00 0F 00 08 05 00 00 00"); + + message.skipBytes(4); // skip XID + + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID); + List instructions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + Instruction i1 = instructions.get(0); + Assert.assertEquals("Wrong type - i1", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.GotoTable", i1.getType().getName()); + Assert.assertEquals("Wrong table-id - i1", 10, i1.getAugmentation(TableIdInstruction.class).getTableId().intValue()); + Instruction i2 = instructions.get(1); + Assert.assertEquals("Wrong type - i2", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.WriteMetadata", i2.getType().getName()); + Assert.assertArrayEquals("Wrong metadata - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 20"), + i2.getAugmentation(MetadataInstruction.class).getMetadata()); + Assert.assertArrayEquals("Wrong metadata-mask - i2", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 30"), + i2.getAugmentation(MetadataInstruction.class).getMetadataMask()); + Instruction i3 = instructions.get(2); + Assert.assertEquals("Wrong type - i3", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.ClearActions", i3.getType().getName()); + Assert.assertEquals("Wrong instructions - i3", 0, i3.getAugmentation(ActionsInstruction.class).getAction().size()); + Instruction i4 = instructions.get(3); + Assert.assertEquals("Wrong type - i4", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.Meter", i4.getType().getName()); + Assert.assertEquals("Wrong meterId - i4", 66051, i4.getAugmentation(MeterIdInstruction.class).getMeterId().intValue()); + Instruction i5 = instructions.get(4); + Assert.assertEquals("Wrong type - i5", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.WriteActions", i5.getType().getName()); + Assert.assertEquals("Wrong instructions - i5", 2, i5.getAugmentation(ActionsInstruction.class).getAction().size()); + Action action1 = i5.getAugmentation(ActionsInstruction.class).getAction().get(0); + Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output", + action1.getType().getName()); + Assert.assertEquals("Wrong action", 37, action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); + Assert.assertEquals("Wrong action", 53, action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); + Action action2 = i5.getAugmentation(ActionsInstruction.class).getAction().get(1); + Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Group", + action2.getType().getName()); + Assert.assertEquals("Wrong action", 80, action2.getAugmentation(GroupIdAction.class).getGroupId().intValue()); + Instruction i6 = instructions.get(5); + Assert.assertEquals("Wrong type - i6", "org.opendaylight.yang.gen.v1.urn." + + "opendaylight.openflow.common.instruction.rev130731.ApplyActions", i6.getType().getName()); + Assert.assertEquals("Wrong instructions - i6", 2, i6.getAugmentation(ActionsInstruction.class).getAction().size()); + action1 = i6.getAugmentation(ActionsInstruction.class).getAction().get(0); + Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetQueue", + action1.getType().getName()); + Assert.assertEquals("Wrong action", 37, action1.getAugmentation(QueueIdAction.class).getQueueId().intValue()); + action2 = i6.getAugmentation(ActionsInstruction.class).getAction().get(1); + Assert.assertEquals("Wrong action", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.SetMplsTtl", + action2.getType().getName()); + Assert.assertEquals("Wrong action", 5, action2.getAugmentation(MplsTtlAction.class).getMplsTtl().intValue()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java index 446533a9..fb622cd8 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListDeserializerTest.java @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2014 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.List; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.PooledByteBufAllocator; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yangtools.yang.binding.DataObject; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class ListDeserializerTest { - - @Mock CodeKeyMaker keyMaker; - @Mock DeserializerRegistry registry; - - /** - * Tests {@link ListDeserializer#deserializeList(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} - */ - @Test - public void test() { - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - List list = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, - 42, buffer, keyMaker, registry); - - Assert.assertNull("List is not null", list); - } - - /** - * Tests {@link ListDeserializer#deserializeHeaders(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} - */ - @Test - public void test2() { - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - List list = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, - 42, buffer, keyMaker, registry); - - Assert.assertNull("List is not null", list); - } +/* + * Copyright (c) 2014 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.List; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.PooledByteBufAllocator; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yangtools.yang.binding.DataObject; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class ListDeserializerTest { + + @Mock CodeKeyMaker keyMaker; + @Mock DeserializerRegistry registry; + + /** + * Tests {@link ListDeserializer#deserializeList(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} + */ + @Test + public void test() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + List list = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, + 42, buffer, keyMaker, registry); + + Assert.assertNull("List is not null", list); + } + + /** + * Tests {@link ListDeserializer#deserializeHeaders(short, int, ByteBuf, CodeKeyMaker, DeserializerRegistry)} + */ + @Test + public void test2() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + List list = ListDeserializer.deserializeHeaders(EncodeConstants.OF13_VERSION_ID, + 42, buffer, keyMaker, registry); + + Assert.assertNull("List is not null", list); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java index f314a3ae..15c367ad 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/ListSerializerTest.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2014 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.PooledByteBufAllocator; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -@RunWith(MockitoJUnitRunner.class) -public class ListSerializerTest { - - @Mock TypeKeyMaker keyMaker; - @Mock SerializerRegistry registry; - - /** - * Tests {@link ListSerializer#serializeHeaderList(List, TypeKeyMaker, SerializerRegistry, ByteBuf)} - * with null List - */ - @Test - public void test() { - ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeHeaderList(null, keyMaker, registry, buffer); - - Assert.assertEquals("Data written to buffer", 0, buffer.readableBytes()); - } +/* + * Copyright (c) 2014 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.PooledByteBufAllocator; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +@RunWith(MockitoJUnitRunner.class) +public class ListSerializerTest { + + @Mock TypeKeyMaker keyMaker; + @Mock SerializerRegistry registry; + + /** + * Tests {@link ListSerializer#serializeHeaderList(List, TypeKeyMaker, SerializerRegistry, ByteBuf)} + * with null List + */ + @Test + public void test() { + ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeHeaderList(null, keyMaker, registry, buffer); + + Assert.assertEquals("Data written to buffer", 0, buffer.readableBytes()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java index 36d9a9ce..a3ad2abb 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/MatchDeserializerTest.java @@ -1,516 +1,516 @@ -/* - * 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.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -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.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.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.Ipv6ExthdrFlags; -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.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.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; - -/** - * @author michal.polkorab - * - */ -public class MatchDeserializerTest { - - private OFDeserializer matchDeserializer; - private DeserializerRegistry registry; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - registry = new DeserializerRegistryImpl(); - registry.init(); - matchDeserializer = registry.getDeserializer( - new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, - EncodeConstants.EMPTY_VALUE, Match.class)); - } - - /** - * Testing Ipv4 address deserialization - */ - @Test - public void testIpv4Address() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); - - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0x8000, 12); - key.setExperimenterId(null); - OFDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserialize(buffer); - Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"), - entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - } - - /** - * Testing Ipv6 address deserialization - */ - @Test - public void testIpv6Address() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07"); - - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0x8000, 26); - key.setExperimenterId(null); - OFDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserialize(buffer); - Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"), - entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - } - - /** - * Testing match deserialization - */ - @Test - public void testMatch() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC " - + "80 00 00 04 00 00 00 01 " - + "80 00 02 04 00 00 00 02 " - + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 " - + "80 00 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 " - + "80 00 09 0C 00 00 00 00 00 07 00 00 00 00 00 08 " - + "80 00 0A 02 00 09 " - + "80 00 0D 04 00 0A 00 0B " - + "80 00 0E 01 0C " - + "80 00 10 01 0D " - + "80 00 12 01 0E " - + "80 00 14 01 0F " - + "80 00 17 08 0A 00 00 01 00 00 FF 00 " - + "80 00 19 08 0A 00 00 02 00 00 00 FF " - + "80 00 1A 02 00 03 " - + "80 00 1C 02 00 04 " - + "80 00 1E 02 00 05 " - + "80 00 20 02 00 06 " - + "80 00 22 02 00 07 " - + "80 00 24 02 00 08 " - + "80 00 26 01 05 " - + "80 00 28 01 07 " - + "80 00 2A 02 00 10 " - + "80 00 2D 08 0A 00 00 09 00 00 FF 00 " - + "80 00 2F 08 0A 00 00 0A 00 00 00 FF " - + "80 00 31 0C 00 00 00 00 00 01 00 00 00 00 00 03 " - + "80 00 33 0C 00 00 00 00 00 02 00 00 00 00 00 04 " - + "80 00 35 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 " - + "80 00 37 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 " - + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 " - + "80 00 39 08 00 00 00 02 00 00 00 03 " - + "80 00 3A 01 15 " - + "80 00 3C 01 17 " - + "80 00 3E 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 " //ipv6ndtarget - + "80 00 40 06 00 05 00 00 00 01 " - + "80 00 42 06 00 05 00 00 00 02 " - + "80 00 44 04 00 00 02 03 " - + "80 00 46 01 03 " - + "80 00 48 01 01 " - + "80 00 4B 06 00 00 02 00 00 01 " - + "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF " - + "80 00 4F 04 00 00 03 04 " - + "00 00 00 00"); - - Match match = matchDeserializer.deserialize(buffer); - Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType()); - Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size()); - List entries = match.getMatchEntries(); - MatchEntries entry0 = entries.get(0); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry0.getOxmClass()); - Assert.assertEquals("Wrong entry field", InPort.class, entry0.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry0.isHasMask()); - Assert.assertEquals("Wrong entry value", 1, - entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - MatchEntries entry1 = entries.get(1); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass()); - Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, - entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); - MatchEntries entry2 = entries.get(2); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass()); - Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask()); - Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), - entry2.getAugmentation(MetadataMatchEntry.class).getMetadata()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), - entry2.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry3 = entries.get(3); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass()); - Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), - entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), - entry3.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry4 = entries.get(4); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass()); - Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), - entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), - entry4.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry5 = entries.get(5); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass()); - Assert.assertEquals("Wrong entry field", EthType.class, entry5.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry5.isHasMask()); - Assert.assertEquals("Wrong entry value", 9, - entry5.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().intValue()); - MatchEntries entry6 = entries.get(6); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry6.getOxmClass()); - Assert.assertEquals("Wrong entry field", VlanVid.class, entry6.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask()); - Assert.assertEquals("Wrong entry value", 10, - entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); - Assert.assertEquals("Wrong entry value", false, - entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), - entry6.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry7 = entries.get(7); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass()); - Assert.assertEquals("Wrong entry field", VlanPcp.class, entry7.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry7.isHasMask()); - Assert.assertEquals("Wrong entry value", 12, - entry7.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().intValue()); - MatchEntries entry8 = entries.get(8); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry8.getOxmClass()); - Assert.assertEquals("Wrong entry field", IpDscp.class, entry8.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry8.isHasMask()); - Assert.assertEquals("Wrong entry value", 13, - entry8.getAugmentation(DscpMatchEntry.class).getDscp().getValue().intValue()); - MatchEntries entry9 = entries.get(9); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry9.getOxmClass()); - Assert.assertEquals("Wrong entry field", IpEcn.class, entry9.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry9.isHasMask()); - Assert.assertEquals("Wrong entry value", 14, - entry9.getAugmentation(EcnMatchEntry.class).getEcn().intValue()); - MatchEntries entry10 = entries.get(10); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry10.getOxmClass()); - Assert.assertEquals("Wrong entry field", IpProto.class, entry10.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry10.isHasMask()); - Assert.assertEquals("Wrong entry value", 15, - entry10.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber().intValue()); - MatchEntries entry11 = entries.get(11); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry11.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv4Src.class, entry11.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"), - entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), - entry11.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry12 = entries.get(12); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry12.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"), - entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), - entry12.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry13 = entries.get(13); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass()); - Assert.assertEquals("Wrong entry field", TcpSrc.class, entry13.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry13.isHasMask()); - Assert.assertEquals("Wrong entry value", 3, - entry13.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry14 = entries.get(14); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry14.getOxmClass()); - Assert.assertEquals("Wrong entry field", TcpDst.class, entry14.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry14.isHasMask()); - Assert.assertEquals("Wrong entry value", 4, - entry14.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry15 = entries.get(15); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry15.getOxmClass()); - Assert.assertEquals("Wrong entry field", UdpSrc.class, entry15.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry15.isHasMask()); - Assert.assertEquals("Wrong entry value", 5, - entry15.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry16 = entries.get(16); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry16.getOxmClass()); - Assert.assertEquals("Wrong entry field", UdpDst.class, entry16.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry16.isHasMask()); - Assert.assertEquals("Wrong entry value", 6, - entry16.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry17 = entries.get(17); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry17.getOxmClass()); - Assert.assertEquals("Wrong entry field", SctpSrc.class, entry17.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry17.isHasMask()); - Assert.assertEquals("Wrong entry value", 7, - entry17.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry18 = entries.get(18); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry18.getOxmClass()); - Assert.assertEquals("Wrong entry field", SctpDst.class, entry18.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry18.isHasMask()); - Assert.assertEquals("Wrong entry value", 8, - entry18.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); - MatchEntries entry19 = entries.get(19); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry19.getOxmClass()); - Assert.assertEquals("Wrong entry field", Icmpv4Type.class, entry19.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry19.isHasMask()); - Assert.assertEquals("Wrong entry value", 5, - entry19.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type().intValue()); - MatchEntries entry20 = entries.get(20); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry20.getOxmClass()); - Assert.assertEquals("Wrong entry field", Icmpv4Code.class, entry20.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry20.isHasMask()); - Assert.assertEquals("Wrong entry value", 7, - entry20.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code().intValue()); - MatchEntries entry21 = entries.get(21); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry21.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpOp.class, entry21.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry21.isHasMask()); - Assert.assertEquals("Wrong entry value", 16, - entry21.getAugmentation(OpCodeMatchEntry.class).getOpCode().intValue()); - MatchEntries entry22 = entries.get(22); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry22.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpSpa.class, entry22.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"), - entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), - entry22.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry23 = entries.get(23); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpTpa.class, entry23.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"), - entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), - entry23.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry24 = entries.get(24); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), - entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), - entry24.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry25 = entries.get(25); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass()); - Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), - entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), - entry25.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry26 = entries.get(26); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), - entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - Assert.assertArrayEquals("Wrong entry mask", - ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), - entry26.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry27 = entries.get(27); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), - entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - Assert.assertArrayEquals("Wrong entry mask", - ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), - entry27.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry28 = entries.get(28); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, - entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"), - entry28.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry29 = entries.get(29); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass()); - Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask()); - Assert.assertEquals("Wrong entry value", 21, - entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue()); - MatchEntries entry30 = entries.get(30); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass()); - Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask()); - Assert.assertEquals("Wrong entry value", 23, - entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue()); - MatchEntries entry31 = entries.get(31); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask()); - Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), - entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); - MatchEntries entry32 = entries.get(32); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), - entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - MatchEntries entry33 = entries.get(33); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6NdTll.class, entry33.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry33.isHasMask()); - Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:02"), - entry33.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); - MatchEntries entry34 = entries.get(34); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry34.getOxmClass()); - Assert.assertEquals("Wrong entry field", MplsLabel.class, entry34.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry34.isHasMask()); - Assert.assertEquals("Wrong entry value", 515, - entry34.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); - MatchEntries entry35 = entries.get(35); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry35.getOxmClass()); - Assert.assertEquals("Wrong entry field", MplsTc.class, entry35.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry35.isHasMask()); - Assert.assertEquals("Wrong entry value", 3, - entry35.getAugmentation(TcMatchEntry.class).getTc().intValue()); - MatchEntries entry36 = entries.get(36); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry36.getOxmClass()); - Assert.assertEquals("Wrong entry field", MplsBos.class, entry36.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry36.isHasMask()); - Assert.assertEquals("Wrong entry value", true, - entry36.getAugmentation(BosMatchEntry.class).isBos()); - MatchEntries entry37 = entries.get(37); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry37.getOxmClass()); - Assert.assertEquals("Wrong entry field", PbbIsid.class, entry37.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry37.isHasMask()); - Assert.assertEquals("Wrong entry value", 2, - entry37.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 01"), - entry37.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry38 = entries.get(38); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry38.getOxmClass()); - Assert.assertEquals("Wrong entry field", TunnelId.class, entry38.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry38.isHasMask()); - Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 07"), - entry38.getAugmentation(MetadataMatchEntry.class).getMetadata()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 FF"), - entry38.getAugmentation(MaskMatchEntry.class).getMask()); - MatchEntries entry39 = entries.get(39); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry39.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask()); - Assert.assertEquals("Wrong entry value", - new Ipv6ExthdrFlags(false, false, false, false, false, false, false, false, false), - entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); - Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"), - entry39.getAugmentation(MaskMatchEntry.class).getMask()); - Assert.assertTrue("Unread data", buffer.readableBytes() == 0); - } - - /** - * Testing header deserialization - */ - @Test - public void testHeaders() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); - - MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, - 0x8000, 12); - key.setExperimenterId(null); - HeaderDeserializer entryDeserializer = registry.getDeserializer(key); - MatchEntries entry = entryDeserializer.deserializeHeader(buffer); - Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); - Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry.getOxmMatchField()); - Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); - Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class)); - } - - /** - * Testing standard match type - */ - @Test - public void testStandardMatch() { - ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 10 80 00 04 08 00 00 00 00 00 00 00 01"); - - Match match = matchDeserializer.deserialize(buffer); - - Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType()); - Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntries().size()); - } +/* + * 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.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageCodeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +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.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.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.Ipv6ExthdrFlags; +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.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.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; + +/** + * @author michal.polkorab + * + */ +public class MatchDeserializerTest { + + private OFDeserializer matchDeserializer; + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + matchDeserializer = registry.getDeserializer( + new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, + EncodeConstants.EMPTY_VALUE, Match.class)); + } + + /** + * Testing Ipv4 address deserialization + */ + @Test + public void testIpv4Address() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); + + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 12); + key.setExperimenterId(null); + OFDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntries entry = entryDeserializer.deserialize(buffer); + Assert.assertEquals("Wrong Ipv4 address format", new Ipv4Address("0.1.2.3"), + entry.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + } + + /** + * Testing Ipv6 address deserialization + */ + @Test + public void testIpv6Address() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 34 10 00 00 00 01 00 02 00 03 00 04 00 05 00 06 0F 07"); + + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 26); + key.setExperimenterId(null); + OFDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntries entry = entryDeserializer.deserialize(buffer); + Assert.assertEquals("Wrong Ipv6 address format", new Ipv6Address("0000:0001:0002:0003:0004:0005:0006:0F07"), + entry.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + } + + /** + * Testing match deserialization + */ + @Test + public void testMatch() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 01 01 AC " + + "80 00 00 04 00 00 00 01 " + + "80 00 02 04 00 00 00 02 " + + "80 00 05 10 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 04 " + + "80 00 07 0C 00 00 00 00 00 05 00 00 00 00 00 06 " + + "80 00 09 0C 00 00 00 00 00 07 00 00 00 00 00 08 " + + "80 00 0A 02 00 09 " + + "80 00 0D 04 00 0A 00 0B " + + "80 00 0E 01 0C " + + "80 00 10 01 0D " + + "80 00 12 01 0E " + + "80 00 14 01 0F " + + "80 00 17 08 0A 00 00 01 00 00 FF 00 " + + "80 00 19 08 0A 00 00 02 00 00 00 FF " + + "80 00 1A 02 00 03 " + + "80 00 1C 02 00 04 " + + "80 00 1E 02 00 05 " + + "80 00 20 02 00 06 " + + "80 00 22 02 00 07 " + + "80 00 24 02 00 08 " + + "80 00 26 01 05 " + + "80 00 28 01 07 " + + "80 00 2A 02 00 10 " + + "80 00 2D 08 0A 00 00 09 00 00 FF 00 " + + "80 00 2F 08 0A 00 00 0A 00 00 00 FF " + + "80 00 31 0C 00 00 00 00 00 01 00 00 00 00 00 03 " + + "80 00 33 0C 00 00 00 00 00 02 00 00 00 00 00 04 " + + "80 00 35 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 15 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16 " + + "80 00 37 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 17 " + + "00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18 " + + "80 00 39 08 00 00 00 02 00 00 00 03 " + + "80 00 3A 01 15 " + + "80 00 3C 01 17 " + + "80 00 3E 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 20 " //ipv6ndtarget + + "80 00 40 06 00 05 00 00 00 01 " + + "80 00 42 06 00 05 00 00 00 02 " + + "80 00 44 04 00 00 02 03 " + + "80 00 46 01 03 " + + "80 00 48 01 01 " + + "80 00 4B 06 00 00 02 00 00 01 " + + "80 00 4D 10 00 00 00 00 00 00 00 07 00 00 00 00 00 00 00 FF " + + "80 00 4F 04 00 00 03 04 " + + "00 00 00 00"); + + Match match = matchDeserializer.deserialize(buffer); + Assert.assertEquals("Wrong match type", OxmMatchType.class, match.getType()); + Assert.assertEquals("Wrong match entries size", 40, match.getMatchEntries().size()); + List entries = match.getMatchEntries(); + MatchEntries entry0 = entries.get(0); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry0.getOxmClass()); + Assert.assertEquals("Wrong entry field", InPort.class, entry0.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry0.isHasMask()); + Assert.assertEquals("Wrong entry value", 1, + entry0.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + MatchEntries entry1 = entries.get(1); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry1.getOxmClass()); + Assert.assertEquals("Wrong entry field", InPhyPort.class, entry1.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry1.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry1.getAugmentation(PortNumberMatchEntry.class).getPortNumber().getValue().intValue()); + MatchEntries entry2 = entries.get(2); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry2.getOxmClass()); + Assert.assertEquals("Wrong entry field", Metadata.class, entry2.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry2.isHasMask()); + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 03"), + entry2.getAugmentation(MetadataMatchEntry.class).getMetadata()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 04"), + entry2.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry3 = entries.get(3); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry3.getOxmClass()); + Assert.assertEquals("Wrong entry field", EthDst.class, entry3.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry3.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:05"), + entry3.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 06"), + entry3.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry4 = entries.get(4); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry4.getOxmClass()); + Assert.assertEquals("Wrong entry field", EthSrc.class, entry4.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry4.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:07"), + entry4.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 08"), + entry4.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry5 = entries.get(5); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry5.getOxmClass()); + Assert.assertEquals("Wrong entry field", EthType.class, entry5.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry5.isHasMask()); + Assert.assertEquals("Wrong entry value", 9, + entry5.getAugmentation(EthTypeMatchEntry.class).getEthType().getValue().intValue()); + MatchEntries entry6 = entries.get(6); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry6.getOxmClass()); + Assert.assertEquals("Wrong entry field", VlanVid.class, entry6.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry6.isHasMask()); + Assert.assertEquals("Wrong entry value", 10, + entry6.getAugmentation(VlanVidMatchEntry.class).getVlanVid().intValue()); + Assert.assertEquals("Wrong entry value", false, + entry6.getAugmentation(VlanVidMatchEntry.class).isCfiBit()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 0B"), + entry6.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry7 = entries.get(7); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry7.getOxmClass()); + Assert.assertEquals("Wrong entry field", VlanPcp.class, entry7.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry7.isHasMask()); + Assert.assertEquals("Wrong entry value", 12, + entry7.getAugmentation(VlanPcpMatchEntry.class).getVlanPcp().intValue()); + MatchEntries entry8 = entries.get(8); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry8.getOxmClass()); + Assert.assertEquals("Wrong entry field", IpDscp.class, entry8.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry8.isHasMask()); + Assert.assertEquals("Wrong entry value", 13, + entry8.getAugmentation(DscpMatchEntry.class).getDscp().getValue().intValue()); + MatchEntries entry9 = entries.get(9); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry9.getOxmClass()); + Assert.assertEquals("Wrong entry field", IpEcn.class, entry9.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry9.isHasMask()); + Assert.assertEquals("Wrong entry value", 14, + entry9.getAugmentation(EcnMatchEntry.class).getEcn().intValue()); + MatchEntries entry10 = entries.get(10); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry10.getOxmClass()); + Assert.assertEquals("Wrong entry field", IpProto.class, entry10.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry10.isHasMask()); + Assert.assertEquals("Wrong entry value", 15, + entry10.getAugmentation(ProtocolNumberMatchEntry.class).getProtocolNumber().intValue()); + MatchEntries entry11 = entries.get(11); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry11.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv4Src.class, entry11.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry11.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.1"), + entry11.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), + entry11.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry12 = entries.get(12); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry12.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry12.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry12.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.2"), + entry12.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), + entry12.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry13 = entries.get(13); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry13.getOxmClass()); + Assert.assertEquals("Wrong entry field", TcpSrc.class, entry13.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry13.isHasMask()); + Assert.assertEquals("Wrong entry value", 3, + entry13.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry14 = entries.get(14); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry14.getOxmClass()); + Assert.assertEquals("Wrong entry field", TcpDst.class, entry14.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry14.isHasMask()); + Assert.assertEquals("Wrong entry value", 4, + entry14.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry15 = entries.get(15); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry15.getOxmClass()); + Assert.assertEquals("Wrong entry field", UdpSrc.class, entry15.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry15.isHasMask()); + Assert.assertEquals("Wrong entry value", 5, + entry15.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry16 = entries.get(16); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry16.getOxmClass()); + Assert.assertEquals("Wrong entry field", UdpDst.class, entry16.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry16.isHasMask()); + Assert.assertEquals("Wrong entry value", 6, + entry16.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry17 = entries.get(17); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry17.getOxmClass()); + Assert.assertEquals("Wrong entry field", SctpSrc.class, entry17.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry17.isHasMask()); + Assert.assertEquals("Wrong entry value", 7, + entry17.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry18 = entries.get(18); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry18.getOxmClass()); + Assert.assertEquals("Wrong entry field", SctpDst.class, entry18.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry18.isHasMask()); + Assert.assertEquals("Wrong entry value", 8, + entry18.getAugmentation(PortMatchEntry.class).getPort().getValue().intValue()); + MatchEntries entry19 = entries.get(19); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry19.getOxmClass()); + Assert.assertEquals("Wrong entry field", Icmpv4Type.class, entry19.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry19.isHasMask()); + Assert.assertEquals("Wrong entry value", 5, + entry19.getAugmentation(Icmpv4TypeMatchEntry.class).getIcmpv4Type().intValue()); + MatchEntries entry20 = entries.get(20); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry20.getOxmClass()); + Assert.assertEquals("Wrong entry field", Icmpv4Code.class, entry20.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry20.isHasMask()); + Assert.assertEquals("Wrong entry value", 7, + entry20.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code().intValue()); + MatchEntries entry21 = entries.get(21); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry21.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpOp.class, entry21.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry21.isHasMask()); + Assert.assertEquals("Wrong entry value", 16, + entry21.getAugmentation(OpCodeMatchEntry.class).getOpCode().intValue()); + MatchEntries entry22 = entries.get(22); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry22.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpSpa.class, entry22.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry22.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.9"), + entry22.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 FF 00"), + entry22.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry23 = entries.get(23); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry23.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpTpa.class, entry23.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry23.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv4Address("10.0.0.10"), + entry23.getAugmentation(Ipv4AddressMatchEntry.class).getIpv4Address()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 FF"), + entry23.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry24 = entries.get(24); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry24.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpSha.class, entry24.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry24.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:01"), + entry24.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 03"), + entry24.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry25 = entries.get(25); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry25.getOxmClass()); + Assert.assertEquals("Wrong entry field", ArpTha.class, entry25.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry25.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:00:00:00:00:02"), + entry25.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 04"), + entry25.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry26 = entries.get(26); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry26.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Src.class, entry26.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry26.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0015"), + entry26.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + Assert.assertArrayEquals("Wrong entry mask", + ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 16"), + entry26.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry27 = entries.get(27); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry27.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Dst.class, entry27.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry27.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0017"), + entry27.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + Assert.assertArrayEquals("Wrong entry mask", + ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 18"), + entry27.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry28 = entries.get(28); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry28.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Flabel.class, entry28.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry28.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry28.getAugmentation(Ipv6FlabelMatchEntry.class).getIpv6Flabel().getValue().intValue()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 03"), + entry28.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry29 = entries.get(29); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry29.getOxmClass()); + Assert.assertEquals("Wrong entry field", Icmpv6Type.class, entry29.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry29.isHasMask()); + Assert.assertEquals("Wrong entry value", 21, + entry29.getAugmentation(Icmpv6TypeMatchEntry.class).getIcmpv6Type().intValue()); + MatchEntries entry30 = entries.get(30); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry30.getOxmClass()); + Assert.assertEquals("Wrong entry field", Icmpv6Code.class, entry30.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry30.isHasMask()); + Assert.assertEquals("Wrong entry value", 23, + entry30.getAugmentation(Icmpv6CodeMatchEntry.class).getIcmpv6Code().intValue()); + MatchEntries entry31 = entries.get(31); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry31.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6NdTarget.class, entry31.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry31.isHasMask()); + Assert.assertEquals("Wrong entry value", new Ipv6Address("0000:0000:0000:0000:0000:0000:0000:0020"), + entry31.getAugmentation(Ipv6AddressMatchEntry.class).getIpv6Address()); + MatchEntries entry32 = entries.get(32); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry32.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6NdSll.class, entry32.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry32.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:01"), + entry32.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + MatchEntries entry33 = entries.get(33); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry33.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6NdTll.class, entry33.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry33.isHasMask()); + Assert.assertEquals("Wrong entry value", new MacAddress("00:05:00:00:00:02"), + entry33.getAugmentation(MacAddressMatchEntry.class).getMacAddress()); + MatchEntries entry34 = entries.get(34); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry34.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsLabel.class, entry34.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry34.isHasMask()); + Assert.assertEquals("Wrong entry value", 515, + entry34.getAugmentation(MplsLabelMatchEntry.class).getMplsLabel().intValue()); + MatchEntries entry35 = entries.get(35); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry35.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsTc.class, entry35.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry35.isHasMask()); + Assert.assertEquals("Wrong entry value", 3, + entry35.getAugmentation(TcMatchEntry.class).getTc().intValue()); + MatchEntries entry36 = entries.get(36); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry36.getOxmClass()); + Assert.assertEquals("Wrong entry field", MplsBos.class, entry36.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry36.isHasMask()); + Assert.assertEquals("Wrong entry value", true, + entry36.getAugmentation(BosMatchEntry.class).isBos()); + MatchEntries entry37 = entries.get(37); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry37.getOxmClass()); + Assert.assertEquals("Wrong entry field", PbbIsid.class, entry37.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry37.isHasMask()); + Assert.assertEquals("Wrong entry value", 2, + entry37.getAugmentation(IsidMatchEntry.class).getIsid().intValue()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 01"), + entry37.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry38 = entries.get(38); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry38.getOxmClass()); + Assert.assertEquals("Wrong entry field", TunnelId.class, entry38.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry38.isHasMask()); + Assert.assertArrayEquals("Wrong entry value", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 07"), + entry38.getAugmentation(MetadataMatchEntry.class).getMetadata()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("00 00 00 00 00 00 00 FF"), + entry38.getAugmentation(MaskMatchEntry.class).getMask()); + MatchEntries entry39 = entries.get(39); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry39.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry39.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", true, entry39.isHasMask()); + Assert.assertEquals("Wrong entry value", + new Ipv6ExthdrFlags(false, false, false, false, false, false, false, false, false), + entry39.getAugmentation(PseudoFieldMatchEntry.class).getPseudoField()); + Assert.assertArrayEquals("Wrong entry mask", ByteBufUtils.hexStringToBytes("03 04"), + entry39.getAugmentation(MaskMatchEntry.class).getMask()); + Assert.assertTrue("Unread data", buffer.readableBytes() == 0); + } + + /** + * Testing header deserialization + */ + @Test + public void testHeaders() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("80 00 18 04 00 01 02 03"); + + MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(EncodeConstants.OF13_VERSION_ID, + 0x8000, 12); + key.setExperimenterId(null); + HeaderDeserializer entryDeserializer = registry.getDeserializer(key); + MatchEntries entry = entryDeserializer.deserializeHeader(buffer); + Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); + Assert.assertEquals("Wrong entry field", Ipv4Dst.class, entry.getOxmMatchField()); + Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); + Assert.assertEquals("Wrong Ipv4 address", null, entry.getAugmentation(Ipv4AddressMatchEntry.class)); + } + + /** + * Testing standard match type + */ + @Test + public void testStandardMatch() { + ByteBuf buffer = ByteBufUtils.hexStringToByteBuf("00 00 00 10 80 00 04 08 00 00 00 00 00 00 00 01"); + + Match match = matchDeserializer.deserialize(buffer); + + Assert.assertEquals("Wrong match type", StandardMatchType.class, match.getType()); + Assert.assertEquals("Wrong match entries size", 1, match.getMatchEntries().size()); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java index 100f38c0..3e83bf4b 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsDeserializerTest.java @@ -1,135 +1,135 @@ -/* - * 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.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; -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.actions.grouping.Action; - -/** - * @author michal.polkorab - * - */ -public class OF10ActionsDeserializerTest { - - private DeserializerRegistry registry; - - /** - * Initializes deserializer registry and lookups correct deserializer - */ - @Before - public void startUp() { - registry = new DeserializerRegistryImpl(); - registry.init(); - } - - /** - * Testing correct deserialization of actions (OF v1.0) - */ - @Test - public void test() { - ByteBuf message = BufferHelper.buildBuffer("00 00 00 08 00 10 20 00 " - + "00 01 00 08 10 10 00 00 " - + "00 02 00 08 25 00 00 00 " - + "00 03 00 08 00 00 00 00 " - + "00 04 00 10 01 02 03 04 05 06 00 00 00 00 00 00 " - + "00 05 00 10 02 03 04 05 06 07 00 00 00 00 00 00 " - + "00 06 00 08 0A 00 00 01 " - + "00 07 00 08 0B 00 00 02 " - + "00 08 00 08 01 00 00 00 " - + "00 09 00 08 00 02 00 00 " - + "00 0A 00 08 00 03 00 00 " - + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30"); - - message.skipBytes(4); // skip XID - CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); - List actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, - message.readableBytes(), message, keyMaker, registry); - Assert.assertEquals("Wrong number of actions", 12, actions.size()); - Action action1 = actions.get(0); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.Output", action1.getType().getName()); - Assert.assertEquals("Wrong port", 16, - action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); - Assert.assertEquals("Wrong max-length", 8192, - action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); - Action action2 = actions.get(1); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetVlanVid", action2.getType().getName()); - Assert.assertEquals("Wrong vlan-vid", 4112, - action2.getAugmentation(VlanVidAction.class).getVlanVid().intValue()); - Action action3 = actions.get(2); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetVlanPcp", action3.getType().getName()); - Assert.assertEquals("Wrong vlan-pcp", 37, - action3.getAugmentation(VlanPcpAction.class).getVlanPcp().intValue()); - Action action4 = actions.get(3); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.StripVlan", action4.getType().getName()); - Action action5 = actions.get(4); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetDlSrc", action5.getType().getName()); - Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), - ByteBufUtils.macAddressToBytes(action5.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - Action action6 = actions.get(5); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetDlDst", action6.getType().getName()); - Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), - ByteBufUtils.macAddressToBytes(action6.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); - Action action7 = actions.get(6); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwSrc", action7.getType().getName()); - Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), - action7.getAugmentation(IpAddressAction.class).getIpAddress()); - Action action8 = actions.get(7); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwDst", action8.getType().getName()); - Assert.assertEquals("Wrong nw-dst", new Ipv4Address("11.0.0.2"), - action8.getAugmentation(IpAddressAction.class).getIpAddress()); - Action action9 = actions.get(8); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetNwTos", action9.getType().getName()); - Assert.assertEquals("Wrong nw-tos", 1, action9.getAugmentation(NwTosAction.class).getNwTos().intValue()); - Action action10 = actions.get(9); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetTpSrc", action10.getType().getName()); - Assert.assertEquals("Wrong port", 2, action10.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Action action11 = actions.get(10); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.SetTpDst", action11.getType().getName()); - Assert.assertEquals("Wrong port", 3, action11.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Action action12 = actions.get(11); - Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" - + ".openflow.common.action.rev130731.Enqueue", action12.getType().getName()); - Assert.assertEquals("Wrong port", 4, action12.getAugmentation(PortAction.class) - .getPort().getValue().intValue()); - Assert.assertEquals("Wrong queue-id", 48, - action12.getAugmentation(QueueIdAction.class).getQueueId().intValue()); - } - -} +/* + * 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.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.deserialization.DeserializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DlAddressAction; +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.actions.grouping.Action; + +/** + * @author michal.polkorab + * + */ +public class OF10ActionsDeserializerTest { + + private DeserializerRegistry registry; + + /** + * Initializes deserializer registry and lookups correct deserializer + */ + @Before + public void startUp() { + registry = new DeserializerRegistryImpl(); + registry.init(); + } + + /** + * Testing correct deserialization of actions (OF v1.0) + */ + @Test + public void test() { + ByteBuf message = BufferHelper.buildBuffer("00 00 00 08 00 10 20 00 " + + "00 01 00 08 10 10 00 00 " + + "00 02 00 08 25 00 00 00 " + + "00 03 00 08 00 00 00 00 " + + "00 04 00 10 01 02 03 04 05 06 00 00 00 00 00 00 " + + "00 05 00 10 02 03 04 05 06 07 00 00 00 00 00 00 " + + "00 06 00 08 0A 00 00 01 " + + "00 07 00 08 0B 00 00 02 " + + "00 08 00 08 01 00 00 00 " + + "00 09 00 08 00 02 00 00 " + + "00 0A 00 08 00 03 00 00 " + + "00 0B 00 10 00 04 00 00 00 00 00 00 00 00 00 30"); + + message.skipBytes(4); // skip XID + CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); + List actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, + message.readableBytes(), message, keyMaker, registry); + Assert.assertEquals("Wrong number of actions", 12, actions.size()); + Action action1 = actions.get(0); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.Output", action1.getType().getName()); + Assert.assertEquals("Wrong port", 16, + action1.getAugmentation(PortAction.class).getPort().getValue().intValue()); + Assert.assertEquals("Wrong max-length", 8192, + action1.getAugmentation(MaxLengthAction.class).getMaxLength().intValue()); + Action action2 = actions.get(1); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetVlanVid", action2.getType().getName()); + Assert.assertEquals("Wrong vlan-vid", 4112, + action2.getAugmentation(VlanVidAction.class).getVlanVid().intValue()); + Action action3 = actions.get(2); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetVlanPcp", action3.getType().getName()); + Assert.assertEquals("Wrong vlan-pcp", 37, + action3.getAugmentation(VlanPcpAction.class).getVlanPcp().intValue()); + Action action4 = actions.get(3); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.StripVlan", action4.getType().getName()); + Action action5 = actions.get(4); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetDlSrc", action5.getType().getName()); + Assert.assertArrayEquals("Wrong dl-src", ByteBufUtils.macAddressToBytes("01:02:03:04:05:06"), + ByteBufUtils.macAddressToBytes(action5.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); + Action action6 = actions.get(5); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetDlDst", action6.getType().getName()); + Assert.assertArrayEquals("Wrong dl-dst", ByteBufUtils.macAddressToBytes("02:03:04:05:06:07"), + ByteBufUtils.macAddressToBytes(action6.getAugmentation(DlAddressAction.class).getDlAddress().getValue())); + Action action7 = actions.get(6); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetNwSrc", action7.getType().getName()); + Assert.assertEquals("Wrong nw-src", new Ipv4Address("10.0.0.1"), + action7.getAugmentation(IpAddressAction.class).getIpAddress()); + Action action8 = actions.get(7); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetNwDst", action8.getType().getName()); + Assert.assertEquals("Wrong nw-dst", new Ipv4Address("11.0.0.2"), + action8.getAugmentation(IpAddressAction.class).getIpAddress()); + Action action9 = actions.get(8); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetNwTos", action9.getType().getName()); + Assert.assertEquals("Wrong nw-tos", 1, action9.getAugmentation(NwTosAction.class).getNwTos().intValue()); + Action action10 = actions.get(9); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetTpSrc", action10.getType().getName()); + Assert.assertEquals("Wrong port", 2, action10.getAugmentation(PortAction.class) + .getPort().getValue().intValue()); + Action action11 = actions.get(10); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.SetTpDst", action11.getType().getName()); + Assert.assertEquals("Wrong port", 3, action11.getAugmentation(PortAction.class) + .getPort().getValue().intValue()); + Action action12 = actions.get(11); + Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight" + + ".openflow.common.action.rev130731.Enqueue", action12.getType().getName()); + Assert.assertEquals("Wrong port", 4, action12.getAugmentation(PortAction.class) + .getPort().getValue().intValue()); + Assert.assertEquals("Wrong queue-id", 48, + action12.getAugmentation(QueueIdAction.class).getQueueId().intValue()); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java index 4a80e8c3..3b72cb4d 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF10ActionsSerializerTest.java @@ -1,219 +1,219 @@ -/* - * 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.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.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.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.VlanPcpAction; -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.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; - -/** - * @author michal.polkorab - * - */ -public class OF10ActionsSerializerTest { - - private SerializerRegistry registry; - - /** - * Initializes serializer table and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - } - - /** - * Testing correct serialization of actions (OF v1.0) - */ - @Test - public void test() { - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(32); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetVlanVid.class); - VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); - vlanBuilder.setVlanVid(15); - actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetVlanPcp.class); - VlanPcpActionBuilder pcpBuilder = new VlanPcpActionBuilder(); - pcpBuilder.setVlanPcp((short) 16); - actionBuilder.addAugmentation(VlanPcpAction.class, pcpBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(StripVlan.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetDlSrc.class); - DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); - dlBuilder.setDlAddress(new MacAddress("00:00:00:02:03:04")); - actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetDlDst.class); - dlBuilder = new DlAddressActionBuilder(); - dlBuilder.setDlAddress(new MacAddress("00:00:00:01:02:03")); - actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwSrc.class); - IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address("10.0.0.1")); - actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwDst.class); - ipBuilder = new IpAddressActionBuilder(); - ipBuilder.setIpAddress(new Ipv4Address("10.0.0.3")); - actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTos.class); - NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); - tosBuilder.setNwTos((short) 204); - actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetTpSrc.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6653L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetTpDst.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6633L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(Enqueue.class); - portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(6613L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); - queueBuilder.setQueueId(400L); - actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build()); - actions.add(actionBuilder.build()); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(actions, TypeKeyMakerFactory - .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out); - - 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 max-length", 32, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong vlan-vid", 15, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong vlan-pcp", 16, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - byte[] data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - out.readBytes(data); - Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:02:03:04"), data); - out.skipBytes(6); - Assert.assertEquals("Wrong action type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; - out.readBytes(data); - Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:01:02:03"), data); - out.skipBytes(6); - Assert.assertEquals("Wrong action type", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(4)", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong action type", 7, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong ip-address(4)", 3, out.readUnsignedByte()); - Assert.assertEquals("Wrong action type", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong nw-tos", 204, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong action type", 9, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong port", 6653, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 10, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong port", 6633, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong port", 6613, out.readUnsignedShort()); - out.skipBytes(6); - Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt()); - Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0); - } - +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.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.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.VlanPcpAction; +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.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; + +/** + * @author michal.polkorab + * + */ +public class OF10ActionsSerializerTest { + + private SerializerRegistry registry; + + /** + * Initializes serializer table and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + } + + /** + * Testing correct serialization of actions (OF v1.0) + */ + @Test + public void test() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(42L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(32); + actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetVlanVid.class); + VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); + vlanBuilder.setVlanVid(15); + actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetVlanPcp.class); + VlanPcpActionBuilder pcpBuilder = new VlanPcpActionBuilder(); + pcpBuilder.setVlanPcp((short) 16); + actionBuilder.addAugmentation(VlanPcpAction.class, pcpBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(StripVlan.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetDlSrc.class); + DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); + dlBuilder.setDlAddress(new MacAddress("00:00:00:02:03:04")); + actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetDlDst.class); + dlBuilder = new DlAddressActionBuilder(); + dlBuilder.setDlAddress(new MacAddress("00:00:00:01:02:03")); + actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwSrc.class); + IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); + ipBuilder.setIpAddress(new Ipv4Address("10.0.0.1")); + actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwDst.class); + ipBuilder = new IpAddressActionBuilder(); + ipBuilder.setIpAddress(new Ipv4Address("10.0.0.3")); + actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwTos.class); + NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); + tosBuilder.setNwTos((short) 204); + actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetTpSrc.class); + portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(6653L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetTpDst.class); + portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(6633L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(Enqueue.class); + portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(6613L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); + queueBuilder.setQueueId(400L); + actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build()); + actions.add(actionBuilder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeList(actions, TypeKeyMakerFactory + .createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out); + + 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 max-length", 32, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong vlan-vid", 15, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong vlan-pcp", 16, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + byte[] data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + out.readBytes(data); + Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:02:03:04"), data); + out.skipBytes(6); + Assert.assertEquals("Wrong action type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH]; + out.readBytes(data); + Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:01:02:03"), data); + out.skipBytes(6); + Assert.assertEquals("Wrong action type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(4)", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong action type", 7, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong ip-address(4)", 3, out.readUnsignedByte()); + Assert.assertEquals("Wrong action type", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong nw-tos", 204, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong action type", 9, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong port", 6653, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 10, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong port", 6633, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong port", 6613, out.readUnsignedShort()); + out.skipBytes(6); + Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt()); + Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0); + } + } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java index f801dee3..4f01fd20 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13ActionsSerializerTest.java @@ -1,287 +1,287 @@ -/* - * 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.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -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.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.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -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.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.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13ActionsSerializerTest { - - private SerializerRegistry registry; - - /** - * Initializes serializer table and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - } - - /** - * Testing correct serialization of actions - */ - @Test - public void test() { - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(52); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(CopyTtlOut.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(CopyTtlIn.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetMplsTtl.class); - MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); - mplsTtl.setMplsTtl((short) 4); - actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(DecMplsTtl.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushVlan.class); - EthertypeActionBuilder etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(16)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopVlan.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushMpls.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(17)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopMpls.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(18)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetQueue.class); - QueueIdActionBuilder queueId = new QueueIdActionBuilder(); - queueId.setQueueId(1234L); - actionBuilder.addAugmentation(QueueIdAction.class, queueId.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(Group.class); - GroupIdActionBuilder group = new GroupIdActionBuilder(); - group.setGroupId(555L); - actionBuilder.addAugmentation(GroupIdAction.class, group.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTtl.class); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl((short) 8); - actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(DecNwTtl.class); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetField.class); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); - matchBuilder.setOxmClass(OpenflowBasicClass.class); - matchBuilder.setOxmMatchField(InPort.class); - matchBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); - portBuilder.setPortNumber(new PortNumber(1L)); - matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); - entries.add(matchBuilder.build()); - matchEntries.setMatchEntries(entries); - actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushPbb.class); - etherType = new EthertypeActionBuilder(); - etherType.setEthertype(new EtherType(19)); - actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopPbb.class); - actions.add(actionBuilder.build()); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(actions, TypeKeyMakerFactory - .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); - - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt()); - Assert.assertEquals("Wrong action max-length", 52, out.readUnsignedShort()); - out.skipBytes(6); - Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 12, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 15, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action mpls-ttl", 4, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong action type", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 16, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 19, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 17, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 20, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 18, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 21, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action queue-id", 1234, out.readUnsignedInt()); - Assert.assertEquals("Wrong action type", 22, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action group", 555, out.readUnsignedInt()); - Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action nw-ttl", 8, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong action type", 24, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & mask", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedInt()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 26, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 19, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } - - /** - * Testing correct serialization of actions - */ - @Test - public void testHeaders() { - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder port = new PortActionBuilder(); - port.setPort(new PortNumber(42L)); - actionBuilder.addAugmentation(PortAction.class, port.build()); - MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); - maxLen.setMaxLength(52); - actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetField.class); - OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); - List entries = new ArrayList<>(); - MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); - matchBuilder.setOxmClass(OpenflowBasicClass.class); - matchBuilder.setOxmMatchField(InPort.class); - matchBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); - portBuilder.setPortNumber(new PortNumber(1L)); - matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); - entries.add(matchBuilder.build()); - matchEntries.setMatchEntries(entries); - actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); - actions.add(actionBuilder.build()); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeHeaderList(actions, TypeKeyMakerFactory - .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); - - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); - Assert.assertTrue("Unread data", out.readableBytes() == 0); - } +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +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.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.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; +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.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.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13ActionsSerializerTest { + + private SerializerRegistry registry; + + /** + * Initializes serializer table and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + } + + /** + * Testing correct serialization of actions + */ + @Test + public void test() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder port = new PortActionBuilder(); + port.setPort(new PortNumber(42L)); + actionBuilder.addAugmentation(PortAction.class, port.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(52); + actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(CopyTtlOut.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(CopyTtlIn.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetMplsTtl.class); + MplsTtlActionBuilder mplsTtl = new MplsTtlActionBuilder(); + mplsTtl.setMplsTtl((short) 4); + actionBuilder.addAugmentation(MplsTtlAction.class, mplsTtl.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(DecMplsTtl.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PushVlan.class); + EthertypeActionBuilder etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(16)); + actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PopVlan.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PushMpls.class); + etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(17)); + actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PopMpls.class); + etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(18)); + actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetQueue.class); + QueueIdActionBuilder queueId = new QueueIdActionBuilder(); + queueId.setQueueId(1234L); + actionBuilder.addAugmentation(QueueIdAction.class, queueId.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(Group.class); + GroupIdActionBuilder group = new GroupIdActionBuilder(); + group.setGroupId(555L); + actionBuilder.addAugmentation(GroupIdAction.class, group.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwTtl.class); + NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); + nwTtl.setNwTtl((short) 8); + actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(DecNwTtl.class); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetField.class); + OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + List entries = new ArrayList<>(); + MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); + matchBuilder.setOxmClass(OpenflowBasicClass.class); + matchBuilder.setOxmMatchField(InPort.class); + matchBuilder.setHasMask(false); + PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); + portBuilder.setPortNumber(new PortNumber(1L)); + matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); + entries.add(matchBuilder.build()); + matchEntries.setMatchEntries(entries); + actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PushPbb.class); + etherType = new EthertypeActionBuilder(); + etherType.setEthertype(new EtherType(19)); + actionBuilder.addAugmentation(EthertypeAction.class, etherType.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PopPbb.class); + actions.add(actionBuilder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeList(actions, TypeKeyMakerFactory + .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); + + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt()); + Assert.assertEquals("Wrong action max-length", 52, out.readUnsignedShort()); + out.skipBytes(6); + Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 12, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 15, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action mpls-ttl", 4, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong action type", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 16, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 19, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 17, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 20, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 18, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 21, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action queue-id", 1234, out.readUnsignedInt()); + Assert.assertEquals("Wrong action type", 22, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action group", 555, out.readUnsignedInt()); + Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action nw-ttl", 8, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong action type", 24, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & mask", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedInt()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 26, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 19, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } + + /** + * Testing correct serialization of actions + */ + @Test + public void testHeaders() { + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder port = new PortActionBuilder(); + port.setPort(new PortNumber(42L)); + actionBuilder.addAugmentation(PortAction.class, port.build()); + MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); + maxLen.setMaxLength(52); + actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetField.class); + OxmFieldsActionBuilder matchEntries = new OxmFieldsActionBuilder(); + List entries = new ArrayList<>(); + MatchEntriesBuilder matchBuilder = new MatchEntriesBuilder(); + matchBuilder.setOxmClass(OpenflowBasicClass.class); + matchBuilder.setOxmMatchField(InPort.class); + matchBuilder.setHasMask(false); + PortNumberMatchEntryBuilder portBuilder = new PortNumberMatchEntryBuilder(); + portBuilder.setPortNumber(new PortNumber(1L)); + matchBuilder.addAugmentation(PortNumberMatchEntry.class, portBuilder.build()); + entries.add(matchBuilder.build()); + matchEntries.setMatchEntries(entries); + actionBuilder.addAugmentation(OxmFieldsAction.class, matchEntries.build()); + actions.add(actionBuilder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeHeaderList(actions, TypeKeyMakerFactory + .createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); + + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); + Assert.assertTrue("Unread data", out.readableBytes() == 0); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java index 902f8b58..68fe7510 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13InstructionsSerializerTest.java @@ -1,196 +1,196 @@ -/* - * 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.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.openflowjava.util.ByteBufUtils; -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.EthertypeAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; -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.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.NwTtlAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; -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.TableIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; -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.PushVlan; -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.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -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.GotoTable; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -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; - -/** - * @author michal.polkorab - * - */ -public class OF13InstructionsSerializerTest { - - private SerializerRegistry registry; - - /** - * Initializes serializer table and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - } - - /** - * Testing instructions translation - */ - @Test - public void test() { - List instructions = new ArrayList<>(); - // Goto_table instruction - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(GotoTable.class); - TableIdInstructionBuilder tableIdBuilder = new TableIdInstructionBuilder(); - tableIdBuilder.setTableId((short) 5); - builder.addAugmentation(TableIdInstruction.class, tableIdBuilder.build()); - instructions.add(builder.build()); - builder = new InstructionBuilder(); - // Write_metadata instruction - builder.setType(WriteMetadata.class); - MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder(); - metaBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07")); - metaBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00")); - builder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); - instructions.add(builder.build()); - // Clear_actions instruction - builder = new InstructionBuilder(); - builder.setType(ClearActions.class); - instructions.add(builder.build()); - // Meter instruction - builder = new InstructionBuilder(); - builder.setType(Meter.class); - MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); - meterBuilder.setMeterId(42L); - builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); - instructions.add(builder.build()); - // Write_actions instruction - builder = new InstructionBuilder(); - builder.setType(WriteActions.class); - ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); - List actions = new ArrayList<>(); - ActionBuilder actionBuilder = new ActionBuilder(); - actionBuilder.setType(Output.class); - PortActionBuilder portBuilder = new PortActionBuilder(); - portBuilder.setPort(new PortNumber(45L)); - actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); - MaxLengthActionBuilder maxBuilder = new MaxLengthActionBuilder(); - maxBuilder.setMaxLength(55); - actionBuilder.addAugmentation(MaxLengthAction.class, maxBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(SetNwTtl.class); - NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); - nwTtl.setNwTtl((short) 64); - actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); - actions.add(actionBuilder.build()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - instructions.add(builder.build()); - // Apply_actions instruction - builder = new InstructionBuilder(); - builder.setType(ApplyActions.class); - actionsBuilder = new ActionsInstructionBuilder(); - actions = new ArrayList<>(); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PushVlan.class); - EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder(); - ethertypeBuilder.setEthertype(new EtherType(14)); - actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build()); - actions.add(actionBuilder.build()); - actionBuilder = new ActionBuilder(); - actionBuilder.setType(PopPbb.class); - actions.add(actionBuilder.build()); - actionsBuilder.setAction(actions); - builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); - instructions.add(builder.build()); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - ListSerializer.serializeList(instructions, TypeKeyMakerFactory - .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); - - Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); - out.skipBytes(4); - byte[] actual = new byte[8]; - out.readBytes(actual); - Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", - ByteBufUtils.bytesToHexString(actual)); - actual = new byte[8]; - out.readBytes(actual); - Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", - ByteBufUtils.bytesToHexString(actual)); - Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction meter-id", 42, out.readUnsignedInt()); - Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 32, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 45, out.readUnsignedInt()); - Assert.assertEquals("Wrong action type", 55, out.readUnsignedShort()); - out.skipBytes(6); - Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action type", 64, out.readUnsignedByte()); - out.skipBytes(3); - Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); - Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - Assert.assertEquals("Wrong action ethertype", 14, out.readUnsignedShort()); - out.skipBytes(2); - Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); - Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); - out.skipBytes(4); - Assert.assertTrue("Not all data were read", out.readableBytes() == 0); - } - -} +/* + * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.openflowjava.protocol.impl.util; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.openflowjava.util.ByteBufUtils; +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.EthertypeAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthertypeActionBuilder; +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.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.NwTtlAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.NwTtlActionBuilder; +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.TableIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TableIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.Output; +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.PushVlan; +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.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +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.GotoTable; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.Meter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteActions; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.WriteMetadata; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +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; + +/** + * @author michal.polkorab + * + */ +public class OF13InstructionsSerializerTest { + + private SerializerRegistry registry; + + /** + * Initializes serializer table and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + } + + /** + * Testing instructions translation + */ + @Test + public void test() { + List instructions = new ArrayList<>(); + // Goto_table instruction + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(GotoTable.class); + TableIdInstructionBuilder tableIdBuilder = new TableIdInstructionBuilder(); + tableIdBuilder.setTableId((short) 5); + builder.addAugmentation(TableIdInstruction.class, tableIdBuilder.build()); + instructions.add(builder.build()); + builder = new InstructionBuilder(); + // Write_metadata instruction + builder.setType(WriteMetadata.class); + MetadataInstructionBuilder metaBuilder = new MetadataInstructionBuilder(); + metaBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07")); + metaBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00")); + builder.addAugmentation(MetadataInstruction.class, metaBuilder.build()); + instructions.add(builder.build()); + // Clear_actions instruction + builder = new InstructionBuilder(); + builder.setType(ClearActions.class); + instructions.add(builder.build()); + // Meter instruction + builder = new InstructionBuilder(); + builder.setType(Meter.class); + MeterIdInstructionBuilder meterBuilder = new MeterIdInstructionBuilder(); + meterBuilder.setMeterId(42L); + builder.addAugmentation(MeterIdInstruction.class, meterBuilder.build()); + instructions.add(builder.build()); + // Write_actions instruction + builder = new InstructionBuilder(); + builder.setType(WriteActions.class); + ActionsInstructionBuilder actionsBuilder = new ActionsInstructionBuilder(); + List actions = new ArrayList<>(); + ActionBuilder actionBuilder = new ActionBuilder(); + actionBuilder.setType(Output.class); + PortActionBuilder portBuilder = new PortActionBuilder(); + portBuilder.setPort(new PortNumber(45L)); + actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); + MaxLengthActionBuilder maxBuilder = new MaxLengthActionBuilder(); + maxBuilder.setMaxLength(55); + actionBuilder.addAugmentation(MaxLengthAction.class, maxBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(SetNwTtl.class); + NwTtlActionBuilder nwTtl = new NwTtlActionBuilder(); + nwTtl.setNwTtl((short) 64); + actionBuilder.addAugmentation(NwTtlAction.class, nwTtl.build()); + actions.add(actionBuilder.build()); + actionsBuilder.setAction(actions); + builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + instructions.add(builder.build()); + // Apply_actions instruction + builder = new InstructionBuilder(); + builder.setType(ApplyActions.class); + actionsBuilder = new ActionsInstructionBuilder(); + actions = new ArrayList<>(); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PushVlan.class); + EthertypeActionBuilder ethertypeBuilder = new EthertypeActionBuilder(); + ethertypeBuilder.setEthertype(new EtherType(14)); + actionBuilder.addAugmentation(EthertypeAction.class, ethertypeBuilder.build()); + actions.add(actionBuilder.build()); + actionBuilder = new ActionBuilder(); + actionBuilder.setType(PopPbb.class); + actions.add(actionBuilder.build()); + actionsBuilder.setAction(actions); + builder.addAugmentation(ActionsInstruction.class, actionsBuilder.build()); + instructions.add(builder.build()); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + ListSerializer.serializeList(instructions, TypeKeyMakerFactory + .createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); + + Assert.assertEquals("Wrong instruction type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction table-id", 5, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong instruction type", 2, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); + out.skipBytes(4); + byte[] actual = new byte[8]; + out.readBytes(actual); + Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", + ByteBufUtils.bytesToHexString(actual)); + actual = new byte[8]; + out.readBytes(actual); + Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", + ByteBufUtils.bytesToHexString(actual)); + Assert.assertEquals("Wrong instruction type", 5, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong instruction type", 6, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction meter-id", 42, out.readUnsignedInt()); + Assert.assertEquals("Wrong instruction type", 3, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 32, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 45, out.readUnsignedInt()); + Assert.assertEquals("Wrong action type", 55, out.readUnsignedShort()); + out.skipBytes(6); + Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action type", 64, out.readUnsignedByte()); + out.skipBytes(3); + Assert.assertEquals("Wrong instruction type", 4, out.readUnsignedShort()); + Assert.assertEquals("Wrong instruction length", 24, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + Assert.assertEquals("Wrong action ethertype", 14, out.readUnsignedShort()); + out.skipBytes(2); + Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); + Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); + out.skipBytes(4); + Assert.assertTrue("Not all data were read", out.readableBytes() == 0); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java index 6ed7c7e7..e607d0fc 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OF13MatchSerializer02Test.java @@ -1,793 +1,793 @@ -/* - * 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.Before; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; -import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; -import org.opendaylight.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.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.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class OF13MatchSerializer02Test { - - private SerializerRegistry registry; - private OFSerializer matchSerializer; - - /** - * Initializes serializer table and stores correct factory in field - */ - @Before - public void startUp() { - registry = new SerializerRegistryImpl(); - registry.init(); - matchSerializer = registry.getSerializer( - new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class)); - } - - /** - * Testing serialization of match - */ - @Test - public void testEmptyMatch() { - MatchBuilder builder = new MatchBuilder(); - builder.setType(OxmMatchType.class); - Match match = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - matchSerializer.serialize(match, out); - - Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort()); - Assert.assertTrue("Wrong padding", out.readableBytes() == 4); - } - - /** - * Testing serialization of match - */ - @Test - public void test() { - MatchBuilder builder = new MatchBuilder(); - builder.setType(OxmMatchType.class); - List entries = new ArrayList<>(); - MatchEntriesBuilder entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(InPort.class); - entryBuilder.setHasMask(false); - PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); - portNumberBuilder.setPortNumber(new PortNumber(42L)); - entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(InPhyPort.class); - entryBuilder.setHasMask(false); - portNumberBuilder = new PortNumberMatchEntryBuilder(); - portNumberBuilder.setPortNumber(new PortNumber(43L)); - entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Metadata.class); - entryBuilder.setHasMask(true); - MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(EthDst.class); - entryBuilder.setHasMask(true); - MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,5}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(EthSrc.class); - entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(EthType.class); - entryBuilder.setHasMask(false); - EthTypeMatchEntryBuilder ethBuilder = new EthTypeMatchEntryBuilder(); - ethBuilder.setEthType(new EtherType(46)); - entryBuilder.addAugmentation(EthTypeMatchEntry.class, ethBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(VlanVid.class); - entryBuilder.setHasMask(true); - VlanVidMatchEntryBuilder vidBuilder = new VlanVidMatchEntryBuilder(); - vidBuilder.setCfiBit(true); - vidBuilder.setVlanVid(45); - entryBuilder.addAugmentation(VlanVidMatchEntry.class, vidBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,9}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(VlanPcp.class); - entryBuilder.setHasMask(false); - VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); - pcpBuilder.setVlanPcp((short) 14); - entryBuilder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(IpDscp.class); - entryBuilder.setHasMask(false); - DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); - dscpBuilder.setDscp(new Dscp((short) 48)); - entryBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(IpEcn.class); - entryBuilder.setHasMask(false); - EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); - ecnBuilder.setEcn((short) 49); - entryBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(IpProto.class); - entryBuilder.setHasMask(false); - ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); - protoBuilder.setProtocolNumber((short) 50); - entryBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv4Src.class); - entryBuilder.setHasMask(true); - Ipv4AddressMatchEntryBuilder ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.1")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,14}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv4Dst.class); - entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.2")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,15}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(TcpSrc.class); - entryBuilder.setHasMask(false); - PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6653)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(TcpDst.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6654)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(UdpSrc.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6655)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(UdpDst.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6656)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(SctpSrc.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6657)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(SctpDst.class); - entryBuilder.setHasMask(false); - portBuilder = new PortMatchEntryBuilder(); - portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params - .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6658)); - entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Icmpv4Type.class); - entryBuilder.setHasMask(false); - Icmpv4TypeMatchEntryBuilder icmpv4typeBuilder = new Icmpv4TypeMatchEntryBuilder(); - icmpv4typeBuilder.setIcmpv4Type((short) 51); - entryBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4typeBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Icmpv4Code.class); - entryBuilder.setHasMask(false); - Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); - icmpv4CodeBuilder.setIcmpv4Code((short) 52); - entryBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpOp.class); - entryBuilder.setHasMask(false); - OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); - opBuilder.setOpCode(53); - entryBuilder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpSpa.class); - entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.4")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,16}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpTpa.class); - entryBuilder.setHasMask(true); - ipv4Builder = new Ipv4AddressMatchEntryBuilder(); - ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.5")); - entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,17}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpSha.class); - entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,4,0,0,6}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(ArpTha.class); - entryBuilder.setHasMask(true); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,6,0,0,4}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6Src.class); - entryBuilder.setHasMask(true); - Ipv6AddressMatchEntryBuilder ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6Dst.class); - entryBuilder.setHasMask(true); - ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6Flabel.class); - entryBuilder.setHasMask(true); - Ipv6FlabelMatchEntryBuilder flabelBuilder = new Ipv6FlabelMatchEntryBuilder(); - flabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L)); - entryBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, flabelBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,1,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Icmpv6Type.class); - entryBuilder.setHasMask(false); - Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); - icmpv6TypeBuilder.setIcmpv6Type((short) 59); - entryBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Icmpv6Code.class); - entryBuilder.setHasMask(false); - Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); - icmpv6CodeBuilder.setIcmpv6Code((short) 60); - entryBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6NdTarget.class); - entryBuilder.setHasMask(false); - ipv6Builder = new Ipv6AddressMatchEntryBuilder(); - ipv6Builder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1")); - entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6NdSll.class); - entryBuilder.setHasMask(false); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6NdTll.class); - entryBuilder.setHasMask(false); - macBuilder = new MacAddressMatchEntryBuilder(); - macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); - entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(MplsLabel.class); - entryBuilder.setHasMask(false); - MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); - labelBuilder.setMplsLabel(61L); - entryBuilder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(MplsTc.class); - entryBuilder.setHasMask(false); - TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); - tcBuilder.setTc((short) 62); - entryBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); - entries.add(entryBuilder.build()); - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(MplsBos.class); - entryBuilder.setHasMask(false); - BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); - bosBuilder.setBos(true); - entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); - entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(PbbIsid.class); - entryBuilder.setHasMask(true); - IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); - isidBuilder.setIsid(64L); - entryBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,1,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(TunnelId.class); - entryBuilder.setHasMask(true); - metadataBuilder = new MetadataMatchEntryBuilder(); - metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); - entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - - entryBuilder = new MatchEntriesBuilder(); - entryBuilder.setOxmClass(OpenflowBasicClass.class); - entryBuilder.setOxmMatchField(Ipv6Exthdr.class); - entryBuilder.setHasMask(true); - PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); - pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); - entryBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); - maskBuilder = new MaskMatchEntryBuilder(); - maskBuilder.setMask(new byte[]{0,2}); - entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); - entries.add(entryBuilder.build()); - - - - builder.setMatchEntries(entries); - Match match = builder.build(); - - ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); - matchSerializer.serialize(match, out); - - Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); - Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 42, out.readUnsignedInt()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 43, out.readUnsignedInt()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 5, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); - Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 7, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); - byte[] array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{1,0,3,0,0,6}, array); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,5}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 9, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{4,0,2,0,0,8}, array); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,2}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 10, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 46, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 13, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 4141, out.readUnsignedShort()); - array = new byte[2]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,9}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 14, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 14, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 16, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 48, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 18, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 49, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 20, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 50, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 23, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,1}, array); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,14}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 25, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,2}, array); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,15}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 26, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6653, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 28, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6654, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 30, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6655, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 32, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6656, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 34, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6657, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 36, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 6658, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 38, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 51, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 40, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 52, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 42, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 53, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 45, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,4}, array); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,16}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 47, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,5}, array); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,17}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 49, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,1,2,3,4,5}, array); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,4,0,0,6}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 51, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,3}, array); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,6,0,0,4}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 53, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 55, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1}, array); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 57, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 58, out.readUnsignedInt()); - array = new byte[4]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,0,2}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 58, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 59, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 60, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 60, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 62, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); - array = new byte[16]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 64, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{1,0,3,0,0,6}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 66, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); - array = new byte[6]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{4,0,2,0,0,8}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 68, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 61, out.readUnsignedInt()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 70, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 62, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 72, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 75, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 64, out.readUnsignedMedium()); - array = new byte[3]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,2}, array); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 77, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); - Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); - Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); - Assert.assertEquals("Wrong match entry field & hasMask", 79, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); - Assert.assertEquals("Wrong match entry value", 358, out.readUnsignedShort()); - array = new byte[2]; - out.readBytes(array); - Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,2}, array); - Assert.assertTrue("Wrong padding", out.readableBytes() == 4); - } - -} +/* + * 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.Before; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer; +import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.openflowjava.protocol.impl.serialization.SerializerRegistryImpl; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Dscp; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6FlowLabel; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.BosMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.DscpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EcnMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.EthTypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6CodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv6TypeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv4AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6FlabelMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.IsidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MacAddressMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MetadataMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MplsLabelMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OpCodeMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PortNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ProtocolNumberMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.PseudoFieldMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.TcMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanPcpMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.VlanVidMatchEntryBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Ipv6ExthdrFlags; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; +import org.opendaylight.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.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.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OxmMatchType; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.PbbIsid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.SctpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TcpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.TunnelId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpDst; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.UdpSrc; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanPcp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.VlanVid; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.Match; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.match.grouping.MatchBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class OF13MatchSerializer02Test { + + private SerializerRegistry registry; + private OFSerializer matchSerializer; + + /** + * Initializes serializer table and stores correct factory in field + */ + @Before + public void startUp() { + registry = new SerializerRegistryImpl(); + registry.init(); + matchSerializer = registry.getSerializer( + new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, Match.class)); + } + + /** + * Testing serialization of match + */ + @Test + public void testEmptyMatch() { + MatchBuilder builder = new MatchBuilder(); + builder.setType(OxmMatchType.class); + Match match = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + matchSerializer.serialize(match, out); + + Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort()); + Assert.assertTrue("Wrong padding", out.readableBytes() == 4); + } + + /** + * Testing serialization of match + */ + @Test + public void test() { + MatchBuilder builder = new MatchBuilder(); + builder.setType(OxmMatchType.class); + List entries = new ArrayList<>(); + MatchEntriesBuilder entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(InPort.class); + entryBuilder.setHasMask(false); + PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); + portNumberBuilder.setPortNumber(new PortNumber(42L)); + entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(InPhyPort.class); + entryBuilder.setHasMask(false); + portNumberBuilder = new PortNumberMatchEntryBuilder(); + portNumberBuilder.setPortNumber(new PortNumber(43L)); + entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Metadata.class); + entryBuilder.setHasMask(true); + MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); + entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(EthDst.class); + entryBuilder.setHasMask(true); + MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,5}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(EthSrc.class); + entryBuilder.setHasMask(true); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(EthType.class); + entryBuilder.setHasMask(false); + EthTypeMatchEntryBuilder ethBuilder = new EthTypeMatchEntryBuilder(); + ethBuilder.setEthType(new EtherType(46)); + entryBuilder.addAugmentation(EthTypeMatchEntry.class, ethBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(VlanVid.class); + entryBuilder.setHasMask(true); + VlanVidMatchEntryBuilder vidBuilder = new VlanVidMatchEntryBuilder(); + vidBuilder.setCfiBit(true); + vidBuilder.setVlanVid(45); + entryBuilder.addAugmentation(VlanVidMatchEntry.class, vidBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,9}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(VlanPcp.class); + entryBuilder.setHasMask(false); + VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); + pcpBuilder.setVlanPcp((short) 14); + entryBuilder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(IpDscp.class); + entryBuilder.setHasMask(false); + DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); + dscpBuilder.setDscp(new Dscp((short) 48)); + entryBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(IpEcn.class); + entryBuilder.setHasMask(false); + EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); + ecnBuilder.setEcn((short) 49); + entryBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(IpProto.class); + entryBuilder.setHasMask(false); + ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); + protoBuilder.setProtocolNumber((short) 50); + entryBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv4Src.class); + entryBuilder.setHasMask(true); + Ipv4AddressMatchEntryBuilder ipv4Builder = new Ipv4AddressMatchEntryBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.1")); + entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,14}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv4Dst.class); + entryBuilder.setHasMask(true); + ipv4Builder = new Ipv4AddressMatchEntryBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.2")); + entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,15}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(TcpSrc.class); + entryBuilder.setHasMask(false); + PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6653)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(TcpDst.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6654)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(UdpSrc.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6655)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(UdpDst.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6656)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(SctpSrc.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6657)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(SctpDst.class); + entryBuilder.setHasMask(false); + portBuilder = new PortMatchEntryBuilder(); + portBuilder.setPort(new org.opendaylight.yang.gen.v1.urn.ietf.params + .xml.ns.yang.ietf.inet.types.rev100924.PortNumber(6658)); + entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Icmpv4Type.class); + entryBuilder.setHasMask(false); + Icmpv4TypeMatchEntryBuilder icmpv4typeBuilder = new Icmpv4TypeMatchEntryBuilder(); + icmpv4typeBuilder.setIcmpv4Type((short) 51); + entryBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4typeBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Icmpv4Code.class); + entryBuilder.setHasMask(false); + Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); + icmpv4CodeBuilder.setIcmpv4Code((short) 52); + entryBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpOp.class); + entryBuilder.setHasMask(false); + OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); + opBuilder.setOpCode(53); + entryBuilder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpSpa.class); + entryBuilder.setHasMask(true); + ipv4Builder = new Ipv4AddressMatchEntryBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.4")); + entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,16}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpTpa.class); + entryBuilder.setHasMask(true); + ipv4Builder = new Ipv4AddressMatchEntryBuilder(); + ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.5")); + entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,17}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpSha.class); + entryBuilder.setHasMask(true); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,4,0,0,6}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(ArpTha.class); + entryBuilder.setHasMask(true); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,6,0,0,4}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6Src.class); + entryBuilder.setHasMask(true); + Ipv6AddressMatchEntryBuilder ipv6Builder = new Ipv6AddressMatchEntryBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1")); + entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6Dst.class); + entryBuilder.setHasMask(true); + ipv6Builder = new Ipv6AddressMatchEntryBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1")); + entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6Flabel.class); + entryBuilder.setHasMask(true); + Ipv6FlabelMatchEntryBuilder flabelBuilder = new Ipv6FlabelMatchEntryBuilder(); + flabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L)); + entryBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, flabelBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,1,0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Icmpv6Type.class); + entryBuilder.setHasMask(false); + Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); + icmpv6TypeBuilder.setIcmpv6Type((short) 59); + entryBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Icmpv6Code.class); + entryBuilder.setHasMask(false); + Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); + icmpv6CodeBuilder.setIcmpv6Code((short) 60); + entryBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6NdTarget.class); + entryBuilder.setHasMask(false); + ipv6Builder = new Ipv6AddressMatchEntryBuilder(); + ipv6Builder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1")); + entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6NdSll.class); + entryBuilder.setHasMask(false); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6NdTll.class); + entryBuilder.setHasMask(false); + macBuilder = new MacAddressMatchEntryBuilder(); + macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); + entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(MplsLabel.class); + entryBuilder.setHasMask(false); + MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); + labelBuilder.setMplsLabel(61L); + entryBuilder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(MplsTc.class); + entryBuilder.setHasMask(false); + TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); + tcBuilder.setTc((short) 62); + entryBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); + entries.add(entryBuilder.build()); + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(MplsBos.class); + entryBuilder.setHasMask(false); + BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); + bosBuilder.setBos(true); + entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); + entries.add(entryBuilder.build()); + + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(PbbIsid.class); + entryBuilder.setHasMask(true); + IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); + isidBuilder.setIsid(64L); + entryBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,1,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(TunnelId.class); + entryBuilder.setHasMask(true); + metadataBuilder = new MetadataMatchEntryBuilder(); + metadataBuilder.setMetadata(new byte[]{0,0,0,0,0,0,0,1}); + entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,0,0,0,0,0,0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + + entryBuilder = new MatchEntriesBuilder(); + entryBuilder.setOxmClass(OpenflowBasicClass.class); + entryBuilder.setOxmMatchField(Ipv6Exthdr.class); + entryBuilder.setHasMask(true); + PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); + pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); + entryBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); + maskBuilder = new MaskMatchEntryBuilder(); + maskBuilder.setMask(new byte[]{0,2}); + entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); + entries.add(entryBuilder.build()); + + + + builder.setMatchEntries(entries); + Match match = builder.build(); + + ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); + matchSerializer.serialize(match, out); + + Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); + Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 42, out.readUnsignedInt()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 43, out.readUnsignedInt()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 5, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); + Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 7, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); + byte[] array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{1,0,3,0,0,6}, array); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,5}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 9, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{4,0,2,0,0,8}, array); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,2}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 10, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 46, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 13, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 4141, out.readUnsignedShort()); + array = new byte[2]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,9}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 14, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 14, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 16, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 48, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 18, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 49, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 20, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 50, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 23, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,1}, array); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,14}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 25, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,2}, array); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,15}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 26, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6653, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 28, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6654, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 30, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6655, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 32, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6656, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 34, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6657, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 36, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 6658, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 38, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 51, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 40, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 52, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 42, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 53, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 45, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,4}, array); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,16}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 47, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{10,0,0,5}, array); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,17}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 49, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,1,2,3,4,5}, array); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,4,0,0,6}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 51, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,3}, array); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,6,0,0,4}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 53, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 55, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1}, array); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 57, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 58, out.readUnsignedInt()); + array = new byte[4]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,0,2}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 58, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 59, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 60, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 60, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 62, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); + array = new byte[16]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,15,0,0,0,0,0,0,0,0,0,0,0,0,0,1}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 64, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{1,0,3,0,0,6}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 66, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); + array = new byte[6]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{4,0,2,0,0,8}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 68, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 61, out.readUnsignedInt()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 70, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 62, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 72, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 75, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 64, out.readUnsignedMedium()); + array = new byte[3]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry mask", new byte[]{0,1,2}, array); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 77, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); + Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); + Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); + Assert.assertEquals("Wrong match entry field & hasMask", 79, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); + Assert.assertEquals("Wrong match entry value", 358, out.readUnsignedShort()); + array = new byte[2]; + out.readBytes(array); + Assert.assertArrayEquals("Wrong match entry value", new byte[]{0,2}, array); + Assert.assertTrue("Wrong padding", out.readableBytes() == 4); + } + +} diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java index 47e92623..4a1ceb78 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/OpenflowUtilsTest.java @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2014 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 org.junit.Assert; -import org.junit.Test; -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; - -/** - * @author michal.polkorab - * - */ -public class OpenflowUtilsTest { - - /** - * Tests {@link OpenflowUtils#createPortState(long)} - */ - @Test - public void testPortState() { - PortStateV10 state = OpenflowUtils.createPortState(512L); - Assert.assertEquals("Wrong port state", - new PortStateV10(false, false, false, false, true, false, true, false), state); - - state = OpenflowUtils.createPortState(1793L); - Assert.assertEquals("Wrong port state", - new PortStateV10(false, true, false, true, true, true, false, true), state); - - state = OpenflowUtils.createPortState(1L); - Assert.assertEquals("Wrong port state", - new PortStateV10(false, true, false, false, false, false, true, false), state); - } - - /** - * Tests {@link OpenflowUtils#createPortConfig(long)} - */ - @Test - public void testPortConfig() { - PortConfigV10 config = OpenflowUtils.createPortConfig(127L); - Assert.assertEquals("Wrong port config", - new PortConfigV10(true, true, true, true, true, true, true), config); - - config = OpenflowUtils.createPortConfig(0L); - Assert.assertEquals("Wrong port config", - new PortConfigV10(false, false, false, false, false, false, false), config); - } - - /** - * Tests {@link OpenflowUtils#createPortFeatures(long)} - */ - @Test - public void testPortFeatures() { - PortFeaturesV10 features = OpenflowUtils.createPortFeatures(4095L); - Assert.assertEquals("Wrong port features", new PortFeaturesV10(true, true, true, true, true, true, true, - true, true, true, true, true), features); - - features = OpenflowUtils.createPortFeatures(0L); - Assert.assertEquals("Wrong port features", new PortFeaturesV10(false, false, false, false, false, false, - false, false, false, false, false, false), features); - } +/* + * Copyright (c) 2014 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 org.junit.Assert; +import org.junit.Test; +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; + +/** + * @author michal.polkorab + * + */ +public class OpenflowUtilsTest { + + /** + * Tests {@link OpenflowUtils#createPortState(long)} + */ + @Test + public void testPortState() { + PortStateV10 state = OpenflowUtils.createPortState(512L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, false, false, false, true, false, true, false), state); + + state = OpenflowUtils.createPortState(1793L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, true, false, true, true, true, false, true), state); + + state = OpenflowUtils.createPortState(1L); + Assert.assertEquals("Wrong port state", + new PortStateV10(false, true, false, false, false, false, true, false), state); + } + + /** + * Tests {@link OpenflowUtils#createPortConfig(long)} + */ + @Test + public void testPortConfig() { + PortConfigV10 config = OpenflowUtils.createPortConfig(127L); + Assert.assertEquals("Wrong port config", + new PortConfigV10(true, true, true, true, true, true, true), config); + + config = OpenflowUtils.createPortConfig(0L); + Assert.assertEquals("Wrong port config", + new PortConfigV10(false, false, false, false, false, false, false), config); + } + + /** + * Tests {@link OpenflowUtils#createPortFeatures(long)} + */ + @Test + public void testPortFeatures() { + PortFeaturesV10 features = OpenflowUtils.createPortFeatures(4095L); + Assert.assertEquals("Wrong port features", new PortFeaturesV10(true, true, true, true, true, true, true, + true, true, true, true, true), features); + + features = OpenflowUtils.createPortFeatures(0L); + Assert.assertEquals("Wrong port features", new PortFeaturesV10(false, false, false, false, false, false, + false, false, false, false, false, false), features); + } } \ No newline at end of file diff --git a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java index c58a119a..ba445321 100644 --- a/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java +++ b/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/util/TypeKeyMakerFactoryTest.java @@ -1,181 +1,181 @@ -/* - * Copyright (c) 2014 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 org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; -import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; -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.ExperimenterActionSubType; -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.actions.grouping.Action; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; -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.instructions.grouping.Instruction; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; - -/** - * @author michal.polkorab - * - */ -public class TypeKeyMakerFactoryTest { - - /** - * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} - */ - @Test - public void testActionKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - ActionBuilder builder = new ActionBuilder(); - builder.setType(Output.class); - Action action = builder.build(); - MessageTypeKey key = keyMaker.make(action); - - Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, - Output.class, null), key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} - */ - @Test - public void testExperimenterActionKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - ActionBuilder builder = new ActionBuilder(); - builder.setType(Experimenter.class); - ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - expIdBuilder.setSubType(ActionSubtypeClass.class); - builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); - Action action = builder.build(); - MessageTypeKey key = keyMaker.make(action); - - Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, - ActionSubtypeClass.class), key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} - */ - @Test - public void testInstructionKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(GotoTable.class); - Instruction instruction = builder.build(); - MessageTypeKey key = keyMaker.make(instruction); - - Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, - GotoTable.class, null), key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} - */ - @Test - public void testExperimenterInstructionKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - InstructionBuilder builder = new InstructionBuilder(); - builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow - .common.instruction.rev130731.Experimenter.class); - ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build()); - Instruction instruction = builder.build(); - MessageTypeKey key = keyMaker.make(instruction); - - Assert.assertNotNull("Null key", key); - Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, - 42L), key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} - */ - @Test - public void testMatchEntriesKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(OpenflowBasicClass.class); - builder.setOxmMatchField(InPort.class); - builder.setHasMask(true); - MatchEntries entry = builder.build(); - MessageTypeKey key = keyMaker.make(entry); - - Assert.assertNotNull("Null key", key); - MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - OpenflowBasicClass.class, InPort.class); - Assert.assertEquals("Wrong key", comparationKey, key); - } - - /** - * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} - */ - @Test - public void testExperimenterMatchEntriesKeyMaker() { - TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); - Assert.assertNotNull("Null keyMaker", keyMaker); - - MatchEntriesBuilder builder = new MatchEntriesBuilder(); - builder.setOxmClass(ExperimenterClass.class); - builder.setOxmMatchField(OxmMatchFieldClass.class); - builder.setHasMask(true); - ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder(); - expIdBuilder.setExperimenter(new ExperimenterId(42L)); - builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build()); - MatchEntries entry = builder.build(); - MessageTypeKey key = keyMaker.make(entry); - - Assert.assertNotNull("Null key", key); - MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, - ExperimenterClass.class, OxmMatchFieldClass.class); - comparationKey.setExperimenterId(42L); - Assert.assertEquals("Wrong key", comparationKey, key); - } - - private class ActionSubtypeClass extends ExperimenterActionSubType { - // only for testing purposes - } - - private class OxmMatchFieldClass extends MatchField { - // only for testing purposes - } +/* + * Copyright (c) 2014 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 org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.extensibility.MessageTypeKey; +import org.opendaylight.openflowjava.protocol.api.keys.ActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.InstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterActionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterInstructionSerializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdAction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdActionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdInstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterIdMatchEntryBuilder; +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.ExperimenterActionSubType; +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.actions.grouping.Action; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.ActionBuilder; +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.instructions.grouping.Instruction; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.InstructionBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.ExperimenterClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.InPort; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.MatchField; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.OpenflowBasicClass; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder; + +/** + * @author michal.polkorab + * + */ +public class TypeKeyMakerFactoryTest { + + /** + * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} + */ + @Test + public void testActionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + ActionBuilder builder = new ActionBuilder(); + builder.setType(Output.class); + Action action = builder.build(); + MessageTypeKey key = keyMaker.make(action); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ActionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, + Output.class, null), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createActionKeyMaker(short)} + */ + @Test + public void testExperimenterActionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + ActionBuilder builder = new ActionBuilder(); + builder.setType(Experimenter.class); + ExperimenterIdActionBuilder expIdBuilder = new ExperimenterIdActionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + expIdBuilder.setSubType(ActionSubtypeClass.class); + builder.addAugmentation(ExperimenterIdAction.class, expIdBuilder.build()); + Action action = builder.build(); + MessageTypeKey key = keyMaker.make(action); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ExperimenterActionSerializerKey(EncodeConstants.OF13_VERSION_ID, 42L, + ActionSubtypeClass.class), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} + */ + @Test + public void testInstructionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(GotoTable.class); + Instruction instruction = builder.build(); + MessageTypeKey key = keyMaker.make(instruction); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new InstructionSerializerKey<>(EncodeConstants.OF13_VERSION_ID, + GotoTable.class, null), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createInstructionKeyMaker(short)} + */ + @Test + public void testExperimenterInstructionKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createInstructionKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + InstructionBuilder builder = new InstructionBuilder(); + builder.setType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow + .common.instruction.rev130731.Experimenter.class); + ExperimenterIdInstructionBuilder expIdBuilder = new ExperimenterIdInstructionBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + builder.addAugmentation(ExperimenterIdInstruction.class, expIdBuilder.build()); + Instruction instruction = builder.build(); + MessageTypeKey key = keyMaker.make(instruction); + + Assert.assertNotNull("Null key", key); + Assert.assertEquals("Wrong key", new ExperimenterInstructionSerializerKey(EncodeConstants.OF13_VERSION_ID, + 42L), key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testMatchEntriesKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(OpenflowBasicClass.class); + builder.setOxmMatchField(InPort.class); + builder.setHasMask(true); + MatchEntries entry = builder.build(); + MessageTypeKey key = keyMaker.make(entry); + + Assert.assertNotNull("Null key", key); + MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + OpenflowBasicClass.class, InPort.class); + Assert.assertEquals("Wrong key", comparationKey, key); + } + + /** + * Tests {@link TypeKeyMakerFactory#createMatchEntriesKeyMaker(short)} + */ + @Test + public void testExperimenterMatchEntriesKeyMaker() { + TypeKeyMaker keyMaker = TypeKeyMakerFactory.createMatchEntriesKeyMaker(EncodeConstants.OF13_VERSION_ID); + Assert.assertNotNull("Null keyMaker", keyMaker); + + MatchEntriesBuilder builder = new MatchEntriesBuilder(); + builder.setOxmClass(ExperimenterClass.class); + builder.setOxmMatchField(OxmMatchFieldClass.class); + builder.setHasMask(true); + ExperimenterIdMatchEntryBuilder expIdBuilder = new ExperimenterIdMatchEntryBuilder(); + expIdBuilder.setExperimenter(new ExperimenterId(42L)); + builder.addAugmentation(ExperimenterIdMatchEntry.class, expIdBuilder.build()); + MatchEntries entry = builder.build(); + MessageTypeKey key = keyMaker.make(entry); + + Assert.assertNotNull("Null key", key); + MatchEntrySerializerKey comparationKey = new MatchEntrySerializerKey<>(EncodeConstants.OF13_VERSION_ID, + ExperimenterClass.class, OxmMatchFieldClass.class); + comparationKey.setExperimenterId(42L); + Assert.assertEquals("Wrong key", comparationKey, key); + } + + private class ActionSubtypeClass extends ExperimenterActionSubType { + // only for testing purposes + } + + private class OxmMatchFieldClass extends MatchField { + // only for testing purposes + } } \ No newline at end of file diff --git a/openflow-protocol-it/src/test/resources/log4j.xml b/openflow-protocol-it/src/test/resources/log4j.xml index 23b1b663..34512d51 100644 --- a/openflow-protocol-it/src/test/resources/log4j.xml +++ b/openflow-protocol-it/src/test/resources/log4j.xml @@ -1,24 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java index c5d7a6aa..1d2c580b 100644 --- a/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java +++ b/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/statistics/StatisticsHandler.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2014 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.statistics; - -/** - * Used for JConsole service - * - * @author michal.polkorab - */ -public interface StatisticsHandler { - - /** - * Resets all counters - */ - public void resetCounters(); - - /** - * Prints statistics - * @return statistics - */ - public String printStatistics(); +/* + * Copyright (c) 2014 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.statistics; + +/** + * Used for JConsole service + * + * @author michal.polkorab + */ +public interface StatisticsHandler { + + /** + * Resets all counters + */ + public void resetCounters(); + + /** + * Prints statistics + * @return statistics + */ + public String printStatistics(); } \ No newline at end of file diff --git a/openflowjava-config/pom.xml b/openflowjava-config/pom.xml index 60647655..91edd9e8 100644 --- a/openflowjava-config/pom.xml +++ b/openflowjava-config/pom.xml @@ -1,53 +1,53 @@ - - - - 4.0.0 - - - org.opendaylight.openflowjava - openflow-protocol-parent - 0.6.0-SNAPSHOT - - openflowjava-config - Configuration files for openflowjava statistics - jar - Openflow Protocol Library - CONFIG - - https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main - HEAD - - - 45-openflowjava-stats.xml - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${configfile} - xml - configstats - - - - - - - - - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + 4.0.0 + + + org.opendaylight.openflowjava + openflow-protocol-parent + 0.6.0-SNAPSHOT + + openflowjava-config + Configuration files for openflowjava statistics + jar + Openflow Protocol Library - CONFIG + + https://wiki.opendaylight.org/view/Openflow_Protocol_Library:Main + HEAD + + + 45-openflowjava-stats.xml + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${configfile} + xml + configstats + + + + + + + + + diff --git a/openflowjava-config/src/main/resources/45-openflowjava-stats.xml b/openflowjava-config/src/main/resources/45-openflowjava-stats.xml index 12761959..882d7e18 100644 --- a/openflowjava-config/src/main/resources/45-openflowjava-stats.xml +++ b/openflowjava-config/src/main/resources/45-openflowjava-stats.xml @@ -1,41 +1,41 @@ - - - - - - - urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl?module=openflow-switch-connection-provider-impl&revision=2014-03-28 - urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider?module=openflow-switch-connection-provider&revision=2014-03-28 - - - - - - - - stats:statistics-collection-service-impl - statistics-collection-service-impl - - true - 10000 - - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-default - - - ofSwitch:openflow-switch-connection-provider - openflow-switch-connection-provider-legacy - - - - - - + + + + + + + urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider:impl?module=openflow-switch-connection-provider-impl&revision=2014-03-28 + urn:opendaylight:params:xml:ns:yang:openflow:switch:connection:provider?module=openflow-switch-connection-provider&revision=2014-03-28 + + + + + + + + stats:statistics-collection-service-impl + statistics-collection-service-impl + + true + 10000 + + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-default + + + ofSwitch:openflow-switch-connection-provider + openflow-switch-connection-provider-legacy + + + + + + \ No newline at end of file diff --git a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java index 0d4046ef..02a2199a 100644 --- a/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java +++ b/simple-client/src/main/java/org/opendaylight/openflowjava/protocol/impl/clients/OFClient.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2014 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 com.google.common.util.concurrent.SettableFuture; - -/** - * Unifying interface for simple clients / switch simulators - * - * @author michal.polkorab - */ -public interface OFClient extends Runnable { - - /** - * @return the isOnlineFuture which is set when client is started - */ - SettableFuture getIsOnlineFuture(); - - /** - * @return the scenarioDone when scenario is successfully finished - */ - SettableFuture getScenarioDone(); - - /** - * @param scenario list of desired actions - */ - void setScenarioHandler(ScenarioHandler scenario); - - /** - * @param securedClient true is client should use encrypted communication, - * false otherwise - */ - void setSecuredClient(boolean securedClient); +/* + * Copyright (c) 2014 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 com.google.common.util.concurrent.SettableFuture; + +/** + * Unifying interface for simple clients / switch simulators + * + * @author michal.polkorab + */ +public interface OFClient extends Runnable { + + /** + * @return the isOnlineFuture which is set when client is started + */ + SettableFuture getIsOnlineFuture(); + + /** + * @return the scenarioDone when scenario is successfully finished + */ + SettableFuture getScenarioDone(); + + /** + * @param scenario list of desired actions + */ + void setScenarioHandler(ScenarioHandler scenario); + + /** + * @param securedClient true is client should use encrypted communication, + * false otherwise + */ + void setSecuredClient(boolean securedClient); } \ No newline at end of file diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java index d24d6d3f..8ef85bc4 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactory.java @@ -1,84 +1,84 @@ -/* - * Copyright (c) 2014 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.util; - -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -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.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public abstract class ExperimenterDeserializerKeyFactory { - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createExperimenterErrorDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, ErrorMessage.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createExperimenterMessageDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, ExperimenterMessage.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createMultipartReplyMessageDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, MultipartReplyExperimenterCase.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createMultipartReplyTFDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, TableFeatureProperties.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createQueuePropertyDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, QueueProperty.class); - } - - /** - * @param version openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdDeserializerKey createMeterBandDeserializerKey( - short version, Long experimenterId) { - return new ExperimenterIdDeserializerKey(version, experimenterId, MeterBandExperimenterCase.class); - } +/* + * Copyright (c) 2014 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.util; + +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +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.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public abstract class ExperimenterDeserializerKeyFactory { + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createExperimenterErrorDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, ErrorMessage.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createExperimenterMessageDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, ExperimenterMessage.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMultipartReplyMessageDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, MultipartReplyExperimenterCase.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMultipartReplyTFDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, TableFeatureProperties.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createQueuePropertyDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, QueueProperty.class); + } + + /** + * @param version openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdDeserializerKey createMeterBandDeserializerKey( + short version, Long experimenterId) { + return new ExperimenterIdDeserializerKey(version, experimenterId, MeterBandExperimenterCase.class); + } } \ No newline at end of file diff --git a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java index 5d1fc635..4ea333b6 100644 --- a/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java +++ b/util/src/main/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactory.java @@ -1,62 +1,62 @@ -/* - * Copyright (c) 2014 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.util; - -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public abstract class ExperimenterSerializerKeyFactory { - - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdSerializerKey createExperimenterMessageSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, ExperimenterInput.class); - } - - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdSerializerKey createMultipartRequestSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MultipartRequestExperimenterCase.class); - } - - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdSerializerKey createMultipartRequestTFSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, TableFeatureProperties.class); - } - - /** - * @param msgVersion openflow wire version - * @param experimenterId experimenter / vendor ID - * @return key instance - */ - public static ExperimenterIdSerializerKey createMeterBandSerializerKey( - short msgVersion, Long experimenterId) { - return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class); - } +/* + * Copyright (c) 2014 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.util; + +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public abstract class ExperimenterSerializerKeyFactory { + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createExperimenterMessageSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, ExperimenterInput.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMultipartRequestSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MultipartRequestExperimenterCase.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMultipartRequestTFSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, TableFeatureProperties.class); + } + + /** + * @param msgVersion openflow wire version + * @param experimenterId experimenter / vendor ID + * @return key instance + */ + public static ExperimenterIdSerializerKey createMeterBandSerializerKey( + short msgVersion, Long experimenterId) { + return new ExperimenterIdSerializerKey<>(msgVersion, experimenterId, MeterBandExperimenterCase.class); + } } \ No newline at end of file diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java index 1c63fc0f..d597cfd5 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterDeserializerKeyFactoryTest.java @@ -1,94 +1,94 @@ -/* - * Copyright (c) 2014 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.util; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; -import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -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.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterDeserializerKeyFactoryTest { - - /** - * Test ExperimenterDeserializerKeyFactory key creation - */ - @Test - public void test() { - ExperimenterIdDeserializerKey createdKey = ExperimenterDeserializerKeyFactory - .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterIdDeserializerKey comparationKey = - new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, ErrorMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 43L); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 43L, ExperimenterMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, ExperimenterMessage.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 44L); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 44L, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, 45L); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - 45L, MultipartReplyExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, MultipartReplyExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, QueueProperty.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, - null, QueueProperty.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - } +/* + * Copyright (c) 2014 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.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdDeserializerKey; +import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; +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.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterDeserializerKeyFactoryTest { + + /** + * Test ExperimenterDeserializerKeyFactory key creation + */ + @Test + public void test() { + ExperimenterIdDeserializerKey createdKey = ExperimenterDeserializerKeyFactory + .createExperimenterErrorDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterIdDeserializerKey comparationKey = + new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, 42L, ErrorMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, ErrorMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 43L, ExperimenterMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createExperimenterMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, ExperimenterMessage.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 44L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 44L, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMeterBandDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, 45L); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + 45L, MultipartReplyExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyMessageDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, MultipartReplyExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createMultipartReplyTFDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, QueueProperty.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdDeserializerKey(EncodeConstants.OF10_VERSION_ID, + null, QueueProperty.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } } \ No newline at end of file diff --git a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java index df975ea5..397f7d69 100644 --- a/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java +++ b/util/src/test/java/org/opendaylight/openflowjava/util/ExperimenterSerializerKeyFactoryTest.java @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2014 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.util; - -import org.junit.Assert; -import org.junit.Test; -import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; -import org.opendaylight.openflowjava.protocol.api.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.meter.band.header.meter.band.MeterBandExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; - -/** - * @author michal.polkorab - * - */ -public class ExperimenterSerializerKeyFactoryTest { - - /** - * Test ExperimenterSerializerKeyFactory key creation - */ - @Test - public void test() { - ExperimenterIdSerializerKey createdKey = ExperimenterSerializerKeyFactory - .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); - ExperimenterIdSerializerKey comparationKey = - new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterInput.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, ExperimenterInput.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( - EncodeConstants.OF10_VERSION_ID, 43L); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - 43L, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, MeterBandExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( - EncodeConstants.OF10_VERSION_ID, 44L); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - 44L, MultipartRequestExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, MultipartRequestExperimenterCase.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( - EncodeConstants.OF10_VERSION_ID, 45L); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - 45L, TableFeatureProperties.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( - EncodeConstants.OF10_VERSION_ID, null); - comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, - null, TableFeatureProperties.class); - Assert.assertEquals("Wrong key created", comparationKey, createdKey); - } +/* + * Copyright (c) 2014 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.util; + +import org.junit.Assert; +import org.junit.Test; +import org.opendaylight.openflowjava.protocol.api.keys.experimenter.ExperimenterIdSerializerKey; +import org.opendaylight.openflowjava.protocol.api.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.meter.band.header.meter.band.MeterBandExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestExperimenterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties; + +/** + * @author michal.polkorab + * + */ +public class ExperimenterSerializerKeyFactoryTest { + + /** + * Test ExperimenterSerializerKeyFactory key creation + */ + @Test + public void test() { + ExperimenterIdSerializerKey createdKey = ExperimenterSerializerKeyFactory + .createExperimenterMessageSerializerKey(EncodeConstants.OF10_VERSION_ID, 42L); + ExperimenterIdSerializerKey comparationKey = + new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, 42L, ExperimenterInput.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, ExperimenterInput.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF10_VERSION_ID, 43L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 43L, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMeterBandSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, MeterBandExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( + EncodeConstants.OF10_VERSION_ID, 44L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 44L, MultipartRequestExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, MultipartRequestExperimenterCase.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( + EncodeConstants.OF10_VERSION_ID, 45L); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + 45L, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + createdKey = ExperimenterSerializerKeyFactory.createMultipartRequestTFSerializerKey( + EncodeConstants.OF10_VERSION_ID, null); + comparationKey = new ExperimenterIdSerializerKey<>(EncodeConstants.OF10_VERSION_ID, + null, TableFeatureProperties.class); + Assert.assertEquals("Wrong key created", comparationKey, createdKey); + } } \ No newline at end of file -- 2.36.6