public static boolean isValidIp6Cidr(String ip6Cidr) { try { IPv6Network network = IPv6Network.fromString(ip6Cidr); } catch (IllegalArgumentException ex) { return false; } return true; }
public static int getIp6CidrSize(String ip6Cidr) { IPv6Network network = null; try { network = IPv6Network.fromString(ip6Cidr); } catch (IllegalArgumentException ex) { return 0; } return network.getNetmask().asPrefixLength(); }
public static boolean isIp6InNetwork(String ip6, String ip6Cidr) { IPv6Network network = null; try { network = IPv6Network.fromString(ip6Cidr); } catch (IllegalArgumentException ex) { return false; } IPv6Address ip = IPv6Address.fromString(ip6); return network.contains(ip); }