net: zperf_shell: Fix IPv6 invalid warning
Fix the ipv6 invalid warning always appearing when a valid ipv4 address is provided. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
parent
cd685bdce8
commit
69e0b03ca9
|
@ -163,9 +163,7 @@ static int parse_ipv6_addr(const struct shell *sh, char *host, char *port,
|
||||||
|
|
||||||
ret = net_addr_pton(AF_INET6, host, &addr->sin6_addr);
|
ret = net_addr_pton(AF_INET6, host, &addr->sin6_addr);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
shell_fprintf(sh, SHELL_WARNING,
|
return -EDESTADDRREQ;
|
||||||
"Invalid IPv6 address %s\n", host);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addr->sin6_port = htons(strtoul(port, NULL, 10));
|
addr->sin6_port = htons(strtoul(port, NULL, 10));
|
||||||
|
@ -189,9 +187,7 @@ static int parse_ipv4_addr(const struct shell *sh, char *host, char *port,
|
||||||
|
|
||||||
ret = net_addr_pton(AF_INET, host, &addr->sin_addr);
|
ret = net_addr_pton(AF_INET, host, &addr->sin_addr);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
shell_fprintf(sh, SHELL_WARNING,
|
return -EDESTADDRREQ;
|
||||||
"Invalid IPv4 address %s\n", host);
|
|
||||||
return -EINVAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addr->sin_port = htons(strtoul(port, NULL, 10));
|
addr->sin_port = htons(strtoul(port, NULL, 10));
|
||||||
|
@ -803,6 +799,7 @@ static int shell_cmd_upload(const struct shell *sh, size_t argc,
|
||||||
bool is_udp;
|
bool is_udp;
|
||||||
int start = 0;
|
int start = 0;
|
||||||
size_t opt_cnt = 0;
|
size_t opt_cnt = 0;
|
||||||
|
int ret;
|
||||||
|
|
||||||
param.options.priority = -1;
|
param.options.priority = -1;
|
||||||
is_udp = proto == IPPROTO_UDP;
|
is_udp = proto == IPPROTO_UDP;
|
||||||
|
@ -907,8 +904,12 @@ static int shell_cmd_upload(const struct shell *sh, size_t argc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV6) && !IS_ENABLED(CONFIG_NET_IPV4)) {
|
if (IS_ENABLED(CONFIG_NET_IPV6) && !IS_ENABLED(CONFIG_NET_IPV4)) {
|
||||||
if (parse_ipv6_addr(sh, argv[start + 1], port_str,
|
ret = parse_ipv6_addr(sh, argv[start + 1], port_str, &ipv6);
|
||||||
&ipv6) < 0) {
|
if (ret == -EDESTADDRREQ) {
|
||||||
|
shell_fprintf(sh, SHELL_WARNING,
|
||||||
|
"Invalid IPv6 address %s\n", argv[start + 1]);
|
||||||
|
}
|
||||||
|
if (ret < 0) {
|
||||||
shell_fprintf(sh, SHELL_WARNING,
|
shell_fprintf(sh, SHELL_WARNING,
|
||||||
"Please specify the IP address of the "
|
"Please specify the IP address of the "
|
||||||
"remote server.\n");
|
"remote server.\n");
|
||||||
|
@ -922,8 +923,12 @@ static int shell_cmd_upload(const struct shell *sh, size_t argc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV4) && !IS_ENABLED(CONFIG_NET_IPV6)) {
|
if (IS_ENABLED(CONFIG_NET_IPV4) && !IS_ENABLED(CONFIG_NET_IPV6)) {
|
||||||
if (parse_ipv4_addr(sh, argv[start + 1], port_str,
|
ret = parse_ipv4_addr(sh, argv[start + 1], port_str, &ipv4);
|
||||||
&ipv4) < 0) {
|
if (ret == -EDESTADDRREQ) {
|
||||||
|
shell_fprintf(sh, SHELL_WARNING,
|
||||||
|
"Invalid IPv4 address %s\n", argv[start + 1]);
|
||||||
|
}
|
||||||
|
if (ret < 0) {
|
||||||
shell_fprintf(sh, SHELL_WARNING,
|
shell_fprintf(sh, SHELL_WARNING,
|
||||||
"Please specify the IP address of the "
|
"Please specify the IP address of the "
|
||||||
"remote server.\n");
|
"remote server.\n");
|
||||||
|
@ -937,10 +942,14 @@ static int shell_cmd_upload(const struct shell *sh, size_t argc,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_NET_IPV6) && IS_ENABLED(CONFIG_NET_IPV4)) {
|
if (IS_ENABLED(CONFIG_NET_IPV6) && IS_ENABLED(CONFIG_NET_IPV4)) {
|
||||||
if (parse_ipv6_addr(sh, argv[start + 1], port_str,
|
ret = parse_ipv6_addr(sh, argv[start + 1], port_str, &ipv6);
|
||||||
&ipv6) < 0) {
|
if (ret < 0) {
|
||||||
if (parse_ipv4_addr(sh, argv[start + 1], port_str,
|
ret = parse_ipv4_addr(sh, argv[start + 1], port_str, &ipv4);
|
||||||
&ipv4) < 0) {
|
if (ret == -EDESTADDRREQ) {
|
||||||
|
shell_fprintf(sh, SHELL_WARNING,
|
||||||
|
"Invalid IP address %s\n", argv[start + 1]);
|
||||||
|
}
|
||||||
|
if (ret < 0) {
|
||||||
shell_fprintf(sh, SHELL_WARNING,
|
shell_fprintf(sh, SHELL_WARNING,
|
||||||
"Please specify the IP address "
|
"Please specify the IP address "
|
||||||
"of the remote server.\n");
|
"of the remote server.\n");
|
||||||
|
|
Loading…
Reference in a new issue