Search in sources :

Example 1 with MultipartReplyAggregateCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method setAggregate.

private static MultipartReplyAggregateCase setAggregate(final ByteBuf input) {
    final MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder();
    MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
    byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    input.readBytes(packetCount);
    builder.setPacketCount(new BigInteger(1, packetCount));
    byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    input.readBytes(byteCount);
    builder.setByteCount(new BigInteger(1, byteCount));
    builder.setFlowCount(input.readUnsignedInt());
    input.skipBytes(PADDING_IN_AGGREGATE_HEADER);
    caseBuilder.setMultipartReplyAggregate(builder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) BigInteger(java.math.BigInteger) MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder)

Example 2 with MultipartReplyAggregateCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase in project openflowplugin by opendaylight.

the class AggregatedFlowStatisticsTranslator method translate.

@Override
public AggregatedFlowStatistics translate(final MultipartReply input, final DeviceInfo deviceInfo, final Object connectionDistinguisher) {
    AggregatedFlowStatisticsBuilder aggregatedFlowStatisticsBuilder = new AggregatedFlowStatisticsBuilder();
    MultipartReplyAggregateCase caseBody = (MultipartReplyAggregateCase) input.getMultipartReplyBody();
    MultipartReplyAggregate replyBody = caseBody.getMultipartReplyAggregate();
    aggregatedFlowStatisticsBuilder.setByteCount(new Counter64(replyBody.getByteCount()));
    aggregatedFlowStatisticsBuilder.setFlowCount(new Counter32(replyBody.getFlowCount()));
    aggregatedFlowStatisticsBuilder.setPacketCount(new Counter64(replyBody.getPacketCount()));
    return aggregatedFlowStatisticsBuilder.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyAggregateCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) MultipartReplyAggregate(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder)

Example 3 with MultipartReplyAggregateCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactory method setAggregate.

private static MultipartReplyAggregateCase setAggregate(ByteBuf input) {
    final MultipartReplyAggregateCaseBuilder caseBuilder = new MultipartReplyAggregateCaseBuilder();
    MultipartReplyAggregateBuilder builder = new MultipartReplyAggregateBuilder();
    byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    input.readBytes(packetCount);
    builder.setPacketCount(new BigInteger(1, packetCount));
    byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    input.readBytes(byteCount);
    builder.setByteCount(new BigInteger(1, byteCount));
    builder.setFlowCount(input.readUnsignedInt());
    input.skipBytes(PADDING_IN_AGGREGATE_HEADER);
    caseBuilder.setMultipartReplyAggregate(builder.build());
    return caseBuilder.build();
}
Also used : MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) BigInteger(java.math.BigInteger) MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder)

Example 4 with MultipartReplyAggregateCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testAggregateSerialize.

@Test
public void testAggregateSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(2));
    final MultipartReplyAggregateCaseBuilder aggregateCase = new MultipartReplyAggregateCaseBuilder();
    MultipartReplyAggregateBuilder aggregate = new MultipartReplyAggregateBuilder();
    aggregate.setPacketCount(BigInteger.valueOf(1L));
    aggregate.setByteCount(BigInteger.valueOf(1L));
    aggregate.setFlowCount(1L);
    aggregateCase.setMultipartReplyAggregate(aggregate.build());
    builder.setMultipartReplyBody(aggregateCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 40);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPAGGREGATE.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyAggregateCase body = (MultipartReplyAggregateCase) message.getMultipartReplyBody();
    MultipartReplyAggregate messageOutput = body.getMultipartReplyAggregate();
    Assert.assertEquals("Wrong Packet count", messageOutput.getPacketCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong Byte count", messageOutput.getByteCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong Flow count", messageOutput.getFlowCount().longValue(), serializedBuffer.readInt());
    serializedBuffer.skipBytes(4);
}
Also used : MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) MultipartReplyAggregateCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyAggregate(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder) Test(org.junit.Test)

Example 5 with MultipartReplyAggregateCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactoryTest method testAggregate.

/**
 * Testing OF10StatsReplyMessageFactory (Aggregate) for correct deserialization.
 */
@Test
public void testAggregate() {
    ByteBuf bb = BufferHelper.buildBuffer("00 02 00 01 " + "FF 01 02 03 04 05 06 07 FF 00 00 00 00 00 00 20 00 00 00 30 00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(statsFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 0x02, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE().booleanValue());
    MultipartReplyAggregateCase messageCase = (MultipartReplyAggregateCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyAggregate message = messageCase.getMultipartReplyAggregate();
    Assert.assertEquals("Wrong packet-count", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 }), message.getPacketCount());
    Assert.assertEquals("Wrong byte-count", new BigInteger(1, new byte[] { (byte) 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20 }), message.getByteCount());
    Assert.assertEquals("Wrong flow-count", 48, message.getFlowCount().intValue());
    Assert.assertTrue("Unread data", bb.readableBytes() == 0);
}
Also used : MultipartReplyAggregateCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyAggregate(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

MultipartReplyAggregateCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase)7 MultipartReplyAggregate (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate)7 BigInteger (java.math.BigInteger)4 ByteBuf (io.netty.buffer.ByteBuf)3 Test (org.junit.Test)3 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 MultipartReplyAggregateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder)3 MultipartReplyAggregateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder)3 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)2 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)2 AggregatedFlowStatisticsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder)1 MultipartReplyFlowAggregateStatsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder)1 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)1 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)1