use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder in project openflowplugin by opendaylight.
the class MeterInstructionDeserializer method deserialize.
@Override
public Instruction deserialize(ByteBuf input) {
final InstructionBuilder builder = new InstructionBuilder();
input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
MeterCaseBuilder caseBuilder = new MeterCaseBuilder();
MeterBuilder instructionBuilder = new MeterBuilder();
instructionBuilder.setMeterId(input.readUnsignedInt());
caseBuilder.setMeter(instructionBuilder.build());
builder.setInstructionChoice(caseBuilder.build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder in project openflowplugin by opendaylight.
the class MeterInstructionDeserializer method deserializeHeader.
@Override
public Instruction deserializeHeader(ByteBuf input) {
InstructionBuilder builder = new InstructionBuilder();
input.skipBytes(2 * EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
builder.setInstructionChoice(new MeterCaseBuilder().build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder in project openflowplugin by opendaylight.
the class FlowInstructionResponseConvertor method convert.
@Override
public Instructions convert(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction> source, VersionConvertorData data) {
InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
List<Instruction> salInstructionList = new ArrayList<>();
int instructionTreeNodekey = 0;
org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction salInstruction;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction switchInst : source) {
if (switchInst.getInstructionChoice() instanceof ApplyActionsCase) {
ApplyActionsCase actionsInstruction = (ApplyActionsCase) switchInst.getInstructionChoice();
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
final Optional<List<Action>> actions = getConvertorExecutor().convert(actionsInstruction.getApplyActions().getAction(), actionResponseConvertorData);
applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
salInstruction = applyActionsCaseBuilder.build();
} else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase) {
ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
salInstruction = clearActionsCaseBuilder.build();
} else if (switchInst.getInstructionChoice() instanceof GotoTableCase) {
GotoTableCase gotoTableCase = (GotoTableCase) switchInst.getInstructionChoice();
GoToTableCaseBuilder goToTableCaseBuilder = new GoToTableCaseBuilder();
GoToTableBuilder goToTableBuilder = new GoToTableBuilder();
goToTableBuilder.setTableId(gotoTableCase.getGotoTable().getTableId());
goToTableCaseBuilder.setGoToTable(goToTableBuilder.build());
salInstruction = goToTableCaseBuilder.build();
} else if (switchInst.getInstructionChoice() instanceof MeterCase) {
MeterCase meterIdInstruction = (MeterCase) switchInst.getInstructionChoice();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
meterBuilder.setMeterId(new MeterId(meterIdInstruction.getMeter().getMeterId()));
meterCaseBuilder.setMeter(meterBuilder.build());
salInstruction = meterCaseBuilder.build();
} else if (switchInst.getInstructionChoice() instanceof WriteActionsCase) {
WriteActionsCase writeActionsCase = (WriteActionsCase) switchInst.getInstructionChoice();
WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
final ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(data.getVersion());
actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS);
final Optional<List<Action>> actions = getConvertorExecutor().convert(writeActionsCase.getWriteActions().getAction(), actionResponseConvertorData);
writeActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
salInstruction = writeActionsCaseBuilder.build();
} else if (switchInst.getInstructionChoice() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) {
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase writeMetadataCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) switchInst.getInstructionChoice();
WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
writeMetadataBuilder.setMetadata(new BigInteger(OFConstants.SIGNUM_UNSIGNED, writeMetadataCase.getWriteMetadata().getMetadata()));
writeMetadataBuilder.setMetadataMask(new BigInteger(OFConstants.SIGNUM_UNSIGNED, writeMetadataCase.getWriteMetadata().getMetadataMask()));
writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
salInstruction = writeMetadataCaseBuilder.build();
} else {
continue;
}
InstructionBuilder instBuilder = new InstructionBuilder();
instBuilder.setInstruction(salInstruction);
instBuilder.setKey(new InstructionKey(instructionTreeNodekey));
instBuilder.setOrder(instructionTreeNodekey);
instructionTreeNodekey++;
salInstructionList.add(instBuilder.build());
}
instructionsBuilder.setInstruction(salInstructionList);
return instructionsBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method createFlowStats.
private static List<FlowStats> createFlowStats() {
FlowStatsBuilder builder = new FlowStatsBuilder();
builder.setTableId((short) 1);
builder.setDurationSec(1L);
builder.setDurationNsec(1L);
builder.setPriority(1);
builder.setIdleTimeout(1);
builder.setHardTimeout(1);
builder.setCookie(BigInteger.valueOf(1234L));
builder.setPacketCount(BigInteger.valueOf(1234L));
builder.setByteCount(BigInteger.valueOf(1234L));
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(InPhyPort.class);
entriesBuilder.setHasMask(false);
InPhyPortCaseBuilder inPhyPortCaseBuilder = new InPhyPortCaseBuilder();
InPhyPortBuilder inPhyPortBuilder = new InPhyPortBuilder();
inPhyPortBuilder.setPortNumber(new PortNumber(42L));
inPhyPortCaseBuilder.setInPhyPort(inPhyPortBuilder.build());
entriesBuilder.setMatchEntryValue(inPhyPortCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpEcn.class);
entriesBuilder.setHasMask(false);
IpEcnCaseBuilder ipEcnCaseBuilder = new IpEcnCaseBuilder();
IpEcnBuilder ipEcnBuilder = new IpEcnBuilder();
ipEcnBuilder.setEcn((short) 4);
ipEcnCaseBuilder.setIpEcn(ipEcnBuilder.build());
entriesBuilder.setMatchEntryValue(ipEcnCaseBuilder.build());
entries.add(entriesBuilder.build());
matchBuilder.setMatchEntry(entries);
builder.setMatch(matchBuilder.build());
final List<Instruction> instructions = new ArrayList<>();
// Goto_table instruction
InstructionBuilder builderInstruction = new InstructionBuilder();
GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
GotoTableBuilder instructionBuilder = new GotoTableBuilder();
instructionBuilder.setTableId((short) 5);
gotoCaseBuilder.setGotoTable(instructionBuilder.build());
builderInstruction.setInstructionChoice(gotoCaseBuilder.build());
instructions.add(builderInstruction.build());
// Write_metadata instruction
builderInstruction = new InstructionBuilder();
WriteMetadataCaseBuilder metadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder metadataBuilder = new WriteMetadataBuilder();
metadataBuilder.setMetadata(ByteBufUtils.hexStringToBytes("00 01 02 03 04 05 06 07"));
metadataBuilder.setMetadataMask(ByteBufUtils.hexStringToBytes("07 06 05 04 03 02 01 00"));
metadataCaseBuilder.setWriteMetadata(metadataBuilder.build());
builderInstruction.setInstructionChoice(metadataCaseBuilder.build());
instructions.add(builderInstruction.build());
// Clear_actions instruction
builderInstruction = new InstructionBuilder();
builderInstruction.setInstructionChoice(new ClearActionsCaseBuilder().build());
instructions.add(builderInstruction.build());
// Meter instruction
builderInstruction = new InstructionBuilder();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
meterBuilder.setMeterId(42L);
meterCaseBuilder.setMeter(meterBuilder.build());
builderInstruction.setInstructionChoice(meterCaseBuilder.build());
instructions.add(builderInstruction.build());
// Write_actions instruction
builderInstruction = new InstructionBuilder();
final WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
final WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(45L));
outputBuilder.setMaxLength(55);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
List<Action> actions = new ArrayList<>();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTtlCaseBuilder ttlCaseBuilder = new SetNwTtlCaseBuilder();
SetNwTtlActionBuilder ttlActionBuilder = new SetNwTtlActionBuilder();
ttlActionBuilder.setNwTtl((short) 64);
ttlCaseBuilder.setSetNwTtlAction(ttlActionBuilder.build());
actionBuilder.setActionChoice(ttlCaseBuilder.build());
actions.add(actionBuilder.build());
writeActionsBuilder.setAction(actions);
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
builderInstruction.setInstructionChoice(writeActionsCaseBuilder.build());
instructions.add(builderInstruction.build());
// Apply_actions instruction
builderInstruction = new InstructionBuilder();
final ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
final ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
actions = new ArrayList<>();
actionBuilder = new ActionBuilder();
PushVlanCaseBuilder vlanCaseBuilder = new PushVlanCaseBuilder();
PushVlanActionBuilder vlanBuilder = new PushVlanActionBuilder();
vlanBuilder.setEthertype(new EtherType(new EtherType(14)));
vlanCaseBuilder.setPushVlanAction(vlanBuilder.build());
actionBuilder.setActionChoice(vlanCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
applyActionsBuilder.setAction(actions);
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
builderInstruction.setInstructionChoice(applyActionsCaseBuilder.build());
instructions.add(builderInstruction.build());
builder.setInstruction(instructions);
List<FlowStats> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCaseBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testMultipartRequestTableFeaturesMessageFactory.
@Test
public void testMultipartRequestTableFeaturesMessageFactory() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(12));
final MultipartReplyTableFeaturesCaseBuilder caseBuilder = new MultipartReplyTableFeaturesCaseBuilder();
final MultipartReplyTableFeaturesBuilder featuresBuilder = new MultipartReplyTableFeaturesBuilder();
final List<TableFeatures> tableFeaturesList = new ArrayList<>();
TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
tableFeaturesBuilder.setTableId((short) 8);
tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
tableFeaturesBuilder.setMetadataMatch(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 });
tableFeaturesBuilder.setMetadataWrite(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 });
tableFeaturesBuilder.setConfig(new TableConfig(true));
tableFeaturesBuilder.setMaxEntries(65L);
TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLES);
NextTableRelatedTableFeaturePropertyBuilder nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
List<NextTableIds> nextIds = new ArrayList<>();
nextIds.add(new NextTableIdsBuilder().setTableId((short) 1).build());
nextIds.add(new NextTableIdsBuilder().setTableId((short) 2).build());
nextPropBuilder.setNextTableIds(nextIds);
propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
List<TableFeatureProperties> properties = new ArrayList<>();
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTNEXTTABLESMISS);
nextPropBuilder = new NextTableRelatedTableFeaturePropertyBuilder();
nextIds = new ArrayList<>();
nextPropBuilder.setNextTableIds(nextIds);
propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);
List<Instruction> insIds = new ArrayList<>();
InstructionBuilder insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new WriteActionsCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
insIds.add(insBuilder.build());
InstructionRelatedTableFeaturePropertyBuilder insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
insPropBuilder.setInstruction(insIds);
propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS);
insPropBuilder = new InstructionRelatedTableFeaturePropertyBuilder();
insIds = new ArrayList<>();
insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new WriteMetadataCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new ApplyActionsCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new MeterCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new ClearActionsCaseBuilder().build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(new GotoTableCaseBuilder().build());
insIds.add(insBuilder.build());
insPropBuilder.setInstruction(insIds);
propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
properties.add(propBuilder.build());
tableFeaturesBuilder.setTableFeatureProperties(properties);
tableFeaturesList.add(tableFeaturesBuilder.build());
tableFeaturesBuilder = new TableFeaturesBuilder();
tableFeaturesBuilder.setTableId((short) 8);
tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
byte[] metadataMatch = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 };
tableFeaturesBuilder.setMetadataMatch(metadataMatch);
byte[] metadataWrite = new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 };
tableFeaturesBuilder.setMetadataWrite(metadataWrite);
tableFeaturesBuilder.setConfig(new TableConfig(true));
tableFeaturesBuilder.setMaxEntries(67L);
properties = new ArrayList<>();
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS);
ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
List<Action> actions = new ArrayList<>();
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new OutputActionCaseBuilder().build());
actions.add(actionBuilder.build());
actBuilder.setAction(actions);
propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS);
actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
actions = new ArrayList<>();
actBuilder.setAction(actions);
propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS);
actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
actions = new ArrayList<>();
actBuilder.setAction(actions);
propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS);
actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
actions = new ArrayList<>();
actBuilder.setAction(actions);
propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTMATCH);
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(InPhyPort.class);
entriesBuilder.setHasMask(false);
List<MatchEntry> entries = new ArrayList<>();
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(InPort.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
OxmRelatedTableFeaturePropertyBuilder oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELD);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpProto.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(IpEcn.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
tableFeaturesBuilder.setTableFeatureProperties(properties);
tableFeaturesList.add(tableFeaturesBuilder.build());
featuresBuilder.setTableFeatures(tableFeaturesList);
caseBuilder.setMultipartReplyTableFeatures(featuresBuilder.build());
builder.setMultipartReplyBody(caseBuilder.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 520);
Assert.assertEquals("Wrong type", MultipartType.OFPMPTABLEFEATURES.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
Assert.assertEquals("Wrong length", 232, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(5);
Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32));
byte[] metadataMatchOutput = new byte[metadataMatch.length];
serializedBuffer.readBytes(metadataMatchOutput);
Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatchOutput);
serializedBuffer.skipBytes(64 - metadataMatch.length);
byte[] metadataWriteOutput = new byte[metadataWrite.length];
serializedBuffer.readBytes(metadataWriteOutput);
Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWriteOutput);
serializedBuffer.skipBytes(64 - metadataWrite.length);
Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong max-entries", 65, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong property type", 2, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 6, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong next-registry-id", 1, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong next-registry-id", 2, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(2);
Assert.assertEquals("Wrong property type", 3, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 0, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction type", 3, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 1, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 24, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction type", 2, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction type", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction type", 6, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction type", 5, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction type", 1, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong instruction length", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong length", 272, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong registry-id", 8, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(5);
Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(serializedBuffer, 32));
metadataMatchOutput = new byte[metadataMatch.length];
serializedBuffer.readBytes(metadataMatchOutput);
serializedBuffer.skipBytes(64 - metadataMatch.length);
Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatchOutput);
metadataWriteOutput = new byte[metadataWrite.length];
serializedBuffer.readBytes(metadataWriteOutput);
serializedBuffer.skipBytes(64 - metadataWrite.length);
Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWriteOutput);
Assert.assertEquals("Wrong config", 1, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong max-entries", 67, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong property type", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 8, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong action type", 0, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong action length", 4, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property type", 5, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 6, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 7, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 8, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong match field&mask", 2, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong match field&mask", 0, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong match length", 4, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 10, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 12, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 13, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 14, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 12, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong match field&mask", 20, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong match class", 0x8000, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong match field&mask", 18, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong match length", 1, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong property type", 15, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong property length", 4, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(4);
Assert.assertTrue("Unread data", serializedBuffer.readableBytes() == 0);
}
Aggregations