com.esf.device.ethernet.service
Interface IEthernetDeviceService


public interface IEthernetDeviceService

Manages Ethernet device configurations.

Author:
eurotech CONFIGURATION Configuration will be accepted in the form of key/value pairs. The key/value pairs are strictly defined here: CONFIG_ENTRY -> KEY + "=" + VALUE KEY -> TYPE + INDEX + "_" + PARAM TYPE -> "eth" INDEX -> "0" | "1" | "2" | ... | "N" PARAM -> "interface" | "type" | "ipaddress" | "netmask" | "network" | "broadcast" | "gateway" VALUE -> (value of the specified parameter) EXAMPLE: eth0_interface=eth0 eth0_type=1 eth0_ipaddress=192.168.1.56 eth0_netmask=255.255.255.1 eth0_network=192.168.1.0 eth0_broadcast=192.168.1.255 eth0_gateway=192.168.1.1

Field Summary
static java.lang.String SERVICE_NAME
          Reports the class name representing this interface.
static int TYPE_DHCP
          definition for an Ethernet interface that uses DHCP for configuration
static int TYPE_NULL
          definition for an Ethernet interface that is not configured
static int TYPE_STATIC
          definition for an Ethernet interface that is statically configured
 
Method Summary
 void bringInterfaceDown(EthernetDevice ethernetDevice)
          brings an Ethernet interface down
 void bringInterfaceDown(java.lang.String ifaceName)
          brings an Ethernet interface down
 void bringInterfaceUp(EthernetDevice ethernetDevice, int state)
          brings an Ethernet interface up using the parameters currently set in in the specified Persistence field.
 java.lang.String getBroadcast(java.lang.String iface, int state)
          gets the broadcast address associated with this interface and state
 java.lang.String getGateway(java.lang.String iface, int state)
          gets the gateway address associated with this interface and state
 java.util.ArrayList getIfaceNames()
          returns a list of interface names present on this system
 java.lang.String getIpAddress(java.lang.String iface, int state)
          gets the IP address associated with this interface and state
 java.lang.String getNetmask(java.lang.String iface, int state)
          gets the network mask associated with this interface and state
 java.lang.String getNetwork(java.lang.String iface, int state)
          gets the network associated with this interface and state
 EthernetDevice getParameters(java.lang.String iface, int state)
          gets all of the parameters that make up an EthernetDevice for a specified state.
 int getType(java.lang.String iface, int state)
          gets the defined type (DHCP or STATIC) from either the OS configuration, the ESF configuration, or the currently running configuration
 boolean isIfaceUp(java.lang.String iface)
          gets the state of an Ethernet interface
 void setBroadcast(java.lang.String iface, int persistence, java.lang.String broadcast)
          sets the broadcast for an interface that has been defined to be statically defined
 void setGateway(java.lang.String iface, int persistence, java.lang.String gateway)
          sets the default gateway for an interface that has been defined to be statically defined
 void setIpAddress(java.lang.String iface, int persistence, java.lang.String ipAddress)
          sets the IP address for an interface that has been defined to be statically defined
 void setNetmask(java.lang.String iface, int persistence, java.lang.String netmask)
          sets the network mask for an interface that has been defined to be statically defined
 void setNetwork(java.lang.String iface, int persistence, java.lang.String network)
          sets the network definition for an interface that has been defined to be statically defined
 void setToDhcp(java.lang.String iface, int persistence)
          sets the method used to configure a particular interface to use either DHCP.
 void setToNull(java.lang.String iface, int persistence)
          removes the configuration currently set for a specified persistence level
 void setToStatic(java.lang.String iface, int persistence, java.lang.String ipAddress, java.lang.String netmask, java.lang.String network, java.lang.String broadcast, java.lang.String gateway)
          sets the parameters of a statically defined Ethernet interface.
 

Field Detail

SERVICE_NAME

public static final java.lang.String SERVICE_NAME
Reports the class name representing this interface.


TYPE_DHCP

public static final int TYPE_DHCP
definition for an Ethernet interface that uses DHCP for configuration

See Also:
Constant Field Values

TYPE_STATIC

public static final int TYPE_STATIC
definition for an Ethernet interface that is statically configured

See Also:
Constant Field Values

TYPE_NULL

public static final int TYPE_NULL
definition for an Ethernet interface that is not configured

See Also:
Constant Field Values
Method Detail

getIfaceNames

public java.util.ArrayList getIfaceNames()
                                  throws java.lang.Exception
returns a list of interface names present on this system

Returns:
an ArrayList of Strings representing the interface names present on this system
Throws:
java.lang.Exception - if the platform is improperly defined, not supported, or not defined

setToDhcp

public void setToDhcp(java.lang.String iface,
                      int persistence)
               throws java.lang.Exception
sets the method used to configure a particular interface to use either DHCP. If there are any static parameters defined they will be deleted.

Parameters:
iface - the interface being set as either DHCP or static
persistence - should use the definition in com.esf.core.persistence.service.Persistence. This allows configuration to be saved to OS config files, the ESF config files, or both. It also defines whether or not the new settings should take affect immediately or just be stored to their respective configuration files.
Throws:
java.lang.Exception - if any parameters are invalid or the iface can not be found

setToStatic

public void setToStatic(java.lang.String iface,
                        int persistence,
                        java.lang.String ipAddress,
                        java.lang.String netmask,
                        java.lang.String network,
                        java.lang.String broadcast,
                        java.lang.String gateway)
                 throws java.lang.Exception
sets the parameters of a statically defined Ethernet interface. If the interface is configured as DHCP it will be set to STATIC

Parameters:
iface - the interface to configure
persistence - should use the definition in com.esf.core.persistence.service.Persistence. This allows configuration to be saved to OS config files, the ESF config files, or both. It also defines whether or not the new settings should take affect immediately or just be stored to their respective configuration files.
ipAddress - the static IP address to set
netmask - the network mask to set
network - the network to set (for example 192.168.1.0)
broadcast - the broadcast address to set
gateway - the gateway to use
Throws:
java.lang.Exception - if any parameters are invalid or if any errors occur in making the changes persistent

setIpAddress

public void setIpAddress(java.lang.String iface,
                         int persistence,
                         java.lang.String ipAddress)
                  throws java.lang.Exception
sets the IP address for an interface that has been defined to be statically defined

Parameters:
iface - the interface to configure
persistence - should use the definition in com.esf.core.persistence.service.Persistence. This allows configuration to be saved to OS config files, the ESF config files, or both. It also defines whether or not the new settings should take affect immediatly or just be stored to their respective configuration files.
ipAddress - the new static IP address to set
Throws:
java.lang.Exception - if any parameters are invalid, if the interface to set is configured to use DHCP or if takeEffectNow is true and the interface is not up

setToNull

public void setToNull(java.lang.String iface,
                      int persistence)
               throws java.lang.Exception
removes the configuration currently set for a specified persistence level

Parameters:
iface - the interface to delete the configuration of
persistence - the persistence level for which the configuration should be deleted
Throws:
java.lang.Exception - if the parameters are invalid

setNetmask

public void setNetmask(java.lang.String iface,
                       int persistence,
                       java.lang.String netmask)
                throws java.lang.Exception
sets the network mask for an interface that has been defined to be statically defined

Parameters:
iface - the interface to configure
persistence - should use the definition in com.esf.core.persistence.service.Persistence. This allows configuration to be saved to OS config files, the ESF config files, or both. It also defines whether or not the new settings should take affect immediately or just be stored to their respective configuration files.
netmask - the new network mask to use
Throws:
java.lang.Exception - if any parameters are invalid, if the interface to set is configured to use DHCP or if takeEffectNow is true and the interface is not up

setNetwork

public void setNetwork(java.lang.String iface,
                       int persistence,
                       java.lang.String network)
                throws java.lang.Exception
sets the network definition for an interface that has been defined to be statically defined

Parameters:
iface - the interface to configure
persistence - should use the definition in com.esf.core.persistence.service.Persistence. This allows configuration to be saved to OS config files, the ESF config files, or both. It also defines whether or not the new settings should take affect immediately or just be stored to their respective configuration files.
network - the new network definition to use
Throws:
java.lang.Exception - if any parameters are invalid, if the interface to set is configured to use DHCP or if takeEffectNow is true and the interface is not up

setBroadcast

public void setBroadcast(java.lang.String iface,
                         int persistence,
                         java.lang.String broadcast)
                  throws java.lang.Exception
sets the broadcast for an interface that has been defined to be statically defined

Parameters:
iface - the interface to configure
persistence - should use the definition in com.esf.core.persistence.service.Persistence. This allows configuration to be saved to OS config files, the ESF config files, or both. It also defines whether or not the new settings should take affect immediateely or just be stored to their respective configuration files.
broadcast - the new broadcast definition to use
Throws:
java.lang.Exception - if any parameters are invalid, if the interface to set is configured to use DHCP or if takeEffectNow is true and the interface is not up

setGateway

public void setGateway(java.lang.String iface,
                       int persistence,
                       java.lang.String gateway)
                throws java.lang.Exception
sets the default gateway for an interface that has been defined to be statically defined

Parameters:
iface - the interface to configure
persistence - should use the definition in com.esf.core.persistence.service.Persistence. This allows configuration to be saved to OS config files, the ESF config files, or both. It also defines whether or not the new settings should take affect immediately or just be stored to their respective configuration files.
gateway - the new gateway to use
Throws:
java.lang.Exception - if any parameters are invalid, if the interface to set is configured to use DHCP or if takeEffectNow is true and the interface is not up

getType

public int getType(java.lang.String iface,
                   int state)
            throws java.lang.Exception
gets the defined type (DHCP or STATIC) from either the OS configuration, the ESF configuration, or the currently running configuration

Parameters:
iface - the interface to get the type from
state - the type of configuration to get. Must be either Persistence.OS_STATE, Persistence.ESF_STATE, or Persistence.CURRENT_STATE
Returns:
the type defined as either IEthernetDeviceService.TYPE_DHCP or IEthernetDeviceService.TYPE_STATIC
Throws:
java.lang.Exception - if there is an error, the type is not defined, or if the interface is not valid

getParameters

public EthernetDevice getParameters(java.lang.String iface,
                                    int state)
                             throws java.lang.Exception
gets all of the parameters that make up an EthernetDevice for a specified state.

Parameters:
iface - the interface to get the configuration of
state - the state of configuration to get. This is either Persistence.OS_STATE, Persistence.ESF_STATE, or Persistence.CURRENT_STATE
Returns:
the parameters associated with this interface and state
Throws:
java.lang.Exception - if there is an error, the type is not defined, or if the interface is not valid

getIpAddress

public java.lang.String getIpAddress(java.lang.String iface,
                                     int state)
                              throws java.lang.Exception
gets the IP address associated with this interface and state

Parameters:
iface - the interface to get the IP address of
state - the state of configuration to get. This is either Persistence.OS_STATE, Persistence.ESF_STATE, or Persistence.CURRENT_STATE
Returns:
the IP address associated with this interface and state
Throws:
java.lang.Exception - if there is an error, the type is not defined, or if the interface is not valid

getNetmask

public java.lang.String getNetmask(java.lang.String iface,
                                   int state)
                            throws java.lang.Exception
gets the network mask associated with this interface and state

Parameters:
iface - the interface to get the network mask of
state - the state of configuration to get. This is either Persistence.OS_STATE, Persistence.ESF_STATE, or Persistence.CURRENT_STATE
Returns:
the network mask associated with this interface and state
Throws:
java.lang.Exception - if there is an error, the type is not defined, or if the interface is not valid

getNetwork

public java.lang.String getNetwork(java.lang.String iface,
                                   int state)
                            throws java.lang.Exception
gets the network associated with this interface and state

Parameters:
iface - the interface to get the network of
state - the state of configuration to get. This is either Persistence.OS_STATE, Persistence.ESF_STATE, or Persistence.CURRENT_STATE
Returns:
the network associated with this interface and state
Throws:
java.lang.Exception - if there is an error, the type is not defined, or if the interface is not valid

getBroadcast

public java.lang.String getBroadcast(java.lang.String iface,
                                     int state)
                              throws java.lang.Exception
gets the broadcast address associated with this interface and state

Parameters:
iface - the interface to get the broadcast address of
state - the state of configuration to get. This is either Persistence.OS_STATE, Persistence.ESF_STATE, or Persistence.CURRENT_STATE
Returns:
the broadcast address associated with this interface and state
Throws:
java.lang.Exception - if there is an error, the type is not defined, or if the interface is not valid

getGateway

public java.lang.String getGateway(java.lang.String iface,
                                   int state)
                            throws java.lang.Exception
gets the gateway address associated with this interface and state

Parameters:
iface - the interface to get the gateway address of
state - the state of configuration to get. This is either Persistence.OS_STATE, Persistence.ESF_STATE, or Persistence.CURRENT_STATE
Returns:
the gateway address associated with this interface and state
Throws:
java.lang.Exception - if there is an error, the type is not defined, or if the interface is not valid

bringInterfaceUp

public void bringInterfaceUp(EthernetDevice ethernetDevice,
                             int state)
                      throws java.lang.Exception
brings an Ethernet interface up using the parameters currently set in in the specified Persistence field. This method will automatically call bringInterfaceDown(String iface) before bringing the interface up. This ensures it comes up in a clean state

Parameters:
ethernetDevice - the EthernetDevice to bring up
state - the persistence state to use when bringing up the interface
Throws:
java.lang.Exception - if the iface is invalid or if the interface is not properly configured

bringInterfaceDown

public void bringInterfaceDown(EthernetDevice ethernetDevice)
                        throws java.lang.Exception
brings an Ethernet interface down

Parameters:
ethernetDevice - the EthernetDevice to bring down
Throws:
java.lang.Exception - if the iface is invalid or if the interface is not up

bringInterfaceDown

public void bringInterfaceDown(java.lang.String ifaceName)
                        throws java.lang.Exception
brings an Ethernet interface down

Parameters:
ifaceName - the interface name to bring down
Throws:
java.lang.Exception - if the ifaceName is invalid or if the interface is not up

isIfaceUp

public boolean isIfaceUp(java.lang.String iface)
                  throws java.lang.Exception
gets the state of an Ethernet interface

Parameters:
iface - the interface to check for its status
Returns:
true if the interface is up, otherwise false
Throws:
java.lang.Exception - if the interface is invalid


Copyright © 2009 Eurotech Inc. All rights reserved.