Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iperf: add parameters to support dynamic device bind #2261

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions netutils/iperf/iperf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>",
Expand Down Expand Up @@ -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)));
Expand Down
Loading