]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - net/bootp.c
net: new utility functions for working with enetaddr's
[karo-tx-uboot.git] / net / bootp.c
index 669d74a6a50ae0f9f1a8ecba05101bb8ada04624..d1cbd39c2b032743b9d86338b12012eaa3e881bb 100644 (file)
@@ -31,9 +31,9 @@
 
 #define BOOTP_VENDOR_MAGIC     0x63825363      /* RFC1048 Magic Cookie         */
 
-#if (CONFIG_COMMANDS & CFG_CMD_NET)
+#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
@@ -53,7 +53,7 @@ int           BootpTry;
 ulong          seed1, seed2;
 #endif
 
-#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
+#if defined(CONFIG_CMD_DHCP)
 dhcp_state_t dhcp_state = INIT;
 unsigned long dhcp_leasetime = 0;
 IPaddr_t NetDHCPServerIP = 0;
@@ -76,12 +76,12 @@ static char *dhcpmsg2str(int type)
 }
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
+#if defined(CONFIG_BOOTP_VENDOREX)
 extern u8 *dhcp_vendorex_prep (u8 *e); /*rtn new e after add own opts. */
 extern u8 *dhcp_vendorex_proc (u8 *e); /*rtn next e if mine,else NULL  */
 #endif
 
-#endif /* CFG_CMD_DHCP */
+#endif
 
 static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
 {
@@ -120,10 +120,12 @@ static void BootpCopyNetParams(Bootp_t *bp)
        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);
+#endif
        if (strlen(bp->bp_file) > 0)
                copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
 
@@ -148,7 +150,7 @@ static int truncate_sz (const char *name, int maxlen, int curlen)
        return (curlen);
 }
 
-#if !(CONFIG_COMMANDS & CFG_CMD_DHCP)
+#if !defined(CONFIG_CMD_DHCP)
 
 static void BootpVendorFieldProcess (u8 * ext)
 {
@@ -161,69 +163,69 @@ static void BootpVendorFieldProcess (u8 * ext)
 
        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) {
                        NetCopyIP (&NetOurDNSIP, (IPaddr_t *) (ext + 2));
                }
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
+#if defined(CONFIG_BOOTP_DNS2)
                if ((NetOurDNS2IP == 0) && (size > 4)) {
                        NetCopyIP (&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4));
                }
 #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
@@ -231,7 +233,7 @@ 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);
@@ -239,7 +241,7 @@ static void BootpVendorFieldProcess (u8 * ext)
                }
                break;
                /* 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.
@@ -269,17 +271,11 @@ 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');
-       }
+       if (NetOurSubnetMask)
+               printf ("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);
 
-       if (NetOurGatewayIP) {
-               puts ("NetOurGatewayIP  : ");
-               print_IPaddr (NetOurGatewayIP);
-               putc ('\n');
-       }
+       if (NetOurGatewayIP)
+               printf ("NetOurGatewayIP        : %pI4", &NetOurGatewayIP);
 
        if (NetBootFileSize) {
                printf ("NetBootFileSize : %d\n", NetBootFileSize);
@@ -311,7 +307,7 @@ BootpHandler(uchar * pkt, unsigned dest, 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;
@@ -344,7 +340,7 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
                         */
                        NetState = NETLOOP_SUCCESS;
                        return;
-#if (CONFIG_COMMANDS & CFG_CMD_NFS)
+#if defined(CONFIG_CMD_NFS)
                } else if (strcmp(s, "NFS") == 0) {
                        /*
                         * Use NFS to load the bootfile.
@@ -357,7 +353,7 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
 
        TftpStart();
 }
-#endif /* !CFG_CMD_DHCP */
+#endif
 
 /*
  *     Timeout on BOOTP/DHCP request.
@@ -369,7 +365,7 @@ BootpTimeout(void)
                puts ("\nRetry count exceeded; starting again\n");
                NetStartAgain ();
        } else {
-               NetSetTimeout (TIMEOUT * CFG_HZ, BootpTimeout);
+               NetSetTimeout (TIMEOUT, BootpTimeout);
                BootpRequest ();
        }
 }
@@ -377,16 +373,16 @@ BootpTimeout(void)
 /*
  *     Initialize BOOTP extension fields in the request.
  */
-#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
+#if defined(CONFIG_CMD_DHCP)
 static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP)
 {
        u8 *start = e;
        u8 *cnt;
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
+#if defined(CONFIG_BOOTP_VENDOREX)
        u8 *x;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SEND_HOSTNAME)
+#if defined(CONFIG_BOOTP_SEND_HOSTNAME)
        char *hostname;
 #endif
 
@@ -425,7 +421,7 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
                *e++ = tmp >> 8;
                *e++ = tmp & 0xff;
        }
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SEND_HOSTNAME)
+#if defined(CONFIG_BOOTP_SEND_HOSTNAME)
        if ((hostname = getenv ("hostname"))) {
                int hostnamelen = strlen (hostname);
 
@@ -436,7 +432,7 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
        }
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
+#if defined(CONFIG_BOOTP_VENDOREX)
        if ((x = dhcp_vendorex_prep (e)))
                return x - start;
 #endif
@@ -444,39 +440,39 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
        *e++ = 55;              /* Parameter Request List */
         cnt = e++;             /* Pointer to count of requested items */
        *cnt = 0;
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
+#if defined(CONFIG_BOOTP_SUBNETMASK)
        *e++  = 1;              /* Subnet Mask */
        *cnt += 1;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_TIMEOFFSET)
+#if defined(CONFIG_BOOTP_TIMEOFFSET)
        *e++  = 2;
        *cnt += 1;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
+#if defined(CONFIG_BOOTP_GATEWAY)
        *e++  = 3;              /* Router Option */
        *cnt += 1;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
+#if defined(CONFIG_BOOTP_DNS)
        *e++  = 6;              /* DNS Server(s) */
        *cnt += 1;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
+#if defined(CONFIG_BOOTP_HOSTNAME)
        *e++  = 12;             /* Hostname */
        *cnt += 1;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
+#if defined(CONFIG_BOOTP_BOOTFILESIZE)
        *e++  = 13;             /* Boot File Size */
        *cnt += 1;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
+#if defined(CONFIG_BOOTP_BOOTPATH)
        *e++  = 17;             /* Boot path */
        *cnt += 1;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
+#if defined(CONFIG_BOOTP_NISDOMAIN)
        *e++  = 40;             /* NIS Domain name request */
        *cnt += 1;
 #endif
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NTPSERVER)
+#if defined(CONFIG_BOOTP_NTPSERVER)
        *e++  = 42;
        *cnt += 1;
 #endif
@@ -491,9 +487,9 @@ static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t R
        return e - start;
 }
 
-#else  /* CFG_CMD_DHCP */
+#else
 /*
- *     Warning: no field size check - change CONFIG_BOOTP_MASK at your own risk!
+ *     Warning: no field size check - change CONFIG_BOOTP_* at your own risk!
  */
 static int BootpExtended (u8 * e)
 {
@@ -504,7 +500,7 @@ static int BootpExtended (u8 * e)
        *e++ = 83;
        *e++ = 99;
 
-#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
+#if defined(CONFIG_CMD_DHCP)
        *e++ = 53;              /* DHCP Message Type */
        *e++ = 1;
        *e++ = DHCP_DISCOVER;
@@ -513,45 +509,45 @@ static int BootpExtended (u8 * e)
        *e++ = 2;
        *e++ = (576 - 312 + OPT_SIZE) >> 16;
        *e++ = (576 - 312 + OPT_SIZE) & 0xff;
-#endif /* CFG_CMD_DHCP */
+#endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
+#if defined(CONFIG_BOOTP_SUBNETMASK)
        *e++ = 1;               /* Subnet mask request */
        *e++ = 4;
        e   += 4;
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
+#if defined(CONFIG_BOOTP_GATEWAY)
        *e++ = 3;               /* Default gateway request */
        *e++ = 4;
        e   += 4;
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
+#if defined(CONFIG_BOOTP_DNS)
        *e++ = 6;               /* Domain Name Server */
        *e++ = 4;
        e   += 4;
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
+#if defined(CONFIG_BOOTP_HOSTNAME)
        *e++ = 12;              /* Host name request */
        *e++ = 32;
        e   += 32;
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
+#if defined(CONFIG_BOOTP_BOOTFILESIZE)
        *e++ = 13;              /* Boot file size */
        *e++ = 2;
        e   += 2;
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
+#if defined(CONFIG_BOOTP_BOOTPATH)
        *e++ = 17;              /* Boot path */
        *e++ = 32;
        e   += 32;
 #endif
 
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
+#if defined(CONFIG_BOOTP_NISDOMAIN)
        *e++ = 40;              /* NIS Domain name request */
        *e++ = 32;
        e   += 32;
@@ -561,7 +557,7 @@ static int BootpExtended (u8 * e)
 
        return e - start;
 }
-#endif /* CFG_CMD_DHCP */
+#endif
 
 void
 BootpRequest (void)
@@ -570,7 +566,7 @@ BootpRequest (void)
        Bootp_t *bp;
        int ext_len, pktlen, iplen;
 
-#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
+#if defined(CONFIG_CMD_DHCP)
        dhcp_state = INIT;
 #endif
 
@@ -669,7 +665,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);
@@ -678,15 +674,15 @@ BootpRequest (void)
        copy_filename (bp->bp_file, BootFile, sizeof(bp->bp_file));
 
        /* Request additional information from the BOOTP/DHCP server */
-#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
+#if defined(CONFIG_CMD_DHCP)
        ext_len = DhcpExtended((u8 *)bp->bp_vend, DHCP_DISCOVER, 0, 0);
 #else
        ext_len = BootpExtended((u8 *)bp->bp_vend);
-#endif /* CFG_CMD_DHCP */
+#endif
 
        /*
         *      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)
@@ -703,18 +699,18 @@ BootpRequest (void)
        pktlen = BOOTP_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 (CONFIG_COMMANDS & CFG_CMD_DHCP)
+#if defined(CONFIG_CMD_DHCP)
        dhcp_state = SELECTING;
        NetSetHandler(DhcpHandler);
 #else
        NetSetHandler(BootpHandler);
-#endif /* CFG_CMD_DHCP */
+#endif
        NetSendPacket(NetTxPacket, pktlen);
 }
 
-#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
+#if defined(CONFIG_CMD_DHCP)
 static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
 {
        uchar *end = popt + BOOTP_HDR_SIZE;
@@ -726,9 +722,9 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
                case 1:
                        NetCopyIP (&NetOurSubnetMask, (popt + 2));
                        break;
-#if (CONFIG_COMMANDS & CFG_CMD_SNTP) && (CONFIG_BOOTP_MASK & CONFIG_BOOTP_TIMEOFFSET)
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
                case 2:         /* Time offset  */
-                       NetCopyLong (&NetTimeOffset, (ulong *) (popt + 2));
+                       NetCopyLong ((ulong *)&NetTimeOffset, (ulong *) (popt + 2));
                        NetTimeOffset = ntohl (NetTimeOffset);
                        break;
 #endif
@@ -737,7 +733,7 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
                        break;
                case 6:
                        NetCopyIP (&NetOurDNSIP, (popt + 2));
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
+#if defined(CONFIG_BOOTP_DNS2)
                        if (*(popt + 1) > 4) {
                                NetCopyIP (&NetOurDNS2IP, (popt + 2 + 4));
                        }
@@ -755,7 +751,7 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
                        memcpy (&NetOurRootPath, popt + 2, size);
                        NetOurRootPath[size] = 0;
                        break;
-#if (CONFIG_COMMANDS & CFG_CMD_SNTP) && (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NTPSERVER)
+#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
                case 42:        /* NTP server IP */
                        NetCopyIP (&NetNtpServerIP, (popt + 2));
                        break;
@@ -801,7 +797,7 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
                        }
                        break;
                default:
-#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
+#if defined(CONFIG_BOOTP_VENDOREX)
                        if (dhcp_vendorex_proc (popt))
                                break;
 #endif
@@ -847,11 +843,16 @@ 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);
-       NetCopyIP(&bp->bp_ciaddr, &bp_offer->bp_ciaddr); /* both in network byte order */
-       NetCopyIP(&bp->bp_yiaddr, &bp_offer->bp_yiaddr);
-       NetCopyIP(&bp->bp_siaddr, &bp_offer->bp_siaddr);
-       NetCopyIP(&bp->bp_giaddr, &bp_offer->bp_giaddr);
+       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 */
+
+       /*
+        * RFC3046 requires Relay Agents to discard packets with
+        * nonzero and offered giaddr
+        */
+       NetWriteIP(&bp->bp_giaddr, 0);
+
        memcpy (bp->bp_chaddr, NetOurEther, 6);
 
        /*
@@ -863,7 +864,9 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
        /*
         * Copy options from OFFER packet if present
         */
-       NetCopyIP(&OfferedIP, &bp->bp_yiaddr);
+
+       /* Copy offered IP into the parameters request list */
+       NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr);
        extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
 
        pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
@@ -871,6 +874,9 @@ static void DhcpSendRequestPkt(Bootp_t *bp_offer)
        NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
 
        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);
 }
 
@@ -900,11 +906,11 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
                 * OFFER from a server we want.
                 */
                debug ("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
-#ifdef CFG_BOOTFILE_PREFIX
+#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");
                        dhcp_state = REQUESTING;
@@ -912,13 +918,11 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
                        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;
@@ -932,9 +936,7 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
                                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');
+                       printf ("DHCP client bound to address %pI4\n", &NetOurIP);
 
                        /* Obey the 'autoload' setting */
                        if ((s = getenv("autoload")) != NULL) {
@@ -945,7 +947,7 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
                                         */
                                        NetState = NETLOOP_SUCCESS;
                                        return;
-#if (CONFIG_COMMANDS & CFG_CMD_NFS)
+#if defined(CONFIG_CMD_NFS)
                                } else if (strcmp(s, "NFS") == 0) {
                                        /*
                                         * Use NFS to load the bootfile.
@@ -959,6 +961,9 @@ DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
                        return;
                }
                break;
+       case BOUND:
+               /* DHCP client bound to address */
+               break;
        default:
                puts ("DHCP: INVALID STATE\n");
                break;
@@ -970,6 +975,6 @@ void DhcpRequest(void)
 {
        BootpRequest();
 }
-#endif /* CFG_CMD_DHCP */
+#endif /* CONFIG_CMD_DHCP */
 
-#endif /* CFG_CMD_NET */
+#endif /* CONFIG_CMD_NET */