Search in sources :

Example 1 with MultipartReplyTableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures in project openflowplugin by opendaylight.

the class MultipartReplyTranslatorUtil method translateTableFeatures.

private static org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures translateTableFeatures(final MultipartReply msg, final short version, final ConvertorExecutor convertorExecutor) {
    MultipartReplyTableFeaturesCase caseBody = (MultipartReplyTableFeaturesCase) msg.getMultipartReplyBody();
    final MultipartReplyTableFeatures multipartReplyTableFeatures = caseBody.getMultipartReplyTableFeatures();
    final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures>> tableFeaturesList = convertorExecutor.convert(multipartReplyTableFeatures, new VersionConvertorData(version));
    return new MultipartReplyTableFeaturesBuilder().setTableFeatures(tableFeaturesList.orElse(Collections.emptyList())).build();
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) ArrayList(java.util.ArrayList) List(java.util.List) FlowAndStatisticsMapList(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder)

Example 2 with MultipartReplyTableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactory method serializeTableFeaturesBody.

private void serializeTableFeaturesBody(final MultipartReplyBody body, final ByteBuf outBuffer) {
    MultipartReplyTableFeaturesCase tableFeaturesCase = (MultipartReplyTableFeaturesCase) body;
    MultipartReplyTableFeatures tableFeatures = tableFeaturesCase.getMultipartReplyTableFeatures();
    for (TableFeatures tableFeature : tableFeatures.getTableFeatures()) {
        ByteBuf tableFeatureBuff = UnpooledByteBufAllocator.DEFAULT.buffer();
        tableFeatureBuff.writeShort(EncodeConstants.EMPTY_LENGTH);
        tableFeatureBuff.writeByte(tableFeature.getTableId());
        tableFeatureBuff.writeZero(TABLE_FEATURES_PADDING);
        write32String(tableFeature.getName(), tableFeatureBuff);
        tableFeatureBuff.writeBytes(tableFeature.getMetadataMatch());
        tableFeatureBuff.writeZero(64 - tableFeature.getMetadataMatch().length);
        tableFeatureBuff.writeBytes(tableFeature.getMetadataWrite());
        tableFeatureBuff.writeZero(64 - tableFeature.getMetadataWrite().length);
        writeTableConfig(tableFeature.getConfig(), tableFeatureBuff);
        tableFeatureBuff.writeInt(tableFeature.getMaxEntries().intValue());
        for (TableFeatureProperties tableFeatureProp : tableFeature.getTableFeatureProperties()) {
            switch(tableFeatureProp.getType()) {
                case OFPTFPTINSTRUCTIONS:
                    writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_CODE);
                    break;
                case OFPTFPTINSTRUCTIONSMISS:
                    writeInstructionRelatedTableProperty(tableFeatureBuff, tableFeatureProp, INSTRUCTIONS_MISS_CODE);
                    break;
                case OFPTFPTNEXTTABLES:
                    writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_CODE);
                    break;
                case OFPTFPTNEXTTABLESMISS:
                    writeNextTableRelatedTableProperty(tableFeatureBuff, tableFeatureProp, NEXT_TABLE_MISS_CODE);
                    break;
                case OFPTFPTWRITEACTIONS:
                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_CODE);
                    break;
                case OFPTFPTWRITEACTIONSMISS:
                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_ACTIONS_MISS_CODE);
                    break;
                case OFPTFPTAPPLYACTIONS:
                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_CODE);
                    break;
                case OFPTFPTAPPLYACTIONSMISS:
                    writeActionsRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_ACTIONS_MISS_CODE);
                    break;
                case OFPTFPTMATCH:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, MATCH_CODE);
                    break;
                case OFPTFPTWILDCARDS:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WILDCARDS_CODE);
                    break;
                case OFPTFPTWRITESETFIELD:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_CODE);
                    break;
                case OFPTFPTWRITESETFIELDMISS:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, WRITE_SETFIELD_MISS_CODE);
                    break;
                case OFPTFPTAPPLYSETFIELD:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_CODE);
                    break;
                case OFPTFPTAPPLYSETFIELDMISS:
                    writeOxmRelatedTableProperty(tableFeatureBuff, tableFeatureProp, APPLY_SETFIELD_MISS_CODE);
                    break;
                case OFPTFPTEXPERIMENTER:
                case OFPTFPTEXPERIMENTERMISS:
                    writeExperimenterRelatedTableProperty(tableFeatureBuff, tableFeatureProp);
                    break;
                default:
                    break;
            }
        }
        tableFeatureBuff.setShort(TABLE_FEATURES_LENGTH_INDEX, tableFeatureBuff.readableBytes());
        outBuffer.writeBytes(tableFeatureBuff);
    }
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)

Example 3 with MultipartReplyTableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyTableFeatures() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0C 00 00 00 00 00 00 " + // first table feature
    "00 40 01 00 00 00 00 00 " + // length, tableId, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + // 
    "00 00 00 00 00 00 00 00 00 00 00 00 00 " + // name
    "00 00 00 00 00 00 00 01 " + // metadata match
    "00 00 00 00 00 00 00 02 " + // metadata write
    "00 00 00 00 " + // config
    "00 00 00 2A " + // second table feature
    "00 40 02 00 00 00 00 00 " + // length, tableId, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" + // name
    " 00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
    "00 00 00 00 00 00 00 03 " + // metadata write
    "00 00 00 00 00 00 00 04 " + // config
    "00 00 00 03 " + // max entries
    "00 00 00 2B");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
    Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size());
    TableFeatures feature = message.getTableFeatures().get(0);
    Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
    Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
    Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
    Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
    feature = message.getTableFeatures().get(1);
    Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
    Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, feature.getMetadataMatch());
    Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 4 }, feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK());
    Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue());
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) Test(org.junit.Test)

Example 4 with MultipartReplyTableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesTest method testEmptyMultipartReplyTableFeatures.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testEmptyMultipartReplyTableFeatures() {
    ByteBuf bb = BufferHelper.buildBuffer("00 0C 00 00 00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
    Assert.assertEquals("Wrong table features size", 0, message.getTableFeatures().size());
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) Test(org.junit.Test)

Example 5 with MultipartReplyTableFeatures

use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesDeserializerTest method deserialize.

@Test
public void deserialize() throws Exception {
    ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    writeValues(buffer, OFPTFPT_INSTRUCTIONS);
    MultipartReplyTableFeatures reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(TABLE_ID, reply.getTableFeatures().get(0).getTableId().byteValue());
    assertEquals(METADATA_MATCH, reply.getTableFeatures().get(0).getMetadataMatch().longValue());
    assertEquals(METADATA_WRITE, reply.getTableFeatures().get(0).getMetadataWrite().longValue());
    assertEquals(MAX_ENTRIES, reply.getTableFeatures().get(0).getMaxEntries().longValue());
    assertEquals(MAX_ENTRIES, reply.getTableFeatures().get(0).getMaxEntries().longValue());
    assertEquals(Instructions.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_INSTRUCTIONS_MISS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(InstructionsMiss.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_NEXT_TABLES);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(NextTable.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_NEXT_TABLES_MISS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(NextTableMiss.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_WRITE_ACTIONS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(WriteActions.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_WRITE_ACTIONS_MISS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(WriteActionsMiss.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_APPLY_ACTIONS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(ApplyActions.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_APPLY_ACTIONS_MISS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(ApplyActionsMiss.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_MATCH);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(Match.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_WILDCARDS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(Wildcards.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_WRITE_SETFIELD);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(WriteSetfield.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_WRITE_SETFIELD_MISS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(WriteSetfieldMiss.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_APPLY_SETFIELD);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(ApplySetfield.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    writeValues(buffer, OFPTFPT_APPLY_SETFIELD_MISS);
    reply = (MultipartReplyTableFeatures) deserializeMultipart(buffer);
    assertEquals(ApplySetfieldMiss.class, reply.getTableFeatures().get(0).getTableProperties().getTableFeatureProperties().get(0).getTableFeaturePropType().getImplementedInterface());
    assertEquals(0, buffer.readableBytes());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures) Test(org.junit.Test)

Aggregations

MultipartReplyTableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)7 MultipartReplyTableFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase)6 ByteBuf (io.netty.buffer.ByteBuf)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures)3 List (java.util.List)2 TableFeatureProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties)2 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures)2 BigInteger (java.math.BigInteger)1 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)1 NextTableRelatedTableFeatureProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.NextTableRelatedTableFeatureProperty)1 NextTableIds (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds)1 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)1 MultipartReplyBody (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.MultipartReplyBody)1 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig)1 MultipartReplyTableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeatures)1 MultipartReplyTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder)1