private Map<String,String> checkIPVersion(String range){
  Map<String,String> details=new HashMap<String,String>(3);
  StringTokenizer st;
  String ipStart, ipEnd;
  if (range.contains("-")) {
    debug.message("IPRange found - ");
    st=new StringTokenizer(range,"-");
    if (st.countTokens() != 2) {
      throw new IllegalArgumentException(range + " is not a valid range");
    }
    ipStart=st.nextToken();
    ipEnd=st.nextToken();
    if (ValidateIPaddress.isIPv4(ipStart) && ValidateIPaddress.isIPv4(ipEnd)) {
      details.put(IP_Version,IP_V4);
      details.put(IP_TYPE,"Range");
    }
 else     if (ValidateIPaddress.isIPv6(ipStart) && ValidateIPaddress.isIPv6(ipEnd)) {
      details.put(IP_Version,IP_V6);
      details.put(IP_TYPE,"Range");
      details.put(IP_START,ipStart);
      details.put(IP_END,ipEnd);
    }
 else {
      throw new IllegalArgumentException(range + " is not a valid range");
    }
  }
 else   if (range.contains("/")) {
    debug.message("IPRange found / ");
    String cidr;
    st=new StringTokenizer(range,"/");
    if (st.countTokens() != 2) {
      throw new IllegalArgumentException("Invalid CIDR found.");
    }
    ipStart=st.nextToken();
    cidr=st.nextToken();
    if (ValidateIPaddress.isIPv4(ipStart) && (Integer.parseInt(cidr) >= 0) && (Integer.parseInt(cidr) <= 32)) {
      details.put(IP_Version,IP_V4);
      details.put(IP_TYPE,"CIDR");
    }
 else     if (ValidateIPaddress.isIPv6(ipStart) && (Integer.parseInt(cidr) >= 0) && (Integer.parseInt(cidr) <= 128)) {
      details.put(IP_Version,IP_V6);
      details.put(IP_TYPE,"CIDR");
    }
 else {
      throw new IllegalArgumentException(ipStart + " is not a valid format for CIDR");
    }
  }
 else {
    debug.message("IPRange found single IP");
    if (ValidateIPaddress.isIPv4(range)) {
      details.put(IP_Version,IP_V4);
      details.put(IP_TYPE,"Single");
    }
 else     if (ValidateIPaddress.isIPv6(range)) {
      details.put(IP_Version,IP_V6);
      details.put(IP_TYPE,"Single");
    }
 else {
      throw new IllegalArgumentException(range + " is not a valid IP");
    }
  }
  return details;
}

private Map < String , String > checkIPVersion ( String range ) { Map < String , String > details = new HashMap < String , String > ( 3 ) ; StringTokenizer st ; String ipStart , ipEnd ; if ( range . contains ( "-" ) ) { debug . message ( "IPRange found - " ) ; st = new StringTokenizer ( range , "-" ) ; if ( st . countTokens ( ) != 2 ) { throw new IllegalArgumentException ( range + " is not a valid range" ) ; } ipStart = st . nextToken ( ) ; ipEnd = st . nextToken ( ) ; if ( ValidateIPaddress . isIPv4 ( ipStart ) && ValidateIPaddress . isIPv4 ( ipEnd ) ) { details . put ( IP_Version , IP_V4 ) ; details . put ( IP_TYPE , "Range" ) ; } else if ( ValidateIPaddress . isIPv6 ( ipStart ) && ValidateIPaddress . isIPv6 ( ipEnd ) ) { details . put ( IP_Version , IP_V6 ) ; details . put ( IP_TYPE , "Range" ) ; details . put ( IP_START , ipStart ) ; details . put ( IP_END , ipEnd ) ; } else { throw new IllegalArgumentException ( range + " is not a valid range" ) ; } } else if ( range . contains ( "/" ) ) { debug . message ( "IPRange found / " ) ; String cidr ; st = new StringTokenizer ( range , "/" ) ; if ( st . countTokens ( ) != 2 ) { throw new IllegalArgumentException ( "Invalid CIDR found." ) ; } ipStart = st . nextToken ( ) ; cidr = st . nextToken ( ) ; if ( ValidateIPaddress . isIPv4 ( ipStart ) && ( Integer . parseInt ( cidr ) >= 0 ) && ( Integer . parseInt ( cidr ) <= 32 ) ) { details . put ( IP_Version , IP_V4 ) ; details . put ( IP_TYPE , "CIDR" ) ; } else if ( ValidateIPaddress . isIPv6 ( ipStart ) && ( Integer . parseInt ( cidr ) >= 0 ) && ( Integer . parseInt ( cidr ) <= 128 ) ) { details . put ( IP_Version , IP_V6 ) ; details . put ( IP_TYPE , "CIDR" ) ; } else { throw new IllegalArgumentException ( ipStart + " is not a valid format for CIDR" ) ; } } else { debug . message ( "IPRange found single IP" ) ; if ( ValidateIPaddress . isIPv4 ( range ) ) { details . put ( IP_Version , IP_V4 ) ; details . put ( IP_TYPE , "Single" ) ; } else if ( ValidateIPaddress . isIPv6 ( range ) ) { details . put ( IP_Version , IP_V6 ) ; details . put ( IP_TYPE , "Single" ) ; } else { throw new IllegalArgumentException ( range + " is not a valid IP" ) ; } } return details ; }
checks what type of version of ip range is
