|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.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 ExtentionsRFC repository http://www.ietf.org/rfc.html
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 previous 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 each received DHCP packet; it is also called for all DHCP options that are not interpreted by the DHCPClient class. |
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 |
Constructor Detail |
public DHCPClient(DHCPListener DL) throws IllegalStateException
DL
- DHCPListener to report DHCP status messagespublic DHCPClient(DHCPListener DL, byte[] serverIP, byte[] localIP) throws IllegalStateException
DL
- DHCPListenerserverIP
- IP of DHCP server where previous IP was obtainedlocalIP
- IP to obtainMethod Detail |
public void run()
public void stopDHCPThread()
public void parseOption(byte[] recvdata, int position)
DHCPClient
class. A subclass
could override this method and implement its own option
handling.recvdata
- the byte array contains the complete packet
received from the DHCP server.position
- position of the option inside the byte 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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |