|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
com.dalsemi.tininet.dhcp.DHCPClient
The DHCPClient supports dynamically obtaining a new IP Address or reclaiming an IP Address lost on reboot from a DHCP server. Both constructors are passed a DHCPListener so that DHCP status messages can be relayed. After the DHCPClient object is constructed, the process in invoked through the start() method. When the user no longer needs the IP Address it is recommended that the stopDHCP method is called to release the IP to the server and close the socket.
Refer to the following RFCs:
951 - BOOTSTRAP PROTOCOL (BOOTP)
1048 - BOOTP Vendor Information Extensions
2131 - Dynamic Host Configuration Protocol
2132 - DHCP Options and BOOTP Vendor Extensions
RFC repository: http://www.ietf.org/rfc.html
| Field Summary | |
static int |
LEASE_INFINITE
|
| Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
DHCPClient(DHCPListener DL)
Constructs a DHCP object and intializes for obtaining a new IP. |
|
DHCPClient(DHCPListener DL,
byte[] serverIP,
byte[] localIP)
Constructs a DHCP object and intializes to attempt to rebind to a previously owned IP that was lost in a reboot. |
|
| Method Summary | |
void |
addDHCPListener(DHCPListener newListener)
Adds listener for accepting DHCP status messages. |
long |
getLeaseTimeout()
This method returns the DHCP lease expiration timeout. |
void |
parseOption(byte[] recvdata,
int position)
This method is called at least once for every DHCP packet received from the DHCP server; it is also called for every DHCP option not handled by the DHCPClient code. |
void |
removeDHCPListener(DHCPListener thisListener)
Removes listener, to discontinue acceptance of status messages. |
void |
run()
Starts DHCP thread. |
void |
stopDHCPThread()
Stops DHCP thread, releases IP, and closes any open sockets. |
| Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int LEASE_INFINITE
| Constructor Detail |
public DHCPClient(DHCPListener DL)
throws java.lang.IllegalStateException
DL - DHCPListener to report DHCP status messages
java.lang.IllegalStateException - if DHCP is already running.
public DHCPClient(DHCPListener DL,
byte[] serverIP,
byte[] localIP)
throws java.lang.IllegalStateException
DL - DHCPListenerserverIP - IP of DHCP server where previous IP was obtainedlocalIP - IP to obtain
java.lang.IllegalStateException - if DHCP is already running.| Method Detail |
public void run()
public void stopDHCPThread()
public void parseOption(byte[] recvdata,
int position)
DHCPClient code.
A subclass could override this method to implement its own
option handling.
recvdata - byte array - the complete packet received from the
DHCP server.position - position of the current option inside the
recvdata[] array.public void addDHCPListener(DHCPListener newListener)
newListener - DHCPListener for accepting status messagespublic void removeDHCPListener(DHCPListener thisListener)
thisListener - DHCPListener to be removed from listpublic long getLeaseTimeout()
System.currentTimeMillis()/1000 from this
value to get the remainder of the DHCP lease life in seconds.
Note: The value LEASE_INFINITE means "infinite lease".
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||