blob: 4bca50d75d76512b750a666b4fe615b383937343 [file] [log] [blame]
wdenk3861aa52002-09-27 23:19:37 +00001/*
2 * Based on LiMon - BOOTP.
3 *
4 * Copyright 1994, 1995, 2000 Neil Russell.
5 * (See License)
6 * Copyright 2000 Roland Borde
7 * Copyright 2000 Paolo Scaffardi
wdenk232c1502004-03-12 00:14:09 +00008 * Copyright 2000-2004 Wolfgang Denk, wd@denx.de
wdenk3861aa52002-09-27 23:19:37 +00009 */
10
11#if 0
wdenk232c1502004-03-12 00:14:09 +000012#define DEBUG 1 /* general debug */
13#define DEBUG_BOOTP_EXT 1 /* Debug received vendor fields */
wdenk3861aa52002-09-27 23:19:37 +000014#endif
15
16#ifdef DEBUG_BOOTP_EXT
17#define debug_ext(fmt,args...) printf (fmt ,##args)
18#else
19#define debug_ext(fmt,args...)
20#endif
21
22#include <common.h>
23#include <command.h>
24#include <net.h>
25#include "bootp.h"
26#include "tftp.h"
wdenk232c1502004-03-12 00:14:09 +000027#include "nfs.h"
wdenk3861aa52002-09-27 23:19:37 +000028#ifdef CONFIG_STATUS_LED
29#include <status_led.h>
30#endif
31
wdenk232c1502004-03-12 00:14:09 +000032#define BOOTP_VENDOR_MAGIC 0x63825363 /* RFC1048 Magic Cookie */
wdenk3861aa52002-09-27 23:19:37 +000033
34#if (CONFIG_COMMANDS & CFG_CMD_NET)
35
36#define TIMEOUT 5 /* Seconds before trying BOOTP again */
wdenk232c1502004-03-12 00:14:09 +000037#ifndef CONFIG_NET_RETRY_COUNT
wdenk3861aa52002-09-27 23:19:37 +000038# define TIMEOUT_COUNT 5 /* # of timeouts before giving up */
39#else
wdenk232c1502004-03-12 00:14:09 +000040# define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT)
wdenk3861aa52002-09-27 23:19:37 +000041#endif
42
43#define PORT_BOOTPS 67 /* BOOTP server UDP port */
44#define PORT_BOOTPC 68 /* BOOTP client UDP port */
45
46#ifndef CONFIG_DHCP_MIN_EXT_LEN /* minimal length of extension list */
wdenk232c1502004-03-12 00:14:09 +000047#define CONFIG_DHCP_MIN_EXT_LEN 64
wdenk3861aa52002-09-27 23:19:37 +000048#endif
49
50ulong BootpID;
51int BootpTry;
52#ifdef CONFIG_BOOTP_RANDOM_DELAY
53ulong seed1, seed2;
54#endif
55
56#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
57dhcp_state_t dhcp_state = INIT;
wdenk682011f2003-06-03 23:54:09 +000058unsigned long dhcp_leasetime = 0;
stroese759a51b2003-04-10 13:26:44 +000059IPaddr_t NetDHCPServerIP = 0;
wdenk3861aa52002-09-27 23:19:37 +000060static void DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len);
61
62/* For Debug */
wdenk3e386912003-04-05 00:53:31 +000063#if 0
64static char *dhcpmsg2str(int type)
wdenk3861aa52002-09-27 23:19:37 +000065{
66 switch (type) {
wdenk232c1502004-03-12 00:14:09 +000067 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;
wdenk3861aa52002-09-27 23:19:37 +000074 default: return "UNKNOWN/INVALID MSG TYPE"; break;
75 }
76}
wdenk3e386912003-04-05 00:53:31 +000077#endif
wdenk3861aa52002-09-27 23:19:37 +000078
79#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
80extern u8 *dhcp_vendorex_prep (u8 *e); /*rtn new e after add own opts. */
81extern u8 *dhcp_vendorex_proc (u8 *e); /*rtn next e if mine,else NULL */
82#endif
83
84#endif /* CFG_CMD_DHCP */
85
86static int BootpCheckPkt(uchar *pkt, unsigned dest, unsigned src, unsigned len)
87{
88 Bootp_t *bp = (Bootp_t *) pkt;
89 int retval = 0;
90
91 if (dest != PORT_BOOTPC || src != PORT_BOOTPS)
92 retval = -1;
93 else if (len < sizeof (Bootp_t) - OPT_SIZE)
94 retval = -2;
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 ) {
100 retval = -3;
101 }
102 else if (bp->bp_htype != HWT_ETHER)
103 retval = -4;
104 else if (bp->bp_hlen != HWL_ETHER)
105 retval = -5;
106 else if (NetReadLong((ulong*)&bp->bp_id) != BootpID) {
107 retval = -6;
108 }
109
110 debug ("Filtering pkt = %d\n", retval);
111
112 return retval;
113}
114
115/*
116 * Copy parameters of interest from BOOTP_REPLY/DHCP_OFFER packet
117 */
wdenk3e386912003-04-05 00:53:31 +0000118static void BootpCopyNetParams(Bootp_t *bp)
wdenk3861aa52002-09-27 23:19:37 +0000119{
wdenk3d3befa2004-03-14 15:06:13 +0000120 IPaddr_t tmp_ip;
121
wdenk3861aa52002-09-27 23:19:37 +0000122 NetCopyIP(&NetOurIP, &bp->bp_yiaddr);
wdenk3d3befa2004-03-14 15:06:13 +0000123 NetCopyIP(&tmp_ip, &bp->bp_siaddr);
124 if (tmp_ip != 0)
125 NetCopyIP(&NetServerIP, &bp->bp_siaddr);
wdenk3861aa52002-09-27 23:19:37 +0000126 memcpy (NetServerEther, ((Ethernet_t *)NetRxPkt)->et_src, 6);
wdenk3d3befa2004-03-14 15:06:13 +0000127 if (strlen(bp->bp_file) > 0)
128 copy_filename (BootFile, bp->bp_file, sizeof(BootFile));
wdenk3861aa52002-09-27 23:19:37 +0000129
130 debug ("Bootfile: %s\n", BootFile);
131
132 /* Propagate to environment:
wdenk8bde7f72003-06-27 21:31:46 +0000133 * don't delete exising entry when BOOTP / DHCP reply does
wdenk3861aa52002-09-27 23:19:37 +0000134 * not contain a new value
135 */
136 if (*BootFile) {
137 setenv ("bootfile", BootFile);
138 }
139}
140
141static int truncate_sz (const char *name, int maxlen, int curlen)
142{
143 if (curlen >= maxlen) {
144 printf("*** WARNING: %s is too long (%d - max: %d) - truncated\n",
145 name, curlen, maxlen);
146 curlen = maxlen - 1;
147 }
148 return (curlen);
149}
150
151#if !(CONFIG_COMMANDS & CFG_CMD_DHCP)
152
wdenk232c1502004-03-12 00:14:09 +0000153static void BootpVendorFieldProcess (u8 * ext)
wdenk3861aa52002-09-27 23:19:37 +0000154{
wdenk232c1502004-03-12 00:14:09 +0000155 int size = *(ext + 1);
wdenk3861aa52002-09-27 23:19:37 +0000156
wdenk232c1502004-03-12 00:14:09 +0000157 debug_ext ("[BOOTP] Processing extension %d... (%d bytes)\n", *ext,
158 *(ext + 1));
wdenk3861aa52002-09-27 23:19:37 +0000159
wdenk232c1502004-03-12 00:14:09 +0000160 NetBootFileSize = 0;
wdenk3861aa52002-09-27 23:19:37 +0000161
wdenk232c1502004-03-12 00:14:09 +0000162 switch (*ext) {
163 /* Fixed length fields */
164 case 1: /* Subnet mask */
wdenk3861aa52002-09-27 23:19:37 +0000165 if (NetOurSubnetMask == 0)
wdenk232c1502004-03-12 00:14:09 +0000166 NetCopyIP (&NetOurSubnetMask, (IPaddr_t *) (ext + 2));
wdenk3861aa52002-09-27 23:19:37 +0000167 break;
wdenk232c1502004-03-12 00:14:09 +0000168 case 2: /* Time offset - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000169 break;
wdenk232c1502004-03-12 00:14:09 +0000170 /* Variable length fields */
171 case 3: /* Gateways list */
wdenk3861aa52002-09-27 23:19:37 +0000172 if (NetOurGatewayIP == 0) {
wdenk232c1502004-03-12 00:14:09 +0000173 NetCopyIP (&NetOurGatewayIP, (IPaddr_t *) (ext + 2));
wdenk3861aa52002-09-27 23:19:37 +0000174 }
175 break;
wdenk232c1502004-03-12 00:14:09 +0000176 case 4: /* Time server - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000177 break;
wdenk232c1502004-03-12 00:14:09 +0000178 case 5: /* IEN-116 name server - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000179 break;
180 case 6:
181 if (NetOurDNSIP == 0) {
wdenk232c1502004-03-12 00:14:09 +0000182 NetCopyIP (&NetOurDNSIP, (IPaddr_t *) (ext + 2));
wdenk3861aa52002-09-27 23:19:37 +0000183 }
stroesefe389a82003-08-28 14:17:32 +0000184#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
185 if ((NetOurDNS2IP == 0) && (size > 4)) {
wdenk232c1502004-03-12 00:14:09 +0000186 NetCopyIP (&NetOurDNS2IP, (IPaddr_t *) (ext + 2 + 4));
stroesefe389a82003-08-28 14:17:32 +0000187 }
188#endif
wdenk3861aa52002-09-27 23:19:37 +0000189 break;
wdenk232c1502004-03-12 00:14:09 +0000190 case 7: /* Log server - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000191 break;
wdenk232c1502004-03-12 00:14:09 +0000192 case 8: /* Cookie/Quote server - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000193 break;
wdenk232c1502004-03-12 00:14:09 +0000194 case 9: /* LPR server - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000195 break;
wdenk232c1502004-03-12 00:14:09 +0000196 case 10: /* Impress server - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000197 break;
wdenk232c1502004-03-12 00:14:09 +0000198 case 11: /* RPL server - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000199 break;
wdenk232c1502004-03-12 00:14:09 +0000200 case 12: /* Host name */
wdenk3861aa52002-09-27 23:19:37 +0000201 if (NetOurHostName[0] == 0) {
wdenk232c1502004-03-12 00:14:09 +0000202 size = truncate_sz ("Host Name", sizeof (NetOurHostName), size);
203 memcpy (&NetOurHostName, ext + 2, size);
204 NetOurHostName[size] = 0;
wdenk3861aa52002-09-27 23:19:37 +0000205 }
206 break;
wdenk232c1502004-03-12 00:14:09 +0000207 case 13: /* Boot file size */
wdenk3861aa52002-09-27 23:19:37 +0000208 if (size == 2)
wdenk232c1502004-03-12 00:14:09 +0000209 NetBootFileSize = ntohs (*(ushort *) (ext + 2));
wdenk3861aa52002-09-27 23:19:37 +0000210 else if (size == 4)
wdenk232c1502004-03-12 00:14:09 +0000211 NetBootFileSize = ntohl (*(ulong *) (ext + 2));
wdenk3861aa52002-09-27 23:19:37 +0000212 break;
wdenk232c1502004-03-12 00:14:09 +0000213 case 14: /* Merit dump file - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000214 break;
wdenk232c1502004-03-12 00:14:09 +0000215 case 15: /* Domain name - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000216 break;
wdenk232c1502004-03-12 00:14:09 +0000217 case 16: /* Swap server - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000218 break;
wdenk232c1502004-03-12 00:14:09 +0000219 case 17: /* Root path */
wdenk3861aa52002-09-27 23:19:37 +0000220 if (NetOurRootPath[0] == 0) {
wdenk232c1502004-03-12 00:14:09 +0000221 size = truncate_sz ("Root Path", sizeof (NetOurRootPath), size);
222 memcpy (&NetOurRootPath, ext + 2, size);
223 NetOurRootPath[size] = 0;
wdenk3861aa52002-09-27 23:19:37 +0000224 }
225 break;
wdenk232c1502004-03-12 00:14:09 +0000226 case 18: /* Extension path - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000227 /*
wdenk8bde7f72003-06-27 21:31:46 +0000228 * This can be used to send the information of the
229 * vendor area in another file that the client can
230 * access via TFTP.
wdenk3861aa52002-09-27 23:19:37 +0000231 */
232 break;
wdenk232c1502004-03-12 00:14:09 +0000233 /* IP host layer fields */
234 case 40: /* NIS Domain name */
wdenk3861aa52002-09-27 23:19:37 +0000235 if (NetOurNISDomain[0] == 0) {
wdenk232c1502004-03-12 00:14:09 +0000236 size = truncate_sz ("NIS Domain Name", sizeof (NetOurNISDomain), size);
237 memcpy (&NetOurNISDomain, ext + 2, size);
238 NetOurNISDomain[size] = 0;
wdenk3861aa52002-09-27 23:19:37 +0000239 }
240 break;
wdenk232c1502004-03-12 00:14:09 +0000241 /* Application layer fields */
242 case 43: /* Vendor specific info - Not yet supported */
wdenk3861aa52002-09-27 23:19:37 +0000243 /*
wdenk8bde7f72003-06-27 21:31:46 +0000244 * Binary information to exchange specific
245 * product information.
wdenk3861aa52002-09-27 23:19:37 +0000246 */
247 break;
wdenk232c1502004-03-12 00:14:09 +0000248 /* Reserved (custom) fields (128..254) */
249 }
wdenk3861aa52002-09-27 23:19:37 +0000250}
251
wdenk232c1502004-03-12 00:14:09 +0000252static void BootpVendorProcess (u8 * ext, int size)
wdenk3861aa52002-09-27 23:19:37 +0000253{
wdenk232c1502004-03-12 00:14:09 +0000254 u8 *end = ext + size;
wdenk3861aa52002-09-27 23:19:37 +0000255
wdenk232c1502004-03-12 00:14:09 +0000256 debug_ext ("[BOOTP] Checking extension (%d bytes)...\n", size);
wdenk3861aa52002-09-27 23:19:37 +0000257
wdenk232c1502004-03-12 00:14:09 +0000258 while ((ext < end) && (*ext != 0xff)) {
259 if (*ext == 0) {
260 ext++;
261 } else {
262 u8 *opt = ext;
263
264 ext += ext[1] + 2;
265 if (ext <= end)
266 BootpVendorFieldProcess (opt);
267 }
wdenk3861aa52002-09-27 23:19:37 +0000268 }
wdenk3861aa52002-09-27 23:19:37 +0000269
270#ifdef DEBUG_BOOTP_EXT
wdenk4b9206e2004-03-23 22:14:11 +0000271 puts ("[BOOTP] Received fields: \n");
wdenk232c1502004-03-12 00:14:09 +0000272 if (NetOurSubnetMask) {
273 puts ("NetOurSubnetMask : ");
274 print_IPaddr (NetOurSubnetMask);
275 putc ('\n');
276 }
wdenk3861aa52002-09-27 23:19:37 +0000277
wdenk232c1502004-03-12 00:14:09 +0000278 if (NetOurGatewayIP) {
279 puts ("NetOurGatewayIP : ");
280 print_IPaddr (NetOurGatewayIP);
281 putc ('\n');
282 }
wdenk3861aa52002-09-27 23:19:37 +0000283
wdenk232c1502004-03-12 00:14:09 +0000284 if (NetBootFileSize) {
285 printf ("NetBootFileSize : %d\n", NetBootFileSize);
286 }
wdenk3861aa52002-09-27 23:19:37 +0000287
wdenk232c1502004-03-12 00:14:09 +0000288 if (NetOurHostName[0]) {
289 printf ("NetOurHostName : %s\n", NetOurHostName);
290 }
wdenk3861aa52002-09-27 23:19:37 +0000291
wdenk232c1502004-03-12 00:14:09 +0000292 if (NetOurRootPath[0]) {
293 printf ("NetOurRootPath : %s\n", NetOurRootPath);
294 }
wdenk3861aa52002-09-27 23:19:37 +0000295
wdenk232c1502004-03-12 00:14:09 +0000296 if (NetOurNISDomain[0]) {
297 printf ("NetOurNISDomain : %s\n", NetOurNISDomain);
298 }
wdenk3861aa52002-09-27 23:19:37 +0000299
wdenk232c1502004-03-12 00:14:09 +0000300 if (NetBootFileSize) {
301 printf ("NetBootFileSize: %d\n", NetBootFileSize);
302 }
303#endif /* DEBUG_BOOTP_EXT */
wdenk3861aa52002-09-27 23:19:37 +0000304}
wdenk3861aa52002-09-27 23:19:37 +0000305/*
306 * Handle a BOOTP received packet.
307 */
308static void
309BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
310{
311 Bootp_t *bp;
312 char *s;
313
314 debug ("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%d)\n",
315 src, dest, len, sizeof (Bootp_t));
316
317 bp = (Bootp_t *)pkt;
318
wdenk232c1502004-03-12 00:14:09 +0000319 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
wdenk3861aa52002-09-27 23:19:37 +0000320 return;
321
322 /*
wdenk232c1502004-03-12 00:14:09 +0000323 * Got a good BOOTP reply. Copy the data into our variables.
wdenk3861aa52002-09-27 23:19:37 +0000324 */
325#ifdef CONFIG_STATUS_LED
326 status_led_set (STATUS_LED_BOOT, STATUS_LED_OFF);
327#endif
328
329 BootpCopyNetParams(bp); /* Store net parameters from reply */
330
331 /* Retrieve extended information (we must parse the vendor area) */
332 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
333 BootpVendorProcess(&bp->bp_vend[4], len);
334
335 NetSetTimeout(0, (thand_f *)0);
336
337 debug ("Got good BOOTP\n");
338
wdenk132ba5f2004-02-27 08:20:54 +0000339 if ((s = getenv("autoload")) != NULL) {
340 if (*s == 'n') {
341 /*
342 * Just use BOOTP to configure system;
343 * Do not use TFTP to load the bootfile.
344 */
345 NetState = NETLOOP_SUCCESS;
346 return;
wdenk0e6d7982004-03-14 00:07:33 +0000347#if (CONFIG_COMMANDS & CFG_CMD_NFS)
wdenk132ba5f2004-02-27 08:20:54 +0000348 } else if (strcmp(s, "NFS") == 0) {
349 /*
350 * Use NFS to load the bootfile.
351 */
352 NfsStart();
353 return;
wdenk0e6d7982004-03-14 00:07:33 +0000354#endif
wdenk132ba5f2004-02-27 08:20:54 +0000355 }
wdenk3861aa52002-09-27 23:19:37 +0000356 }
357
wdenk73a8b272003-06-05 19:27:42 +0000358 TftpStart();
wdenk3861aa52002-09-27 23:19:37 +0000359}
360#endif /* !CFG_CMD_DHCP */
361
362/*
363 * Timeout on BOOTP/DHCP request.
364 */
365static void
366BootpTimeout(void)
367{
368 if (BootpTry >= TIMEOUT_COUNT) {
369 puts ("\nRetry count exceeded; starting again\n");
370 NetStartAgain ();
371 } else {
372 NetSetTimeout (TIMEOUT * CFG_HZ, BootpTimeout);
373 BootpRequest ();
374 }
375}
376
377/*
378 * Initialize BOOTP extension fields in the request.
379 */
380#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
wdenk232c1502004-03-12 00:14:09 +0000381static int DhcpExtended (u8 * e, int message_type, IPaddr_t ServerID, IPaddr_t RequestedIP)
wdenk3861aa52002-09-27 23:19:37 +0000382{
wdenk232c1502004-03-12 00:14:09 +0000383 u8 *start = e;
384 u8 *cnt;
385
wdenk3861aa52002-09-27 23:19:37 +0000386#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
wdenk232c1502004-03-12 00:14:09 +0000387 u8 *x;
wdenk3861aa52002-09-27 23:19:37 +0000388#endif
stroesefe389a82003-08-28 14:17:32 +0000389#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SEND_HOSTNAME)
wdenk232c1502004-03-12 00:14:09 +0000390 uchar *hostname;
stroesefe389a82003-08-28 14:17:32 +0000391#endif
wdenk3861aa52002-09-27 23:19:37 +0000392
wdenk232c1502004-03-12 00:14:09 +0000393 *e++ = 99; /* RFC1048 Magic Cookie */
394 *e++ = 130;
395 *e++ = 83;
396 *e++ = 99;
wdenk3861aa52002-09-27 23:19:37 +0000397
wdenk232c1502004-03-12 00:14:09 +0000398 *e++ = 53; /* DHCP Message Type */
399 *e++ = 1;
400 *e++ = message_type;
wdenk3861aa52002-09-27 23:19:37 +0000401
wdenk232c1502004-03-12 00:14:09 +0000402 *e++ = 57; /* Maximum DHCP Message Size */
403 *e++ = 2;
404 *e++ = (576 - 312 + OPT_SIZE) >> 8;
405 *e++ = (576 - 312 + OPT_SIZE) & 0xff;
wdenk3861aa52002-09-27 23:19:37 +0000406
wdenk232c1502004-03-12 00:14:09 +0000407 if (ServerID) {
408 int tmp = ntohl (ServerID);
wdenk3861aa52002-09-27 23:19:37 +0000409
wdenk232c1502004-03-12 00:14:09 +0000410 *e++ = 54; /* ServerID */
411 *e++ = 4;
412 *e++ = tmp >> 24;
413 *e++ = tmp >> 16;
414 *e++ = tmp >> 8;
415 *e++ = tmp & 0xff;
416 }
wdenk3861aa52002-09-27 23:19:37 +0000417
wdenk232c1502004-03-12 00:14:09 +0000418 if (RequestedIP) {
419 int tmp = ntohl (RequestedIP);
wdenk3861aa52002-09-27 23:19:37 +0000420
wdenk232c1502004-03-12 00:14:09 +0000421 *e++ = 50; /* Requested IP */
422 *e++ = 4;
423 *e++ = tmp >> 24;
424 *e++ = tmp >> 16;
425 *e++ = tmp >> 8;
426 *e++ = tmp & 0xff;
427 }
stroesefe389a82003-08-28 14:17:32 +0000428#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SEND_HOSTNAME)
wdenk232c1502004-03-12 00:14:09 +0000429 if ((hostname = getenv ("hostname"))) {
430 int hostnamelen = strlen (hostname);
431
432 *e++ = 12; /* Hostname */
433 *e++ = hostnamelen;
434 memcpy (e, hostname, hostnamelen);
435 e += hostnamelen;
436 }
stroesefe389a82003-08-28 14:17:32 +0000437#endif
438
wdenk3861aa52002-09-27 23:19:37 +0000439#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
wdenk232c1502004-03-12 00:14:09 +0000440 if ((x = dhcp_vendorex_prep (e)))
441 return x - start;
wdenk3861aa52002-09-27 23:19:37 +0000442#endif
443
wdenk232c1502004-03-12 00:14:09 +0000444 *e++ = 55; /* Parameter Request List */
445 cnt = e++; /* Pointer to count of requested items */
446 *cnt = 0;
wdenk3861aa52002-09-27 23:19:37 +0000447#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
wdenk232c1502004-03-12 00:14:09 +0000448 *e++ = 1; /* Subnet Mask */
449 *cnt += 1;
wdenk3861aa52002-09-27 23:19:37 +0000450#endif
451#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
wdenk232c1502004-03-12 00:14:09 +0000452 *e++ = 3; /* Router Option */
453 *cnt += 1;
wdenk3861aa52002-09-27 23:19:37 +0000454#endif
455#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
wdenk232c1502004-03-12 00:14:09 +0000456 *e++ = 6; /* DNS Server(s) */
457 *cnt += 1;
wdenk3861aa52002-09-27 23:19:37 +0000458#endif
459#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
wdenk232c1502004-03-12 00:14:09 +0000460 *e++ = 12; /* Hostname */
461 *cnt += 1;
wdenk3861aa52002-09-27 23:19:37 +0000462#endif
463#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
wdenk232c1502004-03-12 00:14:09 +0000464 *e++ = 13; /* Boot File Size */
465 *cnt += 1;
wdenk3861aa52002-09-27 23:19:37 +0000466#endif
467#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
wdenk232c1502004-03-12 00:14:09 +0000468 *e++ = 17; /* Boot path */
469 *cnt += 1;
wdenk3861aa52002-09-27 23:19:37 +0000470#endif
471#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
wdenk232c1502004-03-12 00:14:09 +0000472 *e++ = 40; /* NIS Domain name request */
473 *cnt += 1;
wdenk3861aa52002-09-27 23:19:37 +0000474#endif
wdenk232c1502004-03-12 00:14:09 +0000475 *e++ = 255; /* End of the list */
wdenk3861aa52002-09-27 23:19:37 +0000476
wdenk232c1502004-03-12 00:14:09 +0000477 /* Pad to minimal length */
wdenk3861aa52002-09-27 23:19:37 +0000478#ifdef CONFIG_DHCP_MIN_EXT_LEN
wdenk232c1502004-03-12 00:14:09 +0000479 while ((e - start) <= CONFIG_DHCP_MIN_EXT_LEN)
480 *e++ = 0;
wdenk3861aa52002-09-27 23:19:37 +0000481#endif
482
wdenk232c1502004-03-12 00:14:09 +0000483 return e - start;
wdenk3861aa52002-09-27 23:19:37 +0000484}
485
486#else /* CFG_CMD_DHCP */
487/*
488 * Warning: no field size check - change CONFIG_BOOTP_MASK at your own risk!
489 */
wdenk232c1502004-03-12 00:14:09 +0000490static int BootpExtended (u8 * e)
wdenk3861aa52002-09-27 23:19:37 +0000491{
wdenk232c1502004-03-12 00:14:09 +0000492 u8 *start = e;
wdenk3861aa52002-09-27 23:19:37 +0000493
wdenk232c1502004-03-12 00:14:09 +0000494 *e++ = 99; /* RFC1048 Magic Cookie */
495 *e++ = 130;
496 *e++ = 83;
497 *e++ = 99;
wdenk3861aa52002-09-27 23:19:37 +0000498
499#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
wdenk232c1502004-03-12 00:14:09 +0000500 *e++ = 53; /* DHCP Message Type */
501 *e++ = 1;
502 *e++ = DHCP_DISCOVER;
wdenk3861aa52002-09-27 23:19:37 +0000503
wdenk232c1502004-03-12 00:14:09 +0000504 *e++ = 57; /* Maximum DHCP Message Size */
505 *e++ = 2;
506 *e++ = (576 - 312 + OPT_SIZE) >> 16;
507 *e++ = (576 - 312 + OPT_SIZE) & 0xff;
508#endif /* CFG_CMD_DHCP */
wdenk3861aa52002-09-27 23:19:37 +0000509
510#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_SUBNETMASK)
wdenk232c1502004-03-12 00:14:09 +0000511 *e++ = 1; /* Subnet mask request */
512 *e++ = 4;
513 e += 4;
wdenk3861aa52002-09-27 23:19:37 +0000514#endif
515
516#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_GATEWAY)
wdenk232c1502004-03-12 00:14:09 +0000517 *e++ = 3; /* Default gateway request */
518 *e++ = 4;
519 e += 4;
wdenk3861aa52002-09-27 23:19:37 +0000520#endif
521
522#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS)
wdenk232c1502004-03-12 00:14:09 +0000523 *e++ = 6; /* Domain Name Server */
524 *e++ = 4;
525 e += 4;
wdenk3861aa52002-09-27 23:19:37 +0000526#endif
527
528#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_HOSTNAME)
wdenk232c1502004-03-12 00:14:09 +0000529 *e++ = 12; /* Host name request */
530 *e++ = 32;
531 e += 32;
wdenk3861aa52002-09-27 23:19:37 +0000532#endif
533
534#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTFILESIZE)
wdenk232c1502004-03-12 00:14:09 +0000535 *e++ = 13; /* Boot file size */
536 *e++ = 2;
537 e += 2;
wdenk3861aa52002-09-27 23:19:37 +0000538#endif
539
540#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_BOOTPATH)
wdenk232c1502004-03-12 00:14:09 +0000541 *e++ = 17; /* Boot path */
542 *e++ = 32;
543 e += 32;
wdenk3861aa52002-09-27 23:19:37 +0000544#endif
545
546#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NISDOMAIN)
wdenk232c1502004-03-12 00:14:09 +0000547 *e++ = 40; /* NIS Domain name request */
548 *e++ = 32;
549 e += 32;
wdenk3861aa52002-09-27 23:19:37 +0000550#endif
551
wdenk232c1502004-03-12 00:14:09 +0000552 *e++ = 255; /* End of the list */
wdenk3861aa52002-09-27 23:19:37 +0000553
wdenk232c1502004-03-12 00:14:09 +0000554 return e - start;
wdenk3861aa52002-09-27 23:19:37 +0000555}
556#endif /* CFG_CMD_DHCP */
557
558void
559BootpRequest (void)
560{
561 volatile uchar *pkt, *iphdr;
562 Bootp_t *bp;
563 int ext_len, pktlen, iplen;
564
565#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
566 dhcp_state = INIT;
567#endif
568
569#ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */
570 unsigned char bi_enetaddr[6];
571 int reg;
572 char *e,*s;
573 uchar tmp[64];
574 ulong tst1, tst2, sum, m_mask, m_value = 0;
575
576 if (BootpTry ==0) {
577 /* get our mac */
578 reg = getenv_r ("ethaddr", tmp, sizeof(tmp));
579 s = (reg > 0) ? tmp : NULL;
580
581 for (reg=0; reg<6; ++reg) {
582 bi_enetaddr[reg] = s ? simple_strtoul(s, &e, 16) : 0;
583 if (s) {
584 s = (*e) ? e+1 : e;
585 }
586 }
587#ifdef DEBUG
wdenk4b9206e2004-03-23 22:14:11 +0000588 puts ("BootpRequest => Our Mac: ");
wdenk3861aa52002-09-27 23:19:37 +0000589 for (reg=0; reg<6; reg++) {
590 printf ("%x%c",
591 bi_enetaddr[reg],
592 reg==5 ? '\n' : ':');
593 }
594#endif /* DEBUG */
595
596 /* Mac-Manipulation 2 get seed1 */
597 tst1=0;
598 tst2=0;
599 for (reg=2; reg<6; reg++) {
600 tst1 = tst1 << 8;
601 tst1 = tst1 | bi_enetaddr[reg];
602 }
603 for (reg=0; reg<2; reg++) {
604 tst2 = tst2 | bi_enetaddr[reg];
605 tst2 = tst2 << 8;
606 }
607
608 seed1 = tst1^tst2;
609
610 /* Mirror seed1*/
611 m_mask=0x1;
612 for (reg=1;reg<=32;reg++) {
613 m_value |= (m_mask & seed1);
614 seed1 = seed1 >> 1;
615 m_value = m_value << 1;
616 }
617 seed1 = m_value;
618 seed2 = 0xB78D0945;
619 }
620
621 /* Random Number Generator */
622
623 for (reg=0;reg<=0;reg++) {
624 sum = seed1 + seed2;
625 if (sum < seed1 || sum < seed2)
626 sum++;
wdenk8bde7f72003-06-27 21:31:46 +0000627 seed2 = seed1;
wdenk3861aa52002-09-27 23:19:37 +0000628 seed1 = sum;
629
630 if (BootpTry<=2) { /* Start with max 1024 * 1ms */
631 sum = sum >> (22-BootpTry);
632 } else { /*After 3rd BOOTP request max 8192 * 1ms */
633 sum = sum >> 19;
634 }
635 }
636
637 printf ("Random delay: %ld ms...\n", sum);
638 for (reg=0; reg <sum; reg++) {
639 udelay(1000); /*Wait 1ms*/
640 }
641#endif /* CONFIG_BOOTP_RANDOM_DELAY */
642
643 printf("BOOTP broadcast %d\n", ++BootpTry);
644 pkt = NetTxPacket;
645 memset ((void*)pkt, 0, PKTSIZE);
646
wdenka3d991b2004-04-15 21:48:45 +0000647 pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
wdenk3861aa52002-09-27 23:19:37 +0000648
649 /*
650 * Next line results in incorrect packet size being transmitted, resulting
651 * in errors in some DHCP servers, reporting missing bytes. Size must be
652 * set in packet header after extension length has been determined.
653 * C. Hallinan, DS4.COM, Inc.
654 */
655 /* NetSetIP(pkt, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, sizeof (Bootp_t)); */
656 iphdr = pkt; /* We need this later for NetSetIP() */
657 pkt += IP_HDR_SIZE;
658
659 bp = (Bootp_t *)pkt;
660 bp->bp_op = OP_BOOTREQUEST;
661 bp->bp_htype = HWT_ETHER;
662 bp->bp_hlen = HWL_ETHER;
663 bp->bp_hops = 0;
664 bp->bp_secs = htons(get_timer(0) / CFG_HZ);
665 NetWriteIP(&bp->bp_ciaddr, 0);
666 NetWriteIP(&bp->bp_yiaddr, 0);
667 NetWriteIP(&bp->bp_siaddr, 0);
668 NetWriteIP(&bp->bp_giaddr, 0);
669 memcpy (bp->bp_chaddr, NetOurEther, 6);
670 copy_filename (bp->bp_file, BootFile, sizeof(bp->bp_file));
671
672 /* Request additional information from the BOOTP/DHCP server */
673#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
674 ext_len = DhcpExtended(bp->bp_vend, DHCP_DISCOVER, 0, 0);
675#else
676 ext_len = BootpExtended(bp->bp_vend);
677#endif /* CFG_CMD_DHCP */
678
679 /*
680 * Bootp ID is the lower 4 bytes of our ethernet address
681 * plus the current time in HZ.
682 */
683 BootpID = ((ulong)NetOurEther[2] << 24)
684 | ((ulong)NetOurEther[3] << 16)
685 | ((ulong)NetOurEther[4] << 8)
686 | (ulong)NetOurEther[5];
687 BootpID += get_timer(0);
wdenk232c1502004-03-12 00:14:09 +0000688 BootpID = htonl(BootpID);
wdenk3861aa52002-09-27 23:19:37 +0000689 NetCopyLong(&bp->bp_id, &BootpID);
690
691 /*
692 * Calculate proper packet lengths taking into account the
693 * variable size of the options field
694 */
695 pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + ext_len;
696 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + ext_len;
697 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
698 NetSetTimeout(SELECT_TIMEOUT * CFG_HZ, BootpTimeout);
699
700#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
701 dhcp_state = SELECTING;
702 NetSetHandler(DhcpHandler);
703#else
704 NetSetHandler(BootpHandler);
705#endif /* CFG_CMD_DHCP */
706 NetSendPacket(NetTxPacket, pktlen);
707}
708
709#if (CONFIG_COMMANDS & CFG_CMD_DHCP)
wdenk232c1502004-03-12 00:14:09 +0000710static void DhcpOptionsProcess (uchar * popt)
wdenk3861aa52002-09-27 23:19:37 +0000711{
wdenk3e386912003-04-05 00:53:31 +0000712 uchar *end = popt + BOOTP_HDR_SIZE;
wdenk3861aa52002-09-27 23:19:37 +0000713 int oplen, size;
714
wdenk232c1502004-03-12 00:14:09 +0000715 while (popt < end && *popt != 0xff) {
wdenk3861aa52002-09-27 23:19:37 +0000716 oplen = *(popt + 1);
wdenk232c1502004-03-12 00:14:09 +0000717 switch (*popt) {
718 case 1:
719 NetCopyIP (&NetOurSubnetMask, (popt + 2));
720 break;
721 case 3:
722 NetCopyIP (&NetOurGatewayIP, (popt + 2));
723 break;
724 case 6:
725 NetCopyIP (&NetOurDNSIP, (popt + 2));
stroesefe389a82003-08-28 14:17:32 +0000726#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_DNS2)
wdenk232c1502004-03-12 00:14:09 +0000727 if (*(popt + 1) > 4) {
728 NetCopyIP (&NetOurDNS2IP, (popt + 2 + 4));
729 }
stroesefe389a82003-08-28 14:17:32 +0000730#endif
wdenk232c1502004-03-12 00:14:09 +0000731 break;
732 case 12:
733 size = truncate_sz ("Host Name", sizeof (NetOurHostName), oplen);
734 memcpy (&NetOurHostName, popt + 2, size);
735 NetOurHostName[size] = 0;
736 break;
737 case 15: /* Ignore Domain Name Option */
738 break;
739 case 17:
740 size = truncate_sz ("Root Path", sizeof (NetOurRootPath), oplen);
741 memcpy (&NetOurRootPath, popt + 2, size);
742 NetOurRootPath[size] = 0;
743 break;
744 case 51:
745 NetCopyLong (&dhcp_leasetime, (ulong *) (popt + 2));
746 break;
747 case 53: /* Ignore Message Type Option */
748 break;
749 case 54:
750 NetCopyIP (&NetDHCPServerIP, (popt + 2));
751 break;
752 case 58: /* Ignore Renewal Time Option */
753 break;
754 case 59: /* Ignore Rebinding Time Option */
755 break;
756 default:
wdenk3861aa52002-09-27 23:19:37 +0000757#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_VENDOREX)
wdenk232c1502004-03-12 00:14:09 +0000758 if (dhcp_vendorex_proc (popt))
wdenk8bde7f72003-06-27 21:31:46 +0000759 break;
wdenk3861aa52002-09-27 23:19:37 +0000760#endif
wdenk232c1502004-03-12 00:14:09 +0000761 printf ("*** Unhandled DHCP Option in OFFER/ACK: %d\n", *popt);
762 break;
wdenk3861aa52002-09-27 23:19:37 +0000763 }
764 popt += oplen + 2; /* Process next option */
765 }
766}
767
768static int DhcpMessageType(unsigned char *popt)
769{
770 if (NetReadLong((ulong*)popt) != htonl(BOOTP_VENDOR_MAGIC))
771 return -1;
772
773 popt += 4;
774 while ( *popt != 0xff ) {
775 if ( *popt == 53 ) /* DHCP Message Type */
776 return *(popt + 2);
777 popt += *(popt + 1) + 2; /* Scan through all options */
778 }
779 return -1;
780}
781
wdenk3e386912003-04-05 00:53:31 +0000782static void DhcpSendRequestPkt(Bootp_t *bp_offer)
wdenk3861aa52002-09-27 23:19:37 +0000783{
784 volatile uchar *pkt, *iphdr;
785 Bootp_t *bp;
786 int pktlen, iplen, extlen;
wdenk47cd00f2003-03-06 13:39:27 +0000787 IPaddr_t OfferedIP;
wdenk3861aa52002-09-27 23:19:37 +0000788
789 debug ("DhcpSendRequestPkt: Sending DHCPREQUEST\n");
790 pkt = NetTxPacket;
791 memset ((void*)pkt, 0, PKTSIZE);
792
wdenka3d991b2004-04-15 21:48:45 +0000793 pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP);
wdenk3861aa52002-09-27 23:19:37 +0000794
795 iphdr = pkt; /* We'll need this later to set proper pkt size */
796 pkt += IP_HDR_SIZE;
797
798 bp = (Bootp_t *)pkt;
799 bp->bp_op = OP_BOOTREQUEST;
800 bp->bp_htype = HWT_ETHER;
801 bp->bp_hlen = HWL_ETHER;
802 bp->bp_hops = 0;
803 bp->bp_secs = htons(get_timer(0) / CFG_HZ);
804 NetCopyIP(&bp->bp_ciaddr, &bp_offer->bp_ciaddr); /* both in network byte order */
805 NetCopyIP(&bp->bp_yiaddr, &bp_offer->bp_yiaddr);
806 NetCopyIP(&bp->bp_siaddr, &bp_offer->bp_siaddr);
807 NetCopyIP(&bp->bp_giaddr, &bp_offer->bp_giaddr);
808 memcpy (bp->bp_chaddr, NetOurEther, 6);
809
810 /*
811 * ID is the id of the OFFER packet
812 */
813
814 NetCopyLong(&bp->bp_id, &bp_offer->bp_id);
815
816 /*
817 * Copy options from OFFER packet if present
818 */
wdenk47cd00f2003-03-06 13:39:27 +0000819 NetCopyIP(&OfferedIP, &bp->bp_yiaddr);
stroese759a51b2003-04-10 13:26:44 +0000820 extlen = DhcpExtended(bp->bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP);
wdenk3861aa52002-09-27 23:19:37 +0000821
822 pktlen = BOOTP_SIZE - sizeof(bp->bp_vend) + extlen;
823 iplen = BOOTP_HDR_SIZE - sizeof(bp->bp_vend) + extlen;
824 NetSetIP(iphdr, 0xFFFFFFFFL, PORT_BOOTPS, PORT_BOOTPC, iplen);
825
826 debug ("Transmitting DHCPREQUEST packet: len = %d\n", pktlen);
827 NetSendPacket(NetTxPacket, pktlen);
828}
829
830/*
831 * Handle DHCP received packets.
832 */
833static void
834DhcpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len)
835{
836 Bootp_t *bp = (Bootp_t *)pkt;
837
838 debug ("DHCPHandler: got packet: (src=%d, dst=%d, len=%d) state: %d\n",
839 src, dest, len, dhcp_state);
840
wdenk232c1502004-03-12 00:14:09 +0000841 if (BootpCheckPkt(pkt, dest, src, len)) /* Filter out pkts we don't want */
wdenk3861aa52002-09-27 23:19:37 +0000842 return;
843
844 debug ("DHCPHandler: got DHCP packet: (src=%d, dst=%d, len=%d) state: %d\n",
845 src, dest, len, dhcp_state);
846
847 switch (dhcp_state) {
848 case SELECTING:
849 /*
850 * Wait an appropriate time for any potential DHCPOFFER packets
851 * to arrive. Then select one, and generate DHCPREQUEST response.
852 * If filename is in format we recognize, assume it is a valid
853 * OFFER from a server we want.
854 */
855 debug ("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file);
856#ifdef CFG_BOOTFILE_PREFIX
857 if (strncmp(bp->bp_file,
858 CFG_BOOTFILE_PREFIX,
859 strlen(CFG_BOOTFILE_PREFIX)) == 0 ) {
860#endif /* CFG_BOOTFILE_PREFIX */
861
862 debug ("TRANSITIONING TO REQUESTING STATE\n");
863 dhcp_state = REQUESTING;
stroese759a51b2003-04-10 13:26:44 +0000864
wdenk3861aa52002-09-27 23:19:37 +0000865 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
866 DhcpOptionsProcess(&bp->bp_vend[4]);
867
wdenk232c1502004-03-12 00:14:09 +0000868 BootpCopyNetParams(bp); /* Store net params from reply */
wdenk3861aa52002-09-27 23:19:37 +0000869
870 NetSetTimeout(TIMEOUT * CFG_HZ, BootpTimeout);
871 DhcpSendRequestPkt(bp);
872#ifdef CFG_BOOTFILE_PREFIX
873 }
874#endif /* CFG_BOOTFILE_PREFIX */
875
876 return;
877 break;
878 case REQUESTING:
879 debug ("DHCP State: REQUESTING\n");
880
881 if ( DhcpMessageType(bp->bp_vend) == DHCP_ACK ) {
882 char *s;
883
884 if (NetReadLong((ulong*)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC))
885 DhcpOptionsProcess(&bp->bp_vend[4]);
wdenk232c1502004-03-12 00:14:09 +0000886 BootpCopyNetParams(bp); /* Store net params from reply */
wdenk3861aa52002-09-27 23:19:37 +0000887 dhcp_state = BOUND;
wdenk4b9206e2004-03-23 22:14:11 +0000888 puts ("DHCP client bound to address ");
wdenk3861aa52002-09-27 23:19:37 +0000889 print_IPaddr(NetOurIP);
wdenk4b9206e2004-03-23 22:14:11 +0000890 putc ('\n');
wdenk3861aa52002-09-27 23:19:37 +0000891
892 /* Obey the 'autoload' setting */
wdenk132ba5f2004-02-27 08:20:54 +0000893 if ((s = getenv("autoload")) != NULL) {
894 if (*s == 'n') {
895 /*
896 * Just use BOOTP to configure system;
897 * Do not use TFTP to load the bootfile.
898 */
899 NetState = NETLOOP_SUCCESS;
900 return;
wdenk0e6d7982004-03-14 00:07:33 +0000901#if (CONFIG_COMMANDS & CFG_CMD_NFS)
wdenk132ba5f2004-02-27 08:20:54 +0000902 } else if (strcmp(s, "NFS") == 0) {
903 /*
904 * Use NFS to load the bootfile.
905 */
906 NfsStart();
907 return;
wdenk0e6d7982004-03-14 00:07:33 +0000908#endif
wdenk132ba5f2004-02-27 08:20:54 +0000909 }
wdenk3861aa52002-09-27 23:19:37 +0000910 }
wdenk73a8b272003-06-05 19:27:42 +0000911 TftpStart();
wdenk3861aa52002-09-27 23:19:37 +0000912 return;
913 }
914 break;
915 default:
wdenk4b9206e2004-03-23 22:14:11 +0000916 puts ("DHCP: INVALID STATE\n");
wdenk3861aa52002-09-27 23:19:37 +0000917 break;
918 }
919
920}
921
922void DhcpRequest(void)
923{
924 BootpRequest();
925}
926#endif /* CFG_CMD_DHCP */
927
928#endif /* CFG_CMD_NET */