com.dalsemi.tininet
Class TININet

java.lang.Object
  |
  +--com.dalsemi.tininet.TININet

public class TININet
extends java.lang.Object

This class is used to set up parameters for TINI networking.


Field Summary
static int COMMITTED
          Network configuration is committed to flash memory.
static int RESTORE_DISABLED
          Network configuration restore is disabled.
static int UNCOMMITTED
          Network configuration is not committed to flash memory.
 
Constructor Summary
TININet()
           
 
Method Summary
static void addInterfaceEntry(byte[] name, byte[] ipAddr, byte[] subnet, byte[] gateway, byte flags, byte type, int transmitter)
          Adds an interface to the network interface list with the given parameters.
static void commitNetworkState()
          Commits the current network configuration to flash.
static void disableNetworkRestore()
          Disables the ability to commit or restore network configuration until the bank 7 application is re-flashed.
static byte[] getARPCacheTable()
          Gets the current ARP cache table.
static byte[] getConnectionTable()
          Gets the current connection table.
static java.lang.String getDHCPServerIP()
          Gets the IP address of DHCP server.
static void getDHCPServerIP(byte[] address)
          Gets the IP address of the DHCP server.
static int getDNSTimeout()
          Gets the timeout value for DNS queries.
static java.lang.String getDomainname()
          Gets the domain name of TINI.
static java.lang.String getEthernetAddress()
          Gets the ethernet MAC address in dotted decimal notation.
static void getEthernetAddress(byte[] address)
          Gets the ethernet MAC address into the given byte array, with the most significant byte first.
static java.lang.String getGatewayIP()
          Gets the gateway IP address of the default interface as a String.
static void getGatewayIP(byte[] address)
          Gets the gateway IP address of the default interface.
static java.lang.String getGatewayIP(java.lang.String interfaceName)
          Gets the IP address of the gateway for the specified interface as a string in dotted decimal notation.
static void getGatewayIP(java.lang.String interfaceName, byte[] address)
          Gets the IP address of the gateway for the specified interface.
static java.lang.String getHostname()
          Gets the hostname of TINI.
static boolean getInterfaceInfo(int interfaceNum, byte[] data)
          Gets interface information for given interface and stores it in byte array.
static java.lang.String getIPAddress()
          Gets the IP address of the default interface as a String.
static void getIPAddress(byte[] address)
          Gets the IP address of the default interface.
static java.lang.String getIPAddress(java.lang.String interfaceName)
          Gets the IP address of the specified interface as a String.
static void getIPAddress(java.lang.String interfaceName, byte[] address)
          Gets the IP address of the specified interface.
static java.lang.String getMailhost()
          Gets the IP address of the default mailhost.
static int getNetworkCommitState()
          Returns the commit state as UNCOMMITED, COMMITTED or RESTORE_DISABLED
static java.lang.String getPrimaryDNS()
          Gets the primary DNS server address.
static int getProxyPort()
          Gets the proxy server port number.
static java.lang.String getProxyServer()
          Gets the IP address of the proxy server.
static java.lang.String getSecondaryDNS()
          Gets the secondary DNS server address.
static java.lang.String getSubnetMask()
          Gets the subnet mask of the default interface as a String.
static void getSubnetMask(byte[] address)
          Gets the subnet mask of the default interface.
static java.lang.String getSubnetMask(java.lang.String interfaceName)
          Gets the subnet mask of the specified interface as a String.
static void getSubnetMask(java.lang.String interfaceName, byte[] address)
          Gets the subnet mask of the specified interface.
static void removeInterfaceEntry(byte[] name)
          Removes specified interface from the network interface list.
static boolean setDefaultInterface(byte[] name)
          Sets the default network interface.
static boolean setDHCPServerIP(java.lang.String dhcpServer)
          Sets the IP address of the DHCP server to the given string.
static boolean setDNSTimeout(int dnsTimeout)
          Sets the DNS timeout in milliseconds.
static boolean setDomainname(java.lang.String domain)
          Sets the domain name to the given string.
static boolean setGatewayIP(byte[] gateway)
          Sets the gateway address for the default interface.
static boolean setGatewayIP(java.lang.String gateway)
          Sets the gateway IP for the default interface.
static boolean setGatewayIP(java.lang.String interfaceName, byte[] gateway)
          Sets the gateway IP address for the specified interface.
static boolean setGatewayIP(java.lang.String interfaceName, java.lang.String gateway)
          Sets the gateway IP for the specified interface.
static boolean setHostname(java.lang.String host)
          Sets the host name to the given string.
static boolean setIPAddress(byte[] localIP)
          Sets the IP address of the default interface.
static boolean setIPAddress(java.lang.String localIP)
          Sets the IP address of the default interface.
static boolean setIPAddress(java.lang.String interfaceName, byte[] localIP)
          Sets the IP address of the specified interface.
static boolean setIPAddress(java.lang.String interfaceName, java.lang.String localIP)
          Sets the IP address of the specified interface.
static boolean setMailhost(java.lang.String mailhost)
          Sets the mail host to the given IP address.
static boolean setOptions(byte[] dhcp, byte[] ip, byte[] gateway, byte[] subnet, byte[] dns1, byte[] dns2, byte[] domain, byte[] mailhost)
          Sets multiple network configuration settings.
static boolean setPrimaryDNS(java.lang.String primaryDNS)
          Sets the primary DNS IP address to the given string.
static boolean setProxyPort(int proxyPort)
          Sets the proxy port.
static boolean setProxyServer(java.lang.String proxyServer)
          Sets the proxy server IP address
static boolean setSecondaryDNS(java.lang.String secondDNS)
          Sets the secondary DNS IP address to the given string.
static boolean setSubnetMask(byte[] subnetMask)
          Sets the subnet mask of the default interface.
static boolean setSubnetMask(java.lang.String subnetMask)
          Sets the subnet mask of the default interface.
static boolean setSubnetMask(java.lang.String interfaceName, byte[] subnetMask)
          Sets the subnet mask of the specified interface.
static boolean setSubnetMask(java.lang.String interfaceName, java.lang.String subnetMask)
          Sets the subnet mask of the specified interface.
static void update()
          Forces a reload of network settings from the configuration file /etc/.tininet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNCOMMITTED

public static final int UNCOMMITTED
Network configuration is not committed to flash memory.

COMMITTED

public static final int COMMITTED
Network configuration is committed to flash memory.

RESTORE_DISABLED

public static final int RESTORE_DISABLED
Network configuration restore is disabled.
Constructor Detail

TININet

public TININet()
Method Detail

update

public static void update()
Forces a reload of network settings from the configuration file /etc/.tininet

getHostname

public static java.lang.String getHostname()
Gets the hostname of TINI.
Returns:
TINI hostname

getDomainname

public static java.lang.String getDomainname()
Gets the domain name of TINI.
Returns:
TINI domain name

getPrimaryDNS

public static java.lang.String getPrimaryDNS()
Gets the primary DNS server address.
Returns:
primary DNS server address, if the address has not been set an empty string is returned

getSecondaryDNS

public static java.lang.String getSecondaryDNS()
Gets the secondary DNS server address.
Returns:
secondary DNS server address, if the address has not been set an empty string is returned

getMailhost

public static java.lang.String getMailhost()
Gets the IP address of the default mailhost.
Returns:
IP address of the default mailhost, if the address has not been set an empty string is returned

getDNSTimeout

public static int getDNSTimeout()
Gets the timeout value for DNS queries.
Returns:
timeout in milliseconds

getDHCPServerIP

public static void getDHCPServerIP(byte[] address)
Gets the IP address of the DHCP server.
Parameters:
address - byte array of length four to be filled with the IP DHCP server address, most significant byte of address is stored at index zero

getDHCPServerIP

public static java.lang.String getDHCPServerIP()
Gets the IP address of DHCP server.
Returns:
IP address of the dhcp server in dotted decimal notation, if the address has not been set an empty string is returned

getIPAddress

public static void getIPAddress(java.lang.String interfaceName,
                                byte[] address)
Gets the IP address of the specified interface. Currently loopback (lo), ethernet (eth0) and ppp are currently supported.
Parameters:
interfaceName - network interface (lo, eth0 or pppn)
address - byte array of length four to be filled in with the IP address, most significant byte of address is stored at index zero

getIPAddress

public static java.lang.String getIPAddress(java.lang.String interfaceName)
Gets the IP address of the specified interface as a String. Currently loopback (lo), ethernet (eth) and ppp are supported
Parameters:
interfaceName - network interface (lo, eth or ppp)
Returns:
the IP address of the named interface, if the address has not been set an empty string is returned

getIPAddress

public static java.lang.String getIPAddress()
Gets the IP address of the default interface as a String.
Returns:
the IP address in dotted decimal notation, if the address has not been set an empty string is returned

getIPAddress

public static void getIPAddress(byte[] address)
Gets the IP address of the default interface.
Parameters:
address - byte array of length four to be filled with the IP address, most significant byte of address is stored at index zero

getGatewayIP

public static void getGatewayIP(byte[] address)
Gets the gateway IP address of the default interface.
Parameters:
address - byte array of length four to be filled with the IP address, most significant byte of address is stored at index zero

getGatewayIP

public static java.lang.String getGatewayIP()
Gets the gateway IP address of the default interface as a String.
Returns:
ip address of the gateway in dotted decimal notation, if the address has not been set an empty string is returned

getGatewayIP

public static void getGatewayIP(java.lang.String interfaceName,
                                byte[] address)
Gets the IP address of the gateway for the specified interface.
Parameters:
interfaceName - network interface (lo, eth or ppp)
address - byte array of length four to be filled with the IP address, most significant byte of address is stored at index zero

getGatewayIP

public static java.lang.String getGatewayIP(java.lang.String interfaceName)
Gets the IP address of the gateway for the specified interface as a string in dotted decimal notation.
Returns:
IP address of the gateway in dotted decimal notation, if the address has not been set an empty string is returned

getSubnetMask

public static void getSubnetMask(byte[] address)
Gets the subnet mask of the default interface.
Parameters:
address - byte array of length four to be filled with the subnet mask, most significant byte of mask is stored at index zero

getSubnetMask

public static java.lang.String getSubnetMask()
Gets the subnet mask of the default interface as a String.
Returns:
the subnet mask in dotted decimal notation, if the address has not been set an empty string is returned

getSubnetMask

public static void getSubnetMask(java.lang.String interfaceName,
                                 byte[] address)
Gets the subnet mask of the specified interface.
Parameters:
interfaceName - network interface (lo, eth or ppp)
address - byte array of length four to be filled with the subnet mask, most significant byte of mask is stored at index zero

getSubnetMask

public static java.lang.String getSubnetMask(java.lang.String interfaceName)
Gets the subnet mask of the specified interface as a String.
Returns:
the subnet mask in dotted decimal notation, if the address has not been set an empty string is returned

getEthernetAddress

public static void getEthernetAddress(byte[] address)
Gets the ethernet MAC address into the given byte array, with the most significant byte first.
Parameters:
address - byte array of length six to be filled with the ethernet address

getEthernetAddress

public static java.lang.String getEthernetAddress()
Gets the ethernet MAC address in dotted decimal notation.
Returns:
the ethernet address in dotted decimal notation, if the address has not been set an empty string is returned

getProxyServer

public static java.lang.String getProxyServer()
Gets the IP address of the proxy server.
Returns:
the IP address of the proxy server in dotted decimal notation, if the address has not been set an empty string is returned

getProxyPort

public static int getProxyPort()
Gets the proxy server port number.
Returns:
the proxy port number

setHostname

public static boolean setHostname(java.lang.String host)
Sets the host name to the given string.
Parameters:
host - hostname
Returns:
true if successful

setDomainname

public static boolean setDomainname(java.lang.String domain)
Sets the domain name to the given string.
Parameters:
domain - domain name to be set
Returns:
true if successful

setPrimaryDNS

public static boolean setPrimaryDNS(java.lang.String primaryDNS)
Sets the primary DNS IP address to the given string.
Parameters:
primaryDNS - primary DNS IP address in dotted decimal notation
Returns:
true if successful

setSecondaryDNS

public static boolean setSecondaryDNS(java.lang.String secondDNS)
Sets the secondary DNS IP address to the given string.
Parameters:
secondDNS - secondary DNS IP address in dotted decimal notation
Returns:
true if successful

setMailhost

public static boolean setMailhost(java.lang.String mailhost)
Sets the mail host to the given IP address.
Parameters:
mailhost - IP address of the mail host in dotted decimal notation
Returns:
true on success

setDNSTimeout

public static boolean setDNSTimeout(int dnsTimeout)
Sets the DNS timeout in milliseconds. If the timeout value is set to zero, a fallback and retry procedure will take effect. The DNS client will retry starting at 2 seconds and doubling until reaching 16 seconds. The DNS resolver will try four times in this period to resolve the name. * 2s * 4s * 8s * 16s
Parameters:
dnsTimeout - timeout value in milliseconds, zero for fallback and retry
Returns:
true on success

setDHCPServerIP

public static boolean setDHCPServerIP(java.lang.String dhcpServer)
Sets the IP address of the DHCP server to the given string.
Parameters:
dhcpServer - DHCP server IP address in dotted decimal notation
Returns:
true on success

setIPAddress

public static boolean setIPAddress(byte[] localIP)
Sets the IP address of the default interface.
Parameters:
localIP - IP address, MSB of address is index zero
Returns:
true on success

setIPAddress

public static boolean setIPAddress(java.lang.String localIP)
Sets the IP address of the default interface.
Parameters:
localIP - IP address in dotted decimal notation
Returns:
true on success

setIPAddress

public static boolean setIPAddress(java.lang.String interfaceName,
                                   byte[] localIP)
Sets the IP address of the specified interface.
Parameters:
interfaceName - network interface name
localIP - IP address, MSB of address is index zero
Returns:
true on success

setIPAddress

public static boolean setIPAddress(java.lang.String interfaceName,
                                   java.lang.String localIP)
Sets the IP address of the specified interface.
Parameters:
interfaceName - network interface name
localIP - IP address in dotted decimal notation
Returns:
true on success

setGatewayIP

public static boolean setGatewayIP(byte[] gateway)
Sets the gateway address for the default interface.
Parameters:
gateway - IP address of the gateway, MSB of address is index zero
Returns:
true on success

setGatewayIP

public static boolean setGatewayIP(java.lang.String gateway)
Sets the gateway IP for the default interface.
Parameters:
gateway - IP address of the gateway in dotted decimal notation
Returns:
true on success

setGatewayIP

public static boolean setGatewayIP(java.lang.String interfaceName,
                                   byte[] gateway)
Sets the gateway IP address for the specified interface.
Parameters:
interfaceName - network interface name
gateway - ip address of the gateway, MSB of address is index zero
Returns:
true on success

setGatewayIP

public static boolean setGatewayIP(java.lang.String interfaceName,
                                   java.lang.String gateway)
Sets the gateway IP for the specified interface.
Parameters:
interfaceName - network interface name
gateway - IP address of the gateway in dotted decimal notation
Returns:
true on success

setSubnetMask

public static boolean setSubnetMask(byte[] subnetMask)
Sets the subnet mask of the default interface.
Parameters:
subnetMask - subnet mask, MSB of mask is at index zero
Returns:
true on success

setSubnetMask

public static boolean setSubnetMask(java.lang.String subnetMask)
Sets the subnet mask of the default interface.
Parameters:
subnetMask - subnet mask in dotted decimal notation
Returns:
true on success

setSubnetMask

public static boolean setSubnetMask(java.lang.String interfaceName,
                                    byte[] subnetMask)
Sets the subnet mask of the specified interface.
Parameters:
interfaceName - network interface name
subnetMask - subnet mask, MSB of mask is at index zero
Returns:
true on success

setSubnetMask

public static boolean setSubnetMask(java.lang.String interfaceName,
                                    java.lang.String subnetMask)
Sets the subnet mask of the specified interface.
Parameters:
interfaceName - network interface name
subnetMask - subnet mask in dotted decimal notation
Returns:
true on success

setProxyServer

public static boolean setProxyServer(java.lang.String proxyServer)
Sets the proxy server IP address
Parameters:
proxyServer - IP address of the proxy server, MSB of address is at index zero
Returns:
true on success

setProxyPort

public static boolean setProxyPort(int proxyPort)
Sets the proxy port.
Parameters:
proxyPort - the port number to be used for proxy
Returns:
true on success

setOptions

public static boolean setOptions(byte[] dhcp,
                                 byte[] ip,
                                 byte[] gateway,
                                 byte[] subnet,
                                 byte[] dns1,
                                 byte[] dns2,
                                 byte[] domain,
                                 byte[] mailhost)
Sets multiple network configuration settings.
Parameters:
dhcp - IP address of the DHCP server, MSB of address is at index zero
ip - IP address of the local machine, MSB of address is at index zero
gateway - IP address of gateway address, MSB of address is at index zero
subnet - subnet mask, MSB of address is at index zero
dns1 - IP address of the primary DNS server, MSB of address is at index zero
dns2 - IP address of the secondary DNS server, MSB of address is at index zero
domain - domain name stored as a byte array
mailhost - IP address of the outgoing mail server, MSB of address is at index zero
Returns:
true on success

getConnectionTable

public static byte[] getConnectionTable()
Gets the current connection table.
Returns:
byte array containing the connection table

getARPCacheTable

public static byte[] getARPCacheTable()
Gets the current ARP cache table.
Returns:
byte array containing the ARP cache table

commitNetworkState

public static void commitNetworkState()
                               throws CommitException
Commits the current network configuration to flash.
Throws:
CommitException - if state has already been committed.

getNetworkCommitState

public static int getNetworkCommitState()
Returns the commit state as UNCOMMITED, COMMITTED or RESTORE_DISABLED
Returns:
the current commit state

disableNetworkRestore

public static void disableNetworkRestore()
Disables the ability to commit or restore network configuration until the bank 7 application is re-flashed.

setDefaultInterface

public static boolean setDefaultInterface(byte[] name)
Sets the default network interface.
Parameters:
name - network interface, lo (loopback), eth (ethernet) or ppp
Returns:
true if inteface was successfully set as the default

getInterfaceInfo

public static boolean getInterfaceInfo(int interfaceNum,
                                       byte[] data)
Gets interface information for given interface and stores it in byte array. Returns true if information was found using supplied interface number.
Parameters:
interfaceNum - network interface number
data - buffer for interface info
Returns:
true if interface info was found

addInterfaceEntry

public static void addInterfaceEntry(byte[] name,
                                     byte[] ipAddr,
                                     byte[] subnet,
                                     byte[] gateway,
                                     byte flags,
                                     byte type,
                                     int transmitter)
Adds an interface to the network interface list with the given parameters.
Parameters:
name - network interface lo(loopback), eth(ethernet) or ppp
ipAddr - IP address of the new interface
subnet - subnet mask of the new interface
gateway - gateway IP address of the new interface
flags - network configuration flags mapped as follows:
      flags.0 = used - should always be set
      flags.1 = active - should be set if the interface is to be active
      flags.2 = default - set if this should be the default network interface
      flags.3 = UNUSED - must be cleared
      flags.4 = routable - set if interface is to carry routable packets
      flags.5 = multicasting enabled - set if interface supports multicast
      flags.6 = UNUSED - must be cleared
type - type of network interface ethernet = 1, ppp = 2, loopback = 3
transmitter - 24 bit transmitter routine address represented as a 32-bit int

removeInterfaceEntry

public static void removeInterfaceEntry(byte[] name)
Removes specified interface from the network interface list.
Parameters:
name - network interface name to remove


Используются технологии uCoz