Blame view
cmd/net.c
9.67 KB
3863585bb Initial revision |
1 2 3 4 |
/* * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * |
1a4596601 Add GPL-2.0+ SPDX... |
5 |
* SPDX-License-Identifier: GPL-2.0+ |
3863585bb Initial revision |
6 7 8 9 10 11 12 |
*/ /* * Boot support */ #include <common.h> #include <command.h> |
3863585bb Initial revision |
13 |
#include <net.h> |
e4bf0c5cf net: tftpput: Ren... |
14 |
static int netboot_common(enum proto_t, cmd_tbl_t *, int, char * const []); |
3863585bb Initial revision |
15 |
|
088f1b199 common/cmd_*.c: s... |
16 |
static int do_bootp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
17 |
{ |
088f1b199 common/cmd_*.c: s... |
18 |
return netboot_common(BOOTP, cmdtp, argc, argv); |
3863585bb Initial revision |
19 |
} |
0d4983930 Patch by Kenneth ... |
20 21 |
U_BOOT_CMD( bootp, 3, 1, do_bootp, |
2fb2604d5 Command usage cle... |
22 |
"boot image via network using BOOTP/TFTP protocol", |
a89c33db9 General help mess... |
23 |
"[loadAddress] [[hostIPaddr:]bootfilename]" |
8bde7f776 * Code cleanup: |
24 |
); |
088f1b199 common/cmd_*.c: s... |
25 |
int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
26 |
{ |
573f14fe4 bootstage: Plumb ... |
27 28 29 30 31 32 |
int ret; bootstage_mark_name(BOOTSTAGE_KERNELREAD_START, "tftp_start"); ret = netboot_common(TFTPGET, cmdtp, argc, argv); bootstage_mark_name(BOOTSTAGE_KERNELREAD_STOP, "tftp_done"); return ret; |
3863585bb Initial revision |
33 |
} |
0d4983930 Patch by Kenneth ... |
34 35 |
U_BOOT_CMD( tftpboot, 3, 1, do_tftpb, |
2fb2604d5 Command usage cle... |
36 |
"boot image via network using TFTP protocol", |
a89c33db9 General help mess... |
37 |
"[loadAddress] [[hostIPaddr:]bootfilename]" |
8bde7f776 * Code cleanup: |
38 |
); |
2d46cf291 net: tftpput: add... |
39 |
#ifdef CONFIG_CMD_TFTPPUT |
0c1b869b2 net: add static t... |
40 |
static int do_tftpput(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
2d46cf291 net: tftpput: add... |
41 |
{ |
85848f037 cmd: net: Clean u... |
42 |
return netboot_common(TFTPPUT, cmdtp, argc, argv); |
2d46cf291 net: tftpput: add... |
43 44 45 46 47 48 49 50 |
} U_BOOT_CMD( tftpput, 4, 1, do_tftpput, "TFTP put command, for uploading files to a server", "Address Size [[hostIPaddr:]filename]" ); #endif |
7a83af07a TFTP: add tftpsrv... |
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
#ifdef CONFIG_CMD_TFTPSRV static int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { return netboot_common(TFTPSRV, cmdtp, argc, argv); } U_BOOT_CMD( tftpsrv, 2, 1, do_tftpsrv, "act as a TFTP server and boot the first received file", "[loadAddress] " "Listen for an incoming TFTP transfer, receive a file and boot it. " "The transfer is aborted if a transfer has not been started after " "about 50 seconds or if Ctrl-C is pressed." ); #endif |
bf6cb247a rarp: Condtionall... |
69 |
#ifdef CONFIG_CMD_RARP |
088f1b199 common/cmd_*.c: s... |
70 |
int do_rarpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
71 |
{ |
088f1b199 common/cmd_*.c: s... |
72 |
return netboot_common(RARP, cmdtp, argc, argv); |
3863585bb Initial revision |
73 |
} |
0d4983930 Patch by Kenneth ... |
74 75 |
U_BOOT_CMD( rarpboot, 3, 1, do_rarpb, |
2fb2604d5 Command usage cle... |
76 |
"boot image via network using RARP/TFTP protocol", |
a89c33db9 General help mess... |
77 |
"[loadAddress] [[hostIPaddr:]bootfilename]" |
8bde7f776 * Code cleanup: |
78 |
); |
bf6cb247a rarp: Condtionall... |
79 |
#endif |
8bde7f776 * Code cleanup: |
80 |
|
c76fe4742 common/cmd_[i-n]*... |
81 |
#if defined(CONFIG_CMD_DHCP) |
088f1b199 common/cmd_*.c: s... |
82 |
static int do_dhcp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb Initial revision |
83 84 85 |
{ return netboot_common(DHCP, cmdtp, argc, argv); } |
8bde7f776 * Code cleanup: |
86 |
|
0d4983930 Patch by Kenneth ... |
87 88 |
U_BOOT_CMD( dhcp, 3, 1, do_dhcp, |
2fb2604d5 Command usage cle... |
89 |
"boot image via network using DHCP/TFTP protocol", |
a89c33db9 General help mess... |
90 |
"[loadAddress] [[hostIPaddr:]bootfilename]" |
8bde7f776 * Code cleanup: |
91 |
); |
902531788 common/: Remove l... |
92 |
#endif |
3863585bb Initial revision |
93 |
|
c76fe4742 common/cmd_[i-n]*... |
94 |
#if defined(CONFIG_CMD_NFS) |
088f1b199 common/cmd_*.c: s... |
95 |
static int do_nfs(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
cbd8a35c6 * Patch by Masami... |
96 97 98 99 100 101 |
{ return netboot_common(NFS, cmdtp, argc, argv); } U_BOOT_CMD( nfs, 3, 1, do_nfs, |
2fb2604d5 Command usage cle... |
102 |
"boot image via network using NFS protocol", |
a89c33db9 General help mess... |
103 |
"[loadAddress] [[hostIPaddr:]bootfilename]" |
cbd8a35c6 * Patch by Masami... |
104 |
); |
902531788 common/: Remove l... |
105 |
#endif |
cbd8a35c6 * Patch by Masami... |
106 |
|
088f1b199 common/cmd_*.c: s... |
107 |
static void netboot_update_env(void) |
3863585bb Initial revision |
108 |
{ |
6e5923851 * Cleanup, minor ... |
109 |
char tmp[22]; |
3863585bb Initial revision |
110 |
|
049a95a77 net: cosmetic: Ch... |
111 112 |
if (net_gateway.s_addr) { ip_to_string(net_gateway, tmp); |
382bee57f env: Rename seten... |
113 |
env_set("gatewayip", tmp); |
6e5923851 * Cleanup, minor ... |
114 |
} |
3863585bb Initial revision |
115 |
|
049a95a77 net: cosmetic: Ch... |
116 117 |
if (net_netmask.s_addr) { ip_to_string(net_netmask, tmp); |
382bee57f env: Rename seten... |
118 |
env_set("netmask", tmp); |
6e5923851 * Cleanup, minor ... |
119 |
} |
3863585bb Initial revision |
120 |
|
586cbe51a net: cosmetic: Fi... |
121 |
if (net_hostname[0]) |
382bee57f env: Rename seten... |
122 |
env_set("hostname", net_hostname); |
3863585bb Initial revision |
123 |
|
586cbe51a net: cosmetic: Fi... |
124 |
if (net_root_path[0]) |
382bee57f env: Rename seten... |
125 |
env_set("rootpath", net_root_path); |
3863585bb Initial revision |
126 |
|
049a95a77 net: cosmetic: Ch... |
127 128 |
if (net_ip.s_addr) { ip_to_string(net_ip, tmp); |
382bee57f env: Rename seten... |
129 |
env_set("ipaddr", tmp); |
6e5923851 * Cleanup, minor ... |
130 |
} |
a3e1a727f net: Don't write ... |
131 132 |
#if !defined(CONFIG_BOOTP_SERVERIP) /* |
ff78ad284 cmd: net: fix fun... |
133 |
* Only attempt to change serverip if net/bootp.c:store_net_params() |
a3e1a727f net: Don't write ... |
134 135 |
* could have set it */ |
049a95a77 net: cosmetic: Ch... |
136 137 |
if (net_server_ip.s_addr) { ip_to_string(net_server_ip, tmp); |
382bee57f env: Rename seten... |
138 |
env_set("serverip", tmp); |
6e5923851 * Cleanup, minor ... |
139 |
} |
a3e1a727f net: Don't write ... |
140 |
#endif |
049a95a77 net: cosmetic: Ch... |
141 142 |
if (net_dns_server.s_addr) { ip_to_string(net_dns_server, tmp); |
382bee57f env: Rename seten... |
143 |
env_set("dnsip", tmp); |
6e5923851 * Cleanup, minor ... |
144 |
} |
1fe80d79c Finally retire cm... |
145 |
#if defined(CONFIG_BOOTP_DNS2) |
049a95a77 net: cosmetic: Ch... |
146 147 |
if (net_dns_server2.s_addr) { ip_to_string(net_dns_server2, tmp); |
382bee57f env: Rename seten... |
148 |
env_set("dnsip2", tmp); |
6e5923851 * Cleanup, minor ... |
149 |
} |
fe389a82c - Added CONFIG_BO... |
150 |
#endif |
586cbe51a net: cosmetic: Fi... |
151 |
if (net_nis_domain[0]) |
382bee57f env: Rename seten... |
152 |
env_set("domain", net_nis_domain); |
ea287debe * Patch by Masami... |
153 |
|
4fd5055f5 net: cosmetic: Cl... |
154 |
#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET) |
bc0571fc1 net: cosmetic: Fi... |
155 156 |
if (net_ntp_time_offset) { sprintf(tmp, "%d", net_ntp_time_offset); |
382bee57f env: Rename seten... |
157 |
env_set("timeoffset", tmp); |
ea287debe * Patch by Masami... |
158 159 |
} #endif |
4fd5055f5 net: cosmetic: Cl... |
160 |
#if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER) |
049a95a77 net: cosmetic: Ch... |
161 162 |
if (net_ntp_server.s_addr) { ip_to_string(net_ntp_server, tmp); |
382bee57f env: Rename seten... |
163 |
env_set("ntpserverip", tmp); |
ea287debe * Patch by Masami... |
164 165 |
} #endif |
3863585bb Initial revision |
166 |
} |
6e5923851 * Cleanup, minor ... |
167 |
|
e4bf0c5cf net: tftpput: Ren... |
168 169 |
static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc, char * const argv[]) |
3863585bb Initial revision |
170 171 |
{ char *s; |
2e4970d81 net: Fix download... |
172 |
char *end; |
3863585bb Initial revision |
173 174 |
int rcode = 0; int size; |
2e4970d81 net: Fix download... |
175 |
ulong addr; |
3863585bb Initial revision |
176 177 |
/* pre-set load_addr */ |
00caae6d4 env: Rename geten... |
178 |
s = env_get("loadaddr"); |
4fd5055f5 net: cosmetic: Cl... |
179 |
if (s != NULL) |
3863585bb Initial revision |
180 |
load_addr = simple_strtoul(s, NULL, 16); |
3863585bb Initial revision |
181 182 183 184 |
switch (argc) { case 1: break; |
2e4970d81 net: Fix download... |
185 186 187 188 189 |
case 2: /* * Only one arg - accept two forms: * Just load address, or just boot file name. The latter * form must be written in a format which can not be * mis-interpreted as a valid number. |
3863585bb Initial revision |
190 |
*/ |
2e4970d81 net: Fix download... |
191 192 193 194 |
addr = simple_strtoul(argv[1], &end, 16); if (end == (argv[1] + strlen(argv[1]))) load_addr = addr; else |
1411157d8 net: cosmetic: Fi... |
195 196 |
copy_filename(net_boot_file_name, argv[1], sizeof(net_boot_file_name)); |
3863585bb Initial revision |
197 |
break; |
4fd5055f5 net: cosmetic: Cl... |
198 199 |
case 3: load_addr = simple_strtoul(argv[1], NULL, 16); |
1411157d8 net: cosmetic: Fi... |
200 201 |
copy_filename(net_boot_file_name, argv[2], sizeof(net_boot_file_name)); |
3863585bb Initial revision |
202 203 |
break; |
2d46cf291 net: tftpput: add... |
204 205 |
#ifdef CONFIG_CMD_TFTPPUT case 4: |
38bd80b48 net: Fix argument... |
206 |
if (strict_strtoul(argv[1], 16, &save_addr) < 0 || |
4fd5055f5 net: cosmetic: Cl... |
207 |
strict_strtoul(argv[2], 16, &save_size) < 0) { |
38bd80b48 net: Fix argument... |
208 209 |
printf("Invalid address/size "); |
85848f037 cmd: net: Clean u... |
210 |
return CMD_RET_USAGE; |
38bd80b48 net: Fix argument... |
211 |
} |
1411157d8 net: cosmetic: Fi... |
212 213 |
copy_filename(net_boot_file_name, argv[3], sizeof(net_boot_file_name)); |
2d46cf291 net: tftpput: add... |
214 215 |
break; #endif |
47e26b1bf cmd_usage(): simp... |
216 |
default: |
770605e4f bootstage: Replac... |
217 |
bootstage_error(BOOTSTAGE_ID_NET_START); |
4c12eeb8b Convert cmd_usage... |
218 |
return CMD_RET_USAGE; |
3863585bb Initial revision |
219 |
} |
770605e4f bootstage: Replac... |
220 |
bootstage_mark(BOOTSTAGE_ID_NET_START); |
3863585bb Initial revision |
221 |
|
bc0571fc1 net: cosmetic: Fi... |
222 |
size = net_loop(proto); |
4fd5055f5 net: cosmetic: Cl... |
223 |
if (size < 0) { |
770605e4f bootstage: Replac... |
224 |
bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); |
85848f037 cmd: net: Clean u... |
225 |
return CMD_RET_FAILURE; |
566a494f5 [PCS440EP] u... |
226 |
} |
770605e4f bootstage: Replac... |
227 |
bootstage_mark(BOOTSTAGE_ID_NET_NETLOOP_OK); |
3863585bb Initial revision |
228 |
|
bc0571fc1 net: cosmetic: Fi... |
229 |
/* net_loop ok, update environment */ |
3863585bb Initial revision |
230 |
netboot_update_env(); |
eb9401e3e * Patch by Andrea... |
231 |
/* done if no file was loaded (no errors though) */ |
566a494f5 [PCS440EP] u... |
232 |
if (size == 0) { |
770605e4f bootstage: Replac... |
233 |
bootstage_error(BOOTSTAGE_ID_NET_LOADED); |
85848f037 cmd: net: Clean u... |
234 |
return CMD_RET_SUCCESS; |
566a494f5 [PCS440EP] u... |
235 |
} |
eb9401e3e * Patch by Andrea... |
236 |
|
770605e4f bootstage: Replac... |
237 |
bootstage_mark(BOOTSTAGE_ID_NET_LOADED); |
c8e66db78 bootstage: Conver... |
238 |
|
67d668bf9 autostart: unify ... |
239 |
rcode = bootm_maybe_autostart(cmdtp, argv[0]); |
3863585bb Initial revision |
240 |
|
85848f037 cmd: net: Clean u... |
241 |
if (rcode == CMD_RET_SUCCESS) |
770605e4f bootstage: Replac... |
242 |
bootstage_mark(BOOTSTAGE_ID_NET_DONE); |
85848f037 cmd: net: Clean u... |
243 244 |
else bootstage_error(BOOTSTAGE_ID_NET_DONE_ERR); |
3863585bb Initial revision |
245 246 |
return rcode; } |
c76fe4742 common/cmd_[i-n]*... |
247 |
#if defined(CONFIG_CMD_PING) |
088f1b199 common/cmd_*.c: s... |
248 |
static int do_ping(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
73a8b27c5 * Add support for... |
249 250 |
{ if (argc < 2) |
85848f037 cmd: net: Clean u... |
251 |
return CMD_RET_USAGE; |
73a8b27c5 * Add support for... |
252 |
|
049a95a77 net: cosmetic: Ch... |
253 254 |
net_ping_ip = string_to_ip(argv[1]); if (net_ping_ip.s_addr == 0) |
4c12eeb8b Convert cmd_usage... |
255 |
return CMD_RET_USAGE; |
73a8b27c5 * Add support for... |
256 |
|
bc0571fc1 net: cosmetic: Fi... |
257 |
if (net_loop(PING) < 0) { |
73a8b27c5 * Add support for... |
258 259 |
printf("ping failed; host %s is not alive ", argv[1]); |
85848f037 cmd: net: Clean u... |
260 |
return CMD_RET_FAILURE; |
73a8b27c5 * Add support for... |
261 262 263 264 |
} printf("host %s is alive ", argv[1]); |
85848f037 cmd: net: Clean u... |
265 |
return CMD_RET_SUCCESS; |
73a8b27c5 * Add support for... |
266 |
} |
6dff55297 * Patches by Mart... |
267 268 269 |
U_BOOT_CMD( ping, 2, 1, do_ping, |
2fb2604d5 Command usage cle... |
270 |
"send ICMP ECHO_REQUEST to network host", |
a89c33db9 General help mess... |
271 |
"pingAddress" |
6dff55297 * Patches by Mart... |
272 |
); |
902531788 common/: Remove l... |
273 |
#endif |
73a8b27c5 * Add support for... |
274 |
|
c76fe4742 common/cmd_[i-n]*... |
275 |
#if defined(CONFIG_CMD_CDP) |
a3d991bd0 Patches by Pantel... |
276 277 278 279 |
static void cdp_update_env(void) { char tmp[16]; |
6aede5b75 net: cosmetic: Cl... |
280 281 282 283 |
if (cdp_appliance_vlan != htons(-1)) { printf("CDP offered appliance VLAN %d ", ntohs(cdp_appliance_vlan)); |
4fd5055f5 net: cosmetic: Cl... |
284 |
vlan_to_string(cdp_appliance_vlan, tmp); |
382bee57f env: Rename seten... |
285 |
env_set("vlan", tmp); |
4fd5055f5 net: cosmetic: Cl... |
286 |
net_our_vlan = cdp_appliance_vlan; |
a3d991bd0 Patches by Pantel... |
287 |
} |
6aede5b75 net: cosmetic: Cl... |
288 289 290 |
if (cdp_native_vlan != htons(-1)) { printf("CDP offered native VLAN %d ", ntohs(cdp_native_vlan)); |
4fd5055f5 net: cosmetic: Cl... |
291 |
vlan_to_string(cdp_native_vlan, tmp); |
382bee57f env: Rename seten... |
292 |
env_set("nvlan", tmp); |
4fd5055f5 net: cosmetic: Cl... |
293 |
net_native_vlan = cdp_native_vlan; |
a3d991bd0 Patches by Pantel... |
294 |
} |
a3d991bd0 Patches by Pantel... |
295 |
} |
088f1b199 common/cmd_*.c: s... |
296 |
int do_cdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
a3d991bd0 Patches by Pantel... |
297 298 |
{ int r; |
bc0571fc1 net: cosmetic: Fi... |
299 |
r = net_loop(CDP); |
a3d991bd0 Patches by Pantel... |
300 301 302 |
if (r < 0) { printf("cdp failed; perhaps not a CISCO switch? "); |
85848f037 cmd: net: Clean u... |
303 |
return CMD_RET_FAILURE; |
a3d991bd0 Patches by Pantel... |
304 305 306 |
} cdp_update_env(); |
85848f037 cmd: net: Clean u... |
307 |
return CMD_RET_SUCCESS; |
a3d991bd0 Patches by Pantel... |
308 309 310 311 |
} U_BOOT_CMD( cdp, 1, 1, do_cdp, |
ec5c04cdb Revert "cmd_net: ... |
312 |
"Perform CDP network configuration", |
4b58266e9 cmd_net.c: fix bu... |
313 314 |
" " |
a3d991bd0 Patches by Pantel... |
315 |
); |
902531788 common/: Remove l... |
316 |
#endif |
a3d991bd0 Patches by Pantel... |
317 |
|
c76fe4742 common/cmd_[i-n]*... |
318 |
#if defined(CONFIG_CMD_SNTP) |
088f1b199 common/cmd_*.c: s... |
319 |
int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
ea287debe * Patch by Masami... |
320 321 322 323 |
{ char *toff; if (argc < 2) { |
723806cc5 env: Rename some ... |
324 |
net_ntp_server = env_get_ip("ntpserverip"); |
049a95a77 net: cosmetic: Ch... |
325 |
if (net_ntp_server.s_addr == 0) { |
088f1b199 common/cmd_*.c: s... |
326 327 |
printf("ntpserverip not set "); |
85848f037 cmd: net: Clean u... |
328 |
return CMD_RET_FAILURE; |
ea287debe * Patch by Masami... |
329 330 |
} } else { |
049a95a77 net: cosmetic: Ch... |
331 332 |
net_ntp_server = string_to_ip(argv[1]); if (net_ntp_server.s_addr == 0) { |
088f1b199 common/cmd_*.c: s... |
333 334 |
printf("Bad NTP server IP address "); |
85848f037 cmd: net: Clean u... |
335 |
return CMD_RET_FAILURE; |
ea287debe * Patch by Masami... |
336 337 |
} } |
00caae6d4 env: Rename geten... |
338 |
toff = env_get("timeoffset"); |
088f1b199 common/cmd_*.c: s... |
339 |
if (toff == NULL) |
bc0571fc1 net: cosmetic: Fi... |
340 |
net_ntp_time_offset = 0; |
088f1b199 common/cmd_*.c: s... |
341 |
else |
bc0571fc1 net: cosmetic: Fi... |
342 |
net_ntp_time_offset = simple_strtol(toff, NULL, 10); |
ea287debe * Patch by Masami... |
343 |
|
bc0571fc1 net: cosmetic: Fi... |
344 |
if (net_loop(SNTP) < 0) { |
d6840e3d7 sntp: avoid use o... |
345 346 |
printf("SNTP failed: host %pI4 not responding ", |
4fd5055f5 net: cosmetic: Cl... |
347 |
&net_ntp_server); |
85848f037 cmd: net: Clean u... |
348 |
return CMD_RET_FAILURE; |
ea287debe * Patch by Masami... |
349 |
} |
85848f037 cmd: net: Clean u... |
350 |
return CMD_RET_SUCCESS; |
ea287debe * Patch by Masami... |
351 352 353 354 |
} U_BOOT_CMD( sntp, 2, 1, do_sntp, |
2fb2604d5 Command usage cle... |
355 |
"synchronize RTC via network", |
ea287debe * Patch by Masami... |
356 357 358 |
"[NTP server IP] " ); |
902531788 common/: Remove l... |
359 |
#endif |
1a32bf418 Add DNS support |
360 361 |
#if defined(CONFIG_CMD_DNS) |
54841ab50 Make sure that ar... |
362 |
int do_dns(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
1a32bf418 Add DNS support |
363 |
{ |
47e26b1bf cmd_usage(): simp... |
364 |
if (argc == 1) |
4c12eeb8b Convert cmd_usage... |
365 |
return CMD_RET_USAGE; |
1a32bf418 Add DNS support |
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
/* * We should check for a valid hostname: * - Each label must be between 1 and 63 characters long * - the entire hostname has a maximum of 255 characters * - only the ASCII letters 'a' through 'z' (case-insensitive), * the digits '0' through '9', and the hyphen * - cannot begin or end with a hyphen * - no other symbols, punctuation characters, or blank spaces are * permitted * but hey - this is a minimalist implmentation, so only check length * and let the name server deal with things. */ if (strlen(argv[1]) >= 255) { printf("dns error: hostname too long "); |
85848f037 cmd: net: Clean u... |
382 |
return CMD_RET_FAILURE; |
1a32bf418 Add DNS support |
383 |
} |
786eac5f9 net: cosmetic: Cl... |
384 |
net_dns_resolve = argv[1]; |
1a32bf418 Add DNS support |
385 386 |
if (argc == 3) |
786eac5f9 net: cosmetic: Cl... |
387 |
net_dns_env_var = argv[2]; |
1a32bf418 Add DNS support |
388 |
else |
786eac5f9 net: cosmetic: Cl... |
389 |
net_dns_env_var = NULL; |
1a32bf418 Add DNS support |
390 |
|
bc0571fc1 net: cosmetic: Fi... |
391 |
if (net_loop(DNS) < 0) { |
1a32bf418 Add DNS support |
392 393 |
printf("dns lookup of %s failed, check setup ", argv[1]); |
85848f037 cmd: net: Clean u... |
394 |
return CMD_RET_FAILURE; |
1a32bf418 Add DNS support |
395 |
} |
85848f037 cmd: net: Clean u... |
396 |
return CMD_RET_SUCCESS; |
1a32bf418 Add DNS support |
397 398 399 400 401 402 403 404 405 |
} U_BOOT_CMD( dns, 3, 1, do_dns, "lookup the IP of a hostname", "hostname [envvar]" ); #endif /* CONFIG_CMD_DNS */ |
d22c338e0 net: Add link-loc... |
406 407 408 409 410 411 |
#if defined(CONFIG_CMD_LINK_LOCAL) static int do_link_local(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { char tmp[22]; |
bc0571fc1 net: cosmetic: Fi... |
412 |
if (net_loop(LINKLOCAL) < 0) |
85848f037 cmd: net: Clean u... |
413 |
return CMD_RET_FAILURE; |
d22c338e0 net: Add link-loc... |
414 |
|
049a95a77 net: cosmetic: Ch... |
415 416 |
net_gateway.s_addr = 0; ip_to_string(net_gateway, tmp); |
382bee57f env: Rename seten... |
417 |
env_set("gatewayip", tmp); |
d22c338e0 net: Add link-loc... |
418 |
|
049a95a77 net: cosmetic: Ch... |
419 |
ip_to_string(net_netmask, tmp); |
382bee57f env: Rename seten... |
420 |
env_set("netmask", tmp); |
d22c338e0 net: Add link-loc... |
421 |
|
049a95a77 net: cosmetic: Ch... |
422 |
ip_to_string(net_ip, tmp); |
382bee57f env: Rename seten... |
423 424 |
env_set("ipaddr", tmp); env_set("llipaddr", tmp); /* store this for next time */ |
d22c338e0 net: Add link-loc... |
425 |
|
85848f037 cmd: net: Clean u... |
426 |
return CMD_RET_SUCCESS; |
d22c338e0 net: Add link-loc... |
427 428 429 430 431 432 433 434 435 |
} U_BOOT_CMD( linklocal, 1, 1, do_link_local, "acquire a network IP address using the link-local protocol", "" ); #endif /* CONFIG_CMD_LINK_LOCAL */ |