Search in sources :

Example 1 with QueueProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty in project openflowplugin by opendaylight.

the class OF10QueueGetConfigReplyMessageFactory method createPropertiesList.

private static List<QueueProperty> createPropertiesList(ByteBuf input, int length) {
    int propertiesLength = length;
    List<QueueProperty> propertiesList = new ArrayList<>();
    while (propertiesLength > 0) {
        QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder();
        QueueProperties property = QueueProperties.forValue(input.readUnsignedShort());
        propertiesBuilder.setProperty(property);
        propertiesLength -= input.readUnsignedShort();
        input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER);
        if (property.equals(QueueProperties.OFPQTMINRATE)) {
            RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
            rateBuilder.setRate(input.readUnsignedShort());
            propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build());
            input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY);
        }
        propertiesList.add(propertiesBuilder.build());
    }
    return propertiesList;
}
Also used : QueueProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties) RateQueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder) ArrayList(java.util.ArrayList) RateQueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder) QueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder) 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 2 with QueueProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty 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 3 with QueueProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty in project openflowplugin by opendaylight.

the class QueueGetConfigReplyMessageFactory method createPropertiesList.

private List<QueueProperty> createPropertiesList(ByteBuf input, int length) {
    int propertiesLength = length;
    List<QueueProperty> propertiesList = new ArrayList<>();
    while (propertiesLength > 0) {
        int propertyStartIndex = input.readerIndex();
        QueuePropertyBuilder propertiesBuilder = new QueuePropertyBuilder();
        QueueProperties property = QueueProperties.forValue(input.readUnsignedShort());
        propertiesBuilder.setProperty(property);
        int currentPropertyLength = input.readUnsignedShort();
        propertiesLength -= currentPropertyLength;
        input.skipBytes(PADDING_IN_QUEUE_PROPERTY_HEADER);
        if (property.equals(QueueProperties.OFPQTMINRATE) || property.equals(QueueProperties.OFPQTMAXRATE)) {
            RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
            rateBuilder.setRate(input.readUnsignedShort());
            propertiesBuilder.addAugmentation(RateQueueProperty.class, rateBuilder.build());
            input.skipBytes(PADDING_IN_RATE_QUEUE_PROPERTY);
        } else if (property.equals(QueueProperties.OFPQTEXPERIMENTER)) {
            long expId = input.readUnsignedInt();
            input.readerIndex(propertyStartIndex);
            OFDeserializer<QueueProperty> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createQueuePropertyDeserializerKey(EncodeConstants.OF13_VERSION_ID, expId));
            propertiesList.add(deserializer.deserialize(input));
            continue;
        }
        propertiesList.add(propertiesBuilder.build());
    }
    return propertiesList;
}
Also used : OFDeserializer(org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer) QueueProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties) RateQueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder) ArrayList(java.util.ArrayList) RateQueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder) QueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder) 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 QueueProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty in project openflowplugin by opendaylight.

the class QueueGetConfigReplyMessageFactoryTest method createPropertiesList.

private static List<QueueProperty> createPropertiesList() {
    final List<QueueProperty> propertiesList = new ArrayList<>();
    QueuePropertyBuilder pb = new QueuePropertyBuilder();
    pb.setProperty(QueueProperties.forValue(2));
    RateQueuePropertyBuilder rateBuilder = new RateQueuePropertyBuilder();
    rateBuilder.setRate(5);
    pb.addAugmentation(RateQueueProperty.class, rateBuilder.build());
    propertiesList.add(pb.build());
    return propertiesList;
}
Also used : RateQueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder) ArrayList(java.util.ArrayList) RateQueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder) QueuePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder) 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 QueueProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty 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)

Aggregations

RateQueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueueProperty)10 QueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueueProperty)10 ArrayList (java.util.ArrayList)6 RateQueuePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.RateQueuePropertyBuilder)6 QueuePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.property.header.QueuePropertyBuilder)6 ByteBuf (io.netty.buffer.ByteBuf)4 Test (org.junit.Test)2 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)2 QueueProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.QueueProperties)2 GetQueueConfigOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutput)2 GetQueueConfigOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetQueueConfigOutputBuilder)2 Queues (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.queue.get.config.reply.Queues)2 OFDeserializer (org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer)1 ExperimenterIdQueueProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdQueueProperty)1