[U-Boot-Users] [PATCH 9/11] Add default IP addr to ping command
Keith J Outwater
kjoutwater at raytheon.com
Fri May 5 20:16:35 CEST 2006
The patch below adds a default address (taken from the environment) to the
ping command.
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 2cb2c5d..9b6a117 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -223,21 +223,34 @@ #endif
#if (CONFIG_COMMANDS & CFG_CMD_PING)
int do_ping (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
- if (argc < 2)
- return -1;
+ char *s;
+ char *host;
+
+ if (argc < 2) {
+ if ((s = getenv("serverip")) != NULL) {
+ NetPingIP = string_to_ip(s);
+ host = s;
+ }
+ else {
+ return -1;
+ }
+ }
+ else {
+ NetPingIP = string_to_ip(argv[1]);
+ host = argv[1];
+ }
- NetPingIP = string_to_ip(argv[1]);
if (NetPingIP == 0) {
printf ("Usage:\n%s\n", cmdtp->usage);
return -1;
}
if (NetLoop(PING) < 0) {
- printf("ping failed; host %s is not alive\n", argv[1]);
+ printf("ping failed; host %s is not alive\n", host);
return 1;
}
- printf("host %s is alive\n", argv[1]);
+ printf("host %s is alive\n", host);
return 0;
}
@@ -245,7 +258,7 @@ int do_ping (cmd_tbl_t *cmdtp, int flag,
U_BOOT_CMD(
ping, 2, 1, do_ping,
"ping\t- send ICMP ECHO_REQUEST to network host\n",
- "pingAddress\n"
+ "pingAddress (default is $serverip)\n"
);
#endif /* CFG_CMD_PING */
Signed-off-by: Keith Outwater <outwater4 at comcast.net>
More information about the U-Boot
mailing list