This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 9c48a8d4f iperf: add parameters to support dynamic device bind
9c48a8d4f is described below
commit 9c48a8d4fcd11c94f1bdd54175dfc1fb2c0148c0
Author: zhanghongyu <[email protected]>
AuthorDate: Fri Jan 12 15:58:48 2024 +0800
iperf: add parameters to support dynamic device bind
In addition to the CONFIG_NETUTILS_IPERFTEST_DEVNAME configuration, you can
specify network cards by parameter to support devices with multiple network
interface
Signed-off-by: zhanghongyu <[email protected]>
---
netutils/iperf/iperf_main.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/netutils/iperf/iperf_main.c b/netutils/iperf/iperf_main.c
index 46abf8bbb..fc42c13a8 100644
--- a/netutils/iperf/iperf_main.c
+++ b/netutils/iperf/iperf_main.c
@@ -58,6 +58,7 @@ struct wifi_iperf_t
FAR struct arg_lit *udp;
FAR struct arg_str *local;
FAR struct arg_str *rpmsg;
+ FAR struct arg_str *bind;
FAR struct arg_int *port;
FAR struct arg_int *interval;
FAR struct arg_int *time;
@@ -148,6 +149,7 @@ int main(int argc, FAR char *argv[])
iperf_args.udp = arg_lit0("u", "udp", "use UDP rather than TCP");
iperf_args.local = arg_str0(NULL, "local", "<path>", "use local socket");
iperf_args.rpmsg = arg_str0(NULL, "rpmsg", "<name>", "use RPMsg socket");
+ iperf_args.bind = arg_str0("B", "bind", "<ip>", "ip to bind");
iperf_args.port = arg_int0("p", "port", "<port>",
"server port to listen on/connect to");
iperf_args.interval = arg_int0("i", "interval", "<interval>",
@@ -222,11 +224,23 @@ int main(int argc, FAR char *argv[])
}
else
{
- netlib_get_ipv4addr(DEVNAME, &addr);
- if (addr.s_addr == 0)
+ if (iperf_args.bind->count > 0)
{
- printf("ERROR: access IP is 0x00\n");
- goto out;
+ addr.s_addr = inet_addr(iperf_args.bind->sval[0]);
+ if (addr.s_addr == INADDR_NONE)
+ {
+ printf("ERROR: access IP is 0xffffffff\n");
+ goto out;
+ }
+ }
+ else
+ {
+ netlib_get_ipv4addr(DEVNAME, &addr);
+ if (addr.s_addr == 0)
+ {
+ printf("ERROR: access IP is 0x00\n");
+ goto out;
+ }
}
printf(" IP: %s\n", inet_ntoa_r(addr, inetaddr, sizeof(inetaddr)));