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();
}
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);
}
}
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());
}
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());
}
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());
}
Aggregations