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-2004 Wolfgang Denk, wd@denx.de
17 #ifdef CONFIG_STATUS_LED
18 #include <status_led.h>
21 #define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
23 #if defined(CONFIG_CMD_NET)
25 #define TIMEOUT 5000UL /* Milliseconds before trying BOOTP again */
26 #ifndef CONFIG_NET_RETRY_COUNT
27 # define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
29 # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
32 #define PORT_BOOTPS 67 /* BOOTP server UDP port */
33 #define PORT_BOOTPC 68 /* BOOTP client UDP port */
35 #ifndef CONFIG_DHCP_MIN_EXT_LEN /* minimal length of extension list */
36 #define CONFIG_DHCP_MIN_EXT_LEN 64
41 #ifdef CONFIG_BOOTP_RANDOM_DELAY
45 #if defined(CONFIG_CMD_DHCP)
46 dhcp_state_t dhcp_state = INIT;
47 unsigned long dhcp_leasetime = 0;
48 IPaddr_t NetDHCPServerIP = 0;
49 static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len);
53 static char *dhcpmsg2str(int type)
56 case 1: return "DHCPDISCOVER"; break;
57 case 2: return "DHCPOFFER"; break;
58 case 3: return "DHCPREQUEST"; break;
59 case 4: return "DHCPDECLINE"; break;
60 case 5: return "DHCPACK"; break;
61 case 6: return "DHCPNACK"; break;
62 case 7: return "DHCPRELEASE"; break;
63 default: return "UNKNOWN/INVALID MSG TYPE"; break;
68 #if defined(CONFIG_BOOTP_VENDOREX)
69 extern u8 *dhcp_vendorex_prep (u8 *e); /*rtn new e after add own opts. */
70 extern u8 *dhcp_vendorex_proc (u8 *e); /*rtn next e if mine,else NULL */
75 static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
77 Bootp_t *bp = (Bootp_t *) pkt;
80 if (dest != PORT_BOOTPC || src != PORT_BOOTPS)
82 else if (len < sizeof (Bootp_t) - OPT_SIZE)
84 else if (bp->bp_op != OP_BOOTREQUEST &&
85 bp->bp_op != OP_BOOTREPLY &&
86 bp->bp_op != DHCP_OFFER &&
87 bp->bp_op != DHCP_ACK &&
88 bp->bp_op != DHCP_NAK ) {
91 else if (bp->bp_htype != HWT_ETHER)
93 else if (bp->bp_hlen != HWL_ETHER)
95 else if (NetReadLong((ulong*)&bp->bp_id) != BootpID) {
99 debug("Filtering pkt = %d\n", retval);
105 * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet
107 static void BootpCopyNetParams(Bootp_t *bp)
111 NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
112 #if !defined(CONFIG_BOOTP_SERVERIP)
113 NetCopyIP(&tmp_ip, &bp->bp_siaddr);
115 NetCopyIP(&NetServerIP, &bp->bp_siaddr);
116 memcpy (NetServerEther, ((Ethernet_t *)NetRxPacket)->et_src, 6);
118 if (strlen(bp->bp_file) > 0)
119 copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
121 debug("Bootfile: %s\n", BootFile);
123 /* Propagate to environment:
124 * don't delete exising entry when BOOTP / DHCP reply does
125 * not contain a new value
128 setenv ("bootfile", BootFile);
132 static int truncate_sz (const char *name, int maxlen, int curlen)
134 if (curlen >= maxlen) {
135 printf("*** WARNING: %s is too long (%d - max: %d) - truncated\n",
136 name, curlen, maxlen);
142 #if !defined(CONFIG_CMD_DHCP)
144 static void BootpVendorFieldProcess (u8 * ext)
146 int size = *(ext + 1);
148 debug("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
154 /* Fixed length fields */
155 case 1: /* Subnet mask */
156 if (NetOurSubnetMask == 0)
157 NetCopyIP (&NetOurSubnetMask, (IPaddr_t *) (ext + 2));
159 case 2: /* Time offset - Not yet supported */
161 /* Variable length fields */
162 case 3: /* Gateways list */
163 if (NetOurGatewayIP == 0) {
164 NetCopyIP (&NetOurGatewayIP, (IPaddr_t *) (ext + 2));
167 case 4: /* Time server - Not yet supported */
169 case 5: /* IEN-116 name server - Not yet supported */
172 if (NetOurDNSIP == 0) {
173 NetCopyIP (&NetOurDNSIP, (IPaddr_t *) (ext + 2));
175 #if defined(CONFIG_BOOTP_DNS2)
176 if ((NetOurDNS2IP == 0) && (size > 4)) {
177 NetCopyIP (&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4));
181 case 7: /* Log server - Not yet supported */
183 case 8: /* Cookie/Quote server - Not yet supported */
185 case 9: /* LPR server - Not yet supported */
187 case 10: /* Impress server - Not yet supported */
189 case 11: /* RPL server - Not yet supported */
191 case 12: /* Host name */
192 if (NetOurHostName[0] == 0) {
193 size = truncate_sz ("Host Name", sizeof (NetOurHostName), size);
194 memcpy (&NetOurHostName, ext + 2, size);
195 NetOurHostName[size] = 0;
198 case 13: /* Boot file size */
200 NetBootFileSize = ntohs (*(ushort *) (ext + 2));
202 NetBootFileSize = ntohl (*(ulong *) (ext + 2));
204 case 14: /* Merit dump file - Not yet supported */
206 case 15: /* Domain name - Not yet supported */
208 case 16: /* Swap server - Not yet supported */
210 case 17: /* Root path */
211 if (NetOurRootPath[0] == 0) {
212 size = truncate_sz ("Root Path", sizeof (NetOurRootPath), size);
213 memcpy (&NetOurRootPath, ext + 2, size);
214 NetOurRootPath[size] = 0;
217 case 18: /* Extension path - Not yet supported */
219 * This can be used to send the information of the
220 * vendor area in another file that the client can
224 /* IP host layer fields */
225 case 40: /* NIS Domain name */
226 if (NetOurNISDomain[0] == 0) {
227 size = truncate_sz ("NIS Domain Name", sizeof (NetOurNISDomain), size);
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("[BOOTP] Checking extension (%d bytes)...\n", size);
249 while ((ext < end) && (*ext != 0xff)) {
257 BootpVendorFieldProcess (opt);
261 debug("[BOOTP] Received fields: \n");
262 if (NetOurSubnetMask)
263 debug("NetOurSubnetMask : %pI4\n", &NetOurSubnetMask);
266 debug("NetOurGatewayIP : %pI4", &NetOurGatewayIP);
269 debug("NetBootFileSize : %d\n", NetBootFileSize);
271 if (NetOurHostName[0])
272 debug("NetOurHostName : %s\n", NetOurHostName);
274 if (NetOurRootPath[0])
275 debug("NetOurRootPath : %s\n", NetOurRootPath);
277 if (NetOurNISDomain[0])
278 debug("NetOurNISDomain : %s\n", NetOurNISDomain);
281 debug("NetBootFileSize: %d\n", NetBootFileSize);
284 * Handle a BOOTP received packet.
287 BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
292 debug("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%zu)\n",
293 src, dest, len, sizeof (Bootp_t));
297 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
301 * Got a good BOOTP reply. Copy the data into our variables.
303 #ifdef CONFIG_STATUS_LED
304 status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
307 BootpCopyNetParams(bp); /* Store net parameters from reply */
309 /* Retrieve extended information (we must parse the vendor area) */
310 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
311 BootpVendorProcess((uchar *)&bp->bp_vend[4], len);
313 NetSetTimeout(0, (thand_f *)0);
315 debug("Got good BOOTP\n");
317 if ((s = getenv("autoload")) != NULL) {
320 * Just use BOOTP to configure system;
321 * Do not use TFTP to load the bootfile.
323 NetState = NETLOOP_SUCCESS;
325 #if defined(CONFIG_CMD_NFS)
326 } else if (strcmp(s, "NFS") == 0) {
328 * Use NFS to load the bootfile.
341 * Timeout on BOOTP/DHCP request.
346 if (BootpTry >= TIMEOUT_COUNT) {
347 puts ("\nRetry count exceeded; starting again\n");
350 NetSetTimeout (TIMEOUT, BootpTimeout);
356 * Initialize BOOTP extension fields in the request.
358 #if defined(CONFIG_CMD_DHCP)
359 static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP)
364 #if defined(CONFIG_BOOTP_VENDOREX)
367 #if defined(CONFIG_BOOTP_SEND_HOSTNAME)
371 *e++ = 99; /* RFC1048 Magic Cookie */
376 *e++ = 53; /* DHCP Message Type */
380 *e++ = 57; /* Maximum DHCP Message Size */
382 *e++ = (576 - 312 + OPT_SIZE) >> 8;
383 *e++ = (576 - 312 + OPT_SIZE) & 0xff;
386 int tmp = ntohl (ServerID);
388 *e++ = 54; /* ServerID */
397 int tmp = ntohl (RequestedIP);
399 *e++ = 50; /* Requested IP */
406 #if defined(CONFIG_BOOTP_SEND_HOSTNAME)
407 if ((hostname = getenv ("hostname"))) {
408 int hostnamelen = strlen (hostname);
410 *e++ = 12; /* Hostname */
412 memcpy (e, hostname, hostnamelen);
417 #if defined(CONFIG_BOOTP_VENDOREX)
418 if ((x = dhcp_vendorex_prep (e)))
422 *e++ = 55; /* Parameter Request List */
423 cnt = e++; /* Pointer to count of requested items */
425 #if defined(CONFIG_BOOTP_SUBNETMASK)
426 *e++ = 1; /* Subnet Mask */
429 #if defined(CONFIG_BOOTP_TIMEOFFSET)
433 #if defined(CONFIG_BOOTP_GATEWAY)
434 *e++ = 3; /* Router Option */
437 #if defined(CONFIG_BOOTP_DNS)
438 *e++ = 6; /* DNS Server(s) */
441 #if defined(CONFIG_BOOTP_HOSTNAME)
442 *e++ = 12; /* Hostname */
445 #if defined(CONFIG_BOOTP_BOOTFILESIZE)
446 *e++ = 13; /* Boot File Size */
449 #if defined(CONFIG_BOOTP_BOOTPATH)
450 *e++ = 17; /* Boot path */
453 #if defined(CONFIG_BOOTP_NISDOMAIN)
454 *e++ = 40; /* NIS Domain name request */
457 #if defined(CONFIG_BOOTP_NTPSERVER)
461 *e++ = 255; /* End of the list */
463 /* Pad to minimal length */
464 #ifdef CONFIG_DHCP_MIN_EXT_LEN
465 while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
474 * Warning: no field size check - change CONFIG_BOOTP_* at your own risk!
476 static int BootpExtended (u8 * e)
480 *e++ = 99; /* RFC1048 Magic Cookie */
485 #if defined(CONFIG_CMD_DHCP)
486 *e++ = 53; /* DHCP Message Type */
488 *e++ = DHCP_DISCOVER;
490 *e++ = 57; /* Maximum DHCP Message Size */
492 *e++ = (576 - 312 + OPT_SIZE) >> 16;
493 *e++ = (576 - 312 + OPT_SIZE) & 0xff;
496 #if defined(CONFIG_BOOTP_SUBNETMASK)
497 *e++ = 1; /* Subnet mask request */
502 #if defined(CONFIG_BOOTP_GATEWAY)
503 *e++ = 3; /* Default gateway request */
508 #if defined(CONFIG_BOOTP_DNS)
509 *e++ = 6; /* Domain Name Server */
514 #if defined(CONFIG_BOOTP_HOSTNAME)
515 *e++ = 12; /* Host name request */
520 #if defined(CONFIG_BOOTP_BOOTFILESIZE)
521 *e++ = 13; /* Boot file size */
526 #if defined(CONFIG_BOOTP_BOOTPATH)
527 *e++ = 17; /* Boot path */
532 #if defined(CONFIG_BOOTP_NISDOMAIN)
533 *e++ = 40; /* NIS Domain name request */
538 *e++ = 255; /* End of the list */
547 volatile uchar *pkt, *iphdr;
549 int ext_len, pktlen, iplen;
551 #if defined(CONFIG_CMD_DHCP)
555 #ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
556 unsigned char bi_enetaddr[6];
558 ulong tst1, tst2, sum, m_mask, m_value = 0;
562 eth_getenv_enetaddr("ethaddr", bi_enetaddr);
564 debug("BootpRequest => Our Mac: ");
565 for (reg=0; reg<6; reg++)
566 debug("%x%c", bi_enetaddr[reg], reg==5 ? '\n' : ':');
568 /* Mac-Manipulation 2 get seed1 */
571 for (reg=2; reg<6; reg++) {
573 tst1 = tst1 | bi_enetaddr[reg];
575 for (reg=0; reg<2; reg++) {
576 tst2 = tst2 | bi_enetaddr[reg];
584 for (reg=1;reg<=32;reg++) {
585 m_value |= (m_mask & seed1);
587 m_value = m_value << 1;
593 /* Random Number Generator */
595 for (reg=0;reg<=0;reg++) {
597 if (sum < seed1 || sum < seed2)
602 if (BootpTry<=2) { /* Start with max 1024 * 1ms */
603 sum = sum >> (22-BootpTry);
604 } else { /*After 3rd BOOTP request max 8192 * 1ms */
609 printf ("Random delay: %ld ms...\n", sum);
610 for (reg=0; reg <sum; reg++) {
611 udelay(1000); /*Wait 1ms*/
613 #endif /* CONFIG_BOOTP_RANDOM_DELAY */
615 printf("BOOTP broadcast %d\n", ++BootpTry);
617 memset ((void*)pkt, 0, PKTSIZE);
619 pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
622 * Next line results in incorrect packet size being transmitted, resulting
623 * in errors in some DHCP servers, reporting missing bytes. Size must be
624 * set in packet header after extension length has been determined.
625 * C. Hallinan, DS4.COM, Inc.
627 /* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, sizeof (Bootp_t)); */
628 iphdr = pkt; /* We need this later for NetSetIP() */
632 bp->bp_op = OP_BOOTREQUEST;
633 bp->bp_htype = HWT_ETHER;
634 bp->bp_hlen = HWL_ETHER;
636 bp->bp_secs = htons(get_timer(0) / 1000);
637 NetWriteIP(&bp->bp_ciaddr, 0);
638 NetWriteIP(&bp->bp_yiaddr, 0);
639 NetWriteIP(&bp->bp_siaddr, 0);
640 NetWriteIP(&bp->bp_giaddr, 0);
641 memcpy (bp->bp_chaddr, NetOurEther, 6);
642 copy_filename (bp->bp_file, BootFile, sizeof(bp->bp_file));
644 /* Request additional information from the BOOTP/DHCP server */
645 #if defined(CONFIG_CMD_DHCP)
646 ext_len = DhcpExtended((u8 *)bp->bp_vend, DHCP_DISCOVER, 0, 0);
648 ext_len = BootpExtended((u8 *)bp->bp_vend);
652 * Bootp ID is the lower 4 bytes of our ethernet address
653 * plus the current time in ms.
655 BootpID = ((ulong)NetOurEther[2] << 24)
656 | ((ulong)NetOurEther[3] << 16)
657 | ((ulong)NetOurEther[4] << 8)
658 | (ulong)NetOurEther[5];
659 BootpID += get_timer(0);
660 BootpID = htonl(BootpID);
661 NetCopyLong(&bp->bp_id, &BootpID);
664 * Calculate proper packet lengths taking into account the
665 * variable size of the options field
667 pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
668 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
669 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
670 NetSetTimeout(SELECT_TIMEOUT, BootpTimeout);
672 #if defined(CONFIG_CMD_DHCP)
673 dhcp_state = SELECTING;
674 NetSetHandler(DhcpHandler);
676 NetSetHandler(BootpHandler);
678 NetSendPacket(NetTxPacket, pktlen);
681 #if defined(CONFIG_CMD_DHCP)
682 static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
684 uchar *end = popt + BOOTP_HDR_SIZE;
687 while (popt < end && *popt != 0xff) {
691 NetCopyIP (&NetOurSubnetMask, (popt + 2));
693 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
694 case 2: /* Time offset */
695 NetCopyLong ((ulong *)&NetTimeOffset, (ulong *) (popt + 2));
696 NetTimeOffset = ntohl (NetTimeOffset);
700 NetCopyIP (&NetOurGatewayIP, (popt + 2));
703 NetCopyIP (&NetOurDNSIP, (popt + 2));
704 #if defined(CONFIG_BOOTP_DNS2)
705 if (*(popt + 1) > 4) {
706 NetCopyIP (&NetOurDNS2IP, (popt + 2 + 4));
711 size = truncate_sz ("Host Name", sizeof (NetOurHostName), oplen);
712 memcpy (&NetOurHostName, popt + 2, size);
713 NetOurHostName[size] = 0;
715 case 15: /* Ignore Domain Name Option */
718 size = truncate_sz ("Root Path", sizeof (NetOurRootPath), oplen);
719 memcpy (&NetOurRootPath, popt + 2, size);
720 NetOurRootPath[size] = 0;
722 #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
723 case 42: /* NTP server IP */
724 NetCopyIP (&NetNtpServerIP, (popt + 2));
728 NetCopyLong (&dhcp_leasetime, (ulong *) (popt + 2));
730 case 53: /* Ignore Message Type Option */
733 NetCopyIP (&NetDHCPServerIP, (popt + 2));
735 case 58: /* Ignore Renewal Time Option */
737 case 59: /* Ignore Rebinding Time Option */
739 case 66: /* Ignore TFTP server name */
741 case 67: /* vendor opt bootfile */
743 * I can't use dhcp_vendorex_proc here because I need
744 * to write into the bootp packet - even then I had to
745 * pass the bootp packet pointer into here as the
748 size = truncate_sz ("Opt Boot File",
751 if (bp->bp_file[0] == '\0' && size > 0) {
753 * only use vendor boot file if we didn't
754 * receive a boot file in the main non-vendor
755 * part of the packet - god only knows why
756 * some vendors chose not to use this perfectly
757 * good spot to store the boot file (join on
758 * Tru64 Unix) it seems mind bogglingly crazy
761 printf("*** WARNING: using vendor "
762 "optional boot file\n");
763 memcpy(bp->bp_file, popt + 2, size);
764 bp->bp_file[size] = '\0';
768 #if defined(CONFIG_BOOTP_VENDOREX)
769 if (dhcp_vendorex_proc (popt))
772 printf ("*** Unhandled DHCP Option in OFFER/ACK: %d\n", *popt);
775 popt += oplen + 2; /* Process next option */
779 static int DhcpMessageType(unsigned char *popt)
781 if (NetReadLong((ulong*)popt) != htonl(BOOTP_VENDOR_MAGIC))
785 while ( *popt != 0xff ) {
786 if ( *popt == 53 ) /* DHCP Message Type */
788 popt += *(popt + 1) + 2; /* Scan through all options */
793 static void DhcpSendRequestPkt(Bootp_t *bp_offer)
795 volatile uchar *pkt, *iphdr;
797 int pktlen, iplen, extlen;
800 debug("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
802 memset ((void*)pkt, 0, PKTSIZE);
804 pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
806 iphdr = pkt; /* We'll need this later to set proper pkt size */
810 bp->bp_op = OP_BOOTREQUEST;
811 bp->bp_htype = HWT_ETHER;
812 bp->bp_hlen = HWL_ETHER;
814 bp->bp_secs = htons(get_timer(0) / 1000);
815 /* Do not set the client IP, your IP, or server IP yet, since it hasn't been ACK'ed by
819 * RFC3046 requires Relay Agents to discard packets with
820 * nonzero and offered giaddr
822 NetWriteIP(&bp->bp_giaddr, 0);
824 memcpy (bp->bp_chaddr, NetOurEther, 6);
827 * ID is the id of the OFFER packet
830 NetCopyLong(&bp->bp_id, &bp_offer->bp_id);
833 * Copy options from OFFER packet if present
836 /* Copy offered IP into the parameters request list */
837 NetCopyIP(&OfferedIP, &bp_offer->bp_yiaddr);
838 extlen = DhcpExtended((u8 *)bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
840 pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
841 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
842 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
844 debug("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
845 #ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY
846 udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY);
847 #endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */
848 NetSendPacket(NetTxPacket, pktlen);
852 * Handle DHCP received packets.
855 DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
857 Bootp_t *bp = (Bootp_t *)pkt;
859 debug("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
860 src, dest, len, dhcp_state);
862 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
865 debug("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
866 src, dest, len, dhcp_state);
868 switch (dhcp_state) {
871 * Wait an appropriate time for any potential DHCPOFFER packets
872 * to arrive. Then select one, and generate DHCPREQUEST response.
873 * If filename is in format we recognize, assume it is a valid
874 * OFFER from a server we want.
876 debug("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
877 #ifdef CONFIG_SYS_BOOTFILE_PREFIX
878 if (strncmp(bp->bp_file,
879 CONFIG_SYS_BOOTFILE_PREFIX,
880 strlen(CONFIG_SYS_BOOTFILE_PREFIX)) == 0 ) {
881 #endif /* CONFIG_SYS_BOOTFILE_PREFIX */
883 debug("TRANSITIONING TO REQUESTING STATE\n");
884 dhcp_state = REQUESTING;
886 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
887 DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
889 NetSetTimeout(TIMEOUT, BootpTimeout);
890 DhcpSendRequestPkt(bp);
891 #ifdef CONFIG_SYS_BOOTFILE_PREFIX
893 #endif /* CONFIG_SYS_BOOTFILE_PREFIX */
898 debug("DHCP State: REQUESTING\n");
900 if ( DhcpMessageType((u8 *)bp->bp_vend) == DHCP_ACK ) {
903 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
904 DhcpOptionsProcess((u8 *)&bp->bp_vend[4], bp);
905 BootpCopyNetParams(bp); /* Store net params from reply */
907 printf ("DHCP client bound to address %pI4\n", &NetOurIP);
909 /* Obey the 'autoload' setting */
910 if ((s = getenv("autoload")) != NULL) {
913 * Just use BOOTP to configure system;
914 * Do not use TFTP to load the bootfile.
916 NetState = NETLOOP_SUCCESS;
918 #if defined(CONFIG_CMD_NFS)
919 } else if (strcmp(s, "NFS") == 0) {
921 * Use NFS to load the bootfile.
933 /* DHCP client bound to address */
936 puts ("DHCP: INVALID STATE\n");
942 void DhcpRequest(void)
946 #endif /* CONFIG_CMD_DHCP */
948 #endif /* CONFIG_CMD_NET */