Search in sources :

Example 1 with GetQueueConfigOutput

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

the class QueueGetConfigReplyMessageFactory method serialize.

@Override
public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) {
    ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
    outBuffer.writeInt(message.getPort().getValue().intValue());
    outBuffer.writeZero(PADDING);
    for (Queues queue : message.getQueues()) {
        ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        queueBuff.writeInt(queue.getQueueId().getValue().intValue());
        queueBuff.writeInt(queue.getPort().getValue().intValue());
        queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        queueBuff.writeZero(QUEUE_PADDING);
        for (QueueProperty property : queue.getQueueProperty()) {
            ByteBuf propertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
            propertyBuff.writeShort(property.getProperty().getIntValue());
            propertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
            propertyBuff.writeZero(PROPERTY_HEADER_PADDING);
            switch(property.getProperty()) {
                case OFPQTMINRATE:
                case OFPQTMAXRATE:
                    serializeRateBody(property.getAugmentation(RateQueueProperty.class), propertyBuff);
                    break;
                case OFPQTEXPERIMENTER:
                    serializeExperimenterBody(property.getAugmentation(ExperimenterIdQueueProperty.class), propertyBuff);
                    break;
                default:
                    break;
            }
            propertyBuff.setShort(PROPERTY_LENGTH_INDEX, propertyBuff.readableBytes());
            queueBuff.writeBytes(propertyBuff);
        }
        queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes());
        outBuffer.writeBytes(queueBuff);
    }
    ByteBufUtils.updateOFHeaderLength(outBuffer);
}
Also used : RateQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty) ExperimenterIdQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdQueueProperty) Queues(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues) ByteBuf(io.netty.buffer.ByteBuf) QueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty) ExperimenterIdQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdQueueProperty) RateQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty)

Example 2 with GetQueueConfigOutput

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

the class QueueGetConfigReplyMessageFactory method deserialize.

@Override
public GetQueueConfigOutput deserialize(ByteBuf rawMessage) {
    Objects.requireNonNull(registry);
    GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPort(new PortNumber(rawMessage.readUnsignedInt()));
    rawMessage.skipBytes(PADDING_IN_QUEUE_GET_CONFIG_REPLY_HEADER);
    builder.setQueues(createQueuesList(rawMessage));
    return builder.build();
}
Also used : GetQueueConfigOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Example 3 with GetQueueConfigOutput

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

the class OF10QueueGetConfigReplyMessageFactory method serialize.

@Override
public void serialize(GetQueueConfigOutput message, ByteBuf outBuffer) {
    ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH);
    outBuffer.writeShort(message.getPort().getValue().intValue());
    outBuffer.writeZero(PADDING);
    for (Queues queue : message.getQueues()) {
        ByteBuf queueBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        queueBuff.writeInt(queue.getQueueId().getValue().intValue());
        queueBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        queueBuff.writeZero(QUEUE_PADDING);
        for (QueueProperty queueProperty : queue.getQueueProperty()) {
            ByteBuf queuePropertyBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
            queuePropertyBuff.writeShort(queueProperty.getProperty().getIntValue());
            queuePropertyBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
            queuePropertyBuff.writeZero(4);
            if (queueProperty.getProperty() == QueueProperties.OFPQTMINRATE) {
                RateQueueProperty body = queueProperty.getAugmentation(RateQueueProperty.class);
                queuePropertyBuff.writeShort(body.getRate().intValue());
                queuePropertyBuff.writeZero(QUEUE_PROPERTY_PADDING);
            }
            queuePropertyBuff.setShort(QUEUE_PROPERTY_LENGTH_INDEX, queuePropertyBuff.readableBytes());
            queueBuff.writeBytes(queuePropertyBuff);
        }
        queueBuff.setShort(QUEUE_LENGTH_INDEX, queueBuff.readableBytes());
        outBuffer.writeBytes(queueBuff);
    }
    ByteBufUtils.updateOFHeaderLength(outBuffer);
}
Also used : RateQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty) Queues(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues) ByteBuf(io.netty.buffer.ByteBuf) QueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty) RateQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty)

Example 4 with GetQueueConfigOutput

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

the class QueueGetConfigReplyMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    GetQueueConfigOutputBuilder builder = new GetQueueConfigOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPort(new PortNumber(0x00010203L));
    builder.setQueues(createQueuesList());
    GetQueueConfigOutput message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80);
    Assert.assertEquals("Wrong port", message.getPort().getValue().longValue(), serializedBuffer.readInt());
    serializedBuffer.skipBytes(PADDING);
    Assert.assertEquals("Wrong queue Id", message.getQueues().get(0).getQueueId().getValue().longValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong port", message.getQueues().get(0).getPort().getValue().longValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong length", 32, serializedBuffer.readShort());
    serializedBuffer.skipBytes(QUEUE_PADDING);
    List<QueueProperty> properties = message.getQueues().get(0).getQueueProperty();
    Assert.assertEquals("Wrong property", properties.get(0).getProperty().getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort());
    serializedBuffer.skipBytes(PROPERTY_HEADER_PADDING);
    RateQueueProperty rateQueueProperty = properties.get(0).getAugmentation(RateQueueProperty.class);
    Assert.assertEquals("Wrong rate", rateQueueProperty.getRate().intValue(), serializedBuffer.readShort());
    serializedBuffer.skipBytes(PROPERTY_RATE_PADDING);
    Assert.assertEquals("Wrong queue Id", message.getQueues().get(1).getQueueId().getValue().longValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong queue Id", message.getQueues().get(1).getPort().getValue().longValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong length", 32, serializedBuffer.readShort());
    serializedBuffer.skipBytes(QUEUE_PADDING);
    List<QueueProperty> propertiesTwo = message.getQueues().get(1).getQueueProperty();
    Assert.assertEquals("Wrong property", propertiesTwo.get(0).getProperty().getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong property length", 16, serializedBuffer.readShort());
    serializedBuffer.skipBytes(PROPERTY_HEADER_PADDING);
    RateQueueProperty rateQueuePropertyTwo = propertiesTwo.get(0).getAugmentation(RateQueueProperty.class);
    Assert.assertEquals("Wrong rate", rateQueuePropertyTwo.getRate().intValue(), serializedBuffer.readShort());
    serializedBuffer.skipBytes(PROPERTY_RATE_PADDING);
}
Also used : GetQueueConfigOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput) RateQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty) GetQueueConfigOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) ByteBuf(io.netty.buffer.ByteBuf) QueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty) RateQueueProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty) Test(org.junit.Test)

Example 5 with GetQueueConfigOutput

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

the class QueueGetConfigReplyMessageFactoryTest method test.

/**
 * Testing {@link QueueGetConfigReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 03 00 00 00 00 00 00 00 01 00 00 00 03 00 20 00 00 00 00 " + "00 00 00 02 00 10 00 00 00 00 00 05 00 00 00 00 00 00");
    GetQueueConfigOutput builtByFactory = BufferHelper.deserialize(queueFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong port", 3L, builtByFactory.getPort().getValue().longValue());
    Assert.assertEquals("Wrong queues", builtByFactory.getQueues(), createQueuesList());
}
Also used : GetQueueConfigOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)7 Test (org.junit.Test)5 RateQueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty)5 GetQueueConfigOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput)5 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)4 GetQueueConfigOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder)4 QueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty)4 Queues (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues)3 ExperimenterIdQueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdQueueProperty)1