use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder in project openflowplugin by opendaylight.
the class MatchConvertorTest method testIpv4MatchArbitraryBitMaskwithNoMask.
@Test
public void testIpv4MatchArbitraryBitMaskwithNoMask() {
MatchBuilder builder = new MatchBuilder();
Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = new Ipv4MatchArbitraryBitMaskBuilder();
ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask(new Ipv4Address("10.2.2.2"));
ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(new Ipv4Address("10.1.1.1"));
builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
checkEntryHeader(entry, Ipv4Src.class, false);
Assert.assertEquals("wrong Ipv4Address source", "10.2.2.2", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
entry = entries.get(1);
checkEntryHeader(entry, Ipv4Dst.class, false);
Assert.assertEquals("wrong Ipv4Address destination", "10.1.1.1", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder in project openflowplugin by opendaylight.
the class MatchConvertorTest method testIpv4MatchArbitraryBitMaskwithMask.
@Test
public void testIpv4MatchArbitraryBitMaskwithMask() {
Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder = new Ipv4MatchArbitraryBitMaskBuilder();
ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask(new Ipv4Address("10.2.2.2"));
ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceArbitraryBitmask(new DottedQuad("0.0.255.0"));
ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(new Ipv4Address("10.1.1.1"));
ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationArbitraryBitmask(new DottedQuad("0.240.0.0"));
MatchBuilder builder = new MatchBuilder();
builder.setLayer3Match(ipv4MatchArbitraryBitMaskBuilder.build());
Match match = builder.build();
Optional<List<MatchEntry>> entriesOptional = converterManager.convert(match, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
List<MatchEntry> entries = entriesOptional.get();
Assert.assertEquals("Wrong entries size", 2, entries.size());
MatchEntry entry = entries.get(0);
checkEntryHeader(entry, Ipv4Src.class, true);
Assert.assertEquals("wrong Ipv4Address source", "10.2.2.2", ((Ipv4SrcCase) entry.getMatchEntryValue()).getIpv4Src().getIpv4Address().getValue());
entry = entries.get(1);
checkEntryHeader(entry, Ipv4Dst.class, true);
Assert.assertEquals("wrong Ipv4Adress destination", "10.1.1.1", ((Ipv4DstCase) entry.getMatchEntryValue()).getIpv4Dst().getIpv4Address().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchArbitraryBitMaskBuilder in project openflowplugin by opendaylight.
the class MatchNormalizationUtilTest method normalizeIpv4MatchArbitraryBitMask.
@Test
public void normalizeIpv4MatchArbitraryBitMask() {
final Ipv4Address leftAddress = new Ipv4Address("192.168.72.1");
final DottedQuad leftMask = new DottedQuad("255.255.0.0");
final Ipv4Prefix right = new Ipv4Prefix("192.168.0.0/16");
final MatchBuilder matchBuilder = MatchNormalizationUtil.normalizeIpv4MatchArbitraryBitMask(new MatchBuilder().setLayer3Match(new Ipv4MatchArbitraryBitMaskBuilder().setIpv4SourceAddressNoMask(leftAddress).setIpv4SourceArbitraryBitmask(leftMask).setIpv4DestinationAddressNoMask(leftAddress).setIpv4DestinationArbitraryBitmask(leftMask).build()));
assertEquals(right, Ipv4Match.class.cast(matchBuilder.getLayer3Match()).getIpv4Source());
assertEquals(right, Ipv4Match.class.cast(matchBuilder.getLayer3Match()).getIpv4Destination());
}
Aggregations