net: shell: Handle ENETUNREACH for IPv4 ping
This commit updates the the IPv4 ping command to handle the ENETUNREACH error number returned by `net_icmpv4_send_echo_request` function when IPv4 is unavailable. The `net_icmpv4_send_echo_request` function previously returned EINVAL when IPv4 is unavailable and this caused the shell command to report "Invalid IP address" even when the provided IP address is correct; this problem was corrected by returning ENETUNREACH instead of EINVAL in the aforementioned function. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
parent
2c733d5195
commit
5aa62369d4
1 changed files with 1 additions and 1 deletions
|
@ -3155,7 +3155,7 @@ static int cmd_net_ping(const struct shell *shell, size_t argc, char *argv[])
|
|||
if (IS_ENABLED(CONFIG_NET_IPV4)) {
|
||||
ret = ping_ipv4(shell, host, count, interval);
|
||||
if (ret) {
|
||||
if (ret == -EIO) {
|
||||
if (ret == -EIO || ret == -ENETUNREACH) {
|
||||
PR_WARNING("Cannot send IPv4 ping\n");
|
||||
} else if (ret == -EINVAL) {
|
||||
PR_WARNING("Invalid IP address\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue