com.esf.util.net.service
Interface INetworkUtilityService


public interface INetworkUtilityService

Utilities to check the status of a network link


Field Summary
static java.lang.String SERVICE_NAME
          service name of this interface for the bundle activator (com.esf.util.net.service)
 
Method Summary
 java.lang.String calculateBroadcast(java.lang.String ipAddress, java.lang.String netmask)
          calculates the broadcast based on an IP address and subnet mask
 java.lang.String calculateNetwork(java.lang.String ipAddress, java.lang.String netmask)
          calculates the network based on an IP address and subnet mask
 java.lang.String[] getInterfaceNames()
          gets the interface names as would be shown by the output of ifconfig
 java.lang.String getIpAddress(java.lang.String ifaceName)
          gets the IP address for a specified interface.
 java.lang.String getMacAddress(java.lang.String ifaceName)
          gets the MAC address for a specified interface.
 int getNetmaskIntForm(java.lang.String netmask)
          gets the integer representation of the netmask (i.e.
 boolean isLinkUp(java.lang.String ifaceName)
          checks to see if a valid link is present
 boolean isUp(java.lang.String ifaceName)
          checks to see if an interface is 'up'
 

Field Detail

SERVICE_NAME

static final java.lang.String SERVICE_NAME
service name of this interface for the bundle activator (com.esf.util.net.service)

Method Detail

getInterfaceNames

java.lang.String[] getInterfaceNames()
gets the interface names as would be shown by the output of ifconfig

Returns:
the interfaces names currently 'up'

isUp

boolean isUp(java.lang.String ifaceName)
checks to see if an interface is 'up'

Parameters:
ifaceName - the interface to check
Returns:
true if the interface is up, otherwise false

getIpAddress

java.lang.String getIpAddress(java.lang.String ifaceName)
gets the IP address for a specified interface. In order for this to return a valid response the interface must be up

Parameters:
ifaceName - the interface to get the IP address of
Returns:
a String representing the IP address of the specified interface. null is returned if the interface is not up

isLinkUp

boolean isLinkUp(java.lang.String ifaceName)
checks to see if a valid link is present

Parameters:
ifaceName - the interface to check
Returns:
true if a link is present, otherwise false

getMacAddress

java.lang.String getMacAddress(java.lang.String ifaceName)
gets the MAC address for a specified interface. In order for this to return a valid response the interface must be up

Parameters:
ifaceName - the interface to get the MAC address of
Returns:
a String representing the MAC address of the specified interface. null is returned if the interface is not up

calculateNetwork

java.lang.String calculateNetwork(java.lang.String ipAddress,
                                  java.lang.String netmask)
calculates the network based on an IP address and subnet mask

Parameters:
ipAddress - the IP address to use as a base for the calculation
netmask - the network mask to use as a base for the calculation
Returns:
the calculated network as a String

calculateBroadcast

java.lang.String calculateBroadcast(java.lang.String ipAddress,
                                    java.lang.String netmask)
calculates the broadcast based on an IP address and subnet mask

Parameters:
ipAddress - the IP address to use as a base for the calculation
netmask - the network mask to use as a base for the calculation
Returns:
the calculated broadcast address as a String

getNetmaskIntForm

int getNetmaskIntForm(java.lang.String netmask)
                      throws java.lang.Exception
gets the integer representation of the netmask (i.e. 8 for 255.0.0.0 and 16 for 255.255.0.0)

Parameters:
netmask - the netmask to convert it 'dotted notation' (i.e. 255.255.255.0)
Returns:
the integer representing the subnet mask
Throws:
java.lang.Exception - if the passed in subnet mask is invalid