OpenNMS API 1.2.3

org.opennms.netmgt.dhcpd
Class Dhcpd

java.lang.Object
  extended byorg.opennms.netmgt.dhcpd.Dhcpd
All Implemented Interfaces:
Fiber, java.util.Observer, PausableFiber, java.lang.Runnable

public final class Dhcpd
extends java.lang.Object
implements PausableFiber, java.lang.Runnable, java.util.Observer

The DHCP client daemon serves as a multiplexor for DHCP requests and responses. The Bootp/DHCP protocol specifies that a DHCP server listens for requests on local UDP/67 and will either send/broadcast responses to UDP/68 or UDP/67 or will unicast responses back to the client's UDP port on from which the request originated.

The DHCP daemon accepts client connections on TCP/5818. Once a client is connected it can begin forwarding requests. A list of all currently connected clients is maintained. Requests have the following format:

The client indicates that it is finished by sending a request with the remote host IP address set to zero (0).

Incoming requests are sent to UDP/67 on specified remote host. If the remote host is runnning a DHCP server it will send/broadcast an appropriate response to UDP/68 or UDP/67 (or will unicast the response).

The DHCP daemon includes a listener thread which binds to UDP/68 or UDP/67 and simply listens for any incoming DHCP responses. In extended mode, threads are started on both ports. When a datagram is received by the listener thread(s) it loops through the list of currently connected clients and forwards the DHCP response packet to each client. It is the responsibility of the client to validate that the datagram is in response to a DHCP request packet that it generated.

Author:
Mike , OpenNMS

Field Summary
private static java.lang.String LOG4J_CATEGORY
          Log4J prefix
private static java.util.List m_clients
          List of clients currently connected to the DHCP daemon
private  Receiver m_listener
          DHCP response port 67 listener.
private  Receiver2 m_listener2
          DHCP response port 68 listener.
private  java.net.ServerSocket m_server
          Socket over which the daemon actively listens for new client connection requests.
private static Dhcpd m_singleton
          The singular instance of the DHCP server.
private  int m_status
          The current status of the fiber.
private  java.lang.Thread m_worker
          The working thread
 
Fields inherited from interface org.opennms.core.fiber.PausableFiber
PAUSE_PENDING, PAUSED, RESUME_PENDING
 
Fields inherited from interface org.opennms.core.fiber.Fiber
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED
 
Constructor Summary
private Dhcpd()
          Constructs a new DHCP server instance.
 
Method Summary
static Dhcpd getInstance()
          Returns the singular instance of the DHCP server.
 java.lang.String getName()
          Returns the current name of the fiber.
 int getStatus()
          Returns the current status of the fiber.
static long isServer(java.net.InetAddress address)
          Contacts the public server and checks to see if the the passed address is a DHCP server.
static long isServer(java.net.InetAddress address, long timeout, int retries)
          Contacts the public server and checks to see if the the passed address is a DHCP server.
 void pause()
          Pauses Dhcpd
 void resume()
          Resumes Trapd
 void run()
          The main routine of the DHCP server.
 void start()
          Starts the server instance.
 void stop()
          Stops the currently running instance of the DHCP server.
 void update(java.util.Observable inst, java.lang.Object ignored)
          This method is called by the observable instances that the server has registered to receive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG4J_CATEGORY

private static final java.lang.String LOG4J_CATEGORY
Log4J prefix

See Also:
Constant Field Values

m_singleton

private static final Dhcpd m_singleton
The singular instance of the DHCP server.


m_clients

private static java.util.List m_clients
List of clients currently connected to the DHCP daemon


m_server

private java.net.ServerSocket m_server
Socket over which the daemon actively listens for new client connection requests.


m_listener

private Receiver m_listener
DHCP response port 67 listener.


m_listener2

private Receiver2 m_listener2
DHCP response port 68 listener.


m_status

private int m_status
The current status of the fiber.


m_worker

private java.lang.Thread m_worker
The working thread

Constructor Detail

Dhcpd

private Dhcpd()
Constructs a new DHCP server instance. All of the internal fields are initialized to null.

Method Detail

start

public void start()
Starts the server instance. If the server is running then an exception is thrown. Also, since the opening of sockets and other resources are delayed until this method is invoked, standard exceptions are rethrown as an throwable.

Specified by:
start in interface Fiber
Throws:
java.lang.IllegalStateException - Thrown if the server is already running.
java.lang.reflect.UndeclaredThrowableException - Thrown if a non-runtime exception is genereated during startup.

stop

public void stop()
Stops the currently running instance of the DHCP server. If the server is not running, then this command is silently discarded.

Specified by:
stop in interface Fiber

getStatus

public int getStatus()
Returns the current status of the fiber.

Specified by:
getStatus in interface Fiber
Returns:
The current status of the Fiber.

getName

public java.lang.String getName()
Returns the current name of the fiber.

Specified by:
getName in interface Fiber
Returns:
The name of the Fiber.

pause

public void pause()
Pauses Dhcpd

Specified by:
pause in interface PausableFiber

resume

public void resume()
Resumes Trapd

Specified by:
resume in interface PausableFiber

run

public void run()
The main routine of the DHCP server. This method accepts incomming client requests and starts new client handlers to process each request.

Specified by:
run in interface java.lang.Runnable

update

public void update(java.util.Observable inst,
                   java.lang.Object ignored)
This method is called by the observable instances that the server has registered to receive.

Specified by:
update in interface java.util.Observer
Parameters:
inst - The observable object that has changed.
ignored - Thsi parameter is ignored by this method.

getInstance

public static Dhcpd getInstance()
Returns the singular instance of the DHCP server.


isServer

public static long isServer(java.net.InetAddress address,
                            long timeout,
                            int retries)
                     throws java.io.IOException
Contacts the public server and checks to see if the the passed address is a DHCP server.

Parameters:
address - The address to query.
timeout - The time to wait between retries.
retries - The maximum number of attempts.
Returns:
response time in milliseconds if remote box is a DHCP server or -1 if it is NOT.
Throws:
java.io.IOException - Thrown if an error occurs.

isServer

public static long isServer(java.net.InetAddress address)
                     throws java.io.IOException
Contacts the public server and checks to see if the the passed address is a DHCP server.

Parameters:
address - The address to query.
Returns:
response time in milliseconds if remote box is a DHCP server or -1 if it is NOT.
Throws:
java.io.IOException - Thrown if an error occurs.

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.