2 * Based on LiMon - BOOTP.
4 * Copyright 1994, 1995, 2000 Neil Russell.
6 * Copyright 2000 Roland Borde
7 * Copyright 2000 Paolo Scaffardi
8 * Copyright 2000-2002 Wolfgang Denk, wd@denx.de
12 #define DEBUG 1 /* general debug */
13 #define DEBUG_BOOTP_EXT 1 /* Debug received vendor fields */
16 #ifdef DEBUG_BOOTP_EXT
17 #define debug_ext(fmt,args...) printf (fmt ,##args)
19 #define debug_ext(fmt,args...)
28 #ifdef CONFIG_STATUS_LED
29 #include <status_led.h>
32 #define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
34 #if (CONFIG_COMMANDS & CFG_CMD_NET)
36 #define TIMEOUT 5 /* Seconds before trying BOOTP again */
37 #ifndef CONFIG_NET_RETRY_COUNT
38 # define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
40 # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
43 #define PORT_BOOTPS 67 /* BOOTP server UDP port */
44 #define PORT_BOOTPC 68 /* BOOTP client UDP port */
46 #ifndef CONFIG_DHCP_MIN_EXT_LEN /* minimal length of extension list */
47 #define CONFIG_DHCP_MIN_EXT_LEN 64
52 #ifdef CONFIG_BOOTP_RANDOM_DELAY
56 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
57 dhcp_state_t dhcp_state = INIT;
58 unsigned long dhcp_leasetime = 0;
59 IPaddr_t NetDHCPServerIP = 0;
60 static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len);
64 static char *dhcpmsg2str(int type)
67 case 1: return "DHCPDISCOVER"; break;
68 case 2: return "DHCPOFFER"; break;
69 case 3: return "DHCPREQUEST"; break;
70 case 4: return "DHCPDECLINE"; break;
71 case 5: return "DHCPACK"; break;
72 case 6: return "DHCPNACK"; break;
73 case 7: return "DHCPRELEASE"; break;
74 default: return "UNKNOWN/INVALID MSG TYPE"; break;
79 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
80 extern u8 *dhcp_vendorex_prep (u8 *e); /*rtn new e after add own opts. */
81 extern u8 *dhcp_vendorex_proc (u8 *e); /*rtn next e if mine,else NULL */
84 #endif /* CFG_CMD_DHCP */
86 static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
88 Bootp_t *bp = (Bootp_t *) pkt;
91 if (dest != PORT_BOOTPC || src != PORT_BOOTPS)
93 else if (len < sizeof (Bootp_t) - OPT_SIZE)
95 else if (bp->bp_op != OP_BOOTREQUEST &&
96 bp->bp_op != OP_BOOTREPLY &&
97 bp->bp_op != DHCP_OFFER &&
98 bp->bp_op != DHCP_ACK &&
99 bp->bp_op != DHCP_NAK ) {
102 else if (bp->bp_htype != HWT_ETHER)
104 else if (bp->bp_hlen != HWL_ETHER)
106 else if (NetReadLong((ulong*)&bp->bp_id) != BootpID) {
110 debug ("Filtering pkt = %d\n", retval);
116 * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet
118 static void BootpCopyNetParams(Bootp_t *bp)
120 NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
121 NetCopyIP(&NetServerIP, &bp->bp_siaddr);
122 memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6);
123 copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
125 debug ("Bootfile: %s\n", BootFile);
127 /* Propagate to environment:
128 * don't delete exising entry when BOOTP / DHCP reply does
129 * not contain a new value
132 setenv ("bootfile", BootFile);
136 static int truncate_sz (const char *name, int maxlen, int curlen)
138 if (curlen >= maxlen) {
139 printf("*** WARNING: %s is too long (%d - max: %d) - truncated\n",
140 name, curlen, maxlen);
146 #if !(CONFIG_COMMANDS & CFG_CMD_DHCP)
148 static void BootpVendorFieldProcess(u8 *ext)
150 int size = *(ext+1) ;
152 debug_ext ("[BOOTP] Processing extension %d... (%d bytes)\n", *ext, *(ext+1));
157 /* Fixed length fields */
158 case 1: /* Subnet mask */
159 if (NetOurSubnetMask == 0)
160 NetCopyIP(&NetOurSubnetMask, (IPaddr_t*)(ext+2));
162 case 2: /* Time offset - Not yet supported */
164 /* Variable length fields */
165 case 3: /* Gateways list */
166 if (NetOurGatewayIP == 0) {
167 NetCopyIP(&NetOurGatewayIP, (IPaddr_t*)(ext+2));
170 case 4: /* Time server - Not yet supported */
172 case 5: /* IEN-116 name server - Not yet supported */
175 if (NetOurDNSIP == 0) {
176 NetCopyIP(&NetOurDNSIP, (IPaddr_t*)(ext+2));
179 case 7: /* Log server - Not yet supported */
181 case 8: /* Cookie/Quote server - Not yet supported */
183 case 9: /* LPR server - Not yet supported */
185 case 10: /* Impress server - Not yet supported */
187 case 11: /* RPL server - Not yet supported */
189 case 12: /* Host name */
190 if (NetOurHostName[0] == 0) {
191 size = truncate_sz("Host Name", sizeof(NetOurHostName), size);
192 memcpy(&NetOurHostName, ext+2, size);
193 NetOurHostName[size] = 0 ;
196 case 13: /* Boot file size */
198 NetBootFileSize = ntohs(*(ushort*)(ext+2));
200 NetBootFileSize = ntohl(*(ulong*)(ext+2));
202 case 14: /* Merit dump file - Not yet supported */
204 case 15: /* Domain name - Not yet supported */
206 case 16: /* Swap server - Not yet supported */
208 case 17: /* Root path */
209 if (NetOurRootPath[0] == 0) {
210 size = truncate_sz("Root Path", sizeof(NetOurRootPath), size);
211 memcpy(&NetOurRootPath, ext+2, size);
212 NetOurRootPath[size] = 0 ;
215 case 18: /* Extension path - Not yet supported */
217 * This can be used to send the information of the
218 * vendor area in another file that the client can
222 /* IP host layer fields */
223 case 40: /* NIS Domain name */
224 if (NetOurNISDomain[0] == 0) {
225 size = truncate_sz ("NIS Domain Name",
226 sizeof(NetOurNISDomain),
228 memcpy(&NetOurNISDomain, ext+2, size);
229 NetOurNISDomain[size] = 0 ;
232 /* Application layer fields */
233 case 43: /* Vendor specific info - Not yet supported */
235 * Binary information to exchange specific
236 * product information.
239 /* Reserved (custom) fields (128..254) */
243 static void BootpVendorProcess(u8 *ext, int size)
245 u8 *end = ext + size ;
247 debug_ext ("[BOOTP] Checking extension (%d bytes)...\n", size);
249 while ((ext < end) && (*ext != 0xff)) {
256 BootpVendorFieldProcess (opt) ;
260 #ifdef DEBUG_BOOTP_EXT
261 printf("[BOOTP] Received fields: \n");
262 if (NetOurSubnetMask) {
263 puts ("NetOurSubnetMask : ");
264 print_IPaddr (NetOurSubnetMask);
268 if (NetOurGatewayIP) {
269 puts ("NetOurGatewayIP : ");
270 print_IPaddr (NetOurGatewayIP);
274 if (NetBootFileSize) {
275 printf("NetBootFileSize : %d\n", NetBootFileSize);
278 if (NetOurHostName[0]) {
279 printf("NetOurHostName : %s\n", NetOurHostName);
282 if (NetOurRootPath[0]) {
283 printf("NetOurRootPath : %s\n", NetOurRootPath);
286 if (NetOurNISDomain[0]) {
287 printf("NetOurNISDomain : %s\n", NetOurNISDomain);
290 if (NetBootFileSize) {
291 printf("NetBootFileSize: %d\n", NetBootFileSize);
293 #endif /* DEBUG_BOOTP_EXT */
297 * Handle a BOOTP received packet.
300 BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
305 debug ("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%d)\n",
306 src, dest, len, sizeof (Bootp_t));
310 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
314 * Got a good BOOTP reply. Copy the data into our variables.
316 #ifdef CONFIG_STATUS_LED
317 status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
320 BootpCopyNetParams(bp); /* Store net parameters from reply */
322 /* Retrieve extended information (we must parse the vendor area) */
323 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
324 BootpVendorProcess(&bp->bp_vend[4], len);
326 NetSetTimeout(0, (thand_f *)0);
328 debug ("Got good BOOTP\n");
330 if (((s = getenv("autoload")) != NULL) && (*s == 'n')) {
332 * Just use BOOTP to configure system;
333 * Do not use TFTP to load the bootfile.
335 NetState = NETLOOP_SUCCESS;
339 /* Send ARP request to get TFTP server ethernet address.
340 * This automagically starts TFTP, too.
344 #endif /* !CFG_CMD_DHCP */
347 * Timeout on BOOTP/DHCP request.
352 if (BootpTry >= TIMEOUT_COUNT) {
353 puts ("\nRetry count exceeded; starting again\n");
356 NetSetTimeout (TIMEOUT * CFG_HZ, BootpTimeout);
362 * Initialize BOOTP extension fields in the request.
364 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
365 static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP)
369 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
373 *e++ = 99; /* RFC1048 Magic Cookie */
378 *e++ = 53; /* DHCP Message Type */
382 *e++ = 57; /* Maximum DHCP Message Size */
384 *e++ = (576-312+OPT_SIZE) >> 8;
385 *e++ = (576-312+OPT_SIZE) & 0xff;
388 int tmp = ntohl(ServerID);
390 *e++ = 54; /* ServerID */
399 int tmp = ntohl(RequestedIP);
401 *e++ = 50; /* Requested IP */
409 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
410 if ((x = dhcp_vendorex_prep (e)))
414 *e++ = 55; /* Parameter Request List */
415 cnt = e++; /* Pointer to count of requested items */
417 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
418 *e++ = 1; /* Subnet Mask */
421 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
422 *e++ = 3; /* Router Option */
425 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
426 *e++ = 6; /* DNS Server(s) */
429 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
430 *e++ = 12; /* Hostname */
433 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
434 *e++ = 13; /* Boot File Size */
437 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
438 *e++ = 17; /* Boot path */
441 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
442 *e++ = 40; /* NIS Domain name request */
445 *e++ = 255; /* End of the list */
447 /* Pad to minimal length */
448 #ifdef CONFIG_DHCP_MIN_EXT_LEN
449 while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
456 #else /* CFG_CMD_DHCP */
458 * Warning: no field size check - change CONFIG_BOOTP_MASK at your own risk!
460 static int BootpExtended (u8 *e)
464 *e++ = 99; /* RFC1048 Magic Cookie */
469 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
470 *e++ = 53; /* DHCP Message Type */
472 *e++ = DHCP_DISCOVER;
474 *e++ = 57; /* Maximum DHCP Message Size */
476 *e++ = (576-312+OPT_SIZE) >> 16;
477 *e++ = (576-312+OPT_SIZE) & 0xff;
478 #endif /* CFG_CMD_DHCP */
480 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
481 *e++ = 1; /* Subnet mask request */
486 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
487 *e++ = 3; /* Default gateway request */
492 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
493 *e++ = 6; /* Domain Name Server */
498 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
499 *e++ = 12; /* Host name request */
504 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
505 *e++ = 13; /* Boot file size */
510 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
511 *e++ = 17; /* Boot path */
516 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
517 *e++ = 40; /* NIS Domain name request */
522 *e++ = 255; /* End of the list */
526 #endif /* CFG_CMD_DHCP */
531 volatile uchar *pkt, *iphdr;
533 int ext_len, pktlen, iplen;
535 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
539 #ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
540 unsigned char bi_enetaddr[6];
544 ulong tst1, tst2, sum, m_mask, m_value = 0;
548 reg = getenv_r ("ethaddr", tmp, sizeof(tmp));
549 s = (reg > 0) ? tmp : NULL;
551 for (reg=0; reg<6; ++reg) {
552 bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
558 printf("BootpRequest => Our Mac: ");
559 for (reg=0; reg<6; reg++) {
562 reg==5 ? '\n' : ':');
566 /* Mac-Manipulation 2 get seed1 */
569 for (reg=2; reg<6; reg++) {
571 tst1 = tst1 | bi_enetaddr[reg];
573 for (reg=0; reg<2; reg++) {
574 tst2 = tst2 | bi_enetaddr[reg];
582 for (reg=1;reg<=32;reg++) {
583 m_value |= (m_mask & seed1);
585 m_value = m_value << 1;
591 /* Random Number Generator */
593 for (reg=0;reg<=0;reg++) {
595 if (sum < seed1 || sum < seed2)
600 if (BootpTry<=2) { /* Start with max 1024 * 1ms */
601 sum = sum >> (22-BootpTry);
602 } else { /*After 3rd BOOTP request max 8192 * 1ms */
607 printf ("Random delay: %ld ms...\n", sum);
608 for (reg=0; reg <sum; reg++) {
609 udelay(1000); /*Wait 1ms*/
611 #endif /* CONFIG_BOOTP_RANDOM_DELAY */
613 printf("BOOTP broadcast %d\n", ++BootpTry);
615 memset ((void*)pkt, 0, PKTSIZE);
617 NetSetEther(pkt, NetBcastAddr, PROT_IP);
618 pkt += ETHER_HDR_SIZE;
621 * Next line results in incorrect packet size being transmitted, resulting
622 * in errors in some DHCP servers, reporting missing bytes. Size must be
623 * set in packet header after extension length has been determined.
624 * C. Hallinan, DS4.COM, Inc.
626 /* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, sizeof (Bootp_t)); */
627 iphdr = pkt; /* We need this later for NetSetIP() */
631 bp->bp_op = OP_BOOTREQUEST;
632 bp->bp_htype = HWT_ETHER;
633 bp->bp_hlen = HWL_ETHER;
635 bp->bp_secs = htons(get_timer(0) / CFG_HZ);
636 NetWriteIP(&bp->bp_ciaddr, 0);
637 NetWriteIP(&bp->bp_yiaddr, 0);
638 NetWriteIP(&bp->bp_siaddr, 0);
639 NetWriteIP(&bp->bp_giaddr, 0);
640 memcpy (bp->bp_chaddr, NetOurEther, 6);
641 copy_filename (bp->bp_file, BootFile, sizeof(bp->bp_file));
643 /* Request additional information from the BOOTP/DHCP server */
644 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
645 ext_len = DhcpExtended(bp->bp_vend, DHCP_DISCOVER, 0, 0);
647 ext_len = BootpExtended(bp->bp_vend);
648 #endif /* CFG_CMD_DHCP */
651 * Bootp ID is the lower 4 bytes of our ethernet address
652 * plus the current time in HZ.
654 BootpID = ((ulong)NetOurEther[2] << 24)
655 | ((ulong)NetOurEther[3] << 16)
656 | ((ulong)NetOurEther[4] << 8)
657 | (ulong)NetOurEther[5];
658 BootpID += get_timer(0);
659 BootpID = htonl(BootpID);
660 NetCopyLong(&bp->bp_id, &BootpID);
663 * Calculate proper packet lengths taking into account the
664 * variable size of the options field
666 pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + ext_len;
667 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
668 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
669 NetSetTimeout(SELECT_TIMEOUT * CFG_HZ, BootpTimeout);
671 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
672 dhcp_state = SELECTING;
673 NetSetHandler(DhcpHandler);
675 NetSetHandler(BootpHandler);
676 #endif /* CFG_CMD_DHCP */
677 NetSendPacket(NetTxPacket, pktlen);
680 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
681 static void DhcpOptionsProcess(uchar *popt)
683 uchar *end = popt + BOOTP_HDR_SIZE;
686 while ( popt < end && *popt != 0xff ) {
690 NetCopyIP(&NetOurSubnetMask, (popt+2));
693 NetCopyIP(&NetOurGatewayIP, (popt+2));
696 NetCopyIP(&NetOurDNSIP, (popt+2));
699 size = truncate_sz ("Host Name",
700 sizeof(NetOurHostName),
702 memcpy(&NetOurHostName, popt+2, size);
703 NetOurHostName[size] = 0 ;
705 case 15: /* Ignore Domain Name Option */
708 size = truncate_sz ("Root Path",
709 sizeof(NetOurRootPath),
711 memcpy(&NetOurRootPath, popt+2, size);
712 NetOurRootPath[size] = 0 ;
715 NetCopyLong (&dhcp_leasetime, (ulong *)(popt + 2));
717 case 53: /* Ignore Message Type Option */
720 NetCopyIP(&NetDHCPServerIP, (popt+2));
722 case 58: /* Ignore Renewal Time Option */
724 case 59: /* Ignore Rebinding Time Option */
727 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
728 if (dhcp_vendorex_proc(popt))
731 printf("*** Unhandled DHCP Option in OFFER/ACK: %d\n",
735 popt += oplen + 2; /* Process next option */
739 static int DhcpMessageType(unsigned char *popt)
741 if (NetReadLong((ulong*)popt) != htonl(BOOTP_VENDOR_MAGIC))
745 while ( *popt != 0xff ) {
746 if ( *popt == 53 ) /* DHCP Message Type */
748 popt += *(popt + 1) + 2; /* Scan through all options */
753 static void DhcpSendRequestPkt(Bootp_t *bp_offer)
755 volatile uchar *pkt, *iphdr;
757 int pktlen, iplen, extlen;
760 debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
762 memset ((void*)pkt, 0, PKTSIZE);
764 NetSetEther(pkt, NetBcastAddr, PROT_IP);
765 pkt += ETHER_HDR_SIZE;
767 iphdr = pkt; /* We'll need this later to set proper pkt size */
771 bp->bp_op = OP_BOOTREQUEST;
772 bp->bp_htype = HWT_ETHER;
773 bp->bp_hlen = HWL_ETHER;
775 bp->bp_secs = htons(get_timer(0) / CFG_HZ);
776 NetCopyIP(&bp->bp_ciaddr, &bp_offer->bp_ciaddr); /* both in network byte order */
777 NetCopyIP(&bp->bp_yiaddr, &bp_offer->bp_yiaddr);
778 NetCopyIP(&bp->bp_siaddr, &bp_offer->bp_siaddr);
779 NetCopyIP(&bp->bp_giaddr, &bp_offer->bp_giaddr);
780 memcpy (bp->bp_chaddr, NetOurEther, 6);
783 * ID is the id of the OFFER packet
786 NetCopyLong(&bp->bp_id, &bp_offer->bp_id);
789 * Copy options from OFFER packet if present
791 NetCopyIP(&OfferedIP, &bp->bp_yiaddr);
792 extlen = DhcpExtended(bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
794 pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
795 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
796 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
798 debug ("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
799 NetSendPacket(NetTxPacket, pktlen);
803 * Handle DHCP received packets.
806 DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
808 Bootp_t *bp = (Bootp_t *)pkt;
810 debug ("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
811 src, dest, len, dhcp_state);
813 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
816 debug ("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
817 src, dest, len, dhcp_state);
819 switch (dhcp_state) {
822 * Wait an appropriate time for any potential DHCPOFFER packets
823 * to arrive. Then select one, and generate DHCPREQUEST response.
824 * If filename is in format we recognize, assume it is a valid
825 * OFFER from a server we want.
827 debug ("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
828 #ifdef CFG_BOOTFILE_PREFIX
829 if (strncmp(bp->bp_file,
831 strlen(CFG_BOOTFILE_PREFIX)) == 0 ) {
832 #endif /* CFG_BOOTFILE_PREFIX */
834 debug ("TRANSITIONING TO REQUESTING STATE\n");
835 dhcp_state = REQUESTING;
837 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
838 DhcpOptionsProcess(&bp->bp_vend[4]);
840 BootpCopyNetParams(bp); /* Store net params from reply */
842 NetSetTimeout(TIMEOUT * CFG_HZ, BootpTimeout);
843 DhcpSendRequestPkt(bp);
844 #ifdef CFG_BOOTFILE_PREFIX
846 #endif /* CFG_BOOTFILE_PREFIX */
851 debug ("DHCP State: REQUESTING\n");
853 if ( DhcpMessageType(bp->bp_vend) == DHCP_ACK ) {
856 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
857 DhcpOptionsProcess(&bp->bp_vend[4]);
858 BootpCopyNetParams(bp); /* Store net params from reply */
860 printf("DHCP client bound to address ");
861 print_IPaddr(NetOurIP);
864 /* Obey the 'autoload' setting */
865 if (((s = getenv("autoload")) != NULL) && (*s == 'n')) {
866 NetState = NETLOOP_SUCCESS;
869 /* Send ARP request to get TFTP server ethernet address.
870 * This automagically starts TFTP, too.
877 printf("DHCP: INVALID STATE\n");
883 void DhcpRequest(void)
887 #endif /* CFG_CMD_DHCP */
889 #endif /* CFG_CMD_NET */