Search in sources :

Example 11 with MultipartReplyMessage

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

the class MultipartReplyGroupFeaturesTest method testMultipartReplyGroupFeatures2.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
 * (with different group types and capabilities).
 */
@Test
public void testMultipartReplyGroupFeatures2() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 08 00 01 00 00 00 00 " + // types
    "00 00 00 00 " + // capabilities
    "00 00 00 00 " + // max groups
    "00 00 00 01 " + // max groups
    "00 00 00 02 " + // max groups
    "00 00 00 03 " + // max groups
    "00 00 00 04 " + // actions bitmap (all actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyGroupFeaturesCase messageCase = (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();
    Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes());
    Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), message.getCapabilities());
}
Also used : MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 12 with MultipartReplyMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage 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 13 with MultipartReplyMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage 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 14 with MultipartReplyMessage

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

the class MultipartReplyMessageFactoryTest method testGroupFeaturesSerialize.

@Test
public void testGroupFeaturesSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(8));
    final MultipartReplyGroupFeaturesCaseBuilder featureCase = new MultipartReplyGroupFeaturesCaseBuilder();
    MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder();
    feature.setTypes(new GroupTypes(true, false, true, false));
    feature.setCapabilities(new GroupCapabilities(true, false, true, true));
    List<Long> maxGroups = new ArrayList<>();
    maxGroups.add(1L);
    maxGroups.add(2L);
    maxGroups.add(3L);
    maxGroups.add(4L);
    feature.setMaxGroups(maxGroups);
    feature.setActionsBitmap(createActionType());
    featureCase.setMultipartReplyGroupFeatures(feature.build());
    builder.setMultipartReplyBody(featureCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPFEATURES.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyGroupFeaturesCase body = (MultipartReplyGroupFeaturesCase) message.getMultipartReplyBody();
    MultipartReplyGroupFeatures messageOutput = body.getMultipartReplyGroupFeatures();
    Assert.assertEquals("Wrong type", messageOutput.getTypes(), createGroupTypes(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), createGroupCapabilities(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(0).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(1).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(2).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(3).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(0), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(1), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(2), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(3), createActionType(serializedBuffer.readInt()));
}
Also used : MultipartReplyGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures) ArrayList(java.util.ArrayList) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReplyGroupFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder) Test(org.junit.Test)

Example 15 with MultipartReplyMessage

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

the class MultipartReplyMessageFactoryTest method testGroupSerialize.

@Test
public void testGroupSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(6));
    MultipartReplyGroupCaseBuilder groupCase = new MultipartReplyGroupCaseBuilder();
    MultipartReplyGroupBuilder group = new MultipartReplyGroupBuilder();
    group.setGroupStats(createGroupStats());
    groupCase.setMultipartReplyGroup(group.build());
    builder.setMultipartReplyBody(groupCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 72);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUP.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyGroupCase body = (MultipartReplyGroupCase) message.getMultipartReplyBody();
    MultipartReplyGroup messageOutput = body.getMultipartReplyGroup();
    GroupStats groupStats = messageOutput.getGroupStats().get(0);
    Assert.assertEquals("Wrong length", 56, serializedBuffer.readShort());
    serializedBuffer.skipBytes(2);
    Assert.assertEquals("Wrong group id", groupStats.getGroupId().getValue().intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong ref count", groupStats.getRefCount().intValue(), serializedBuffer.readInt());
    serializedBuffer.skipBytes(4);
    Assert.assertEquals("Wrong Packet count", groupStats.getPacketCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong Byte count", groupStats.getByteCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong duration sec", groupStats.getDurationSec().intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong duration nsec", groupStats.getDurationNsec().intValue(), serializedBuffer.readInt());
    BucketStats bucketStats = groupStats.getBucketStats().get(0);
    Assert.assertEquals("Wrong Packet count", bucketStats.getPacketCount().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong Byte count", bucketStats.getByteCount().longValue(), serializedBuffer.readLong());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase) MultipartReplyGroupCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCaseBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReplyGroupBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroupBuilder) MultipartReplyGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ByteBuf(io.netty.buffer.ByteBuf) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)61 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)61 ByteBuf (io.netty.buffer.ByteBuf)56 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)24 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)23 BigInteger (java.math.BigInteger)13 DeviceContext (org.opendaylight.openflowplugin.api.openflow.device.DeviceContext)5 MultipartReplyGroupDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase)5 MultipartReplyGroupDesc (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc)5 DataContainer (org.opendaylight.yangtools.yang.binding.DataContainer)5 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)4 MultipartReplyFlowCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase)4 MultipartReplyFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow)4 FlowStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats)4 MeterBandTypeBitmap (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap)3 MultipartReplyAggregateCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCase)3 MultipartReplyMeterFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)3 MultipartReplyPortDescCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase)3 MultipartReplyPortStatsCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortStatsCase)3 MultipartReplyQueueCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyQueueCase)3