Search in sources :

Example 16 with MultipartReplyBody

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

the class OF10StatsReplyMessageFactory method serializeDescBody.

private void serializeDescBody(MultipartReplyBody body, ByteBuf outBuffer) {
    MultipartReplyDescCase descCase = (MultipartReplyDescCase) body;
    MultipartReplyDesc desc = descCase.getMultipartReplyDesc();
    write256String(desc.getMfrDesc(), outBuffer);
    write256String(desc.getHwDesc(), outBuffer);
    write256String(desc.getSwDesc(), outBuffer);
    write32String(desc.getSerialNum(), outBuffer);
    write256String(desc.getDpDesc(), outBuffer);
}
Also used : MultipartReplyDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase) MultipartReplyDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc)

Example 17 with MultipartReplyBody

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

the class MultipartReplyFlowAggregateStatsDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    message.readBytes(packetCount);
    final byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    message.readBytes(byteCount);
    final MultipartReplyFlowAggregateStatsBuilder builder = new MultipartReplyFlowAggregateStatsBuilder().setPacketCount(new Counter64(new BigInteger(1, packetCount))).setByteCount(new Counter64(new BigInteger(1, byteCount))).setFlowCount(new Counter32(message.readUnsignedInt()));
    message.skipBytes(PADDING_IN_AGGREGATE_HEADER);
    return builder.build();
}
Also used : MultipartReplyFlowAggregateStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) BigInteger(java.math.BigInteger)

Example 18 with MultipartReplyBody

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

the class MultipartReplyMessageDeserializer method deserialize.

@Override
public MultipartReply deserialize(ByteBuf message) {
    final long xid = message.readUnsignedInt();
    final int type = message.readUnsignedShort();
    final boolean reqMore = (message.readUnsignedShort() & 0x01) != 0;
    message.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
    final OFDeserializer<MultipartReplyBody> deserializer = Preconditions.checkNotNull(registry).getDeserializer(new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, type, MultipartReplyBody.class));
    return new MultipartReplyBuilder().setVersion((short) EncodeConstants.OF13_VERSION_ID).setXid(xid).setRequestMore(reqMore).setMultipartReplyBody(deserializer.deserialize(message)).build();
}
Also used : MultipartReplyBody(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.multipart.reply.MultipartReplyBody) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder)

Example 19 with MultipartReplyBody

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

the class MultipartReplyPortDescDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
    final List<Ports> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final PortsBuilder itemBuilder = new PortsBuilder();
        itemBuilder.setPortNumber(new PortNumberUni(message.readUnsignedInt()));
        message.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
        itemBuilder.setHardwareAddress(ByteBufUtils.readIetfMacAddress(message));
        message.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
        items.add(itemBuilder.setName(ByteBufUtils.decodeNullTerminatedString(message, EncodeConstants.MAX_PORT_NAME_LENGTH)).setConfiguration(readPortConfig(message)).setState(readPortState(message)).setCurrentFeature(readPortFeatures(message)).setAdvertisedFeatures(readPortFeatures(message)).setSupported(readPortFeatures(message)).setPeerFeatures(readPortFeatures(message)).setCurrentSpeed(message.readUnsignedInt()).setMaximumSpeed(message.readUnsignedInt()).build());
    }
    return builder.setPorts(items).build();
}
Also used : MultipartReplyPortDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.MultipartReplyPortDescBuilder) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) ArrayList(java.util.ArrayList) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports) PortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.PortsBuilder)

Example 20 with MultipartReplyBody

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

the class MultipartReplyMessageFactoryTest method testFlowBody.

private static void testFlowBody(MultipartReplyBody body, ByteBuf output) {
    MultipartReplyFlowCase flowCase = (MultipartReplyFlowCase) body;
    MultipartReplyFlow flow = flowCase.getMultipartReplyFlow();
    FlowStats flowStats = flow.getFlowStats().get(0);
    Assert.assertEquals("Wrong length", 176, output.readShort());
    Assert.assertEquals("Wrong Table ID", flowStats.getTableId().intValue(), output.readUnsignedByte());
    output.skipBytes(1);
    Assert.assertEquals("Wrong duration sec", flowStats.getDurationSec().intValue(), output.readInt());
    Assert.assertEquals("Wrong duration nsec", flowStats.getDurationNsec().intValue(), output.readInt());
    Assert.assertEquals("Wrong priority", flowStats.getPriority().intValue(), output.readShort());
    Assert.assertEquals("Wrong idle timeout", flowStats.getIdleTimeout().intValue(), output.readShort());
    Assert.assertEquals("Wrong hard timeout", flowStats.getHardTimeout().intValue(), output.readShort());
    output.skipBytes(6);
    Assert.assertEquals("Wrong cookie", flowStats.getCookie().longValue(), output.readLong());
    Assert.assertEquals("Wrong Packet count", flowStats.getPacketCount().longValue(), output.readLong());
    Assert.assertEquals("Wrong Byte count", flowStats.getByteCount().longValue(), output.readLong());
    Assert.assertEquals("Wrong match type", 1, output.readUnsignedShort());
    output.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
    Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort());
    short fieldAndMask = output.readUnsignedByte();
    Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
    Assert.assertEquals("Wrong oxm field", 1, fieldAndMask >> 1);
    output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    Assert.assertEquals("Wrong oxm value", 42, output.readUnsignedInt());
    Assert.assertEquals("Wrong oxm class", 0x8000, output.readUnsignedShort());
    fieldAndMask = output.readUnsignedByte();
    Assert.assertEquals("Wrong oxm hasMask", 0, fieldAndMask & 1);
    Assert.assertEquals("Wrong oxm field", 9, fieldAndMask >> 1);
    output.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES);
    Assert.assertEquals("Wrong oxm value", 4, output.readUnsignedByte());
    output.skipBytes(7);
    Assert.assertEquals("Wrong instruction type", 1, output.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
    Assert.assertEquals("Wrong instruction table-id", 5, output.readUnsignedByte());
    output.skipBytes(3);
    Assert.assertEquals("Wrong instruction type", 2, output.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort());
    output.skipBytes(4);
    byte[] actual = new byte[8];
    output.readBytes(actual);
    Assert.assertEquals("Wrong instruction metadata", "00 01 02 03 04 05 06 07", ByteBufUtils.bytesToHexString(actual));
    actual = new byte[8];
    output.readBytes(actual);
    Assert.assertEquals("Wrong instruction metadata-mask", "07 06 05 04 03 02 01 00", ByteBufUtils.bytesToHexString(actual));
    Assert.assertEquals("Wrong instruction type", 5, output.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
    output.skipBytes(4);
    Assert.assertEquals("Wrong instruction type", 6, output.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 8, output.readUnsignedShort());
    Assert.assertEquals("Wrong instruction meter-id", 42, output.readUnsignedInt());
    Assert.assertEquals("Wrong instruction type", 3, output.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 32, output.readUnsignedShort());
    output.skipBytes(4);
    Assert.assertEquals("Wrong action type", 0, output.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 16, output.readUnsignedShort());
    Assert.assertEquals("Wrong action type", 45, output.readUnsignedInt());
    Assert.assertEquals("Wrong action type", 55, output.readUnsignedShort());
    output.skipBytes(6);
    Assert.assertEquals("Wrong action type", 23, output.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
    Assert.assertEquals("Wrong action type", 64, output.readUnsignedByte());
    output.skipBytes(3);
    Assert.assertEquals("Wrong instruction type", 4, output.readUnsignedShort());
    Assert.assertEquals("Wrong instruction length", 24, output.readUnsignedShort());
    output.skipBytes(4);
    Assert.assertEquals("Wrong action type", 17, output.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
    Assert.assertEquals("Wrong action ethertype", 14, output.readUnsignedShort());
    output.skipBytes(2);
    Assert.assertEquals("Wrong action type", 27, output.readUnsignedShort());
    Assert.assertEquals("Wrong action length", 8, output.readUnsignedShort());
    output.skipBytes(4);
    Assert.assertTrue("Not all data were read", output.readableBytes() == 0);
}
Also used : FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)

Aggregations

ArrayList (java.util.ArrayList)11 ByteBuf (io.netty.buffer.ByteBuf)9 BigInteger (java.math.BigInteger)8 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)7 Counter64 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64)6 BucketId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId)2 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)2 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)2 MeterId (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId)2 DurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.statistics.types.rev130925.duration.DurationBuilder)2 MultipartReplyAggregateCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase)2 MultipartReplyFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)2 MultipartReplyTableCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCase)2 MultipartReplyAggregate (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregate)2 MultipartReplyFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow)2 FlowStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats)2 MultipartReplyTable (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTable)2 TableStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStats)2 List (java.util.List)1 OFDeserializer (org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer)1