use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class Activator method createBuckets.
private static BucketsBuilder createBuckets() {
List<Action> actionList = new ArrayList<>();
actionList.add(new ActionBuilder().setOrder(0).setAction(new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build()).build());
BucketBuilder bucketBuilder = new BucketBuilder();
bucketBuilder.setBucketId(new BucketId(12L));
bucketBuilder.setAction(actionList);
List<Bucket> bucketList = new ArrayList<>();
bucketList.add(bucketBuilder.build());
actionList = new ArrayList<>();
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetField(new SetFieldBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(new Ipv4Prefix("10.0.1.0/32")).build()).build());
actionList.add(new ActionBuilder().setAction(setFieldCaseBuilder.build()).setOrder(0).build());
setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetField(new SetFieldBuilder().setLayer3Match(new Ipv4MatchBuilder().setIpv4Destination(new Ipv4Prefix("10.0.10.0/32")).build()).build());
actionList.add(new ActionBuilder().setAction(setFieldCaseBuilder.build()).setOrder(0).build());
bucketBuilder = new BucketBuilder();
bucketBuilder.setBucketId(new BucketId(13L));
bucketBuilder.setAction(actionList);
bucketList.add(bucketBuilder.build());
BucketsBuilder bucketsBuilder = new BucketsBuilder();
bucketsBuilder.setBucket(bucketList);
return bucketsBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class SalToOfSetNwSrcActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetNwSrcActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
final ActionBuilder builder = new ActionBuilder();
final Address address = source.getSetNwSrcAction().getAddress();
if (address instanceof Ipv4) {
Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv4) address).getIpv4Address().getValue());
Ipv4Address result = new Ipv4Address(addressParts.iterator().next());
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(result);
Integer prefix = IpConversionUtil.extractPrefix(result);
ipv4SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchEntryBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
builder.setActionChoice(setFieldCaseBuilder.build());
} else if (address instanceof Ipv6) {
Iterable<String> addressParts = PREFIX_SPLITTER.split(((Ipv6) address).getIpv6Address().getValue());
Ipv6Address result = new Ipv6Address(addressParts.iterator().next());
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
ipv6SrcBuilder.setIpv6Address(result);
Integer prefix = IpConversionUtil.extractPrefix(result);
ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(matchEntryBuilder.build());
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldActionBuilder = new SetFieldActionBuilder();
setFieldActionBuilder.setMatchEntry(matchEntriesList);
setFieldCaseBuilder.setSetFieldAction(setFieldActionBuilder.build());
builder.setActionChoice(setFieldCaseBuilder.build());
} else {
throw new IllegalArgumentException("Address is not supported: " + address.getClass().getName());
}
return Optional.of(builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class SalToOfSetVlanIdActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetVlanIdActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setOxmMatchField(VlanVid.class);
matchBuilder.setHasMask(false);
VlanVidCaseBuilder vlanVidCaseBuilder = new VlanVidCaseBuilder();
VlanVidBuilder vlanVidBuilder = new VlanVidBuilder();
vlanVidBuilder.setCfiBit(true);
SetVlanIdAction setvlanidaction = source.getSetVlanIdAction();
vlanVidBuilder.setVlanVid(setvlanidaction.getVlanId().getValue());
vlanVidCaseBuilder.setVlanVid(vlanVidBuilder.build());
matchBuilder.setMatchEntryValue(vlanVidCaseBuilder.build());
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setFieldCaseBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class SalToOfSetVlanPcpActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetVlanPcpActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
SetVlanPcpAction setvlanpcpaction = source.getSetVlanPcpAction();
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(MatchConvertorUtil.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
setFieldBuilder.setMatchEntry(matchEntriesList);
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setFieldCaseBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction48.
private static InstructionsBuilder createAppyActionInstruction48() {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
// Tunnel
final TunnelBuilder tunnel = new TunnelBuilder();
tunnel.setTunnelId(BigInteger.valueOf(10668));
setFieldBuilder.setTunnel(tunnel.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
final InstructionBuilder ib = new InstructionBuilder();
ib.setKey(new InstructionKey(0));
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
final InstructionsBuilder isb = new InstructionsBuilder();
final List<Instruction> instructions = new ArrayList<>();
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
Aggregations