Fix - bug 270
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / factories / MultipartReplyMessageFactory.java
index 15e9f77cb8e4c3c0f78605115e083049502b8181..628d388d5bd588359296d6f02e2538a8ec3d1e30 100644 (file)
@@ -281,15 +281,15 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             flowStatsBuilder.setHardTimeout(input.readUnsignedShort());
             flowStatsBuilder.setFlags(createFlowModFlagsFromBitmap(input.readShort()));
             input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);
-            byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
+            byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(cookie);
-            flowStatsBuilder.setCookie(new BigInteger(cookie));
-            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
+            flowStatsBuilder.setCookie(new BigInteger(1, cookie));
+            byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(packetCount);
-            flowStatsBuilder.setPacketCount(new BigInteger(packetCount));
-            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
+            flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
+            byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(byteCount);
-            flowStatsBuilder.setByteCount(new BigInteger(byteCount));
+            flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
             flowStatsBuilder.setMatch(MatchDeserializer.createMatch(input));
             flowStatsBuilder.setInstructions(InstructionsDeserializer.createInstructions(input, input.readableBytes()));
             flowStatsList.add(flowStatsBuilder.build());
@@ -311,12 +311,12 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
     private static MultipartReplyAggregateCase setAggregate(ByteBuf input) {
         MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder();
         MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
-        byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
+        byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         input.readBytes(packetCount);
-        builder.setPacketCount(new BigInteger(packetCount));
-        byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
+        builder.setPacketCount(new BigInteger(1, packetCount));
+        byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
         input.readBytes(byteCount);
-        builder.setByteCount(new BigInteger(byteCount));
+        builder.setByteCount(new BigInteger(1, byteCount));
         builder.setFlowCount(input.readUnsignedInt());
         input.skipBytes(PADDING_IN_AGGREGATE_HEADER);
         caseBuilder.setMultipartReplyAggregate(builder.build());
@@ -332,12 +332,12 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             tableStatsBuilder.setTableId(input.readUnsignedByte());
             input.skipBytes(PADDING_IN_TABLE_HEADER);
             tableStatsBuilder.setActiveCount(input.readUnsignedInt());
-            byte[] lookupCount = new byte[Long.SIZE/Byte.SIZE];
+            byte[] lookupCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(lookupCount);
-            tableStatsBuilder.setLookupCount(new BigInteger(lookupCount));
-            byte[] matchedCount = new byte[Long.SIZE/Byte.SIZE];
+            tableStatsBuilder.setLookupCount(new BigInteger(1, lookupCount));
+            byte[] matchedCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(matchedCount);
-            tableStatsBuilder.setMatchedCount(new BigInteger(matchedCount));
+            tableStatsBuilder.setMatchedCount(new BigInteger(1, matchedCount));
             tableStatsList.add(tableStatsBuilder.build());
         }
         builder.setTableStats(tableStatsList);
@@ -444,42 +444,42 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             PortStatsBuilder portStatsBuilder = new PortStatsBuilder();
             portStatsBuilder.setPortNo(input.readUnsignedInt());
             input.skipBytes(PADDING_IN_PORT_STATS_HEADER);
-            byte[] rxPackets = new byte[Long.SIZE/Byte.SIZE];
+            byte[] rxPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(rxPackets);
-            portStatsBuilder.setRxPackets(new BigInteger(rxPackets));
-            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setRxPackets(new BigInteger(1, rxPackets));
+            byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(txPackets);
-            portStatsBuilder.setTxPackets(new BigInteger(txPackets));
-            byte[] rxBytes = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setTxPackets(new BigInteger(1, txPackets));
+            byte[] rxBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(rxBytes);
-            portStatsBuilder.setRxBytes(new BigInteger(rxBytes));
-            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setRxBytes(new BigInteger(1, rxBytes));
+            byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(txBytes);
-            portStatsBuilder.setTxBytes(new BigInteger(txBytes));
-            byte[] rxDropped = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setTxBytes(new BigInteger(1, txBytes));
+            byte[] rxDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(rxDropped);
-            portStatsBuilder.setRxDropped(new BigInteger(rxDropped));
-            byte[] txDropped = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setRxDropped(new BigInteger(1, rxDropped));
+            byte[] txDropped = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(txDropped);
-            portStatsBuilder.setTxDropped(new BigInteger(txDropped));
-            byte[] rxErrors = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setTxDropped(new BigInteger(1, txDropped));
+            byte[] rxErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(rxErrors);
-            portStatsBuilder.setRxErrors(new BigInteger(rxErrors));
-            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setRxErrors(new BigInteger(1, rxErrors));
+            byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(txErrors);
-            portStatsBuilder.setTxErrors(new BigInteger(txErrors));
-            byte[] rxFrameErr = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setTxErrors(new BigInteger(1, txErrors));
+            byte[] rxFrameErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(rxFrameErr);
-            portStatsBuilder.setRxFrameErr(new BigInteger(rxFrameErr));
-            byte[] rxOverErr = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setRxFrameErr(new BigInteger(1, rxFrameErr));
+            byte[] rxOverErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(rxOverErr);
-            portStatsBuilder.setRxOverErr(new BigInteger(rxOverErr));
-            byte[] rxCrcErr = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setRxOverErr(new BigInteger(1, rxOverErr));
+            byte[] rxCrcErr = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(rxCrcErr);
-            portStatsBuilder.setRxCrcErr(new BigInteger(rxCrcErr));
-            byte[] collisions = new byte[Long.SIZE/Byte.SIZE];
+            portStatsBuilder.setRxCrcErr(new BigInteger(1, rxCrcErr));
+            byte[] collisions = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(collisions);
-            portStatsBuilder.setCollisions(new BigInteger(collisions));
+            portStatsBuilder.setCollisions(new BigInteger(1, collisions));
             portStatsBuilder.setDurationSec(input.readUnsignedInt());
             portStatsBuilder.setDurationNsec(input.readUnsignedInt());
             portStatsList.add(portStatsBuilder.build());
@@ -497,15 +497,15 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder();
             queueStatsBuilder.setPortNo(input.readUnsignedInt());
             queueStatsBuilder.setQueueId(input.readUnsignedInt());
-            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];
+            byte[] txBytes = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(txBytes);
-            queueStatsBuilder.setTxBytes(new BigInteger(txBytes));
-            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];
+            queueStatsBuilder.setTxBytes(new BigInteger(1, txBytes));
+            byte[] txPackets = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(txPackets);
-            queueStatsBuilder.setTxPackets(new BigInteger(txPackets));
-            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];
+            queueStatsBuilder.setTxPackets(new BigInteger(1, txPackets));
+            byte[] txErrors = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(txErrors);
-            queueStatsBuilder.setTxErrors(new BigInteger(txErrors));
+            queueStatsBuilder.setTxErrors(new BigInteger(1, txErrors));
             queueStatsBuilder.setDurationSec(input.readUnsignedInt());
             queueStatsBuilder.setDurationNsec(input.readUnsignedInt());
             queueStatsList.add(queueStatsBuilder.build());
@@ -526,24 +526,24 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             groupStatsBuilder.setGroupId(new GroupId(input.readUnsignedInt()));
             groupStatsBuilder.setRefCount(input.readUnsignedInt());
             input.skipBytes(PADDING_IN_GROUP_HEADER_02);
-            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
+            byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(packetCount);
-            groupStatsBuilder.setPacketCount(new BigInteger(packetCount));
-            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
+            groupStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
+            byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(byteCount);
-            groupStatsBuilder.setByteCount(new BigInteger(byteCount));
+            groupStatsBuilder.setByteCount(new BigInteger(1, byteCount));
             groupStatsBuilder.setDurationSec(input.readUnsignedInt());
             groupStatsBuilder.setDurationNsec(input.readUnsignedInt());
             int actualLength = GROUP_BODY_LENGTH;
             List<BucketStats> bucketStatsList = new ArrayList<>();
             while (actualLength < bodyLength) {
                 BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
-                byte[] packetCountBucket = new byte[Long.SIZE/Byte.SIZE];
+                byte[] packetCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
                 input.readBytes(packetCountBucket);
-                bucketStatsBuilder.setPacketCount(new BigInteger(packetCountBucket));
-                byte[] byteCountBucket = new byte[Long.SIZE/Byte.SIZE];
+                bucketStatsBuilder.setPacketCount(new BigInteger(1, packetCountBucket));
+                byte[] byteCountBucket = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
                 input.readBytes(byteCountBucket);
-                bucketStatsBuilder.setByteCount(new BigInteger(byteCountBucket));
+                bucketStatsBuilder.setByteCount(new BigInteger(1, byteCountBucket));
                 bucketStatsList.add(bucketStatsBuilder.build());
                 actualLength += BUCKET_COUNTER_LENGTH;
             } 
@@ -592,24 +592,24 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
             int meterStatsBodyLength = input.readUnsignedShort();
             input.skipBytes(PADDING_IN_METER_STATS_HEADER);
             meterStatsBuilder.setFlowCount(input.readUnsignedInt());
-            byte[] packetInCount = new byte[Long.SIZE/Byte.SIZE];
+            byte[] packetInCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(packetInCount);
-            meterStatsBuilder.setPacketInCount(new BigInteger(packetInCount));
-            byte[] byteInCount = new byte[Long.SIZE/Byte.SIZE];
+            meterStatsBuilder.setPacketInCount(new BigInteger(1, packetInCount));
+            byte[] byteInCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
             input.readBytes(byteInCount);
-            meterStatsBuilder.setByteInCount(new BigInteger(byteInCount));
+            meterStatsBuilder.setByteInCount(new BigInteger(1, byteInCount));
             meterStatsBuilder.setDurationSec(input.readUnsignedInt());
             meterStatsBuilder.setDurationNsec(input.readUnsignedInt());
             int actualLength = METER_BODY_LENGTH;
             List<MeterBandStats> meterBandStatsList = new ArrayList<>();
             while (actualLength < meterStatsBodyLength) {
                 MeterBandStatsBuilder meterBandStatsBuilder = new MeterBandStatsBuilder();
-                byte[] packetBandCount = new byte[Long.SIZE/Byte.SIZE];
+                byte[] packetBandCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
                 input.readBytes(packetBandCount);
-                meterBandStatsBuilder.setPacketBandCount(new BigInteger(packetBandCount));
-                byte[] byteBandCount = new byte[Long.SIZE/Byte.SIZE];
+                meterBandStatsBuilder.setPacketBandCount(new BigInteger(1, packetBandCount));
+                byte[] byteBandCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
                 input.readBytes(byteBandCount);
-                meterBandStatsBuilder.setByteBandCount(new BigInteger(byteBandCount));
+                meterBandStatsBuilder.setByteBandCount(new BigInteger(1, byteBandCount));
                 meterBandStatsList.add(meterBandStatsBuilder.build());
                 actualLength += METER_BAND_STATS_LENGTH;
             }