@Test public void shouldnotMatch() throws IpTypeMissMatchException, IPStringConversionException { IPv6Cidr cidr1 = new IPv6Cidr("cccc:cccc:cccc:cccc::192.168.3.51/64"); IPv6Cidr cidr2 = new IPv6Cidr("cccc:ffff:cccc:cccc:aaaa:aaaa:aaaa:aaaa/64"); assertFalse(cidr1.matches(cidr2)); }
public boolean matches(IPv6Cidr oCidr) throws IpTypeMissMatchException, IPStringConversionException { if (oCidr == null) { return false; } if (oCidr.getSubnet() != this.subnet) { return false; } byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(oCidr.getIpBytes(), maskBytes, ByteStreamOperation.AND); for (int i = 0; i < mySubnet.length; i++) { if (mySubnet[i] != theirSubnet[i]) { return false; } } return true; }
IPv6Cidr { public boolean matches(IPv6Cidr oCidr) throws IpTypeMissMatchException, IPStringConversionException { if (oCidr == null) { return false; } if (oCidr.getSubnet() != this.subnet) { return false; } byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(oCidr.getIpBytes(), maskBytes, ByteStreamOperation.AND); for (int i = 0; i < mySubnet.length; i++) { if (mySubnet[i] != theirSubnet[i]) { return false; } } return true; } }
IPv6Cidr { public boolean matches(IPv6Cidr oCidr) throws IpTypeMissMatchException, IPStringConversionException { if (oCidr == null) { return false; } if (oCidr.getSubnet() != this.subnet) { return false; } byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(oCidr.getIpBytes(), maskBytes, ByteStreamOperation.AND); for (int i = 0; i < mySubnet.length; i++) { if (mySubnet[i] != theirSubnet[i]) { return false; } } return true; } IPv6Cidr();  IPv6Cidr(String cidr); }
IPv6Cidr { public boolean matches(IPv6Cidr oCidr) throws IpTypeMissMatchException, IPStringConversionException { if (oCidr == null) { return false; } if (oCidr.getSubnet() != this.subnet) { return false; } byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(oCidr.getIpBytes(), maskBytes, ByteStreamOperation.AND); for (int i = 0; i < mySubnet.length; i++) { if (mySubnet[i] != theirSubnet[i]) { return false; } } return true; } IPv6Cidr();  IPv6Cidr(String cidr); void setCidr(String in); boolean contains(String ip); boolean matches(IPv6Cidr oCidr); String getExpandedIPv6Cidr(String cidr); String getCidr(); String getIp(); int getSubnet(); byte[] getIpBytes(); byte[] getMaskBytes(); }
IPv6Cidr { public boolean matches(IPv6Cidr oCidr) throws IpTypeMissMatchException, IPStringConversionException { if (oCidr == null) { return false; } if (oCidr.getSubnet() != this.subnet) { return false; } byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(oCidr.getIpBytes(), maskBytes, ByteStreamOperation.AND); for (int i = 0; i < mySubnet.length; i++) { if (mySubnet[i] != theirSubnet[i]) { return false; } } return true; } IPv6Cidr();  IPv6Cidr(String cidr); void setCidr(String in); boolean contains(String ip); boolean matches(IPv6Cidr oCidr); String getExpandedIPv6Cidr(String cidr); String getCidr(); String getIp(); int getSubnet(); byte[] getIpBytes(); byte[] getMaskBytes();  }