multipart request message updated 56/1956/1
authorTimotej Kubas <timotej.kubas@pantheon.sk>
Thu, 17 Oct 2013 09:20:50 +0000 (11:20 +0200)
committerTimotej Kubas <timotej.kubas@pantheon.sk>
Thu, 17 Oct 2013 09:27:23 +0000 (11:27 +0200)
multipart request message flags updated in YANG
experimenter input message compute length fixed

Change-Id: I609b24cca8ad9887921d818304e95bc17b206b30
Signed-off-by: Timotej Kubas <timotej.kubas@pantheon.sk>
openflow-protocol-api/src/main/yang/openflow-action.yang
openflow-protocol-api/src/main/yang/openflow-protocol.yang
openflow-protocol-api/src/main/yang/openflow-types.yang
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/ExperimenterInputMessageFactory.java
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/HelloInputMessageFactory.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/MultipartReplyMessageFactoryTest.java

index f28b083b26c5129b188c4db36300c3cdc4e5ac13..473b8a61c4f8239502823b908227d6657777364c 100644 (file)
@@ -77,6 +77,7 @@ module openflow-action {
         base oft:action;
     }
     
+    /*
     grouping output {
         description 
             "Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
@@ -166,6 +167,7 @@ module openflow-action {
             // TODO: figure definition
         }
     }
+    */
     
     container actions {
         uses action-header;
index ee8d88fd9d9ebbe2245f95a000410c1a2bec0423..7e16905a2ead5b124d782919a1d9e4d5101d3707 100644 (file)
@@ -638,7 +638,7 @@ module openflow-protocol {
                                 type uint16;\r
                             }\r
                             leaf flags {\r
-                                type uint16;\r
+                                type oft:flow-mod-flags;\r
                             }\r
                             leaf cookie {\r
                                 type uint64;\r
@@ -788,7 +788,8 @@ module openflow-protocol {
                     case multipart-reply-group-desc {\r
                         list group-desc {\r
                             leaf type {\r
-                                type uint8;\r
+                                //type uint8;\r
+                                type oft:group-type;\r
                             }\r
                             leaf group-id {\r
                                 type uint32;\r
index 6552b2ee8527cf985d7e3e2e9ffd1a4eef848ee9..1722b1ba4e5f946574c86f742a3cef334c2e7415 100644 (file)
@@ -468,11 +468,6 @@ module openflow-types {
     typedef multipart-type {
         /* ofp_multipart_type */
         type enumeration {
-            enum OFPGT_ALL {
-              value 0;
-              description "All (multicast/broadcast) group.";
-            }
-            
             enum OFPMP_DESC {
               value 0;
               description "Description of this OpenFlow switch.
index 2dce07721a2f0cfa220cb6b3731611bfede37ee9..64bf2ac39cedd932e0afb823129e525d7070f3b6 100644 (file)
@@ -3,11 +3,42 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 \r
 import io.netty.buffer.ByteBuf;\r
 \r
+import java.math.BigInteger;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroup;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow.FlowStatsBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.GroupStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.GroupStatsBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.group.stats.BucketStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.group.stats.BucketStatsBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.stats.PortStatsBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.queue.QueueStatsBuilder;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.TableStatsBuilder;\r
 \r
 /**\r
  * @author timotej.kubas\r
@@ -25,7 +56,7 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
     /**\r
      * @return singleton factory\r
      */\r
-    public static synchronized MultipartReplyMessageFactory getInstance(){\r
+    public static synchronized MultipartReplyMessageFactory getInstance() {\r
         if (instance == null){\r
             instance = new MultipartReplyMessageFactory();\r
         }\r
@@ -38,10 +69,277 @@ public class MultipartReplyMessageFactory implements OFDeserializer<MultipartRep
         builder.setVersion(version);\r
         builder.setXid(rawMessage.readUnsignedInt());\r
         builder.setType(MultipartType.forValue(rawMessage.readUnsignedShort()));\r
-        builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) > 0));\r
+        builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));\r
         rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);\r
         // TODO - implement body\r
         //mrmb.setBody(rawMessage.readBytes(rawMessage.readableBytes()).array());\r
+        \r
+        switch (builder.getType().getIntValue()) {\r
+        case 0:  builder.setMultipartReplyBody(setDesc(rawMessage));\r
+                 break;\r
+        case 1:  builder.setMultipartReplyBody(setFlow(rawMessage));\r
+                 break;\r
+        case 2:  builder.setMultipartReplyBody(setAggregate(rawMessage));\r
+                 break;\r
+        case 3:  builder.setMultipartReplyBody(setTable(rawMessage));\r
+                 break;         \r
+        case 4:  builder.setMultipartReplyBody(setPortStats(rawMessage));\r
+                 break;\r
+        case 5:  builder.setMultipartReplyBody(setQueue(rawMessage));\r
+                 break;         \r
+        case 6:  builder.setMultipartReplyBody(setGroup(rawMessage));\r
+                 break;\r
+        default: \r
+                 break;\r
+        }\r
+        \r
+        return builder.build();\r
+    }\r
+    \r
+    private static MultipartReplyDesc setDesc(ByteBuf input) {\r
+        final int DESC_STR_LEN = 256;\r
+        final int SERIAL_NUM_LEN = 32;\r
+        MultipartReplyDescBuilder descBuilder = new MultipartReplyDescBuilder();\r
+        byte[] mfrDescBytes = new byte[DESC_STR_LEN];\r
+        input.readBytes(mfrDescBytes);\r
+        String mfrDesc = new String(mfrDescBytes);\r
+        descBuilder.setMfrDesc(mfrDesc.trim());\r
+        byte[] hwDescBytes = new byte[DESC_STR_LEN];\r
+        input.readBytes(hwDescBytes);\r
+        String hwDesc = new String(hwDescBytes);\r
+        descBuilder.setHwDesc(hwDesc.trim());\r
+        byte[] swDescBytes = new byte[DESC_STR_LEN];\r
+        input.readBytes(swDescBytes);\r
+        String swDesc = new String(swDescBytes);\r
+        descBuilder.setSwDesc(swDesc.trim());\r
+        byte[] serialNumBytes = new byte[SERIAL_NUM_LEN];\r
+        input.readBytes(serialNumBytes);\r
+        String serialNum = new String(serialNumBytes);\r
+        descBuilder.setSerialNum(serialNum.trim());\r
+        byte[] dpDescBytes = new byte[DESC_STR_LEN];\r
+        input.readBytes(dpDescBytes);\r
+        String dpDesc = new String(dpDescBytes);\r
+        descBuilder.setDpDesc(dpDesc.trim());\r
+        return descBuilder.build();\r
+    }\r
+    \r
+    private static MultipartReplyFlow setFlow(ByteBuf input) {\r
+        final byte PADDING_IN_FLOW_STATS_HEADER_01 = 1;\r
+        final byte PADDING_IN_FLOW_STATS_HEADER_02 = 4;\r
+        MultipartReplyFlowBuilder flowBuilder = new MultipartReplyFlowBuilder();\r
+        List<FlowStats> flowStatsList = new ArrayList<>();\r
+        FlowStatsBuilder flowStatsBuilder = new FlowStatsBuilder();\r
+        while (input.readableBytes() > 0) {\r
+            flowStatsBuilder.setTableId(input.readUnsignedByte());\r
+            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_01);\r
+            flowStatsBuilder.setDurationSec(input.readUnsignedInt());\r
+            flowStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
+            flowStatsBuilder.setPriority(input.readUnsignedShort());\r
+            flowStatsBuilder.setIdleTimeout(input.readUnsignedShort());\r
+            flowStatsBuilder.setHardTimeout(input.readUnsignedShort());\r
+            flowStatsBuilder.setFlags(createFlowModFalgsFromBitmap(input.readShort()));\r
+            input.skipBytes(PADDING_IN_FLOW_STATS_HEADER_02);\r
+            byte[] cookie = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(cookie);\r
+            flowStatsBuilder.setCookie(new BigInteger(cookie));\r
+            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(packetCount);\r
+            flowStatsBuilder.setPacketCount(new BigInteger(packetCount));\r
+            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(byteCount);\r
+            flowStatsBuilder.setByteCount(new BigInteger(byteCount));\r
+            // TODO match\r
+            // TODO instructions\r
+            flowStatsList.add(flowStatsBuilder.build());\r
+        }\r
+        flowBuilder.setFlowStats(flowStatsList);\r
+        return flowBuilder.build();\r
+    }\r
+    \r
+    private static FlowModFlags createFlowModFalgsFromBitmap(short input){\r
+        final Boolean _oFPFFSENDFLOWREM = (input & (1 << 0)) > 0;\r
+        final Boolean _oFPFFCHECKOVERLAP = (input & (1 << 1)) > 0;\r
+        final Boolean _oFPFFRESETCOUNTS = (input & (1 << 2)) > 0; \r
+        final Boolean _oFPFFNOPKTCOUNTS = (input & (1 << 3)) > 0;\r
+        final Boolean _oFPFFNOBYTCOUNTS = (input & (1 << 4)) > 0;\r
+        return new FlowModFlags(_oFPFFCHECKOVERLAP, _oFPFFNOBYTCOUNTS, _oFPFFNOPKTCOUNTS, _oFPFFRESETCOUNTS, _oFPFFSENDFLOWREM);\r
+    }\r
+    \r
+    private static MultipartReplyAggregate setAggregate(ByteBuf input) {\r
+        final byte PADDING_IN_AGGREGATE_HEADER = 4;\r
+        MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();\r
+        byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];\r
+        input.readBytes(packetCount);\r
+        builder.setPacketCount(new BigInteger(packetCount));\r
+        byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];\r
+        input.readBytes(byteCount);\r
+        builder.setByteCount(new BigInteger(byteCount));\r
+        builder.setFlowCount(input.readUnsignedInt());\r
+        input.skipBytes(PADDING_IN_AGGREGATE_HEADER);\r
+        return builder.build();\r
+    }\r
+    \r
+    private static MultipartReplyTable setTable(ByteBuf input) {\r
+        final byte PADDING_IN_TABLE_HEADER = 3;\r
+        MultipartReplyTableBuilder builder = new MultipartReplyTableBuilder();\r
+        TableStatsBuilder tableStatsBuilder = new TableStatsBuilder();\r
+        List<TableStats> tableStatsList = new ArrayList<>();\r
+        while (input.readableBytes() > 0) {\r
+            tableStatsBuilder.setTableId(input.readUnsignedByte());\r
+            input.skipBytes(PADDING_IN_TABLE_HEADER);\r
+            tableStatsBuilder.setActiveCount(input.readUnsignedInt());\r
+            byte[] lookupCount = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(lookupCount);\r
+            tableStatsBuilder.setLookupCount(new BigInteger(lookupCount));\r
+            byte[] matchedCount = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(matchedCount);\r
+            tableStatsBuilder.setMatchedCount(new BigInteger(matchedCount));\r
+            tableStatsList.add(tableStatsBuilder.build());\r
+        }\r
+        builder.setTableStats(tableStatsList);\r
+        return builder.build();\r
+    }\r
+    \r
+    private static MultipartReplyPortStats setPortStats(ByteBuf input) {\r
+        final byte PADDING_IN_PORT_STATS_HEADER = 4;\r
+        MultipartReplyPortStatsBuilder builder = new MultipartReplyPortStatsBuilder();\r
+        PortStatsBuilder portStatsBuilder = new PortStatsBuilder();\r
+        List<PortStats> portStatsList = new ArrayList<>();\r
+        while (input.readableBytes() > 0) {\r
+            portStatsBuilder.setPortNo(input.readUnsignedInt());\r
+            input.skipBytes(PADDING_IN_PORT_STATS_HEADER);\r
+            \r
+            byte[] rxPackets = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(rxPackets);\r
+            portStatsBuilder.setRxPackets(new BigInteger(rxPackets));\r
+            \r
+            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(txPackets);\r
+            portStatsBuilder.setTxPackets(new BigInteger(txPackets));\r
+            \r
+            byte[] rxBytes = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(rxBytes);\r
+            portStatsBuilder.setRxBytes(new BigInteger(rxBytes));\r
+            \r
+            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(txBytes);\r
+            portStatsBuilder.setTxBytes(new BigInteger(txBytes));\r
+            \r
+            byte[] rxDropped = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(rxDropped);\r
+            portStatsBuilder.setRxDropped(new BigInteger(rxDropped));\r
+            \r
+            byte[] txDropped = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(txDropped);\r
+            portStatsBuilder.setTxDropped(new BigInteger(txDropped));\r
+            \r
+            byte[] rxErrors = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(rxErrors);\r
+            portStatsBuilder.setRxErrors(new BigInteger(rxErrors));\r
+            \r
+            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(txErrors);\r
+            portStatsBuilder.setTxErrors(new BigInteger(txErrors));\r
+            \r
+            byte[] rxFrameErr = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(rxFrameErr);\r
+            portStatsBuilder.setRxFrameErr(new BigInteger(rxFrameErr));\r
+            \r
+            byte[] rxOverErr = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(rxOverErr);\r
+            portStatsBuilder.setRxOverErr(new BigInteger(rxOverErr));\r
+            \r
+            byte[] rxCrcErr = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(rxCrcErr);\r
+            portStatsBuilder.setRxCrcErr(new BigInteger(rxCrcErr));\r
+            \r
+            byte[] collisions = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(collisions);\r
+            portStatsBuilder.setCollisions(new BigInteger(collisions));\r
+            \r
+            portStatsBuilder.setDurationSec(input.readUnsignedInt());\r
+            portStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
+            portStatsList.add(portStatsBuilder.build());\r
+        }\r
+        builder.setPortStats(portStatsList);\r
         return builder.build();\r
-    } \r
+    }\r
+    \r
+    private static MultipartReplyQueue setQueue(ByteBuf input) {\r
+        MultipartReplyQueueBuilder builder = new MultipartReplyQueueBuilder();\r
+        QueueStatsBuilder queueStatsBuilder = new QueueStatsBuilder();\r
+        List<QueueStats> queueStatsList = new ArrayList<>();\r
+        \r
+        while (input.readableBytes() > 0) {\r
+            queueStatsBuilder.setPortNo(input.readUnsignedInt());\r
+            queueStatsBuilder.setQueueId(input.readUnsignedInt());\r
+\r
+            byte[] txBytes = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(txBytes);\r
+            queueStatsBuilder.setTxBytes(new BigInteger(txBytes));\r
+\r
+            byte[] txPackets = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(txPackets);\r
+            queueStatsBuilder.setTxPackets(new BigInteger(txPackets));\r
+\r
+            byte[] txErrors = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(txErrors);\r
+            queueStatsBuilder.setTxErrors(new BigInteger(txErrors));\r
+\r
+            queueStatsBuilder.setDurationSec(input.readUnsignedInt());\r
+            queueStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
+            queueStatsList.add(queueStatsBuilder.build());\r
+        }\r
+        builder.setQueueStats(queueStatsList);\r
+        return builder.build();\r
+    }\r
+    \r
+    private static MultipartReplyGroup setGroup(ByteBuf input) {\r
+        final byte PADDING_IN_GROUP_HEADER_01 = 2;\r
+        final byte PADDING_IN_GROUP_HEADER_02 = 4;\r
+        final byte BUCKET_COUNTER_LENGTH = 16;\r
+        final byte GROUP_BODY_LENGTH = 40;\r
+        int actualLength;\r
+        MultipartReplyGroupBuilder builder = new MultipartReplyGroupBuilder();\r
+        GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();\r
+        List<GroupStats> groupStatsList = new ArrayList<>();\r
+        \r
+        BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();\r
+        List<BucketStats> bucketStatsList = new ArrayList<>();\r
+        \r
+        while (input.readableBytes() > 0) {\r
+            int bodyLength = input.readUnsignedShort();\r
+            actualLength = 0;\r
+            \r
+            input.skipBytes(PADDING_IN_GROUP_HEADER_01);\r
+            groupStatsBuilder.setGroupId(input.readUnsignedInt());\r
+            groupStatsBuilder.setRefCount(input.readUnsignedInt());\r
+            input.skipBytes(PADDING_IN_GROUP_HEADER_02);\r
+            byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(packetCount);\r
+            groupStatsBuilder.setPacketCount(new BigInteger(packetCount));\r
+            byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];\r
+            input.readBytes(byteCount);\r
+            groupStatsBuilder.setByteCount(new BigInteger(byteCount));\r
+            groupStatsBuilder.setDurationSec(input.readUnsignedInt());\r
+            groupStatsBuilder.setDurationNsec(input.readUnsignedInt());\r
+            actualLength = GROUP_BODY_LENGTH;\r
+            \r
+            while (actualLength < bodyLength) {\r
+                byte[] packetCountBucket = new byte[Long.SIZE/Byte.SIZE];\r
+                input.readBytes(packetCountBucket);\r
+                bucketStatsBuilder.setPacketCount(new BigInteger(packetCountBucket));\r
+                byte[] byteCountBucket = new byte[Long.SIZE/Byte.SIZE];\r
+                input.readBytes(byteCountBucket);\r
+                bucketStatsBuilder.setByteCount(new BigInteger(byteCountBucket));\r
+                bucketStatsList.add(bucketStatsBuilder.build());\r
+\r
+                groupStatsBuilder.setBucketStats(bucketStatsList);\r
+                groupStatsList.add(groupStatsBuilder.build());\r
+                actualLength = actualLength + BUCKET_COUNTER_LENGTH;\r
+            } \r
+        }\r
+        builder.setGroupStats(groupStatsList);\r
+        return builder.build();\r
+    }\r
 }\r
index 82ab09092c4d1da4e7680ac323bed9c376630b22..2797e8b61c103b0544eeb328863acdc57e030dfe 100644 (file)
@@ -15,7 +15,7 @@ public class ExperimenterInputMessageFactory implements OFSerializer<Experimente
 \r
     /** Code type of Experimenter message */\r
     public static final byte MESSAGE_TYPE = 4;\r
-    private static int dataLength;\r
+    private int dataLength;\r
     private static ExperimenterInputMessageFactory instance;\r
     \r
     private ExperimenterInputMessageFactory() {\r
index 719dc0f4279ce58f693146a858ed428fa5c7a945..27af163902e6f6a39f682e3434f8943a755284d4 100644 (file)
@@ -55,14 +55,14 @@ public class HelloInputMessageFactory implements OFSerializer<HelloInput>{
     \r
     private static int computeElementsLength(List<Elements> elements) {\r
         int versionBitmapSize = 0;\r
-        final int OFHeaderSize = 8;\r
+        final int ofHeaderSize = 8;\r
         int typeSize = 0;\r
         \r
         if (elements != null) {\r
             typeSize = 2;\r
             versionBitmapSize = elements.get(0).getVersionBitmap().size()/Byte.SIZE;\r
             } \r
-        MESSAGE_LENGTH = OFHeaderSize + versionBitmapSize + typeSize;\r
+        MESSAGE_LENGTH = ofHeaderSize + versionBitmapSize + typeSize;\r
         return MESSAGE_LENGTH;\r
     }\r
  \r
index 470d944a9347bcc42e68ea5efda625d7281666de..fda59e66699274534ef5636b42da9cd484f539e7 100644 (file)
@@ -3,10 +3,21 @@ package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
 \r
 import io.netty.buffer.ByteBuf;\r
 \r
+import java.math.BigInteger;\r
+\r
 import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
+import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregate;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDesc;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlow;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroup;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStats;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueue;\r
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTable;\r
 \r
 /**\r
  * @author timotej.kubas\r
@@ -29,4 +40,359 @@ public class MultipartReplyMessageFactoryTest {
         //Assert.assertArrayEquals("Wrong body", new byte[]{0x01, 0x02, 0x03, 0x04}, builtByFactory.getBody());\r
     }\r
     \r
+    /**\r
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testMultipartReplyDescBody(){\r
+        final int DESC_STR_LEN = 256;\r
+        final int SERIAL_NUM_LEN = 32;\r
+        ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 00 00 00");\r
+        \r
+        String mfrDesc = "Manufacturer description";\r
+        byte[] mfrDescBytes = new byte[256];\r
+        mfrDescBytes = mfrDesc.getBytes();\r
+        bb.writeBytes(mfrDescBytes);\r
+        ByteBufUtils.padBuffer((DESC_STR_LEN - mfrDescBytes.length), bb);\r
+        \r
+        String hwDesc = "Hardware description";\r
+        byte[] hwDescBytes = new byte[256];\r
+        hwDescBytes = hwDesc.getBytes();\r
+        bb.writeBytes(hwDescBytes);\r
+        ByteBufUtils.padBuffer((DESC_STR_LEN - hwDescBytes.length), bb);\r
+        \r
+        String swDesc = "Software description";\r
+        byte[] swDescBytes = new byte[256];\r
+        swDescBytes = swDesc.getBytes();\r
+        bb.writeBytes(swDescBytes);\r
+        ByteBufUtils.padBuffer((DESC_STR_LEN - swDescBytes.length), bb);\r
+        \r
+        String serialNum = "SN0123456789";\r
+        byte[] serialNumBytes = new byte[32];\r
+        serialNumBytes = serialNum.getBytes();\r
+        bb.writeBytes(serialNumBytes);\r
+        ByteBufUtils.padBuffer((SERIAL_NUM_LEN - serialNumBytes.length), bb);\r
+        \r
+        String dpDesc = "switch3 in room 3120";\r
+        byte[] dpDescBytes = new byte[256];\r
+        dpDescBytes = dpDesc.getBytes();\r
+        bb.writeBytes(dpDescBytes);\r
+        ByteBufUtils.padBuffer((DESC_STR_LEN - dpDescBytes.length), bb);\r
+        \r
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
+        \r
+        BufferHelper.checkHeaderV13(builtByFactory);\r
+        Assert.assertEquals("Wrong type", 0x00, builtByFactory.getType().getIntValue());\r
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+        MultipartReplyDesc message = (MultipartReplyDesc) builtByFactory.getMultipartReplyBody();\r
+        Assert.assertEquals("Wrong mfrDesc", "Manufacturer description", message.getMfrDesc());\r
+        Assert.assertEquals("Wrong hwDesc", "Hardware description", message.getHwDesc());\r
+        Assert.assertEquals("Wrong swDesc", "Software description", message.getSwDesc());\r
+        Assert.assertEquals("Wrong serialNum", "SN0123456789", message.getSerialNum());\r
+        Assert.assertEquals("Wrong dpDesc", "switch3 in room 3120", message.getDpDesc());\r
+    }\r
+    \r
+    /**\r
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testMultipartReplyFlowBody(){\r
+        ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00 "+\r
+                                              "08 "+//tableId\r
+                                              "00 "+//pad_01\r
+                                              "00 00 00 09 "+//durationSec\r
+                                              "00 00 00 07 "+//durationNsec\r
+                                              "00 0C "+//priority\r
+                                              "00 0E "+//idleTimeout\r
+                                              "00 0F "+//hardTimeout\r
+                                              "00 0B "+//flags\r
+                                              "00 00 00 00 "+//pad_02\r
+                                              "00 01 01 01 01 01 01 01 "+//cookie\r
+                                              "00 01 01 01 01 01 01 01 "+//packetCount\r
+                                              "00 01 01 01 01 01 01 01"//byteCount\r
+                                              );\r
+        \r
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
+        \r
+        BufferHelper.checkHeaderV13(builtByFactory);\r
+        Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());\r
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+        MultipartReplyFlow message = (MultipartReplyFlow) builtByFactory.getMultipartReplyBody();\r
+        Assert.assertEquals("Wrong tableId", 8, message.getFlowStats().get(0).getTableId().intValue());\r
+        Assert.assertEquals("Wrong durationSec", 9, message.getFlowStats().get(0).getDurationSec().intValue());\r
+        Assert.assertEquals("Wrong durationNsec", 7, message.getFlowStats().get(0).getDurationNsec().intValue());\r
+        Assert.assertEquals("Wrong priority", 12, message.getFlowStats().get(0).getPriority().intValue());\r
+        Assert.assertEquals("Wrong idleTimeOut", 14, message.getFlowStats().get(0).getIdleTimeout().intValue());\r
+        Assert.assertEquals("Wrong hardTimeOut", 15, message.getFlowStats().get(0).getHardTimeout().intValue());\r
+        Assert.assertEquals("Wrong flags", new FlowModFlags(true, false, true, false, true), \r
+                                           message.getFlowStats().get(0).getFlags());\r
+        Assert.assertEquals("Wrong cookie", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getFlowStats().get(0).getCookie());\r
+        Assert.assertEquals("Wrong packetCount", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getFlowStats().get(0).getPacketCount());\r
+        Assert.assertEquals("Wrong byteCount", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getFlowStats().get(0).getByteCount());\r
+    }\r
+    \r
+    /**\r
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testMultipartReplyAggregateBody(){\r
+        ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 00 00 00 00 "+\r
+                                              "00 01 01 01 01 01 01 01 "+//packetCount\r
+                                              "00 01 01 01 01 01 01 01 "+//byteCount\r
+                                              "00 00 00 08 "+//flowCount\r
+                                              "00 00 00 00"//pad\r
+                                              );\r
+        \r
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
+        \r
+        BufferHelper.checkHeaderV13(builtByFactory);\r
+        Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());\r
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+        MultipartReplyAggregate message = (MultipartReplyAggregate) builtByFactory.getMultipartReplyBody();\r
+        Assert.assertEquals("Wrong packetCount", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getPacketCount());\r
+        Assert.assertEquals("Wrong byteCount", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getByteCount());\r
+        Assert.assertEquals("Wrong flowCount", \r
+                8, \r
+                message.getFlowCount().intValue());\r
+    }\r
+    \r
+    /**\r
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testMultipartReplyTableBody(){\r
+        ByteBuf bb = BufferHelper.buildBuffer("00 03 00 01 00 00 00 00 "+\r
+                                              "08 "+//tableId\r
+                                              "00 00 00 "+//pad\r
+                                              "00 00 00 10 "+//activeCount\r
+                                              "00 01 01 01 01 01 01 01 "+//lookupCount\r
+                                              "00 01 01 01 01 01 01 01"//matchedCount\r
+                                              );\r
+        \r
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
+        \r
+        BufferHelper.checkHeaderV13(builtByFactory);\r
+        Assert.assertEquals("Wrong type", 0x03, builtByFactory.getType().getIntValue());\r
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+        \r
+        MultipartReplyTable message = (MultipartReplyTable) builtByFactory.getMultipartReplyBody();\r
+        Assert.assertEquals("Wrong tableId", 8, message.getTableStats().get(0).getTableId().intValue());\r
+        Assert.assertEquals("Wrong activeCount", 16, message.getTableStats().get(0).getActiveCount().longValue());\r
+        Assert.assertEquals("Wrong lookupCount", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getTableStats().get(0).getLookupCount());\r
+        Assert.assertEquals("Wrong matchedCount", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getTableStats().get(0).getMatchedCount());\r
+    }\r
+    \r
+    /**\r
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testMultipartReplyPortStatsBody(){\r
+        ByteBuf bb = BufferHelper.buildBuffer("00 04 00 01 00 00 00 00 "+\r
+                                              "00 00 00 FF "+//portNo\r
+                                              "00 00 00 00 "+//pad\r
+                                              "00 01 01 01 01 01 01 01 "+//rxPackets\r
+                                              "00 02 02 02 02 02 02 02 "+//txPackets\r
+                                              "00 02 03 02 03 02 03 02 "+//rxBytes\r
+                                              "00 02 03 02 03 02 03 02 "+//txBytes\r
+                                              "00 02 03 02 03 02 03 02 "+//rxDropped\r
+                                              "00 02 03 02 03 02 03 02 "+//txDropped\r
+                                              "00 02 03 02 03 02 03 02 "+//rxErrors\r
+                                              "00 02 03 02 03 02 03 02 "+//txErrors\r
+                                              "00 02 03 02 03 02 03 02 "+//rxFrameErr\r
+                                              "00 02 03 02 03 02 03 02 "+//rxOverErr\r
+                                              "00 02 03 02 03 02 03 02 "+//rxCrcErr\r
+                                              "00 02 03 02 03 02 03 02 "+//collisions\r
+                                              "00 00 00 02 "+//durationSec\r
+                                              "00 00 00 04"//durationNsec\r
+                                              );\r
+        \r
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
+        \r
+        BufferHelper.checkHeaderV13(builtByFactory);\r
+        Assert.assertEquals("Wrong type", 0x04, builtByFactory.getType().getIntValue());\r
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+        \r
+        MultipartReplyPortStats message = (MultipartReplyPortStats) builtByFactory.getMultipartReplyBody();\r
+        \r
+        Assert.assertEquals("Wrong portNo", 255, message.getPortStats().get(0).getPortNo().intValue());\r
+        Assert.assertEquals("Wrong rxPackets", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getPortStats().get(0).getRxPackets());\r
+        Assert.assertEquals("Wrong txPackets", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
+                message.getPortStats().get(0).getTxPackets());\r
+        Assert.assertEquals("Wrong rxBytes", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getRxBytes());\r
+        Assert.assertEquals("Wrong txBytes", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getTxBytes());\r
+        Assert.assertEquals("Wrong rxDropped", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getRxDropped());\r
+        Assert.assertEquals("Wrong txDropped", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getTxDropped());\r
+        Assert.assertEquals("Wrong rxErrors", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getRxErrors());\r
+        Assert.assertEquals("Wrong txErrors", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getTxErrors());\r
+        Assert.assertEquals("Wrong rxFrameErr", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getRxFrameErr());\r
+        Assert.assertEquals("Wrong rxOverErr", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getRxOverErr());\r
+        Assert.assertEquals("Wrong rxCrcErr", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getRxCrcErr());\r
+        Assert.assertEquals("Wrong collisions", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getPortStats().get(0).getCollisions());\r
+        Assert.assertEquals("Wrong durationSec", 2, message.getPortStats().get(0).getDurationSec().intValue());\r
+        Assert.assertEquals("Wrong durationNsec", 4, message.getPortStats().get(0).getDurationNsec().intValue());\r
+    }\r
+    \r
+    /**\r
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testMultipartReplyQueueBody(){\r
+        ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 "+\r
+                                              "00 00 00 FF "+//portNo\r
+                                              "00 00 00 10 "+//queueId\r
+                                              "00 02 03 02 03 02 03 02 "+//txBytes\r
+                                              "00 02 02 02 02 02 02 02 "+//txPackets\r
+                                              "00 02 03 02 03 02 03 02 "+//txErrors\r
+                                              "00 00 00 02 "+//durationSec\r
+                                              "00 00 00 04"//durationNsec\r
+                                              );\r
+        \r
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
+        \r
+        BufferHelper.checkHeaderV13(builtByFactory);\r
+        Assert.assertEquals("Wrong type", 0x05, builtByFactory.getType().getIntValue());\r
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+        \r
+        MultipartReplyQueue message = (MultipartReplyQueue) builtByFactory.getMultipartReplyBody();\r
+        \r
+        Assert.assertEquals("Wrong portNo", 255, message.getQueueStats().get(0).getPortNo().intValue());\r
+        Assert.assertEquals("Wrong queueId", 16, message.getQueueStats().get(0).getQueueId().intValue());\r
+        Assert.assertEquals("Wrong txBytes", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getQueueStats().get(0).getTxBytes());\r
+        Assert.assertEquals("Wrong txPackets", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
+                message.getQueueStats().get(0).getTxPackets());\r
+        Assert.assertEquals("Wrong txErrors", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x03, 0x02, 0x03, 0x02, 0x03, 0x02}), \r
+                message.getQueueStats().get(0).getTxErrors());\r
+        Assert.assertEquals("Wrong durationSec", 2, message.getQueueStats().get(0).getDurationSec().intValue());\r
+        Assert.assertEquals("Wrong durationNsec", 4, message.getQueueStats().get(0).getDurationNsec().intValue());\r
+    }\r
+    \r
+    /**\r
+     * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO\r
+     */\r
+    @Test\r
+    public void testMultipartReplyGroupBody(){\r
+        ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 "+\r
+                                              "00 48 "+//length\r
+                                              "00 00 "+//pad1\r
+                                              "00 00 00 10 "+//groupId\r
+                                              "00 00 00 12 "+//refCount\r
+                                              "00 00 00 00 "+//pad2\r
+                                              "00 01 01 01 01 01 01 01 "+//packetCount\r
+                                              "00 01 01 01 01 01 01 01 "+//byteCount\r
+                                              "00 00 00 08 "+//durationSec\r
+                                              "00 00 00 09 "+//durationNsec\r
+                                              "00 01 01 01 01 01 01 01 "+//packetCountBucket\r
+                                              "00 01 01 01 01 01 01 01 "+//byteCountBucket\r
+                                              "00 02 02 02 02 02 02 02 "+//packetCountBucket_2\r
+                                              "00 02 02 02 02 02 02 02 "+//byteCountBucket_2\r
+                                              "00 48 "+//length_2\r
+                                              "00 00 "+//pad1.2\r
+                                              "00 00 00 10 "+//groupId_2\r
+                                              "00 00 00 12 "+//refCount_2\r
+                                              "00 00 00 00 "+//pad2.2\r
+                                              "00 01 01 01 01 01 01 01 "+//packetCount_2\r
+                                              "00 01 01 01 01 01 01 01 "+//byteCount_2\r
+                                              "00 00 00 08 "+//durationSec_2\r
+                                              "00 00 00 09 "+//durationNsec_2\r
+                                              "00 01 01 01 01 01 01 01 "+//packetCountBucket_1.2\r
+                                              "00 01 01 01 01 01 01 01 "+//byteCountBucket_1.2\r
+                                              "00 02 02 02 02 02 02 02 "+//packetCountBucket_2.2\r
+                                              "00 02 02 02 02 02 02 02"//byteCountBucket_2.2\r
+                                              );\r
+        \r
+        MultipartReplyMessage builtByFactory = BufferHelper.decodeV13(MultipartReplyMessageFactory.getInstance(), bb);\r
+        \r
+        BufferHelper.checkHeaderV13(builtByFactory);\r
+        Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());\r
+        Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());\r
+        \r
+        MultipartReplyGroup message = (MultipartReplyGroup) builtByFactory.getMultipartReplyBody();\r
+        \r
+        Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().intValue());\r
+        Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());\r
+        Assert.assertEquals("Wrong packetCount", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getGroupStats().get(0).getPacketCount());\r
+        Assert.assertEquals("Wrong byteCount", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getGroupStats().get(0).getByteCount());\r
+        Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());\r
+        Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());\r
+        Assert.assertEquals("Wrong packetCountBucket", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());\r
+        Assert.assertEquals("Wrong byteCountBucket", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());\r
+        Assert.assertEquals("Wrong packetCountBucket_2", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
+                message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());\r
+        Assert.assertEquals("Wrong byteCountBucket_2", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
+                message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());\r
+        \r
+        Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().intValue());\r
+        Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());\r
+        Assert.assertEquals("Wrong packetCount_2", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getGroupStats().get(1).getPacketCount());\r
+        Assert.assertEquals("Wrong byteCount_2", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getGroupStats().get(1).getByteCount());\r
+        Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());\r
+        Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());\r
+        Assert.assertEquals("Wrong packetCountBucket_1.2", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());\r
+        Assert.assertEquals("Wrong byteCountBucket_1.2", \r
+                new BigInteger(new byte[]{0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01}), \r
+                message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());\r
+        Assert.assertEquals("Wrong packetCountBucket_2.2", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
+                message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());\r
+        Assert.assertEquals("Wrong byteCountBucket_2.2", \r
+                new BigInteger(new byte[]{0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02}), \r
+                message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());\r
+    }\r
 }\r