mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
iperf: compatible work with no IPv4
We possible want to use iperf to test rpmsg socket etc. Fix error when enable iperf and no IPv4 ``` arm-none-eabi-ld: warning: ~/nuttx/nuttx has a LOAD segment with RWX permissions arm-none-eabi-ld: ~/nuttx/staging/libapps.a(iperf_main.c.~.apps.netutils.iperf_1.o): in function `iperf_main': ~/apps/netutils/iperf/iperf_main.c:248:(.text.iperf_main+0x330): undefined reference to `inet_ntoa_r' arm-none-eabi-ld: ~/apps/netutils/iperf/iperf_main.c:240:(.text.iperf_main+0x354): undefined reference to `netlib_get_ipv4addr' arm-none-eabi-ld: ~/nuttx/staging/libapps.a(iperf.c.~.apps.netutils.iperf_1.o): in function `iperf_print_addr': ~/apps/netutils/iperf/iperf.c:226:(.text.iperf_print_addr+0x3c): undefined reference to `inet_ntoa' ``` Signed-off-by: buxiasen <buxiasen@xiaomi.com>
This commit is contained in:
parent
188838469c
commit
157ecb091d
2 changed files with 10 additions and 0 deletions
|
|
@ -220,6 +220,7 @@ static void iperf_print_addr(FAR const char *str, FAR struct sockaddr *addr)
|
|||
{
|
||||
switch (addr->sa_family)
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
case AF_INET:
|
||||
{
|
||||
FAR struct sockaddr_in *inaddr = (FAR struct sockaddr_in *)addr;
|
||||
|
|
@ -227,6 +228,7 @@ static void iperf_print_addr(FAR const char *str, FAR struct sockaddr *addr)
|
|||
inet_ntoa(inaddr->sin_addr), htons(inaddr->sin_port));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
case AF_LOCAL:
|
||||
{
|
||||
|
|
|
|||
|
|
@ -140,7 +140,10 @@ int main(int argc, FAR char *argv[])
|
|||
struct iperf_cfg_t cfg;
|
||||
struct in_addr addr;
|
||||
int nerrors;
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
char inetaddr[INET_ADDRSTRLEN];
|
||||
#endif
|
||||
|
||||
bzero(&addr, sizeof(struct in_addr));
|
||||
bzero(&cfg, sizeof(cfg));
|
||||
|
|
@ -226,6 +229,7 @@ int main(int argc, FAR char *argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
if (iperf_args.bind->count > 0)
|
||||
{
|
||||
addr.s_addr = inet_addr(iperf_args.bind->sval[0]);
|
||||
|
|
@ -248,6 +252,10 @@ int main(int argc, FAR char *argv[])
|
|||
printf(" IP: %s\n", inet_ntoa_r(addr, inetaddr, sizeof(inetaddr)));
|
||||
|
||||
cfg.sip = addr.s_addr;
|
||||
#else
|
||||
printf("ERROR: IPv4 Not Enabled\n");
|
||||
goto out;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (iperf_args.udp->count == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue