use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.
the class MatchResponseConvertor2Test method testWithMatchEntryWithSrcArbitraryBitMaskAndDstCidrMask.
/**
* Test {@link MatchResponseConvertor#convert(MatchEntriesGrouping, VersionDatapathIdConvertorData)}.
*/
@Test
public void testWithMatchEntryWithSrcArbitraryBitMaskAndDstCidrMask() {
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(Ipv4Src.class);
entriesBuilder.setHasMask(true);
final Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
final Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(new Ipv4Address("10.1.1.1"));
ipv4SrcBuilder.setMask(new byte[] { (byte) 255, (byte) 0, (byte) 255, 0 });
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
entries.add(entriesBuilder.build());
entriesBuilder = new MatchEntryBuilder();
entriesBuilder.setOxmClass(OpenflowBasicClass.class);
entriesBuilder.setOxmMatchField(Ipv4Dst.class);
entriesBuilder.setHasMask(true);
final Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
final Ipv4DstBuilder ipv4AddressBuilder = new Ipv4DstBuilder();
ipv4AddressBuilder.setIpv4Address(new Ipv4Address("10.0.1.1"));
ipv4AddressBuilder.setMask(new byte[] { (byte) 255, (byte) 255, (byte) 240, 0 });
ipv4DstCaseBuilder.setIpv4Dst(ipv4AddressBuilder.build());
entriesBuilder.setMatchEntryValue(ipv4DstCaseBuilder.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 salMatch = convert(match, datapathIdConvertorData);
final org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match builtMatch = salMatch.build();
final Ipv4MatchArbitraryBitMask ipv4MatchArbitraryBitMask = (Ipv4MatchArbitraryBitMask) builtMatch.getLayer3Match();
Assert.assertEquals("Wrong ipv4 src address", "10.1.1.1", ipv4MatchArbitraryBitMask.getIpv4SourceAddressNoMask().getValue());
Assert.assertEquals("Wrong ipv4 dst address", "10.0.1.1", ipv4MatchArbitraryBitMask.getIpv4DestinationAddressNoMask().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address 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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address 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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.
the class SetNwSrcActionSerializer method buildAction.
@Override
protected SetFieldCase buildAction(Action input) {
final Address address = SetNwSrcActionCase.class.cast(input).getSetNwSrcAction().getAddress();
final SetFieldBuilder builder = new SetFieldBuilder();
if (Ipv4.class.isInstance(address)) {
builder.setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(Ipv4.class.cast(address).getIpv4Address()).build());
} else if (Ipv6.class.isInstance(address)) {
builder.setLayer3Match(new Ipv6MatchBuilder().setIpv6Source(Ipv6.class.cast(address).getIpv6Address()).build());
}
return new SetFieldCaseBuilder().setSetField(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project openflowplugin by opendaylight.
the class AbstractMatchEntrySerializer method writeIpv4Prefix.
/**
* Serialize Ipv4 prefix (address and mask).
*
* @param prefix Ipv4 prefix
* @param outBuffer output buffer
*/
protected static void writeIpv4Prefix(final Ipv4Prefix prefix, final ByteBuf outBuffer) {
// Split address to IP and mask
final Iterator<String> addressParts = IpConversionUtil.splitToParts(prefix);
// Write address part of prefix
writeIpv4Address(new Ipv4Address(addressParts.next()), outBuffer);
// If prefix had mask, also write prefix
Optional.ofNullable(MatchConvertorUtil.extractIpv4Mask(addressParts)).ifPresent(mask -> writeMask(mask, outBuffer, EncodeConstants.GROUPS_IN_IPV4_ADDRESS));
}
Aggregations