+ if (ipVersion == 6) {
+ // fix for Bug2290 - this is custom code because no classes
+ // with ODL-friendly licenses have been found
+ // extract address (in front of /) and length (after /)
+ String[] parts = cidr.split("/");
+ if (parts.length != 2) {
+ return false;
+ }
+ try {
+ int length = Integer.parseInt(parts[1]);
+ //TODO?: limit check on length
+ // convert to byte array
+ byte[] addrBytes = ((Inet6Address) InetAddress.getByName(parts[0])).getAddress();
+ int i;
+ for (i=length; i<128; i++) { // offset is to ensure proper comparison
+ if (((((int) addrBytes[i/8]) & 0x000000FF) & (1 << (7-(i%8)))) != 0) {
+ return(false);
+ }
+ }
+ return(true);
+ } catch (Exception e) {
+ return(false);
+ }
+ }
+ return false;