use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad 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.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad in project openflowplugin by opendaylight.
the class AddressNormalizationUtilTest method normalizeIpv4Arbitrary.
@Test
public void normalizeIpv4Arbitrary() throws Exception {
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");
assertEquals(right, AddressNormalizationUtil.normalizeIpv4Arbitrary(leftAddress, leftMask));
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad 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());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad in project openflowplugin by opendaylight.
the class IpConversionUtil method extractIpv4AddressMask.
public static DottedQuad extractIpv4AddressMask(final Ipv4Prefix ipv4Prefix) {
Iterator<String> addressParts = PREFIX_SPLITTER.split(ipv4Prefix.getValue()).iterator();
addressParts.next();
Integer cidrMask = 0;
if (addressParts.hasNext()) {
cidrMask = Integer.parseInt(addressParts.next());
}
long maskBits = 0;
maskBits = 0xffffffff << IPV4_ADDRESS_LENGTH - cidrMask;
String mask = String.format("%d.%d.%d.%d", (maskBits & 0x0000000000ff000000L) >> 24, (maskBits & 0x0000000000ff0000) >> 16, (maskBits & 0x0000000000ff00) >> 8, maskBits & 0xff);
DottedQuad netMask = new DottedQuad(mask);
return netMask;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad in project openflowplugin by opendaylight.
the class IpConversionUtilTest method extractIpv4AddressMaskTest.
@Test
public void extractIpv4AddressMaskTest() {
DottedQuad dottedQuad;
dottedQuad = IpConversionUtil.extractIpv4AddressMask(new Ipv4Prefix("1.1.1.1/24"));
Assert.assertEquals(dottedQuad.getValue(), "255.255.255.0");
}
Aggregations