net: ping6: Add ping6 command

Implement ping6 command to ping hosts using IPv6. It works the same way as
an ordinary ping command. There is no ICMP request so it is not possible
to ping our host. This patch adds options in Kconfig and Makefile to
build ping6 command.

Series-changes: 3
- Added structures and functions descriptions
- Added to ping6_receive() return value instead of void

Series-changes: 4
- Fixed structures and functions description style

Signed-off-by: Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Viacheslav Mitrofanov
2022-12-02 12:18:08 +03:00
committed by Tom Rini
parent 7fbf230d79
commit eeb0a2c693
8 changed files with 197 additions and 2 deletions

View File

@@ -1847,6 +1847,13 @@ config CMD_PING
help
Send ICMP ECHO_REQUEST to network host
config CMD_PING6
bool "ping6"
depends on IPV6
default y if (CMD_PING && IPV6)
help
Send ICMPv6 ECHO_REQUEST to network host
config CMD_CDP
bool "cdp"
help

View File

@@ -403,6 +403,32 @@ U_BOOT_CMD(
);
#endif
#if IS_ENABLED(CONFIG_CMD_PING6)
int do_ping6(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[])
{
if (string_to_ip6(argv[1], strlen(argv[1]), &net_ping_ip6))
return CMD_RET_USAGE;
use_ip6 = true;
if (net_loop(PING6) < 0) {
use_ip6 = false;
printf("ping6 failed; host %pI6c is not alive\n",
&net_ping_ip6);
return 1;
}
use_ip6 = false;
printf("host %pI6c is alive\n", &net_ping_ip6);
return 0;
}
U_BOOT_CMD(
ping6, 2, 1, do_ping6,
"send ICMPv6 ECHO_REQUEST to network host",
"pingAddress"
);
#endif /* CONFIG_CMD_PING6 */
#if defined(CONFIG_CMD_CDP)
static void cdp_update_env(void)