use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithIpv6SrcCidrlMaskAndDstArbitraryBitMask.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithIpv6SrcCidrlMaskAndDstArbitraryBitMask() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.Metadata.class);
entriesBuilder.setHasMask(true);
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Src.class);
entriesBuilder.setHasMask(true);
final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
final Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
ipv6SrcBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
ipv6SrcBuilder.setMask(new byte[] { (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Dst.class);
entriesBuilder.setHasMask(true);
final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();
ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2002:2002:2002:2002:2002:2002:2002:2002"));
ipv6AddressBuilder.setMask(new byte[] { (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 255 });
ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
entries.add(entriesBuilder.build());
builder.setMatchEntry(entries);
final Match match = builder.build();
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatchBuilder = convert(match, datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();
final Ipv6MatchArbitraryBitMask ipv6MatchArbitraryBitMask = (Ipv6MatchArbitraryBitMask) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv6 src address", "1001:1001:1001:1001:1001:1001:1001:1001", ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
Assert.assertEquals("Wrong ipv6 dst address", "2002:2002:2002:2002:2002:2002:2002:2002", ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testLayer3MatchIpv6.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testLayer3MatchIpv6() {
final MatchBuilder builder = new MatchBuilder();
builder.setType(OxmMatchType.class);
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Src.class);
entriesBuilder.setHasMask(false);
final Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
final Ipv6SrcBuilder ipv6AddressBuilder = new Ipv6SrcBuilder();
ipv6AddressBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9657"));
ipv6SrcCaseBuilder.setIpv6Src(ipv6AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Dst.class);
entriesBuilder.setHasMask(false);
final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
final Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
ipv6DstBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9658"));
ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Flabel.class);
entriesBuilder.setHasMask(false);
final Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
final Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
ipv6FlabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(18L));
ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6NdTarget.class);
entriesBuilder.setHasMask(false);
final Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();
final Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();
ipv6NdTargetBuilder.setIpv6Address(new Ipv6Address("2001:cdba:0000:0000:0000:0000:3257:9659"));
ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6NdSll.class);
entriesBuilder.setHasMask(false);
final Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();
final Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();
ipv6NdSllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:05"));
ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6NdTll.class);
entriesBuilder.setHasMask(false);
final Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();
final Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();
ipv6NdTllBuilder.setMacAddress(new MacAddress("00:00:00:00:00:06"));
ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
entriesBuilder.setHasMask(false);
final Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();
final Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();
ipv6ExthdrBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true));
ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());
builder.setMatchEntry(entries);
entries.add(entriesBuilder.build());
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
datapathIdConvertorData.setDatapathId(new BigInteger("42"));
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder salMatchBuilder = convert(builder.build(), datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatchBuilder.build();
final Ipv6Match ipv6Match = (Ipv6Match) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv6 src address", "2001:cdba::3257:9657/128", ipv6Match.getIpv6Source().getValue());
Assert.assertEquals("Wrong ipv6 dst address", "2001:cdba::3257:9658/128", ipv6Match.getIpv6Destination().getValue());
Assert.assertEquals("Wrong ipv6 nd target", "2001:cdba:0000:0000:0000:0000:3257:9659", ipv6Match.getIpv6NdTarget().getValue());
Assert.assertEquals("Wrong ipv6 flabel", 18, ipv6Match.getIpv6Label().getIpv6Flabel().getValue().intValue());
Assert.assertEquals("Wrong ipv6 nd sll", new MacAddress("00:00:00:00:00:05"), ipv6Match.getIpv6NdSll());
Assert.assertEquals("Wrong ipv6 nd tll", new MacAddress("00:00:00:00:00:06"), ipv6Match.getIpv6NdTll());
Assert.assertEquals("Wrong ipv6 ext header", 358, ipv6Match.getIpv6ExtHeader().getIpv6Exthdr().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder in project openflowplugin by opendaylight.
the class TableFeaturesResponseConvertorTest method createEmptySetFieldCase.
private static SetFieldCase createEmptySetFieldCase() {
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
List<MatchEntry> matchEntries = new ArrayList<>();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntries.add(matchEntryBuilder.build());
setFieldActionBuilder.setMatchEntry(matchEntries);
setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
return setFieldCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder in project openflowplugin by opendaylight.
the class TableFeaturesResponseConvertorTest method testWithMPTableFeatureWithProperties.
/**
* Test correct input.
*/
@Test
public void testWithMPTableFeatureWithProperties() {
TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
featuresBuilder.setTableId((short) 5);
featuresBuilder.setName("Aloha");
byte[] metaMatch = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 };
featuresBuilder.setMetadataMatch(metaMatch);
byte[] metaWrite = new byte[] { 8, 9, 10, 11, 12, 13, 14, 15 };
featuresBuilder.setMetadataWrite(metaWrite);
featuresBuilder.setConfig(new TableConfig(false));
featuresBuilder.setMaxEntries(42L);
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<>();
nextIds.add(new NextTableIdsBuilder().setTableId((short) 3).build());
nextPropBuilder.setNextTableIds(nextIds);
propBuilder.addAugmentation(NextTableRelatedTableFeatureProperty.class, nextPropBuilder.build());
properties.add(propBuilder.build());
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTINSTRUCTIONS);
/* -------------------------------------------------- */
List<Action> actions = new ArrayList<>();
WriteActionsBuilder writeActionsBuilder = new WriteActionsBuilder();
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createSetNwSrcAction());
actions.add(actionBuilder.build());
writeActionsBuilder.setAction(actions);
WriteActionsCaseBuilder writeActionsCaseBuilder = new WriteActionsCaseBuilder();
writeActionsCaseBuilder.setWriteActions(writeActionsBuilder.build());
InstructionBuilder insBuilder = new InstructionBuilder();
insBuilder.setInstructionChoice(writeActionsCaseBuilder.build());
List<Instruction> insIds = new ArrayList<>();
insIds.add(insBuilder.build());
/* -------------------------------------------------- */
insBuilder = new InstructionBuilder();
GotoTableCaseBuilder gotoCaseBuilder = new GotoTableCaseBuilder();
GotoTableBuilder gotoTableBuilder = new GotoTableBuilder();
gotoCaseBuilder.setGotoTable(gotoTableBuilder.build());
insBuilder.setInstructionChoice(gotoCaseBuilder.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();
WriteMetadataCaseBuilder writeMetadataCaseBuilder = new WriteMetadataCaseBuilder();
WriteMetadataBuilder writeMetadataBuilder = new WriteMetadataBuilder();
writeMetadataCaseBuilder.setWriteMetadata(writeMetadataBuilder.build());
insBuilder.setInstructionChoice(writeMetadataCaseBuilder.build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
insBuilder.setInstructionChoice(applyActionsCaseBuilder.build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
MeterBuilder meterBuilder = new MeterBuilder();
meterCaseBuilder.setMeter(meterBuilder.build());
insBuilder.setInstructionChoice(meterCaseBuilder.build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
ClearActionsCaseBuilder clearActionsCaseBuilder = new ClearActionsCaseBuilder();
insBuilder.setInstructionChoice(clearActionsCaseBuilder.build());
insIds.add(insBuilder.build());
insBuilder = new InstructionBuilder();
GotoTableCaseBuilder gotoCaseBuilder2 = new GotoTableCaseBuilder();
GotoTableBuilder gotoTableBuilder2 = new GotoTableBuilder();
gotoCaseBuilder2.setGotoTable(gotoTableBuilder2.build());
insBuilder.setInstructionChoice(gotoCaseBuilder2.build());
insIds.add(insBuilder.build());
insPropBuilder.setInstruction(insIds);
propBuilder.addAugmentation(InstructionRelatedTableFeatureProperty.class, insPropBuilder.build());
properties.add(propBuilder.build());
featuresBuilder.setTableFeatureProperties(properties);
List<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> features = new ArrayList<>();
features.add(featuresBuilder.build());
featuresBuilder = new TableFeaturesBuilder();
featuresBuilder.setTableId((short) 6);
featuresBuilder.setName("Mahalo");
byte[] metaMatch2 = new byte[] { 8, 9, 10, 11, 12, 13, 14, 15 };
featuresBuilder.setMetadataMatch(metaMatch2);
byte[] metaWrite2 = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 };
featuresBuilder.setMetadataWrite(metaWrite2);
featuresBuilder.setConfig(new TableConfig(false));
featuresBuilder.setMaxEntries(24L);
/* -------------------------------------------------- */
properties = new ArrayList<>();
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());
// [0]
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());
// [1]
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELD);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv6Exthdr.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(VlanVid.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
// [2]
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(VlanPcp.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(TcpSrc.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
// [3]
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(UdpSrc.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(UdpDst.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
// [4]
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWILDCARDS);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
entries = new ArrayList<>();
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthSrc.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(EthDst.class);
entriesBuilder.setHasMask(false);
entries.add(entriesBuilder.build());
oxmBuilder.setMatchEntry(entries);
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
// [5]
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONS);
actions = new ArrayList<>();
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createSetNwSrcAction());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createSetNwSrcAction());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createSetNwSrcAction());
actions.add(actionBuilder.build());
ActionRelatedTableFeaturePropertyBuilder actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
actBuilder.setAction(actions);
propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
// [6]
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS);
actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
actions = new ArrayList<>();
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createGroupAction());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createCopyTtlInCase());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createCopyTtlOutCase());
actions.add(actionBuilder.build());
actBuilder.setAction(actions);
propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
// [7]
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTWRITEACTIONS);
actBuilder = new ActionRelatedTableFeaturePropertyBuilder();
actions = new ArrayList<>();
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createSetMplsTtlCase());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createDecMplsTtlCase());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(pushVlanCase());
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<>();
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createPopVlanCase());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createPushPbbCase());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(createEmptySetFieldCase());
actions.add(actionBuilder.build());
actBuilder.setAction(actions);
propBuilder.addAugmentation(ActionRelatedTableFeatureProperty.class, actBuilder.build());
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
/* -------------------------------------------------- */
propBuilder = new TableFeaturePropertiesBuilder();
propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
oxmBuilder = new OxmRelatedTableFeaturePropertyBuilder();
propBuilder.addAugmentation(OxmRelatedTableFeatureProperty.class, oxmBuilder.build());
properties.add(propBuilder.build());
/* -------------------------------------------------- */
featuresBuilder.setTableFeatureProperties(properties);
features.add(featuresBuilder.build());
MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
builder.setTableFeatures(features);
List<TableFeatures> list = convert(builder.build());
Assert.assertEquals("Returned empty list", 2, list.size());
TableFeatures feature = list.get(0);
Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Aloha", feature.getName());
Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch());
Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());
Assert.assertEquals("Wrong properties", 4, feature.getTableProperties().getTableFeatureProperties().size());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties property = feature.getTableProperties().getTableFeatureProperties().get(0);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTable", property.getTableFeaturePropType().getImplementedInterface().getName());
NextTable propType = (NextTable) property.getTableFeaturePropType();
List<Short> ids = propType.getTables().getTableIds();
Assert.assertEquals("Wrong next table-id size", 2, ids.size());
Assert.assertEquals("Wrong next-registry-id", 1, ids.get(0).intValue());
Assert.assertEquals("Wrong next-registry-id", 2, ids.get(1).intValue());
property = feature.getTableProperties().getTableFeatureProperties().get(1);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.NextTableMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
NextTableMiss propType2 = (NextTableMiss) property.getTableFeaturePropType();
ids = propType2.getTablesMiss().getTableIds();
Assert.assertEquals("Wrong next table-id size", 1, ids.size());
Assert.assertEquals("Wrong next-registry-id", 3, ids.get(0).intValue());
property = feature.getTableProperties().getTableFeatureProperties().get(2);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Instructions", property.getTableFeaturePropType().getImplementedInterface().getName());
Instructions propType3 = (Instructions) property.getTableFeaturePropType();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> instructionIds = propType3.getInstructions().getInstruction();
Assert.assertEquals("Wrong instruction-ids size", 2, instructionIds.size());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.WriteActionsCase", instructionIds.get(0).getInstruction().getImplementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.GoToTableCase", instructionIds.get(1).getInstruction().getImplementedInterface().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(3);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.InstructionsMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
InstructionsMiss propType4 = (InstructionsMiss) property.getTableFeaturePropType();
instructionIds = propType4.getInstructionsMiss().getInstruction();
Assert.assertEquals("Wrong instruction-ids size", 5, instructionIds.size());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.WriteMetadataCase", instructionIds.get(0).getInstruction().getImplementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.ApplyActionsCase", instructionIds.get(1).getInstruction().getImplementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.MeterCase", instructionIds.get(2).getInstruction().getImplementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.ClearActionsCase", instructionIds.get(3).getInstruction().getImplementedInterface().getName());
Assert.assertEquals("Wrong instruction-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types." + "rev131026.instruction.instruction.GoToTableCase", instructionIds.get(4).getInstruction().getImplementedInterface().getName());
feature = list.get(1);
Assert.assertEquals("Wrong table-id", 6, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Mahalo", feature.getName());
Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch2), feature.getMetadataMatch());
Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite2), feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
Assert.assertEquals("Wrong max-entries", 24, feature.getMaxEntries().intValue());
Assert.assertEquals("Wrong properties", 12, feature.getTableProperties().getTableFeatureProperties().size());
property = feature.getTableProperties().getTableFeatureProperties().get(0);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Match", property.getTableFeaturePropType().getImplementedInterface().getName());
Match propType5 = (Match) property.getTableFeaturePropType();
List<SetFieldMatch> fieldMatch = propType5.getMatchSetfield().getSetFieldMatch();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.InPhyPort", fieldMatch.get(0).getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.InPort", fieldMatch.get(1).getMatchType().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(1);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfield", property.getTableFeaturePropType().getImplementedInterface().getName());
ApplySetfield propType6 = (ApplySetfield) property.getTableFeaturePropType();
fieldMatch = propType6.getApplySetfield().getSetFieldMatch();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto", fieldMatch.get(0).getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpEcn", fieldMatch.get(1).getMatchType().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(2);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfield", property.getTableFeaturePropType().getImplementedInterface().getName());
WriteSetfield propType7 = (WriteSetfield) property.getTableFeaturePropType();
fieldMatch = propType7.getWriteSetfield().getSetFieldMatch();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv6Exthdr", fieldMatch.get(0).getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid", fieldMatch.get(1).getMatchType().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(3);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteSetfieldMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
WriteSetfieldMiss propType8 = (WriteSetfieldMiss) property.getTableFeaturePropType();
fieldMatch = propType8.getWriteSetfieldMiss().getSetFieldMatch();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanPcp", fieldMatch.get(0).getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc", fieldMatch.get(1).getMatchType().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(4);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
ApplySetfieldMiss propType9 = (ApplySetfieldMiss) property.getTableFeaturePropType();
fieldMatch = propType9.getApplySetfieldMiss().getSetFieldMatch();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc", fieldMatch.get(0).getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst", fieldMatch.get(1).getMatchType().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(5);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.Wildcards", property.getTableFeaturePropType().getImplementedInterface().getName());
Wildcards propType10 = (Wildcards) property.getTableFeaturePropType();
fieldMatch = propType10.getWildcardSetfield().getSetFieldMatch();
Assert.assertEquals("Wrong match-entry-ids size", 2, fieldMatch.size());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc", fieldMatch.get(0).getMatchType().getName());
Assert.assertEquals("Wrong match-entry-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst", fieldMatch.get(1).getMatchType().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(6);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions", property.getTableFeaturePropType().getImplementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions propType11 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActions) property.getTableFeaturePropType();
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = propType11.getApplyActions().getAction();
Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", actionsList.get(0).getAction().getImplementedInterface().getName());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", actionsList.get(1).getAction().getImplementedInterface().getName());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetNwSrcActionCase", actionsList.get(2).getAction().getImplementedInterface().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(7);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss propType12 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplyActionsMiss) property.getTableFeaturePropType();
actionsList = propType12.getApplyActionsMiss().getAction();
Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase", actionsList.get(0).getAction().getImplementedInterface().getName());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlInCase", actionsList.get(1).getAction().getImplementedInterface().getName());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.CopyTtlOutCase", actionsList.get(2).getAction().getImplementedInterface().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(8);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions", property.getTableFeaturePropType().getImplementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions propType13 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActions) property.getTableFeaturePropType();
actionsList = propType13.getWriteActions().getAction();
Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetMplsTtlActionCase", actionsList.get(0).getAction().getImplementedInterface().getName());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecMplsTtlCase", actionsList.get(1).getAction().getImplementedInterface().getName());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCase", actionsList.get(2).getAction().getImplementedInterface().getName());
property = feature.getTableProperties().getTableFeatureProperties().get(9);
Assert.assertEquals("Wrong property type", "org.opendaylight.yang.gen.v1.urn.opendaylight.table.types." + "rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss", property.getTableFeaturePropType().getImplementedInterface().getName());
org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss propType14 = (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.WriteActionsMiss) property.getTableFeaturePropType();
actionsList = propType14.getWriteActionsMiss().getAction();
Assert.assertEquals("Wrong actions-ids size", 3, actionsList.size());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCase", actionsList.get(0).getAction().getImplementedInterface().getName());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCase", actionsList.get(1).getAction().getImplementedInterface().getName());
Assert.assertEquals("Wrong actions-id", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase", actionsList.get(2).getAction().getImplementedInterface().getName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder in project openflowplugin by opendaylight.
the class SalToOfIpv4MatchArbitraryBitMaskCase method process.
@Override
public Optional<List<MatchEntry>> process(@Nonnull Ipv4MatchArbitraryBitMask source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
List<MatchEntry> result = new ArrayList<>();
if (source.getIpv4SourceAddressNoMask() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(source.getIpv4SourceAddressNoMask());
DottedQuad sourceArbitrarySubNetMask = source.getIpv4SourceArbitraryBitmask();
boolean hasMask = false;
if (sourceArbitrarySubNetMask != null) {
byte[] maskByteArray = IpConversionUtil.convertArbitraryMaskToByteArray(sourceArbitrarySubNetMask);
if (maskByteArray != null) {
ipv4SrcBuilder.setMask(maskByteArray);
hasMask = true;
}
}
matchEntryBuilder.setHasMask(hasMask);
Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
if (source.getIpv4DestinationAddressNoMask() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
ipv4DstBuilder.setIpv4Address(source.getIpv4DestinationAddressNoMask());
DottedQuad destArbitrarySubNetMask = source.getIpv4DestinationArbitraryBitmask();
boolean hasMask = false;
if (destArbitrarySubNetMask != null) {
byte[] maskByteArray = IpConversionUtil.convertArbitraryMaskToByteArray(destArbitrarySubNetMask);
if (maskByteArray != null) {
ipv4DstBuilder.setMask(maskByteArray);
hasMask = true;
}
}
matchEntryBuilder.setHasMask(hasMask);
Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
return Optional.of(result);
}
Aggregations