com.dalsemi.tininet
Class AddressConf

java.lang.Object
  |
  +--com.dalsemi.tininet.AddressConf

public class AddressConf
extends java.lang.Object

This class implements auto detection of link local IP address, useful when there is no DHCP server and manual IP configuration is not desired.
To use this class, first try to acquire an IP using the DHCP client class. If after about 25 seconds no IP is leased, stop the DHCP client thread and use AddressConf.acquireLinkLocalIP().

              DHCPListener dhcpListener = new DhcpListener();
              DHCPClient dhcpClient = new DHCPClient(dhcpListener);
              synchronized (lock) {
                  dhcpClient.start();

                  try {
                      // This will wait until the dhcpListener notifies
                      // us that we now have an IP address.  If we don't
                      // get one after 30 sec. assume we'll never get
                      // one and try to get a link local address instead.
                      lock.wait(60000);
                  }
                  catch(InterruptedException ie) {}

                  if (!haveIPaddress) {
                      dhcpClient.stopDHCPThread();
                      if (!AddressConf.acquireLinkLocalIP()) {
                          // Couldn't get a dhcp address or a link local.
                          // We're hosed, reboot.
                          System.out.println("Unable to obtain Link Local Address.");
                          TINIOS.reboot();
                      }
                      System.out.println("Link Local address: " + TININet.getIPAddress());
                      haveIPaddress = true;
                  }
              }
 


Method Summary
static boolean acquireLinkLocalIP()
          Acquires a random link local address (169.254.x.x).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

acquireLinkLocalIP

public static boolean acquireLinkLocalIP()
Acquires a random link local address (169.254.x.x).
Returns:
true if successful


Also see:
o TINI 1.16 API
o TINI Home Page
o 1-Wire API

o JDK 1.1

Last update Wed Jun 8 17:19:36 CDT 2005