use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.
the class FlowRemovedTranslator method translateMatch.
protected MatchBuilder translateMatch(FlowRemoved flowRemoved, DeviceInfo deviceInfo) {
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
datapathIdConvertorData.setDatapathId(deviceInfo.getDatapathId());
final Optional<MatchBuilder> matchBuilderOptional = getConvertorExecutor().convert(flowRemoved.getMatch(), datapathIdConvertorData);
return matchBuilderOptional.orElse(new MatchBuilder());
}
use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.
the class OfToSalSetFieldCase method process.
@Override
public Optional<Action> process(@Nonnull final SetFieldCase source, final ActionResponseConvertorData data, ConvertorExecutor convertorExecutor) {
final VersionDatapathIdConvertorData datapathIdConvertorData = new VersionDatapathIdConvertorData(data.getVersion());
final SetFieldAction setFieldAction = source.getSetFieldAction();
final SetFieldBuilder setField = new SetFieldBuilder();
final Optional<MatchBuilder> matchOptional = convertorExecutor.convert(setFieldAction, datapathIdConvertorData);
setField.fieldsFrom(matchOptional.orElse(new MatchBuilder()).build());
return Optional.of(new SetFieldCaseBuilder().setSetField(setField.build()).build());
}
use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.
the class FlowConvertorTest method testCloneAndAugmentFlowWithSetVlanId.
@Test
public void testCloneAndAugmentFlowWithSetVlanId() {
MockFlow mockFlow = new MockFlow();
Action action1 = createAction(new SetVlanIdActionCaseBuilder().setSetVlanIdAction(new SetVlanIdActionBuilder().setVlanId(new VlanId(10)).build()).build(), 0);
mockFlow.setMatch(new MatchBuilder().setEthernetMatch(createEthernetMatch()).build());
mockFlow.setInstructions(toApplyInstruction(Collections.singletonList(action1)));
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
data.setDatapathId(BigInteger.ONE);
List<FlowModInputBuilder> flowModInputBuilders = convert(mockFlow, data);
Assert.assertEquals(2, flowModInputBuilders.size());
}
use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.
the class FlowConvertorTest method testOnlyModifyStrictCommand.
/**
* Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testOnlyModifyStrictCommand() {
UpdatedFlowBuilder flowBuilder = new UpdatedFlowBuilder();
flowBuilder.setStrict(true);
UpdatedFlow flow = flowBuilder.build();
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
data.setDatapathId(new BigInteger("42"));
List<FlowModInputBuilder> flowMod = convert(flow, data);
Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());
}
use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithIpv6DstCidrMaskAndSrcArbitraryBitMask.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithIpv6DstCidrMaskAndSrcArbitraryBitMask() {
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(Ipv6Dst.class);
entriesBuilder.setHasMask(true);
final Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
final Ipv6DstBuilder ipv6AddressBuilder = new Ipv6DstBuilder();
ipv6AddressBuilder.setIpv6Address(new Ipv6Address("1001:1001:1001:1001:1001:1001:1001:1001"));
ipv6AddressBuilder.setMask(new byte[] { (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
ipv6DstCaseBuilder.setIpv6Dst(ipv6AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
entries.add(entriesBuilder.build());
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("2002:2002:2002:2002:2002:2002:2002:2002"));
ipv6SrcBuilder.setMask(new byte[] { (byte) 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 255 });
ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.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", "2002:2002:2002:2002:2002:2002:2002:2002", ipv6MatchArbitraryBitMask.getIpv6SourceAddressNoMask().getValue());
Assert.assertEquals("Wrong ipv6 dst address", "1001:1001:1001:1001:1001:1001:1001:1001", ipv6MatchArbitraryBitMask.getIpv6DestinationAddressNoMask().getValue());
}
Aggregations