com.cysols.iodef.utils
Class ASUtilities

java.lang.Object
  extended by com.cysols.iodef.utils.ASUtilities

public class ASUtilities
extends Object

This is a utility class which has mainly two static methods; one is to return a country name from IP Address, another is to return AS number from IP Address. Perl scripts are used for resolving the country name and AS number. "ip2country.pl" is to resolve the country name. This script is called by ipToCountry(String ipAddr) method. On the other hand, two perl scripts are required when this class resolves the AS number. It cannot return the AS number without running the perl as_paths_dNew.pl daemon script. It is provided as another package. How to use is as follows;

 0. extracts ASPATHS.tgz
 1. run as follows
       %./as_paths_dNew.pl tmp/*
           reading database....
           database has been read.
           aut-num -- 10032  import --  30346  route -- 260152 origin --  260148 Lines = 3588540, Ignored = 2688963
            ^Z
           Suspended
       %bg
          [1]    ./as_paths_dNew.pl tmp/alltel.db tmp/altdb.db tmp/ans.db tmp/aoltw.db  ... &
 

Then, "as_paths_cN.pl" is called from ipToASNumber(String ipAddr) and the AS number is resolved through those perl scripts.


Field Summary
static String DEFAULT_IP2AS_PATH
          Default program path of as_paths_cN.pl (AS number resolver).
static String DEFAULT_IP2COUNTRY_PATH
          Default program path of ip2country.pl (country name resovler).
static String UNKNOWN
          A string when an IP Address cannot be resolved to its AS Number or country name.
 
Method Summary
static String getIP2ASCommandPath()
          Returns the path of command to convert IP address to AS number.
static String getIP2CountryCommandPath()
          Returns the path of command to convert IP address to country string.
static String ipToASNumber(String ipAddr)
          Convert the specified IP address to the corresponding AS number.
static String ipToCountry(String ipAddr)
          Convert the specified IP address to the corresponding counrty string.
static void setIP2ASCommandPath(String path)
          Sets the path of command to convert IP address to AS number as the specified.
static void setIP2CountryCommandPath(String path)
          Sets the path of command to convert IP address to country string as the specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_IP2AS_PATH

public static final String DEFAULT_IP2AS_PATH
Default program path of as_paths_cN.pl (AS number resolver).

See Also:
Constant Field Values

DEFAULT_IP2COUNTRY_PATH

public static final String DEFAULT_IP2COUNTRY_PATH
Default program path of ip2country.pl (country name resovler).

See Also:
Constant Field Values

UNKNOWN

public static final String UNKNOWN
A string when an IP Address cannot be resolved to its AS Number or country name.

See Also:
Constant Field Values
Method Detail

getIP2ASCommandPath

public static String getIP2ASCommandPath()
Returns the path of command to convert IP address to AS number.

Returns:
IP address to AS number command path.

setIP2ASCommandPath

public static void setIP2ASCommandPath(String path)
Sets the path of command to convert IP address to AS number as the specified.

Parameters:
path - IP address to AS number command path.

getIP2CountryCommandPath

public static String getIP2CountryCommandPath()
Returns the path of command to convert IP address to country string.

Returns:
IP address to country string command path.

setIP2CountryCommandPath

public static void setIP2CountryCommandPath(String path)
Sets the path of command to convert IP address to country string as the specified.

Parameters:
path - IP address to country string command path.

ipToASNumber

public static String ipToASNumber(String ipAddr)
Convert the specified IP address to the corresponding AS number. "unknown" returns if the command fails or IP address is invalid.

Parameters:
ipAddr - IP address to be converted to AS number.
Returns:
AS number corresponding to the specified IP address.

ipToCountry

public static String ipToCountry(String ipAddr)
Convert the specified IP address to the corresponding counrty string. "unknown" returns if the command fails or IP address is invalid.

Parameters:
ipAddr - IP address to be converted to country string.
Returns:
country string corresponding to the specified IP address.