Fix errors in serializers and deserializers 79/51579/13
authorTomas Slusny <tomas.slusny@pantheon.tech>
Wed, 8 Feb 2017 19:14:02 +0000 (20:14 +0100)
committerTomas Slusny <tomas.slusny@pantheon.tech>
Mon, 20 Feb 2017 09:47:35 +0000 (10:47 +0100)
Fixed issues with deserializing missing multipart table features,
flows and unsigned longs.
Fixed issues when serializing Ipv4 and Ipv6 source and destination
match entries.
Added additional safety checks to match entry deserializers.

See also: bug 7139, bug 7141

Change-Id: Ie93a486aa847fdb39f01d24768f259cc4661fcad
Signed-off-by: Tomas Slusny <tomas.slusny@pantheon.tech>
76 files changed:
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/action/OutputActionDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteMetadataInstructionDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/AbstractMatchEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpOpEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceHardwareAddressEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpSourceTransportAddressEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetHardwareAddressEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/ArpTargetTransportAddressEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetDestinationEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetSourceEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/EthernetTypeEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4CodeEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv4TypeEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6CodeEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Icmpv6TypeEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPhyPortEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/InPortEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpDscpEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpEcnEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/IpProtoEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4DestinationEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv4SourceEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6DestinationEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6ExtHeaderEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6FlabelEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdSllEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTargetEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6NdTllEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/Ipv6SourceEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MatchDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MetadataEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsBosEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsLabelEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/MplsTcEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/PbbEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpDestinationPortEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/SctpSourcePortEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpDestinationPortEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TcpSourcePortEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpDestinationPortEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/UdpSourcePortEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanPcpEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/VlanVidEntryDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyDescDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyExperimenterDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowAggregateStatsDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowTableStatsDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupDescDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyGroupStatsDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterConfigDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterFeaturesDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMeterStatsDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyPortStatsDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyQueueStatsDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/TableFeaturesMatchFieldDeserializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/util/InstructionUtil.java [new file with mode: 0644]
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/OutputActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/match/MatchSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/FlowMessageSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/GroupMessageSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/MeterMessageSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/messages/PortMessageSerializer.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/serialization/util/ActionUtil.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/instruction/WriteMetadataInstructionDeserializerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/match/TunnelIdEntryDeserializerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyFlowStatsDeserializerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyMessageDeserializerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/MultipartReplyTableFeaturesDeserializerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/multipart/TableFeaturesMatchFieldDeserializerTest.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/protocol/serialization/actions/SetQueueActionSerializerTest.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/convertor/common/IpConversionUtil.java
openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/util/OpenflowPortsUtil.java

index dc51a7921116d45815ec24511ba786b42973e9f7..20408c9a131c162e2915cfdb76876836c4d87b27 100644 (file)
@@ -7,32 +7,30 @@
  */
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
 
  */
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.action;
 
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
-import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
 
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
 
-import io.netty.buffer.ByteBuf;
-
 public class OutputActionDeserializer extends AbstractActionDeserializer {
 
     @Override
     public Action deserialize(ByteBuf message) {
         processHeader(message);
 
 public class OutputActionDeserializer extends AbstractActionDeserializer {
 
     @Override
     public Action deserialize(ByteBuf message) {
         processHeader(message);
 
-        final String portNumberAsString = OpenflowPortsUtil
-            .portNumberToString(OpenflowPortsUtil
-                    .getProtocolAgnosticPort(OpenflowVersion.OF13, message.readUnsignedInt()));
+        final Uri portUri = OpenflowPortsUtil
+            .getProtocolAgnosticPortUri(EncodeConstants.OF13_VERSION_ID, message.readUnsignedInt());
 
         final int maxLength = message.readUnsignedShort();
         message.skipBytes(ActionConstants.OUTPUT_PADDING);
 
         return new OutputActionCaseBuilder()
             .setOutputAction(new OutputActionBuilder()
 
         final int maxLength = message.readUnsignedShort();
         message.skipBytes(ActionConstants.OUTPUT_PADDING);
 
         return new OutputActionCaseBuilder()
             .setOutputAction(new OutputActionBuilder()
-                    .setOutputNodeConnector(new Uri(portNumberAsString))
+                    .setOutputNodeConnector(portUri)
                     .setMaxLength(maxLength)
                     .build())
             .build();
                     .setMaxLength(maxLength)
                     .build())
             .build();
index 2687f2d56bdb83687cc6038cc6178a885906c96b..2c87c2d6fccf57991e21cae311fddd6e7d70d7f5 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.impl.protocol.deserialization.instructio
 
 import java.math.BigInteger;
 
 
 import java.math.BigInteger;
 
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
 import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
@@ -24,10 +25,15 @@ public class WriteMetadataInstructionDeserializer extends AbstractInstructionDes
         processHeader(message);
         message.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
 
         processHeader(message);
         message.skipBytes(InstructionConstants.PADDING_IN_WRITE_METADATA);
 
+        final byte[] meta = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        message.readBytes(meta);
+        final byte[] metaMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        message.readBytes(metaMask);
+
         return new WriteMetadataCaseBuilder()
             .setWriteMetadata(new WriteMetadataBuilder()
         return new WriteMetadataCaseBuilder()
             .setWriteMetadata(new WriteMetadataBuilder()
-                    .setMetadata(BigInteger.valueOf(message.readLong()))
-                    .setMetadataMask(BigInteger.valueOf(message.readLong()))
+                    .setMetadata(new BigInteger(1, meta))
+                    .setMetadataMask(new BigInteger(1, metaMask))
                     .build())
             .build();
     }
                     .build())
             .build();
     }
index 6230cbae071ec4975ff4a059543a3bbd2b57d243..9243747009d0b24717fef03fa54739142136aa63 100644 (file)
@@ -60,4 +60,14 @@ public abstract class AbstractMatchEntryDeserializer implements MatchEntryDeseri
                 + builder + "#" + propertyName + " contains invalid data.");
     }
 
                 + builder + "#" + propertyName + " contains invalid data.");
     }
 
+    /**
+     * Throw error on malformed match builder input
+     * @param builder match builder
+     * @param propertyName name of property that already containsData
+     */
+    protected static void throwErrorOnMalformed(MatchBuilder builder, String propertyName, String fieldName) {
+        throw new IllegalArgumentException("Match: " + builder.toString() + " is malformed, "
+            + builder + "#" + propertyName + "#" + fieldName + " contains invalid data.");
+    }
+
 }
 }
index f4f91476bfa5dc421b314337772120d6e8ebab8d..81f793c14ccef7c52b6fb181461385a34625f700 100644 (file)
@@ -25,14 +25,15 @@ public class ArpOpEntryDeserializer extends AbstractMatchEntryDeserializer {
 
         if (Objects.isNull(layer3Match)) {
             builder.setLayer3Match(new ArpMatchBuilder()
 
         if (Objects.isNull(layer3Match)) {
             builder.setLayer3Match(new ArpMatchBuilder()
-                    .setArpOp(arpOp)
-                    .build());
-        } else if (ArpMatch.class.isInstance(layer3Match)) {
+                .setArpOp(arpOp)
+                .build());
+        } else if (ArpMatch.class.isInstance(layer3Match)
+            && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpOp())) {
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
-                    .setArpOp(arpOp)
-                    .build());
+                .setArpOp(arpOp)
+                .build());
         } else {
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "arpOp");
         }
     }
 
         }
     }
 
index 76afbbd4020f2d298a11f8ae43278c8903aad12e..b37983bd33ad07afa8200ef970680dce3eb66d24 100644 (file)
@@ -32,14 +32,15 @@ public class ArpSourceHardwareAddressEntryDeserializer extends AbstractMatchEntr
 
         if (Objects.isNull(layer3Match)) {
             builder.setLayer3Match(new ArpMatchBuilder()
 
         if (Objects.isNull(layer3Match)) {
             builder.setLayer3Match(new ArpMatchBuilder()
-                    .setArpSourceHardwareAddress(arpBuilder.build())
-                    .build());
-        } else if (ArpMatch.class.isInstance(layer3Match)) {
+                .setArpSourceHardwareAddress(arpBuilder.build())
+                .build());
+        } else if (ArpMatch.class.isInstance(layer3Match)
+            && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpSourceHardwareAddress())) {
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
-                    .setArpSourceHardwareAddress(arpBuilder.build())
-                    .build());
+                .setArpSourceHardwareAddress(arpBuilder.build())
+                .build());
         } else {
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "arpSourceHardwareAddress");
         }
     }
 
         }
     }
 
index 6be18e0524c4a7360479acbd6522e1d5ac00b3c0..13668646ca44879767dc19f4e7d4d0f2ba684cf5 100644 (file)
@@ -28,12 +28,13 @@ public class ArpSourceTransportAddressEntryDeserializer extends AbstractMatchEnt
             builder.setLayer3Match(new ArpMatchBuilder()
                     .setArpSourceTransportAddress(prefix)
                     .build());
             builder.setLayer3Match(new ArpMatchBuilder()
                     .setArpSourceTransportAddress(prefix)
                     .build());
-        } else if (ArpMatch.class.isInstance(layer3Match)) {
+        } else if (ArpMatch.class.isInstance(layer3Match)
+            && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpSourceTransportAddress())) {
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
                     .setArpSourceTransportAddress(prefix)
                     .build());
         } else {
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
                     .setArpSourceTransportAddress(prefix)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "arpSourceTransportAddress");
         }
     }
 
         }
     }
 
index bb59ef2d259202ec34c2f9244432af40f69ca667..595c5f315f1abed1c5ee0552a11dfd7c9bf67ddd 100644 (file)
@@ -34,12 +34,13 @@ public class ArpTargetHardwareAddressEntryDeserializer extends AbstractMatchEntr
             builder.setLayer3Match(new ArpMatchBuilder()
                     .setArpTargetHardwareAddress(arpBuilder.build())
                     .build());
             builder.setLayer3Match(new ArpMatchBuilder()
                     .setArpTargetHardwareAddress(arpBuilder.build())
                     .build());
-        } else if (ArpMatch.class.isInstance(layer3Match)) {
+        } else if (ArpMatch.class.isInstance(layer3Match)
+            && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpTargetHardwareAddress())) {
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
                     .setArpTargetHardwareAddress(arpBuilder.build())
                     .build());
         } else {
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
                     .setArpTargetHardwareAddress(arpBuilder.build())
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "arpTargetHardwareAddress");
         }
     }
 
         }
     }
 
index 314e4b3b2cc7a1bfe26a0c37305698dc0387ac08..21dcce7226b87bdfa04521d224517cae0a08334a 100644 (file)
@@ -28,12 +28,13 @@ public class ArpTargetTransportAddressEntryDeserializer extends AbstractMatchEnt
             builder.setLayer3Match(new ArpMatchBuilder()
                     .setArpTargetTransportAddress(prefix)
                     .build());
             builder.setLayer3Match(new ArpMatchBuilder()
                     .setArpTargetTransportAddress(prefix)
                     .build());
-        } else if (ArpMatch.class.isInstance(layer3Match)) {
+        } else if (ArpMatch.class.isInstance(layer3Match)
+            && Objects.isNull(ArpMatch.class.cast(layer3Match).getArpTargetTransportAddress())) {
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
                     .setArpTargetTransportAddress(prefix)
                     .build());
         } else {
             builder.setLayer3Match(new ArpMatchBuilder(ArpMatch.class.cast(layer3Match))
                     .setArpTargetTransportAddress(prefix)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "arpTargetTransportAddress");
         }
     }
 
         }
     }
 
index 3708534c19a35e7fb94b95c252204aa662887f61..66f5bd7e9c0acc4b03e857756672e18ac0e4df9d 100644 (file)
@@ -38,7 +38,7 @@ public class EthernetDestinationEntryDeserializer extends AbstractMatchEntryDese
                     .setEthernetDestination(ethernetDestinationBuilder.build())
                     .build());
         } else {
                     .setEthernetDestination(ethernetDestinationBuilder.build())
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "ethernetMatch");
+            throwErrorOnMalformed(builder, "ethernetMatch", "ethernetDestination");
         }
     }
 
         }
     }
 
index 7a538b69e186197ae619c43e8c6a151083e97c48..e75d67d3c08874f6146d62acc07f03b275693d11 100644 (file)
@@ -38,7 +38,7 @@ public class EthernetSourceEntryDeserializer extends AbstractMatchEntryDeseriali
                     .setEthernetSource(ethernetSourceBuilder.build())
                     .build());
         } else {
                     .setEthernetSource(ethernetSourceBuilder.build())
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "ethernetMatch");
+            throwErrorOnMalformed(builder, "ethernetMatch", "ethernetSource");
         }
     }
 
         }
     }
 
index 2511c47216b6fc8125c9d5a6e5f47388f6bbc954..7f8c3f31cdb282b9614f8300f36aa4d72e1c17f5 100644 (file)
@@ -35,7 +35,7 @@ public class EthernetTypeEntryDeserializer extends AbstractMatchEntryDeserialize
                             .build())
                     .build());
         } else {
                             .build())
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "ethernetMatch");
+            throwErrorOnMalformed(builder, "ethernetMatch", "ethernetType");
         }
     }
 
         }
     }
 
index 58d1c157b7524ee8c94593dc9ce43b209351716e..d426f73ddac9692eb3ca059421c96b0a60ee1d6b 100644 (file)
@@ -29,7 +29,7 @@ public class Icmpv4CodeEntryDeserializer extends AbstractMatchEntryDeserializer
                     .setIcmpv4Code(code)
                     .build());
         } else {
                     .setIcmpv4Code(code)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "icmpv4Match");
+            throwErrorOnMalformed(builder, "icmpv4Match", "icmpv4Code");
         }
     }
 
         }
     }
 
index 73c3a636e078092859ac4da8e3bb8a1305c19b1e..dd119a54a858007e643475af47c24df5b3b1c259 100644 (file)
@@ -29,7 +29,7 @@ public class Icmpv4TypeEntryDeserializer extends AbstractMatchEntryDeserializer
                     .setIcmpv4Type(type)
                     .build());
         } else {
                     .setIcmpv4Type(type)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "icmpv4Match");
+            throwErrorOnMalformed(builder, "icmpv4Match", "icmpv4Type");
         }
     }
 
         }
     }
 
index 3f36e4f443969f9a4fec08cede4781b5d9ac4d94..6bc515e42aadb3c47309fa1fd7805052e9c458fd 100644 (file)
@@ -29,7 +29,7 @@ public class Icmpv6CodeEntryDeserializer extends AbstractMatchEntryDeserializer
                     .setIcmpv6Code(code)
                     .build());
         } else {
                     .setIcmpv6Code(code)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "icmpv6Match");
+            throwErrorOnMalformed(builder, "icmpv6Match", "icmpv6Code");
         }
     }
 
         }
     }
 
index 5f8afa71d026101913195a491136bf350e287fad..1ec452821e13b42bb2293555169bfedacf50b40c 100644 (file)
@@ -29,7 +29,7 @@ public class Icmpv6TypeEntryDeserializer extends AbstractMatchEntryDeserializer
                     .setIcmpv6Type(type)
                     .build());
         } else {
                     .setIcmpv6Type(type)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "icmpv6Match");
+            throwErrorOnMalformed(builder, "icmpv6Match", "icmpv6Type");
         }
     }
 
         }
     }
 
index 42f399165b1abd6a4781418468f01a0c61c111ca..9ecb2ba958e0098cf1aeb70e0452cf7768b91faa 100644 (file)
@@ -23,10 +23,7 @@ public class InPhyPortEntryDeserializer extends AbstractMatchEntryDeserializer {
         final long port = message.readUnsignedInt();
 
         if (Objects.isNull(builder.getInPhyPort())) {
         final long port = message.readUnsignedInt();
 
         if (Objects.isNull(builder.getInPhyPort())) {
-            final String portName = OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID, port);
-
-            // We do not assign datapath ID here, because we simply do not have it
-            builder.setInPhyPort(new NodeConnectorId(Objects.isNull(portName) ? String.valueOf(port) : portName));
+            builder.setInPhyPort(new NodeConnectorId(OpenflowPortsUtil.getProtocolAgnosticPortUri(EncodeConstants.OF13_VERSION_ID, port)));
         } else {
             throwErrorOnMalformed(builder, "inPhyPort");
         }
         } else {
             throwErrorOnMalformed(builder, "inPhyPort");
         }
index 1f7e3ace226641e8338e95515fac865c063a97d3..e6b59bec8ab6fc6d5d58900058388670a73d2e34 100644 (file)
@@ -23,10 +23,7 @@ public class InPortEntryDeserializer extends AbstractMatchEntryDeserializer {
         final long port = message.readUnsignedInt();
 
         if (Objects.isNull(builder.getInPort())) {
         final long port = message.readUnsignedInt();
 
         if (Objects.isNull(builder.getInPort())) {
-            final String portName = OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID, port);
-
-            // We do not assign datapath ID here, because we simply do not have it
-            builder.setInPort(new NodeConnectorId(Objects.isNull(portName) ? String.valueOf(port) : portName));
+            builder.setInPort(new NodeConnectorId(OpenflowPortsUtil.getProtocolAgnosticPortUri(EncodeConstants.OF13_VERSION_ID, port)));
         } else {
             throwErrorOnMalformed(builder, "inPort");
         }
         } else {
             throwErrorOnMalformed(builder, "inPort");
         }
index 9944449affcaa78f00e6562079e1fc7dd3a211ed..3fb635067140feea6d1232f1cbf7cdf1a5bcf847 100644 (file)
@@ -30,7 +30,7 @@ public class IpDscpEntryDeserializer extends AbstractMatchEntryDeserializer {
                     .setIpDscp(new Dscp(dscp))
                     .build());
         } else {
                     .setIpDscp(new Dscp(dscp))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "ipMatch");
+            throwErrorOnMalformed(builder, "ipMatch", "ipDscp");
         }
     }
 
         }
     }
 
index 797ce95f4090886f71b1af1fee556a981a3a9e9f..c1458d331dc5982c87cff29ea179f880db336c74 100644 (file)
@@ -29,7 +29,7 @@ public class IpEcnEntryDeserializer extends AbstractMatchEntryDeserializer {
                     .setIpEcn(ecn)
                     .build());
         } else {
                     .setIpEcn(ecn)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "ipMatch");
+            throwErrorOnMalformed(builder, "ipMatch", "ipEcn");
         }
     }
 
         }
     }
 
index f5066201276e0df293db529bbb8bf585c19007a5..c3a4f005547d94bdb4a370d188d9e6e3ba354fd4 100644 (file)
@@ -29,7 +29,7 @@ public class IpProtoEntryDeserializer extends AbstractMatchEntryDeserializer {
                     .setIpProtocol(proto)
                     .build());
         } else {
                     .setIpProtocol(proto)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "ipMatch");
+            throwErrorOnMalformed(builder, "ipMatch", "ipProtocol");
         }
     }
 
         }
     }
 
index 572965019bbff5e6bb222e970d6a7b5ac1f26a7a..943ba8c2e30d2cd82774fdaceec381357a7d81d5 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
 
 import java.util.Objects;
 
 
 import java.util.Objects;
 
+import javax.annotation.Nullable;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
@@ -36,41 +37,25 @@ public class Ipv4DestinationEntryDeserializer extends AbstractMatchEntryDeserial
             if (IpConversionUtil.isArbitraryBitMask(mask)) {
                 setArbitraryMatch(builder, address, mask);
             } else {
             if (IpConversionUtil.isArbitraryBitMask(mask)) {
                 setArbitraryMatch(builder, address, mask);
             } else {
-                setPrefixMatch(builder, address, mask, hasMask);
+                setPrefixMatch(builder, address, mask);
             }
         } else {
             }
         } else {
-            setPrefixMatch(builder, address, null, hasMask);
+            setPrefixMatch(builder, address, null);
         }
     }
 
         }
     }
 
-    private static void setPrefixMatch(final MatchBuilder builder, final Ipv4Address address,
-            final byte[] mask, final boolean hasMask) {
-        if (hasMask) {
-            if (Objects.isNull(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv4MatchBuilder()
-                        .setIpv4Destination(IpConversionUtil.createPrefix(address, mask))
-                        .build());
-            } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv4MatchBuilder()
-                        .setIpv4Destination(IpConversionUtil.createPrefix(address, mask))
-                        .setIpv4Destination(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Destination())
-                        .build());
-            } else {
-                throwErrorOnMalformed(builder, "layer3Match");
-            }
+    private static void setPrefixMatch(final MatchBuilder builder, final Ipv4Address address, @Nullable final byte[] mask) {
+        if (Objects.isNull(builder.getLayer3Match())) {
+            builder.setLayer3Match(new Ipv4MatchBuilder()
+                .setIpv4Destination(IpConversionUtil.createPrefix(address, mask))
+                .build());
+        } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Destination())) {
+            builder.setLayer3Match(new Ipv4MatchBuilder(Ipv4Match.class.cast(builder.getLayer3Match()))
+                .setIpv4Destination(IpConversionUtil.createPrefix(address, mask))
+                .build());
         } else {
         } else {
-            if (Objects.isNull(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv4MatchBuilder()
-                        .setIpv4Destination(IpConversionUtil.createPrefix(address))
-                        .build());
-            } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv4MatchBuilder()
-                        .setIpv4Destination(IpConversionUtil.createPrefix(address))
-                        .setIpv4Source(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Source())
-                        .build());
-            } else {
-                throwErrorOnMalformed(builder, "layer3Match");
-            }
+            throwErrorOnMalformed(builder, "layer3Match", "ipv4Destination");
         }
     }
 
         }
     }
 
@@ -81,16 +66,14 @@ public class Ipv4DestinationEntryDeserializer extends AbstractMatchEntryDeserial
                     .setIpv4DestinationAddressNoMask(address)
                     .setIpv4DestinationArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
                     .build());
                     .setIpv4DestinationAddressNoMask(address)
                     .setIpv4DestinationArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
                     .build());
-        } else if (Ipv4MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())) {
-            final Ipv4MatchArbitraryBitMask match = Ipv4MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
-            builder.setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder()
+        } else if (Ipv4MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv4MatchArbitraryBitMask.class.cast(builder.getLayer3Match()).getIpv4DestinationAddressNoMask())) {
+            builder.setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder(Ipv4MatchArbitraryBitMask.class.cast(builder.getLayer3Match()))
                     .setIpv4DestinationAddressNoMask(address)
                     .setIpv4DestinationArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
                     .setIpv4DestinationAddressNoMask(address)
                     .setIpv4DestinationArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
-                    .setIpv4SourceAddressNoMask(match.getIpv4SourceAddressNoMask())
-                    .setIpv4SourceArbitraryBitmask(match.getIpv4SourceArbitraryBitmask())
                     .build());
         } else {
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv4DestinationAddressNoMask");
         }
     }
 
         }
     }
 
index 80552328b30706430dfb371d1a417205e6a8a800..910fb179b33869e86fc23b654a83ff09c6eb57f4 100644 (file)
@@ -36,41 +36,25 @@ public class Ipv4SourceEntryDeserializer extends AbstractMatchEntryDeserializer
             if (IpConversionUtil.isArbitraryBitMask(mask)) {
                 setArbitraryMatch(builder, address, mask);
             } else {
             if (IpConversionUtil.isArbitraryBitMask(mask)) {
                 setArbitraryMatch(builder, address, mask);
             } else {
-                setPrefixMatch(builder, address, mask, hasMask);
+                setPrefixMatch(builder, address, mask);
             }
         } else {
             }
         } else {
-            setPrefixMatch(builder, address, null, hasMask);
+            setPrefixMatch(builder, address, null);
         }
     }
 
         }
     }
 
-    private static void setPrefixMatch(final MatchBuilder builder, final Ipv4Address address,
-            final byte[] mask, final boolean hasMask) {
-        if (hasMask) {
-            if (Objects.isNull(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv4MatchBuilder()
-                        .setIpv4Source(IpConversionUtil.createPrefix(address, mask))
-                        .build());
-            } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv4MatchBuilder()
-                        .setIpv4Source(IpConversionUtil.createPrefix(address, mask))
-                        .setIpv4Destination(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Destination())
-                        .build());
-            } else {
-                throwErrorOnMalformed(builder, "layer3Match");
-            }
+    private static void setPrefixMatch(final MatchBuilder builder, final Ipv4Address address, final byte[] mask) {
+        if (Objects.isNull(builder.getLayer3Match())) {
+            builder.setLayer3Match(new Ipv4MatchBuilder()
+                .setIpv4Source(IpConversionUtil.createPrefix(address, mask))
+                .build());
+        } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Source())) {
+            builder.setLayer3Match(new Ipv4MatchBuilder(Ipv4Match.class.cast(builder.getLayer3Match()))
+                .setIpv4Source(IpConversionUtil.createPrefix(address, mask))
+                .build());
         } else {
         } else {
-            if (Objects.isNull(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv4MatchBuilder()
-                        .setIpv4Source(IpConversionUtil.createPrefix(address))
-                        .build());
-            } else if (Ipv4Match.class.isInstance(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv4MatchBuilder()
-                        .setIpv4Source(IpConversionUtil.createPrefix(address))
-                        .setIpv4Destination(Ipv4Match.class.cast(builder.getLayer3Match()).getIpv4Destination())
-                        .build());
-            } else {
-                throwErrorOnMalformed(builder, "layer3Match");
-            }
+            throwErrorOnMalformed(builder, "layer3Match", "ipv4Source");
         }
     }
 
         }
     }
 
@@ -81,16 +65,14 @@ public class Ipv4SourceEntryDeserializer extends AbstractMatchEntryDeserializer
                     .setIpv4SourceAddressNoMask(address)
                     .setIpv4SourceArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
                     .build());
                     .setIpv4SourceAddressNoMask(address)
                     .setIpv4SourceArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
                     .build());
-        } else if (Ipv4MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())) {
-            final Ipv4MatchArbitraryBitMask match = Ipv4MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
-            builder.setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder()
+        } else if (Ipv4MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv4MatchArbitraryBitMask.class.cast(builder.getLayer3Match()).getIpv4SourceAddressNoMask())) {
+            builder.setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder(Ipv4MatchArbitraryBitMask.class.cast(builder.getLayer3Match()))
                     .setIpv4SourceAddressNoMask(address)
                     .setIpv4SourceArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
                     .setIpv4SourceAddressNoMask(address)
                     .setIpv4SourceArbitraryBitmask(IpConversionUtil.createArbitraryBitMask(mask))
-                    .setIpv4DestinationAddressNoMask(match.getIpv4DestinationAddressNoMask())
-                    .setIpv4DestinationArbitraryBitmask(match.getIpv4DestinationArbitraryBitmask())
                     .build());
         } else {
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv4SourceAddressNoMask");
         }
     }
 
         }
     }
 
index aed993fadc202ec360208ca53636eab81e8e079c..b5ae535e59f2558851856eded8a78386ad983577 100644 (file)
@@ -36,39 +36,25 @@ public class Ipv6DestinationEntryDeserializer extends AbstractMatchEntryDeserial
             if (IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
                 setArbitraryMatch(builder, address, mask);
             } else {
             if (IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
                 setArbitraryMatch(builder, address, mask);
             } else {
-                setPrefixMatch(builder, address, mask, hasMask);
+                setPrefixMatch(builder, address, mask);
             }
         } else {
             }
         } else {
-            setPrefixMatch(builder, address, null, hasMask);
+            setPrefixMatch(builder, address, null);
         }
     }
 
         }
     }
 
-    private static void setPrefixMatch(final MatchBuilder builder, final Ipv6Address address,
-            final byte[] mask, final boolean hasMask) {
-        if (hasMask) {
-            if (Objects.isNull(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv6MatchBuilder()
-                        .setIpv6Destination(IpConversionUtil.createPrefix(address, mask))
-                        .build());
-            } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
-                        .setIpv6Destination(IpConversionUtil.createPrefix(address, mask))
-                        .build());
-            } else {
-                throwErrorOnMalformed(builder, "layer3Match");
-            }
+    private static void setPrefixMatch(final MatchBuilder builder, final Ipv6Address address, final byte[] mask) {
+        if (Objects.isNull(builder.getLayer3Match())) {
+            builder.setLayer3Match(new Ipv6MatchBuilder()
+                .setIpv6Destination(IpConversionUtil.createPrefix(address, mask))
+                .build());
+        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6Destination())) {
+            builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
+                .setIpv6Destination(IpConversionUtil.createPrefix(address, mask))
+                .build());
         } else {
         } else {
-            if (Objects.isNull(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv6MatchBuilder()
-                        .setIpv6Destination(IpConversionUtil.createPrefix(address))
-                        .build());
-            } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
-                        .setIpv6Destination(IpConversionUtil.createPrefix(address))
-                        .build());
-            } else {
-                throwErrorOnMalformed(builder, "layer3Match");
-            }
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6Destination");
         }
     }
 
         }
     }
 
@@ -79,14 +65,15 @@ public class Ipv6DestinationEntryDeserializer extends AbstractMatchEntryDeserial
                     .setIpv6DestinationAddressNoMask(address)
                     .setIpv6DestinationArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
                     .build());
                     .setIpv6DestinationAddressNoMask(address)
                     .setIpv6DestinationArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
                     .build());
-        } else if (Ipv6MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())) {
+        } else if (Ipv6MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6MatchArbitraryBitMask.class.cast(builder.getLayer3Match()).getIpv6DestinationAddressNoMask())) {
             final Ipv6MatchArbitraryBitMask match = Ipv6MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder(match)
                     .setIpv6DestinationAddressNoMask(address)
                     .setIpv6DestinationArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
                     .build());
         } else {
             final Ipv6MatchArbitraryBitMask match = Ipv6MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder(match)
                     .setIpv6DestinationAddressNoMask(address)
                     .setIpv6DestinationArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6DestinationAddressNoMask");
         }
     }
 
         }
     }
 
index 0890d50911cfd3b11e9a8d43499c959ef39d064e..f8d155444c2053d736c1d2431f37f4179ae22abd 100644 (file)
@@ -8,23 +8,16 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
 
 
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
 
+import io.netty.buffer.ByteBuf;
 import java.util.Objects;
 import java.util.Objects;
-
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
-import org.opendaylight.openflowjava.util.ByteBufUtils;
-import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.common.IpConversionUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ipv6.match.fields.Ipv6ExtHeaderBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMask;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchArbitraryBitMaskBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
 
-import io.netty.buffer.ByteBuf;
-
 public class Ipv6ExtHeaderEntryDeserializer extends AbstractMatchEntryDeserializer {
 
     @Override
 public class Ipv6ExtHeaderEntryDeserializer extends AbstractMatchEntryDeserializer {
 
     @Override
@@ -42,13 +35,14 @@ public class Ipv6ExtHeaderEntryDeserializer extends AbstractMatchEntryDeserializ
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6ExtHeader(extHeaderBuilder.build())
                     .build());
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6ExtHeader(extHeaderBuilder.build())
                     .build());
-        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6ExtHeader())) {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6ExtHeader(extHeaderBuilder.build())
                     .build());
         } else {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6ExtHeader(extHeaderBuilder.build())
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6ExtHeader");
         }
 
     }
         }
 
     }
index 58a3f2d3c346837e744bded3dd70fce7a1e39ee2..76bf0e89dc148e14871dddd33e379d37f9a70268 100644 (file)
@@ -38,13 +38,14 @@ public class Ipv6FlabelEntryDeserializer extends AbstractMatchEntryDeserializer
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6Label(ipv6labelBuilder.build())
                     .build());
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6Label(ipv6labelBuilder.build())
                     .build());
-        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6Label())) {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6Label(ipv6labelBuilder.build())
                     .build());
         } else {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6Label(ipv6labelBuilder.build())
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6Label");
         }
 
     }
         }
 
     }
index acd9a439684f5bf03efb77268bedcac896637c2d..4e461223d363e0e2ccf4596066502313a5091b50 100644 (file)
@@ -29,13 +29,14 @@ public class Ipv6NdSllEntryDeserializer extends AbstractMatchEntryDeserializer {
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6NdSll(address)
                     .build());
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6NdSll(address)
                     .build());
-        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6NdSll())) {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6NdSll(address)
                     .build());
         } else {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6NdSll(address)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6NdSll");
         }
 
     }
         }
 
     }
index fd406b348cd48ad586808a2e160bfbec890be020..53219061656e6587e4545cdcb0664637dd1efe8c 100644 (file)
@@ -29,13 +29,14 @@ public class Ipv6NdTargetEntryDeserializer extends AbstractMatchEntryDeserialize
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6NdTarget(address)
                     .build());
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6NdTarget(address)
                     .build());
-        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6NdTarget())) {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6NdTarget(address)
                     .build());
         } else {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6NdTarget(address)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6NdTarget");
         }
 
     }
         }
 
     }
index 7a5445441fcfa047269f1fd6c79013e244886a88..4bb750d449849ec7cdb1dc4a104b60397a5b5a10 100644 (file)
@@ -29,13 +29,14 @@ public class Ipv6NdTllEntryDeserializer extends AbstractMatchEntryDeserializer {
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6NdTll(address)
                     .build());
             builder.setLayer3Match(new Ipv6MatchBuilder()
                     .setIpv6NdTll(address)
                     .build());
-        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
+        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6NdTll())) {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6NdTll(address)
                     .build());
         } else {
             final Ipv6Match match = Ipv6Match.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchBuilder(match)
                     .setIpv6NdTll(address)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6NdTll");
         }
 
     }
         }
 
     }
index b988e7f1219f9fa115f5c212870b51f6a9856266..4a700ad695faebc8df15a66352152f71b8543584 100644 (file)
@@ -36,40 +36,25 @@ public class Ipv6SourceEntryDeserializer extends AbstractMatchEntryDeserializer
             if (IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
                 setArbitraryMatch(builder, address, mask);
             } else {
             if (IpConversionUtil.isIpv6ArbitraryBitMask(mask)) {
                 setArbitraryMatch(builder, address, mask);
             } else {
-                setPrefixMatch(builder, address, mask, hasMask);
+                setPrefixMatch(builder, address, mask);
             }
         } else {
             }
         } else {
-            setPrefixMatch(builder, address, null, hasMask);
+            setPrefixMatch(builder, address, null);
         }
     }
 
         }
     }
 
-    private static void setPrefixMatch(final MatchBuilder builder, final Ipv6Address address,
-            final byte[] mask, final boolean hasMask) {
-        if (hasMask) {
-            if (Objects.isNull(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv6MatchBuilder()
-                        .setIpv6Source(IpConversionUtil.createPrefix(address, mask))
-                        .build());
-            } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
-                        .setIpv6Source(IpConversionUtil.createPrefix(address, mask))
-                        .setIpv6Destination(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6Destination())
-                        .build());
-            } else {
-                throwErrorOnMalformed(builder, "layer3Match");
-            }
+    private static void setPrefixMatch(final MatchBuilder builder, final Ipv6Address address, final byte[] mask) {
+        if (Objects.isNull(builder.getLayer3Match())) {
+            builder.setLayer3Match(new Ipv6MatchBuilder()
+                .setIpv6Source(IpConversionUtil.createPrefix(address, mask))
+                .build());
+        } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6Match.class.cast(builder.getLayer3Match()).getIpv6Source())) {
+            builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
+                .setIpv6Source(IpConversionUtil.createPrefix(address, mask))
+                .build());
         } else {
         } else {
-            if (Objects.isNull(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv6MatchBuilder()
-                        .setIpv6Source(IpConversionUtil.createPrefix(address))
-                        .build());
-            } else if (Ipv6Match.class.isInstance(builder.getLayer3Match())) {
-                builder.setLayer3Match(new Ipv6MatchBuilder(Ipv6Match.class.cast(builder.getLayer3Match()))
-                        .setIpv6Source(IpConversionUtil.createPrefix(address))
-                        .build());
-            } else {
-                throwErrorOnMalformed(builder, "layer3Match");
-            }
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6Source");
         }
     }
 
         }
     }
 
@@ -80,14 +65,15 @@ public class Ipv6SourceEntryDeserializer extends AbstractMatchEntryDeserializer
                     .setIpv6SourceAddressNoMask(address)
                     .setIpv6SourceArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
                     .build());
                     .setIpv6SourceAddressNoMask(address)
                     .setIpv6SourceArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
                     .build());
-        } else if (Ipv6MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())) {
+        } else if (Ipv6MatchArbitraryBitMask.class.isInstance(builder.getLayer3Match())
+            && Objects.isNull(Ipv6MatchArbitraryBitMask.class.cast(builder.getLayer3Match()).getIpv6SourceAddressNoMask())) {
             final Ipv6MatchArbitraryBitMask match = Ipv6MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder(match)
                     .setIpv6SourceAddressNoMask(address)
                     .setIpv6SourceArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
                     .build());
         } else {
             final Ipv6MatchArbitraryBitMask match = Ipv6MatchArbitraryBitMask.class.cast(builder.getLayer3Match());
             builder.setLayer3Match(new Ipv6MatchArbitraryBitMaskBuilder(match)
                     .setIpv6SourceAddressNoMask(address)
                     .setIpv6SourceArbitraryBitmask(IpConversionUtil.createIpv6ArbitraryBitMask(mask))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer3Match");
+            throwErrorOnMalformed(builder, "layer3Match", "ipv6SourceAddressNoMask");
         }
     }
 
         }
     }
 
index 9d8d1136781ef9857fef8b4fc10eedb115d15ffc..8b92ed09a6bb0b61fa3e6709ff5c07be4e0ea063 100644 (file)
@@ -83,7 +83,7 @@ public class MatchDeserializer implements OFDeserializer<Match>, HeaderDeseriali
                 + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
 
         final MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(
                 + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
 
         final MatchEntryDeserializerKey key = new MatchEntryDeserializerKey(
-                EncodeConstants.OF13_VERSION_ID,oxmClass, oxmField);
+                EncodeConstants.OF13_VERSION_ID, oxmClass, oxmField);
 
         if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
             long expId = inBuffer.getUnsignedInt(inBuffer.readerIndex()
 
         if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
             long expId = inBuffer.getUnsignedInt(inBuffer.readerIndex()
index 04f585f3db2e5f2f72fbe7e01efec6ee0f9e7228..cb99ff06444c7e86adf02639fb073568fd5598fa 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
 import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import java.util.Objects;
 import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import java.util.Objects;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
@@ -21,11 +22,15 @@ public class MetadataEntryDeserializer extends AbstractMatchEntryDeserializer {
     public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
         final boolean hasMask = processHeader(message);
         final Metadata metadata = builder.getMetadata();
     public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
         final boolean hasMask = processHeader(message);
         final Metadata metadata = builder.getMetadata();
+        final byte[] metaByte = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        message.readBytes(metaByte);
         final MetadataBuilder metadataBuilder = new MetadataBuilder()
         final MetadataBuilder metadataBuilder = new MetadataBuilder()
-                .setMetadata(BigInteger.valueOf(message.readLong()));
+                .setMetadata(new BigInteger(1, metaByte));
 
         if (hasMask) {
 
         if (hasMask) {
-            metadataBuilder.setMetadataMask(BigInteger.valueOf(message.readLong()));
+            final byte[] metaMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(metaMask);
+            metadataBuilder.setMetadataMask(new BigInteger(1, metaMask));
         }
 
         if (Objects.isNull(metadata)) {
         }
 
         if (Objects.isNull(metadata)) {
index 06d590ddaa760f2fd54b69124300b767df5a4ee3..b15d1275f5a72a7eedca9c624fb7cd57de20045d 100644 (file)
@@ -31,7 +31,7 @@ public class MplsBosEntryDeserializer extends AbstractMatchEntryDeserializer {
                     .setMplsBos(mplsBos)
                     .build());
         } else {
                     .setMplsBos(mplsBos)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "protocolMatchFields");
+            throwErrorOnMalformed(builder, "protocolMatchFields", "mplsBos");
         }
     }
 
         }
     }
 
index c71ae84139f8d594fb4d68af55566098bb246096..8fc0d788890e3c9a7e914aba320996bd6cced6b1 100644 (file)
@@ -31,7 +31,7 @@ public class MplsLabelEntryDeserializer extends AbstractMatchEntryDeserializer {
                     .setMplsLabel(mplsLabel)
                     .build());
         } else {
                     .setMplsLabel(mplsLabel)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "protocolMatchFields");
+            throwErrorOnMalformed(builder, "protocolMatchFields", "mplsLabel");
         }
     }
 
         }
     }
 
index 5836cf9fa38b60a88faa87240ceda03bcabf4b98..26483b6e6f5ff00c3c6fe86e8b73fb43f4e959dc 100644 (file)
@@ -31,7 +31,7 @@ public class MplsTcEntryDeserializer extends AbstractMatchEntryDeserializer {
                     .setMplsTc(mplsTc)
                     .build());
         } else {
                     .setMplsTc(mplsTc)
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "protocolMatchFields");
+            throwErrorOnMalformed(builder, "protocolMatchFields", "mplsTc");
         }
     }
 
         }
     }
 
index 1d59140b9a55d23494ac142f72f579520e6046df..b0b06b86cfe0a3e667063102a2cce880da4fa338 100644 (file)
@@ -38,7 +38,7 @@ public class PbbEntryDeserializer extends AbstractMatchEntryDeserializer {
                     .setPbb(pbbBuilder.build())
                     .build());
         } else {
                     .setPbb(pbbBuilder.build())
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "protocolMatchFields");
+            throwErrorOnMalformed(builder, "protocolMatchFields", "pbb");
         }
     }
 
         }
     }
 
index 1995043276e84902bafc2a09ca046866569ad322..2b7dfbaf279a80f57813609d1eebe2edd9d6cfb1 100644 (file)
@@ -26,12 +26,13 @@ public class SctpDestinationPortEntryDeserializer extends AbstractMatchEntryDese
             builder.setLayer4Match(new SctpMatchBuilder()
                     .setSctpDestinationPort(new PortNumber(port))
                     .build());
             builder.setLayer4Match(new SctpMatchBuilder()
                     .setSctpDestinationPort(new PortNumber(port))
                     .build());
-        } else if (SctpMatch.class.isInstance(builder.getLayer4Match())) {
+        } else if (SctpMatch.class.isInstance(builder.getLayer4Match())
+            && Objects.isNull(SctpMatch.class.cast(builder.getLayer4Match()).getSctpDestinationPort())) {
             builder.setLayer4Match(new SctpMatchBuilder(SctpMatch.class.cast(builder.getLayer4Match()))
                     .setSctpDestinationPort(new PortNumber(port))
                     .build());
         } else {
             builder.setLayer4Match(new SctpMatchBuilder(SctpMatch.class.cast(builder.getLayer4Match()))
                     .setSctpDestinationPort(new PortNumber(port))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer4Match");
+            throwErrorOnMalformed(builder, "layer4Match", "sctpDestinationPort");
         }
     }
 
         }
     }
 
index 8204c5959de27903be69e05f2d6493651561a75e..286beafc8e2ba7922016a4f2bd82e0dc14b4d0fc 100644 (file)
@@ -26,12 +26,13 @@ public class SctpSourcePortEntryDeserializer extends AbstractMatchEntryDeseriali
             builder.setLayer4Match(new SctpMatchBuilder()
                     .setSctpSourcePort(new PortNumber(port))
                     .build());
             builder.setLayer4Match(new SctpMatchBuilder()
                     .setSctpSourcePort(new PortNumber(port))
                     .build());
-        } else if (SctpMatch.class.isInstance(builder.getLayer4Match())) {
+        } else if (SctpMatch.class.isInstance(builder.getLayer4Match())
+            && Objects.isNull(SctpMatch.class.cast(builder.getLayer4Match()).getSctpSourcePort())) {
             builder.setLayer4Match(new SctpMatchBuilder(SctpMatch.class.cast(builder.getLayer4Match()))
                     .setSctpSourcePort(new PortNumber(port))
                     .build());
         } else {
             builder.setLayer4Match(new SctpMatchBuilder(SctpMatch.class.cast(builder.getLayer4Match()))
                     .setSctpSourcePort(new PortNumber(port))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer4Match");
+            throwErrorOnMalformed(builder, "layer4Match", "sctpSourcePort");
         }
     }
 
         }
     }
 
index 5a1afead44d9c45c5b91e635b31b2cc95f8eb254..4b2f248e2818130235097e74296f023763e38c06 100644 (file)
@@ -26,12 +26,13 @@ public class TcpDestinationPortEntryDeserializer extends AbstractMatchEntryDeser
             builder.setLayer4Match(new TcpMatchBuilder()
                     .setTcpDestinationPort(new PortNumber(port))
                     .build());
             builder.setLayer4Match(new TcpMatchBuilder()
                     .setTcpDestinationPort(new PortNumber(port))
                     .build());
-        } else if (TcpMatch.class.isInstance(builder.getLayer4Match())) {
+        } else if (TcpMatch.class.isInstance(builder.getLayer4Match())
+            && Objects.isNull(TcpMatch.class.cast(builder.getLayer4Match()).getTcpDestinationPort())) {
             builder.setLayer4Match(new TcpMatchBuilder(TcpMatch.class.cast(builder.getLayer4Match()))
                     .setTcpDestinationPort(new PortNumber(port))
                     .build());
         } else {
             builder.setLayer4Match(new TcpMatchBuilder(TcpMatch.class.cast(builder.getLayer4Match()))
                     .setTcpDestinationPort(new PortNumber(port))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer4Match");
+            throwErrorOnMalformed(builder, "layer4Match", "tcpDestinationPort");
         }
     }
 
         }
     }
 
index 0f7fb97dd8454230fe01bd1029f0552e0cca5f29..02daf560c42090a5e18c7a5b361791da421b115f 100644 (file)
@@ -26,12 +26,13 @@ public class TcpSourcePortEntryDeserializer extends AbstractMatchEntryDeserializ
             builder.setLayer4Match(new TcpMatchBuilder()
                     .setTcpSourcePort(new PortNumber(port))
                     .build());
             builder.setLayer4Match(new TcpMatchBuilder()
                     .setTcpSourcePort(new PortNumber(port))
                     .build());
-        } else if (TcpMatch.class.isInstance(builder.getLayer4Match())) {
+        } else if (TcpMatch.class.isInstance(builder.getLayer4Match())
+            && Objects.isNull(TcpMatch.class.cast(builder.getLayer4Match()).getTcpSourcePort())) {
             builder.setLayer4Match(new TcpMatchBuilder(TcpMatch.class.cast(builder.getLayer4Match()))
                     .setTcpSourcePort(new PortNumber(port))
                     .build());
         } else {
             builder.setLayer4Match(new TcpMatchBuilder(TcpMatch.class.cast(builder.getLayer4Match()))
                     .setTcpSourcePort(new PortNumber(port))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer4Match");
+            throwErrorOnMalformed(builder, "layer4Match", "tcpSource");
         }
     }
 
         }
     }
 
index 8c61e8de3da5ffa578c255c15a81c1bbba00b2e8..f22c4dc7097f8d4533cb563c46b442a5030639ee 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
 import java.math.BigInteger;
 import java.util.Objects;
 
 import java.math.BigInteger;
 import java.util.Objects;
 
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
 
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
 
@@ -22,11 +23,15 @@ public class TunnelIdEntryDeserializer extends AbstractMatchEntryDeserializer {
     public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
         final boolean hasMask = processHeader(message);
 
     public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
         final boolean hasMask = processHeader(message);
 
+        final byte[] tunnelId = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        message.readBytes(tunnelId);
         final TunnelBuilder tunnelBuilder = new TunnelBuilder()
         final TunnelBuilder tunnelBuilder = new TunnelBuilder()
-            .setTunnelId(BigInteger.valueOf(message.readLong()));
+            .setTunnelId(new BigInteger(1, tunnelId));
 
         if (hasMask) {
 
         if (hasMask) {
-            tunnelBuilder.setTunnelMask(BigInteger.valueOf(message.readLong()));
+            final byte[] tunnelMask = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(tunnelMask);
+            tunnelBuilder.setTunnelMask(new BigInteger(1, tunnelMask));
         }
 
         if (Objects.isNull(builder.getTunnel())) {
         }
 
         if (Objects.isNull(builder.getTunnel())) {
index 4c58d228cc873c200dabba1cc0edcabeae4aff6a..837e4aeb4cc5c4e7ca545c904ea25e431cf19d56 100644 (file)
@@ -26,12 +26,13 @@ public class UdpDestinationPortEntryDeserializer extends AbstractMatchEntryDeser
             builder.setLayer4Match(new UdpMatchBuilder()
                     .setUdpDestinationPort(new PortNumber(port))
                     .build());
             builder.setLayer4Match(new UdpMatchBuilder()
                     .setUdpDestinationPort(new PortNumber(port))
                     .build());
-        } else if (UdpMatch.class.isInstance(builder.getLayer4Match())) {
+        } else if (UdpMatch.class.isInstance(builder.getLayer4Match())
+            && Objects.isNull(UdpMatch.class.cast(builder.getLayer4Match()).getUdpDestinationPort())) {
             builder.setLayer4Match(new UdpMatchBuilder(UdpMatch.class.cast(builder.getLayer4Match()))
                     .setUdpDestinationPort(new PortNumber(port))
                     .build());
         } else {
             builder.setLayer4Match(new UdpMatchBuilder(UdpMatch.class.cast(builder.getLayer4Match()))
                     .setUdpDestinationPort(new PortNumber(port))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer4Match");
+            throwErrorOnMalformed(builder, "layer4Match", "udpDestinationPort");
         }
     }
 
         }
     }
 
index adc55a6f585405049b3b727d6b05fea7cbb6fff5..2139d8bccd0d844e23b06b98f49403049be53fca 100644 (file)
@@ -26,12 +26,13 @@ public class UdpSourcePortEntryDeserializer extends AbstractMatchEntryDeserializ
             builder.setLayer4Match(new UdpMatchBuilder()
                     .setUdpSourcePort(new PortNumber(port))
                     .build());
             builder.setLayer4Match(new UdpMatchBuilder()
                     .setUdpSourcePort(new PortNumber(port))
                     .build());
-        } else if (UdpMatch.class.isInstance(builder.getLayer4Match())) {
+        } else if (UdpMatch.class.isInstance(builder.getLayer4Match())
+            && Objects.isNull(UdpMatch.class.cast(builder.getLayer4Match()).getUdpSourcePort())) {
             builder.setLayer4Match(new UdpMatchBuilder(UdpMatch.class.cast(builder.getLayer4Match()))
                     .setUdpSourcePort(new PortNumber(port))
                     .build());
         } else {
             builder.setLayer4Match(new UdpMatchBuilder(UdpMatch.class.cast(builder.getLayer4Match()))
                     .setUdpSourcePort(new PortNumber(port))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "layer4Match");
+            throwErrorOnMalformed(builder, "layer4Match", "udpSourcePort");
         }
     }
 
         }
     }
 
index b728803b6d48501549a76c000a1a5f5f5ebd9988..90a6ad825a493d6eab82bceed1899040412b31e9 100644 (file)
@@ -25,12 +25,12 @@ public class VlanPcpEntryDeserializer extends AbstractMatchEntryDeserializer {
             builder.setVlanMatch(new VlanMatchBuilder()
                     .setVlanPcp(new VlanPcp(pcp))
                     .build());
             builder.setVlanMatch(new VlanMatchBuilder()
                     .setVlanPcp(new VlanPcp(pcp))
                     .build());
-        } else if (Objects.nonNull(builder.getVlanMatch().getVlanPcp())) {
+        } else if (Objects.isNull(builder.getVlanMatch().getVlanPcp())) {
             builder.setVlanMatch(new VlanMatchBuilder(builder.getVlanMatch())
                     .setVlanPcp(new VlanPcp(pcp))
                     .build());
         } else {
             builder.setVlanMatch(new VlanMatchBuilder(builder.getVlanMatch())
                     .setVlanPcp(new VlanPcp(pcp))
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "vlanMatch");
+            throwErrorOnMalformed(builder, "vlanMatch", "vlanPcp");
         }
     }
 
         }
     }
 
index a9f62c41113d10c389e553ae18bd652badbc8ddb..2298b23c4695b336cd39b29456b67919cb2d065c 100644 (file)
@@ -41,12 +41,12 @@ public class VlanVidEntryDeserializer extends AbstractMatchEntryDeserializer {
             builder.setVlanMatch(new VlanMatchBuilder()
                     .setVlanId(vlanIdBuilder.build())
                     .build());
             builder.setVlanMatch(new VlanMatchBuilder()
                     .setVlanId(vlanIdBuilder.build())
                     .build());
-        } else if (Objects.nonNull(builder.getVlanMatch().getVlanId())) {
+        } else if (Objects.isNull(builder.getVlanMatch().getVlanId())) {
             builder.setVlanMatch(new VlanMatchBuilder(builder.getVlanMatch())
                     .setVlanId(vlanIdBuilder.build())
                     .build());
         } else {
             builder.setVlanMatch(new VlanMatchBuilder(builder.getVlanMatch())
                     .setVlanId(vlanIdBuilder.build())
                     .build());
         } else {
-            throwErrorOnMalformed(builder, "vlanMatch");
+            throwErrorOnMalformed(builder, "vlanMatch", "vlanVid");
         }
     }
 
         }
     }
 
index 57a4a350b2149dc68b841832b061b35796014693..97caa46e85f528061cd23f26405207a1e9100a53 100644 (file)
@@ -35,11 +35,11 @@ public class MultipartReplyDescDeserializer implements OFDeserializer<MultipartR
         message.readBytes(dpDescBytes);
 
         return new MultipartReplyDescBuilder()
         message.readBytes(dpDescBytes);
 
         return new MultipartReplyDescBuilder()
-                .setManufacturer(new String(mfrDescBytes))
-                .setHardware(new String(hwDescBytes))
-                .setSoftware(new String(swDescBytes))
-                .setSerialNumber(new String(serialNumBytes))
-                .setDescription(new String(dpDescBytes))
+                .setManufacturer(new String(mfrDescBytes).trim())
+                .setHardware(new String(hwDescBytes).trim())
+                .setSoftware(new String(swDescBytes).trim())
+                .setSerialNumber(new String(serialNumBytes).trim())
+                .setDescription(new String(dpDescBytes).trim())
                 .build();
     }
 
                 .build();
     }
 
index 4a0931dae9e014002f959179489233daf2a2cbb6..cd948ec6ef68fbff7c58b45fb981480c0b349394 100644 (file)
@@ -32,6 +32,7 @@ public class MultipartReplyExperimenterDeserializer implements OFDeserializer<Mu
     private DeserializerRegistry registry;
 
     @Override
     private DeserializerRegistry registry;
 
     @Override
+    @SuppressWarnings("unchecked")
     public MultipartReplyBody deserialize(ByteBuf message) {
         final MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();
         final long expId = message.readUnsignedInt();
     public MultipartReplyBody deserialize(ByteBuf message) {
         final MultipartReplyExperimenterBuilder builder = new MultipartReplyExperimenterBuilder();
         final long expId = message.readUnsignedInt();
index 08eaaa512c05bca4fb3872294f824e37b7d9c5e0..723bc4440a41d16b83b9c33e0514277ba3881c0c 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
 import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder;
@@ -22,9 +23,14 @@ public class MultipartReplyFlowAggregateStatsDeserializer implements OFDeseriali
 
     @Override
     public MultipartReplyBody deserialize(ByteBuf message) {
 
     @Override
     public MultipartReplyBody deserialize(ByteBuf message) {
+        final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        message.readBytes(packetCount);
+        final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+        message.readBytes(byteCount);
+
         final MultipartReplyFlowAggregateStatsBuilder builder = new MultipartReplyFlowAggregateStatsBuilder()
         final MultipartReplyFlowAggregateStatsBuilder builder = new MultipartReplyFlowAggregateStatsBuilder()
-            .setPacketCount(new Counter64(BigInteger.valueOf(message.readLong())))
-            .setByteCount(new Counter64(BigInteger.valueOf(message.readLong())))
+            .setPacketCount(new Counter64(new BigInteger(1, packetCount)))
+            .setByteCount(new Counter64(new BigInteger(1, byteCount)))
             .setFlowCount(new Counter32(message.readUnsignedInt()));
 
         message.skipBytes(PADDING_IN_AGGREGATE_HEADER);
             .setFlowCount(new Counter32(message.readUnsignedInt()));
 
         message.skipBytes(PADDING_IN_AGGREGATE_HEADER);
index 2a3495fee28e3fb57f3e74e03a7f4c49473d4206..5b593bf92860cb263427a363b5f6da1220698d8c 100644 (file)
@@ -17,12 +17,10 @@ import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegi
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
-import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey;
-import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
 import org.opendaylight.openflowplugin.extension.api.path.MatchPath;
-import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeActionExperimenterKey;
 import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeMatchKey;
 import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeMatchKey;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.util.InstructionUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList;
@@ -32,7 +30,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCo
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
@@ -62,7 +59,6 @@ public class MultipartReplyFlowStatsDeserializer implements OFDeserializer<Multi
             itemBuilder.setTableId(itemMessage.readUnsignedByte());
             itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
 
             itemBuilder.setTableId(itemMessage.readUnsignedByte());
             itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
 
-
             itemBuilder
                 .setDuration(new DurationBuilder()
                         .setSecond(new Counter32(itemMessage.readUnsignedInt()))
             itemBuilder
                 .setDuration(new DurationBuilder()
                         .setSecond(new Counter32(itemMessage.readUnsignedInt()))
@@ -75,12 +71,18 @@ public class MultipartReplyFlowStatsDeserializer implements OFDeserializer<Multi
 
             itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
 
 
             itemMessage.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
 
-            itemBuilder
-                .setCookie(new FlowCookie(BigInteger.valueOf(itemMessage.readLong())))
-                .setCookieMask(new FlowCookie(BigInteger.valueOf(itemMessage.readLong())))
-                .setPacketCount(new Counter64(BigInteger.valueOf(itemMessage.readLong())))
-                .setByteCount(new Counter64(BigInteger.valueOf(itemMessage.readLong())));
+            final byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            itemMessage.readBytes(cookie);
+            final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            itemMessage.readBytes(packetCount);
+            final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            itemMessage.readBytes(byteCount);
 
 
+            itemBuilder
+                .setCookie(new FlowCookie(new BigInteger(1, cookie)))
+                .setCookieMask(new FlowCookie(OFConstants.DEFAULT_COOKIE_MASK))
+                .setPacketCount(new Counter64(new BigInteger(1, packetCount)))
+                .setByteCount(new Counter64(new BigInteger(1, byteCount)));
 
             final OFDeserializer<Match> matchDeserializer = registry.getDeserializer(MATCH_KEY);
             itemBuilder.setMatch(new MatchBuilder(matchDeserializer.deserialize(itemMessage)).build());
 
             final OFDeserializer<Match> matchDeserializer = registry.getDeserializer(MATCH_KEY);
             itemBuilder.setMatch(new MatchBuilder(matchDeserializer.deserialize(itemMessage)).build());
@@ -94,38 +96,11 @@ public class MultipartReplyFlowStatsDeserializer implements OFDeserializer<Multi
                 int offset = 0;
 
                 while ((itemMessage.readerIndex() - startIndex) < length) {
                 int offset = 0;
 
                 while ((itemMessage.readerIndex() - startIndex) < length) {
-                    final int type = itemMessage.getUnsignedShort(itemMessage.readerIndex());
-                    OFDeserializer<Instruction> deserializer = null;
-
-                    if (InstructionConstants.APPLY_ACTIONS_TYPE == type) {
-                        deserializer = registry.getDeserializer(
-                                new MessageCodeActionExperimenterKey(
-                                    EncodeConstants.OF13_VERSION_ID, type, Instruction.class,
-                                    ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION,
-                                    null));
-                    } else if (InstructionConstants.WRITE_ACTIONS_TYPE == type) {
-                        deserializer = registry.getDeserializer(
-                                new MessageCodeActionExperimenterKey(
-                                    EncodeConstants.OF13_VERSION_ID, type, Instruction.class,
-                                    ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION,
-                                    null));
-                    } else {
-                        Long expId = null;
-
-                        if (EncodeConstants.EXPERIMENTER_VALUE == type) {
-                            expId = itemMessage.getUnsignedInt(itemMessage.readerIndex() +
-                                    2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-                        }
-
-                        deserializer = registry.getDeserializer(
-                                new MessageCodeExperimenterKey(
-                                    EncodeConstants.OF13_VERSION_ID, type, Instruction.class, expId));
-                    }
-
                     instructions.add(new InstructionBuilder()
                             .setKey(new InstructionKey(offset))
                             .setOrder(offset)
                     instructions.add(new InstructionBuilder()
                             .setKey(new InstructionKey(offset))
                             .setOrder(offset)
-                            .setInstruction(deserializer.deserialize(itemMessage))
+                            .setInstruction(InstructionUtil
+                                .readInstruction(EncodeConstants.OF13_VERSION_ID, itemMessage, registry))
                             .build());
 
                     offset++;
                             .build());
 
                     offset++;
@@ -145,7 +120,7 @@ public class MultipartReplyFlowStatsDeserializer implements OFDeserializer<Multi
     }
 
     private static FlowModFlags createFlowModFlagsFromBitmap(int input) {
     }
 
     private static FlowModFlags createFlowModFlagsFromBitmap(int input) {
-        final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0;
+        final Boolean _oFPFFSENDFLOWREM = (input & (1)) > 0;
         final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;
         final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0;
         final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0;
         final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;
         final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0;
         final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0;
index 6b894c42272654e023b6253bb554ac585f58d9af..01390f887eaca4fdcba5c35458354dc7f39dcb1a 100644 (file)
@@ -13,10 +13,12 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.flow.table.and.statistics.map.FlowTableAndStatisticsMapKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.multipart.reply.multipart.reply.body.MultipartReplyFlowTableStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId;
@@ -36,11 +38,19 @@ public class MultipartReplyFlowTableStatsDeserializer implements OFDeserializer<
 
             message.skipBytes(PADDING_IN_TABLE_HEADER);
 
 
             message.skipBytes(PADDING_IN_TABLE_HEADER);
 
+            itemBuilder
+                .setKey(new FlowTableAndStatisticsMapKey(itemBuilder.getTableId()))
+                .setActiveFlows(new Counter32(message.readUnsignedInt()));
+
+            final byte[] packetsLooked = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(packetsLooked);
+            final byte[] packetsMatched = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(packetsMatched);
+
             items.add(itemBuilder
             items.add(itemBuilder
-                    .setActiveFlows(new Counter32(message.readUnsignedInt()))
-                    .setPacketsLookedUp(new Counter64(BigInteger.valueOf(message.readLong())))
-                    .setPacketsMatched(new Counter64(BigInteger.valueOf(message.readLong())))
-                    .build());
+                .setPacketsLookedUp(new Counter64(new BigInteger(1, packetsLooked)))
+                .setPacketsMatched(new Counter64(new BigInteger(1, packetsMatched)))
+                .build());
         }
 
         return builder
         }
 
         return builder
index 9b01d3b01aac38b84d5c5d4b10febc1f2833a188..abd9df9c86a1f3f9a56b20d79c39c163e37d5739 100644 (file)
@@ -20,13 +20,16 @@ import org.opendaylight.openflowplugin.impl.protocol.deserialization.util.Action
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupDescBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupDescBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStatsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 
 public class MultipartReplyGroupDescDeserializer implements OFDeserializer<MultipartReplyBody>, DeserializerRegistryInjector {
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 
 public class MultipartReplyGroupDescDeserializer implements OFDeserializer<MultipartReplyBody>, DeserializerRegistryInjector {
@@ -54,46 +57,48 @@ public class MultipartReplyGroupDescDeserializer implements OFDeserializer<Multi
             final List<Bucket> subItems = new ArrayList<>();
             int actualLength = GROUP_DESC_HEADER_LENGTH;
 
             final List<Bucket> subItems = new ArrayList<>();
             int actualLength = GROUP_DESC_HEADER_LENGTH;
 
+            long bucketKey = 0;
             while (actualLength < itemLength) {
                 final int bucketsLength = message.readUnsignedShort();
 
                 final BucketBuilder bucketBuilder = new BucketBuilder()
             while (actualLength < itemLength) {
                 final int bucketsLength = message.readUnsignedShort();
 
                 final BucketBuilder bucketBuilder = new BucketBuilder()
+                    .setBucketId(new BucketId(bucketKey))
+                    .setKey(new BucketKey(new BucketId(bucketKey)))
                     .setWeight(message.readUnsignedShort())
                     .setWatchPort(message.readUnsignedInt())
                     .setWatchGroup(message.readUnsignedInt());
 
                     .setWeight(message.readUnsignedShort())
                     .setWatchPort(message.readUnsignedInt())
                     .setWatchGroup(message.readUnsignedInt());
 
-                message.skipBytes(PADDING_IN_BUCKETS_HEADER);
+                bucketKey++;
 
 
-                if (message.readableBytes() > 0) {
-                    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
-                        .Action> actions = new ArrayList<>();
-                    final int startIndex = message.readerIndex();
-                    final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
-                    int offset = 0;
-
-                    while ((message.readerIndex() - startIndex) < bucketLength) {
-                        actions.add(new ActionBuilder()
-                                .setKey(new ActionKey(offset))
-                                .setOrder(offset)
-                                .setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry,
-                                        ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION))
-                                .build());
-
-                        offset++;
-                    }
-
-                    bucketBuilder.setAction(actions);
+                message.skipBytes(PADDING_IN_BUCKETS_HEADER);
+                final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list
+                    .Action> actions = new ArrayList<>();
+                final int startIndex = message.readerIndex();
+                final int bucketLength = bucketsLength - BUCKETS_HEADER_LENGTH;
+                int offset = 0;
+
+                while ((message.readerIndex() - startIndex) < bucketLength) {
+                    actions.add(new ActionBuilder()
+                            .setKey(new ActionKey(offset))
+                            .setOrder(offset)
+                            .setAction(ActionUtil.readAction(EncodeConstants.OF13_VERSION_ID, message, registry,
+                                    ActionPath.GROUPDESCSTATSUPDATED_GROUPDESCSTATS_BUCKETS_BUCKET_ACTION))
+                            .build());
+
+                    offset++;
                 }
 
                 }
 
+                bucketBuilder.setAction(actions);
                 subItems.add(bucketBuilder.build());
                 actualLength += bucketsLength;
             }
 
             items.add(itemBuilder
                 subItems.add(bucketBuilder.build());
                 actualLength += bucketsLength;
             }
 
             items.add(itemBuilder
-                    .setBuckets(new BucketsBuilder()
-                        .setBucket(subItems)
-                        .build())
-                    .build());
+                .setKey(new GroupDescStatsKey(itemBuilder.getGroupId()))
+                .setBuckets(new BucketsBuilder()
+                    .setBucket(subItems)
+                    .build())
+                .build());
         }
 
         return builder
         }
 
         return builder
index a2a85b17109b5da09e6b997b4f8a8610cd441f9a..22ff100a2e13c73d975b3ccbaf23d5db3f98c3c3 100644 (file)
@@ -13,16 +13,20 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyGroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.BucketsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.BucketsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounterKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 
 public class MultipartReplyGroupStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 
 public class MultipartReplyGroupStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
@@ -47,9 +51,15 @@ public class MultipartReplyGroupStatsDeserializer implements OFDeserializer<Mult
 
             message.skipBytes(PADDING_IN_GROUP_HEADER_02);
 
 
             message.skipBytes(PADDING_IN_GROUP_HEADER_02);
 
+            final byte[] packetCountg = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(packetCountg);
+            final byte[] byteCountg = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(byteCountg);
+
             itemBuilder
             itemBuilder
-                .setPacketCount(new Counter64(BigInteger.valueOf(message.readLong())))
-                .setByteCount(new Counter64(BigInteger.valueOf(message.readLong())))
+                .setKey(new GroupStatsKey(itemBuilder.getGroupId()))
+                .setPacketCount(new Counter64(new BigInteger(1, packetCountg)))
+                .setByteCount(new Counter64(new BigInteger(1, byteCountg)))
                 .setDuration(new DurationBuilder()
                         .setSecond(new Counter32(message.readUnsignedInt()))
                         .setNanosecond(new Counter32(message.readUnsignedInt()))
                 .setDuration(new DurationBuilder()
                         .setSecond(new Counter32(message.readUnsignedInt()))
                         .setNanosecond(new Counter32(message.readUnsignedInt()))
@@ -57,13 +67,22 @@ public class MultipartReplyGroupStatsDeserializer implements OFDeserializer<Mult
 
             final List<BucketCounter> subItems = new ArrayList<>();
             int actualLength = GROUP_BODY_LENGTH;
 
             final List<BucketCounter> subItems = new ArrayList<>();
             int actualLength = GROUP_BODY_LENGTH;
+            long bucketKey = 0;
 
             while (actualLength < itemLength) {
 
             while (actualLength < itemLength) {
+                final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+                message.readBytes(packetCount);
+                final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+                message.readBytes(byteCount);
+
                 subItems.add(new BucketCounterBuilder()
                 subItems.add(new BucketCounterBuilder()
-                        .setPacketCount(new Counter64(BigInteger.valueOf(message.readLong())))
-                        .setByteCount(new Counter64(BigInteger.valueOf(message.readLong())))
-                        .build());
+                    .setBucketId(new BucketId(bucketKey))
+                    .setKey(new BucketCounterKey(new BucketId(bucketKey)))
+                    .setPacketCount(new Counter64(new BigInteger(1, packetCount)))
+                    .setByteCount(new Counter64(new BigInteger(1, byteCount)))
+                    .build());
 
 
+                bucketKey++;
                 actualLength += BUCKET_COUNTER_LENGTH;
             }
 
                 actualLength += BUCKET_COUNTER_LENGTH;
             }
 
index d541c1da833f595419226c4f5b2a87b49303fc8c..632a6c769f007700af0da004249cfc07897cfd66 100644 (file)
@@ -26,6 +26,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.MeterBandHeadersBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStatsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.MeterBandHeaderBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.meter.band.headers.meter.band.header.MeterBandTypesBuilder;
@@ -110,10 +111,11 @@ public class MultipartReplyMeterConfigDeserializer implements OFDeserializer<Mul
             }
 
             items.add(itemBuilder
             }
 
             items.add(itemBuilder
-                    .setMeterBandHeaders(new MeterBandHeadersBuilder()
-                        .setMeterBandHeader(subItems)
-                        .build())
-                    .build());
+                .setKey(new MeterConfigStatsKey(itemBuilder.getMeterId()))
+                .setMeterBandHeaders(new MeterBandHeadersBuilder()
+                    .setMeterBandHeader(subItems)
+                    .build())
+                .build());
         }
 
         return builder
         }
 
         return builder
index 14d50d860ea6f2841cb5088b7c28a6cbc64925c9..1ffc8c34c7230e0a172e6ce336eee7378198a46a 100644 (file)
@@ -40,7 +40,7 @@ public class MultipartReplyMeterFeaturesDeserializer implements OFDeserializer<M
     private static List<Class<? extends MeterBand>> readMeterBands(ByteBuf message) {
         final List<Class<? extends MeterBand>> bandTypes = new ArrayList<>();
         final long typesMask = message.readUnsignedInt();
     private static List<Class<? extends MeterBand>> readMeterBands(ByteBuf message) {
         final List<Class<? extends MeterBand>> bandTypes = new ArrayList<>();
         final long typesMask = message.readUnsignedInt();
-        final boolean mbtDROP = (typesMask & (1 << 0)) != 0;
+        final boolean mbtDROP = (typesMask & (1)) != 0;
         final boolean mbtDSCPREMARK = (typesMask & (1 << 1)) != 0;
 
         if (mbtDROP) bandTypes.add(MeterBandDrop.class);
         final boolean mbtDSCPREMARK = (typesMask & (1 << 1)) != 0;
 
         if (mbtDROP) bandTypes.add(MeterBandDrop.class);
@@ -53,7 +53,7 @@ public class MultipartReplyMeterFeaturesDeserializer implements OFDeserializer<M
         final List<Class<? extends MeterCapability>> meterCapabilities = new ArrayList<>();
         final long capabilitiesMask = message.readUnsignedInt();
 
         final List<Class<? extends MeterCapability>> meterCapabilities = new ArrayList<>();
         final long capabilitiesMask = message.readUnsignedInt();
 
-        final boolean mfKBPS = (capabilitiesMask & (1 << 0)) != 0;
+        final boolean mfKBPS = (capabilitiesMask & (1)) != 0;
         final boolean mfPKTPS = (capabilitiesMask & (1 << 1)) != 0;
         final boolean mfBURST = (capabilitiesMask & (1 << 2)) != 0;
         final boolean mfSTATS = (capabilitiesMask & (1 << 3)) != 0;
         final boolean mfPKTPS = (capabilitiesMask & (1 << 1)) != 0;
         final boolean mfBURST = (capabilitiesMask & (1 << 2)) != 0;
         final boolean mfSTATS = (capabilitiesMask & (1 << 3)) != 0;
index 09eb3a47947bfb1108aaa2d843818ad9cba0f15e..74f7c29c768e4876e2cd1fac1a8f1a17f94c89b6 100644 (file)
@@ -13,16 +13,20 @@ import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.BandId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.DurationBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.MeterBandStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStatKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 
 public class MultipartReplyMeterStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 
 public class MultipartReplyMeterStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
@@ -44,9 +48,17 @@ public class MultipartReplyMeterStatsDeserializer implements OFDeserializer<Mult
             message.skipBytes(PADDING_IN_METER_STATS_HEADER);
 
             itemBuilder
             message.skipBytes(PADDING_IN_METER_STATS_HEADER);
 
             itemBuilder
-                .setFlowCount(new Counter32(message.readUnsignedInt()))
-                .setPacketInCount(new Counter64(BigInteger.valueOf(message.readLong())))
-                .setByteInCount(new Counter64(BigInteger.valueOf(message.readLong())))
+                .setKey(new MeterStatsKey(itemBuilder.getMeterId()))
+                .setFlowCount(new Counter32(message.readUnsignedInt()));
+
+            final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(packetCount);
+            final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(byteCount);
+
+            itemBuilder
+                .setPacketInCount(new Counter64(new BigInteger(1, packetCount)))
+                .setByteInCount(new Counter64(new BigInteger(1, byteCount)))
                 .setDuration(new DurationBuilder()
                         .setSecond(new Counter32(message.readUnsignedInt()))
                         .setNanosecond(new Counter32(message.readUnsignedInt()))
                 .setDuration(new DurationBuilder()
                         .setSecond(new Counter32(message.readUnsignedInt()))
                         .setNanosecond(new Counter32(message.readUnsignedInt()))
@@ -54,13 +66,22 @@ public class MultipartReplyMeterStatsDeserializer implements OFDeserializer<Mult
 
             final List<BandStat> subItems = new ArrayList<>();
             int actualLength = METER_BODY_LENGTH;
 
             final List<BandStat> subItems = new ArrayList<>();
             int actualLength = METER_BODY_LENGTH;
+            long bandKey = 0;
 
             while (actualLength < itemLength) {
 
             while (actualLength < itemLength) {
+                final byte[] packetCountB = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+                message.readBytes(packetCountB);
+                final byte[] byteCountB = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+                message.readBytes(byteCountB);
+
                 subItems.add(new BandStatBuilder()
                 subItems.add(new BandStatBuilder()
-                        .setPacketBandCount(new Counter64(BigInteger.valueOf(message.readLong())))
-                        .setByteBandCount(new Counter64(BigInteger.valueOf(message.readLong())))
-                        .build());
+                    .setBandId(new BandId(bandKey))
+                    .setKey(new BandStatKey(new BandId(bandKey)))
+                    .setPacketBandCount(new Counter64(new BigInteger(1, packetCountB)))
+                    .setByteBandCount(new Counter64(new BigInteger(1, byteCountB)))
+                    .build());
 
 
+                bandKey++;
                 actualLength += METER_BAND_STATS_LENGTH;
             }
 
                 actualLength += METER_BAND_STATS_LENGTH;
             }
 
index 34b35b7fb207ff2abe1db729f877e690c1b5dd12..020e8ccadfde46f4697f0ea8339a04281e1b0b10 100644 (file)
@@ -12,7 +12,6 @@ import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Objects;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
@@ -25,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.m
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMapKey;
 
 public class MultipartReplyPortStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
 
 
 public class MultipartReplyPortStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
 
@@ -40,37 +40,58 @@ public class MultipartReplyPortStatsDeserializer implements OFDeserializer<Multi
                 new NodeConnectorStatisticsAndPortNumberMapBuilder();
 
             final long port = message.readUnsignedInt();
                 new NodeConnectorStatisticsAndPortNumberMapBuilder();
 
             final long port = message.readUnsignedInt();
-            final String portName = OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID, port);
-
-            // We do not assign datapath ID here, because we simply do not have it
-            itemBuilder.setNodeConnectorId(new NodeConnectorId(Objects.isNull(portName)
-                        ? String.valueOf(port)
-                        : portName));
+            itemBuilder.setNodeConnectorId(new NodeConnectorId(OpenflowPortsUtil.getProtocolAgnosticPortUri(EncodeConstants.OF13_VERSION_ID, port)));
 
             message.skipBytes(PADDING_IN_PORT_STATS_HEADER);
 
 
             message.skipBytes(PADDING_IN_PORT_STATS_HEADER);
 
+            final byte[] recPack = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(recPack);
+            final byte[] txPack = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(txPack);
+            final byte[] recByt = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(recByt);
+            final byte[] txByt = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(txByt);
+            final byte[] recDrop = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(recDrop);
+            final byte[] txDrop = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(txDrop);
+            final byte[] recError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(recError);
+            final byte[] txError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(txError);
+            final byte[] recFrameError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(recFrameError);
+            final byte[] recOverRunError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(recOverRunError);
+            final byte[] recCrcError = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(recCrcError);
+            final byte[] collisionCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(collisionCount);
+
             items.add(itemBuilder
             items.add(itemBuilder
-                    .setPackets(new PacketsBuilder()
-                        .setReceived(BigInteger.valueOf(message.readLong()))
-                        .setTransmitted(BigInteger.valueOf(message.readLong()))
-                        .build())
-                    .setBytes(new BytesBuilder()
-                        .setReceived(BigInteger.valueOf(message.readLong()))
-                        .setTransmitted(BigInteger.valueOf(message.readLong()))
-                        .build())
-                    .setReceiveDrops(BigInteger.valueOf(message.readLong()))
-                    .setTransmitDrops(BigInteger.valueOf(message.readLong()))
-                    .setReceiveErrors(BigInteger.valueOf(message.readLong()))
-                    .setTransmitErrors(BigInteger.valueOf(message.readLong()))
-                    .setReceiveFrameError(BigInteger.valueOf(message.readLong()))
-                    .setReceiveOverRunError(BigInteger.valueOf((message.readLong())))
-                    .setReceiveCrcError(BigInteger.valueOf((message.readLong())))
-                    .setCollisionCount(BigInteger.valueOf(message.readLong()))
-                    .setDuration(new DurationBuilder()
-                        .setSecond(new Counter32(message.readUnsignedInt()))
-                        .setNanosecond(new Counter32(message.readUnsignedInt()))
-                        .build())
-                    .build());
+                .setKey(new NodeConnectorStatisticsAndPortNumberMapKey(itemBuilder.getNodeConnectorId()))
+                .setPackets(new PacketsBuilder()
+                    .setReceived(new BigInteger(1, recPack))
+                    .setTransmitted(new BigInteger(1, txPack))
+                    .build())
+                .setBytes(new BytesBuilder()
+                    .setReceived(new BigInteger(1, recByt))
+                    .setTransmitted(new BigInteger(1, txByt))
+                    .build())
+                .setReceiveDrops(new BigInteger(1, recDrop))
+                .setTransmitDrops(new BigInteger(1, txDrop))
+                .setReceiveErrors(new BigInteger(1, recError))
+                .setTransmitErrors(new BigInteger(1, txError))
+                .setReceiveFrameError(new BigInteger(1, recFrameError))
+                .setReceiveOverRunError(new BigInteger(1, recOverRunError))
+                .setReceiveCrcError(new BigInteger(1, recCrcError))
+                .setCollisionCount(new BigInteger(1, collisionCount))
+                .setDuration(new DurationBuilder()
+                    .setSecond(new Counter32(message.readUnsignedInt()))
+                    .setNanosecond(new Counter32(message.readUnsignedInt()))
+                    .build())
+                .build());
         }
 
         return builder
         }
 
         return builder
index bb3bc9539c4ec399c351efe20b1315f497d7de68..23d21d32ca412a3b490ec1619b1e494c1308daf3 100644 (file)
@@ -12,7 +12,6 @@ import io.netty.buffer.ByteBuf;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Objects;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
@@ -25,6 +24,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.m
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.multipart.reply.multipart.reply.body.MultipartReplyQueueStatsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMap;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.queue.id.and.statistics.map.QueueIdAndStatisticsMapKey;
 
 public class MultipartReplyQueueStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
 
 
 public class MultipartReplyQueueStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
 
@@ -35,22 +35,28 @@ public class MultipartReplyQueueStatsDeserializer implements OFDeserializer<Mult
 
         while (message.readableBytes() > 0) {
             final long port = message.readUnsignedInt();
 
         while (message.readableBytes() > 0) {
             final long port = message.readUnsignedInt();
-            final String portName = OpenflowPortsUtil.getPortLogicalName(EncodeConstants.OF13_VERSION_ID, port);
+            final NodeConnectorId nodeConnectorId = new NodeConnectorId(OpenflowPortsUtil.getProtocolAgnosticPortUri(EncodeConstants.OF13_VERSION_ID, port));
+            final QueueId queueId = new QueueId(message.readUnsignedInt());
+
+            final byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(txBytes);
+            final byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(txPackets);
+            final byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+            message.readBytes(txErrors);
 
 
-            // We do not assign datapath ID here, because we simply do not have it
             items.add(new QueueIdAndStatisticsMapBuilder()
             items.add(new QueueIdAndStatisticsMapBuilder()
-                    .setNodeConnectorId(new NodeConnectorId(Objects.isNull(portName)
-                            ? String.valueOf(port)
-                            : portName))
-                    .setQueueId(new QueueId(message.readUnsignedInt()))
-                    .setTransmittedBytes(new Counter64(BigInteger.valueOf(message.readLong())))
-                    .setTransmittedPackets(new Counter64(BigInteger.valueOf(message.readLong())))
-                    .setTransmissionErrors(new Counter64(BigInteger.valueOf(message.readLong())))
-                    .setDuration(new DurationBuilder()
-                        .setSecond(new Counter32(message.readUnsignedInt()))
-                        .setNanosecond(new Counter32(message.readUnsignedInt()))
-                        .build())
-                    .build());
+                .setKey(new QueueIdAndStatisticsMapKey(nodeConnectorId, queueId))
+                .setNodeConnectorId(nodeConnectorId)
+                .setQueueId(queueId)
+                .setTransmittedBytes(new Counter64(new BigInteger(1, txBytes)))
+                .setTransmittedPackets(new Counter64(new BigInteger(1, txPackets)))
+                .setTransmissionErrors(new Counter64(new BigInteger(1, txErrors)))
+                .setDuration(new DurationBuilder()
+                    .setSecond(new Counter32(message.readUnsignedInt()))
+                    .setNanosecond(new Counter32(message.readUnsignedInt()))
+                    .build())
+                .build());
         }
 
         return builder
         }
 
         return builder
index 3d7af701cc890105ef41801a88c8c2aed784526c..0e535da16fa7d2252cb18cce135d3f7c6dbf9fd5 100644 (file)
@@ -14,20 +14,16 @@ import java.util.ArrayList;
 import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
 import java.util.List;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector;
-import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory;
 import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowjava.util.ExperimenterDeserializerKeyFactory;
-import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey;
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
-import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeActionExperimenterKey;
 import org.opendaylight.openflowplugin.impl.protocol.deserialization.util.ActionUtil;
 import org.opendaylight.openflowplugin.impl.protocol.deserialization.util.ActionUtil;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.util.InstructionUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
@@ -55,10 +51,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.wildcards.WildcardSetfieldBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TableProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -85,15 +83,22 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
 
             message.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
 
 
             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
             items.add(itemBuilder
-                    .setName(ByteBufUtils.decodeNullTerminatedString(message, MAX_TABLE_NAME_LENGTH))
-                    .setMetadataMatch(BigInteger.valueOf(message.readLong()))
-                    .setMetadataWrite(BigInteger.valueOf(message.readLong()))
-                    .setConfig(readTableConfig(message))
-                    .setMaxEntries(message.readUnsignedInt())
-                    .setTableProperties(readTableProperties(message,
-                            itemLength - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH))
-                    .build());
+                .setKey(new TableFeaturesKey(itemBuilder.getTableId()))
+                .setName(name)
+                .setMetadataMatch(new BigInteger(1, match))
+                .setMetadataWrite(new BigInteger(1, write))
+                .setConfig(readTableConfig(message))
+                .setMaxEntries(message.readUnsignedInt())
+                .setTableProperties(readTableProperties(message,
+                    itemLength - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH))
+                .build());
         }
 
         return builder
         }
 
         return builder
@@ -111,7 +116,7 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
     private final TableProperties readTableProperties(ByteBuf message, int length) {
         final List<TableFeatureProperties> items = new ArrayList<>();
         int tableFeaturesLength = length;
     private final TableProperties readTableProperties(ByteBuf message, int length) {
         final List<TableFeatureProperties> items = new ArrayList<>();
         int tableFeaturesLength = length;
-
+        int order = 0;
         while (tableFeaturesLength > 0) {
             final int propStartIndex = message.readerIndex();
             final TableFeaturesPropType propType = TableFeaturesPropType.forValue(message.readUnsignedShort());
         while (tableFeaturesLength > 0) {
             final int propStartIndex = message.readerIndex();
             final TableFeaturesPropType propType = TableFeaturesPropType.forValue(message.readUnsignedShort());
@@ -119,19 +124,25 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
             final int paddingRemainder = propertyLength % EncodeConstants.PADDING;
             tableFeaturesLength -= propertyLength;
             final int commonPropertyLength = propertyLength - COMMON_PROPERTY_LENGTH;
             final int paddingRemainder = propertyLength % EncodeConstants.PADDING;
             tableFeaturesLength -= propertyLength;
             final int commonPropertyLength = propertyLength - COMMON_PROPERTY_LENGTH;
-            final TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
+            final TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder()
+                .setOrder(order)
+                .setKey(new TableFeaturePropertiesKey(order));
 
             switch (propType) {
                 case OFPTFPTINSTRUCTIONS:
                     propBuilder.setTableFeaturePropType(new InstructionsBuilder()
 
             switch (propType) {
                 case OFPTFPTINSTRUCTIONS:
                     propBuilder.setTableFeaturePropType(new InstructionsBuilder()
-                            .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.InstructionsBuilder()
+                            .setInstructions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
+                                .rev131026.table.feature.prop.type.table.feature.prop.type.instructions
+                                .InstructionsBuilder()
                                 .setInstruction(readInstructions(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTINSTRUCTIONSMISS:
                     propBuilder.setTableFeaturePropType(new InstructionsMissBuilder()
                                 .setInstruction(readInstructions(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTINSTRUCTIONSMISS:
                     propBuilder.setTableFeaturePropType(new InstructionsMissBuilder()
-                            .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss.InstructionsMissBuilder()
+                            .setInstructionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
+                                .rev131026.table.feature.prop.type.table.feature.prop.type.instructions.miss
+                                .InstructionsMissBuilder()
                                 .setInstruction(readInstructions(message, commonPropertyLength))
                                 .build())
                             .build());
                                 .setInstruction(readInstructions(message, commonPropertyLength))
                                 .build())
                             .build());
@@ -152,28 +163,34 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
                     break;
                 case OFPTFPTWRITEACTIONS:
                     propBuilder.setTableFeaturePropType(new WriteActionsBuilder()
                     break;
                 case OFPTFPTWRITEACTIONS:
                     propBuilder.setTableFeaturePropType(new WriteActionsBuilder()
-                            .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
+                            .setWriteActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026
+                                .table.feature.prop.type.table.feature.prop.type.write.actions.WriteActionsBuilder()
                                 .setAction(readActions(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTWRITEACTIONSMISS:
                     propBuilder.setTableFeaturePropType(new WriteActionsMissBuilder()
                                 .setAction(readActions(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTWRITEACTIONSMISS:
                     propBuilder.setTableFeaturePropType(new WriteActionsMissBuilder()
-                            .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss.WriteActionsMissBuilder()
+                            .setWriteActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
+                                .rev131026.table.feature.prop.type.table.feature.prop.type.write.actions.miss
+                                .WriteActionsMissBuilder()
                                 .setAction(readActions(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTAPPLYACTIONS:
                     propBuilder.setTableFeaturePropType(new ApplyActionsBuilder()
                                 .setAction(readActions(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTAPPLYACTIONS:
                     propBuilder.setTableFeaturePropType(new ApplyActionsBuilder()
-                            .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
+                            .setApplyActions(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026
+                                .table.feature.prop.type.table.feature.prop.type.apply.actions.ApplyActionsBuilder()
                                 .setAction(readActions(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTAPPLYACTIONSMISS:
                     propBuilder.setTableFeaturePropType(new ApplyActionsMissBuilder()
                                 .setAction(readActions(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTAPPLYACTIONSMISS:
                     propBuilder.setTableFeaturePropType(new ApplyActionsMissBuilder()
-                            .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss.ApplyActionsMissBuilder()
+                            .setApplyActionsMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
+                                .rev131026.table.feature.prop.type.table.feature.prop.type.apply.actions.miss
+                                .ApplyActionsMissBuilder()
                                 .setAction(readActions(message, commonPropertyLength))
                                 .build())
                             .build());
                                 .setAction(readActions(message, commonPropertyLength))
                                 .build())
                             .build());
@@ -194,28 +211,34 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
                     break;
                 case OFPTFPTWRITESETFIELD:
                     propBuilder.setTableFeaturePropType(new WriteSetfieldBuilder()
                     break;
                 case OFPTFPTWRITESETFIELD:
                     propBuilder.setTableFeaturePropType(new WriteSetfieldBuilder()
-                            .setWriteSetfield(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder()
+                            .setWriteSetfield(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026
+                                .table.feature.prop.type.table.feature.prop.type.write.setfield.WriteSetfieldBuilder()
                                 .setSetFieldMatch(readMatchFields(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTWRITESETFIELDMISS:
                     propBuilder.setTableFeaturePropType(new WriteSetfieldMissBuilder()
                                 .setSetFieldMatch(readMatchFields(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTWRITESETFIELDMISS:
                     propBuilder.setTableFeaturePropType(new WriteSetfieldMissBuilder()
-                            .setWriteSetfieldMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss.WriteSetfieldMissBuilder()
+                            .setWriteSetfieldMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
+                                .rev131026.table.feature.prop.type.table.feature.prop.type.write.setfield.miss
+                                .WriteSetfieldMissBuilder()
                                 .setSetFieldMatch(readMatchFields(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTAPPLYSETFIELD:
                     propBuilder.setTableFeaturePropType(new ApplySetfieldBuilder()
                                 .setSetFieldMatch(readMatchFields(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTAPPLYSETFIELD:
                     propBuilder.setTableFeaturePropType(new ApplySetfieldBuilder()
-                            .setApplySetfield(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder()
+                            .setApplySetfield(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026
+                                .table.feature.prop.type.table.feature.prop.type.apply.setfield.ApplySetfieldBuilder()
                                 .setSetFieldMatch(readMatchFields(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTAPPLYSETFIELDMISS:
                     propBuilder.setTableFeaturePropType(new ApplySetfieldMissBuilder()
                                 .setSetFieldMatch(readMatchFields(message, commonPropertyLength))
                                 .build())
                             .build());
                     break;
                 case OFPTFPTAPPLYSETFIELDMISS:
                     propBuilder.setTableFeaturePropType(new ApplySetfieldMissBuilder()
-                            .setApplySetfieldMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss.ApplySetfieldMissBuilder()
+                            .setApplySetfieldMiss(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types
+                                .rev131026.table.feature.prop.type.table.feature.prop.type.apply.setfield.miss
+                                .ApplySetfieldMissBuilder()
                                 .setSetFieldMatch(readMatchFields(message, commonPropertyLength))
                                 .build())
                             .build());
                                 .setSetFieldMatch(readMatchFields(message, commonPropertyLength))
                                 .build())
                             .build());
@@ -243,6 +266,7 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
             }
 
             items.add(propBuilder.build());
             }
 
             items.add(propBuilder.build());
+            order++;
         }
 
 
         }
 
 
@@ -259,8 +283,11 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
         while ((message.readerIndex() - startIndex) < length) {
             MATCH_FIELD_DESERIALIZER
                 .deserialize(message)
         while ((message.readerIndex() - startIndex) < length) {
             MATCH_FIELD_DESERIALIZER
                 .deserialize(message)
-                .ifPresent(matchField -> matchFields.add(matchField));
-            message.getUnsignedByte(message.readerIndex());
+                .map(matchFields::add)
+                .orElseGet(() -> {
+                    message.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+                    return Boolean.FALSE;
+                });
         }
 
         return matchFields;
         }
 
         return matchFields;
@@ -268,10 +295,11 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
 
     private List<Short> readNextTableIds(ByteBuf message, int length) {
         final List<Short> tableIds = new ArrayList<>();
 
     private List<Short> readNextTableIds(ByteBuf message, int length) {
         final List<Short> tableIds = new ArrayList<>();
+        int nextTableLength = length;
 
 
-        while (length > 0) {
+        while (nextTableLength > 0) {
             tableIds.add(message.readUnsignedByte());
             tableIds.add(message.readUnsignedByte());
-            length--;
+            nextTableLength -= 1;
         }
 
         return tableIds;
         }
 
         return tableIds;
@@ -286,41 +314,18 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
         int offset = 0;
 
         while ((message.readerIndex() - startIndex) < length) {
         int offset = 0;
 
         while ((message.readerIndex() - startIndex) < length) {
-            final int type = message.getUnsignedShort(message.readerIndex());
-            HeaderDeserializer<Instruction> deserializer = null;
-
-            if (InstructionConstants.APPLY_ACTIONS_TYPE == type) {
-                deserializer = registry.getDeserializer(
-                        new MessageCodeActionExperimenterKey(
-                            EncodeConstants.OF13_VERSION_ID, type, Instruction.class,
-                            ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION,
-                            null));
-            } else if (InstructionConstants.WRITE_ACTIONS_TYPE == type) {
-                deserializer = registry.getDeserializer(
-                        new MessageCodeActionExperimenterKey(
-                            EncodeConstants.OF13_VERSION_ID, type, Instruction.class,
-                            ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION,
-                            null));
-            } else {
-                Long expId = null;
-
-                if (EncodeConstants.EXPERIMENTER_VALUE == type) {
-                    expId = message.getUnsignedInt(message.readerIndex() +
-                            2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-                }
-
-                deserializer = registry.getDeserializer(
-                        new MessageCodeExperimenterKey(
-                            EncodeConstants.OF13_VERSION_ID, type, Instruction.class, expId));
-            }
-
-            instructions.add(new InstructionBuilder()
+            try {
+                instructions.add(new InstructionBuilder()
                     .setKey(new InstructionKey(offset))
                     .setOrder(offset)
                     .setKey(new InstructionKey(offset))
                     .setOrder(offset)
-                    .setInstruction(deserializer.deserializeHeader(message))
+                    .setInstruction(InstructionUtil
+                        .readInstructionHeader(EncodeConstants.OF13_VERSION_ID, message, registry))
                     .build());
 
                     .build());
 
-            offset++;
+                offset++;
+            } catch (ClassCastException | IllegalStateException e) {
+                message.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            }
         }
 
         return instructions;
         }
 
         return instructions;
@@ -343,7 +348,6 @@ public class MultipartReplyTableFeaturesDeserializer implements OFDeserializer<M
                 offset++;
             } catch (ClassCastException | IllegalStateException e) {
                 message.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
                 offset++;
             } catch (ClassCastException | IllegalStateException e) {
                 message.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-                continue;
             }
         }
 
             }
         }
 
index f60ed59f3b4858e2e1bf895a7621f7d7453f4b7d..257d6e9a5eb16cdf6e3ca38479f856d71bce9ae8 100644 (file)
@@ -229,19 +229,34 @@ public class TableFeaturesMatchFieldDeserializer {
                     OxmMatchConstants.NXM_NX_TCP_FLAG), TcpFlags.class)
         .build();
 
                     OxmMatchConstants.NXM_NX_TCP_FLAG), TcpFlags.class)
         .build();
 
+/**
+     * Processes match entry header and returns if it have mask, or not
+     * @param in input buffer
+     * @return SetFieldMatchBuilder with hasMask properly set
+     */
+    protected static SetFieldMatchBuilder processHeader(ByteBuf in) {
+        in.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); // skip oxm_class
+        boolean hasMask = (in.readUnsignedByte() & 1) != 0;
+        in.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); // skip match entry length
+
+        return new SetFieldMatchBuilder()
+            .setHasMask(hasMask);
+    }
+
     /**
      * Deserialize match field if deserializer supports it, otherwise returns empty optional
      * @param message input buffer
      * @return set field match
      */
     public Optional<SetFieldMatch> deserialize(ByteBuf message) {
     /**
      * Deserialize match field if deserializer supports it, otherwise returns empty optional
      * @param message input buffer
      * @return set field match
      */
     public Optional<SetFieldMatch> deserialize(ByteBuf message) {
-        int oxmClass = message.readUnsignedShort();
-        int oxmFieldAndMask = message.readUnsignedByte();
-        int oxmField = oxmFieldAndMask >>> 1;
+        int oxmClass = message.getUnsignedShort(message.readerIndex());
+        int oxmField = message.getUnsignedByte(message.readerIndex()
+                + EncodeConstants.SIZE_OF_SHORT_IN_BYTES) >>> 1;
         Long expId = null;
 
         if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
         Long expId = null;
 
         if (oxmClass == EncodeConstants.EXPERIMENTER_VALUE) {
-            expId = message.getUnsignedInt(message.readerIndex());
+            expId = message.getUnsignedInt(message.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES
+                    + 2 * EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
         }
 
         final MatchEntryDeserializerKey key =
         }
 
         final MatchEntryDeserializerKey key =
@@ -251,10 +266,8 @@ public class TableFeaturesMatchFieldDeserializer {
 
         return Optional
             .ofNullable(CODE_TO_FIELD.get(key))
 
         return Optional
             .ofNullable(CODE_TO_FIELD.get(key))
-            .map(clazz -> new SetFieldMatchBuilder()
-                    .setHasMask((oxmFieldAndMask & 1) != 0)
+            .map(clazz -> processHeader(message)
                     .setKey(new SetFieldMatchKey(clazz))
                     .setMatchType(clazz)
                     .build());
                     .setKey(new SetFieldMatchKey(clazz))
                     .setMatchType(clazz)
                     .build());
-    }
-}
+    }}
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/util/InstructionUtil.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/protocol/deserialization/util/InstructionUtil.java
new file mode 100644 (file)
index 0000000..e66a65c
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the 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.util;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
+import org.opendaylight.openflowjava.protocol.api.extensibility.HeaderDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.impl.util.InstructionConstants;
+import org.opendaylight.openflowplugin.api.openflow.protocol.deserialization.MessageCodeExperimenterKey;
+import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
+import org.opendaylight.openflowplugin.impl.protocol.deserialization.key.MessageCodeActionExperimenterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
+
+/**
+ * Utility class for action deserialization
+ */
+public class InstructionUtil {
+
+    /**
+     * Deserialize OpenFlow instruction
+     *
+     * @param version OpenFlow version
+     * @param message OpenFlow buffered message
+     * @param registry deserializer registry
+     */
+    public static Instruction readInstruction(final short version,
+                                              final ByteBuf message,
+                                              final DeserializerRegistry registry) {
+        final int type = message.getUnsignedShort(message.readerIndex());
+        final OFDeserializer<Instruction> deserializer;
+
+        if (InstructionConstants.APPLY_ACTIONS_TYPE == type) {
+            deserializer = registry.getDeserializer(
+                new MessageCodeActionExperimenterKey(
+                    version, type, Instruction.class,
+                    ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION,
+                    null));
+        } else if (InstructionConstants.WRITE_ACTIONS_TYPE == type) {
+            deserializer = registry.getDeserializer(
+                new MessageCodeActionExperimenterKey(
+                    version, type, Instruction.class,
+                    ActionPath.FLOWSSTATISTICSUPDATE_FLOWANDSTATISTICSMAPLIST_INSTRUCTIONS_INSTRUCTION_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION,
+                    null));
+        } else {
+            Long expId = null;
+
+            if (EncodeConstants.EXPERIMENTER_VALUE == type) {
+                expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            }
+
+            deserializer = registry.getDeserializer(
+                new MessageCodeExperimenterKey(
+                    version, type, Instruction.class, expId));
+        }
+
+        return deserializer.deserialize(message);
+    }
+
+    /**
+     * Deserialize OpenFlow instruction header
+     *
+     * @param version OpenFlow version
+     * @param message OpenFlow buffered message
+     * @param registry deserializer registry
+     */
+    public static Instruction readInstructionHeader(final short version,
+                                                    final ByteBuf message,
+                                                    final DeserializerRegistry registry) {
+        final int type = message.getUnsignedShort(message.readerIndex());
+        final HeaderDeserializer<Instruction> deserializer;
+
+        if (InstructionConstants.APPLY_ACTIONS_TYPE == type) {
+            deserializer = registry.getDeserializer(
+                new MessageCodeActionExperimenterKey(
+                    version, type, Instruction.class,
+                    ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_APPLYACTIONSCASE_APPLYACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION,
+                    null));
+        } else if (InstructionConstants.WRITE_ACTIONS_TYPE == type) {
+            deserializer = registry.getDeserializer(
+                new MessageCodeActionExperimenterKey(
+                    version, type, Instruction.class,
+                    ActionPath.NODES_NODE_TABLE_FLOW_INSTRUCTIONS_INSTRUCTION_WRITEACTIONSCASE_WRITEACTIONS_ACTION_ACTION_EXTENSIONLIST_EXTENSION,
+                    null));
+        } else {
+            Long expId = null;
+
+            if (EncodeConstants.EXPERIMENTER_VALUE == type) {
+                expId = message.getUnsignedInt(message.readerIndex() + 2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            }
+
+            deserializer = registry.getDeserializer(
+                new MessageCodeExperimenterKey(
+                    version, type, Instruction.class, expId));
+        }
+
+        return deserializer.deserializeHeader(message);
+    }
+
+}
index 8c8cabac660319053b9b140b05e4620cac5cd5f2..d241db34cb6c072eebb11cf564814f66265ad242 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
 
 package org.opendaylight.openflowplugin.impl.protocol.serialization.actions;
 
+import com.google.common.base.MoreObjects;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.openflowjava.protocol.impl.util.ActionConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
@@ -24,7 +25,7 @@ public class OutputActionSerializer extends AbstractActionSerializer {
         outBuffer.writeInt(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
                 OpenflowVersion.OF13,
                 outputAction.getOutputNodeConnector().getValue()).intValue());
         outBuffer.writeInt(InventoryDataServiceUtil.portNumberfromNodeConnectorId(
                 OpenflowVersion.OF13,
                 outputAction.getOutputNodeConnector().getValue()).intValue());
-        outBuffer.writeShort(outputAction.getMaxLength());
+        outBuffer.writeShort(MoreObjects.firstNonNull(outputAction.getMaxLength(), 0));
         outBuffer.writeZero(ActionConstants.OUTPUT_PADDING);
     }
 
         outBuffer.writeZero(ActionConstants.OUTPUT_PADDING);
     }
 
index 4b0f6681ef6beb26d30fb43d21f4986b17f5f1b7..603f59bf102bba9074e47393921980f391835b9b 100644 (file)
@@ -19,7 +19,7 @@ public class SetQueueActionSerializer extends AbstractActionSerializer {
     public void serialize(Action action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
         final SetQueueAction setQueueAction = SetQueueActionCase.class.cast(action).getSetQueueAction();
     public void serialize(Action action, ByteBuf outBuffer) {
         super.serialize(action, outBuffer);
         final SetQueueAction setQueueAction = SetQueueActionCase.class.cast(action).getSetQueueAction();
-        outBuffer.writeByte(setQueueAction.getQueueId().intValue());
+        outBuffer.writeInt(setQueueAction.getQueueId().intValue());
     }
 
     @Override
     }
 
     @Override
index b6d7eb61c3a568aa7db2c17e3c2e35abd04ab818..7712dbecffbf1e1ed4819f964f4d8a8df932cc35 100644 (file)
@@ -80,9 +80,11 @@ public class MatchSerializer implements OFSerializer<Match>, HeaderSerializer<Ma
         }
 
         // Serialize match entries
         }
 
         // Serialize match entries
-        entryRegistry.values().stream()
-                .filter(entry -> entry.matchTypeCheck(match))
-                .forEach(entry -> entry.serialize(match, outBuffer));
+        entryRegistry.entrySet().forEach(entry -> {
+            if (entry.getValue().matchTypeCheck(match)) {
+                entry.getValue().serialize(match, outBuffer);
+            }
+        });
 
         // Serialize match extensions
         ExtensionResolvers.getMatchExtensionResolver().getExtension(match).transform(extensions -> {
 
         // Serialize match extensions
         ExtensionResolvers.getMatchExtensionResolver().getExtension(match).transform(extensions -> {
index 7050c0780c37e8b3e20feb69064485329b3360ad..2d7cf3708d6267dbe98a3358f5133cf29f5bfd3c 100644 (file)
@@ -18,7 +18,6 @@ import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.stream.Collectors;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
@@ -53,7 +52,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instru
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.IpMatchFields;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
@@ -101,7 +99,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer<FlowMessage
 
     @Override
     public void serialize(FlowMessage message, ByteBuf outBuffer) {
 
     @Override
     public void serialize(FlowMessage message, ByteBuf outBuffer) {
-        if (isSetVlanIdActionCasePresent(message)) {
+        if (!isVlanMatchPresent(message) && isSetVlanIdActionCasePresent(message)) {
             writeVlanFlow(message, outBuffer);
         } else {
             writeFlow(message, outBuffer);
             writeVlanFlow(message, outBuffer);
         } else {
             writeFlow(message, outBuffer);
@@ -134,6 +132,33 @@ public class FlowMessageSerializer extends AbstractMessageSerializer<FlowMessage
         outBuffer.setShort(index + 2, outBuffer.writerIndex() - index);
     }
 
         outBuffer.setShort(index + 2, outBuffer.writerIndex() - index);
     }
 
+    /**
+     * Instead of serializing this flow normally, we need to split it to two parts if flow contains
+     * #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase}
+     * @param message flow mod message
+     * @param outBuffer output buffer
+     */
+    private void writeVlanFlow(final FlowMessage message, final ByteBuf outBuffer) {
+        writeFlow(
+            new FlowMessageBuilder(message)
+                .setMatch(new MatchBuilder(message.getMatch())
+                    .setVlanMatch(VLAN_MATCH_FALSE)
+                    .build())
+                .setInstructions(new InstructionsBuilder()
+                    .setInstruction(updateSetVlanIdAction(message))
+                    .build())
+                .build(),
+            outBuffer);
+
+        writeFlow(
+            new FlowMessageBuilder(message)
+                .setMatch(new MatchBuilder(message.getMatch())
+                    .setVlanMatch(VLAN_MATCH_TRUE)
+                    .build())
+                .build(),
+            outBuffer);
+    }
+
     /**
      * Serialize OpenFlowPlugin match to raw bytes
      * @param message OpenFlow flow mod message
     /**
      * Serialize OpenFlowPlugin match to raw bytes
      * @param message OpenFlow flow mod message
@@ -156,7 +181,7 @@ public class FlowMessageSerializer extends AbstractMessageSerializer<FlowMessage
         final Optional<Short> protocol = Optional
                 .ofNullable(message.getMatch())
                 .flatMap(m -> Optional.ofNullable(m.getIpMatch()))
         final Optional<Short> protocol = Optional
                 .ofNullable(message.getMatch())
                 .flatMap(m -> Optional.ofNullable(m.getIpMatch()))
-                .map(IpMatchFields::getIpProtocol);
+                .flatMap(ipm -> Optional.ofNullable(ipm.getIpProtocol()));
 
         // Update instructions if needed and then serialize all instructions
         Optional.ofNullable(message.getInstructions())
 
         // Update instructions if needed and then serialize all instructions
         Optional.ofNullable(message.getInstructions())
@@ -184,15 +209,18 @@ public class FlowMessageSerializer extends AbstractMessageSerializer<FlowMessage
      */
     private static Optional<Instruction> updateInstruction(final Instruction instruction, final Short protocol) {
         if( ApplyActionsCase.class.isInstance(instruction)) {
      */
     private static Optional<Instruction> updateInstruction(final Instruction instruction, final Short protocol) {
         if( ApplyActionsCase.class.isInstance(instruction)) {
-            return Optional.ofNullable(ApplyActionsCase.class.cast(instruction).getApplyActions())
-                    .flatMap(aa -> Optional.ofNullable(aa.getAction()))
-                    .map(as -> (Instruction) new ApplyActionsCaseBuilder()
-                            .setApplyActions(new ApplyActionsBuilder()
-                                    .setAction(as.stream()
-                                            .map(a -> updateSetTpActions(a, protocol))
-                                            .collect(Collectors.toList()))
-                                    .build())
-                            .build());
+            return Optional
+                .ofNullable(ApplyActionsCase.class.cast(instruction).getApplyActions())
+                .flatMap(aa -> Optional.ofNullable(aa.getAction()))
+                .map(as -> new ApplyActionsCaseBuilder()
+                    .setApplyActions(new ApplyActionsBuilder()
+                        .setAction(as
+                            .stream()
+                            .filter(Objects::nonNull)
+                            .map(a -> updateSetTpActions(a, protocol))
+                            .collect(Collectors.toList()))
+                        .build())
+                    .build());
         }
 
         return Optional.empty();
         }
 
         return Optional.empty();
@@ -233,44 +261,6 @@ public class FlowMessageSerializer extends AbstractMessageSerializer<FlowMessage
         return action;
     }
 
         return action;
     }
 
-
-    /**
-     * Instead of serializing this flow normally, we need to split it to two parts if flow contains
-     * #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase}
-     * @param message flow mod message
-     * @param outBuffer output buffer
-     */
-    private void writeVlanFlow(final FlowMessage message, final ByteBuf outBuffer) {
-        Optional.ofNullable(message.getMatch())
-                .ifPresent(match -> Optional.ofNullable(match.getVlanMatch())
-                        .map(v -> Stream.of(
-                                new FlowMessageBuilder(message)
-                                        .setMatch(new MatchBuilder(match)
-                                                .setVlanMatch(new VlanMatchBuilder(v)
-                                                        .setVlanId(new VlanIdBuilder()
-                                                                .setVlanIdPresent(v.getVlanId().isVlanIdPresent())
-                                                                .setVlanId(v.getVlanId().getVlanId())
-                                                                .build())
-                                                        .build())
-                                                .build())
-                                        .build())
-                        ).orElseGet(() -> Stream.of(
-                                new FlowMessageBuilder(message)
-                                        .setMatch(new MatchBuilder(match)
-                                                .setVlanMatch(VLAN_MATCH_FALSE)
-                                                .build())
-                                        .setInstructions(new InstructionsBuilder()
-                                                .setInstruction(updateSetVlanIdAction(message))
-                                                .build())
-                                        .build(),
-                                new FlowMessageBuilder(message)
-                                        .setMatch(new MatchBuilder(match)
-                                                .setVlanMatch(VLAN_MATCH_TRUE)
-                                                .build())
-                                        .build())
-                        ).forEach(m -> writeFlow(m, outBuffer)));
-    }
-
     /**
      * Create copy of instructions of original flow but insert #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase}
      * before each #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase}
     /**
      * Create copy of instructions of original flow but insert #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase}
      * before each #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase}
@@ -345,6 +335,18 @@ public class FlowMessageSerializer extends AbstractMessageSerializer<FlowMessage
                 flags.isNOBYTCOUNTS());
     }
 
                 flags.isNOBYTCOUNTS());
     }
 
+    /**
+     * Determine if flow contains vlan match
+     * @param flow flow
+     * @return true if flow contains vlan match
+     */
+    private static boolean isVlanMatchPresent(final Flow flow) {
+        return Optional
+            .ofNullable(flow.getMatch())
+            .flatMap(m -> Optional.ofNullable(m.getVlanMatch()))
+            .isPresent();
+    }
+
     /**
      * Determine if flow contains #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase}
      * instruction with #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase} action
     /**
      * Determine if flow contains #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase}
      * instruction with #{@link org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCase} action
index 7ac412f3a5d60ef4ed924c499234bd5bd2c9da26..768b5c48a87bd1d44ef0e9ea66cd0e1823df814f 100644 (file)
@@ -15,11 +15,11 @@ import java.util.Optional;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
-import org.opendaylight.openflowjava.util.ByteBufUtils;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.impl.protocol.serialization.util.ActionUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.impl.protocol.serialization.util.ActionUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupModCommand;
 
 /**
  * Translates GroupMod messages.
 
 /**
  * Translates GroupMod messages.
@@ -38,6 +38,7 @@ public class GroupMessageSerializer extends AbstractMessageSerializer<GroupMessa
 
     @Override
     public void serialize(GroupMessage message, ByteBuf outBuffer) {
 
     @Override
     public void serialize(GroupMessage message, ByteBuf outBuffer) {
+        int index = outBuffer.writerIndex();
         super.serialize(message, outBuffer);
         outBuffer.writeShort(message.getCommand().getIntValue());
         outBuffer.writeByte(message.getGroupType().getIntValue());
         super.serialize(message, outBuffer);
         outBuffer.writeShort(message.getCommand().getIntValue());
         outBuffer.writeByte(message.getGroupType().getIntValue());
@@ -45,28 +46,29 @@ public class GroupMessageSerializer extends AbstractMessageSerializer<GroupMessa
         outBuffer.writeInt(message.getGroupId().getValue().intValue());
 
         Optional.ofNullable(message.getBuckets())
         outBuffer.writeInt(message.getGroupId().getValue().intValue());
 
         Optional.ofNullable(message.getBuckets())
-                .flatMap(b -> Optional.ofNullable(b.getBucket()))
-                .ifPresent(b -> b.stream()
-                        .sorted(COMPARATOR)
-                        .forEach(bucket -> {
-                            int index = outBuffer.writerIndex();
-                            outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
-                            outBuffer.writeShort(MoreObjects.firstNonNull(bucket.getWeight(), 0));
-                            outBuffer.writeInt(MoreObjects.firstNonNull(bucket.getWatchPort(), OFConstants.OFPG_ANY).intValue());
-                            outBuffer.writeInt(MoreObjects.firstNonNull(bucket.getWatchGroup(), OFConstants.OFPG_ANY).intValue());
-                            outBuffer.writeZero(PADDING_IN_BUCKET);
+            .filter(b -> !GroupModCommand.OFPGCDELETE.equals(message.getCommand()))
+            .flatMap(b -> Optional.ofNullable(b.getBucket()))
+            .ifPresent(b -> b.stream()
+                .sorted(COMPARATOR)
+                .forEach(bucket -> {
+                    int bucketIndex = outBuffer.writerIndex();
+                    outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
+                    outBuffer.writeShort(MoreObjects.firstNonNull(bucket.getWeight(), 0));
+                    outBuffer.writeInt(MoreObjects.firstNonNull(bucket.getWatchPort(), OFConstants.OFPG_ANY).intValue());
+                    outBuffer.writeInt(MoreObjects.firstNonNull(bucket.getWatchGroup(), OFConstants.OFPG_ANY).intValue());
+                    outBuffer.writeZero(PADDING_IN_BUCKET);
 
 
-                            Optional.ofNullable(bucket.getAction()).ifPresent(as -> as.forEach(a ->
-                                    ActionUtil.writeAction(
-                                            a.getAction(),
-                                            OFConstants.OFP_VERSION_1_3,
-                                            registry,
-                                            outBuffer)));
+                    Optional.ofNullable(bucket.getAction()).ifPresent(as -> as.forEach(a ->
+                        ActionUtil.writeAction(
+                            a.getAction(),
+                            OFConstants.OFP_VERSION_1_3,
+                            registry,
+                            outBuffer)));
 
 
-                            outBuffer.setShort(index, outBuffer.writerIndex() - index);
-                        }));
+                    outBuffer.setShort(bucketIndex, outBuffer.writerIndex() - bucketIndex);
+                }));
 
 
-        ByteBufUtils.updateOFHeaderLength(outBuffer);
+        outBuffer.setShort(index + 2, outBuffer.writerIndex() - index);
     }
 
     @Override
     }
 
     @Override
index 404a9d573a2c0c58b1514b5de6c1028f2f50a466..cbc5ed4aa9bcc92ca7c19848597a51e0e69254bf 100644 (file)
@@ -42,13 +42,14 @@ public class MeterMessageSerializer extends AbstractMessageSerializer<MeterMessa
 
     @Override
     public void serialize(final MeterMessage message, final ByteBuf outBuffer) {
 
     @Override
     public void serialize(final MeterMessage message, final ByteBuf outBuffer) {
+        int index = outBuffer.writerIndex();
         super.serialize(message, outBuffer);
         outBuffer.writeShort(message.getCommand().getIntValue());
         outBuffer.writeShort(createMeterFlagsBitMask(
                 MoreObjects.firstNonNull(message.getFlags(), new MeterFlags(false, false, true, false))));
         outBuffer.writeInt(message.getMeterId().getValue().intValue());
         serializeBands(message.getMeterBandHeaders(), outBuffer);
         super.serialize(message, outBuffer);
         outBuffer.writeShort(message.getCommand().getIntValue());
         outBuffer.writeShort(createMeterFlagsBitMask(
                 MoreObjects.firstNonNull(message.getFlags(), new MeterFlags(false, false, true, false))));
         outBuffer.writeInt(message.getMeterId().getValue().intValue());
         serializeBands(message.getMeterBandHeaders(), outBuffer);
-        ByteBufUtils.updateOFHeaderLength(outBuffer);
+        outBuffer.setShort(index + 2, outBuffer.writerIndex() - index);
     }
 
     @Override
     }
 
     @Override
index c098ab51271d66f488089eb930dca1e8287554dd..9f4b7822865cf7f357403c058f4a6b4e90b51445 100644 (file)
@@ -29,6 +29,7 @@ public class PortMessageSerializer extends AbstractMessageSerializer<PortMessage
 
     @Override
     public void serialize(final PortMessage message, final ByteBuf outBuffer) {
 
     @Override
     public void serialize(final PortMessage message, final ByteBuf outBuffer) {
+        int index = outBuffer.writerIndex();
         super.serialize(message, outBuffer);
         outBuffer.writeInt(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.OF13, message.getPortNumber()).intValue());
         outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01);
         super.serialize(message, outBuffer);
         outBuffer.writeInt(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.OF13, message.getPortNumber()).intValue());
         outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_01);
@@ -39,7 +40,7 @@ public class PortMessageSerializer extends AbstractMessageSerializer<PortMessage
         outBuffer.writeInt(portConfigBitMask); // Configuration mask
         outBuffer.writeInt(createPortFeaturesBitMask(message.getAdvertisedFeatures()));
         outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_03);
         outBuffer.writeInt(portConfigBitMask); // Configuration mask
         outBuffer.writeInt(createPortFeaturesBitMask(message.getAdvertisedFeatures()));
         outBuffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_03);
-        ByteBufUtils.updateOFHeaderLength(outBuffer);
+        outBuffer.setShort(index + 2, outBuffer.writerIndex() - index);
     }
 
     @Override
     }
 
     @Override
index 7169edb02e0197f9cfd02953305e9ecfbd21476a..f2bc24bf8f4521df185627c2430f41df9b4c0a92 100644 (file)
@@ -26,11 +26,15 @@ import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.ExtensionKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionGrouping;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Utility class for action serialization
  */
 public class ActionUtil {
 
 /**
  * Utility class for action serialization
  */
 public class ActionUtil {
+    private static final Logger LOG = LoggerFactory.getLogger(ActionUtil.class);
+
     private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> ACTION_ORDERING =
             Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build());
 
     private static final Ordering<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> ACTION_ORDERING =
             Ordering.from(OrderComparator.<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action>build());
 
@@ -52,29 +56,34 @@ public class ActionUtil {
      * @param registry  serializer registry
      * @param outBuffer output buffer
      */
      * @param registry  serializer registry
      * @param outBuffer output buffer
      */
+    @SuppressWarnings("unchecked")
     public static void writeAction(Action action, short version, SerializerRegistry registry, ByteBuf outBuffer) {
     public static void writeAction(Action action, short version, SerializerRegistry registry, ByteBuf outBuffer) {
-        Optional.ofNullable(OFSessionUtil.getExtensionConvertorProvider())
+        try {
+            Optional.ofNullable(OFSessionUtil.getExtensionConvertorProvider())
                 .flatMap(provider ->
                 .flatMap(provider ->
-                        (GeneralExtensionGrouping.class.isInstance(action)
-                                ? convertExtensionGrouping(provider, action, version)
-                                : convertGenericAction(provider, action, version))
-                                .map(ofjAction -> {
-                                    final OFSerializer<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
-                                            .action.rev150203.actions.grouping.Action> serializer = registry
-                                            .getSerializer(TypeKeyMakerFactory.createActionKeyMaker(version)
-                                                    .make(ofjAction));
-
-                                    serializer.serialize(ofjAction, outBuffer);
-                                    return action;
-                                })
+                    (GeneralExtensionGrouping.class.isInstance(action)
+                        ? convertExtensionGrouping(provider, action, version)
+                        : convertGenericAction(provider, action, version))
+                        .map(ofjAction -> {
+                            final OFSerializer<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common
+                                .action.rev150203.actions.grouping.Action> serializer = registry
+                                .getSerializer(TypeKeyMakerFactory.createActionKeyMaker(version)
+                                    .make(ofjAction));
+
+                            serializer.serialize(ofjAction, outBuffer);
+                            return action;
+                        })
                 ).orElseGet(() -> {
                 ).orElseGet(() -> {
-            final OFSerializer<Action> serializer = registry.getSerializer(
+                final OFSerializer<Action> serializer = registry.getSerializer(
                     new MessageTypeKey<>(
                     new MessageTypeKey<>(
-                            version, (Class<? extends Action>) action.getImplementedInterface()));
-
-            serializer.serialize(action, outBuffer);
-            return action;
-        });
+                        version, (Class<? extends Action>) action.getImplementedInterface()));
+
+                serializer.serialize(action, outBuffer);
+                return action;
+            });
+        } catch (final IllegalStateException | ClassCastException e) {
+            LOG.warn("Serializer for action {} for version {} not found.", action.getImplementedInterface(), version);
+        }
     }
 
     /**
     }
 
     /**
@@ -107,6 +116,7 @@ public class ActionUtil {
      * @param version OpenFlow version
      * @return optional OpenFlowJava action
      */
      * @param version OpenFlow version
      * @return optional OpenFlowJava action
      */
+    @SuppressWarnings("unchecked")
     private static Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions
             .grouping.Action> convertGenericAction(final ExtensionConverterProvider provider,
                                                    final Action action,
     private static Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions
             .grouping.Action> convertGenericAction(final ExtensionConverterProvider provider,
                                                    final Action action,
index 395a1896184e989f749ac04e1af230c3b19178ed..5d435d778ccb0394df81b15515efb10d3dd06746 100644 (file)
@@ -28,8 +28,8 @@ public class WriteMetadataInstructionDeserializerTest extends AbstractInstructio
     @Test
     public void testDeserialize() throws Exception {
         final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
     @Test
     public void testDeserialize() throws Exception {
         final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
-        final BigInteger metadata = BigInteger.valueOf(1234567890L);
-        final BigInteger metadataMask = BigInteger.valueOf(9876543210L);
+        final BigInteger metadata = BigInteger.valueOf(1234L);
+        final BigInteger metadataMask = BigInteger.valueOf(9876L);
         writeHeader(in);
         in.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
         in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, EncodeConstants.SIZE_OF_LONG_IN_BYTES));
         writeHeader(in);
         in.writeZero(InstructionConstants.PADDING_IN_WRITE_METADATA);
         in.writeBytes(ByteUtil.convertBigIntegerToNBytes(metadata, EncodeConstants.SIZE_OF_LONG_IN_BYTES));
@@ -37,10 +37,19 @@ public class WriteMetadataInstructionDeserializerTest extends AbstractInstructio
 
         final Instruction instruction = deserializeInstruction(in);
         assertEquals(WriteMetadataCase.class, instruction.getImplementedInterface());
 
         final Instruction instruction = deserializeInstruction(in);
         assertEquals(WriteMetadataCase.class, instruction.getImplementedInterface());
-        assertArrayEquals(metadata.toByteArray(),
-                WriteMetadataCase.class.cast(instruction).getWriteMetadata().getMetadata().toByteArray());
-        assertArrayEquals(metadataMask.toByteArray(),
-                WriteMetadataCase.class.cast(instruction).getWriteMetadata().getMetadataMask().toByteArray());
+
+        assertArrayEquals(
+            ByteUtil
+                .convertBigIntegerToNBytes(metadata, EncodeConstants.SIZE_OF_LONG_IN_BYTES),
+            ByteUtil
+                .convertBigIntegerToNBytes(WriteMetadataCase.class.cast(instruction).getWriteMetadata().getMetadata(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
+
+        assertArrayEquals(
+            ByteUtil
+                .convertBigIntegerToNBytes(metadataMask, EncodeConstants.SIZE_OF_LONG_IN_BYTES),
+            ByteUtil
+                .convertBigIntegerToNBytes(WriteMetadataCase.class.cast(instruction).getWriteMetadata().getMetadataMask(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
+
         assertEquals(0, in.readableBytes());
     }
 
         assertEquals(0, in.readableBytes());
     }
 
index 37264c4173a426b86b987b099e42de905de69814..b3432b2995c52374a0a039d993c9ffa8964ca446 100644 (file)
@@ -8,11 +8,14 @@
 
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
 
 
 package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
 import static org.junit.Assert.assertEquals;
 
+import java.math.BigInteger;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
 import org.junit.Test;
 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
+import org.opendaylight.openflowplugin.openflow.md.util.ByteUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel;
 
 import io.netty.buffer.ByteBuf;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Tunnel;
 
 import io.netty.buffer.ByteBuf;
@@ -23,23 +26,30 @@ public class TunnelIdEntryDeserializerTest extends AbstractMatchEntryDeserialize
     @Test
     public void deserializeEntry() throws Exception {
         final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
     @Test
     public void deserializeEntry() throws Exception {
         final ByteBuf in = UnpooledByteBufAllocator.DEFAULT.buffer();
-        final long tunnelId = 6;
-        final long tunnelIdMask = 5;
+        final BigInteger tunnelId = BigInteger.valueOf(6);
+        final BigInteger tunnelIdMask = BigInteger.valueOf(5);
 
         writeHeader(in, false);
 
         writeHeader(in, false);
-        in.writeLong(tunnelId);
+        in.writeBytes(ByteUtil.convertBigIntegerToNBytes(tunnelId, EncodeConstants.SIZE_OF_LONG_IN_BYTES));
 
         Tunnel match = deserialize(in).getTunnel();
 
         Tunnel match = deserialize(in).getTunnel();
-        assertEquals(tunnelId, match.getTunnelId().longValue());
+        assertArrayEquals(
+            ByteUtil.convertBigIntegerToNBytes(tunnelId, EncodeConstants.SIZE_OF_LONG_IN_BYTES),
+            ByteUtil.convertBigIntegerToNBytes(match.getTunnelId(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
+
         assertEquals(0, in.readableBytes());
 
         writeHeader(in, true);
         assertEquals(0, in.readableBytes());
 
         writeHeader(in, true);
-        in.writeLong(tunnelId);
-        in.writeLong(tunnelIdMask);
+        in.writeBytes(ByteUtil.convertBigIntegerToNBytes(tunnelId, EncodeConstants.SIZE_OF_LONG_IN_BYTES));
+        in.writeBytes(ByteUtil.convertBigIntegerToNBytes(tunnelIdMask, EncodeConstants.SIZE_OF_LONG_IN_BYTES));
 
         match = deserialize(in).getTunnel();
 
         match = deserialize(in).getTunnel();
-        assertEquals(tunnelId, match.getTunnelId().longValue());
-        assertEquals(tunnelIdMask, match.getTunnelMask().longValue());
+        assertArrayEquals(
+            ByteUtil.convertBigIntegerToNBytes(tunnelId, EncodeConstants.SIZE_OF_LONG_IN_BYTES),
+            ByteUtil.convertBigIntegerToNBytes(match.getTunnelId(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
+        assertArrayEquals(
+            ByteUtil.convertBigIntegerToNBytes(tunnelIdMask, EncodeConstants.SIZE_OF_LONG_IN_BYTES),
+            ByteUtil.convertBigIntegerToNBytes(match.getTunnelMask(), EncodeConstants.SIZE_OF_LONG_IN_BYTES));
         assertEquals(0, in.readableBytes());
     }
 
         assertEquals(0, in.readableBytes());
     }
 
index 7f5b2c87cb7eaaf9a26923897ba439fa629e122e..963a54ebd0685fafb456d2d882a61bc717ab73d6 100644 (file)
@@ -34,7 +34,7 @@ public class MultipartReplyFlowStatsDeserializerTest extends AbstractMultipartDe
     private static final byte PADDING_IN_FLOW_STATS_HEADER_01 = 1;
     private static final byte PADDING_IN_FLOW_STATS_HEADER_02 = 4;
 
     private static final byte PADDING_IN_FLOW_STATS_HEADER_01 = 1;
     private static final byte PADDING_IN_FLOW_STATS_HEADER_02 = 4;
 
-    private static  final short ITEM_LENGTH = 104;
+    private static  final short ITEM_LENGTH = 96;
     private static  final byte TABLE_ID = 1;
     private static  final int SECOND = 1;
     private static  final int NANOSECOND = 2;
     private static  final byte TABLE_ID = 1;
     private static  final int SECOND = 1;
     private static  final int NANOSECOND = 2;
@@ -49,7 +49,6 @@ public class MultipartReplyFlowStatsDeserializerTest extends AbstractMultipartDe
     private static final FlowModFlags FLAGS = new FlowModFlags(
             CHECK_OVERLAP, NO_BYTCOUNTS, NO_PKTCOUNTS, RESET_COUNTS, SEND_FLOWREM);
     private static  final long COOKIE = 2;
     private static final FlowModFlags FLAGS = new FlowModFlags(
             CHECK_OVERLAP, NO_BYTCOUNTS, NO_PKTCOUNTS, RESET_COUNTS, SEND_FLOWREM);
     private static  final long COOKIE = 2;
-    private static  final long COOKIE_MASK = 3;
     private static  final long PACKET_COUNT = 4;
     private static  final long BYTE_COUNT = 5;
 
     private static  final long PACKET_COUNT = 4;
     private static  final long BYTE_COUNT = 5;
 
@@ -77,7 +76,6 @@ public class MultipartReplyFlowStatsDeserializerTest extends AbstractMultipartDe
                 FLAGS.isNOBYTCOUNTS()));
         buffer.writeZero(PADDING_IN_FLOW_STATS_HEADER_02);
         buffer.writeLong(COOKIE);
                 FLAGS.isNOBYTCOUNTS()));
         buffer.writeZero(PADDING_IN_FLOW_STATS_HEADER_02);
         buffer.writeLong(COOKIE);
-        buffer.writeLong(COOKIE_MASK);
         buffer.writeLong(PACKET_COUNT);
         buffer.writeLong(BYTE_COUNT);
 
         buffer.writeLong(PACKET_COUNT);
         buffer.writeLong(BYTE_COUNT);
 
@@ -141,7 +139,6 @@ public class MultipartReplyFlowStatsDeserializerTest extends AbstractMultipartDe
         assertEquals(HARD_TIMEOUT, flowAndStatisticsMapList.getHardTimeout().intValue());
         assertTrue(flowAndStatisticsMapList.getFlags().equals(FLAGS));
         assertEquals(COOKIE, flowAndStatisticsMapList.getCookie().getValue().longValue());
         assertEquals(HARD_TIMEOUT, flowAndStatisticsMapList.getHardTimeout().intValue());
         assertTrue(flowAndStatisticsMapList.getFlags().equals(FLAGS));
         assertEquals(COOKIE, flowAndStatisticsMapList.getCookie().getValue().longValue());
-        assertEquals(COOKIE_MASK, flowAndStatisticsMapList.getCookieMask().getValue().longValue());
         assertEquals(BYTE_COUNT, flowAndStatisticsMapList.getByteCount().getValue().longValue());
         assertEquals(PACKET_COUNT, flowAndStatisticsMapList.getPacketCount().getValue().longValue());
 
         assertEquals(BYTE_COUNT, flowAndStatisticsMapList.getByteCount().getValue().longValue());
         assertEquals(PACKET_COUNT, flowAndStatisticsMapList.getPacketCount().getValue().longValue());
 
@@ -168,4 +165,4 @@ public class MultipartReplyFlowStatsDeserializerTest extends AbstractMultipartDe
     protected int getType() {
         return MultipartType.OFPMPFLOW.getIntValue();
     }
     protected int getType() {
         return MultipartType.OFPMPFLOW.getIntValue();
     }
-}
\ No newline at end of file
+}
index 15ac117cdb4201769fec0b85891b25de110ae9a9..8a401ffda4a04b746d2d8e3ea01b07b8ed0097ce 100644 (file)
@@ -37,7 +37,7 @@ public class MultipartReplyMessageDeserializerTest extends AbstractDeserializerT
     private static final short TYPE = 19;
     private static final short MULTIPART_TYPE = 1;
     private static final short REQ_MORE = 1;
     private static final short TYPE = 19;
     private static final short MULTIPART_TYPE = 1;
     private static final short REQ_MORE = 1;
-    private static final short ITEM_LENGTH = 88;
+    private static final short ITEM_LENGTH = 80;
 
     private static  final byte TABLE_ID = 1;
     private static  final int SECOND = 1;
 
     private static  final byte TABLE_ID = 1;
     private static  final int SECOND = 1;
@@ -53,7 +53,6 @@ public class MultipartReplyMessageDeserializerTest extends AbstractDeserializerT
     private static final FlowModFlags FLAGS = new FlowModFlags(
             CHECK_OVERLAP, NO_BYTCOUNTS, NO_PKTCOUNTS, RESET_COUNTS, SEND_FLOWREM);
     private static  final long COOKIE = 2;
     private static final FlowModFlags FLAGS = new FlowModFlags(
             CHECK_OVERLAP, NO_BYTCOUNTS, NO_PKTCOUNTS, RESET_COUNTS, SEND_FLOWREM);
     private static  final long COOKIE = 2;
-    private static  final long COOKIE_MASK = 3;
     private static  final long PACKET_COUNT = 4;
     private static  final long BYTE_COUNT = 5;
 
     private static  final long PACKET_COUNT = 4;
     private static  final long BYTE_COUNT = 5;
 
@@ -90,7 +89,6 @@ public class MultipartReplyMessageDeserializerTest extends AbstractDeserializerT
                 FLAGS.isNOBYTCOUNTS()));
         buffer.writeZero(PADDING_IN_FLOW_STATS_HEADER_02);
         buffer.writeLong(COOKIE);
                 FLAGS.isNOBYTCOUNTS()));
         buffer.writeZero(PADDING_IN_FLOW_STATS_HEADER_02);
         buffer.writeLong(COOKIE);
-        buffer.writeLong(COOKIE_MASK);
         buffer.writeLong(PACKET_COUNT);
         buffer.writeLong(BYTE_COUNT);
 
         buffer.writeLong(PACKET_COUNT);
         buffer.writeLong(BYTE_COUNT);
 
@@ -145,7 +143,6 @@ public class MultipartReplyMessageDeserializerTest extends AbstractDeserializerT
         assertEquals(HARD_TIMEOUT, flowAndStatisticsMapList.getHardTimeout().intValue());
         assertTrue(flowAndStatisticsMapList.getFlags().equals(FLAGS));
         assertEquals(COOKIE, flowAndStatisticsMapList.getCookie().getValue().longValue());
         assertEquals(HARD_TIMEOUT, flowAndStatisticsMapList.getHardTimeout().intValue());
         assertTrue(flowAndStatisticsMapList.getFlags().equals(FLAGS));
         assertEquals(COOKIE, flowAndStatisticsMapList.getCookie().getValue().longValue());
-        assertEquals(COOKIE_MASK, flowAndStatisticsMapList.getCookieMask().getValue().longValue());
         assertEquals(BYTE_COUNT, flowAndStatisticsMapList.getByteCount().getValue().longValue());
         assertEquals(PACKET_COUNT, flowAndStatisticsMapList.getPacketCount().getValue().longValue());
 
         assertEquals(BYTE_COUNT, flowAndStatisticsMapList.getByteCount().getValue().longValue());
         assertEquals(PACKET_COUNT, flowAndStatisticsMapList.getPacketCount().getValue().longValue());
 
@@ -159,4 +156,4 @@ public class MultipartReplyMessageDeserializerTest extends AbstractDeserializerT
         assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().getAction().get(0)
                 .getAction().getImplementedInterface());
     }
         assertEquals(PopPbbActionCase.class, applyActions.getApplyActions().getAction().get(0)
                 .getAction().getImplementedInterface());
     }
-}
\ No newline at end of file
+}
index 58b37e9ed3f8b66efdd60d89568c14f9b90a7e42..5bb18eb70d14374793a1ff0853eb1c5f29d915b8 100644 (file)
@@ -202,26 +202,32 @@ public class MultipartReplyTableFeaturesDeserializerTest extends AbstractMultipa
             case OFPTFPTMATCH:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_OP << 1);
             case OFPTFPTMATCH:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_OP << 1);
+                buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
                 break;
             case OFPTFPTWILDCARDS:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_SHA << 1);
                 break;
             case OFPTFPTWILDCARDS:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_SHA << 1);
+                buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
                 break;
             case OFPTFPTWRITESETFIELD:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_SPA << 1);
                 break;
             case OFPTFPTWRITESETFIELD:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_SPA << 1);
+                buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
                 break;
             case OFPTFPTWRITESETFIELDMISS:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_THA << 1);
                 break;
             case OFPTFPTWRITESETFIELDMISS:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_THA << 1);
+                buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
                 break;
             case OFPTFPTAPPLYSETFIELD:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_TPA << 1);
                 break;
             case OFPTFPTAPPLYSETFIELD:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ARP_TPA << 1);
+                buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
                 break;
             case OFPTFPTAPPLYSETFIELDMISS:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ETH_TYPE << 1);
                 break;
             case OFPTFPTAPPLYSETFIELDMISS:
                 buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
                 buffer.writeByte(OxmMatchConstants.ETH_TYPE << 1);
+                buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
                 break;
             default:
                 break;
                 break;
             default:
                 break;
@@ -244,4 +250,4 @@ public class MultipartReplyTableFeaturesDeserializerTest extends AbstractMultipa
     protected int getType() {
         return MultipartType.OFPMPTABLEFEATURES.getIntValue();
     }
     protected int getType() {
         return MultipartType.OFPMPTABLEFEATURES.getIntValue();
     }
-}
\ No newline at end of file
+}
index 72113919a1fc979871ad3ae59d91e204bc63434e..fc74907d8fcfb9f3f659206dc1953dd6c8749313 100644 (file)
@@ -59,14 +59,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.f
 
 public class TableFeaturesMatchFieldDeserializerTest {
     private TableFeaturesMatchFieldDeserializer deserializer = new TableFeaturesMatchFieldDeserializer();
 
 public class TableFeaturesMatchFieldDeserializerTest {
     private TableFeaturesMatchFieldDeserializer deserializer = new TableFeaturesMatchFieldDeserializer();
-    private Optional<SetFieldMatch> fieldMatch;
 
     @Test
     public void deserialize() throws Exception {
         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
 
         addValues(buffer, OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.ARP_OP);
 
     @Test
     public void deserialize() throws Exception {
         ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
 
         addValues(buffer, OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.ARP_OP);
-        fieldMatch = deserializer.deserialize(buffer);
+        Optional<SetFieldMatch> fieldMatch = deserializer.deserialize(buffer);
         assertEquals(ArpOp.class, fieldMatch.get().getKey().getMatchType());
 
         addValues(buffer, OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.ARP_SHA);
         assertEquals(ArpOp.class, fieldMatch.get().getKey().getMatchType());
 
         addValues(buffer, OxmMatchConstants.OPENFLOW_BASIC_CLASS, OxmMatchConstants.ARP_SHA);
@@ -228,5 +227,6 @@ public class TableFeaturesMatchFieldDeserializerTest {
         buffer.clear();
         buffer.writeShort(oxmClass);
         buffer.writeByte(oxmField << 1);
         buffer.clear();
         buffer.writeShort(oxmClass);
         buffer.writeByte(oxmField << 1);
+        buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
     }
     }
-}
\ No newline at end of file
+}
index 6e8c9f419f49a7926b3a49028a7397c3817a1753..a3414d1a6ba173bddd91d66e00fff5de9746eb9d 100644 (file)
@@ -29,7 +29,7 @@ public class SetQueueActionSerializerTest extends AbstractActionSerializerTest {
                         .build())
                 .build();
 
                         .build())
                 .build();
 
-        assertAction(action, out -> assertEquals(out.readUnsignedByte(), queue));
+        assertAction(action, out -> assertEquals(out.readUnsignedInt(), queue));
     }
 
     @Override
     }
 
     @Override
index 689f5a3fe4216102b3ba59aa61af79161512b5e9..1180766924e02bd72251d09983b7efb99ca99ddd 100644 (file)
@@ -124,6 +124,10 @@ public final class IpConversionUtil {
     }
 
     public static Ipv4Prefix createPrefix(final Ipv4Address ipv4Address, final byte [] bytemask){
     }
 
     public static Ipv4Prefix createPrefix(final Ipv4Address ipv4Address, final byte [] bytemask){
+        if (bytemask == null) {
+            return createPrefix(ipv4Address);
+        }
+
         return IetfInetUtil.INSTANCE.ipv4PrefixFor(ipv4Address, countBits(bytemask));
     }
 
         return IetfInetUtil.INSTANCE.ipv4PrefixFor(ipv4Address, countBits(bytemask));
     }
 
@@ -178,6 +182,10 @@ public final class IpConversionUtil {
     }
 
     public static Ipv6Prefix createPrefix(final Ipv6Address ipv6Address, final byte [] bytemask){
     }
 
     public static Ipv6Prefix createPrefix(final Ipv6Address ipv6Address, final byte [] bytemask){
+        if (bytemask == null) {
+            return createPrefix(ipv6Address);
+        }
+
         return IetfInetUtil.INSTANCE.ipv6PrefixFor(ipv6Address, countBits(bytemask));
     }
 
         return IetfInetUtil.INSTANCE.ipv6PrefixFor(ipv6Address, countBits(bytemask));
     }
 
@@ -398,7 +406,7 @@ public final class IpConversionUtil {
         List<String> partsV6Prefix = Lists.newArrayList(splittedV6Prefix.iterator());
 
         boolean valid = true;
         List<String> partsV6Prefix = Lists.newArrayList(splittedV6Prefix.iterator());
 
         boolean valid = true;
-        
+
         try {
             mask = Integer.parseInt(partsV6Prefix.get(1));
             if (mask > 128) {
         try {
             mask = Integer.parseInt(partsV6Prefix.get(1));
             if (mask > 128) {
index d502c0d6fb7dd0c00600e115541c27473cf11dc0..19b1b25e778403bafe96b6c4f3eab72412866d00 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.collect.ImmutableBiMap;
 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
 import org.opendaylight.openflowjava.protocol.api.util.BinContent;
 import org.opendaylight.openflowplugin.api.OFConstants;
 import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumberValues;
@@ -149,4 +150,15 @@ public class OpenflowPortsUtil {
         }
         return result;
     }
         }
         return result;
     }
+
+    /**
+     * Converts port number to Uri
+     * @param version openflow version
+     * @param portNumber port number
+     * @return port number uri
+     */
+    public static Uri getProtocolAgnosticPortUri(final short version, final long portNumber) {
+        return new Uri(portNumberToString(getProtocolAgnosticPort(OpenflowVersion.get(version), portNumber)));
+    }
+
 }
 }