org.opennms.netmgt.dhcpd
Class Dhcpd

java.lang.Object
  extended by org.opennms.netmgt.daemon.AbstractServiceDaemon
      extended by org.opennms.netmgt.dhcpd.Dhcpd
All Implemented Interfaces:
Runnable, Observer, Fiber, PausableFiber, SpringServiceDaemon, ServiceDaemon, org.springframework.beans.factory.InitializingBean

public final class Dhcpd
extends AbstractServiceDaemon
implements Runnable, 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
 
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
 
Method Summary
static Dhcpd getInstance()
          Returns the singular instance of the DHCP server.
static long isServer(InetAddress address)
          Contacts the public server and checks to see if the the passed address is a DHCP server.
static long isServer(InetAddress address, long timeout, int retries)
          Contacts the public server and checks to see if the the passed address is a DHCP server.
protected  void onInit()
           
protected  void onStart()
           
protected  void onStop()
           
 void run()
          The main routine of the DHCP server.
 void update(Observable inst, Object ignored)
          This method is called by the observable instances that the server has registered to receive.
 
Methods inherited from class org.opennms.netmgt.daemon.AbstractServiceDaemon
afterPropertiesSet, debugf, debugf, errorf, errorf, fatalf, fatalf, getName, getStatus, getStatusText, infof, infof, init, isPaused, isRunning, isStarting, isStartPending, log, onPause, onResume, pause, resume, setStatus, start, status, stop, waitForStatus, waitForStatus, warnf, warnf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

onStart

protected void onStart()
Overrides:
onStart in class AbstractServiceDaemon

onStop

protected void onStop()
Overrides:
onStop in class AbstractServiceDaemon

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 Runnable

update

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

Specified by:
update in interface 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(InetAddress address,
                            long timeout,
                            int retries)
                     throws 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:
IOException - Thrown if an error occurs.

isServer

public static long isServer(InetAddress address)
                     throws 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:
IOException - Thrown if an error occurs.

onInit

protected void onInit()
Specified by:
onInit in class AbstractServiceDaemon


Copyright © 2009. All Rights Reserved.