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
8 package org.opendaylight.openflowplugin.impl.protocol.deserialization.multipart;
10 import io.netty.buffer.ByteBuf;
11 import java.math.BigInteger;
12 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody;
18 public class MultipartReplyFlowAggregateStatsDeserializer implements OFDeserializer<MultipartReplyBody> {
19 private static final byte PADDING_IN_AGGREGATE_HEADER = 4;
22 public MultipartReplyBody deserialize(ByteBuf message) {
23 final byte[] packetCount = new byte[Long.BYTES];
24 message.readBytes(packetCount);
25 final byte[] byteCount = new byte[Long.BYTES];
26 message.readBytes(byteCount);
28 final MultipartReplyFlowAggregateStatsBuilder builder = new MultipartReplyFlowAggregateStatsBuilder()
29 .setPacketCount(new Counter64(new BigInteger(1, packetCount)))
30 .setByteCount(new Counter64(new BigInteger(1, byteCount)))
31 .setFlowCount(new Counter32(message.readUnsignedInt()));
33 message.skipBytes(PADDING_IN_AGGREGATE_HEADER);
34 return builder.build();