Merge "Bumped to SNAPSHOT dependencies - some dependencies moved to <dependencyManag...
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / MultipartReplyMessageFactory.java
index 628d388d5bd588359296d6f02e2538a8ec3d1e30..3ef96147d95b848333fb223fbbddfc6826214b7a 100644 (file)
@@ -23,6 +23,7 @@ import org.opendaylight.openflowjava.protocol.impl.util.MatchDeserializer;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ActionRelatedTableFeaturePropertyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.ExperimenterRelatedTableFeaturePropertyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeatureProperty;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.InstructionRelatedTableFeaturePropertyBuilder;
@@ -32,7 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.OxmRelatedTableFeaturePropertyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIds;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.table.features.properties.container.table.feature.properties.NextTableIdsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.ActionsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev130731.actions.grouping.Action;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
@@ -53,8 +54,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.BucketsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.buckets.grouping.BucketsListBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDscpRemarkCaseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandExperimenterCaseBuilder;
@@ -132,8 +133,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeatureProperties;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.TableFeaturePropertiesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder;
 
 /**
  * Translates MultipartReply messages
@@ -271,27 +272,28 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
         List<FlowStats> flowStatsList = new ArrayList<>();
         while (input.readableBytes() > 0) {
             FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();
-            input.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
-            flowStatsBuilder.setTableId(input.readUnsignedByte());
-            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
-            flowStatsBuilder.setDurationSec(input.readUnsignedInt());
-            flowStatsBuilder.setDurationNsec(input.readUnsignedInt());
-            flowStatsBuilder.setPriority(input.readUnsignedShort());
-            flowStatsBuilder.setIdleTimeout(input.readUnsignedShort());
-            flowStatsBuilder.setHardTimeout(input.readUnsignedShort());
-            flowStatsBuilder.setFlags(createFlowModFlagsFromBitmap(input.readShort()));
-            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
+            int flowRecordLength = input.readUnsignedShort();
+            ByteBuf subInput = input.readSlice(flowRecordLength - EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
+            flowStatsBuilder.setTableId(subInput.readUnsignedByte());
+            subInput.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);
+            flowStatsBuilder.setDurationSec(subInput.readUnsignedInt());
+            flowStatsBuilder.setDurationNsec(subInput.readUnsignedInt());
+            flowStatsBuilder.setPriority(subInput.readUnsignedShort());
+            flowStatsBuilder.setIdleTimeout(subInput.readUnsignedShort());
+            flowStatsBuilder.setHardTimeout(subInput.readUnsignedShort());
+            flowStatsBuilder.setFlags(createFlowModFlagsFromBitmap(subInput.readUnsignedShort()));
+            subInput.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
             byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
-            input.readBytes(cookie);
+            subInput.readBytes(cookie);
             flowStatsBuilder.setCookie(new BigInteger(1, cookie));
             byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
-            input.readBytes(packetCount);
+            subInput.readBytes(packetCount);
             flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
             byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
-            input.readBytes(byteCount);
+            subInput.readBytes(byteCount);
             flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
-            flowStatsBuilder.setMatch(MatchDeserializer.createMatch(input));
-            flowStatsBuilder.setInstructions(InstructionsDeserializer.createInstructions(input, input.readableBytes()));
+            flowStatsBuilder.setMatch(MatchDeserializer.createMatch(subInput));
+            flowStatsBuilder.setInstruction(InstructionsDeserializer.createInstructions(subInput, subInput.readableBytes()));
             flowStatsList.add(flowStatsBuilder.build());
         }
         flowBuilder.setFlowStats(flowStatsList);
@@ -299,7 +301,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
         return caseBuilder.build();
     }
     
-    private static FlowModFlags createFlowModFlagsFromBitmap(short input){
+    private static FlowModFlags createFlowModFlagsFromBitmap(int input){
         final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) != 0;
         final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) != 0;
         final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) != 0; 
@@ -390,7 +392,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             if (type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONS)
                     || type.equals(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS)) {
                 InstructionRelatedTableFeaturePropertyBuilder insBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
-                insBuilder.setInstructions(InstructionsDeserializer.createInstructionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+                insBuilder.setInstruction(InstructionsDeserializer.createInstructionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
                 builder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insBuilder.build());
             } else if (type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLES)
                     || type.equals(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS)) {
@@ -410,7 +412,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONS)
                     || type.equals(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS)) {
                 ActionRelatedTableFeaturePropertyBuilder actionBuilder = new ActionRelatedTableFeaturePropertyBuilder();
-                actionBuilder.setActionsList(ActionsDeserializer.createActionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
+                actionBuilder.setAction(ActionsDeserializer.createActionIds(input, propertyLength - COMMON_PROPERTY_LENGTH));
                 builder.addAugmentation(ActionRelatedTableFeatureProperty.class, actionBuilder.build());
             } else if (type.equals(TableFeaturesPropType.OFPTFPTMATCH)
                     || type.equals(TableFeaturesPropType.OFPTFPTWILDCARDS)
@@ -426,6 +428,13 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                 ExperimenterRelatedTableFeaturePropertyBuilder expBuilder = new ExperimenterRelatedTableFeaturePropertyBuilder();
                 expBuilder.setExperimenter(input.readUnsignedInt());
                 expBuilder.setExpType(input.readUnsignedInt());
+                int dataLength = propertyLength - COMMON_PROPERTY_LENGTH - 2 * EncodeConstants.SIZE_OF_INT_IN_BYTES;
+                if (dataLength > 0) {
+                    byte[] data = new byte[dataLength];
+                    input.readBytes(data);
+                    expBuilder.setData(data);
+                }
+                builder.addAugmentation(ExperimenterRelatedTableFeatureProperty.class, expBuilder.build());
             }
             if (paddingRemainder != 0) {
                 input.skipBytes(EncodeConstants.PADDING - paddingRemainder);
@@ -837,9 +846,9 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
                 bucketsBuilder.setWatchPort(new PortNumber(input.readUnsignedInt()));
                 bucketsBuilder.setWatchGroup(input.readUnsignedInt());
                 input.skipBytes(PADDING_IN_BUCKETS_HEADER);
-                List<ActionsList> actionsList = ActionsDeserializer
-                        .createActionsList(input, bucketsLength - BUCKETS_HEADER_LENGTH);
-                bucketsBuilder.setActionsList(actionsList);
+                List<Action> actionsList = ActionsDeserializer
+                        .createActions(input, bucketsLength - BUCKETS_HEADER_LENGTH);
+                bucketsBuilder.setAction(actionsList);
                 bucketsList.add(bucketsBuilder.build());
                 actualLength += bucketsLength;
             }