Search in sources :

Example 1 with Queues

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues 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 Queues

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues in project openflowplugin by opendaylight.

the class QueueGetConfigReplyMessageFactoryTest method createQueuesList.

private static List<Queues> createQueuesList() {
    final List<Queues> queuesList = new ArrayList<>();
    QueuesBuilder qb = new QueuesBuilder();
    qb.setQueueId(new QueueId(1L));
    qb.setPort(new PortNumber(3L));
    qb.setQueueProperty(createPropertiesList());
    queuesList.add(qb.build());
    return queuesList;
}
Also used : ArrayList(java.util.ArrayList) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId) Queues(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) QueuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder)

Example 3 with Queues

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues in project openflowplugin by opendaylight.

the class QueueGetConfigReplyMessageFactory method createQueuesList.

private List<Queues> createQueuesList(ByteBuf input) {
    List<Queues> queuesList = new ArrayList<>();
    while (input.readableBytes() > 0) {
        QueuesBuilder queueBuilder = new QueuesBuilder();
        queueBuilder.setQueueId(new QueueId(input.readUnsignedInt()));
        queueBuilder.setPort(new PortNumber(input.readUnsignedInt()));
        int length = input.readUnsignedShort();
        input.skipBytes(PADDING_IN_PACKET_QUEUE_HEADER);
        queueBuilder.setQueueProperty(createPropertiesList(input, length - PACKET_QUEUE_LENGTH));
        queuesList.add(queueBuilder.build());
    }
    return queuesList;
}
Also used : ArrayList(java.util.ArrayList) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId) Queues(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) QueuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder)

Example 4 with Queues

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues 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 5 with Queues

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues in project openflowplugin by opendaylight.

the class QueueGetConfigReplyMessageFactoryTest method createQueuesList.

private static List<Queues> createQueuesList() {
    List<Queues> queuesList = new ArrayList<>();
    for (int i = 1; i < 3; i++) {
        QueuesBuilder qb = new QueuesBuilder();
        qb.setQueueId(new QueueId((long) i));
        qb.setPort(new PortNumber((long) i));
        qb.setQueueProperty(createPropertiesList());
        queuesList.add(qb.build());
    }
    return queuesList;
}
Also used : ArrayList(java.util.ArrayList) QueueId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId) Queues(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) QueuesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder)

Aggregations

Queues (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues)9 ArrayList (java.util.ArrayList)6 QueueId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueId)6 QueuesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.QueuesBuilder)6 ByteBuf (io.netty.buffer.ByteBuf)5 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)4 Test (org.junit.Test)3 RateQueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty)3 GetQueueConfigOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput)3 QueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty)2 ExperimenterIdQueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdQueueProperty)1 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)1 MultipartRequestQueueCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestQueueCaseBuilder)1 MultipartRequestQueueBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.queue._case.MultipartRequestQueueBuilder)1