OpenNMS API 1.2.9

## org.opennms.netmgt.dhcpd
Class Poller

    java.lang.Object
      org.opennms.netmgt.dhcpd.Poller

final class Poller
extends java.lang.Object

Establishes a TCP socket connection with the DHCP daemon and formats and sends request messages.

Version:
  CVS 1.1.1.1
Author:
  Mike , OpenNMS

Field Summary
`(package private) static short` `BROADCAST_FLAG` Broadcast flag...when set in the 'flags' portion of the DHCP query packet, it forces the DHCP server to broadcast the DHCP response.
`private static byte[]` `DEFAULT_MAC_ADDRESS` The hardware address (ex: 00:06:0D:BE:9C:B2)
`(package private) static int` `DEFAULT_RETRIES` Default retries
`(package private) static long` `DEFAULT_TIMEOUT` Default timeout
`private java.net.Socket` `m_connection` TCP Socket connection with DHCP Daemon
`private java.io.ObjectInputStream` `m_ins` Objects from the server.
`private static int` `m_nextXid` Holds the value for the next identifier sent to the DHCP server.
`private java.io.ObjectOutputStream` `m_outs` Output Object stream
`private static int` `MESSAGE_TYPE` The message type option for the DHCP request.
`private static boolean` `paramsChecked`
`private static boolean` `relayMode`
`private static boolean` `reqTargetIp`
`private static int` `REQUESTED_IP` The requested ip option for the DHCP request.
`private static java.lang.String` `s_extendedMode`
`private static byte[]` `s_hwAddress`
`private static byte[]` `s_myIpAddress`
`private static byte[]` `s_requestIpAddress`
`private static boolean` `targetOffset`

Constructor Summary
`private` `Poller(long timeout)` Constructor.

Method Summary
`void` `close()` Closes the client's socket connection to the DHCP daemon.
`protected void` `finalize()` Ensures that during garbage collection the resources used by this object are released!
`private static Message` `getDisconnectRequest()` Returns a disconnection request message that can be sent to the server.
`private static Message` `getPollingRequest(java.net.InetAddress addr, byte mType)` Returns a DHCP DISCOVER, INFORM, or REQUEST message that can be sent to the DHCP server.
`(package private) static long` `isServer(java.net.InetAddress host, long timeout, int retries)` This method actually tests the remote host to determine if it is running a functional DHCP server.
`private static void` `setHwAddress(java.lang.String hwAddressStr)`
`private static byte[]` `setIpAddress(java.lang.String ipAddressStr)`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT_MAC_ADDRESS

    private static final byte[] DEFAULT_MAC_ADDRESS

  The hardware address (ex: 00:06:0D:BE:9C:B2)

### s_hwAddress

    private static byte[] s_hwAddress

### s_myIpAddress

    private static byte[] s_myIpAddress

### s_extendedMode

    private static java.lang.String s_extendedMode

### s_requestIpAddress

    private static byte[] s_requestIpAddress

### reqTargetIp

    private static boolean reqTargetIp

### targetOffset

    private static boolean targetOffset

### relayMode

    private static boolean relayMode

### paramsChecked

    private static boolean paramsChecked

### BROADCAST_FLAG

    static final short BROADCAST_FLAG

  Broadcast flag...when set in the 'flags' portion of the DHCP query packet, it forces the DHCP server to broadcast the DHCP response. This is useful when we are not setting the relay address in the outgoing DHCP query. Otherwise, we would not receive the response.

  See Also:
    Constant Field Values

### DEFAULT_RETRIES

    static final int DEFAULT_RETRIES

  Default retries

  See Also:
    Constant Field Values

### DEFAULT_TIMEOUT

    static final long DEFAULT_TIMEOUT

  Default timeout

  See Also:
    Constant Field Values

### MESSAGE_TYPE

    private static final int MESSAGE_TYPE

  The message type option for the DHCP request.

  See Also:
    Constant Field Values

### REQUESTED_IP

    private static final int REQUESTED_IP

  The requested ip option for the DHCP request.

  See Also:
    Constant Field Values

### m_nextXid

    private static int m_nextXid

  Holds the value for the next identifier sent to the DHCP server.

### m_connection

    private java.net.Socket m_connection

  TCP Socket connection with DHCP Daemon

### m_outs

    private java.io.ObjectOutputStream m_outs

  Output Object stream

### m_ins

    private java.io.ObjectInputStream m_ins

  Objects from the server.

Constructor Detail

### Poller

    private Poller(long timeout)
            throws java.io.IOException

  Constructor. Establishes a TCP socket conection with the DHCP client daemon on port 5818.

Throws:
  `java.io.IOException` - if unable to establish the connection with the DHCP client daemon.

Method Detail

### getDisconnectRequest

    private static Message getDisconnectRequest()
                                         throws java.net.UnknownHostException

  Returns a disconnection request message that can be sent to the server.

  Returns:
    A disconnection message.
  Throws:
    `java.net.UnknownHostException`

### getPollingRequest

    private static Message getPollingRequest(java.net.InetAddress addr,
                                             byte mType)

  Returns a DHCP DISCOVER, INFORM, or REQUEST message that can be sent to the DHCP server. DHCP server should respond with a DHCP OFFER, ACK, or NAK message in response..

  Returns:
    The message to send to the DHCP server.

### finalize

    protected void finalize()
                     throws java.lang.Throwable

  Ensures that during garbage collection the resources used by this object are released!

  Throws:
    `java.lang.Throwable`

### close

    public void close()

  Closes the client's socket connection to the DHCP daemon.

  Throws:
    `java.io.IOException` - if the socket close() method fails.

### isServer

    static long isServer(java.net.InetAddress host,
                         long timeout,
                         int retries)
                  throws java.io.IOException

  This method actually tests the remote host to determine if it is running a functional DHCP server.

  Formats a DHCP query and encodes it in a client request message which is sent to the DHCP daemon over the established TCP socket connection. If a matching DHCP response packet is not received from the DHCP daemon within the specified timeout the client request message will be re-sent up to the specified number of retries.

  If a response is received from the DHCP daemon it is validated to ensure that:

  - The DHCP response packet was sent from the remote host to which the original request packet was directed.
  - The XID of the DHCP response packet matches the XID of the original DHCP request packet.

  If the response validates 'true' is returned. Otherwise the request is resent until max retry count is exceeded.

  Before returning, a client disconnect message (remote host field set to zero) is sent to the DHCP daemon.

  Returns:
    response time in milliseconds if the specified host responded with a valid DHCP offer datagram within the context of the specified timeout and retry values or negative one (-1) otherwise.
  Throws:
    `java.io.IOException`

### setHwAddress

    private static void setHwAddress(java.lang.String hwAddressStr)

### setIpAddress

    private static byte[] setIpAddress(java.lang.String ipAddressStr)

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.