2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
11 import io.netty.buffer.ByteBuf;
12 import java.math.BigInteger;
13 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
20 public class MultipartReplyFlowAggregateStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
22 private static final byte PADDING_IN_AGGREGATE_HEADER = 4;
25 public MultipartReplyBody deserialize(ByteBuf message) {
26 final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
27 message.readBytes(packetCount);
28 final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
29 message.readBytes(byteCount);
31 final MultipartReplyFlowAggregateStatsBuilder builder = new MultipartReplyFlowAggregateStatsBuilder()
32 .setPacketCount(new Counter64(new BigInteger(1, packetCount)))
33 .setByteCount(new Counter64(new BigInteger(1, byteCount)))
34 .setFlowCount(new Counter32(message.readUnsignedInt()));
36 message.skipBytes(PADDING_IN_AGGREGATE_HEADER);
37 return builder.build();