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 int dhcp_leasetime = 0;
59 static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len);
63 static char *dhcpmsg2str(int type)
66 case 1: return "DHCPDISCOVER"; break;
67 case 2: return "DHCPOFFER"; break;
68 case 3: return "DHCPREQUEST"; break;
69 case 4: return "DHCPDECLINE"; break;
70 case 5: return "DHCPACK"; break;
71 case 6: return "DHCPNACK"; break;
72 case 7: return "DHCPRELEASE"; break;
73 default: return "UNKNOWN/INVALID MSG TYPE"; break;
78 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
79 extern u8 *dhcp_vendorex_prep (u8 *e); /*rtn new e after add own opts. */
80 extern u8 *dhcp_vendorex_proc (u8 *e); /*rtn next e if mine,else NULL */
83 #endif /* CFG_CMD_DHCP */
85 static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
87 Bootp_t *bp = (Bootp_t *) pkt;
90 if (dest != PORT_BOOTPC || src != PORT_BOOTPS)
92 else if (len < sizeof (Bootp_t) - OPT_SIZE)
94 else if (bp->bp_op != OP_BOOTREQUEST &&
95 bp->bp_op != OP_BOOTREPLY &&
96 bp->bp_op != DHCP_OFFER &&
97 bp->bp_op != DHCP_ACK &&
98 bp->bp_op != DHCP_NAK ) {
101 else if (bp->bp_htype != HWT_ETHER)
103 else if (bp->bp_hlen != HWL_ETHER)
105 else if (NetReadLong((ulong*)&bp->bp_id) != BootpID) {
109 debug ("Filtering pkt = %d\n", retval);
115 * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet
117 static void BootpCopyNetParams(Bootp_t *bp)
119 NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
120 NetCopyIP(&NetServerIP, &bp->bp_siaddr);
121 memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6);
122 copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
124 debug ("Bootfile: %s\n", BootFile);
126 /* Propagate to environment:
127 * don't delete exising entry when BOOTP / DHCP reply does
128 * not contain a new value
131 setenv ("bootfile", BootFile);
135 static int truncate_sz (const char *name, int maxlen, int curlen)
137 if (curlen >= maxlen) {
138 printf("*** WARNING: %s is too long (%d - max: %d) - truncated\n",
139 name, curlen, maxlen);
145 #if !(CONFIG_COMMANDS & CFG_CMD_DHCP)
147 static void BootpVendorFieldProcess(u8 *ext)
149 int size = *(ext+1) ;
151 debug_ext ("[BOOTP] Processing extension %d... (%d bytes)\n", *ext, *(ext+1));
156 /* Fixed length fields */
157 case 1: /* Subnet mask */
158 if (NetOurSubnetMask == 0)
159 NetCopyIP(&NetOurSubnetMask, (IPaddr_t*)(ext+2));
161 case 2: /* Time offset - Not yet supported */
163 /* Variable length fields */
164 case 3: /* Gateways list */
165 if (NetOurGatewayIP == 0) {
166 NetCopyIP(&NetOurGatewayIP, (IPaddr_t*)(ext+2));
169 case 4: /* Time server - Not yet supported */
171 case 5: /* IEN-116 name server - Not yet supported */
174 if (NetOurDNSIP == 0) {
175 NetCopyIP(&NetOurDNSIP, (IPaddr_t*)(ext+2));
178 case 7: /* Log server - Not yet supported */
180 case 8: /* Cookie/Quote server - Not yet supported */
182 case 9: /* LPR server - Not yet supported */
184 case 10: /* Impress server - Not yet supported */
186 case 11: /* RPL server - Not yet supported */
188 case 12: /* Host name */
189 if (NetOurHostName[0] == 0) {
190 size = truncate_sz("Host Name", sizeof(NetOurHostName), size);
191 memcpy(&NetOurHostName, ext+2, size);
192 NetOurHostName[size] = 0 ;
195 case 13: /* Boot file size */
197 NetBootFileSize = ntohs(*(ushort*)(ext+2));
199 NetBootFileSize = ntohl(*(ulong*)(ext+2));
201 case 14: /* Merit dump file - Not yet supported */
203 case 15: /* Domain name - Not yet supported */
205 case 16: /* Swap server - Not yet supported */
207 case 17: /* Root path */
208 if (NetOurRootPath[0] == 0) {
209 size = truncate_sz("Root Path", sizeof(NetOurRootPath), size);
210 memcpy(&NetOurRootPath, ext+2, size);
211 NetOurRootPath[size] = 0 ;
214 case 18: /* Extension path - Not yet supported */
216 * This can be used to send the information of the
217 * vendor area in another file that the client can
221 /* IP host layer fields */
222 case 40: /* NIS Domain name */
223 if (NetOurNISDomain[0] == 0) {
224 size = truncate_sz ("NIS Domain Name",
225 sizeof(NetOurNISDomain),
227 memcpy(&NetOurNISDomain, ext+2, size);
228 NetOurNISDomain[size] = 0 ;
231 /* Application layer fields */
232 case 43: /* Vendor specific info - Not yet supported */
234 * Binary information to exchange specific
235 * product information.
238 /* Reserved (custom) fields (128..254) */
242 static void BootpVendorProcess(u8 *ext, int size)
244 u8 *end = ext + size ;
246 debug_ext ("[BOOTP] Checking extension (%d bytes)...\n", size);
248 while ((ext < end) && (*ext != 0xff)) {
255 BootpVendorFieldProcess (opt) ;
259 #ifdef DEBUG_BOOTP_EXT
260 printf("[BOOTP] Received fields: \n");
261 if (NetOurSubnetMask) {
262 puts ("NetOurSubnetMask : ");
263 print_IPaddr (NetOurSubnetMask);
267 if (NetOurGatewayIP) {
268 puts ("NetOurGatewayIP : ");
269 print_IPaddr (NetOurGatewayIP);
273 if (NetBootFileSize) {
274 printf("NetBootFileSize : %d\n", NetBootFileSize);
277 if (NetOurHostName[0]) {
278 printf("NetOurHostName : %s\n", NetOurHostName);
281 if (NetOurRootPath[0]) {
282 printf("NetOurRootPath : %s\n", NetOurRootPath);
285 if (NetOurNISDomain[0]) {
286 printf("NetOurNISDomain : %s\n", NetOurNISDomain);
289 if (NetBootFileSize) {
290 printf("NetBootFileSize: %d\n", NetBootFileSize);
292 #endif /* DEBUG_BOOTP_EXT */
296 * Handle a BOOTP received packet.
299 BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
304 debug ("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%d)\n",
305 src, dest, len, sizeof (Bootp_t));
309 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
313 * Got a good BOOTP reply. Copy the data into our variables.
315 #ifdef CONFIG_STATUS_LED
316 status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
319 BootpCopyNetParams(bp); /* Store net parameters from reply */
321 /* Retrieve extended information (we must parse the vendor area) */
322 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
323 BootpVendorProcess(&bp->bp_vend[4], len);
325 NetSetTimeout(0, (thand_f *)0);
327 debug ("Got good BOOTP\n");
329 if (((s = getenv("autoload")) != NULL) && (*s == 'n')) {
331 * Just use BOOTP to configure system;
332 * Do not use TFTP to load the bootfile.
334 NetState = NETLOOP_SUCCESS;
338 /* Send ARP request to get TFTP server ethernet address.
339 * This automagically starts TFTP, too.
343 #endif /* !CFG_CMD_DHCP */
346 * Timeout on BOOTP/DHCP request.
351 if (BootpTry >= TIMEOUT_COUNT) {
352 puts ("\nRetry count exceeded; starting again\n");
355 NetSetTimeout (TIMEOUT * CFG_HZ, BootpTimeout);
361 * Initialize BOOTP extension fields in the request.
363 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
364 static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP)
368 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
372 *e++ = 99; /* RFC1048 Magic Cookie */
377 *e++ = 53; /* DHCP Message Type */
381 *e++ = 57; /* Maximum DHCP Message Size */
383 *e++ = (576-312+OPT_SIZE) >> 8;
384 *e++ = (576-312+OPT_SIZE) & 0xff;
387 int tmp = ntohl(ServerID);
389 *e++ = 54; /* ServerID */
398 int tmp = ntohl(RequestedIP);
400 *e++ = 50; /* Requested IP */
408 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
409 if ((x = dhcp_vendorex_prep (e)))
413 *e++ = 55; /* Parameter Request List */
414 cnt = e++; /* Pointer to count of requested items */
416 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
417 *e++ = 1; /* Subnet Mask */
420 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
421 *e++ = 3; /* Router Option */
424 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
425 *e++ = 6; /* DNS Server(s) */
428 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
429 *e++ = 12; /* Hostname */
432 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
433 *e++ = 13; /* Boot File Size */
436 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
437 *e++ = 17; /* Boot path */
440 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
441 *e++ = 40; /* NIS Domain name request */
444 *e++ = 255; /* End of the list */
446 /* Pad to minimal length */
447 #ifdef CONFIG_DHCP_MIN_EXT_LEN
448 while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
455 #else /* CFG_CMD_DHCP */
457 * Warning: no field size check - change CONFIG_BOOTP_MASK at your own risk!
459 static int BootpExtended (u8 *e)
463 *e++ = 99; /* RFC1048 Magic Cookie */
468 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
469 *e++ = 53; /* DHCP Message Type */
471 *e++ = DHCP_DISCOVER;
473 *e++ = 57; /* Maximum DHCP Message Size */
475 *e++ = (576-312+OPT_SIZE) >> 16;
476 *e++ = (576-312+OPT_SIZE) & 0xff;
477 #endif /* CFG_CMD_DHCP */
479 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
480 *e++ = 1; /* Subnet mask request */
485 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
486 *e++ = 3; /* Default gateway request */
491 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
492 *e++ = 6; /* Domain Name Server */
497 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
498 *e++ = 12; /* Host name request */
503 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
504 *e++ = 13; /* Boot file size */
509 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
510 *e++ = 17; /* Boot path */
515 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
516 *e++ = 40; /* NIS Domain name request */
521 *e++ = 255; /* End of the list */
525 #endif /* CFG_CMD_DHCP */
530 volatile uchar *pkt, *iphdr;
532 int ext_len, pktlen, iplen;
534 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
538 #ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
539 unsigned char bi_enetaddr[6];
543 ulong tst1, tst2, sum, m_mask, m_value = 0;
547 reg = getenv_r ("ethaddr", tmp, sizeof(tmp));
548 s = (reg > 0) ? tmp : NULL;
550 for (reg=0; reg<6; ++reg) {
551 bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
557 printf("BootpRequest => Our Mac: ");
558 for (reg=0; reg<6; reg++) {
561 reg==5 ? '\n' : ':');
565 /* Mac-Manipulation 2 get seed1 */
568 for (reg=2; reg<6; reg++) {
570 tst1 = tst1 | bi_enetaddr[reg];
572 for (reg=0; reg<2; reg++) {
573 tst2 = tst2 | bi_enetaddr[reg];
581 for (reg=1;reg<=32;reg++) {
582 m_value |= (m_mask & seed1);
584 m_value = m_value << 1;
590 /* Random Number Generator */
592 for (reg=0;reg<=0;reg++) {
594 if (sum < seed1 || sum < seed2)
599 if (BootpTry<=2) { /* Start with max 1024 * 1ms */
600 sum = sum >> (22-BootpTry);
601 } else { /*After 3rd BOOTP request max 8192 * 1ms */
606 printf ("Random delay: %ld ms...\n", sum);
607 for (reg=0; reg <sum; reg++) {
608 udelay(1000); /*Wait 1ms*/
610 #endif /* CONFIG_BOOTP_RANDOM_DELAY */
612 printf("BOOTP broadcast %d\n", ++BootpTry);
614 memset ((void*)pkt, 0, PKTSIZE);
616 NetSetEther(pkt, NetBcastAddr, PROT_IP);
617 pkt += ETHER_HDR_SIZE;
620 * Next line results in incorrect packet size being transmitted, resulting
621 * in errors in some DHCP servers, reporting missing bytes. Size must be
622 * set in packet header after extension length has been determined.
623 * C. Hallinan, DS4.COM, Inc.
625 /* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, sizeof (Bootp_t)); */
626 iphdr = pkt; /* We need this later for NetSetIP() */
630 bp->bp_op = OP_BOOTREQUEST;
631 bp->bp_htype = HWT_ETHER;
632 bp->bp_hlen = HWL_ETHER;
634 bp->bp_secs = htons(get_timer(0) / CFG_HZ);
635 NetWriteIP(&bp->bp_ciaddr, 0);
636 NetWriteIP(&bp->bp_yiaddr, 0);
637 NetWriteIP(&bp->bp_siaddr, 0);
638 NetWriteIP(&bp->bp_giaddr, 0);
639 memcpy (bp->bp_chaddr, NetOurEther, 6);
640 copy_filename (bp->bp_file, BootFile, sizeof(bp->bp_file));
642 /* Request additional information from the BOOTP/DHCP server */
643 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
644 ext_len = DhcpExtended(bp->bp_vend, DHCP_DISCOVER, 0, 0);
646 ext_len = BootpExtended(bp->bp_vend);
647 #endif /* CFG_CMD_DHCP */
650 * Bootp ID is the lower 4 bytes of our ethernet address
651 * plus the current time in HZ.
653 BootpID = ((ulong)NetOurEther[2] << 24)
654 | ((ulong)NetOurEther[3] << 16)
655 | ((ulong)NetOurEther[4] << 8)
656 | (ulong)NetOurEther[5];
657 BootpID += get_timer(0);
658 BootpID = htonl(BootpID);
659 NetCopyLong(&bp->bp_id, &BootpID);
662 * Calculate proper packet lengths taking into account the
663 * variable size of the options field
665 pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + ext_len;
666 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
667 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
668 NetSetTimeout(SELECT_TIMEOUT * CFG_HZ, BootpTimeout);
670 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
671 dhcp_state = SELECTING;
672 NetSetHandler(DhcpHandler);
674 NetSetHandler(BootpHandler);
675 #endif /* CFG_CMD_DHCP */
676 NetSendPacket(NetTxPacket, pktlen);
679 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
680 static void DhcpOptionsProcess(uchar *popt)
682 uchar *end = popt + BOOTP_HDR_SIZE;
685 while ( popt < end && *popt != 0xff ) {
689 NetCopyIP(&NetOurSubnetMask, (popt+2));
692 NetCopyIP(&NetOurGatewayIP, (popt+2));
695 NetCopyIP(&NetOurDNSIP, (popt+2));
698 size = truncate_sz ("Host Name",
699 sizeof(NetOurHostName),
701 memcpy(&NetOurHostName, popt+2, size);
702 NetOurHostName[size] = 0 ;
704 case 15: /* Ignore Domain Name Option */
707 size = truncate_sz ("Root Path",
708 sizeof(NetOurRootPath),
710 memcpy(&NetOurRootPath, popt+2, size);
711 NetOurRootPath[size] = 0 ;
714 dhcp_leasetime = *(unsigned int *)(popt + 2);
716 case 53: /* Ignore Message Type Option */
719 NetCopyIP(&NetServerIP, (popt+2));
721 case 58: /* Ignore Renewal Time Option */
723 case 59: /* Ignore Rebinding Time Option */
726 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
727 if (dhcp_vendorex_proc(popt))
730 printf("*** Unhandled DHCP Option in OFFER/ACK: %d\n",
734 popt += oplen + 2; /* Process next option */
738 static int DhcpMessageType(unsigned char *popt)
740 if (NetReadLong((ulong*)popt) != htonl(BOOTP_VENDOR_MAGIC))
744 while ( *popt != 0xff ) {
745 if ( *popt == 53 ) /* DHCP Message Type */
747 popt += *(popt + 1) + 2; /* Scan through all options */
752 static void DhcpSendRequestPkt(Bootp_t *bp_offer)
754 volatile uchar *pkt, *iphdr;
756 int pktlen, iplen, extlen;
759 debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
761 memset ((void*)pkt, 0, PKTSIZE);
763 NetSetEther(pkt, NetBcastAddr, PROT_IP);
764 pkt += ETHER_HDR_SIZE;
766 iphdr = pkt; /* We'll need this later to set proper pkt size */
770 bp->bp_op = OP_BOOTREQUEST;
771 bp->bp_htype = HWT_ETHER;
772 bp->bp_hlen = HWL_ETHER;
774 bp->bp_secs = htons(get_timer(0) / CFG_HZ);
775 NetCopyIP(&bp->bp_ciaddr, &bp_offer->bp_ciaddr); /* both in network byte order */
776 NetCopyIP(&bp->bp_yiaddr, &bp_offer->bp_yiaddr);
777 NetCopyIP(&bp->bp_siaddr, &bp_offer->bp_siaddr);
778 NetCopyIP(&bp->bp_giaddr, &bp_offer->bp_giaddr);
779 memcpy (bp->bp_chaddr, NetOurEther, 6);
782 * ID is the id of the OFFER packet
785 NetCopyLong(&bp->bp_id, &bp_offer->bp_id);
788 * Copy options from OFFER packet if present
790 NetCopyIP(&OfferedIP, &bp->bp_yiaddr);
791 extlen = DhcpExtended(bp->bp_vend, DHCP_REQUEST, NetServerIP, OfferedIP);
793 pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
794 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
795 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
797 debug ("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
798 NetSendPacket(NetTxPacket, pktlen);
802 * Handle DHCP received packets.
805 DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
807 Bootp_t *bp = (Bootp_t *)pkt;
809 debug ("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
810 src, dest, len, dhcp_state);
812 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
815 debug ("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
816 src, dest, len, dhcp_state);
818 switch (dhcp_state) {
821 * Wait an appropriate time for any potential DHCPOFFER packets
822 * to arrive. Then select one, and generate DHCPREQUEST response.
823 * If filename is in format we recognize, assume it is a valid
824 * OFFER from a server we want.
826 debug ("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
827 #ifdef CFG_BOOTFILE_PREFIX
828 if (strncmp(bp->bp_file,
830 strlen(CFG_BOOTFILE_PREFIX)) == 0 ) {
831 #endif /* CFG_BOOTFILE_PREFIX */
833 debug ("TRANSITIONING TO REQUESTING STATE\n");
834 dhcp_state = REQUESTING;
836 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
837 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 */