Search in sources :

Example 6 with MultipartRequestFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.

the class OF10StatsRequestInputFlowFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 00 00 00 34 18 ff 00 33 00 01 02 03 04 " + "05 05 04 03 02 01 00 00 34 35 00 00 36 37 38 00 00 0a 00 00 01 0a 00 00 02 " + "00 39 00 3a 01 00 00 2a ");
    MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV10(deserializedMessage);
    Assert.assertEquals("Wrong type", 1, deserializedMessage.getType().getIntValue());
    Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
    Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
}
Also used : MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 7 with MultipartRequestFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.

the class OF10StatsRequestInputQueueFactoryTest method test.

@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 05 00 00 00 0f 00 00 00 00 00 10");
    MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV10(deserializedMessage);
    Assert.assertEquals("Wrong type", 5, deserializedMessage.getType().getIntValue());
    Assert.assertEquals("Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags());
    Assert.assertEquals("Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody());
}
Also used : MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 8 with MultipartRequestFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method deserialize.

@Override
public MultipartReplyMessage deserialize(final ByteBuf rawMessage) {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    int type = rawMessage.readUnsignedShort();
    builder.setType(MultipartType.forValue(type));
    builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));
    rawMessage.skipBytes(PADDING_IN_MULTIPART_REPLY_HEADER);
    switch(MultipartType.forValue(type)) {
        case OFPMPDESC:
            builder.setMultipartReplyBody(setDesc(rawMessage));
            break;
        case OFPMPFLOW:
            builder.setMultipartReplyBody(setFlow(rawMessage));
            break;
        case OFPMPAGGREGATE:
            builder.setMultipartReplyBody(setAggregate(rawMessage));
            break;
        case OFPMPTABLE:
            builder.setMultipartReplyBody(setTable(rawMessage));
            break;
        case OFPMPPORTSTATS:
            builder.setMultipartReplyBody(setPortStats(rawMessage));
            break;
        case OFPMPQUEUE:
            builder.setMultipartReplyBody(setQueue(rawMessage));
            break;
        case OFPMPGROUP:
            builder.setMultipartReplyBody(setGroup(rawMessage));
            break;
        case OFPMPGROUPDESC:
            builder.setMultipartReplyBody(setGroupDesc(rawMessage));
            break;
        case OFPMPGROUPFEATURES:
            builder.setMultipartReplyBody(setGroupFeatures(rawMessage));
            break;
        case OFPMPMETER:
            builder.setMultipartReplyBody(setMeter(rawMessage));
            break;
        case OFPMPMETERCONFIG:
            builder.setMultipartReplyBody(setMeterConfig(rawMessage));
            break;
        case OFPMPMETERFEATURES:
            builder.setMultipartReplyBody(setMeterFeatures(rawMessage));
            break;
        case OFPMPTABLEFEATURES:
            builder.setMultipartReplyBody(setTableFeatures(rawMessage));
            break;
        case OFPMPPORTDESC:
            builder.setMultipartReplyBody(setPortDesc(rawMessage));
            break;
        case OFPMPEXPERIMENTER:
            builder.setMultipartReplyBody(setExperimenter(rawMessage));
            break;
        default:
            break;
    }
    return builder.build();
}
Also used : 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)

Example 9 with MultipartRequestFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.

the class OF10StatsReplyMessageFactory method deserialize.

@Override
public MultipartReplyMessage deserialize(ByteBuf rawMessage) {
    Objects.requireNonNull(registry);
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    int type = rawMessage.readUnsignedShort();
    builder.setType(MultipartType.forValue(type));
    builder.setFlags(new MultipartRequestFlags((rawMessage.readUnsignedShort() & 0x01) != 0));
    switch(MultipartType.forValue(type)) {
        case OFPMPDESC:
            builder.setMultipartReplyBody(setDesc(rawMessage));
            break;
        case OFPMPFLOW:
            builder.setMultipartReplyBody(setFlow(rawMessage));
            break;
        case OFPMPAGGREGATE:
            builder.setMultipartReplyBody(setAggregate(rawMessage));
            break;
        case OFPMPTABLE:
            builder.setMultipartReplyBody(setTable(rawMessage));
            break;
        case OFPMPPORTSTATS:
            builder.setMultipartReplyBody(setPortStats(rawMessage));
            break;
        case OFPMPQUEUE:
            builder.setMultipartReplyBody(setQueue(rawMessage));
            break;
        case OFPMPEXPERIMENTER:
            builder.setMultipartReplyBody(setExperimenter(rawMessage));
            break;
        default:
            break;
    }
    return builder.build();
}
Also used : 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)

Example 10 with MultipartRequestFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags in project openflowplugin by opendaylight.

the class MultipartRequestInputFactoryTest method testMultipartRequestInputAggregateBodyFactory.

/**
 * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
 */
@Test
public void testMultipartRequestInputAggregateBodyFactory() throws Exception {
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.forValue(2));
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setMultipartRequestBody(createRequestAggregate());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    multipartFactory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 18, 48);
    Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
    out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
    Assert.assertEquals("Wrong aggregate", message.getMultipartRequestBody(), decodeRequestAggregate(out));
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Aggregations

MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)71 Test (org.junit.Test)64 ByteBuf (io.netty.buffer.ByteBuf)60 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)40 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)26 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)26 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)21 ArrayList (java.util.ArrayList)4 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)3 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)3 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)3 MultipartReplyAggregateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder)3 TableFeatureProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties)3 TableFeaturePropertiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder)3 BigInteger (java.math.BigInteger)2 MultipartRequestInputFactoryTest (org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest)2 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)2 ActionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder)2 InstructionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.InstructionRelatedTableFeaturePropertyBuilder)2 NextTableRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeaturePropertyBuilder)2