private void processIPv6(final String rule){
  final String[] s=rule.split("/",-1);
  final String address=s[0];
  final String ipv6Literal;
  if (address.charAt(0) == '[' && address.charAt(address.length() - 1) == ']') {
    ipv6Literal=address.substring(1,address.length() - 1);
  }
 else {
    ipv6Literal=address;
  }
  boolean isValid;
  try {
    final Class<?> ipUtils=Class.forName("sun.net.util.IPAddressUtil");
    final Method method=ipUtils.getMethod("isIPv6LiteralAddress",String.class);
    isValid=(Boolean)method.invoke(null,ipv6Literal);
  }
 catch (  Exception e) {
    isValid=true;
  }
  if (!isValid) {
    throw genericDecodeError();
  }
  final InetAddress addr;
  try {
    addr=InetAddress.getByName(address);
  }
 catch (  final UnknownHostException ex) {
    throw genericDecodeError();
  }
  if (addr instanceof Inet6Address) {
    this.ruleType=RuleType.IPv6;
    final Inet6Address addr6=(Inet6Address)addr;
    this.ruleMask=addr6.getAddress();
    this.prefixMask=new byte[IN6ADDRSZ];
    prefixMask(processPrefix(s,IPV6MAXPREFIX));
  }
 else {
    if (s.length == 2) {
      throw genericDecodeError();
    }
    this.ruleMask=addr.getAddress();
    this.ruleType=RuleType.IPv4;
    this.prefixMask=new byte[IN4ADDRSZ];
    prefixMask(processPrefix(s,IPV4MAXPREFIX));
  }
}

private void processIPv6 ( final String rule ) { final String [ ] s = rule . split ( "/" , - 1 ) ; final String address = s [ 0 ] ; final String ipv6Literal ; if ( address . charAt ( 0 ) == '[' && address . charAt ( address . length ( ) - 1 ) == ']' ) { ipv6Literal = address . substring ( 1 , address . length ( ) - 1 ) ; } else { ipv6Literal = address ; } boolean isValid ; try { final Class < ? > ipUtils = Class . forName ( "sun.net.util.IPAddressUtil" ) ; final Method method = ipUtils . getMethod ( "isIPv6LiteralAddress" , String . class ) ; isValid = ( Boolean ) method . invoke ( null , ipv6Literal ) ; } catch ( Exception e ) { isValid = true ; } if ( ! isValid ) { throw genericDecodeError ( ) ; } final InetAddress addr ; try { addr = InetAddress . getByName ( address ) ; } catch ( final UnknownHostException ex ) { throw genericDecodeError ( ) ; } if ( addr instanceof Inet6Address ) { this . ruleType = RuleType . IPv6 ; final Inet6Address addr6 = ( Inet6Address ) addr ; this . ruleMask = addr6 . getAddress ( ) ; this . prefixMask = new byte [ IN6ADDRSZ ] ; prefixMask ( processPrefix ( s , IPV6MAXPREFIX ) ) ; } else { if ( s . length == 2 ) { throw genericDecodeError ( ) ; } this . ruleMask = addr . getAddress ( ) ; this . ruleType = RuleType . IPv4 ; this . prefixMask = new byte [ IN4ADDRSZ ] ; prefixMask ( processPrefix ( s , IPV4MAXPREFIX ) ) ; } }
the rule string is an ipv6 rule . build both the prefix mask array and rule mask from the string .
