]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - net/bootp.c
Merge branch 'master' of git://git.denx.de/u-boot-mpc83xx
[karo-tx-uboot.git] / net / bootp.c
index 55dcc81db60d973df9141da3fc72daa2eb9198e9..34124b8fc2425d6fe70e3b5cd42ec159119670df 100644 (file)
@@ -8,17 +8,6 @@
  *     Copyright 2000-2004 Wolfgang Denk, wd@denx.de
  */
 
-#if 0
-#define DEBUG          1       /* general debug */
-#define DEBUG_BOOTP_EXT 1      /* Debug received vendor fields */
-#endif
-
-#ifdef DEBUG_BOOTP_EXT
-#define debug_ext(fmt,args...) printf (fmt ,##args)
-#else
-#define debug_ext(fmt,args...)
-#endif
-
 #include <common.h>
 #include <command.h>
 #include <net.h>
 #ifdef CONFIG_STATUS_LED
 #include <status_led.h>
 #endif
+#include <linux/compiler.h>
 
 #define BOOTP_VENDOR_MAGIC     0x63825363      /* RFC1048 Magic Cookie         */
 
-#if defined(CONFIG_CMD_NET)
-
-#define TIMEOUT                5               /* Seconds before trying BOOTP again    */
+#define TIMEOUT                5000UL  /* Milliseconds before trying BOOTP again */
 #ifndef CONFIG_NET_RETRY_COUNT
 # define TIMEOUT_COUNT 5               /* # of timeouts before giving up  */
 #else
@@ -57,7 +45,8 @@ ulong         seed1, seed2;
 dhcp_state_t dhcp_state = INIT;
 unsigned long dhcp_leasetime = 0;
 IPaddr_t NetDHCPServerIP = 0;
-static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len);
+static void DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
+                       unsigned len);
 
 /* For Debug */
 #if 0
@@ -107,7 +96,7 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
                retval = -6;
        }
 
-       debug ("Filtering pkt = %d\n", retval);
+       debug("Filtering pkt = %d\n", retval);
 
        return retval;
 }
@@ -117,19 +106,19 @@ static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
  */
 static void BootpCopyNetParams(Bootp_t *bp)
 {
-       IPaddr_t tmp_ip;
+       __maybe_unused IPaddr_t tmp_ip;
 
        NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
 #if !defined(CONFIG_BOOTP_SERVERIP)
        NetCopyIP(&tmp_ip, &bp->bp_siaddr);
        if (tmp_ip != 0)
                NetCopyIP(&NetServerIP, &bp->bp_siaddr);
-       memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6);
+       memcpy (NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6);
 #endif
        if (strlen(bp->bp_file) > 0)
                copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
 
-       debug ("Bootfile: %s\n", BootFile);
+       debug("Bootfile: %s\n", BootFile);
 
        /* Propagate to environment:
         * don't delete exising entry when BOOTP / DHCP reply does
@@ -156,28 +145,28 @@ static void BootpVendorFieldProcess (u8 * ext)
 {
        int size = *(ext + 1);
 
-       debug_ext ("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
+       debug("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
                   *(ext + 1));
 
        NetBootFileSize = 0;
 
        switch (*ext) {
                /* Fixed length fields */
-       case 1:                 /* Subnet mask                                  */
+       case 1:                 /* Subnet mask                                  */
                if (NetOurSubnetMask == 0)
                        NetCopyIP (&NetOurSubnetMask, (IPaddr_t *) (ext + 2));
                break;
-       case 2:                 /* Time offset - Not yet supported              */
+       case 2:                 /* Time offset - Not yet supported              */
                break;
                /* Variable length fields */
-       case 3:                 /* Gateways list                                */
+       case 3:                 /* Gateways list                                */
                if (NetOurGatewayIP == 0) {
                        NetCopyIP (&NetOurGatewayIP, (IPaddr_t *) (ext + 2));
                }
                break;
-       case 4:                 /* Time server - Not yet supported              */
+       case 4:                 /* Time server - Not yet supported              */
                break;
-       case 5:                 /* IEN-116 name server - Not yet supported      */
+       case 5:                 /* IEN-116 name server - Not yet supported      */
                break;
        case 6:
                if (NetOurDNSIP == 0) {
@@ -189,43 +178,43 @@ static void BootpVendorFieldProcess (u8 * ext)
                }
 #endif
                break;
-       case 7:                 /* Log server - Not yet supported               */
+       case 7:                 /* Log server - Not yet supported               */
                break;
-       case 8:                 /* Cookie/Quote server - Not yet supported      */
+       case 8:                 /* Cookie/Quote server - Not yet supported      */
                break;
-       case 9:                 /* LPR server - Not yet supported               */
+       case 9:                 /* LPR server - Not yet supported               */
                break;
-       case 10:                /* Impress server - Not yet supported           */
+       case 10:                /* Impress server - Not yet supported           */
                break;
-       case 11:                /* RPL server - Not yet supported               */
+       case 11:                /* RPL server - Not yet supported               */
                break;
-       case 12:                /* Host name                                    */
+       case 12:                /* Host name                                    */
                if (NetOurHostName[0] == 0) {
                        size = truncate_sz ("Host Name", sizeof (NetOurHostName), size);
                        memcpy (&NetOurHostName, ext + 2, size);
                        NetOurHostName[size] = 0;
                }
                break;
-       case 13:                /* Boot file size                               */
+       case 13:                /* Boot file size                               */
                if (size == 2)
                        NetBootFileSize = ntohs (*(ushort *) (ext + 2));
                else if (size == 4)
                        NetBootFileSize = ntohl (*(ulong *) (ext + 2));
                break;
-       case 14:                /* Merit dump file - Not yet supported          */
+       case 14:                /* Merit dump file - Not yet supported          */
                break;
-       case 15:                /* Domain name - Not yet supported              */
+       case 15:                /* Domain name - Not yet supported              */
                break;
-       case 16:                /* Swap server - Not yet supported              */
+       case 16:                /* Swap server - Not yet supported              */
                break;
-       case 17:                /* Root path                                    */
+       case 17:                /* Root path                                    */
                if (NetOurRootPath[0] == 0) {
                        size = truncate_sz ("Root Path", sizeof (NetOurRootPath), size);
                        memcpy (&NetOurRootPath, ext + 2, size);
                        NetOurRootPath[size] = 0;
                }
                break;
-       case 18:                /* Extension path - Not yet supported           */
+       case 18:                /* Extension path - Not yet supported           */
                /*
                 * This can be used to send the information of the
                 * vendor area in another file that the client can
@@ -233,15 +222,20 @@ static void BootpVendorFieldProcess (u8 * ext)
                 */
                break;
                /* IP host layer fields */
-       case 40:                /* NIS Domain name                              */
+       case 40:                /* NIS Domain name                              */
                if (NetOurNISDomain[0] == 0) {
                        size = truncate_sz ("NIS Domain Name", sizeof (NetOurNISDomain), size);
                        memcpy (&NetOurNISDomain, ext + 2, size);
                        NetOurNISDomain[size] = 0;
                }
                break;
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
+       case 42:        /* NTP server IP */
+               NetCopyIP(&NetNtpServerIP, (IPaddr_t *) (ext + 2));
+               break;
+#endif
                /* Application layer fields */
-       case 43:                /* Vendor specific info - Not yet supported     */
+       case 43:                /* Vendor specific info - Not yet supported     */
                /*
                 * Binary information to exchange specific
                 * product information.
@@ -255,7 +249,7 @@ static void BootpVendorProcess (u8 * ext, int size)
 {
        u8 *end = ext + size;
 
-       debug_ext ("[BOOTP] Checking extension (%d bytes)...\n", size);
+       debug("[BOOTP] Checking extension (%d bytes)...\n", size);
 
        while ((ext < end) && (*ext != 0xff)) {
                if (*ext == 0) {
@@ -269,51 +263,44 @@ static void BootpVendorProcess (u8 * ext, int size)
                }
        }
 
-#ifdef DEBUG_BOOTP_EXT
-       puts ("[BOOTP] Received fields: \n");
-       if (NetOurSubnetMask) {
-               puts ("NetOurSubnetMask : ");
-               print_IPaddr (NetOurSubnetMask);
-               putc ('\n');
-       }
+       debug("[BOOTP] Received fields: \n");
+       if (NetOurSubnetMask)
+               debug("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);
 
-       if (NetOurGatewayIP) {
-               puts ("NetOurGatewayIP  : ");
-               print_IPaddr (NetOurGatewayIP);
-               putc ('\n');
-       }
+       if (NetOurGatewayIP)
+               debug("NetOurGatewayIP  : %pI4", &NetOurGatewayIP);
 
-       if (NetBootFileSize) {
-               printf ("NetBootFileSize : %d\n", NetBootFileSize);
-       }
+       if (NetBootFileSize)
+               debug("NetBootFileSize : %d\n", NetBootFileSize);
 
-       if (NetOurHostName[0]) {
-               printf ("NetOurHostName  : %s\n", NetOurHostName);
-       }
+       if (NetOurHostName[0])
+               debug("NetOurHostName  : %s\n", NetOurHostName);
 
-       if (NetOurRootPath[0]) {
-               printf ("NetOurRootPath  : %s\n", NetOurRootPath);
-       }
+       if (NetOurRootPath[0])
+               debug("NetOurRootPath  : %s\n", NetOurRootPath);
 
-       if (NetOurNISDomain[0]) {
-               printf ("NetOurNISDomain : %s\n", NetOurNISDomain);
-       }
+       if (NetOurNISDomain[0])
+               debug("NetOurNISDomain : %s\n", NetOurNISDomain);
 
-       if (NetBootFileSize) {
-               printf ("NetBootFileSize: %d\n", NetBootFileSize);
-       }
-#endif /* DEBUG_BOOTP_EXT */
+       if (NetBootFileSize)
+               debug("NetBootFileSize: %d\n", NetBootFileSize);
+
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
+       if (NetNtpServerIP)
+               debug("NetNtpServerIP : %pI4\n", &NetNtpServerIP);
+#endif
 }
+
 /*
  *     Handle a BOOTP received packet.
  */
 static void
-BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+BootpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
+            unsigned len)
 {
        Bootp_t *bp;
-       char    *s;
 
-       debug ("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%d)\n",
+       debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
                src, dest, len, sizeof (Bootp_t));
 
        bp = (Bootp_t *)pkt;
@@ -336,28 +323,9 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
 
        NetSetTimeout(0, (thand_f *)0);
 
-       debug ("Got good BOOTP\n");
-
-       if ((s = getenv("autoload")) != NULL) {
-               if (*s == 'n') {
-                       /*
-                        * Just use BOOTP to configure system;
-                        * Do not use TFTP to load the bootfile.
-                        */
-                       NetState = NETLOOP_SUCCESS;
-                       return;
-#if defined(CONFIG_CMD_NFS)
-               } else if (strcmp(s, "NFS") == 0) {
-                       /*
-                        * Use NFS to load the bootfile.
-                        */
-                       NfsStart();
-                       return;
-#endif
-               }
-       }
+       debug("Got good BOOTP\n");
 
-       TftpStart();
+       net_auto_load();
 }
 #endif
 
@@ -371,7 +339,7 @@ BootpTimeout(void)
                puts ("\nRetry count exceeded; starting again\n");
                NetStartAgain ();
        } else {
-               NetSetTimeout (TIMEOUT * CFG_HZ, BootpTimeout);
+               NetSetTimeout (TIMEOUT, BootpTimeout);
                BootpRequest ();
        }
 }
@@ -384,6 +352,11 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
 {
        u8 *start = e;
        u8 *cnt;
+#if defined(CONFIG_BOOTP_PXE)
+       char *uuid;
+       size_t vci_strlen;
+       u16 clientarch;
+#endif
 
 #if defined(CONFIG_BOOTP_VENDOREX)
        u8 *x;
@@ -438,6 +411,41 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
        }
 #endif
 
+#if defined(CONFIG_BOOTP_PXE)
+       clientarch = CONFIG_BOOTP_PXE_CLIENTARCH;
+       *e++ = 93;      /* Client System Architecture */
+       *e++ = 2;
+       *e++ = (clientarch >> 8) & 0xff;
+       *e++ = clientarch & 0xff;
+
+       *e++ = 94;      /* Client Network Interface Identifier */
+       *e++ = 3;
+       *e++ = 1;       /* type field for UNDI */
+       *e++ = 0;       /* major revision */
+       *e++ = 0;       /* minor revision */
+
+       uuid = getenv("pxeuuid");
+
+       if (uuid) {
+               if (uuid_str_valid(uuid)) {
+                       *e++ = 97;      /* Client Machine Identifier */
+                       *e++ = 17;
+                       *e++ = 0;       /* type 0 - UUID */
+
+                       uuid_str_to_bin(uuid, e);
+                       e += 16;
+               } else {
+                       printf("Invalid pxeuuid: %s\n", uuid);
+               }
+       }
+
+       *e++ = 60;      /* Vendor Class Identifier */
+       vci_strlen = strlen(CONFIG_BOOTP_VCI_STRING);
+       *e++ = vci_strlen;
+       memcpy(e, CONFIG_BOOTP_VCI_STRING, vci_strlen);
+       e += vci_strlen;
+#endif
+
 #if defined(CONFIG_BOOTP_VENDOREX)
        if ((x = dhcp_vendorex_prep (e)))
                return x - start;
@@ -482,11 +490,15 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
        *e++  = 42;
        *cnt += 1;
 #endif
+       /* no options, so back up to avoid sending an empty request list */
+       if (*cnt == 0)
+               e -= 2;
+
        *e++  = 255;            /* End of the list */
 
        /* Pad to minimal length */
 #ifdef CONFIG_DHCP_MIN_EXT_LEN
-       while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
+       while ((e - start) < CONFIG_DHCP_MIN_EXT_LEN)
                *e++ = 0;
 #endif
 
@@ -558,6 +570,11 @@ static int BootpExtended (u8 * e)
        *e++ = 32;
        e   += 32;
 #endif
+#if defined(CONFIG_BOOTP_NTPSERVER)
+       *e++ = 42;
+       *e++ = 4;
+       e   += 4;
+#endif
 
        *e++ = 255;             /* End of the list */
 
@@ -579,29 +596,15 @@ BootpRequest (void)
 #ifdef CONFIG_BOOTP_RANDOM_DELAY               /* Random BOOTP delay */
        unsigned char bi_enetaddr[6];
        int   reg;
-       char  *e,*s;
-       char tmp[64];
        ulong tst1, tst2, sum, m_mask, m_value = 0;
 
        if (BootpTry ==0) {
                /* get our mac */
-               reg = getenv_r ("ethaddr", tmp, sizeof(tmp));
-               s = (reg > 0) ? tmp : NULL;
+               eth_getenv_enetaddr("ethaddr", bi_enetaddr);
 
-               for (reg=0; reg<6; ++reg) {
-                       bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
-                       if (s) {
-                               s = (*e) ? e+1 : e;
-                       }
-               }
-#ifdef DEBUG
-               puts ("BootpRequest => Our Mac: ");
-               for (reg=0; reg<6; reg++) {
-                       printf ("%x%c",
-                               bi_enetaddr[reg],
-                               reg==5 ? '\n' : ':');
-               }
-#endif /* DEBUG */
+               debug("BootpRequest => Our Mac: ");
+               for (reg=0; reg<6; reg++)
+                       debug("%x%c", bi_enetaddr[reg], reg==5 ? '\n' : ':');
 
                /* Mac-Manipulation 2 get seed1 */
                tst1=0;
@@ -671,7 +674,7 @@ BootpRequest (void)
        bp->bp_htype = HWT_ETHER;
        bp->bp_hlen = HWL_ETHER;
        bp->bp_hops = 0;
-       bp->bp_secs = htons(get_timer(0) / CFG_HZ);
+       bp->bp_secs = htons(get_timer(0) / 1000);
        NetWriteIP(&bp->bp_ciaddr, 0);
        NetWriteIP(&bp->bp_yiaddr, 0);
        NetWriteIP(&bp->bp_siaddr, 0);
@@ -688,7 +691,7 @@ BootpRequest (void)
 
        /*
         *      Bootp ID is the lower 4 bytes of our ethernet address
-        *      plus the current time in HZ.
+        *      plus the current time in ms.
         */
        BootpID = ((ulong)NetOurEther[2] << 24)
                | ((ulong)NetOurEther[3] << 16)
@@ -702,10 +705,10 @@ BootpRequest (void)
         * Calculate proper packet lengths taking into account the
         * variable size of the options field
         */
-       pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + ext_len;
+       pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
        iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
        NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
-       NetSetTimeout(SELECT_TIMEOUT * CFG_HZ, BootpTimeout);
+       NetSetTimeout(SELECT_TIMEOUT, BootpTimeout);
 
 #if defined(CONFIG_CMD_DHCP)
        dhcp_state = SELECTING;
@@ -721,6 +724,9 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
 {
        uchar *end = popt + BOOTP_HDR_SIZE;
        int oplen, size;
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
+       int *to_ptr;
+#endif
 
        while (popt < end && *popt != 0xff) {
                oplen = *(popt + 1);
@@ -730,7 +736,8 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
                        break;
 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
                case 2:         /* Time offset  */
-                       NetCopyLong ((ulong *)&NetTimeOffset, (ulong *) (popt + 2));
+                       to_ptr = &NetTimeOffset;
+                       NetCopyLong ((ulong *)to_ptr, (ulong *)(popt + 2));
                        NetTimeOffset = ntohl (NetTimeOffset);
                        break;
 #endif
@@ -835,7 +842,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
        int pktlen, iplen, extlen;
        IPaddr_t OfferedIP;
 
-       debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
+       debug("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
        pkt = NetTxPacket;
        memset ((void*)pkt, 0, PKTSIZE);
 
@@ -849,7 +856,7 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
        bp->bp_htype = HWT_ETHER;
        bp->bp_hlen = HWL_ETHER;
        bp->bp_hops = 0;
-       bp->bp_secs = htons(get_timer(0) / CFG_HZ);
+       bp->bp_secs = htons(get_timer(0) / 1000);
        /* Do not set the client IP, your IP, or server IP yet, since it hasn't been ACK'ed by
         * the server yet */
 
@@ -875,11 +882,14 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
        NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr);
        extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
 
-       pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
+       pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
        iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
        NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
 
-       debug ("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
+       debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
+#ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY
+       udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY);
+#endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */
        NetSendPacket(NetTxPacket, pktlen);
 }
 
@@ -887,17 +897,18 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
  *     Handle DHCP received packets.
  */
 static void
-DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
+DhcpHandler(uchar *pkt, unsigned dest, IPaddr_t sip, unsigned src,
+           unsigned len)
 {
        Bootp_t *bp = (Bootp_t *)pkt;
 
-       debug ("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
+       debug("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
                src, dest, len, dhcp_state);
 
        if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
                return;
 
-       debug ("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
+       debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
                src, dest, len, dhcp_state);
 
        switch (dhcp_state) {
@@ -908,66 +919,44 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
                 * If filename is in format we recognize, assume it is a valid
                 * OFFER from a server we want.
                 */
-               debug ("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
-#ifdef CFG_BOOTFILE_PREFIX
+               debug("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
+#ifdef CONFIG_SYS_BOOTFILE_PREFIX
                if (strncmp(bp->bp_file,
-                           CFG_BOOTFILE_PREFIX,
-                           strlen(CFG_BOOTFILE_PREFIX)) == 0 ) {
-#endif /* CFG_BOOTFILE_PREFIX */
+                           CONFIG_SYS_BOOTFILE_PREFIX,
+                           strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0 ) {
+#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
 
-                       debug ("TRANSITIONING TO REQUESTING STATE\n");
+                       debug("TRANSITIONING TO REQUESTING STATE\n");
                        dhcp_state = REQUESTING;
 
                        if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
                                DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
 
-                       BootpCopyNetParams(bp); /* Store net params from reply */
-
-                       NetSetTimeout(TIMEOUT * CFG_HZ, BootpTimeout);
+                       NetSetTimeout(TIMEOUT, BootpTimeout);
                        DhcpSendRequestPkt(bp);
-#ifdef CFG_BOOTFILE_PREFIX
+#ifdef CONFIG_SYS_BOOTFILE_PREFIX
                }
-#endif /* CFG_BOOTFILE_PREFIX */
+#endif /* CONFIG_SYS_BOOTFILE_PREFIX */
 
                return;
                break;
        case REQUESTING:
-               debug ("DHCP State: REQUESTING\n");
+               debug("DHCP State: REQUESTING\n");
 
                if ( DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK ) {
-                       char *s;
-
                        if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
                                DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
                        BootpCopyNetParams(bp); /* Store net params from reply */
                        dhcp_state = BOUND;
-                       puts ("DHCP client bound to address ");
-                       print_IPaddr(NetOurIP);
-                       putc ('\n');
-
-                       /* Obey the 'autoload' setting */
-                       if ((s = getenv("autoload")) != NULL) {
-                               if (*s == 'n') {
-                                       /*
-                                        * Just use BOOTP to configure system;
-                                        * Do not use TFTP to load the bootfile.
-                                        */
-                                       NetState = NETLOOP_SUCCESS;
-                                       return;
-#if defined(CONFIG_CMD_NFS)
-                               } else if (strcmp(s, "NFS") == 0) {
-                                       /*
-                                        * Use NFS to load the bootfile.
-                                        */
-                                       NfsStart();
-                                       return;
-#endif
-                               }
-                       }
-                       TftpStart();
+                       printf ("DHCP client bound to address %pI4\n", &NetOurIP);
+
+                       net_auto_load();
                        return;
                }
                break;
+       case BOUND:
+               /* DHCP client bound to address */
+               break;
        default:
                puts ("DHCP: INVALID STATE\n");
                break;
@@ -980,5 +969,3 @@ void DhcpRequest(void)
        BootpRequest();
 }
 #endif /* CONFIG_CMD_DHCP */
-
-#endif /* CONFIG_CMD_NET */