use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction44.
private static InstructionsBuilder createAppyActionInstruction44() {
final List<Action> actionLists = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
final ActionBuilder ab1 = new ActionBuilder();
final SetFieldBuilder setFieldBuilder1 = new SetFieldBuilder();
final ActionBuilder ab5 = new ActionBuilder();
final SetFieldBuilder setFieldBuilder5 = new SetFieldBuilder();
final ActionBuilder ab6 = new ActionBuilder();
final SetFieldBuilder setFieldBuilder6 = new SetFieldBuilder();
// IPv6
final Ipv6MatchBuilder ipv6Builder = new Ipv6MatchBuilder();
final Ipv6MatchBuilder ipv6Builder1 = new Ipv6MatchBuilder();
final Ipv6MatchBuilder ipv6Builder5 = new Ipv6MatchBuilder();
final Ipv6MatchBuilder ipv6Builder6 = new Ipv6MatchBuilder();
final Ipv6Prefix dstip6 = new Ipv6Prefix("2002::2/128");
final Ipv6Prefix srcip6 = new Ipv6Prefix("2001:0:0:0:0:0:0:1/128");
final Ipv6ExtHeaderBuilder nextheader = new Ipv6ExtHeaderBuilder();
nextheader.setIpv6Exthdr(58);
final Ipv6LabelBuilder ipv6label = new Ipv6LabelBuilder();
final Ipv6FlowLabel label = new Ipv6FlowLabel(10028L);
ipv6label.setIpv6Flabel(label);
ipv6Builder.setIpv6Source(srcip6);
ipv6Builder1.setIpv6Destination(dstip6);
ipv6Builder5.setIpv6ExtHeader(nextheader.build());
ipv6Builder6.setIpv6Label(ipv6label.build());
setFieldBuilder.setLayer3Match(ipv6Builder.build());
ab.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder.build()).build());
ab.setKey(new ActionKey(0));
actionLists.add(ab.build());
setFieldBuilder1.setLayer3Match(ipv6Builder1.build());
ab1.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder1.build()).build());
ab1.setKey(new ActionKey(1));
actionLists.add(ab1.build());
setFieldBuilder5.setLayer3Match(ipv6Builder5.build());
ab5.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder5.build()).build());
ab5.setKey(new ActionKey(5));
actionLists.add(ab5.build());
setFieldBuilder6.setLayer3Match(ipv6Builder6.build());
ab6.setAction(new SetFieldCaseBuilder().setSetField(setFieldBuilder6.build()).build());
ab6.setKey(new ActionKey(6));
actionLists.add(ab6.build());
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionLists);
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;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project openflowplugin by opendaylight.
the class SalToOfIpv6MatchCase method process.
@Override
public Optional<List<MatchEntry>> process(@Nonnull Ipv6Match source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
List<MatchEntry> result = new ArrayList<>();
if (source.getIpv6Source() != null) {
Ipv6Prefix ipv6Prefix = source.getIpv6Source();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6Src.class);
Ipv6SrcCaseBuilder ipv6SrcCaseBuilder = new Ipv6SrcCaseBuilder();
Ipv6SrcBuilder ipv6SrcBuilder = new Ipv6SrcBuilder();
final Integer prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
boolean hasMask = false;
if (null != prefix) {
ipv6SrcBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
hasMask = true;
}
ipv6SrcBuilder.setIpv6Address(IpConversionUtil.extractIpv6Address(ipv6Prefix));
ipv6SrcCaseBuilder.setIpv6Src(ipv6SrcBuilder.build());
matchEntryBuilder.setHasMask(hasMask);
matchEntryBuilder.setMatchEntryValue(ipv6SrcCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
if (source.getIpv6Destination() != null) {
Ipv6Prefix ipv6Prefix = source.getIpv6Destination();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6Dst.class);
Ipv6DstCaseBuilder ipv6DstCaseBuilder = new Ipv6DstCaseBuilder();
Ipv6DstBuilder ipv6DstBuilder = new Ipv6DstBuilder();
final Integer prefix = IpConversionUtil.extractIpv6Prefix(ipv6Prefix);
boolean hasMask = false;
if (null != prefix) {
ipv6DstBuilder.setMask(IpConversionUtil.convertIpv6PrefixToByteArray(prefix));
hasMask = true;
}
ipv6DstBuilder.setIpv6Address(IpConversionUtil.extractIpv6Address(ipv6Prefix));
ipv6DstCaseBuilder.setIpv6Dst(ipv6DstBuilder.build());
matchEntryBuilder.setHasMask(hasMask);
matchEntryBuilder.setMatchEntryValue(ipv6DstCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
if (source.getIpv6Label() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
boolean hasmask = false;
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6Flabel.class);
Ipv6FlabelCaseBuilder ipv6FlabelCaseBuilder = new Ipv6FlabelCaseBuilder();
Ipv6FlabelBuilder ipv6FlabelBuilder = new Ipv6FlabelBuilder();
ipv6FlabelBuilder.setIpv6Flabel(source.getIpv6Label().getIpv6Flabel());
if (source.getIpv6Label().getFlabelMask() != null) {
hasmask = true;
ipv6FlabelBuilder.setMask(ByteUtil.unsignedIntToBytes(source.getIpv6Label().getFlabelMask().getValue()));
}
ipv6FlabelCaseBuilder.setIpv6Flabel(ipv6FlabelBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv6FlabelCaseBuilder.build());
matchEntryBuilder.setHasMask(hasmask);
result.add(matchEntryBuilder.build());
}
if (source.getIpv6NdTarget() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setHasMask(false);
matchEntryBuilder.setOxmMatchField(Ipv6NdTarget.class);
Ipv6NdTargetCaseBuilder ipv6NdTargetCaseBuilder = new Ipv6NdTargetCaseBuilder();
Ipv6NdTargetBuilder ipv6NdTargetBuilder = new Ipv6NdTargetBuilder();
ipv6NdTargetBuilder.setIpv6Address(source.getIpv6NdTarget());
ipv6NdTargetCaseBuilder.setIpv6NdTarget(ipv6NdTargetBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv6NdTargetCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
if (source.getIpv6NdSll() != null) {
MacAddress ipv6NdSll = source.getIpv6NdSll();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6NdSll.class);
Ipv6NdSllCaseBuilder ipv6NdSllCaseBuilder = new Ipv6NdSllCaseBuilder();
Ipv6NdSllBuilder ipv6NdSllBuilder = new Ipv6NdSllBuilder();
ipv6NdSllBuilder.setMacAddress(ipv6NdSll);
ipv6NdSllCaseBuilder.setIpv6NdSll(ipv6NdSllBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv6NdSllCaseBuilder.build());
matchEntryBuilder.setHasMask(false);
result.add(matchEntryBuilder.build());
}
if (source.getIpv6NdTll() != null) {
MacAddress ipv6NdSll = source.getIpv6NdTll();
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6NdTll.class);
Ipv6NdTllCaseBuilder ipv6NdTllCaseBuilder = new Ipv6NdTllCaseBuilder();
Ipv6NdTllBuilder ipv6NdTllBuilder = new Ipv6NdTllBuilder();
ipv6NdTllBuilder.setMacAddress(ipv6NdSll);
ipv6NdTllCaseBuilder.setIpv6NdTll(ipv6NdTllBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv6NdTllCaseBuilder.build());
matchEntryBuilder.setHasMask(false);
result.add(matchEntryBuilder.build());
}
if (source.getIpv6ExtHeader() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
boolean hasmask = false;
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv6Exthdr.class);
Ipv6ExthdrCaseBuilder ipv6ExthdrCaseBuilder = new Ipv6ExthdrCaseBuilder();
Ipv6ExthdrBuilder ipv6ExthdrBuilder = new Ipv6ExthdrBuilder();
int bitmap = source.getIpv6ExtHeader().getIpv6Exthdr();
ipv6ExthdrBuilder.setPseudoField(makeIpv6ExthdrFlags(bitmap));
if (source.getIpv6ExtHeader().getIpv6ExthdrMask() != null) {
hasmask = true;
ipv6ExthdrBuilder.setMask(ByteUtil.unsignedShortToBytes(source.getIpv6ExtHeader().getIpv6ExthdrMask()));
}
ipv6ExthdrCaseBuilder.setIpv6Exthdr(ipv6ExthdrBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv6ExthdrCaseBuilder.build());
matchEntryBuilder.setHasMask(hasmask);
result.add(matchEntryBuilder.build());
}
return Optional.of(result);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project openflowplugin by opendaylight.
the class Ipv6DestinationEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Ipv6Prefix ipv6Address = new Ipv6Prefix("2001:db8::/32");
final Match ipv6abmMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Destination(ipv6Address).build()).build();
assertMatch(ipv6abmMatch, true, (out) -> {
byte[] address = new byte[16];
out.readBytes(address);
assertArrayEquals(address, IetfInetUtil.INSTANCE.ipv6AddressBytes(IpConversionUtil.extractIpv6Address(ipv6Address)));
byte[] mask = new byte[16];
out.readBytes(mask);
assertArrayEquals(mask, IpConversionUtil.convertIpv6PrefixToByteArray(IpConversionUtil.extractIpv6Prefix(ipv6Address)));
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project openflowplugin by opendaylight.
the class Ipv6DestinationEntrySerializerTest method testSerializeWithoutMask.
@Test
public void testSerializeWithoutMask() throws Exception {
final Ipv6Prefix ipv6Address = new Ipv6Prefix("2001:db8::123/128");
final Match ipv6abmMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Destination(ipv6Address).build()).build();
assertMatch(ipv6abmMatch, false, (out) -> {
byte[] address = new byte[16];
out.readBytes(address);
assertArrayEquals(address, IetfInetUtil.INSTANCE.ipv6AddressBytes(IpConversionUtil.extractIpv6Address(ipv6Address)));
});
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Prefix in project openflowplugin by opendaylight.
the class Ipv6SourceEntrySerializerTest method testSerialize.
@Test
public void testSerialize() throws Exception {
final Ipv6Prefix ipv6Address = new Ipv6Prefix("2001:db8::/32");
final Match ipv6abmMatch = new MatchBuilder().setLayer3Match(new Ipv6MatchBuilder().setIpv6Source(ipv6Address).build()).build();
assertMatch(ipv6abmMatch, true, (out) -> {
byte[] address = new byte[16];
out.readBytes(address);
assertArrayEquals(address, IetfInetUtil.INSTANCE.ipv6AddressBytes(IpConversionUtil.extractIpv6Address(ipv6Address)));
byte[] mask = new byte[16];
out.readBytes(mask);
assertArrayEquals(mask, IpConversionUtil.convertIpv6PrefixToByteArray(IpConversionUtil.extractIpv6Prefix(ipv6Address)));
});
}
Aggregations