- 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);
- byte[] cookie = new byte[Long.SIZE/Byte.SIZE];
- input.readBytes(cookie);
- flowStatsBuilder.setCookie(new BigInteger(cookie));
- byte[] packetCount = new byte[Long.SIZE/Byte.SIZE];
- input.readBytes(packetCount);
- flowStatsBuilder.setPacketCount(new BigInteger(packetCount));
- byte[] byteCount = new byte[Long.SIZE/Byte.SIZE];
- input.readBytes(byteCount);
- flowStatsBuilder.setByteCount(new BigInteger(byteCount));
- flowStatsBuilder.setMatch(MatchDeserializer.createMatch(input));
- flowStatsBuilder.setInstructions(InstructionsDeserializer.createInstructions(input, input.readableBytes()));
+ 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];
+ subInput.readBytes(cookie);
+ flowStatsBuilder.setCookie(new BigInteger(1, cookie));
+ byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+ subInput.readBytes(packetCount);
+ flowStatsBuilder.setPacketCount(new BigInteger(1, packetCount));
+ byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
+ subInput.readBytes(byteCount);
+ flowStatsBuilder.setByteCount(new BigInteger(1, byteCount));
+ OFDeserializer<Match> matchDeserializer = registry.getDeserializer(new MessageCodeKey(
+ EncodeConstants.OF13_VERSION_ID, EncodeConstants.EMPTY_VALUE, Match.class));
+ flowStatsBuilder.setMatch(matchDeserializer.deserialize(subInput));
+ CodeKeyMaker keyMaker = CodeKeyMakerFactory
+ .createInstructionsKeyMaker(EncodeConstants.OF13_VERSION_ID);
+ List<Instruction> instructions = ListDeserializer.deserializeList(
+ EncodeConstants.OF13_VERSION_ID, subInput.readableBytes(), subInput, keyMaker, registry);
+ flowStatsBuilder.setInstruction(instructions);