tuwien.auto.eicl.struct.eibnetip.util
Class HPAI
java.lang.Object
tuwien.auto.eicl.struct.eibnetip.util.HPAI
public class HPAI
extends java.lang.Object
This class is the implementation of the EIBnet/IP Host Protocol Address
Information (HPAI) structure. HPAI is used to describe a server/client end
point. Its structure varies according to the used underlying protocol. This
class is implemented for IPv4.
HPAI(byte[] _Data) - Creates an HPAI instance from its byte array representation.
|
HPAI(int _PortNumber) - Creates a new HPAI object for the local host.
|
byte[] | getAddress() - Returns the IP network address in byte format (big endian).
|
String | getAddressString() - Offers the IP network address in dot notation as string.
|
String | getDescription() - Offers a human readable host description consisting of IP address and
port
|
static InetAddress | getLocalIP() - Allows to retrieve the IP address that is used for the local host.
|
int | getPort() - Returns the port as integer
|
InetSocketAddress | getSocketAddress() - Returns the IP address and port number as an InetSocketAddress object.
|
short | getStructLength() - Retrieves the structure size.
|
static void | setLocalIP(InetAddress ia) - Allows to set the IP address to be used for the local host.
|
byte[] | toByteArray() - Converts the HPAI to its byte array representation.
|
HPAI
public HPAI(byte[] _Data)
throws EICLException
Creates an HPAI instance from its byte array representation.
_Data
- The HPAI as byte array.
EICLException
- If the host protocol in the parsed structure is another than
IPv4.
HPAI
public HPAI(int _PortNumber)
throws EICLException
Creates a new HPAI object for the local host. The IP address is
determined automatically. Since there does not seem to be a way to access
routing information in a portable manner, the automatic detection fails
when more than one network interface is installed on the local host. In
this case, one of them is chosen at random. The result of the
autodetection process can be retrieved at any time via getLocalIP() and
can be overridden using the setLocalIP(InetAddress) method.
_PortNumber
- the local port to be used in the HPAI
getAddress
public byte[] getAddress()
Returns the IP network address in byte format (big endian).
getAddressString
public String getAddressString()
Offers the IP network address in dot notation as string.
- The IPv4 addresss as string
getDescription
public String getDescription()
Offers a human readable host description consisting of IP address and
port
- A human readable host description.
getLocalIP
public static InetAddress getLocalIP()
Allows to retrieve the IP address that is used for the local host.
- The IP address used by the HPAI(int) constructor.
getPort
public int getPort()
Returns the port as integer
- The port contained in HPAI
getSocketAddress
public InetSocketAddress getSocketAddress()
Returns the IP address and port number as an InetSocketAddress object.
- The hostdescription as InetSocketaAddress
getStructLength
public short getStructLength()
Retrieves the structure size.
setLocalIP
public static void setLocalIP(InetAddress ia)
Allows to set the IP address to be used for the local host. This is only
necessary when the address is not correctly detected automatically.
ia
- The IP address to be used by the HPAI(int) constructor.
toByteArray
public byte[] toByteArray()
throws EICLException
Converts the HPAI to its byte array representation.
- the byte array representation of the HPAI