From 99b3fc9c75db8dc1f4cbadd76056bc5d0053b33c Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 18 Jul 2020 16:31:13 +0200 Subject: [PATCH] Migrate uint/ByteBuf interactions Migrate use of Uint helpers provided by yangtools, which offer better performance and ergonomics. This is the first step, migrating production code, so that it is validated using existing tests. JIRA: OPNFLWPLUG-1099 Change-Id: I5f396bff3b7d2eaff25c4b3bf6d5eab28add4b44 Signed-off-by: Robert Varga --- extension/openflowjava-extension-eric/pom.xml | 4 + .../codec/match/Icmpv6NDOptionsTypeCodec.java | 21 +- .../codec/match/Icmpv6NDReservedCodec.java | 22 +- .../openflowjava-extension-nicira/pom.xml | 4 + .../nx/codec/action/ConntrackCodec.java | 20 +- .../nx/codec/action/DecapCodec.java | 14 +- .../nx/codec/action/EncapCodec.java | 5 +- .../nx/codec/action/FinTimeoutCodec.java | 14 +- .../nx/codec/action/LearnCodecUtil.java | 36 +-- .../nx/codec/action/MultipathCodec.java | 14 +- .../nx/codec/action/OutputReg2Codec.java | 7 +- .../nx/codec/action/OutputRegCodec.java | 9 +- .../nx/codec/action/RegLoadCodec.java | 7 +- .../nx/codec/action/RegMoveCodec.java | 8 +- .../nx/codec/action/ResubmitCodec.java | 14 +- .../nx/codec/match/AbstractNshcCodec.java | 6 +- .../nx/codec/match/AbstractRegCodec.java | 9 +- .../nx/codec/match/ArpOpCodec.java | 15 +- .../nx/codec/match/ArpSpaCodec.java | 15 +- .../nx/codec/match/ArpTpaCodec.java | 15 +- .../nx/codec/match/CtMarkCodec.java | 8 +- .../nx/codec/match/CtStateCodec.java | 23 +- .../nx/codec/match/CtTpDstCodec.java | 16 +- .../nx/codec/match/CtTpSrcCodec.java | 16 +- .../nx/codec/match/CtZoneCodec.java | 17 +- .../nx/codec/match/EthTypeCodec.java | 15 +- .../nx/codec/match/IcmpTypeCodec.java | 16 +- .../nx/codec/match/InPortCodec.java | 13 +- .../nx/codec/match/IpDstCodec.java | 14 +- .../nx/codec/match/IpSrcCodec.java | 13 +- .../nx/codec/match/Ipv6DstCodec.java | 13 +- .../nx/codec/match/Ipv6SrcCodec.java | 13 +- .../nx/codec/match/NshFlagsCodec.java | 12 +- .../nx/codec/match/NshMdtypeCodec.java | 9 +- .../nx/codec/match/NshNpCodec.java | 8 +- .../openflowjava/nx/codec/match/NsiCodec.java | 7 +- .../openflowjava/nx/codec/match/NspCodec.java | 11 +- .../nx/codec/match/PktMarkCodec.java | 16 +- .../nx/codec/match/TcpDstCodec.java | 22 +- .../nx/codec/match/TcpSrcCodec.java | 23 +- .../nx/codec/match/TunIpv4DstCodec.java | 16 +- .../nx/codec/match/TunIpv4SrcCodec.java | 16 +- .../nx/codec/match/UdpDstCodec.java | 23 +- .../nx/codec/match/UdpSrcCodec.java | 23 +- openflowjava/openflow-protocol-impl/pom.xml | 4 + .../action/OF10EnqueueActionDeserializer.java | 18 +- .../action/OF10OutputActionDeserializer.java | 9 +- .../OF10SetNwTosActionDeserializer.java | 7 +- .../OF10SetTpDstActionDeserializer.java | 7 +- .../OF10SetTpSrcActionDeserializer.java | 6 +- .../OF10SetVlanPcpActionDeserializer.java | 7 +- .../OF10SetVlanVidActionDeserializer.java | 14 +- .../action/OF13GroupActionDeserializer.java | 18 +- .../action/OF13OutputActionDeserializer.java | 10 +- .../action/OF13PopMplsActionDeserializer.java | 16 +- .../OF13PushMplsActionDeserializer.java | 5 +- .../action/OF13PushPbbActionDeserializer.java | 16 +- .../OF13PushVlanActionDeserializer.java | 16 +- .../OF13SetMplsTtlActionDeserializer.java | 7 +- .../OF13SetNwTtlActionDeserializer.java | 7 +- .../OF13SetQueueActionDeserializer.java | 7 +- .../factories/BarrierInputMessageFactory.java | 11 +- .../factories/BarrierReplyMessageFactory.java | 10 +- .../factories/EchoReplyMessageFactory.java | 4 +- .../factories/EchoRequestMessageFactory.java | 4 +- .../factories/ErrorMessageFactory.java | 4 +- .../factories/ExperimenterMessageFactory.java | 6 +- .../FeaturesReplyMessageFactory.java | 20 +- .../factories/FlowModInputMessageFactory.java | 30 +-- .../factories/FlowRemovedMessageFactory.java | 33 ++- .../GetAsyncReplyMessageFactory.java | 4 +- .../GetAsyncRequestMessageFactory.java | 11 +- .../GetConfigInputMessageFactory.java | 12 +- .../GetConfigReplyMessageFactory.java | 8 +- .../GetFeaturesInputMessageFactory.java | 10 +- .../GetQueueConfigInputMessageFactory.java | 6 +- .../GroupModInputMessageFactory.java | 14 +- .../factories/HelloMessageFactory.java | 4 +- .../MeterModInputMessageFactory.java | 18 +- .../MultipartReplyMessageFactory.java | 215 +++++++----------- .../MultipartRequestInputMessageFactory.java | 61 +++-- .../factories/OF10ErrorMessageFactory.java | 5 +- .../OF10FeaturesReplyMessageFactory.java | 19 +- .../OF10FeaturesRequestMessageFactory.java | 4 +- .../OF10FlowModInputMessageFactory.java | 22 +- .../OF10FlowRemovedMessageFactory.java | 28 +-- ...OF10GetQueueConfigInputMessageFactory.java | 7 +- .../factories/OF10HelloMessageFactory.java | 6 +- .../factories/OF10PacketInMessageFactory.java | 12 +- .../OF10PacketOutInputMessageFactory.java | 11 +- .../OF10PortModInputMessageFactory.java | 7 +- .../OF10PortStatusMessageFactory.java | 8 +- ...OF10QueueGetConfigReplyMessageFactory.java | 12 +- .../OF10StatsReplyMessageFactory.java | 123 ++++------ .../OF10StatsRequestInputFactory.java | 20 +- .../factories/PacketInMessageFactory.java | 19 +- .../PacketOutInputMessageFactory.java | 8 +- .../factories/PortModInputMessageFactory.java | 6 +- .../factories/PortStatusMessageFactory.java | 10 +- .../QueueGetConfigReplyMessageFactory.java | 14 +- .../factories/RoleReplyMessageFactory.java | 11 +- .../RoleRequestInputMessageFactory.java | 10 +- .../SetAsyncInputMessageFactory.java | 4 +- .../SetConfigInputMessageFactory.java | 7 +- .../TableModInputMessageFactory.java | 7 +- .../factories/VendorMessageFactory.java | 6 +- .../GoToTableInstructionDeserializer.java | 17 +- .../MeterInstructionDeserializer.java | 20 +- .../match/OxmArpOpDeserializer.java | 10 +- .../match/OxmEthTypeDeserializer.java | 9 +- .../match/OxmIcmpv4CodeDeserializer.java | 20 +- .../match/OxmIcmpv4TypeDeserializer.java | 19 +- .../match/OxmIcmpv6CodeDeserializer.java | 19 +- .../match/OxmIcmpv6TypeDeserializer.java | 19 +- .../match/OxmInPhyPortDeserializer.java | 10 +- .../match/OxmInPortDeserializer.java | 10 +- .../match/OxmIpDscpDeserializer.java | 9 +- .../match/OxmIpEcnDeserializer.java | 10 +- .../match/OxmIpProtoDeserializer.java | 10 +- .../match/OxmIpv6FlabelDeserializer.java | 4 +- .../match/OxmMplsLabelDeserializer.java | 10 +- .../match/OxmMplsTcDeserializer.java | 10 +- .../match/OxmPacketTypeDeserializer.java | 5 +- .../match/OxmSctpDstDeserializer.java | 10 +- .../match/OxmSctpSrcDeserializer.java | 19 +- .../match/OxmTcpDstDeserializer.java | 20 +- .../match/OxmTcpSrcDeserializer.java | 19 +- .../match/OxmUdpDstDeserializer.java | 19 +- .../match/OxmUdpSrcDeserializer.java | 19 +- .../match/OxmVlanPcpDeserializer.java | 19 +- .../match/OxmVlanVidDeserializer.java | 3 +- ...OxmExperimenterMatchEntryDeserializer.java | 4 +- .../match/ext/OnfOxmTcpFlagsDeserializer.java | 4 +- .../impl/util/OF10MatchDeserializer.java | 20 +- openflowplugin-impl/pom.xml | 4 + .../messages/FlowMessageDeserializer.java | 19 +- ...ltipartReplyTableFeaturesDeserializer.java | 21 +- 137 files changed, 996 insertions(+), 1082 deletions(-) diff --git a/extension/openflowjava-extension-eric/pom.xml b/extension/openflowjava-extension-eric/pom.xml index 613f025be2..b600255a72 100644 --- a/extension/openflowjava-extension-eric/pom.xml +++ b/extension/openflowjava-extension-eric/pom.xml @@ -32,6 +32,10 @@ io.netty netty-buffer + + org.opendaylight.yangtools + yang-common-netty + org.slf4j slf4j-log4j12 diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java index ade88aa5b5..1d24d6faa8 100644 --- a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java +++ b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDOptionsTypeCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.eric.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.eric.api.EricConstants; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; @@ -17,16 +18,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Eric import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.Icmpv6NdOptionsType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.options.type.grouping.Icmpv6NdOptionsTypeValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdOptionsTypeCaseValueBuilder; public class Icmpv6NDOptionsTypeCodec extends AbstractMatchCodec { - private static final int VALUE_LENGTH = 1; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey( + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, EricExpClass.class, Icmpv6NdOptionsType.class); public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( EncodeConstants.OF13_VERSION_ID, EricConstants.ERICOXM_OF_EXPERIMENTER_ID, @@ -41,12 +40,13 @@ public class Icmpv6NDOptionsTypeCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - Icmpv6NdOptionsTypeCaseValueBuilder caseBuilder = new Icmpv6NdOptionsTypeCaseValueBuilder(); - caseBuilder.setIcmpv6NdOptionsTypeValues(new Icmpv6NdOptionsTypeValuesBuilder() - .setIcmpv6NdOptionsType(message.readUnsignedByte()).build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new Icmpv6NdOptionsTypeCaseValueBuilder() + .setIcmpv6NdOptionsTypeValues(new Icmpv6NdOptionsTypeValuesBuilder() + .setIcmpv6NdOptionsType(readUint8(message)) + .build()) + .build()) + .build(); } @Override @@ -73,5 +73,4 @@ public class Icmpv6NDOptionsTypeCodec extends AbstractMatchCodec { public Class getOxmClass() { return EricExpClass.class; } - } \ No newline at end of file diff --git a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodec.java b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodec.java index 722a246c26..0c6ab13062 100644 --- a/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodec.java +++ b/extension/openflowjava-extension-eric/src/main/java/org/opendaylight/openflowjava/eric/codec/match/Icmpv6NDReservedCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.eric.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.eric.api.EricConstants; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; @@ -17,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Eric import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.Icmpv6NdReserved; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.icmpv6.nd.reserved.grouping.Icmpv6NdReservedValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev180730.oxm.container.match.entry.value.Icmpv6NdReservedCaseValue; @@ -26,7 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.eric.match.rev public class Icmpv6NDReservedCodec extends AbstractMatchCodec { private static final int VALUE_LENGTH = 4; - public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey( + public static final MatchEntrySerializerKey SERIALIZER_KEY = new MatchEntrySerializerKey<>( EncodeConstants.OF13_VERSION_ID, EricExpClass.class, Icmpv6NdReserved.class); public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( EncodeConstants.OF13_VERSION_ID, EricConstants.ERICOXM_OF_EXPERIMENTER_ID, @@ -35,18 +35,19 @@ public class Icmpv6NDReservedCodec extends AbstractMatchCodec { @Override public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); - Icmpv6NdReservedCaseValue caseValue = ((Icmpv6NdReservedCaseValue) input.getMatchEntryValue()); + Icmpv6NdReservedCaseValue caseValue = (Icmpv6NdReservedCaseValue) input.getMatchEntryValue(); outBuffer.writeInt(caseValue.getIcmpv6NdReservedValues().getIcmpv6NdReserved().intValue()); } @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - Icmpv6NdReservedCaseValueBuilder caseBuilder = new Icmpv6NdReservedCaseValueBuilder(); - caseBuilder.setIcmpv6NdReservedValues(new Icmpv6NdReservedValuesBuilder() - .setIcmpv6NdReserved(message.readUnsignedInt()).build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new Icmpv6NdReservedCaseValueBuilder() + .setIcmpv6NdReservedValues(new Icmpv6NdReservedValuesBuilder() + .setIcmpv6NdReserved(readUint32(message)) + .build()) + .build()) + .build(); } @Override @@ -73,5 +74,4 @@ public class Icmpv6NDReservedCodec extends AbstractMatchCodec { public Class getOxmClass() { return EricExpClass.class; } - } \ No newline at end of file diff --git a/extension/openflowjava-extension-nicira/pom.xml b/extension/openflowjava-extension-nicira/pom.xml index 8da1ce15ee..9b4b1c2df1 100644 --- a/extension/openflowjava-extension-nicira/pom.xml +++ b/extension/openflowjava-extension-nicira/pom.xml @@ -31,6 +31,10 @@ io.netty netty-buffer + + org.opendaylight.yangtools + yang-common-netty + org.slf4j slf4j-log4j12 diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ConntrackCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ConntrackCodec.java index 1545338ad6..07735f5661 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ConntrackCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ConntrackCodec.java @@ -7,6 +7,10 @@ */ package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import com.google.common.net.InetAddresses; import io.netty.buffer.ByteBuf; import java.net.InetAddress; @@ -177,10 +181,10 @@ public class ConntrackCodec extends AbstractActionCodec { public Action deserialize(final ByteBuf message) { final short length = deserializeCtHeader(message); NxActionConntrackBuilder nxActionConntrackBuilder = new NxActionConntrackBuilder(); - nxActionConntrackBuilder.setFlags(message.readUnsignedShort()); - nxActionConntrackBuilder.setZoneSrc(message.readUnsignedInt()); - nxActionConntrackBuilder.setConntrackZone(message.readUnsignedShort()); - nxActionConntrackBuilder.setRecircTable(message.readUnsignedByte()); + nxActionConntrackBuilder.setFlags(readUint16(message)); + nxActionConntrackBuilder.setZoneSrc(readUint32(message)); + nxActionConntrackBuilder.setConntrackZone(readUint16(message)); + nxActionConntrackBuilder.setRecircTable(readUint8(message)); message.skipBytes(5); if (length > CT_LENGTH) { @@ -213,7 +217,7 @@ public class ConntrackCodec extends AbstractActionCodec { processedCtActionsLength = processedCtActionsLength - length; NxActionNatBuilder nxActionNatBuilder = new NxActionNatBuilder(); message.skipBytes(2); - nxActionNatBuilder.setFlags(message.readUnsignedShort()); + nxActionNatBuilder.setFlags(readUint16(message)); int rangePresent = message.readUnsignedShort(); nxActionNatBuilder.setRangePresent(rangePresent); @@ -226,10 +230,10 @@ public class ConntrackCodec extends AbstractActionCodec { nxActionNatBuilder.setIpAddressMax(IpAddressBuilder.getDefaultInstance(address.getHostAddress())); } if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMIN.getIntValue())) { - nxActionNatBuilder.setPortMin(message.readUnsignedShort()); + nxActionNatBuilder.setPortMin(readUint16(message)); } if (0 != (rangePresent & NxActionNatRangePresent.NXNATRANGEPROTOMAX.getIntValue())) { - nxActionNatBuilder.setPortMax(message.readUnsignedShort()); + nxActionNatBuilder.setPortMax(readUint16(message)); } NxActionNatCaseBuilder caseBuilder = new NxActionNatCaseBuilder(); @@ -248,7 +252,7 @@ public class ConntrackCodec extends AbstractActionCodec { deserializeCtHeaderWithoutSubtype(message); NxActionCtMarkBuilder nxActionCtMarkBuilder = new NxActionCtMarkBuilder(); - nxActionCtMarkBuilder.setCtMark(message.readUnsignedInt()); + nxActionCtMarkBuilder.setCtMark(readUint32(message)); NxActionCtMarkCaseBuilder caseBuilder = new NxActionCtMarkCaseBuilder(); caseBuilder.setNxActionCtMark(nxActionCtMarkBuilder.build()); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/DecapCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/DecapCodec.java index f02835afb6..1979c6f9a6 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/DecapCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/DecapCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey; @@ -16,7 +17,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionDecap; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionDecapBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.decap.grouping.NxActionDecap; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.decap.grouping.NxActionDecapBuilder; public class DecapCodec extends AbstractActionCodec { @@ -35,11 +35,11 @@ public class DecapCodec extends AbstractActionCodec { final ActionBuilder actionBuilder = deserializeHeader(message); // skip padding message.skipBytes(PADDING); - long packetType = message.readUnsignedInt(); - NxActionDecap nxActionDecap = new NxActionDecapBuilder().setPacketType(packetType).build(); - ActionDecap actionDecap = new ActionDecapBuilder().setNxActionDecap(nxActionDecap).build(); - actionBuilder.setActionChoice(actionDecap); - return actionBuilder.build(); + return actionBuilder + .setActionChoice(new ActionDecapBuilder() + .setNxActionDecap(new NxActionDecapBuilder().setPacketType(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/EncapCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/EncapCodec.java index 68f87e0e89..cc2801b970 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/EncapCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/EncapCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey; @@ -34,8 +36,7 @@ public class EncapCodec extends AbstractActionCodec { final ActionBuilder actionBuilder = deserializeHeader(message); // skip header size, not used message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - final long packetType = message.readUnsignedInt(); - NxActionEncap nxActionEncap = new NxActionEncapBuilder().setPacketType(packetType).build(); + NxActionEncap nxActionEncap = new NxActionEncapBuilder().setPacketType(readUint32(message)).build(); ActionEncap actionEncap = new ActionEncapBuilder().setNxActionEncap(nxActionEncap).build(); actionBuilder.setActionChoice(actionEncap); return actionBuilder.build(); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/FinTimeoutCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/FinTimeoutCodec.java index e070522310..63ae37bd1b 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/FinTimeoutCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/FinTimeoutCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey; @@ -56,15 +57,14 @@ public class FinTimeoutCodec extends AbstractActionCodec { public Action deserialize(final ByteBuf message) { final ActionBuilder actionBuilder = deserializeHeader(message); - ActionFinTimeoutBuilder builder = new ActionFinTimeoutBuilder(); - NxActionFinTimeoutBuilder nxActionFinTimeoutBuilder = new NxActionFinTimeoutBuilder(); - nxActionFinTimeoutBuilder.setFinIdleTimeout(message.readUnsignedShort()); - nxActionFinTimeoutBuilder.setFinHardTimeout(message.readUnsignedShort()); - builder.setNxActionFinTimeout(nxActionFinTimeoutBuilder.build()); + ActionFinTimeoutBuilder builder = new ActionFinTimeoutBuilder() + .setNxActionFinTimeout(new NxActionFinTimeoutBuilder() + .setFinIdleTimeout(readUint16(message)) + .setFinHardTimeout(readUint16(message)) + .build()); message.skipBytes(PADDING); actionBuilder.setActionChoice(builder.build()); return actionBuilder.build(); } - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/LearnCodecUtil.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/LearnCodecUtil.java index d2a7b0d111..65e019e8dd 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/LearnCodecUtil.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/LearnCodecUtil.java @@ -7,6 +7,10 @@ */ package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import java.math.BigInteger; import java.util.ArrayList; @@ -187,15 +191,15 @@ public final class LearnCodecUtil { */ static void deserializeLearnHeader(final ByteBuf message, NxActionLearnBuilder nxActionLearnBuilder) { - nxActionLearnBuilder.setIdleTimeout(message.readUnsignedShort()); - nxActionLearnBuilder.setHardTimeout(message.readUnsignedShort()); - nxActionLearnBuilder.setPriority(message.readUnsignedShort()); + nxActionLearnBuilder.setIdleTimeout(readUint16(message)); + nxActionLearnBuilder.setHardTimeout(readUint16(message)); + nxActionLearnBuilder.setPriority(readUint16(message)); nxActionLearnBuilder.setCookie(BigInteger.valueOf(message.readLong())); - nxActionLearnBuilder.setFlags(message.readUnsignedShort()); - nxActionLearnBuilder.setTableId(message.readUnsignedByte()); + nxActionLearnBuilder.setFlags(readUint16(message)); + nxActionLearnBuilder.setTableId(readUint8(message)); message.skipBytes(1); - nxActionLearnBuilder.setFinIdleTimeout(message.readUnsignedShort()); - nxActionLearnBuilder.setFinHardTimeout(message.readUnsignedShort()); + nxActionLearnBuilder.setFinIdleTimeout(readUint16(message)); + nxActionLearnBuilder.setFinHardTimeout(readUint16(message)); } static synchronized void buildFlowModSpecs(NxActionLearnBuilder nxActionLearnBuilder, ByteBuf message, @@ -252,9 +256,9 @@ public final class LearnCodecUtil { private static FlowMods readFlowModAddMatchFromField(ByteBuf message, short numBits) { FlowModAddMatchFromFieldBuilder builder = new FlowModAddMatchFromFieldBuilder(); - builder.setSrcField(message.readUnsignedInt()); + builder.setSrcField(readUint32(message)); builder.setSrcOfs((int) message.readShort()); - builder.setDstField(message.readUnsignedInt()); + builder.setDstField(readUint32(message)); builder.setDstOfs((int) message.readShort()); builder.setFlowModNumBits((int) numBits); length -= FROM_FIELD_LENGTH - EncodeConstants.SIZE_OF_SHORT_IN_BYTES; @@ -268,8 +272,8 @@ public final class LearnCodecUtil { private static FlowMods readFlowModAddMatchFromValue(ByteBuf message, short numBits) { FlowModAddMatchFromValueBuilder builder = new FlowModAddMatchFromValueBuilder(); - builder.setValue(message.readUnsignedShort()); - builder.setSrcField(message.readUnsignedInt()); + builder.setValue(readUint16(message)); + builder.setSrcField(readUint32(message)); builder.setSrcOfs((int) message.readShort()); builder.setFlowModNumBits((int) numBits); length -= FROM_VALUE_LENGTH - EncodeConstants.SIZE_OF_SHORT_IN_BYTES; @@ -283,9 +287,9 @@ public final class LearnCodecUtil { private static FlowMods readFlowModCopyFromField(ByteBuf message, short numBits) { FlowModCopyFieldIntoFieldBuilder builder = new FlowModCopyFieldIntoFieldBuilder(); - builder.setSrcField(message.readUnsignedInt()); + builder.setSrcField(readUint32(message)); builder.setSrcOfs((int) message.readShort()); - builder.setDstField(message.readUnsignedInt()); + builder.setDstField(readUint32(message)); builder.setDstOfs((int) message.readShort()); builder.setFlowModNumBits((int) numBits); length -= FROM_FIELD_LENGTH - EncodeConstants.SIZE_OF_SHORT_IN_BYTES; @@ -299,8 +303,8 @@ public final class LearnCodecUtil { private static FlowMods readFlowModCopyFromValue(ByteBuf message, short numBits) { FlowModCopyValueIntoFieldBuilder builder = new FlowModCopyValueIntoFieldBuilder(); - builder.setValue(message.readUnsignedShort()); - builder.setDstField(message.readUnsignedInt()); + builder.setValue(readUint16(message)); + builder.setDstField(readUint32(message)); builder.setDstOfs((int) message.readShort()); builder.setFlowModNumBits((int) numBits); length -= FROM_VALUE_LENGTH - EncodeConstants.SIZE_OF_SHORT_IN_BYTES; @@ -314,7 +318,7 @@ public final class LearnCodecUtil { private static FlowMods readFlowToPort(ByteBuf message, short numBits) { FlowModOutputToPortBuilder builder = new FlowModOutputToPortBuilder(); - builder.setSrcField(message.readUnsignedInt()); + builder.setSrcField(readUint32(message)); builder.setSrcOfs((int) message.readShort()); builder.setFlowModNumBits((int) numBits); length -= TO_PORT_LENGTH - EncodeConstants.SIZE_OF_SHORT_IN_BYTES; diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/MultipathCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/MultipathCodec.java index 01e7e18cc2..4662aa99e9 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/MultipathCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/MultipathCodec.java @@ -5,9 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey; @@ -56,16 +58,16 @@ public class MultipathCodec extends AbstractActionCodec { NxActionMultipathBuilder nxActionMultipathBuilder = new NxActionMultipathBuilder(); nxActionMultipathBuilder.setFields(OfjNxHashFields.forValue(message.readUnsignedShort())); - nxActionMultipathBuilder.setBasis(message.readUnsignedShort()); + nxActionMultipathBuilder.setBasis(readUint16(message)); message.skipBytes(2); //two bytes nxActionMultipathBuilder.setAlgorithm(OfjNxMpAlgorithm.forValue(message.readUnsignedShort())); - nxActionMultipathBuilder.setMaxLink(message.readUnsignedShort()); - nxActionMultipathBuilder.setArg(message.readUnsignedInt()); + nxActionMultipathBuilder.setMaxLink(readUint16(message)); + nxActionMultipathBuilder.setArg(readUint32(message)); message.skipBytes(2); //two bytes - nxActionMultipathBuilder.setOfsNbits(message.readUnsignedShort()); - nxActionMultipathBuilder.setDst(message.readUnsignedInt()); + nxActionMultipathBuilder.setOfsNbits(readUint16(message)); + nxActionMultipathBuilder.setDst(readUint32(message)); actionMultipathBuilder.setNxActionMultipath(nxActionMultipathBuilder.build()); actionBuilder.setActionChoice(actionMultipathBuilder.build()); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/OutputReg2Codec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/OutputReg2Codec.java index f945bb6171..fa5cc30614 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/OutputReg2Codec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/OutputReg2Codec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey; @@ -32,8 +33,8 @@ public class OutputReg2Codec extends AbstractActionCodec { final ActionBuilder actionBuilder = deserializeHeader(message); final ActionOutputReg2Builder builder = new ActionOutputReg2Builder(); NxActionOutputReg2Builder nxActionOutputReg2Builder = new NxActionOutputReg2Builder(); - nxActionOutputReg2Builder.setNBits(message.readUnsignedShort()); - nxActionOutputReg2Builder.setMaxLen(message.readUnsignedShort()); + nxActionOutputReg2Builder.setNBits(readUint16(message)); + nxActionOutputReg2Builder.setMaxLen(readUint16(message)); nxActionOutputReg2Builder.setSrc(readNxmHeader(message)); skipPadding(message, startIndex); builder.setNxActionOutputReg2(nxActionOutputReg2Builder.build()); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/OutputRegCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/OutputRegCodec.java index e9634b7955..a10fcf026e 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/OutputRegCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/OutputRegCodec.java @@ -7,6 +7,9 @@ */ package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey; @@ -46,9 +49,9 @@ public class OutputRegCodec extends AbstractActionCodec { final ActionBuilder actionBuilder = deserializeHeader(message); final ActionOutputRegBuilder builder = new ActionOutputRegBuilder(); NxActionOutputRegBuilder nxActionOutputRegBuilder = new NxActionOutputRegBuilder(); - nxActionOutputRegBuilder.setNBits(message.readUnsignedShort()); - nxActionOutputRegBuilder.setSrc(message.readUnsignedInt()); - nxActionOutputRegBuilder.setMaxLen(message.readUnsignedShort()); + nxActionOutputRegBuilder.setNBits(readUint16(message)); + nxActionOutputRegBuilder.setSrc(readUint32(message)); + nxActionOutputRegBuilder.setMaxLen(readUint16(message)); message.skipBytes(PADDING_IN_OUTPUT_REG_ACTION); builder.setNxActionOutputReg(nxActionOutputRegBuilder.build()); actionBuilder.setActionChoice(builder.build()); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java index 7f6fce66c5..922ffbc9a5 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegLoadCodec.java @@ -7,6 +7,9 @@ */ package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import java.math.BigInteger; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; @@ -41,8 +44,8 @@ public class RegLoadCodec extends AbstractActionCodec { final ActionBuilder actionBuilder = deserializeHeader(message); NxActionRegLoadBuilder nxActionRegLoadBuilder = new NxActionRegLoadBuilder(); final ActionRegLoadBuilder actionRegLoadBuilder = new ActionRegLoadBuilder(); - nxActionRegLoadBuilder.setOfsNbits(message.readUnsignedShort()); - nxActionRegLoadBuilder.setDst(message.readUnsignedInt()); + nxActionRegLoadBuilder.setOfsNbits(readUint16(message)); + nxActionRegLoadBuilder.setDst(readUint32(message)); nxActionRegLoadBuilder.setValue(BigInteger.valueOf(message.readLong())); actionRegLoadBuilder.setNxActionRegLoad(nxActionRegLoadBuilder.build()); actionBuilder.setActionChoice(actionRegLoadBuilder.build()); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java index d97ffb80bd..f00a0c6a81 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/RegMoveCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey; @@ -44,9 +46,9 @@ public class RegMoveCodec extends AbstractActionCodec { final ActionBuilder actionBuilder = deserializeHeader(message); final ActionRegMoveBuilder actionRegMoveBuilder = new ActionRegMoveBuilder(); NxActionRegMoveBuilder nxActionRegMoveBuilder = new NxActionRegMoveBuilder(); - nxActionRegMoveBuilder.setNBits(message.readUnsignedShort()); - nxActionRegMoveBuilder.setSrcOfs(message.readUnsignedShort()); - nxActionRegMoveBuilder.setDstOfs(message.readUnsignedShort()); + nxActionRegMoveBuilder.setNBits(readUint16(message)); + nxActionRegMoveBuilder.setSrcOfs(readUint16(message)); + nxActionRegMoveBuilder.setDstOfs(readUint16(message)); nxActionRegMoveBuilder.setSrc(readNxmHeader(message)); nxActionRegMoveBuilder.setDst(readNxmHeader(message)); skipPadding(message, startIndex); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ResubmitCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ResubmitCodec.java index ade0947bc7..cb8ef17267 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ResubmitCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/action/ResubmitCodec.java @@ -5,9 +5,11 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.action; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraActionDeserializerKey; import org.opendaylight.openflowjava.nx.api.NiciraActionSerializerKey; @@ -68,11 +70,11 @@ public class ResubmitCodec extends AbstractActionCodec { public Action deserialize(final ByteBuf message) { final ActionBuilder actionBuilder = deserializeHeader(message); - ActionResubmitBuilder builder = new ActionResubmitBuilder(); - NxActionResubmitBuilder nxActionResubmitBuilder = new NxActionResubmitBuilder(); - nxActionResubmitBuilder.setInPort(message.readUnsignedShort()); - nxActionResubmitBuilder.setTable(message.readUnsignedByte()); - builder.setNxActionResubmit(nxActionResubmitBuilder.build()); + ActionResubmitBuilder builder = new ActionResubmitBuilder() + .setNxActionResubmit(new NxActionResubmitBuilder() + .setInPort(readUint16(message)) + .setTable(readUint8(message)) + .build()); message.skipBytes(PADDING); actionBuilder.setActionChoice(builder.build()); diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java index 8b571edd8e..ad068b2f8b 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractNshcCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -30,8 +32,8 @@ public abstract class AbstractNshcCodec extends AbstractExperimenterMatchCodec { @Override protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) { - Long nshc = message.readUnsignedInt(); - Long mask = hasMask ? message.readUnsignedInt() : null; + Uint32 nshc = readUint32(message); + Uint32 mask = hasMask ? readUint32(message) : null; return new NshcCaseValueBuilder().setNshc(nshc).setMask(mask).build(); } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java index 5d3156d289..062b3dab79 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/AbstractRegCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; @@ -25,10 +26,10 @@ public abstract class AbstractRegCodec extends AbstractMatchCodec { public MatchEntry deserialize(ByteBuf message) { final MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); final RegValuesBuilder regValuesBuilder = new RegValuesBuilder(); - regValuesBuilder.setValue(message.readUnsignedInt()); + regValuesBuilder.setValue(readUint32(message)); if (matchEntriesBuilder.isHasMask()) { - regValuesBuilder.setMask(message.readUnsignedInt()); + regValuesBuilder.setMask(readUint32(message)); } return matchEntriesBuilder @@ -41,7 +42,7 @@ public abstract class AbstractRegCodec extends AbstractMatchCodec { @Override public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); - final RegCaseValue regCase = ((RegCaseValue) input.getMatchEntryValue()); + final RegCaseValue regCase = (RegCaseValue) input.getMatchEntryValue(); outBuffer.writeInt(regCase.getRegValues().getValue().intValue()); if (input.isHasMask()) { diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java index 5a4120254c..f747a74a1a 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpOpCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfArpOp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.arp.op.grouping.ArpOpValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpOpCaseValue; @@ -33,17 +34,17 @@ public class ArpOpCodec extends AbstractMatchCodec { @Override public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); - ArpOpCaseValue arpOpCase = ((ArpOpCaseValue) input.getMatchEntryValue()); + ArpOpCaseValue arpOpCase = (ArpOpCaseValue) input.getMatchEntryValue(); outBuffer.writeShort(arpOpCase.getArpOpValues().getValue().toJava()); } @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - ArpOpCaseValueBuilder caseBuilder = new ArpOpCaseValueBuilder(); - caseBuilder.setArpOpValues(new ArpOpValuesBuilder().setValue(message.readUnsignedShort()).build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new ArpOpCaseValueBuilder() + .setArpOpValues(new ArpOpValuesBuilder().setValue(readUint16(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java index af9f8cffac..d4e9069af5 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpSpaCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfArpSpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.arp.spa.grouping.ArpSpaValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpSpaCaseValue; @@ -33,17 +34,17 @@ public class ArpSpaCodec extends AbstractMatchCodec { @Override public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); - ArpSpaCaseValue arpSpaCase = ((ArpSpaCaseValue) input.getMatchEntryValue()); + ArpSpaCaseValue arpSpaCase = (ArpSpaCaseValue) input.getMatchEntryValue(); outBuffer.writeInt(arpSpaCase.getArpSpaValues().getValue().intValue()); } @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - ArpSpaCaseValueBuilder caseBuilder = new ArpSpaCaseValueBuilder(); - caseBuilder.setArpSpaValues(new ArpSpaValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new ArpSpaCaseValueBuilder() + .setArpSpaValues(new ArpSpaValuesBuilder().setValue(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java index cf5eecfa57..e47f34676a 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/ArpTpaCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfArpTpa; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.arp.tpa.grouping.ArpTpaValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.ArpTpaCaseValue; @@ -33,17 +34,17 @@ public class ArpTpaCodec extends AbstractMatchCodec { @Override public void serialize(MatchEntry input, ByteBuf outBuffer) { serializeHeader(input, outBuffer); - ArpTpaCaseValue arpTpaCase = ((ArpTpaCaseValue) input.getMatchEntryValue()); + ArpTpaCaseValue arpTpaCase = (ArpTpaCaseValue) input.getMatchEntryValue(); outBuffer.writeInt(arpTpaCase.getArpTpaValues().getValue().intValue()); } @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); - ArpTpaCaseValueBuilder caseBuilder = new ArpTpaCaseValueBuilder(); - caseBuilder.setArpTpaValues(new ArpTpaValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntriesBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new ArpTpaCaseValueBuilder() + .setArpTpaValues(new ArpTpaValuesBuilder().setValue(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtMarkCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtMarkCodec.java index 012ba76667..b318f186d1 100755 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtMarkCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtMarkCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -51,9 +52,9 @@ public class CtMarkCodec extends AbstractMatchCodec { CtMarkCaseValueBuilder caseBuilder = new CtMarkCaseValueBuilder(); CtMarkValuesBuilder ctMarkValuesBuilder = new CtMarkValuesBuilder(); if (matchEntryBuilder.isHasMask()) { - ctMarkValuesBuilder.setMask(message.readUnsignedInt()); + ctMarkValuesBuilder.setMask(readUint32(message)); } - ctMarkValuesBuilder.setCtMark(message.readUnsignedInt()); + ctMarkValuesBuilder.setCtMark(readUint32(message)); caseBuilder.setCtMarkValues(ctMarkValuesBuilder.build()); matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); return matchEntryBuilder.build(); @@ -83,5 +84,4 @@ public class CtMarkCodec extends AbstractMatchCodec { public Class getOxmClass() { return Nxm1Class.class; } - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtStateCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtStateCodec.java index 4b8b26dea6..1508e58027 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtStateCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtStateCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtState; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.state.grouping.CtStateValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtStateCaseValue; @@ -47,15 +47,15 @@ public class CtStateCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - final MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - CtStateCaseValueBuilder caseBuilder = new CtStateCaseValueBuilder(); - CtStateValuesBuilder ctStateValuesBuilder = new CtStateValuesBuilder(); - ctStateValuesBuilder.setCtState(message.readUnsignedInt()); - ctStateValuesBuilder.setMask(message.readUnsignedInt()); - caseBuilder.setCtStateValues(ctStateValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - matchEntryBuilder.setHasMask(true); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setHasMask(true) + .setMatchEntryValue(new CtStateCaseValueBuilder() + .setCtStateValues(new CtStateValuesBuilder() + .setCtState(readUint32(message)) + .setMask(readUint32(message)) + .build()) + .build()) + .build(); } @Override @@ -82,5 +82,4 @@ public class CtStateCodec extends AbstractMatchCodec { public Class getOxmClass() { return Nxm1Class.class; } - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpDstCodec.java index 0e4dd1b386..f401244a76 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpDstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpDstCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtTpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.tp.dst.grouping.CtTpDstValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtTpDstCaseValue; @@ -41,13 +41,11 @@ public class CtTpDstCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - final MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - CtTpDstCaseValueBuilder ctTpSrcCaseValueBuilder = new CtTpDstCaseValueBuilder(); - CtTpDstValuesBuilder ctTpSrcValuesBuilder = new CtTpDstValuesBuilder(); - ctTpSrcValuesBuilder.setCtTpDst(message.readUnsignedShort()); - ctTpSrcCaseValueBuilder.setCtTpDstValues(ctTpSrcValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(ctTpSrcCaseValueBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new CtTpDstCaseValueBuilder() + .setCtTpDstValues(new CtTpDstValuesBuilder().setCtTpDst(readUint16(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpSrcCodec.java index 3e710fb54c..2a15df91cb 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpSrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtTpSrcCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtTpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.tp.src.grouping.CtTpSrcValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtTpSrcCaseValue; @@ -41,13 +41,11 @@ public class CtTpSrcCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - final MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - CtTpSrcCaseValueBuilder ctTpSrcCaseValueBuilder = new CtTpSrcCaseValueBuilder(); - CtTpSrcValuesBuilder ctTpSrcValuesBuilder = new CtTpSrcValuesBuilder(); - ctTpSrcValuesBuilder.setCtTpSrc(message.readUnsignedShort()); - ctTpSrcCaseValueBuilder.setCtTpSrcValues(ctTpSrcValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(ctTpSrcCaseValueBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new CtTpSrcCaseValueBuilder() + .setCtTpSrcValues(new CtTpSrcValuesBuilder().setCtTpSrc(readUint16(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtZoneCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtZoneCodec.java index 729d8d22db..cb452331f9 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtZoneCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/CtZoneCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxCtZone; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.ct.zone.grouping.CtZoneValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.CtZoneCaseValue; @@ -46,13 +46,11 @@ public class CtZoneCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - CtZoneCaseValueBuilder caseBuilder = new CtZoneCaseValueBuilder(); - CtZoneValuesBuilder ctZoneValuesBuilder = new CtZoneValuesBuilder(); - ctZoneValuesBuilder.setCtZone(message.readUnsignedShort()); - caseBuilder.setCtZoneValues(ctZoneValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new CtZoneCaseValueBuilder() + .setCtZoneValues(new CtZoneValuesBuilder().setCtZone(readUint16(message)).build()) + .build()) + .build(); } @Override @@ -79,5 +77,4 @@ public class CtZoneCodec extends AbstractMatchCodec { public Class getOxmClass() { return Nxm1Class.class; } - } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java index c29da7592d..d5b6494a0a 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/EthTypeCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfEthType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.eth.type.grouping.EthTypeValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.EthTypeCaseValue; @@ -39,13 +40,11 @@ public class EthTypeCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - EthTypeCaseValueBuilder caseBuilder = new EthTypeCaseValueBuilder(); - EthTypeValuesBuilder valuesBuilder = new EthTypeValuesBuilder(); - valuesBuilder.setValue(message.readUnsignedShort()).build(); - caseBuilder.setEthTypeValues(valuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new EthTypeCaseValueBuilder() + .setEthTypeValues(new EthTypeValuesBuilder().setValue(readUint16(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IcmpTypeCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IcmpTypeCodec.java index c405cbfd22..d52e7ef1e2 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IcmpTypeCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IcmpTypeCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfIcmpType; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.icmp.type.grouping.IcmpTypeValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.IcmpTypeCaseValue; @@ -37,13 +38,12 @@ public class IcmpTypeCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); - IcmpTypeCaseValueBuilder icmpTypeCaseValueBuilder = new IcmpTypeCaseValueBuilder(); - icmpTypeCaseValueBuilder.setIcmpTypeValues(new IcmpTypeValuesBuilder() - .setValue(message.readUnsignedByte()).build()); - matchEntriesBuilder.setMatchEntryValue(icmpTypeCaseValueBuilder.build()); - matchEntriesBuilder.setHasMask(false); - return matchEntriesBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new IcmpTypeCaseValueBuilder() + .setIcmpTypeValues(new IcmpTypeValuesBuilder().setValue(readUint8(message)).build()) + .build()) + .setHasMask(false) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/InPortCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/InPortCodec.java index e5b9483e99..a6e164b1fb 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/InPortCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/InPortCodec.java @@ -16,7 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfInPort; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.in.port.type.grouping.NxmOfInPortValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.OfInPortCaseValue; @@ -44,13 +43,11 @@ public class InPortCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - OfInPortCaseValueBuilder caseBuilder = new OfInPortCaseValueBuilder(); - NxmOfInPortValuesBuilder valuesBuilder = new NxmOfInPortValuesBuilder(); - valuesBuilder.setValue(message.readInt()).build(); - caseBuilder.setNxmOfInPortValues(valuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new OfInPortCaseValueBuilder() + .setNxmOfInPortValues(new NxmOfInPortValuesBuilder().setValue(message.readInt()).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IpDstCodec.java index 4f60c526d7..4e72293734 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IpDstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IpDstCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfIpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.ip.dst.grouping.IpDstValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.IpDstCaseValue; @@ -36,14 +37,13 @@ public class IpDstCodec extends AbstractMatchCodec { public static final MatchEntryDeserializerKey DESERIALIZER_KEY = new MatchEntryDeserializerKey( EncodeConstants.OF13_VERSION_ID, OxmMatchConstants.NXM_0_CLASS, NXM_FIELD_CODE); - @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); - IpDstCaseValueBuilder caseBuilder = new IpDstCaseValueBuilder(); - caseBuilder.setIpDstValues(new IpDstValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntriesBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new IpDstCaseValueBuilder() + .setIpDstValues(new IpDstValuesBuilder().setValue(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IpSrcCodec.java index 6e5cf893ff..1aae00a60e 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IpSrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/IpSrcCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfIpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.ip.src.grouping.IpSrcValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.IpSrcCaseValue; @@ -39,11 +40,11 @@ public class IpSrcCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); - IpSrcCaseValueBuilder caseBuilder = new IpSrcCaseValueBuilder(); - caseBuilder.setIpSrcValues(new IpSrcValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntriesBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new IpSrcCaseValueBuilder() + .setIpSrcValues(new IpSrcValuesBuilder().setValue(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Ipv6DstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Ipv6DstCodec.java index 40957be303..7e20b3ad8b 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Ipv6DstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Ipv6DstCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfIpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.ip.dst.grouping.IpDstValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.IpDstCaseValue; @@ -39,11 +40,11 @@ public class Ipv6DstCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); - IpDstCaseValueBuilder caseBuilder = new IpDstCaseValueBuilder(); - caseBuilder.setIpDstValues(new IpDstValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntriesBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new IpDstCaseValueBuilder() + .setIpDstValues(new IpDstValuesBuilder().setValue(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Ipv6SrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Ipv6SrcCodec.java index 761065cf0e..b98cc75a90 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Ipv6SrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/Ipv6SrcCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -16,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfIpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.ip.src.grouping.IpSrcValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.IpSrcCaseValue; @@ -39,11 +40,11 @@ public class Ipv6SrcCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); - IpSrcCaseValueBuilder caseBuilder = new IpSrcCaseValueBuilder(); - caseBuilder.setIpSrcValues(new IpSrcValuesBuilder().setValue(message.readUnsignedInt()).build()); - matchEntriesBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntriesBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new IpSrcCaseValueBuilder() + .setIpSrcValues(new IpSrcValuesBuilder().setValue(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodec.java index 719b70141c..7fb4772b41 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshFlagsCodec.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; @@ -22,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NshFlagsCaseValueBuilder; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class NshFlagsCodec extends AbstractExperimenterMatchCodec { @@ -55,10 +58,11 @@ public class NshFlagsCodec extends AbstractExperimenterMatchCodec { @Override protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) { - Short flagsValue = message.readUnsignedByte(); - Short maskValue = hasMask ? message.readUnsignedByte() : null; - NshFlagsValues flagsValues = new NshFlagsValuesBuilder().setNshFlags(flagsValue).setMask(maskValue).build(); - return new NshFlagsCaseValueBuilder().setNshFlagsValues(flagsValues).build(); + Uint8 flagsValue = readUint8(message); + Uint8 maskValue = hasMask ? readUint8(message) : null; + return new NshFlagsCaseValueBuilder() + .setNshFlagsValues(new NshFlagsValuesBuilder().setNshFlags(flagsValue).setMask(maskValue).build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java index 2471846e18..1d0594deb9 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshMdtypeCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; @@ -47,9 +48,9 @@ public class NshMdtypeCodec extends AbstractExperimenterMatchCodec { @Override protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) { - Short value = message.readUnsignedByte(); - NshMdtypeValues nshMdtypeValues = new NshMdtypeValuesBuilder().setValue(value).build(); - return new NshMdtypeCaseValueBuilder().setNshMdtypeValues(nshMdtypeValues).build(); + return new NshMdtypeCaseValueBuilder() + .setNshMdtypeValues(new NshMdtypeValuesBuilder().setValue(readUint8(message)).build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java index c21df1d996..e7ce6ca1a3 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NshNpCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; @@ -46,9 +48,9 @@ public class NshNpCodec extends AbstractExperimenterMatchCodec { @Override protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) { - Short value = message.readUnsignedByte(); - NshNpValues nshNpValues = new NshNpValuesBuilder().setValue(value).build(); - return new NshNpCaseValueBuilder().setNshNpValues(nshNpValues).build(); + return new NshNpCaseValueBuilder() + .setNshNpValues(new NshNpValuesBuilder().setValue(readUint8(message)).build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java index df047cc05e..de4393c2bd 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NsiCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; @@ -21,6 +23,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.experimenter.id._case.nx.exp.match.entry.value.NsiCaseValueBuilder; import org.opendaylight.yangtools.yang.common.Uint32; +import org.opendaylight.yangtools.yang.common.Uint8; public class NsiCodec extends AbstractExperimenterMatchCodec { @@ -49,8 +52,8 @@ public class NsiCodec extends AbstractExperimenterMatchCodec { @Override protected NxExpMatchEntryValue deserializeValue(final ByteBuf message, final boolean hasMask) { - Short value = message.readUnsignedByte(); - Short mask = hasMask ? message.readUnsignedByte() : null; + Uint8 value = readUint8(message); + Uint8 mask = hasMask ? readUint8(message) : null; NsiValues nsiValues = new NsiValuesBuilder().setNsi(value).setMask(mask).build(); return new NsiCaseValueBuilder().setNsiValues(nsiValues).build(); } diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java index ba7353cbf9..759dc4ad55 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/NspCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.nx.api.NiciraConstants; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; @@ -49,10 +51,11 @@ public class NspCodec extends AbstractExperimenterMatchCodec { @Override protected NxExpMatchEntryValue deserializeValue(ByteBuf message, boolean hasMask) { - Long nspValue = message.readUnsignedInt(); - Long maskValue = hasMask ? message.readUnsignedInt() : null; - NspValues nspValues = new NspValuesBuilder().setNsp(nspValue).setMask(maskValue).build(); - return new NspCaseValueBuilder().setNspValues(nspValues).build(); + Uint32 nspValue = readUint32(message); + Uint32 maskValue = hasMask ? readUint32(message) : null; + return new NspCaseValueBuilder() + .setNspValues(new NspValuesBuilder().setNsp(nspValue).setMask(maskValue).build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/PktMarkCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/PktMarkCodec.java index 99183724ac..0692bb0536 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/PktMarkCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/PktMarkCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxPktMark; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.pkt.mark.grouping.PktMarkValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.PktMarkCaseValue; @@ -42,13 +42,11 @@ public class PktMarkCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - final MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - PktMarkCaseValueBuilder pktMarkCaseValueBuilder = new PktMarkCaseValueBuilder(); - PktMarkValuesBuilder pktMarkValuesBuilder = new PktMarkValuesBuilder(); - pktMarkValuesBuilder.setPktMark(message.readUnsignedInt()); - pktMarkCaseValueBuilder.setPktMarkValues(pktMarkValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(pktMarkCaseValueBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new PktMarkCaseValueBuilder() + .setPktMarkValues(new PktMarkValuesBuilder().setPktMark(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java index 4254304fa8..f9202f51cd 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpDstCodec.java @@ -17,11 +17,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfTcpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.tcp.dst.grouping.TcpDstValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValue; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpDstCaseValueBuilder; +import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils; /** * Codec for the TcpDst message. @@ -47,17 +47,15 @@ public class TcpDstCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(final ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - matchEntryBuilder.setHasMask(true); - int portNo = message.readUnsignedShort(); - int mask = message.readUnsignedShort(); - TcpDstCaseValueBuilder caseBuilder = new TcpDstCaseValueBuilder(); - TcpDstValuesBuilder tcpDstValuesBuilder = new TcpDstValuesBuilder(); - tcpDstValuesBuilder.setPort(new PortNumber(portNo)); - tcpDstValuesBuilder.setMask(mask); - caseBuilder.setTcpDstValues(tcpDstValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setHasMask(true) + .setMatchEntryValue(new TcpDstCaseValueBuilder() + .setTcpDstValues(new TcpDstValuesBuilder() + .setPort(new PortNumber(ByteBufUtils.readUint16(message))) + .setMask(ByteBufUtils.readUint16(message)) + .build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java index 8914d71126..0ac34ab066 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TcpSrcCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfTcpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.tcp.src.grouping.TcpSrcValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TcpSrcCaseValue; @@ -47,17 +48,15 @@ public class TcpSrcCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - matchEntryBuilder.setHasMask(true); - int portNo = message.readUnsignedShort(); - int mask = message.readUnsignedShort(); - TcpSrcCaseValueBuilder caseBuilder = new TcpSrcCaseValueBuilder(); - TcpSrcValuesBuilder tcpSrcValuesBuilder = new TcpSrcValuesBuilder(); - tcpSrcValuesBuilder.setPort(new PortNumber(portNo)); - tcpSrcValuesBuilder.setMask(mask); - caseBuilder.setTcpSrcValues(tcpSrcValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setHasMask(true) + .setMatchEntryValue(new TcpSrcCaseValueBuilder() + .setTcpSrcValues(new TcpSrcValuesBuilder() + .setPort(new PortNumber(readUint16(message))) + .setMask(readUint16(message)) + .build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java index d1b4a3d4e7..90c8af24b4 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4DstCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunIpv4Dst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.ipv4.dst.grouping.TunIpv4DstValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunIpv4DstCaseValue; @@ -41,13 +41,11 @@ public class TunIpv4DstCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); - TunIpv4DstCaseValueBuilder caseBuilder = new TunIpv4DstCaseValueBuilder(); - TunIpv4DstValuesBuilder valuesBuilder = new TunIpv4DstValuesBuilder(); - valuesBuilder.setValue(message.readUnsignedInt()); - caseBuilder.setTunIpv4DstValues(valuesBuilder.build()); - matchEntriesBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntriesBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new TunIpv4DstCaseValueBuilder() + .setTunIpv4DstValues(new TunIpv4DstValuesBuilder().setValue(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java index 166f675f44..a1b6877ebc 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/TunIpv4SrcCodec.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +18,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm1Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxTunIpv4Src; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.nx.match.tun.ipv4.src.grouping.TunIpv4SrcValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.TunIpv4SrcCaseValue; @@ -41,13 +41,11 @@ public class TunIpv4SrcCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntriesBuilder = deserializeHeaderToBuilder(message); - TunIpv4SrcCaseValueBuilder caseBuilder = new TunIpv4SrcCaseValueBuilder(); - TunIpv4SrcValuesBuilder valuesBuilder = new TunIpv4SrcValuesBuilder(); - valuesBuilder.setValue(message.readUnsignedInt()); - caseBuilder.setTunIpv4SrcValues(valuesBuilder.build()); - matchEntriesBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntriesBuilder.build(); + return deserializeHeaderToBuilder(message) + .setMatchEntryValue(new TunIpv4SrcCaseValueBuilder() + .setTunIpv4SrcValues(new TunIpv4SrcValuesBuilder().setValue(readUint32(message)).build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java index 8174e18ee6..ec732adf3e 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpDstCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfUdpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.udp.dst.grouping.UdpDstValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpDstCaseValue; @@ -47,17 +48,15 @@ public class UdpDstCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - matchEntryBuilder.setHasMask(true); - int portNo = message.readUnsignedShort(); - int mask = message.readUnsignedShort(); - UdpDstCaseValueBuilder caseBuilder = new UdpDstCaseValueBuilder(); - UdpDstValuesBuilder udpDstValuesBuilder = new UdpDstValuesBuilder(); - udpDstValuesBuilder.setPort(new PortNumber(portNo)); - udpDstValuesBuilder.setMask(mask); - caseBuilder.setUdpDstValues(udpDstValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setHasMask(true) + .setMatchEntryValue(new UdpDstCaseValueBuilder() + .setUdpDstValues(new UdpDstValuesBuilder() + .setPort(new PortNumber(readUint16(message))) + .setMask(readUint16(message)) + .build()) + .build()) + .build(); } @Override diff --git a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java index 21870f877d..da0f41790b 100644 --- a/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java +++ b/extension/openflowjava-extension-nicira/src/main/java/org/opendaylight/openflowjava/nx/codec/match/UdpSrcCodec.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.nx.codec.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntryDeserializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; @@ -17,7 +19,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Nxm0Class; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmOfUdpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.ofj.nxm.of.match.udp.src.grouping.UdpSrcValuesBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.UdpSrcCaseValue; @@ -47,17 +48,15 @@ public class UdpSrcCodec extends AbstractMatchCodec { @Override public MatchEntry deserialize(ByteBuf message) { - MatchEntryBuilder matchEntryBuilder = deserializeHeaderToBuilder(message); - matchEntryBuilder.setHasMask(true); - int portNo = message.readUnsignedShort(); - int mask = message.readUnsignedShort(); - UdpSrcCaseValueBuilder caseBuilder = new UdpSrcCaseValueBuilder(); - UdpSrcValuesBuilder udpSrcValuesBuilder = new UdpSrcValuesBuilder(); - udpSrcValuesBuilder.setPort(new PortNumber(portNo)); - udpSrcValuesBuilder.setMask(mask); - caseBuilder.setUdpSrcValues(udpSrcValuesBuilder.build()); - matchEntryBuilder.setMatchEntryValue(caseBuilder.build()); - return matchEntryBuilder.build(); + return deserializeHeaderToBuilder(message) + .setHasMask(true) + .setMatchEntryValue(new UdpSrcCaseValueBuilder() + .setUdpSrcValues(new UdpSrcValuesBuilder() + .setPort(new PortNumber(readUint16(message))) + .setMask(readUint16(message)) + .build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/pom.xml b/openflowjava/openflow-protocol-impl/pom.xml index bd9a9ed346..28ab9676b5 100644 --- a/openflowjava/openflow-protocol-impl/pom.xml +++ b/openflowjava/openflow-protocol-impl/pom.xml @@ -111,6 +111,10 @@ org.opendaylight.infrautils diagstatus-api + + org.opendaylight.yangtools + yang-common-netty + io.netty netty-transport-native-epoll diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java index abbfc40727..969cff2f4d 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10EnqueueActionDeserializer.java @@ -5,9 +5,11 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -26,24 +28,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 * @author michal.polkorab */ public class OF10EnqueueActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { - final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - final EnqueueCaseBuilder caseBuilder = new EnqueueCaseBuilder(); EnqueueActionBuilder actionBuilder = new EnqueueActionBuilder(); - actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); + actionBuilder.setPort(new PortNumber(readUint16(input).toUint32())); input.skipBytes(ActionConstants.PADDING_IN_ENQUEUE_ACTION); - actionBuilder.setQueueId(new QueueId(input.readUnsignedInt())); - caseBuilder.setEnqueueAction(actionBuilder.build()); - builder.setActionChoice(caseBuilder.build()); - return builder.build(); + actionBuilder.setQueueId(new QueueId(readUint32(input))); + return new ActionBuilder() + .setActionChoice(new EnqueueCaseBuilder().setEnqueueAction(actionBuilder.build()).build()) + .build(); } @Override protected ActionChoice getType() { return new OutputActionCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java index f4eb99286f..81e7647796 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10OutputActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; @@ -23,15 +24,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 * @author michal.polkorab */ public class OF10OutputActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); OutputActionBuilder actionBuilder = new OutputActionBuilder(); - actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); - actionBuilder.setMaxLength(input.readUnsignedShort()); + actionBuilder.setPort(new PortNumber(readUint16(input).toUint32())); + actionBuilder.setMaxLength(readUint16(input)); caseBuilder.setOutputAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); return builder.build(); @@ -41,5 +41,4 @@ public class OF10OutputActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new OutputActionCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java index 6e0c0ac329..be0554b2d8 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetNwTosActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -23,14 +24,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 * @author michal.polkorab */ public class OF10SetNwTosActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetNwTosCaseBuilder caseBuilder = new SetNwTosCaseBuilder(); SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder(); - tosBuilder.setNwTos(input.readUnsignedByte()); + tosBuilder.setNwTos(readUint8(input)); caseBuilder.setSetNwTosAction(tosBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_SET_NW_TOS_ACTION); @@ -41,5 +41,4 @@ public class OF10SetNwTosActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new SetNwTosCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java index 65c2ac5083..91d8bf0f81 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpDstActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -24,14 +25,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 * @author michal.polkorab */ public class OF10SetTpDstActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetTpDstCaseBuilder caseBuilder = new SetTpDstCaseBuilder(); SetTpDstActionBuilder actionBuilder = new SetTpDstActionBuilder(); - actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); + actionBuilder.setPort(new PortNumber(readUint16(input).toUint32())); caseBuilder.setSetTpDstAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); @@ -42,5 +42,4 @@ public class OF10SetTpDstActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new SetTpDstCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java index 210016d73e..95139c92a3 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetTpSrcActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -24,14 +25,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 * @author michal.polkorab */ public class OF10SetTpSrcActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetTpSrcCaseBuilder caseBuilder = new SetTpSrcCaseBuilder(); SetTpSrcActionBuilder actionBuilder = new SetTpSrcActionBuilder(); - actionBuilder.setPort(new PortNumber((long) input.readUnsignedShort())); + actionBuilder.setPort(new PortNumber(readUint16(input).toUint32())); caseBuilder.setSetTpSrcAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_TP_PORT_ACTION); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java index ed2e8c0bb7..15a3bcc691 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanPcpActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -23,7 +24,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 * @author michal.polkorab */ public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping @@ -31,7 +31,7 @@ public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetVlanPcpCaseBuilder caseBuilder = new SetVlanPcpCaseBuilder(); SetVlanPcpActionBuilder actionBuilder = new SetVlanPcpActionBuilder(); - actionBuilder.setVlanPcp(input.readUnsignedByte()); + actionBuilder.setVlanPcp(readUint8(input)); caseBuilder.setSetVlanPcpAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_PCP_ACTION); @@ -42,5 +42,4 @@ public class OF10SetVlanPcpActionDeserializer extends AbstractActionDeserializer protected ActionChoice getType() { return new SetVlanPcpCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java index 3bf0810265..223cbaee94 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF10SetVlanVidActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -26,14 +27,11 @@ public class OF10SetVlanVidActionDeserializer extends AbstractActionDeserializer @Override public Action deserialize(ByteBuf input) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping - .ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - SetVlanVidCaseBuilder caseBuilder = new SetVlanVidCaseBuilder(); - SetVlanVidActionBuilder actionBuilder = new SetVlanVidActionBuilder(); - actionBuilder.setVlanVid(input.readUnsignedShort()); - caseBuilder.setSetVlanVidAction(actionBuilder.build()); - builder.setActionChoice(caseBuilder.build()); + final ActionBuilder builder = new ActionBuilder() + .setActionChoice(new SetVlanVidCaseBuilder() + .setSetVlanVidAction(new SetVlanVidActionBuilder().setVlanVid(readUint16(input)).build()) + .build()); input.skipBytes(ActionConstants.PADDING_IN_SET_VLAN_VID_ACTION); return builder.build(); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java index 9f9683882d..be361a02df 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13GroupActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; @@ -22,23 +23,18 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 * @author michal.polkorab */ public class OF13GroupActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping - .ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - GroupCaseBuilder caseBuilder = new GroupCaseBuilder(); - GroupActionBuilder actionBuilder = new GroupActionBuilder(); - actionBuilder.setGroupId(input.readUnsignedInt()); - caseBuilder.setGroupAction(actionBuilder.build()); - builder.setActionChoice(caseBuilder.build()); - return builder.build(); + return new ActionBuilder() + .setActionChoice(new GroupCaseBuilder() + .setGroupAction(new GroupActionBuilder().setGroupId(readUint32(input)).build()) + .build()) + .build(); } @Override protected ActionChoice getType() { return new GroupCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java index 4f41f4b135..4d57adc980 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13OutputActionDeserializer.java @@ -5,9 +5,11 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -24,7 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 * @author michal.polkorab */ public class OF13OutputActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping @@ -32,8 +33,8 @@ public class OF13OutputActionDeserializer extends AbstractActionDeserializer { input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); OutputActionBuilder actionBuilder = new OutputActionBuilder(); - actionBuilder.setPort(new PortNumber(input.readUnsignedInt())); - actionBuilder.setMaxLength(input.readUnsignedShort()); + actionBuilder.setPort(new PortNumber(readUint32(input))); + actionBuilder.setMaxLength(readUint16(input)); caseBuilder.setOutputAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.OUTPUT_PADDING); @@ -44,5 +45,4 @@ public class OF13OutputActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new OutputActionCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java index c414de406e..f4c15c7d6b 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PopMplsActionDeserializer.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.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; @@ -17,6 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils; /** * OF13PopMplsActionDeserializer. @@ -24,16 +24,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 * @author michal.polkorab */ public class OF13PopMplsActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { - final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - PopMplsCaseBuilder caseBuilder = new PopMplsCaseBuilder(); - PopMplsActionBuilder mplsBuilder = new PopMplsActionBuilder(); - mplsBuilder.setEthertype(new EtherType(input.readUnsignedShort())); - caseBuilder.setPopMplsAction(mplsBuilder.build()); - builder.setActionChoice(caseBuilder.build()); + final ActionBuilder builder = new ActionBuilder() + .setActionChoice(new PopMplsCaseBuilder() + .setPopMplsAction(new PopMplsActionBuilder() + .setEthertype(new EtherType(ByteBufUtils.readUint16(input))) + .build()) + .build()); input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); return builder.build(); } @@ -42,5 +41,4 @@ public class OF13PopMplsActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new PopMplsCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java index 681f65ed78..abd1284b88 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushMplsActionDeserializer.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.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; @@ -17,6 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils; /** * OF13PushMplsActionDeserializer. @@ -31,7 +31,7 @@ public class OF13PushMplsActionDeserializer extends AbstractActionDeserializer { input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); PushMplsCaseBuilder caseBuilder = new PushMplsCaseBuilder(); PushMplsActionBuilder mplsBuilder = new PushMplsActionBuilder(); - mplsBuilder.setEthertype(new EtherType(input.readUnsignedShort())); + mplsBuilder.setEthertype(new EtherType(ByteBufUtils.readUint16(input))); caseBuilder.setPushMplsAction(mplsBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); @@ -42,5 +42,4 @@ public class OF13PushMplsActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new PushMplsCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java index 01ed3bf9af..33c8149580 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushPbbActionDeserializer.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.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; @@ -17,6 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils; /** * OF13PushPbbActionDeserializer. @@ -24,16 +24,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 * @author michal.polkorab */ public class OF13PushPbbActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { - final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - PushPbbCaseBuilder caseBuilder = new PushPbbCaseBuilder(); - PushPbbActionBuilder pbbBuilder = new PushPbbActionBuilder(); - pbbBuilder.setEthertype(new EtherType(input.readUnsignedShort())); - caseBuilder.setPushPbbAction(pbbBuilder.build()); - builder.setActionChoice(caseBuilder.build()); + final ActionBuilder builder = new ActionBuilder() + .setActionChoice(new PushPbbCaseBuilder() + .setPushPbbAction(new PushPbbActionBuilder() + .setEthertype(new EtherType(ByteBufUtils.readUint16(input))) + .build()) + .build()); input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); return builder.build(); } @@ -42,5 +41,4 @@ public class OF13PushPbbActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new PushPbbCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java index 63792a5b97..f7ad0c92dc 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13PushVlanActionDeserializer.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.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; @@ -17,6 +16,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.EtherType; +import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils; /** * OF13PushVlanActionDeserializer. @@ -24,16 +24,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 * @author michal.polkorab */ public class OF13PushVlanActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { - final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - PushVlanCaseBuilder caseBuilder = new PushVlanCaseBuilder(); - PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder(); - vlanBuilder.setEthertype(new EtherType(input.readUnsignedShort())); - caseBuilder.setPushVlanAction(vlanBuilder.build()); - builder.setActionChoice(caseBuilder.build()); + final ActionBuilder builder = new ActionBuilder() + .setActionChoice(new PushVlanCaseBuilder() + .setPushVlanAction(new PushVlanActionBuilder() + .setEthertype(new EtherType(ByteBufUtils.readUint16(input))) + .build()) + .build()); input.skipBytes(ActionConstants.ETHERTYPE_ACTION_PADDING); return builder.build(); } @@ -42,5 +41,4 @@ public class OF13PushVlanActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new PushVlanCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java index f833bd9cee..150d58a5f9 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetMplsTtlActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -23,14 +24,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 * @author michal.polkorab */ public class OF13SetMplsTtlActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetMplsTtlCaseBuilder caseBuilder = new SetMplsTtlCaseBuilder(); SetMplsTtlActionBuilder actionBuilder = new SetMplsTtlActionBuilder(); - actionBuilder.setMplsTtl(input.readUnsignedByte()); + actionBuilder.setMplsTtl(readUint8(input)); caseBuilder.setSetMplsTtlAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.SET_MPLS_TTL_PADDING); @@ -41,5 +41,4 @@ public class OF13SetMplsTtlActionDeserializer extends AbstractActionDeserializer protected ActionChoice getType() { return new SetMplsTtlCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java index 028be4d4bf..ac6408dd17 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetNwTtlActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants; @@ -23,14 +24,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 * @author michal.polkorab */ public class OF13SetNwTtlActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetNwTtlCaseBuilder caseBuilder = new SetNwTtlCaseBuilder(); SetNwTtlActionBuilder actionBuilder = new SetNwTtlActionBuilder(); - actionBuilder.setNwTtl(input.readUnsignedByte()); + actionBuilder.setNwTtl(readUint8(input)); caseBuilder.setSetNwTtlAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); input.skipBytes(ActionConstants.SET_NW_TTL_PADDING); @@ -41,5 +41,4 @@ public class OF13SetNwTtlActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new SetNwTtlCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java index 797a2723b7..915296250c 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/action/OF13SetQueueActionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.ActionChoice; @@ -22,14 +23,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev1 * @author michal.polkorab */ public class OF13SetQueueActionDeserializer extends AbstractActionDeserializer { - @Override public Action deserialize(ByteBuf input) { final ActionBuilder builder = new ActionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); SetQueueCaseBuilder caseBuilder = new SetQueueCaseBuilder(); SetQueueActionBuilder actionBuilder = new SetQueueActionBuilder(); - actionBuilder.setQueueId(input.readUnsignedInt()); + actionBuilder.setQueueId(readUint32(input)); caseBuilder.setSetQueueAction(actionBuilder.build()); builder.setActionChoice(caseBuilder.build()); return builder.build(); @@ -39,5 +39,4 @@ public class OF13SetQueueActionDeserializer extends AbstractActionDeserializer { protected ActionChoice getType() { return new SetQueueCaseBuilder().build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java index 254a9ea793..04878ac649 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierInputMessageFactory.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; @@ -22,10 +24,9 @@ public class BarrierInputMessageFactory extends VersionAssignableFactory impleme @Override public BarrierInput deserialize(ByteBuf rawMessage) { - BarrierInputBuilder builder = new BarrierInputBuilder(); - builder.setVersion(getVersion()); - builder.setXid(rawMessage.readUnsignedInt()); - return builder.build(); + return new BarrierInputBuilder() + .setVersion(getVersion()) + .setXid(readUint32(rawMessage)) + .build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java index 4d5cf784bb..0945f0b00e 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/BarrierReplyMessageFactory.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; @@ -24,9 +26,9 @@ public class BarrierReplyMessageFactory extends VersionAssignableFactory impleme @Override public BarrierOutput deserialize(ByteBuf rawMessage) { - BarrierOutputBuilder builder = new BarrierOutputBuilder(); - builder.setVersion(getVersion()); - builder.setXid(rawMessage.readUnsignedInt()); - return builder.build(); + return new BarrierOutputBuilder() + .setVersion(getVersion()) + .setXid(readUint32(rawMessage)) + .build(); } } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java index 217071fb16..c8aa2369aa 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoReplyMessageFactory.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; @@ -26,7 +28,7 @@ public class EchoReplyMessageFactory extends VersionAssignableFactory implements public EchoOutput deserialize(ByteBuf rawMessage) { EchoOutputBuilder builder = new EchoOutputBuilder(); builder.setVersion(getVersion()); - builder.setXid(rawMessage.readUnsignedInt()); + builder.setXid(readUint32(rawMessage)); int remainingBytes = rawMessage.readableBytes(); if (remainingBytes > 0) { byte[] data = new byte[remainingBytes]; diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java index ef253977ca..3df9e6049d 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/EchoRequestMessageFactory.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; @@ -26,7 +28,7 @@ public class EchoRequestMessageFactory extends VersionAssignableFactory implemen public EchoRequestMessage deserialize(ByteBuf rawMessage) { EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder(); builder.setVersion(getVersion()); - builder.setXid(rawMessage.readUnsignedInt()); + builder.setXid(readUint32(rawMessage)); byte[] data = new byte[rawMessage.readableBytes()]; rawMessage.readBytes(data); builder.setData(data); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java index b46c46f566..0024ed34e4 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ErrorMessageFactory.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; import java.util.Objects; @@ -55,7 +57,7 @@ public class ErrorMessageFactory implements OFDeserializer, int startIndex = rawMessage.readerIndex(); ErrorMessageBuilder builder = new ErrorMessageBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); + builder.setXid(readUint32(rawMessage)); int type = rawMessage.readUnsignedShort(); ErrorType errorType = ErrorType.forValue(type); if (ErrorType.EXPERIMENTER.equals(errorType)) { diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java index 13995727f8..4f6c94372b 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/ExperimenterMessageFactory.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; import java.util.Objects; @@ -20,6 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13 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.experimenter.core.ExperimenterDataOfChoice; +import org.opendaylight.yangtools.yang.common.Uint32; /** * Implementation of OFDeserializer for ExperimenterMessages. @@ -36,7 +38,7 @@ public class ExperimenterMessageFactory implements OFDeserializer, FlowModInputBuilder builder = new FlowModInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(cookie); - builder.setCookie(new BigInteger(1, cookie)); - final byte[] cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(cookieMask); - builder.setCookieMask(new BigInteger(1, cookieMask)); - builder.setTableId(new TableId((long) rawMessage.readUnsignedByte())); + builder.setXid(readUint32(rawMessage)); + builder.setCookie(readUint64(rawMessage)); + builder.setCookieMask(readUint64(rawMessage)); + builder.setTableId(new TableId(readUint8(rawMessage).toUint32())); builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedByte())); - builder.setIdleTimeout(rawMessage.readUnsignedShort()); - builder.setHardTimeout(rawMessage.readUnsignedShort()); - builder.setPriority(rawMessage.readUnsignedShort()); - builder.setBufferId(rawMessage.readUnsignedInt()); - builder.setOutPort(new PortNumber(rawMessage.readUnsignedInt())); - builder.setOutGroup(rawMessage.readUnsignedInt()); + builder.setIdleTimeout(readUint16(rawMessage)); + builder.setHardTimeout(readUint16(rawMessage)); + builder.setPriority(readUint16(rawMessage)); + builder.setBufferId(readUint32(rawMessage)); + builder.setOutPort(new PortNumber(readUint32(rawMessage))); + builder.setOutGroup(readUint32(rawMessage)); builder.setFlags(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort())); rawMessage.skipBytes(PADDING); OFDeserializer matchDeserializer = registry.getDeserializer( diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java index f8a5667e62..d2a589b7e7 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/FlowRemovedMessageFactory.java @@ -5,12 +5,15 @@ * terms of the Eclipse Public License v1.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.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint64; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import java.util.Objects; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; @@ -41,23 +44,17 @@ public class FlowRemovedMessageFactory implements OFDeserializer matchDeserializer = registry.getDeserializer(new MessageCodeKey( EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); builder.setMatch(matchDeserializer.deserialize(rawMessage)); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java index 0e124962b3..37d05aeee0 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetAsyncReplyMessageFactory.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import java.util.ArrayList; import java.util.List; @@ -39,7 +41,7 @@ public class GetAsyncReplyMessageFactory implements OFDeserializer { - @Override public GetAsyncInput deserialize(ByteBuf rawMessage) { - GetAsyncInputBuilder builder = new GetAsyncInputBuilder(); - builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - return builder.build(); + return new GetAsyncInputBuilder() + .setVersion((short) EncodeConstants.OF13_VERSION_ID) + .setXid(readUint32(rawMessage)) + .build(); } } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java index 84bb66faba..f2e7e08a6f 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigInputMessageFactory.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; @@ -19,13 +21,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731 * @author giuseppex.petralia@intel.com */ public class GetConfigInputMessageFactory extends VersionAssignableFactory implements OFDeserializer { - @Override public GetConfigInput deserialize(ByteBuf rawMessage) { - GetConfigInputBuilder builder = new GetConfigInputBuilder(); - builder.setVersion(getVersion()); - builder.setXid(rawMessage.readUnsignedInt()); - return builder.build(); + return new GetConfigInputBuilder() + .setVersion(getVersion()) + .setXid(readUint32(rawMessage)) + .build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java index c8c8071cda..f8e4bcc98d 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetConfigReplyMessageFactory.java @@ -5,9 +5,11 @@ * terms of the Eclipse Public License v1.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.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.impl.util.VersionAssignableFactory; @@ -27,9 +29,9 @@ public class GetConfigReplyMessageFactory extends VersionAssignableFactory imple public GetConfigOutput deserialize(ByteBuf rawMessage) { GetConfigOutputBuilder builder = new GetConfigOutputBuilder(); builder.setVersion(getVersion()); - builder.setXid(rawMessage.readUnsignedInt()); + builder.setXid(readUint32(rawMessage)); builder.setFlags(SwitchConfigFlag.forValue(rawMessage.readUnsignedShort())); - builder.setMissSendLen(rawMessage.readUnsignedShort()); + builder.setMissSendLen(readUint16(rawMessage)); return builder.build(); } } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java index 4295644c7c..e3d72996b0 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/GetFeaturesInputMessageFactory.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -17,9 +19,9 @@ public class GetFeaturesInputMessageFactory implements OFDeserializer bucketsList = new ArrayList<>(); while (rawMessage.readableBytes() > 0) { BucketsListBuilder bucketsBuilder = new BucketsListBuilder(); final int bucketsLength = rawMessage.readUnsignedShort(); - bucketsBuilder.setWeight(rawMessage.readUnsignedShort()); - bucketsBuilder.setWatchPort(new PortNumber(rawMessage.readUnsignedInt())); - bucketsBuilder.setWatchGroup(rawMessage.readUnsignedInt()); + bucketsBuilder.setWeight(readUint16(rawMessage)); + bucketsBuilder.setWatchPort(new PortNumber(readUint32(rawMessage))); + bucketsBuilder.setWatchGroup(readUint32(rawMessage)); rawMessage.skipBytes(PADDING_IN_BUCKETS_HEADER); CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, @@ -70,5 +73,4 @@ public class GroupModInputMessageFactory implements OFDeserializer 0) { builder.setElements(readElement(rawMessage)); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java index 2a6ab7e314..4d03bee586 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MeterModInputMessageFactory.java @@ -7,6 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; import java.util.ArrayList; @@ -54,10 +57,10 @@ public class MeterModInputMessageFactory implements OFDeserializer bandsList = new ArrayList<>(); while (rawMessage.readableBytes() > 0) { BandsBuilder bandsBuilder = new BandsBuilder(); @@ -69,8 +72,8 @@ public class MeterModInputMessageFactory implements OFDeserializer matchDeserializer = registry.getDeserializer(new MessageCodeKey( EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); flowStatsBuilder.setMatch(matchDeserializer.deserialize(subInput)); @@ -322,13 +319,9 @@ public class MultipartReplyMessageFactory implements OFDeserializer tableStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { TableStatsBuilder tableStatsBuilder = new TableStatsBuilder(); - tableStatsBuilder.setTableId(input.readUnsignedByte()); + tableStatsBuilder.setTableId(readUint8(input)); input.skipBytes(PADDING_IN_TABLE_HEADER); - tableStatsBuilder.setActiveCount(input.readUnsignedInt()); - byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(lookupCount); - tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount)); - byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(matchedCount); - tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount)); + tableStatsBuilder.setActiveCount(readUint32(input)); + tableStatsBuilder.setLookupCount(readUint64(input)); + tableStatsBuilder.setMatchedCount(readUint64(input)); tableStatsList.add(tableStatsBuilder.build()); } builder.setTableStats(tableStatsList); @@ -363,7 +352,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer 0) { TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder(); final int length = input.readUnsignedShort(); - featuresBuilder.setTableId(input.readUnsignedByte()); + featuresBuilder.setTableId(readUint8(input)); input.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES); featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH)); byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; @@ -373,7 +362,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer ids = new ArrayList<>(); while (propertyLength > 0) { NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder(); - nextTableIdsBuilder.setTableId(input.readUnsignedByte()); + nextTableIdsBuilder.setTableId(readUint8(input)); ids.add(nextTableIdsBuilder.build()); propertyLength--; } @@ -462,46 +451,22 @@ public class MultipartReplyMessageFactory implements OFDeserializer portStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { PortStatsBuilder portStatsBuilder = new PortStatsBuilder(); - portStatsBuilder.setPortNo(input.readUnsignedInt()); + portStatsBuilder.setPortNo(readUint32(input)); input.skipBytes(PADDING_IN_PORT_STATS_HEADER); - byte[] rxPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxPackets); - portStatsBuilder.setRxPackets(new BigInteger(1, rxPackets)); - byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txPackets); - portStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); - byte[] rxBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxBytes); - portStatsBuilder.setRxBytes(new BigInteger(1, rxBytes)); - byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txBytes); - portStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); - byte[] rxDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxDropped); - portStatsBuilder.setRxDropped(new BigInteger(1, rxDropped)); - byte[] txDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txDropped); - portStatsBuilder.setTxDropped(new BigInteger(1, txDropped)); - byte[] rxErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxErrors); - portStatsBuilder.setRxErrors(new BigInteger(1, rxErrors)); - byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txErrors); - portStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); - byte[] rxFrameErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxFrameErr); - portStatsBuilder.setRxFrameErr(new BigInteger(1, rxFrameErr)); - byte[] rxOverErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxOverErr); - portStatsBuilder.setRxOverErr(new BigInteger(1, rxOverErr)); - byte[] rxCrcErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxCrcErr); - portStatsBuilder.setRxCrcErr(new BigInteger(1, rxCrcErr)); - byte[] collisions = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(collisions); - portStatsBuilder.setCollisions(new BigInteger(1, collisions)); - portStatsBuilder.setDurationSec(input.readUnsignedInt()); - portStatsBuilder.setDurationNsec(input.readUnsignedInt()); + portStatsBuilder.setRxPackets(readUint64(input)); + portStatsBuilder.setTxPackets(readUint64(input)); + portStatsBuilder.setRxBytes(readUint64(input)); + portStatsBuilder.setTxBytes(readUint64(input)); + portStatsBuilder.setRxDropped(readUint64(input)); + portStatsBuilder.setTxDropped(readUint64(input)); + portStatsBuilder.setRxErrors(readUint64(input)); + portStatsBuilder.setTxErrors(readUint64(input)); + portStatsBuilder.setRxFrameErr(readUint64(input)); + portStatsBuilder.setRxOverErr(readUint64(input)); + portStatsBuilder.setRxCrcErr(readUint64(input)); + portStatsBuilder.setCollisions(readUint64(input)); + portStatsBuilder.setDurationSec(readUint32(input)); + portStatsBuilder.setDurationNsec(readUint32(input)); portStatsList.add(portStatsBuilder.build()); } builder.setPortStats(portStatsList); @@ -515,19 +480,13 @@ public class MultipartReplyMessageFactory implements OFDeserializer queueStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder(); - queueStatsBuilder.setPortNo(input.readUnsignedInt()); - queueStatsBuilder.setQueueId(input.readUnsignedInt()); - byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txBytes); - queueStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); - byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txPackets); - queueStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); - byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txErrors); - queueStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); - queueStatsBuilder.setDurationSec(input.readUnsignedInt()); - queueStatsBuilder.setDurationNsec(input.readUnsignedInt()); + queueStatsBuilder.setPortNo(readUint32(input)); + queueStatsBuilder.setQueueId(readUint32(input)); + queueStatsBuilder.setTxBytes(readUint64(input)); + queueStatsBuilder.setTxPackets(readUint64(input)); + queueStatsBuilder.setTxErrors(readUint64(input)); + queueStatsBuilder.setDurationSec(readUint32(input)); + queueStatsBuilder.setDurationNsec(readUint32(input)); queueStatsList.add(queueStatsBuilder.build()); } builder.setQueueStats(queueStatsList); @@ -543,27 +502,19 @@ public class MultipartReplyMessageFactory implements OFDeserializer bucketStatsList = new ArrayList<>(); while (actualLength < bodyLength) { BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder(); - byte[] packetCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(packetCountBucket); - bucketStatsBuilder.setPacketCount(new BigInteger(1, packetCountBucket)); - byte[] byteCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(byteCountBucket); - bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket)); + bucketStatsBuilder.setPacketCount(readUint64(input)); + bucketStatsBuilder.setByteCount(readUint64(input)); bucketStatsList.add(bucketStatsBuilder.build()); actualLength += BUCKET_COUNTER_LENGTH; } @@ -578,11 +529,11 @@ public class MultipartReplyMessageFactory implements OFDeserializer meterStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { MeterStatsBuilder meterStatsBuilder = new MeterStatsBuilder(); - meterStatsBuilder.setMeterId(new MeterId(input.readUnsignedInt())); + meterStatsBuilder.setMeterId(new MeterId(readUint32(input))); final int meterStatsBodyLength = input.readUnsignedShort(); input.skipBytes(PADDING_IN_METER_STATS_HEADER); - meterStatsBuilder.setFlowCount(input.readUnsignedInt()); - byte[] packetInCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(packetInCount); - meterStatsBuilder.setPacketInCount(new BigInteger(1, packetInCount)); - byte[] byteInCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(byteInCount); - meterStatsBuilder.setByteInCount(new BigInteger(1, byteInCount)); - meterStatsBuilder.setDurationSec(input.readUnsignedInt()); - meterStatsBuilder.setDurationNsec(input.readUnsignedInt()); + meterStatsBuilder.setFlowCount(readUint32(input)); + meterStatsBuilder.setPacketInCount(readUint64(input)); + meterStatsBuilder.setByteInCount(readUint64(input)); + meterStatsBuilder.setDurationSec(readUint32(input)); + meterStatsBuilder.setDurationNsec(readUint32(input)); int actualLength = METER_BODY_LENGTH; List meterBandStatsList = new ArrayList<>(); while (actualLength < meterStatsBodyLength) { MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder(); - byte[] packetBandCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(packetBandCount); - meterBandStatsBuilder.setPacketBandCount(new BigInteger(1, packetBandCount)); - byte[] byteBandCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(byteBandCount); - meterBandStatsBuilder.setByteBandCount(new BigInteger(1, byteBandCount)); + meterBandStatsBuilder.setPacketBandCount(readUint64(input)); + meterBandStatsBuilder.setByteBandCount(readUint64(input)); meterBandStatsList.add(meterBandStatsBuilder.build()); actualLength += METER_BAND_STATS_LENGTH; } @@ -651,7 +594,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer bandsList = new ArrayList<>(); while (actualLength < meterConfigBodyLength) { @@ -664,8 +607,8 @@ public class MultipartReplyMessageFactory implements OFDeserializer portsList = new ArrayList<>(); while (input.readableBytes() > 0) { PortsBuilder portsBuilder = new PortsBuilder(); - portsBuilder.setPortNo(input.readUnsignedInt()); + portsBuilder.setPortNo(readUint32(input)); input.skipBytes(PADDING_IN_PORT_DESC_HEADER_01); portsBuilder.setHwAddr(ByteBufUtils.readIetfMacAddress(input)); input.skipBytes(PADDING_IN_PORT_DESC_HEADER_02); @@ -740,8 +683,8 @@ public class MultipartReplyMessageFactory implements OFDeserializer bucketsList = new ArrayList<>(); while (actualLength < bodyLength) { BucketsListBuilder bucketsBuilder = new BucketsListBuilder(); final int bucketsLength = input.readUnsignedShort(); - bucketsBuilder.setWeight(input.readUnsignedShort()); - bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt())); - bucketsBuilder.setWatchGroup(input.readUnsignedInt()); + bucketsBuilder.setWeight(readUint16(input)); + bucketsBuilder.setWatchPort(new PortNumber(readUint32(input))); + bucketsBuilder.setWatchGroup(readUint32(input)); input.skipBytes(PADDING_IN_BUCKETS_HEADER); CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF13_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF13_VERSION_ID, diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java index 372c4fb0c0..d8fef1feac 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartRequestInputMessageFactory.java @@ -7,9 +7,12 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint64; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -123,7 +126,7 @@ public class MultipartRequestInputMessageFactory MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); + builder.setXid(readUint32(rawMessage)); int type = rawMessage.readUnsignedShort(); builder.setType(getMultipartType(type)); builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort())); @@ -199,17 +202,13 @@ public class MultipartRequestInputMessageFactory while (input.readableBytes() > 0) { TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder(); final int length = input.readUnsignedShort(); - featuresBuilder.setTableId(input.readUnsignedByte()); + featuresBuilder.setTableId(readUint8(input)); input.skipBytes(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES); featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH)); - byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadataMatch); - featuresBuilder.setMetadataMatch(new BigInteger(1, metadataMatch)); - byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(metadataWrite); - featuresBuilder.setMetadataWrite(new BigInteger(1, metadataWrite)); + featuresBuilder.setMetadataMatch(readUint64(input)); + featuresBuilder.setMetadataWrite(readUint64(input)); featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt())); - featuresBuilder.setMaxEntries(input.readUnsignedInt()); + featuresBuilder.setMaxEntries(readUint32(input)); featuresBuilder.setTableFeatureProperties( createTableFeaturesProperties(input, length - MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH)); features.add(featuresBuilder.build()); @@ -244,7 +243,7 @@ public class MultipartRequestInputMessageFactory List ids = new ArrayList<>(); while (propertyLength > 0) { NextTableIdsBuilder nextTableIdsBuilder = new NextTableIdsBuilder(); - nextTableIdsBuilder.setTableId(input.readUnsignedByte()); + nextTableIdsBuilder.setTableId(readUint8(input)); ids.add(nextTableIdsBuilder.build()); propertyLength--; } @@ -303,17 +302,13 @@ public class MultipartRequestInputMessageFactory private MultipartRequestFlowCase setFlow(ByteBuf input) { final MultipartRequestFlowCaseBuilder caseBuilder = new MultipartRequestFlowCaseBuilder(); MultipartRequestFlowBuilder flowBuilder = new MultipartRequestFlowBuilder(); - flowBuilder.setTableId(input.readUnsignedByte()); + flowBuilder.setTableId(readUint8(input)); input.skipBytes(FLOW_PADDING_1); - flowBuilder.setOutPort(input.readUnsignedInt()); - flowBuilder.setOutGroup(input.readUnsignedInt()); + flowBuilder.setOutPort(readUint32(input)); + flowBuilder.setOutGroup(readUint32(input)); input.skipBytes(FLOW_PADDING_2); - byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(cookie); - flowBuilder.setCookie(new BigInteger(1, cookie)); - final byte[] cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(cookieMask); - flowBuilder.setCookieMask(new BigInteger(1, cookieMask)); + flowBuilder.setCookie(readUint64(input)); + flowBuilder.setCookieMask(readUint64(input)); OFDeserializer matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); flowBuilder.setMatch(matchDeserializer.deserialize(input)); @@ -324,17 +319,13 @@ public class MultipartRequestInputMessageFactory private MultipartRequestAggregateCase setAggregate(ByteBuf input) { final MultipartRequestAggregateCaseBuilder caseBuilder = new MultipartRequestAggregateCaseBuilder(); MultipartRequestAggregateBuilder aggregateBuilder = new MultipartRequestAggregateBuilder(); - aggregateBuilder.setTableId(input.readUnsignedByte()); + aggregateBuilder.setTableId(readUint8(input)); input.skipBytes(AGGREGATE_PADDING_1); - aggregateBuilder.setOutPort(input.readUnsignedInt()); - aggregateBuilder.setOutGroup(input.readUnsignedInt()); + aggregateBuilder.setOutPort(readUint32(input)); + aggregateBuilder.setOutGroup(readUint32(input)); input.skipBytes(AGGREGATE_PADDING_2); - byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(cookie); - aggregateBuilder.setCookie(new BigInteger(1, cookie)); - final byte[] cookieMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(cookieMask); - aggregateBuilder.setCookieMask(new BigInteger(1, cookieMask)); + aggregateBuilder.setCookie(readUint64(input)); + aggregateBuilder.setCookieMask(readUint64(input)); OFDeserializer matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class)); aggregateBuilder.setMatch(matchDeserializer.deserialize(input)); @@ -353,7 +344,7 @@ public class MultipartRequestInputMessageFactory private static MultipartRequestPortStatsCase setPortStats(ByteBuf input) { MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); - portBuilder.setPortNo(input.readUnsignedInt()); + portBuilder.setPortNo(readUint32(input)); caseBuilder.setMultipartRequestPortStats(portBuilder.build()); return caseBuilder.build(); } @@ -361,8 +352,8 @@ public class MultipartRequestInputMessageFactory private static MultipartRequestQueueCase setQueue(ByteBuf input) { MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); - queueBuilder.setPortNo(input.readUnsignedInt()); - queueBuilder.setQueueId(input.readUnsignedInt()); + queueBuilder.setPortNo(readUint32(input)); + queueBuilder.setQueueId(readUint32(input)); caseBuilder.setMultipartRequestQueue(queueBuilder.build()); return caseBuilder.build(); } @@ -370,7 +361,7 @@ public class MultipartRequestInputMessageFactory private static MultipartRequestGroupCase setGroup(ByteBuf input) { MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder(); MultipartRequestGroupBuilder groupBuilder = new MultipartRequestGroupBuilder(); - groupBuilder.setGroupId(new GroupId(input.readUnsignedInt())); + groupBuilder.setGroupId(new GroupId(readUint32(input))); caseBuilder.setMultipartRequestGroup(groupBuilder.build()); return caseBuilder.build(); } @@ -394,7 +385,7 @@ public class MultipartRequestInputMessageFactory private static MultipartRequestMeterCase setMeter(ByteBuf input) { MultipartRequestMeterCaseBuilder caseBuilder = new MultipartRequestMeterCaseBuilder(); MultipartRequestMeterBuilder meterBuilder = new MultipartRequestMeterBuilder(); - meterBuilder.setMeterId(new MeterId(input.readUnsignedInt())); + meterBuilder.setMeterId(new MeterId(readUint32(input))); caseBuilder.setMultipartRequestMeter(meterBuilder.build()); return caseBuilder.build(); } @@ -402,7 +393,7 @@ public class MultipartRequestInputMessageFactory private static MultipartRequestMeterConfigCase setMeterConfig(ByteBuf input) { MultipartRequestMeterConfigCaseBuilder caseBuilder = new MultipartRequestMeterConfigCaseBuilder(); MultipartRequestMeterConfigBuilder meterBuilder = new MultipartRequestMeterConfigBuilder(); - meterBuilder.setMeterId(new MeterId(input.readUnsignedInt())); + meterBuilder.setMeterId(new MeterId(readUint32(input))); caseBuilder.setMultipartRequestMeterConfig(meterBuilder.build()); return caseBuilder.build(); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java index b9cd3b3dbc..7b32fb4dd4 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10ErrorMessageFactory.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -35,7 +36,7 @@ public class OF10ErrorMessageFactory implements OFDeserializer { public ErrorMessage deserialize(ByteBuf rawMessage) { ErrorMessageBuilder builder = new ErrorMessageBuilder(); builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); + builder.setXid(readUint32(rawMessage)); int type = rawMessage.readUnsignedShort(); ErrorTypeV10 errorType = ErrorTypeV10.forValue(type); decodeType(builder, errorType, type); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java index 49089f6240..bfcefa9f7d 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10FeaturesReplyMessageFactory.java @@ -5,11 +5,14 @@ * terms of the Eclipse Public License v1.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.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint64; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; @@ -36,12 +39,10 @@ public class OF10FeaturesReplyMessageFactory implements OFDeserializer matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class)); builder.setMatchV10(matchDeserializer.deserialize(rawMessage)); - byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(cookie); - builder.setCookie(new BigInteger(1, cookie)); + builder.setCookie(readUint64(rawMessage)); builder.setCommand(FlowModCommand.forValue(rawMessage.readUnsignedShort())); - builder.setIdleTimeout(rawMessage.readUnsignedShort()); - builder.setHardTimeout(rawMessage.readUnsignedShort()); - builder.setPriority(rawMessage.readUnsignedShort()); - builder.setBufferId(rawMessage.readUnsignedInt()); - builder.setOutPort(new PortNumber((long) rawMessage.readUnsignedShort())); + builder.setIdleTimeout(readUint16(rawMessage)); + builder.setHardTimeout(readUint16(rawMessage)); + builder.setPriority(readUint16(rawMessage)); + builder.setBufferId(readUint32(rawMessage)); + builder.setOutPort(new PortNumber(readUint16(rawMessage).toUint32())); builder.setFlagsV10(createFlowModFlagsFromBitmap(rawMessage.readUnsignedShort())); CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); @@ -78,5 +79,4 @@ public class OF10FlowModInputMessageFactory implements OFDeserializer matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class)); builder.setMatchV10(matchDeserializer.deserialize(rawMessage)); - byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(cookie); - builder.setCookie(new BigInteger(1, cookie)); - builder.setPriority(rawMessage.readUnsignedShort()); + builder.setCookie(readUint64(rawMessage)); + builder.setPriority(readUint16(rawMessage)); builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte())); rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE); - builder.setDurationSec(rawMessage.readUnsignedInt()); - builder.setDurationNsec(rawMessage.readUnsignedInt()); - builder.setIdleTimeout(rawMessage.readUnsignedShort()); + builder.setDurationSec(readUint32(rawMessage)); + builder.setDurationNsec(readUint32(rawMessage)); + builder.setIdleTimeout(readUint16(rawMessage)); rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE_2); - byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(packetCount); - builder.setPacketCount(new BigInteger(1, packetCount)); - byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(byteCount); - builder.setByteCount(new BigInteger(1, byteCount)); + builder.setPacketCount(readUint64(rawMessage)); + builder.setByteCount(readUint64(rawMessage)); return builder.build(); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java index 30d739b896..178a238324 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10GetQueueConfigInputMessageFactory.java @@ -7,6 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -25,8 +28,8 @@ public class OF10GetQueueConfigInputMessageFactory implements OFDeserializer { public HelloMessage deserialize(ByteBuf rawMessage) { HelloMessageBuilder builder = new HelloMessageBuilder(); builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); + builder.setXid(readUint32(rawMessage)); if (rawMessage.readableBytes() > 0) { rawMessage.skipBytes(rawMessage.readableBytes()); } return builder.build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java index f1e8bbb5b4..103f9179fc 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10PacketInMessageFactory.java @@ -5,9 +5,11 @@ * terms of the Eclipse Public License v1.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.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -28,10 +30,10 @@ public class OF10PacketInMessageFactory implements OFDeserializer, DeserializerRegistryInjector { - private DeserializerRegistry registry; @Override @@ -39,9 +41,9 @@ public class OF10PacketOutInputMessageFactory implements OFDeserializer actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, actions_len, @@ -54,5 +56,4 @@ public class OF10PacketOutInputMessageFactory implements OFDeserializer queuesList = new ArrayList<>(); while (input.readableBytes() > 0) { QueuesBuilder queueBuilder = new QueuesBuilder(); - queueBuilder.setQueueId(new QueueId(input.readUnsignedInt())); + queueBuilder.setQueueId(new QueueId(readUint32(input))); int length = input.readUnsignedShort(); input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER); queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_HEADER_LENGTH)); @@ -72,7 +74,7 @@ public class OF10QueueGetConfigReplyMessageFactory implements OFDeserializer 0) { FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder(); final int length = input.readUnsignedShort(); - flowStatsBuilder.setTableId(input.readUnsignedByte()); + flowStatsBuilder.setTableId(readUint8(input)); input.skipBytes(PADDING_IN_FLOW_STATS_HEADER); OFDeserializer matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class)); flowStatsBuilder.setMatchV10(matchDeserializer.deserialize(input)); - flowStatsBuilder.setDurationSec(input.readUnsignedInt()); - flowStatsBuilder.setDurationNsec(input.readUnsignedInt()); - flowStatsBuilder.setPriority(input.readUnsignedShort()); - flowStatsBuilder.setIdleTimeout(input.readUnsignedShort()); - flowStatsBuilder.setHardTimeout(input.readUnsignedShort()); + flowStatsBuilder.setDurationSec(readUint32(input)); + flowStatsBuilder.setDurationNsec(readUint32(input)); + flowStatsBuilder.setPriority(readUint16(input)); + flowStatsBuilder.setIdleTimeout(readUint16(input)); + flowStatsBuilder.setHardTimeout(readUint16(input)); input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02); - byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(cookie); - flowStatsBuilder.setCookie(new BigInteger(1, cookie)); - byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(packetCount); - flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount)); - byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(byteCount); - flowStatsBuilder.setByteCount(new BigInteger(1, byteCount)); + flowStatsBuilder.setCookie(readUint64(input)); + flowStatsBuilder.setPacketCount(readUint64(input)); + flowStatsBuilder.setByteCount(readUint64(input)); CodeKeyMaker keyMaker = CodeKeyMakerFactory.createActionsKeyMaker(EncodeConstants.OF10_VERSION_ID); List actions = ListDeserializer.deserializeList(EncodeConstants.OF10_VERSION_ID, length - LENGTH_OF_FLOW_STATS, input, keyMaker, registry); @@ -192,13 +189,9 @@ public class OF10StatsReplyMessageFactory implements OFDeserializer= TABLE_STATS_LENGTH" with "> 0" after fix in OVS switch while (input.readableBytes() >= TABLE_STATS_LENGTH) { TableStatsBuilder tableStatsBuilder = new TableStatsBuilder(); - tableStatsBuilder.setTableId(input.readUnsignedByte()); + tableStatsBuilder.setTableId(readUint8(input)); input.skipBytes(PADDING_IN_TABLE_HEADER); tableStatsBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH)); long wildcards = input.readUnsignedInt(); tableStatsBuilder.setWildcards(OF10MatchDeserializer.createWildcards(wildcards)); tableStatsBuilder.setNwSrcMask(OF10MatchDeserializer.decodeNwSrcMask(wildcards)); tableStatsBuilder.setNwDstMask(OF10MatchDeserializer.decodeNwDstMask(wildcards)); - tableStatsBuilder.setMaxEntries(input.readUnsignedInt()); - tableStatsBuilder.setActiveCount(input.readUnsignedInt()); - byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(lookupCount); - tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount)); - byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(matchedCount); - tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount)); + tableStatsBuilder.setMaxEntries(readUint32(input)); + tableStatsBuilder.setActiveCount(readUint32(input)); + tableStatsBuilder.setLookupCount(readUint64(input)); + tableStatsBuilder.setMatchedCount(readUint64(input)); tableStatsList.add(tableStatsBuilder.build()); } input.skipBytes(input.readableBytes()); @@ -240,44 +229,20 @@ public class OF10StatsReplyMessageFactory implements OFDeserializer portStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { PortStatsBuilder portStatsBuilder = new PortStatsBuilder(); - portStatsBuilder.setPortNo((long) input.readUnsignedShort()); + portStatsBuilder.setPortNo(readUint16(input).toUint32()); input.skipBytes(PADDING_IN_PORT_STATS_HEADER); - byte[] rxPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxPackets); - portStatsBuilder.setRxPackets(new BigInteger(1, rxPackets)); - byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txPackets); - portStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); - byte[] rxBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxBytes); - portStatsBuilder.setRxBytes(new BigInteger(1, rxBytes)); - byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txBytes); - portStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); - byte[] rxDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxDropped); - portStatsBuilder.setRxDropped(new BigInteger(1, rxDropped)); - byte[] txDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txDropped); - portStatsBuilder.setTxDropped(new BigInteger(1, txDropped)); - byte[] rxErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxErrors); - portStatsBuilder.setRxErrors(new BigInteger(1, rxErrors)); - byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txErrors); - portStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); - byte[] rxFrameErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxFrameErr); - portStatsBuilder.setRxFrameErr(new BigInteger(1, rxFrameErr)); - byte[] rxOverErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxOverErr); - portStatsBuilder.setRxOverErr(new BigInteger(1, rxOverErr)); - byte[] rxCrcErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(rxCrcErr); - portStatsBuilder.setRxCrcErr(new BigInteger(1, rxCrcErr)); - byte[] collisions = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(collisions); - portStatsBuilder.setCollisions(new BigInteger(1, collisions)); + portStatsBuilder.setRxPackets(readUint64(input)); + portStatsBuilder.setTxPackets(readUint64(input)); + portStatsBuilder.setRxBytes(readUint64(input)); + portStatsBuilder.setTxBytes(readUint64(input)); + portStatsBuilder.setRxDropped(readUint64(input)); + portStatsBuilder.setTxDropped(readUint64(input)); + portStatsBuilder.setRxErrors(readUint64(input)); + portStatsBuilder.setTxErrors(readUint64(input)); + portStatsBuilder.setRxFrameErr(readUint64(input)); + portStatsBuilder.setRxOverErr(readUint64(input)); + portStatsBuilder.setRxCrcErr(readUint64(input)); + portStatsBuilder.setCollisions(readUint64(input)); portStatsList.add(portStatsBuilder.build()); } builder.setPortStats(portStatsList); @@ -291,18 +256,12 @@ public class OF10StatsReplyMessageFactory implements OFDeserializer queueStatsList = new ArrayList<>(); while (input.readableBytes() > 0) { QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder(); - queueStatsBuilder.setPortNo((long) input.readUnsignedShort()); + queueStatsBuilder.setPortNo(readUint16(input).toUint32()); input.skipBytes(PADDING_IN_QUEUE_HEADER); - queueStatsBuilder.setQueueId(input.readUnsignedInt()); - byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txBytes); - queueStatsBuilder.setTxBytes(new BigInteger(1, txBytes)); - byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txPackets); - queueStatsBuilder.setTxPackets(new BigInteger(1, txPackets)); - byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - input.readBytes(txErrors); - queueStatsBuilder.setTxErrors(new BigInteger(1, txErrors)); + queueStatsBuilder.setQueueId(readUint32(input)); + queueStatsBuilder.setTxBytes(readUint64(input)); + queueStatsBuilder.setTxPackets(readUint64(input)); + queueStatsBuilder.setTxErrors(readUint64(input)); queueStatsList.add(queueStatsBuilder.build()); } builder.setQueueStats(queueStatsList); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java index f59e542371..9fa7a55b77 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/OF10StatsRequestInputFactory.java @@ -7,6 +7,10 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; import java.util.Objects; @@ -61,7 +65,7 @@ public class OF10StatsRequestInputFactory MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); builder.setVersion((short) EncodeConstants.OF10_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); + builder.setXid(readUint32(rawMessage)); int type = rawMessage.readUnsignedShort(); builder.setType(getMultipartType(type)); builder.setFlags(getMultipartRequestFlags(rawMessage.readUnsignedShort())); @@ -103,9 +107,9 @@ public class OF10StatsRequestInputFactory private static MultipartRequestQueueCase setQueue(ByteBuf input) { final MultipartRequestQueueCaseBuilder caseBuilder = new MultipartRequestQueueCaseBuilder(); MultipartRequestQueueBuilder queueBuilder = new MultipartRequestQueueBuilder(); - queueBuilder.setPortNo((long) input.readUnsignedShort()); + queueBuilder.setPortNo(readUint16(input).toUint32()); input.skipBytes(2); - queueBuilder.setQueueId(input.readUnsignedInt()); + queueBuilder.setQueueId(readUint32(input)); caseBuilder.setMultipartRequestQueue(queueBuilder.build()); return caseBuilder.build(); } @@ -113,7 +117,7 @@ public class OF10StatsRequestInputFactory private static MultipartRequestPortStatsCase setPortStats(ByteBuf input) { MultipartRequestPortStatsCaseBuilder caseBuilder = new MultipartRequestPortStatsCaseBuilder(); MultipartRequestPortStatsBuilder portBuilder = new MultipartRequestPortStatsBuilder(); - portBuilder.setPortNo((long) input.readUnsignedShort()); + portBuilder.setPortNo(readUint16(input).toUint32()); caseBuilder.setMultipartRequestPortStats(portBuilder.build()); return caseBuilder.build(); } @@ -132,9 +136,9 @@ public class OF10StatsRequestInputFactory OFDeserializer matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class)); aggregateBuilder.setMatchV10(matchDeserializer.deserialize(input)); - aggregateBuilder.setTableId(input.readUnsignedByte()); + aggregateBuilder.setTableId(readUint8(input)); input.skipBytes(AGGREGATE_PADDING_1); - aggregateBuilder.setOutPort((long) input.readUnsignedShort()); + aggregateBuilder.setOutPort(readUint16(input).toUint32()); caseBuilder.setMultipartRequestAggregate(aggregateBuilder.build()); return caseBuilder.build(); } @@ -145,9 +149,9 @@ public class OF10StatsRequestInputFactory OFDeserializer matchDeserializer = registry.getDeserializer( new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class)); flowBuilder.setMatchV10(matchDeserializer.deserialize(input)); - flowBuilder.setTableId(input.readUnsignedByte()); + flowBuilder.setTableId(readUint8(input)); input.skipBytes(FLOW_PADDING_1); - flowBuilder.setOutPort((long) input.readUnsignedShort()); + flowBuilder.setOutPort(readUint16(input).toUint32()); caseBuilder.setMultipartRequestFlow(flowBuilder.build()); return caseBuilder.build(); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java index b9e7fae677..cbb353c8ae 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactory.java @@ -5,12 +5,15 @@ * terms of the Eclipse Public License v1.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.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint64; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import java.util.Objects; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector; @@ -44,14 +47,12 @@ public class PacketInMessageFactory implements OFDeserializer, PacketInMessageBuilder builder = new PacketInMessageBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - builder.setBufferId(rawMessage.readUnsignedInt()); - builder.setTotalLen(rawMessage.readUnsignedShort()); + builder.setXid(readUint32(rawMessage)); + builder.setBufferId(readUint32(rawMessage)); + builder.setTotalLen(readUint16(rawMessage)); builder.setReason(PacketInReason.forValue(rawMessage.readUnsignedByte())); - builder.setTableId(new TableId((long)rawMessage.readUnsignedByte())); - byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - rawMessage.readBytes(cookie); - builder.setCookie(new BigInteger(1, cookie)); + builder.setTableId(new TableId(readUint8(rawMessage).toUint32())); + builder.setCookie(readUint64(rawMessage)); OFDeserializer matchDeserializer = registry.getDeserializer(MATCH_KEY); builder.setMatch(matchDeserializer.deserialize(rawMessage)); rawMessage.skipBytes(PADDING_IN_PACKET_IN_HEADER); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java index 44449d65c0..b43891a3f4 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketOutInputMessageFactory.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; @@ -30,9 +32,9 @@ public class PacketOutInputMessageFactory implements OFDeserializer public PortModInput deserialize(final ByteBuf rawMessage) { PortModInputBuilder builder = new PortModInputBuilder(); builder.setVersion((short) EncodeConstants.OF13_VERSION_ID); - builder.setXid(rawMessage.readUnsignedInt()); - builder.setPortNo(new PortNumber(rawMessage.readUnsignedInt())); + builder.setXid(readUint32(rawMessage)); + builder.setPortNo(new PortNumber(readUint32(rawMessage))); rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_1); builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage)); rawMessage.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_2); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java index 6eb2e23257..0deb920b05 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PortStatusMessageFactory.java @@ -8,6 +8,8 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -35,10 +37,10 @@ public class PortStatusMessageFactory implements OFDeserializer queuesList = new ArrayList<>(); while (input.readableBytes() > 0) { QueuesBuilder queueBuilder = new QueuesBuilder(); - queueBuilder.setQueueId(new QueueId(input.readUnsignedInt())); - queueBuilder.setPort(new PortNumber(input.readUnsignedInt())); + queueBuilder.setQueueId(new QueueId(readUint32(input))); + queueBuilder.setPort(new PortNumber(readUint32(input))); int length = input.readUnsignedShort(); input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER); queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_LENGTH)); @@ -86,7 +88,7 @@ public class QueueGetConfigReplyMessageFactory implements OFDeserializer public ExperimenterMessage deserialize(ByteBuf message) { Objects.requireNonNull(deserializerRegistry); - final long xid = message.readUnsignedInt(); + final Uint32 xid = readUint32(message); final long expId = message.readUnsignedInt(); OFDeserializer deserializer = deserializerRegistry.getDeserializer( ExperimenterDeserializerKeyFactory.createVendorMessageDeserializerKey( diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java index d58f1a5829..96038dd744 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/instruction/GoToTableInstructionDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; @@ -28,22 +29,18 @@ public class GoToTableInstructionDeserializer implements OFDeserializer @Override public Instruction deserialize(ByteBuf input) { - final InstructionBuilder builder = new InstructionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - MeterCaseBuilder caseBuilder = new MeterCaseBuilder(); - MeterBuilder instructionBuilder = new MeterBuilder(); - instructionBuilder.setMeterId(input.readUnsignedInt()); - caseBuilder.setMeter(instructionBuilder.build()); - builder.setInstructionChoice(caseBuilder.build()); - return builder.build(); + return new InstructionBuilder() + .setInstructionChoice(new MeterCaseBuilder() + .setMeter(new MeterBuilder().setMeterId(readUint32(input)).build()) + .build()) + .build(); } @Override public Instruction deserializeHeader(ByteBuf input) { - InstructionBuilder builder = new InstructionBuilder(); input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES); - builder.setInstructionChoice(new MeterCaseBuilder().build()); - return builder.build(); + return new InstructionBuilder().setInstructionChoice(new MeterCaseBuilder().build()).build(); } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java index 2db74cb9f2..9a0633dec9 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmArpOpDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.ArpOp; @@ -34,11 +36,9 @@ public class OxmArpOpDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addArpOpValue(ByteBuf input, MatchEntryBuilder builder) { - ArpOpCaseBuilder caseBuilder = new ArpOpCaseBuilder(); - ArpOpBuilder opBuilder = new ArpOpBuilder(); - opBuilder.setOpCode(input.readUnsignedShort()); - caseBuilder.setArpOp(opBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new ArpOpCaseBuilder() + .setArpOp(new ArpOpBuilder().setOpCode(readUint16(input)).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java index 19bfdb599b..9f0605abc5 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmEthTypeDeserializer.java @@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.EthTypeCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.eth.type._case.EthTypeBuilder; +import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils; /** * Translates OxmEthType messages. @@ -35,11 +36,9 @@ public class OxmEthTypeDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addEthTypeValue(ByteBuf input, MatchEntryBuilder builder) { - EthTypeCaseBuilder caseBuilder = new EthTypeCaseBuilder(); - EthTypeBuilder ethBuilder = new EthTypeBuilder(); - ethBuilder.setEthType(new EtherType(input.readUnsignedShort())); - caseBuilder.setEthType(ethBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new EthTypeCaseBuilder() + .setEthType(new EthTypeBuilder().setEthType(new EtherType(ByteBufUtils.readUint16(input))).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java index 4f6ec5a010..aee94b2aff 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4CodeDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Code; @@ -14,7 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4CodeCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.code._case.Icmpv4CodeBuilder; @@ -28,17 +29,11 @@ public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv4CodeValue(input, builder); - return builder.build(); - } - - private static void addIcmpv4CodeValue(ByteBuf input, MatchEntryBuilder builder) { - Icmpv4CodeCaseBuilder caseBuilder = new Icmpv4CodeCaseBuilder(); - Icmpv4CodeBuilder icmpBuilder = new Icmpv4CodeBuilder(); - icmpBuilder.setIcmpv4Code(input.readUnsignedByte()); - caseBuilder.setIcmpv4Code(icmpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new Icmpv4CodeCaseBuilder() + .setIcmpv4Code(new Icmpv4CodeBuilder().setIcmpv4Code(readUint8(input)).build()) + .build()) + .build(); } @Override @@ -50,5 +45,4 @@ public class OxmIcmpv4CodeDeserializer extends AbstractOxmMatchEntryDeserializer protected Class getOxmClass() { return OpenflowBasicClass.class; } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java index 8341b4bdf8..7b110387b2 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv4TypeDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv4Type; @@ -14,7 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv4TypeCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv4.type._case.Icmpv4TypeBuilder; @@ -28,17 +29,11 @@ public class OxmIcmpv4TypeDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv4TypeValue(input, builder); - return builder.build(); - } - - private static void addIcmpv4TypeValue(ByteBuf input, MatchEntryBuilder builder) { - Icmpv4TypeCaseBuilder caseBuilder = new Icmpv4TypeCaseBuilder(); - Icmpv4TypeBuilder icmpBuilder = new Icmpv4TypeBuilder(); - icmpBuilder.setIcmpv4Type(input.readUnsignedByte()); - caseBuilder.setIcmpv4Type(icmpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new Icmpv4TypeCaseBuilder() + .setIcmpv4Type(new Icmpv4TypeBuilder().setIcmpv4Type(readUint8(input)).build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java index 5ce6b1883f..4e5284b023 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6CodeDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Code; @@ -14,7 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6CodeCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.code._case.Icmpv6CodeBuilder; @@ -28,17 +29,11 @@ public class OxmIcmpv6CodeDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv6CodeValue(input, builder); - return builder.build(); - } - - private static void addIcmpv6CodeValue(ByteBuf input, MatchEntryBuilder builder) { - Icmpv6CodeCaseBuilder caseBuilder = new Icmpv6CodeCaseBuilder(); - Icmpv6CodeBuilder icmpBuilder = new Icmpv6CodeBuilder(); - icmpBuilder.setIcmpv6Code(input.readUnsignedByte()); - caseBuilder.setIcmpv6Code(icmpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new Icmpv6CodeCaseBuilder() + .setIcmpv6Code(new Icmpv6CodeBuilder().setIcmpv6Code(readUint8(input)).build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java index 6211f24cdb..c225dfc0cf 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIcmpv6TypeDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Icmpv6Type; @@ -14,7 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OpenflowBasicClass; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.Icmpv6TypeCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.icmpv6.type._case.Icmpv6TypeBuilder; @@ -28,17 +29,11 @@ public class OxmIcmpv6TypeDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addIcmpv6TypeValue(input, builder); - return builder.build(); - } - - private static void addIcmpv6TypeValue(ByteBuf input, MatchEntryBuilder builder) { - Icmpv6TypeCaseBuilder caseBuilder = new Icmpv6TypeCaseBuilder(); - Icmpv6TypeBuilder icmpBuilder = new Icmpv6TypeBuilder(); - icmpBuilder.setIcmpv6Type(input.readUnsignedByte()); - caseBuilder.setIcmpv6Type(icmpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new Icmpv6TypeCaseBuilder() + .setIcmpv6Type(new Icmpv6TypeBuilder().setIcmpv6Type(readUint8(input)).build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java index 766788c22a..6fc4f4dcff 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPhyPortDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; @@ -35,11 +37,9 @@ public class OxmInPhyPortDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addInPhyPortValue(ByteBuf input, MatchEntryBuilder builder) { - InPhyPortCaseBuilder caseBuilder = new InPhyPortCaseBuilder(); - InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder(); - inPhyPortBuilder.setPortNumber(new PortNumber(input.readUnsignedInt())); - caseBuilder.setInPhyPort(inPhyPortBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new InPhyPortCaseBuilder() + .setInPhyPort(new InPhyPortBuilder().setPortNumber(new PortNumber(readUint32(input))).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java index 244c9edf8d..ec25b6e22b 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmInPortDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber; @@ -35,11 +37,9 @@ public class OxmInPortDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addInPortValue(ByteBuf input, MatchEntryBuilder builder) { - InPortCaseBuilder caseBuilder = new InPortCaseBuilder(); - InPortBuilder inPortBuilder = new InPortBuilder(); - inPortBuilder.setPortNumber(new PortNumber(input.readUnsignedInt())); - caseBuilder.setInPort(inPortBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new InPortCaseBuilder() + .setInPort(new InPortBuilder().setPortNumber(new PortNumber(readUint32(input))).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java index 7e79176a59..3d21613168 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpDscpDeserializer.java @@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.IpDscpCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.ip.dscp._case.IpDscpBuilder; +import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils; /** * Translates OxmIpDscp messages. @@ -35,11 +36,9 @@ public class OxmIpDscpDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addIpDscpValue(ByteBuf input, MatchEntryBuilder builder) { - IpDscpCaseBuilder caseBuilder = new IpDscpCaseBuilder(); - IpDscpBuilder dscpBuilder = new IpDscpBuilder(); - dscpBuilder.setDscp(new Dscp(input.readUnsignedByte())); - caseBuilder.setIpDscp(dscpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new IpDscpCaseBuilder() + .setIpDscp(new IpDscpBuilder().setDscp(new Dscp(ByteBufUtils.readUint8(input))).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java index 7971cc4117..4d38ebe297 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpEcnDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpEcn; @@ -34,11 +36,9 @@ public class OxmIpEcnDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addIpEcnValue(ByteBuf input, MatchEntryBuilder builder) { - IpEcnCaseBuilder caseBuilder = new IpEcnCaseBuilder(); - IpEcnBuilder ecnBuilder = new IpEcnBuilder(); - ecnBuilder.setEcn(input.readUnsignedByte()); - caseBuilder.setIpEcn(ecnBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new IpEcnCaseBuilder() + .setIpEcn(new IpEcnBuilder().setEcn(readUint8(input)).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java index 7149f7f0d6..662073d8e1 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpProtoDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.IpProto; @@ -34,11 +36,9 @@ public class OxmIpProtoDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addIpProtoValue(ByteBuf input, MatchEntryBuilder builder) { - IpProtoCaseBuilder caseBuilder = new IpProtoCaseBuilder(); - IpProtoBuilder protoBuilder = new IpProtoBuilder(); - protoBuilder.setProtocolNumber(input.readUnsignedByte()); - caseBuilder.setIpProto(protoBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new IpProtoCaseBuilder() + .setIpProto(new IpProtoBuilder().setProtocolNumber(readUint8(input)).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java index aa58896169..b4e9719698 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmIpv6FlabelDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -38,7 +40,7 @@ public class OxmIpv6FlabelDeserializer extends AbstractOxmMatchEntryDeserializer private static void addIpv6FlabelValue(ByteBuf input, MatchEntryBuilder builder) { Ipv6FlabelCaseBuilder caseBuilder = new Ipv6FlabelCaseBuilder(); Ipv6FlabelBuilder labelBuilder = new Ipv6FlabelBuilder(); - labelBuilder.setIpv6Flabel(new Ipv6FlowLabel(input.readUnsignedInt())); + labelBuilder.setIpv6Flabel(new Ipv6FlowLabel(readUint32(input))); if (builder.isHasMask()) { labelBuilder.setMask(OxmDeserializerHelper.convertMask(input, EncodeConstants.SIZE_OF_INT_IN_BYTES)); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java index 30c52600fd..64fb826152 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsLabelDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; @@ -34,11 +36,9 @@ public class OxmMplsLabelDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addMplsLabelValue(ByteBuf input, MatchEntryBuilder builder) { - MplsLabelCaseBuilder caseBuilder = new MplsLabelCaseBuilder(); - MplsLabelBuilder labelBuilder = new MplsLabelBuilder(); - labelBuilder.setMplsLabel(input.readUnsignedInt()); - caseBuilder.setMplsLabel(labelBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new MplsLabelCaseBuilder() + .setMplsLabel(new MplsLabelBuilder().setMplsLabel(readUint32(input)).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java index 46f9db39f2..274ba9fb2d 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmMplsTcDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; @@ -34,11 +36,9 @@ public class OxmMplsTcDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addMplsTcValue(ByteBuf input, MatchEntryBuilder builder) { - MplsTcCaseBuilder caseBuilder = new MplsTcCaseBuilder(); - MplsTcBuilder tcBuilder = new MplsTcBuilder(); - tcBuilder.setTc(input.readUnsignedByte()); - caseBuilder.setMplsTc(tcBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new MplsTcCaseBuilder() + .setMplsTc(new MplsTcBuilder().setTc(readUint8(input)).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPacketTypeDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPacketTypeDeserializer.java index c0d30d4f4d..2480f0b0d3 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPacketTypeDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmPacketTypeDeserializer.java @@ -5,9 +5,10 @@ * terms of the Eclipse Public License v1.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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; @@ -35,7 +36,7 @@ public class OxmPacketTypeDeserializer extends AbstractOxmMatchEntryDeserializer final MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), message); PacketTypeCaseBuilder caseBuilder = new PacketTypeCaseBuilder(); PacketTypeBuilder packetTypeBuilder = new PacketTypeBuilder(); - packetTypeBuilder.setPacketType(message.readUnsignedInt()); + packetTypeBuilder.setPacketType(readUint32(message)); caseBuilder.setPacketType(packetTypeBuilder.build()); builder.setMatchEntryValue(caseBuilder.build()); return builder.build(); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java index 2b3e4c3830..29d4e53474 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpDstDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + 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.rev130715.PortNumber; @@ -35,11 +37,9 @@ public class OxmSctpDstDeserializer extends AbstractOxmMatchEntryDeserializer } private static void addSctpDstValue(ByteBuf input, MatchEntryBuilder builder) { - SctpDstCaseBuilder caseBuilder = new SctpDstCaseBuilder(); - SctpDstBuilder sctpBuilder = new SctpDstBuilder(); - sctpBuilder.setPort(new PortNumber(input.readUnsignedShort())); - caseBuilder.setSctpDst(sctpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + builder.setMatchEntryValue(new SctpDstCaseBuilder() + .setSctpDst(new SctpDstBuilder().setPort(new PortNumber(readUint16(input))).build()) + .build()); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java index 12b136b70b..1ccd766a00 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmSctpSrcDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + 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.rev130715.PortNumber; @@ -15,7 +17,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Open import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.SctpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.SctpSrcCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.sctp.src._case.SctpSrcBuilder; @@ -29,17 +30,11 @@ public class OxmSctpSrcDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addSctpSrcValue(input, builder); - return builder.build(); - } - - private static void addSctpSrcValue(ByteBuf input, MatchEntryBuilder builder) { - SctpSrcCaseBuilder caseBuilder = new SctpSrcCaseBuilder(); - SctpSrcBuilder sctpBuilder = new SctpSrcBuilder(); - sctpBuilder.setPort(new PortNumber(input.readUnsignedShort())); - caseBuilder.setSctpSrc(sctpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new SctpSrcCaseBuilder() + .setSctpSrc(new SctpSrcBuilder().setPort(new PortNumber(readUint16(input))).build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java index dd9e445a62..6da8da1e95 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpDstDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + 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.rev130715.PortNumber; @@ -15,7 +17,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Open import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpDstCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.dst._case.TcpDstBuilder; @@ -29,17 +30,11 @@ public class OxmTcpDstDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addTcpDstValue(input, builder); - return builder.build(); - } - - private static void addTcpDstValue(ByteBuf input, MatchEntryBuilder builder) { - TcpDstCaseBuilder caseBuilder = new TcpDstCaseBuilder(); - TcpDstBuilder tcpBuilder = new TcpDstBuilder(); - tcpBuilder.setPort(new PortNumber(input.readUnsignedShort())); - caseBuilder.setTcpDst(tcpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new TcpDstCaseBuilder() + .setTcpDst(new TcpDstBuilder().setPort(new PortNumber(readUint16(input))).build()) + .build()) + .build(); } @Override @@ -51,5 +46,4 @@ public class OxmTcpDstDeserializer extends AbstractOxmMatchEntryDeserializer protected Class getOxmClass() { return OpenflowBasicClass.class; } - } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java index ff07d366d2..f393e8f760 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmTcpSrcDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + 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.rev130715.PortNumber; @@ -15,7 +17,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Open import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.TcpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.TcpSrcCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.tcp.src._case.TcpSrcBuilder; @@ -29,17 +30,11 @@ public class OxmTcpSrcDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addTcpSrcValue(input, builder); - return builder.build(); - } - - private static void addTcpSrcValue(ByteBuf input, MatchEntryBuilder builder) { - TcpSrcCaseBuilder caseBuilder = new TcpSrcCaseBuilder(); - TcpSrcBuilder tcpBuilder = new TcpSrcBuilder(); - tcpBuilder.setPort(new PortNumber(input.readUnsignedShort())); - caseBuilder.setTcpSrc(tcpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new TcpSrcCaseBuilder() + .setTcpSrc(new TcpSrcBuilder().setPort(new PortNumber(readUint16(input))).build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java index edbbcfc9b1..e887594f85 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpDstDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + 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.rev130715.PortNumber; @@ -15,7 +17,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Open import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpDst; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpDstCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.dst._case.UdpDstBuilder; @@ -29,17 +30,11 @@ public class OxmUdpDstDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addUdpDstValue(input, builder); - return builder.build(); - } - - private static void addUdpDstValue(ByteBuf input, MatchEntryBuilder builder) { - UdpDstCaseBuilder caseBuilder = new UdpDstCaseBuilder(); - UdpDstBuilder udpBuilder = new UdpDstBuilder(); - udpBuilder.setPort(new PortNumber(input.readUnsignedShort())); - caseBuilder.setUdpDst(udpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new UdpDstCaseBuilder() + .setUdpDst(new UdpDstBuilder().setPort(new PortNumber(readUint16(input))).build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java index bbe970c7ad..e5e55128f1 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmUdpSrcDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + 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.rev130715.PortNumber; @@ -15,7 +17,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Open import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.UdpSrc; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.UdpSrcCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.udp.src._case.UdpSrcBuilder; @@ -29,17 +30,11 @@ public class OxmUdpSrcDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addUdpSrcValue(input, builder); - return builder.build(); - } - - private static void addUdpSrcValue(ByteBuf input, MatchEntryBuilder builder) { - UdpSrcCaseBuilder caseBuilder = new UdpSrcCaseBuilder(); - UdpSrcBuilder udpBuilder = new UdpSrcBuilder(); - udpBuilder.setPort(new PortNumber(input.readUnsignedShort())); - caseBuilder.setUdpSrc(udpBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new UdpSrcCaseBuilder() + .setUdpSrc(new UdpSrcBuilder().setPort(new PortNumber(readUint16(input))).build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java index 0bd079be94..6e9f4503f9 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanPcpDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.MatchField; @@ -14,7 +16,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Open import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmClassBase; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.VlanPcp; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry; -import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanPcpCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.pcp._case.VlanPcpBuilder; @@ -28,17 +29,11 @@ public class OxmVlanPcpDeserializer extends AbstractOxmMatchEntryDeserializer @Override public MatchEntry deserialize(ByteBuf input) { - MatchEntryBuilder builder = processHeader(getOxmClass(), getOxmField(), input); - addVlanPcpValue(input, builder); - return builder.build(); - } - - private static void addVlanPcpValue(ByteBuf input, MatchEntryBuilder builder) { - VlanPcpCaseBuilder caseBuilder = new VlanPcpCaseBuilder(); - VlanPcpBuilder vlanBuilder = new VlanPcpBuilder(); - vlanBuilder.setVlanPcp(input.readUnsignedByte()); - caseBuilder.setVlanPcp(vlanBuilder.build()); - builder.setMatchEntryValue(caseBuilder.build()); + return processHeader(getOxmClass(), getOxmField(), input) + .setMatchEntryValue(new VlanPcpCaseBuilder() + .setVlanPcp(new VlanPcpBuilder().setVlanPcp(readUint8(input)).build()) + .build()) + .build(); } @Override diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java index 43758f6d37..b617180c97 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/OxmVlanVidDeserializer.java @@ -18,6 +18,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.matc import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.VlanVidCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entry.value.grouping.match.entry.value.vlan.vid._case.VlanVidBuilder; +import org.opendaylight.yangtools.yang.common.Uint16; /** * Translates OxmVlanVid messages. @@ -39,7 +40,7 @@ public class OxmVlanVidDeserializer extends AbstractOxmMatchEntryDeserializer VlanVidBuilder vlanBuilder = new VlanVidBuilder(); int vidEntryValue = input.readUnsignedShort(); vlanBuilder.setCfiBit((vidEntryValue & 1 << 12) != 0); // cfi is 13-th bit - vlanBuilder.setVlanVid(vidEntryValue & (1 << 12) - 1); // value without 13-th bit + vlanBuilder.setVlanVid(Uint16.valueOf(vidEntryValue & (1 << 12) - 1)); // value without 13-th bit if (builder.isHasMask()) { vlanBuilder.setMask(OxmDeserializerHelper .convertMask(input, EncodeConstants.SIZE_OF_SHORT_IN_BYTES)); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/AbstractOxmExperimenterMatchEntryDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/AbstractOxmExperimenterMatchEntryDeserializer.java index e9535d8e4a..7bc71456e9 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/AbstractOxmExperimenterMatchEntryDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/AbstractOxmExperimenterMatchEntryDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.impl.deserialization.match.AbstractOxmMatchEntryDeserializer; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.oxm.container.match.entry.value.ExperimenterIdCaseBuilder; @@ -22,7 +24,7 @@ public abstract class AbstractOxmExperimenterMatchEntryDeserializer extends Abst protected ExperimenterIdCaseBuilder createExperimenterIdCase(MatchEntryBuilder entryBuilder, ByteBuf input) { ExperimenterIdCaseBuilder expCaseBuilder = new ExperimenterIdCaseBuilder(); ExperimenterBuilder expBuilder = new ExperimenterBuilder(); - expBuilder.setExperimenter(new ExperimenterId(input.readUnsignedInt())); + expBuilder.setExperimenter(new ExperimenterId(readUint32(input))); expCaseBuilder.setExperimenter(expBuilder.build()); return expCaseBuilder; } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/OnfOxmTcpFlagsDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/OnfOxmTcpFlagsDeserializer.java index 57c2c9d74b..4e1a85d842 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/OnfOxmTcpFlagsDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/match/ext/OnfOxmTcpFlagsDeserializer.java @@ -7,6 +7,8 @@ */ package org.opendaylight.openflowjava.protocol.impl.deserialization.match.ext; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; + import io.netty.buffer.ByteBuf; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; @@ -39,7 +41,7 @@ public class OnfOxmTcpFlagsDeserializer extends AbstractOxmExperimenterMatchEntr private static void addTcpFlagsAugmentation(ByteBuf input, ExperimenterIdCaseBuilder expCaseBuilder, boolean hasMask) { TcpFlagsBuilder flagsBuilder = new TcpFlagsBuilder(); - flagsBuilder.setFlags(input.readUnsignedShort()); + flagsBuilder.setFlags(readUint16(input)); if (hasMask) { byte[] mask = new byte[EncodeConstants.SIZE_OF_SHORT_IN_BYTES]; input.readBytes(mask); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java index 7de1ff7b8b..ed505ccee7 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/util/OF10MatchDeserializer.java @@ -5,9 +5,11 @@ * terms of the Eclipse Public License 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 static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer; @@ -40,21 +42,21 @@ public class OF10MatchDeserializer implements OFDeserializer { builder.setWildcards(createWildcards(wildcards)); builder.setNwSrcMask(decodeNwSrcMask(wildcards)); builder.setNwDstMask(decodeNwDstMask(wildcards)); - builder.setInPort(input.readUnsignedShort()); + builder.setInPort(readUint16(input)); builder.setDlSrc(ByteBufUtils.readIetfMacAddress(input)); builder.setDlDst(ByteBufUtils.readIetfMacAddress(input)); - builder.setDlVlan(input.readUnsignedShort()); - builder.setDlVlanPcp(input.readUnsignedByte()); + builder.setDlVlan(readUint16(input)); + builder.setDlVlanPcp(readUint8(input)); input.skipBytes(PADDING_IN_MATCH); - builder.setDlType(input.readUnsignedShort()); - builder.setNwTos(input.readUnsignedByte()); - builder.setNwProto(input.readUnsignedByte()); + builder.setDlType(readUint16(input)); + builder.setNwTos(readUint8(input)); + builder.setNwProto(readUint8(input)); input.skipBytes(PADDING_IN_MATCH_2); builder.setNwSrc(ByteBufUtils.readIetfIpv4Address(input)); builder.setNwDst(ByteBufUtils.readIetfIpv4Address(input)); - builder.setTpSrc(input.readUnsignedShort()); - builder.setTpDst(input.readUnsignedShort()); + builder.setTpSrc(readUint16(input)); + builder.setTpDst(readUint16(input)); return builder.build(); } diff --git a/openflowplugin-impl/pom.xml b/openflowplugin-impl/pom.xml index 5b9a5fc740..7d8ffa1c16 100644 --- a/openflowplugin-impl/pom.xml +++ b/openflowplugin-impl/pom.xml @@ -44,6 +44,10 @@ org.opendaylight.controller.model model-inventory + + org.opendaylight.yangtools + yang-common-netty + org.opendaylight.mdsal mdsal-binding-api diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializer.java index 6d9c372891..3fa354f0a3 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/messages/FlowMessageDeserializer.java @@ -5,9 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.openflowplugin.impl.protocol.deserialization.messages; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint16; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import com.google.common.base.Preconditions; import io.netty.buffer.ByteBuf; import java.math.BigInteger; @@ -51,17 +54,17 @@ public class FlowMessageDeserializer implements OFDeserializer, Des public FlowMessage deserialize(ByteBuf message) { final FlowMessageBuilder builder = new FlowMessageBuilder() .setVersion((short) EncodeConstants.OF13_VERSION_ID) - .setXid(message.readUnsignedInt()) + .setXid(readUint32(message)) .setCookie(new FlowCookie(BigInteger.valueOf(message.readLong()))) .setCookieMask(new FlowCookie(BigInteger.valueOf(message.readLong()))) - .setTableId(message.readUnsignedByte()) + .setTableId(readUint8(message)) .setCommand(FlowModCommand.forValue(message.readUnsignedByte())) - .setIdleTimeout(message.readUnsignedShort()) - .setHardTimeout(message.readUnsignedShort()) - .setPriority(message.readUnsignedShort()) - .setBufferId(message.readUnsignedInt()) + .setIdleTimeout(readUint16(message)) + .setHardTimeout(readUint16(message)) + .setPriority(readUint16(message)) + .setBufferId(readUint32(message)) .setOutPort(BigInteger.valueOf(message.readUnsignedInt())) - .setOutGroup(message.readUnsignedInt()) + .setOutGroup(readUint32(message)) .setFlags(createFlowModFlagsFromBitmap(message.readUnsignedShort())); message.skipBytes(PADDING); diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java index b72893e99c..8fff863611 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java @@ -7,8 +7,11 @@ */ package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint64; +import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint8; + import io.netty.buffer.ByteBuf; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry; @@ -80,23 +83,17 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer 0) { final int itemLength = message.readUnsignedShort(); final TableFeaturesBuilder itemBuilder = new TableFeaturesBuilder() - .setTableId(message.readUnsignedByte()); + .setTableId(readUint8(message)); message.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES); - final String name = ByteBufUtils.decodeNullTerminatedString(message, MAX_TABLE_NAME_LENGTH); - final byte[] match = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - message.readBytes(match); - final byte[] write = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES]; - message.readBytes(write); - items.add(itemBuilder .withKey(new TableFeaturesKey(itemBuilder.getTableId())) - .setName(name) - .setMetadataMatch(new BigInteger(1, match)) - .setMetadataWrite(new BigInteger(1, write)) + .setName(ByteBufUtils.decodeNullTerminatedString(message, MAX_TABLE_NAME_LENGTH)) + .setMetadataMatch(readUint64(message)) + .setMetadataWrite(readUint64(message)) .setConfig(readTableConfig(message)) - .setMaxEntries(message.readUnsignedInt()) + .setMaxEntries(readUint32(message)) .setTableProperties(readTableProperties(message, itemLength - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH)) .build()); -- 2.36.6