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.
PAUSE_PENDING, PAUSED, RESUME_PENDING
RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED
Modifier and Type | Method and Description |
---|---|
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()
onInit
|
protected void |
onStart()
onStart
|
protected void |
onStop()
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.
|
afterPropertiesSet, destroy, getName, getStatus, getStatusText, init, isPaused, isRunning, isStarting, onPause, onResume, pause, resume, setStatus, start, status, stop, waitForStatus, waitForStatus
protected void onStart()
onStart
onStart
in class AbstractServiceDaemon
protected void onStop()
onStop
onStop
in class AbstractServiceDaemon
public void run()
public void update(Observable inst, Object ignored)
public static Dhcpd getInstance()
Dhcpd
object.public static long isServer(InetAddress address, long timeout, int retries) throws IOException
address
- The address to query.timeout
- The time to wait between retries.retries
- The maximum number of attempts.IOException
- Thrown if an error occurs.public static long isServer(InetAddress address) throws IOException
address
- The address to query.IOException
- Thrown if an error occurs.protected void onInit()
onInit
onInit
in class AbstractServiceDaemon
Copyright © 2019. All rights reserved.