@Test public void shouldContainIps48through63() throws Exception { int i; String ipStr; IPv6Cidr cidr = new IPv6Cidr("ffff::192.168.3.48/124"); assertFalse(cidr.contains("ffff::192.168.3.47")); for (i = 48; i <= 63; i++) { ipStr = String.format("ffff::192.168.3.%d", i); } assertFalse(cidr.contains("ffff::192.168.3.64")); }
public boolean contains(String ip) throws IPStringConversionException, IpTypeMissMatchException { boolean out; if(!IPUtils.isValidIpv6String(ip)) { return false; } byte[] theirBytes = new IPv6(ip).getBytes(); byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(theirBytes, maskBytes, ByteStreamOperation.AND); out = IPUtils.bytesEqual(theirSubnet, mySubnet); return out; }
IPv6Cidr { public boolean contains(String ip) throws IPStringConversionException, IpTypeMissMatchException { boolean out; if(!IPUtils.isValidIpv6String(ip)) { return false; } byte[] theirBytes = new IPv6(ip).getBytes(); byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(theirBytes, maskBytes, ByteStreamOperation.AND); out = IPUtils.bytesEqual(theirSubnet, mySubnet); return out; } }
IPv6Cidr { public boolean contains(String ip) throws IPStringConversionException, IpTypeMissMatchException { boolean out; if(!IPUtils.isValidIpv6String(ip)) { return false; } byte[] theirBytes = new IPv6(ip).getBytes(); byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(theirBytes, maskBytes, ByteStreamOperation.AND); out = IPUtils.bytesEqual(theirSubnet, mySubnet); return out; } IPv6Cidr();  IPv6Cidr(String cidr); }
IPv6Cidr { public boolean contains(String ip) throws IPStringConversionException, IpTypeMissMatchException { boolean out; if(!IPUtils.isValidIpv6String(ip)) { return false; } byte[] theirBytes = new IPv6(ip).getBytes(); byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(theirBytes, maskBytes, ByteStreamOperation.AND); out = IPUtils.bytesEqual(theirSubnet, mySubnet); return out; } 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 contains(String ip) throws IPStringConversionException, IpTypeMissMatchException { boolean out; if(!IPUtils.isValidIpv6String(ip)) { return false; } byte[] theirBytes = new IPv6(ip).getBytes(); byte[] mySubnet = IPUtils.opBytes(ipBytes, maskBytes, ByteStreamOperation.AND); byte[] theirSubnet = IPUtils.opBytes(theirBytes, maskBytes, ByteStreamOperation.AND); out = IPUtils.bytesEqual(theirSubnet, mySubnet); return out; } 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();  }