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...)
27 #ifdef CONFIG_STATUS_LED
28 #include <status_led.h>
31 #define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
33 #if (CONFIG_COMMANDS & CFG_CMD_NET)
35 #define TIMEOUT 5 /* Seconds before trying BOOTP again */
36 #ifndef CONFIG_NET_RETRY_COUNT
37 # define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
39 # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
42 #define PORT_BOOTPS 67 /* BOOTP server UDP port */
43 #define PORT_BOOTPC 68 /* BOOTP client UDP port */
45 #ifndef CONFIG_DHCP_MIN_EXT_LEN /* minimal length of extension list */
46 #define CONFIG_DHCP_MIN_EXT_LEN 64
51 #ifdef CONFIG_BOOTP_RANDOM_DELAY
55 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
56 dhcp_state_t dhcp_state = INIT;
57 unsigned long dhcp_leasetime = 0;
58 IPaddr_t NetDHCPServerIP = 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));
177 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
178 if ((NetOurDNS2IP == 0) && (size > 4)) {
179 NetCopyIP(&NetOurDNS2IP, (IPaddr_t*)(ext+2+4));
183 case 7: /* Log server - Not yet supported */
185 case 8: /* Cookie/Quote server - Not yet supported */
187 case 9: /* LPR server - Not yet supported */
189 case 10: /* Impress server - Not yet supported */
191 case 11: /* RPL server - Not yet supported */
193 case 12: /* Host name */
194 if (NetOurHostName[0] == 0) {
195 size = truncate_sz("Host Name", sizeof(NetOurHostName), size);
196 memcpy(&NetOurHostName, ext+2, size);
197 NetOurHostName[size] = 0 ;
200 case 13: /* Boot file size */
202 NetBootFileSize = ntohs(*(ushort*)(ext+2));
204 NetBootFileSize = ntohl(*(ulong*)(ext+2));
206 case 14: /* Merit dump file - Not yet supported */
208 case 15: /* Domain name - Not yet supported */
210 case 16: /* Swap server - Not yet supported */
212 case 17: /* Root path */
213 if (NetOurRootPath[0] == 0) {
214 size = truncate_sz("Root Path", sizeof(NetOurRootPath), size);
215 memcpy(&NetOurRootPath, ext+2, size);
216 NetOurRootPath[size] = 0 ;
219 case 18: /* Extension path - Not yet supported */
221 * This can be used to send the information of the
222 * vendor area in another file that the client can
226 /* IP host layer fields */
227 case 40: /* NIS Domain name */
228 if (NetOurNISDomain[0] == 0) {
229 size = truncate_sz ("NIS Domain Name",
230 sizeof(NetOurNISDomain),
232 memcpy(&NetOurNISDomain, ext+2, size);
233 NetOurNISDomain[size] = 0 ;
236 /* Application layer fields */
237 case 43: /* Vendor specific info - Not yet supported */
239 * Binary information to exchange specific
240 * product information.
243 /* Reserved (custom) fields (128..254) */
247 static void BootpVendorProcess(u8 *ext, int size)
249 u8 *end = ext + size ;
251 debug_ext ("[BOOTP] Checking extension (%d bytes)...\n", size);
253 while ((ext < end) && (*ext != 0xff)) {
260 BootpVendorFieldProcess (opt) ;
264 #ifdef DEBUG_BOOTP_EXT
265 printf("[BOOTP] Received fields: \n");
266 if (NetOurSubnetMask) {
267 puts ("NetOurSubnetMask : ");
268 print_IPaddr (NetOurSubnetMask);
272 if (NetOurGatewayIP) {
273 puts ("NetOurGatewayIP : ");
274 print_IPaddr (NetOurGatewayIP);
278 if (NetBootFileSize) {
279 printf("NetBootFileSize : %d\n", NetBootFileSize);
282 if (NetOurHostName[0]) {
283 printf("NetOurHostName : %s\n", NetOurHostName);
286 if (NetOurRootPath[0]) {
287 printf("NetOurRootPath : %s\n", NetOurRootPath);
290 if (NetOurNISDomain[0]) {
291 printf("NetOurNISDomain : %s\n", NetOurNISDomain);
294 if (NetBootFileSize) {
295 printf("NetBootFileSize: %d\n", NetBootFileSize);
297 #endif /* DEBUG_BOOTP_EXT */
301 * Handle a BOOTP received packet.
304 BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
309 debug ("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%d)\n",
310 src, dest, len, sizeof (Bootp_t));
314 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
318 * Got a good BOOTP reply. Copy the data into our variables.
320 #ifdef CONFIG_STATUS_LED
321 status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
324 BootpCopyNetParams(bp); /* Store net parameters from reply */
326 /* Retrieve extended information (we must parse the vendor area) */
327 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
328 BootpVendorProcess(&bp->bp_vend[4], len);
330 NetSetTimeout(0, (thand_f *)0);
332 debug ("Got good BOOTP\n");
334 if (((s = getenv("autoload")) != NULL) && (*s == 'n')) {
336 * Just use BOOTP to configure system;
337 * Do not use TFTP to load the bootfile.
339 NetState = NETLOOP_SUCCESS;
345 #endif /* !CFG_CMD_DHCP */
348 * Timeout on BOOTP/DHCP request.
353 if (BootpTry >= TIMEOUT_COUNT) {
354 puts ("\nRetry count exceeded; starting again\n");
357 NetSetTimeout (TIMEOUT * CFG_HZ, BootpTimeout);
363 * Initialize BOOTP extension fields in the request.
365 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
366 static int DhcpExtended(u8 *e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP)
370 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
373 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SEND_HOSTNAME)
377 *e++ = 99; /* RFC1048 Magic Cookie */
382 *e++ = 53; /* DHCP Message Type */
386 *e++ = 57; /* Maximum DHCP Message Size */
388 *e++ = (576-312+OPT_SIZE) >> 8;
389 *e++ = (576-312+OPT_SIZE) & 0xff;
392 int tmp = ntohl(ServerID);
394 *e++ = 54; /* ServerID */
403 int tmp = ntohl(RequestedIP);
405 *e++ = 50; /* Requested IP */
413 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SEND_HOSTNAME)
414 if ( (hostname = getenv("hostname")) ) {
415 int hostnamelen = strlen(hostname);
416 *e++ = 12; /* Hostname */
418 memcpy(e,hostname,hostnamelen);
423 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
424 if ((x = dhcp_vendorex_prep (e)))
428 *e++ = 55; /* Parameter Request List */
429 cnt = e++; /* Pointer to count of requested items */
431 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
432 *e++ = 1; /* Subnet Mask */
435 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
436 *e++ = 3; /* Router Option */
439 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
440 *e++ = 6; /* DNS Server(s) */
443 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
444 *e++ = 12; /* Hostname */
447 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
448 *e++ = 13; /* Boot File Size */
451 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
452 *e++ = 17; /* Boot path */
455 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
456 *e++ = 40; /* NIS Domain name request */
459 *e++ = 255; /* End of the list */
461 /* Pad to minimal length */
462 #ifdef CONFIG_DHCP_MIN_EXT_LEN
463 while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
470 #else /* CFG_CMD_DHCP */
472 * Warning: no field size check - change CONFIG_BOOTP_MASK at your own risk!
474 static int BootpExtended (u8 *e)
478 *e++ = 99; /* RFC1048 Magic Cookie */
483 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
484 *e++ = 53; /* DHCP Message Type */
486 *e++ = DHCP_DISCOVER;
488 *e++ = 57; /* Maximum DHCP Message Size */
490 *e++ = (576-312+OPT_SIZE) >> 16;
491 *e++ = (576-312+OPT_SIZE) & 0xff;
492 #endif /* CFG_CMD_DHCP */
494 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
495 *e++ = 1; /* Subnet mask request */
500 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
501 *e++ = 3; /* Default gateway request */
506 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
507 *e++ = 6; /* Domain Name Server */
512 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
513 *e++ = 12; /* Host name request */
518 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
519 *e++ = 13; /* Boot file size */
524 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
525 *e++ = 17; /* Boot path */
530 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
531 *e++ = 40; /* NIS Domain name request */
536 *e++ = 255; /* End of the list */
540 #endif /* CFG_CMD_DHCP */
545 volatile uchar *pkt, *iphdr;
547 int ext_len, pktlen, iplen;
549 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
553 #ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
554 unsigned char bi_enetaddr[6];
558 ulong tst1, tst2, sum, m_mask, m_value = 0;
562 reg = getenv_r ("ethaddr", tmp, sizeof(tmp));
563 s = (reg > 0) ? tmp : NULL;
565 for (reg=0; reg<6; ++reg) {
566 bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
572 printf("BootpRequest => Our Mac: ");
573 for (reg=0; reg<6; reg++) {
576 reg==5 ? '\n' : ':');
580 /* Mac-Manipulation 2 get seed1 */
583 for (reg=2; reg<6; reg++) {
585 tst1 = tst1 | bi_enetaddr[reg];
587 for (reg=0; reg<2; reg++) {
588 tst2 = tst2 | bi_enetaddr[reg];
596 for (reg=1;reg<=32;reg++) {
597 m_value |= (m_mask & seed1);
599 m_value = m_value << 1;
605 /* Random Number Generator */
607 for (reg=0;reg<=0;reg++) {
609 if (sum < seed1 || sum < seed2)
614 if (BootpTry<=2) { /* Start with max 1024 * 1ms */
615 sum = sum >> (22-BootpTry);
616 } else { /*After 3rd BOOTP request max 8192 * 1ms */
621 printf ("Random delay: %ld ms...\n", sum);
622 for (reg=0; reg <sum; reg++) {
623 udelay(1000); /*Wait 1ms*/
625 #endif /* CONFIG_BOOTP_RANDOM_DELAY */
627 printf("BOOTP broadcast %d\n", ++BootpTry);
629 memset ((void*)pkt, 0, PKTSIZE);
631 NetSetEther(pkt, NetBcastAddr, PROT_IP);
632 pkt += ETHER_HDR_SIZE;
635 * Next line results in incorrect packet size being transmitted, resulting
636 * in errors in some DHCP servers, reporting missing bytes. Size must be
637 * set in packet header after extension length has been determined.
638 * C. Hallinan, DS4.COM, Inc.
640 /* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, sizeof (Bootp_t)); */
641 iphdr = pkt; /* We need this later for NetSetIP() */
645 bp->bp_op = OP_BOOTREQUEST;
646 bp->bp_htype = HWT_ETHER;
647 bp->bp_hlen = HWL_ETHER;
649 bp->bp_secs = htons(get_timer(0) / CFG_HZ);
650 NetWriteIP(&bp->bp_ciaddr, 0);
651 NetWriteIP(&bp->bp_yiaddr, 0);
652 NetWriteIP(&bp->bp_siaddr, 0);
653 NetWriteIP(&bp->bp_giaddr, 0);
654 memcpy (bp->bp_chaddr, NetOurEther, 6);
655 copy_filename (bp->bp_file, BootFile, sizeof(bp->bp_file));
657 /* Request additional information from the BOOTP/DHCP server */
658 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
659 ext_len = DhcpExtended(bp->bp_vend, DHCP_DISCOVER, 0, 0);
661 ext_len = BootpExtended(bp->bp_vend);
662 #endif /* CFG_CMD_DHCP */
665 * Bootp ID is the lower 4 bytes of our ethernet address
666 * plus the current time in HZ.
668 BootpID = ((ulong)NetOurEther[2] << 24)
669 | ((ulong)NetOurEther[3] << 16)
670 | ((ulong)NetOurEther[4] << 8)
671 | (ulong)NetOurEther[5];
672 BootpID += get_timer(0);
673 BootpID = htonl(BootpID);
674 NetCopyLong(&bp->bp_id, &BootpID);
677 * Calculate proper packet lengths taking into account the
678 * variable size of the options field
680 pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + ext_len;
681 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
682 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
683 NetSetTimeout(SELECT_TIMEOUT * CFG_HZ, BootpTimeout);
685 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
686 dhcp_state = SELECTING;
687 NetSetHandler(DhcpHandler);
689 NetSetHandler(BootpHandler);
690 #endif /* CFG_CMD_DHCP */
691 NetSendPacket(NetTxPacket, pktlen);
694 #if (CONFIG_COMMANDS & CFG_CMD_DHCP)
695 static void DhcpOptionsProcess(uchar *popt)
697 uchar *end = popt + BOOTP_HDR_SIZE;
700 while ( popt < end && *popt != 0xff ) {
704 NetCopyIP(&NetOurSubnetMask, (popt+2));
707 NetCopyIP(&NetOurGatewayIP, (popt+2));
710 NetCopyIP(&NetOurDNSIP, (popt+2));
711 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
712 if ( *(popt+1) > 4 ) {
713 NetCopyIP(&NetOurDNS2IP, (popt+2+4));
718 size = truncate_sz ("Host Name",
719 sizeof(NetOurHostName),
721 memcpy(&NetOurHostName, popt+2, size);
722 NetOurHostName[size] = 0 ;
724 case 15: /* Ignore Domain Name Option */
727 size = truncate_sz ("Root Path",
728 sizeof(NetOurRootPath),
730 memcpy(&NetOurRootPath, popt+2, size);
731 NetOurRootPath[size] = 0 ;
734 NetCopyLong (&dhcp_leasetime, (ulong *)(popt + 2));
736 case 53: /* Ignore Message Type Option */
739 NetCopyIP(&NetDHCPServerIP, (popt+2));
741 case 58: /* Ignore Renewal Time Option */
743 case 59: /* Ignore Rebinding Time Option */
746 #if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
747 if (dhcp_vendorex_proc(popt))
750 printf("*** Unhandled DHCP Option in OFFER/ACK: %d\n",
754 popt += oplen + 2; /* Process next option */
758 static int DhcpMessageType(unsigned char *popt)
760 if (NetReadLong((ulong*)popt) != htonl(BOOTP_VENDOR_MAGIC))
764 while ( *popt != 0xff ) {
765 if ( *popt == 53 ) /* DHCP Message Type */
767 popt += *(popt + 1) + 2; /* Scan through all options */
772 static void DhcpSendRequestPkt(Bootp_t *bp_offer)
774 volatile uchar *pkt, *iphdr;
776 int pktlen, iplen, extlen;
779 debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
781 memset ((void*)pkt, 0, PKTSIZE);
783 NetSetEther(pkt, NetBcastAddr, PROT_IP);
784 pkt += ETHER_HDR_SIZE;
786 iphdr = pkt; /* We'll need this later to set proper pkt size */
790 bp->bp_op = OP_BOOTREQUEST;
791 bp->bp_htype = HWT_ETHER;
792 bp->bp_hlen = HWL_ETHER;
794 bp->bp_secs = htons(get_timer(0) / CFG_HZ);
795 NetCopyIP(&bp->bp_ciaddr, &bp_offer->bp_ciaddr); /* both in network byte order */
796 NetCopyIP(&bp->bp_yiaddr, &bp_offer->bp_yiaddr);
797 NetCopyIP(&bp->bp_siaddr, &bp_offer->bp_siaddr);
798 NetCopyIP(&bp->bp_giaddr, &bp_offer->bp_giaddr);
799 memcpy (bp->bp_chaddr, NetOurEther, 6);
802 * ID is the id of the OFFER packet
805 NetCopyLong(&bp->bp_id, &bp_offer->bp_id);
808 * Copy options from OFFER packet if present
810 NetCopyIP(&OfferedIP, &bp->bp_yiaddr);
811 extlen = DhcpExtended(bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
813 pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
814 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
815 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
817 debug ("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
818 NetSendPacket(NetTxPacket, pktlen);
822 * Handle DHCP received packets.
825 DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
827 Bootp_t *bp = (Bootp_t *)pkt;
829 debug ("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
830 src, dest, len, dhcp_state);
832 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
835 debug ("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
836 src, dest, len, dhcp_state);
838 switch (dhcp_state) {
841 * Wait an appropriate time for any potential DHCPOFFER packets
842 * to arrive. Then select one, and generate DHCPREQUEST response.
843 * If filename is in format we recognize, assume it is a valid
844 * OFFER from a server we want.
846 debug ("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
847 #ifdef CFG_BOOTFILE_PREFIX
848 if (strncmp(bp->bp_file,
850 strlen(CFG_BOOTFILE_PREFIX)) == 0 ) {
851 #endif /* CFG_BOOTFILE_PREFIX */
853 debug ("TRANSITIONING TO REQUESTING STATE\n");
854 dhcp_state = REQUESTING;
856 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
857 DhcpOptionsProcess(&bp->bp_vend[4]);
859 BootpCopyNetParams(bp); /* Store net params from reply */
861 NetSetTimeout(TIMEOUT * CFG_HZ, BootpTimeout);
862 DhcpSendRequestPkt(bp);
863 #ifdef CFG_BOOTFILE_PREFIX
865 #endif /* CFG_BOOTFILE_PREFIX */
870 debug ("DHCP State: REQUESTING\n");
872 if ( DhcpMessageType(bp->bp_vend) == DHCP_ACK ) {
875 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
876 DhcpOptionsProcess(&bp->bp_vend[4]);
877 BootpCopyNetParams(bp); /* Store net params from reply */
879 printf("DHCP client bound to address ");
880 print_IPaddr(NetOurIP);
883 /* Obey the 'autoload' setting */
884 if (((s = getenv("autoload")) != NULL) && (*s == 'n')) {
885 NetState = NETLOOP_SUCCESS;
893 printf("DHCP: INVALID STATE\n");
899 void DhcpRequest(void)
903 #endif /* CFG_CMD_DHCP */
905 #endif /* CFG_CMD_NET */