blob: 09489d404e3475a560d719ffdf296f3707362bdb [file] [log] [blame]
wdenk38635852002-08-27 05:55:31 +00001/*
2 * (C) Copyright 2000
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
wdenk38635852002-08-27 05:55:31 +00006 */
7
8/*
9 * Boot support
10 */
11#include <common.h>
12#include <command.h>
wdenk38635852002-08-27 05:55:31 +000013#include <net.h>
14
Simon Glassd6c5f552011-10-24 18:00:02 +000015static int netboot_common(enum proto_t, cmd_tbl_t *, int, char * const []);
wdenk38635852002-08-27 05:55:31 +000016
Kim Phillipsdc00a682012-10-29 13:34:31 +000017static int do_bootp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk38635852002-08-27 05:55:31 +000018{
Kim Phillipsdc00a682012-10-29 13:34:31 +000019 return netboot_common(BOOTP, cmdtp, argc, argv);
wdenk38635852002-08-27 05:55:31 +000020}
21
wdenkf287a242003-07-01 21:06:45 +000022U_BOOT_CMD(
23 bootp, 3, 1, do_bootp,
Peter Tyserdfb72b82009-01-27 18:03:12 -060024 "boot image via network using BOOTP/TFTP protocol",
Wolfgang Denkc54781c2009-05-24 17:06:54 +020025 "[loadAddress] [[hostIPaddr:]bootfilename]"
wdenk57b2d802003-06-27 21:31:46 +000026);
27
Kim Phillipsdc00a682012-10-29 13:34:31 +000028int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk38635852002-08-27 05:55:31 +000029{
Simon Glass768cbf02011-12-10 11:08:06 +000030 int ret;
31
32 bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start");
33 ret = netboot_common(TFTPGET, cmdtp, argc, argv);
34 bootstage_mark_name(BOOTSTAGE_KERNELREAD_STOP, "tftp_done");
35 return ret;
wdenk38635852002-08-27 05:55:31 +000036}
37
wdenkf287a242003-07-01 21:06:45 +000038U_BOOT_CMD(
39 tftpboot, 3, 1, do_tftpb,
Peter Tyserdfb72b82009-01-27 18:03:12 -060040 "boot image via network using TFTP protocol",
Wolfgang Denkc54781c2009-05-24 17:06:54 +020041 "[loadAddress] [[hostIPaddr:]bootfilename]"
wdenk57b2d802003-06-27 21:31:46 +000042);
43
Simon Glass85d96ec2011-10-24 18:00:08 +000044#ifdef CONFIG_CMD_TFTPPUT
45int do_tftpput(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
46{
47 int ret;
48
49 ret = netboot_common(TFTPPUT, cmdtp, argc, argv);
50 return ret;
51}
52
53U_BOOT_CMD(
54 tftpput, 4, 1, do_tftpput,
55 "TFTP put command, for uploading files to a server",
56 "Address Size [[hostIPaddr:]filename]"
57);
58#endif
59
Luca Ceresoli7aa81a42011-05-17 00:03:40 +000060#ifdef CONFIG_CMD_TFTPSRV
61static int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
62{
63 return netboot_common(TFTPSRV, cmdtp, argc, argv);
64}
65
66U_BOOT_CMD(
67 tftpsrv, 2, 1, do_tftpsrv,
68 "act as a TFTP server and boot the first received file",
69 "[loadAddress]\n"
70 "Listen for an incoming TFTP transfer, receive a file and boot it.\n"
71 "The transfer is aborted if a transfer has not been started after\n"
72 "about 50 seconds or if Ctrl-C is pressed."
73);
74#endif
75
76
Peter Tyserf7a48ca2010-09-30 11:25:48 -050077#ifdef CONFIG_CMD_RARP
Kim Phillipsdc00a682012-10-29 13:34:31 +000078int do_rarpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk38635852002-08-27 05:55:31 +000079{
Kim Phillipsdc00a682012-10-29 13:34:31 +000080 return netboot_common(RARP, cmdtp, argc, argv);
wdenk38635852002-08-27 05:55:31 +000081}
82
wdenkf287a242003-07-01 21:06:45 +000083U_BOOT_CMD(
84 rarpboot, 3, 1, do_rarpb,
Peter Tyserdfb72b82009-01-27 18:03:12 -060085 "boot image via network using RARP/TFTP protocol",
Wolfgang Denkc54781c2009-05-24 17:06:54 +020086 "[loadAddress] [[hostIPaddr:]bootfilename]"
wdenk57b2d802003-06-27 21:31:46 +000087);
Peter Tyserf7a48ca2010-09-30 11:25:48 -050088#endif
wdenk57b2d802003-06-27 21:31:46 +000089
Jon Loeligerd76b5c12007-07-08 18:02:23 -050090#if defined(CONFIG_CMD_DHCP)
Kim Phillipsdc00a682012-10-29 13:34:31 +000091static int do_dhcp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk38635852002-08-27 05:55:31 +000092{
93 return netboot_common(DHCP, cmdtp, argc, argv);
94}
wdenk57b2d802003-06-27 21:31:46 +000095
wdenkf287a242003-07-01 21:06:45 +000096U_BOOT_CMD(
97 dhcp, 3, 1, do_dhcp,
Peter Tyserdfb72b82009-01-27 18:03:12 -060098 "boot image via network using DHCP/TFTP protocol",
Wolfgang Denkc54781c2009-05-24 17:06:54 +020099 "[loadAddress] [[hostIPaddr:]bootfilename]"
wdenk57b2d802003-06-27 21:31:46 +0000100);
Jon Loeligerd704d912007-07-10 11:02:44 -0500101#endif
wdenk38635852002-08-27 05:55:31 +0000102
Jon Loeligerd76b5c12007-07-08 18:02:23 -0500103#if defined(CONFIG_CMD_NFS)
Kim Phillipsdc00a682012-10-29 13:34:31 +0000104static int do_nfs(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenkbe9c1cb2004-02-24 02:00:03 +0000105{
106 return netboot_common(NFS, cmdtp, argc, argv);
107}
108
109U_BOOT_CMD(
110 nfs, 3, 1, do_nfs,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600111 "boot image via network using NFS protocol",
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200112 "[loadAddress] [[hostIPaddr:]bootfilename]"
wdenkbe9c1cb2004-02-24 02:00:03 +0000113);
Jon Loeligerd704d912007-07-10 11:02:44 -0500114#endif
wdenkbe9c1cb2004-02-24 02:00:03 +0000115
Kim Phillipsdc00a682012-10-29 13:34:31 +0000116static void netboot_update_env(void)
wdenk38635852002-08-27 05:55:31 +0000117{
wdenk05939202004-04-18 17:39:38 +0000118 char tmp[22];
wdenk38635852002-08-27 05:55:31 +0000119
wdenk05939202004-04-18 17:39:38 +0000120 if (NetOurGatewayIP) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000121 ip_to_string(NetOurGatewayIP, tmp);
122 setenv("gatewayip", tmp);
wdenk05939202004-04-18 17:39:38 +0000123 }
wdenk38635852002-08-27 05:55:31 +0000124
wdenk05939202004-04-18 17:39:38 +0000125 if (NetOurSubnetMask) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000126 ip_to_string(NetOurSubnetMask, tmp);
127 setenv("netmask", tmp);
wdenk05939202004-04-18 17:39:38 +0000128 }
wdenk38635852002-08-27 05:55:31 +0000129
wdenk05939202004-04-18 17:39:38 +0000130 if (NetOurHostName[0])
Kim Phillipsdc00a682012-10-29 13:34:31 +0000131 setenv("hostname", NetOurHostName);
wdenk38635852002-08-27 05:55:31 +0000132
wdenk05939202004-04-18 17:39:38 +0000133 if (NetOurRootPath[0])
Kim Phillipsdc00a682012-10-29 13:34:31 +0000134 setenv("rootpath", NetOurRootPath);
wdenk38635852002-08-27 05:55:31 +0000135
wdenk05939202004-04-18 17:39:38 +0000136 if (NetOurIP) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000137 ip_to_string(NetOurIP, tmp);
138 setenv("ipaddr", tmp);
wdenk05939202004-04-18 17:39:38 +0000139 }
Joe Hershbergerd4762042012-05-23 07:59:17 +0000140#if !defined(CONFIG_BOOTP_SERVERIP)
141 /*
142 * Only attempt to change serverip if net/bootp.c:BootpCopyNetParams()
143 * could have set it
144 */
wdenk05939202004-04-18 17:39:38 +0000145 if (NetServerIP) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000146 ip_to_string(NetServerIP, tmp);
147 setenv("serverip", tmp);
wdenk05939202004-04-18 17:39:38 +0000148 }
Joe Hershbergerd4762042012-05-23 07:59:17 +0000149#endif
wdenk05939202004-04-18 17:39:38 +0000150 if (NetOurDNSIP) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000151 ip_to_string(NetOurDNSIP, tmp);
152 setenv("dnsip", tmp);
wdenk05939202004-04-18 17:39:38 +0000153 }
Jon Loeliger5336a762007-07-09 22:08:34 -0500154#if defined(CONFIG_BOOTP_DNS2)
wdenk05939202004-04-18 17:39:38 +0000155 if (NetOurDNS2IP) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000156 ip_to_string(NetOurDNS2IP, tmp);
157 setenv("dnsip2", tmp);
wdenk05939202004-04-18 17:39:38 +0000158 }
stroesee0aadfb2003-08-28 14:17:32 +0000159#endif
wdenk05939202004-04-18 17:39:38 +0000160 if (NetOurNISDomain[0])
Kim Phillipsdc00a682012-10-29 13:34:31 +0000161 setenv("domain", NetOurNISDomain);
wdenkb4ad9622005-04-01 00:25:43 +0000162
Jon Loeligerd76b5c12007-07-08 18:02:23 -0500163#if defined(CONFIG_CMD_SNTP) \
Jon Loeliger5336a762007-07-09 22:08:34 -0500164 && defined(CONFIG_BOOTP_TIMEOFFSET)
wdenkb4ad9622005-04-01 00:25:43 +0000165 if (NetTimeOffset) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000166 sprintf(tmp, "%d", NetTimeOffset);
167 setenv("timeoffset", tmp);
wdenkb4ad9622005-04-01 00:25:43 +0000168 }
169#endif
Jon Loeligerd76b5c12007-07-08 18:02:23 -0500170#if defined(CONFIG_CMD_SNTP) \
Jon Loeliger5336a762007-07-09 22:08:34 -0500171 && defined(CONFIG_BOOTP_NTPSERVER)
wdenkb4ad9622005-04-01 00:25:43 +0000172 if (NetNtpServerIP) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000173 ip_to_string(NetNtpServerIP, tmp);
174 setenv("ntpserverip", tmp);
wdenkb4ad9622005-04-01 00:25:43 +0000175 }
176#endif
wdenk38635852002-08-27 05:55:31 +0000177}
wdenk05939202004-04-18 17:39:38 +0000178
Simon Glassd6c5f552011-10-24 18:00:02 +0000179static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
180 char * const argv[])
wdenk38635852002-08-27 05:55:31 +0000181{
182 char *s;
Peter Tyser24c297d2008-12-02 12:59:51 -0600183 char *end;
wdenk38635852002-08-27 05:55:31 +0000184 int rcode = 0;
185 int size;
Peter Tyser24c297d2008-12-02 12:59:51 -0600186 ulong addr;
wdenk38635852002-08-27 05:55:31 +0000187
188 /* pre-set load_addr */
189 if ((s = getenv("loadaddr")) != NULL) {
190 load_addr = simple_strtoul(s, NULL, 16);
191 }
192
193 switch (argc) {
194 case 1:
195 break;
196
Peter Tyser24c297d2008-12-02 12:59:51 -0600197 case 2: /*
198 * Only one arg - accept two forms:
199 * Just load address, or just boot file name. The latter
200 * form must be written in a format which can not be
201 * mis-interpreted as a valid number.
wdenk38635852002-08-27 05:55:31 +0000202 */
Peter Tyser24c297d2008-12-02 12:59:51 -0600203 addr = simple_strtoul(argv[1], &end, 16);
204 if (end == (argv[1] + strlen(argv[1])))
205 load_addr = addr;
206 else
207 copy_filename(BootFile, argv[1], sizeof(BootFile));
wdenk38635852002-08-27 05:55:31 +0000208 break;
209
210 case 3: load_addr = simple_strtoul(argv[1], NULL, 16);
Kim Phillipsdc00a682012-10-29 13:34:31 +0000211 copy_filename(BootFile, argv[2], sizeof(BootFile));
wdenk38635852002-08-27 05:55:31 +0000212
213 break;
214
Simon Glass85d96ec2011-10-24 18:00:08 +0000215#ifdef CONFIG_CMD_TFTPPUT
216 case 4:
Simon Glass778fe692011-12-19 16:10:43 +0000217 if (strict_strtoul(argv[1], 16, &save_addr) < 0 ||
218 strict_strtoul(argv[2], 16, &save_size) < 0) {
219 printf("Invalid address/size\n");
220 return cmd_usage(cmdtp);
221 }
Simon Glass85d96ec2011-10-24 18:00:08 +0000222 copy_filename(BootFile, argv[3], sizeof(BootFile));
223 break;
224#endif
Wolfgang Denk3b683112010-07-17 01:06:04 +0200225 default:
Simon Glass0169e6b2012-02-13 13:51:18 +0000226 bootstage_error(BOOTSTAGE_ID_NET_START);
Simon Glassa06dfc72011-12-10 08:44:01 +0000227 return CMD_RET_USAGE;
wdenk38635852002-08-27 05:55:31 +0000228 }
Simon Glass0169e6b2012-02-13 13:51:18 +0000229 bootstage_mark(BOOTSTAGE_ID_NET_START);
wdenk38635852002-08-27 05:55:31 +0000230
Heiko Schocher633e03a2007-06-22 19:11:54 +0200231 if ((size = NetLoop(proto)) < 0) {
Simon Glass0169e6b2012-02-13 13:51:18 +0000232 bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK);
wdenk38635852002-08-27 05:55:31 +0000233 return 1;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200234 }
Simon Glass0169e6b2012-02-13 13:51:18 +0000235 bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK);
wdenk38635852002-08-27 05:55:31 +0000236
237 /* NetLoop ok, update environment */
238 netboot_update_env();
239
wdenkc217f6d2002-11-11 02:11:37 +0000240 /* done if no file was loaded (no errors though) */
Heiko Schocher633e03a2007-06-22 19:11:54 +0200241 if (size == 0) {
Simon Glass0169e6b2012-02-13 13:51:18 +0000242 bootstage_error(BOOTSTAGE_ID_NET_LOADED);
wdenkc217f6d2002-11-11 02:11:37 +0000243 return 0;
Heiko Schocher633e03a2007-06-22 19:11:54 +0200244 }
wdenkc217f6d2002-11-11 02:11:37 +0000245
wdenk38635852002-08-27 05:55:31 +0000246 /* flush cache */
247 flush_cache(load_addr, size);
248
Simon Glass0169e6b2012-02-13 13:51:18 +0000249 bootstage_mark(BOOTSTAGE_ID_NET_LOADED);
Simon Glass964d1d42012-01-14 15:24:52 +0000250
Mike Frysinger194c2e82011-06-05 13:43:02 +0000251 rcode = bootm_maybe_autostart(cmdtp, argv[0]);
wdenk38635852002-08-27 05:55:31 +0000252
Heiko Schocher633e03a2007-06-22 19:11:54 +0200253 if (rcode < 0)
Simon Glass0169e6b2012-02-13 13:51:18 +0000254 bootstage_error(BOOTSTAGE_ID_NET_DONE_ERR);
Heiko Schocher633e03a2007-06-22 19:11:54 +0200255 else
Simon Glass0169e6b2012-02-13 13:51:18 +0000256 bootstage_mark(BOOTSTAGE_ID_NET_DONE);
wdenk38635852002-08-27 05:55:31 +0000257 return rcode;
258}
wdenke6466f62003-06-05 19:27:42 +0000259
Jon Loeligerd76b5c12007-07-08 18:02:23 -0500260#if defined(CONFIG_CMD_PING)
Kim Phillipsdc00a682012-10-29 13:34:31 +0000261static int do_ping(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenke6466f62003-06-05 19:27:42 +0000262{
263 if (argc < 2)
264 return -1;
265
266 NetPingIP = string_to_ip(argv[1]);
Wolfgang Denk3b683112010-07-17 01:06:04 +0200267 if (NetPingIP == 0)
Simon Glassa06dfc72011-12-10 08:44:01 +0000268 return CMD_RET_USAGE;
wdenke6466f62003-06-05 19:27:42 +0000269
270 if (NetLoop(PING) < 0) {
271 printf("ping failed; host %s is not alive\n", argv[1]);
272 return 1;
273 }
274
275 printf("host %s is alive\n", argv[1]);
276
277 return 0;
278}
wdenkca9bc762003-07-15 07:45:49 +0000279
280U_BOOT_CMD(
281 ping, 2, 1, do_ping,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600282 "send ICMP ECHO_REQUEST to network host",
Wolfgang Denkc54781c2009-05-24 17:06:54 +0200283 "pingAddress"
wdenkca9bc762003-07-15 07:45:49 +0000284);
Jon Loeligerd704d912007-07-10 11:02:44 -0500285#endif
wdenk38635852002-08-27 05:55:31 +0000286
Jon Loeligerd76b5c12007-07-08 18:02:23 -0500287#if defined(CONFIG_CMD_CDP)
wdenk145d2c12004-04-15 21:48:45 +0000288
289static void cdp_update_env(void)
290{
291 char tmp[16];
292
293 if (CDPApplianceVLAN != htons(-1)) {
294 printf("CDP offered appliance VLAN %d\n", ntohs(CDPApplianceVLAN));
295 VLAN_to_string(CDPApplianceVLAN, tmp);
296 setenv("vlan", tmp);
297 NetOurVLAN = CDPApplianceVLAN;
298 }
299
300 if (CDPNativeVLAN != htons(-1)) {
301 printf("CDP offered native VLAN %d\n", ntohs(CDPNativeVLAN));
302 VLAN_to_string(CDPNativeVLAN, tmp);
303 setenv("nvlan", tmp);
304 NetOurNativeVLAN = CDPNativeVLAN;
305 }
306
307}
308
Kim Phillipsdc00a682012-10-29 13:34:31 +0000309int do_cdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenk145d2c12004-04-15 21:48:45 +0000310{
311 int r;
312
313 r = NetLoop(CDP);
314 if (r < 0) {
315 printf("cdp failed; perhaps not a CISCO switch?\n");
316 return 1;
317 }
318
319 cdp_update_env();
320
321 return 0;
322}
323
324U_BOOT_CMD(
325 cdp, 1, 1, do_cdp,
Wolfgang Denkd29afc32010-10-26 23:42:23 +0200326 "Perform CDP network configuration",
Wolfgang Denkf003d922010-12-23 17:02:18 +0100327 "\n"
wdenk145d2c12004-04-15 21:48:45 +0000328);
Jon Loeligerd704d912007-07-10 11:02:44 -0500329#endif
wdenk145d2c12004-04-15 21:48:45 +0000330
Jon Loeligerd76b5c12007-07-08 18:02:23 -0500331#if defined(CONFIG_CMD_SNTP)
Kim Phillipsdc00a682012-10-29 13:34:31 +0000332int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
wdenkb4ad9622005-04-01 00:25:43 +0000333{
334 char *toff;
335
336 if (argc < 2) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000337 NetNtpServerIP = getenv_IPaddr("ntpserverip");
wdenkb4ad9622005-04-01 00:25:43 +0000338 if (NetNtpServerIP == 0) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000339 printf("ntpserverip not set\n");
wdenkb4ad9622005-04-01 00:25:43 +0000340 return (1);
341 }
342 } else {
343 NetNtpServerIP = string_to_ip(argv[1]);
344 if (NetNtpServerIP == 0) {
Kim Phillipsdc00a682012-10-29 13:34:31 +0000345 printf("Bad NTP server IP address\n");
wdenkb4ad9622005-04-01 00:25:43 +0000346 return (1);
347 }
348 }
349
Kim Phillipsdc00a682012-10-29 13:34:31 +0000350 toff = getenv("timeoffset");
351 if (toff == NULL)
352 NetTimeOffset = 0;
353 else
354 NetTimeOffset = simple_strtol(toff, NULL, 10);
wdenkb4ad9622005-04-01 00:25:43 +0000355
356 if (NetLoop(SNTP) < 0) {
Luuk Paulussen7cb3f892011-05-16 18:27:11 +0000357 printf("SNTP failed: host %pI4 not responding\n",
358 &NetNtpServerIP);
wdenkb4ad9622005-04-01 00:25:43 +0000359 return 1;
360 }
361
362 return 0;
363}
364
365U_BOOT_CMD(
366 sntp, 2, 1, do_sntp,
Peter Tyserdfb72b82009-01-27 18:03:12 -0600367 "synchronize RTC via network",
wdenkb4ad9622005-04-01 00:25:43 +0000368 "[NTP server IP]\n"
369);
Jon Loeligerd704d912007-07-10 11:02:44 -0500370#endif
Robin Getz82f0d232009-07-20 14:53:54 -0400371
372#if defined(CONFIG_CMD_DNS)
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200373int do_dns(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Robin Getz82f0d232009-07-20 14:53:54 -0400374{
Wolfgang Denk3b683112010-07-17 01:06:04 +0200375 if (argc == 1)
Simon Glassa06dfc72011-12-10 08:44:01 +0000376 return CMD_RET_USAGE;
Robin Getz82f0d232009-07-20 14:53:54 -0400377
378 /*
379 * We should check for a valid hostname:
380 * - Each label must be between 1 and 63 characters long
381 * - the entire hostname has a maximum of 255 characters
382 * - only the ASCII letters 'a' through 'z' (case-insensitive),
383 * the digits '0' through '9', and the hyphen
384 * - cannot begin or end with a hyphen
385 * - no other symbols, punctuation characters, or blank spaces are
386 * permitted
387 * but hey - this is a minimalist implmentation, so only check length
388 * and let the name server deal with things.
389 */
390 if (strlen(argv[1]) >= 255) {
391 printf("dns error: hostname too long\n");
392 return 1;
393 }
394
395 NetDNSResolve = argv[1];
396
397 if (argc == 3)
398 NetDNSenvvar = argv[2];
399 else
400 NetDNSenvvar = NULL;
401
402 if (NetLoop(DNS) < 0) {
403 printf("dns lookup of %s failed, check setup\n", argv[1]);
404 return 1;
405 }
406
407 return 0;
408}
409
410U_BOOT_CMD(
411 dns, 3, 1, do_dns,
412 "lookup the IP of a hostname",
413 "hostname [envvar]"
414);
415
416#endif /* CONFIG_CMD_DNS */
Joe Hershbergerb35a3a62012-05-23 08:00:12 +0000417
418#if defined(CONFIG_CMD_LINK_LOCAL)
419static int do_link_local(cmd_tbl_t *cmdtp, int flag, int argc,
420 char * const argv[])
421{
422 char tmp[22];
423
424 if (NetLoop(LINKLOCAL) < 0)
425 return 1;
426
427 NetOurGatewayIP = 0;
428 ip_to_string(NetOurGatewayIP, tmp);
429 setenv("gatewayip", tmp);
430
431 ip_to_string(NetOurSubnetMask, tmp);
432 setenv("netmask", tmp);
433
434 ip_to_string(NetOurIP, tmp);
435 setenv("ipaddr", tmp);
436 setenv("llipaddr", tmp); /* store this for next time */
437
438 return 0;
439}
440
441U_BOOT_CMD(
442 linklocal, 1, 1, do_link_local,
443 "acquire a network IP address using the link-local protocol",
444 ""
445);
446
447#endif /* CONFIG_CMD_LINK_LOCAL */