private OFMatchV3 buildOFMatchV3() { OFFactory of13Factory = OFFactories.getFactory(OFVersion.OF_13); OFOxms oxms = of13Factory.oxms(); OFOxmEthType ofOxmEthType = oxms.buildEthType().setValue(EthType.IPv4).build(); OFOxmIpv4Src ofOxmIpv4Src = oxms.buildIpv4Src().setValue(IPv4Address.of(multicastGroup.sourceIP)).build(); OFOxmIpProto ofOxmIpProto = oxms.buildIpProto().setValue(IpProtocol.UDP).build(); OFOxmIpv4Dst ofOxmIpv4Dst = oxms.buildIpv4Dst().setValue(IPv4Address.of(multicastGroup.groupIP)).build(); OFOxmList oxmList = OFOxmList.of(ofOxmEthType, ofOxmIpv4Src, ofOxmIpv4Dst, ofOxmIpProto); OFMatchV3 of13Match = of13Factory.buildMatchV3().setOxmList(oxmList).build(); return of13Match; }
@Test public void testGetCanonicalNoMask() { IPv4AddressWithMask fullIp = IPv4AddressWithMask.of("1.2.3.4/32"); assertEquals(IPv4Address.NO_MASK, fullIp.getMask()); OFOxmIpv4SrcMasked ipv4SrcMasked = oxms.ipv4SrcMasked(fullIp.getValue(), fullIp.getMask()); assertTrue(ipv4SrcMasked.isMasked()); assertEquals(IPv4Address.NO_MASK, ipv4SrcMasked.getMask()); // canonicalize should convert the masked oxm to the non-masked one OFOxm<IPv4Address> canonical = ipv4SrcMasked.getCanonical(); assertThat(canonical, CoreMatchers.instanceOf(OFOxmIpv4Src.class)); assertFalse(canonical.isMasked()); }