net: zperf: Add shell command to stop TCP/UDP server
Add zperf shell command to stop TCP/UDP server. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
87ca1c3329
commit
dd3fb692fe
1 changed files with 44 additions and 2 deletions
|
@ -367,6 +367,22 @@ static void udp_session_cb(enum zperf_status status,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cmd_udp_download_stop(const struct shell *sh, size_t argc,
|
||||||
|
char *argv[])
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = zperf_udp_download_stop();
|
||||||
|
if (ret < 0) {
|
||||||
|
shell_fprintf(sh, SHELL_WARNING, "UDP server not running!\n");
|
||||||
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
shell_fprintf(sh, SHELL_NORMAL, "UDP server stopped\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int cmd_udp_download(const struct shell *sh, size_t argc,
|
static int cmd_udp_download(const struct shell *sh, size_t argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -1055,6 +1071,22 @@ static void tcp_session_cb(enum zperf_status status,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int cmd_tcp_download_stop(const struct shell *sh, size_t argc,
|
||||||
|
char *argv[])
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = zperf_tcp_download_stop();
|
||||||
|
if (ret < 0) {
|
||||||
|
shell_fprintf(sh, SHELL_WARNING, "TCP server not running!\n");
|
||||||
|
return -ENOEXEC;
|
||||||
|
}
|
||||||
|
|
||||||
|
shell_fprintf(sh, SHELL_NORMAL, "TCP server stopped\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int cmd_tcp_download(const struct shell *sh, size_t argc,
|
static int cmd_tcp_download(const struct shell *sh, size_t argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -1162,6 +1194,11 @@ static void zperf_init(const struct shell *sh)
|
||||||
zperf_session_init();
|
zperf_session_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_tcp_download,
|
||||||
|
SHELL_CMD(stop, NULL, "Stop TCP server\n", cmd_tcp_download_stop),
|
||||||
|
SHELL_SUBCMD_SET_END
|
||||||
|
);
|
||||||
|
|
||||||
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_tcp,
|
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_tcp,
|
||||||
SHELL_CMD(upload, NULL,
|
SHELL_CMD(upload, NULL,
|
||||||
"[<options>] <dest ip> <dest port> <duration> <packet size>[K]\n"
|
"[<options>] <dest ip> <dest port> <duration> <packet size>[K]\n"
|
||||||
|
@ -1199,13 +1236,18 @@ SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_tcp,
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
cmd_tcp_upload2),
|
cmd_tcp_upload2),
|
||||||
SHELL_CMD(download, NULL,
|
SHELL_CMD(download, &zperf_cmd_tcp_download,
|
||||||
"[<port>]\n"
|
"[<port>]\n"
|
||||||
"Example: tcp download 5001\n",
|
"Example: tcp download 5001\n",
|
||||||
cmd_tcp_download),
|
cmd_tcp_download),
|
||||||
SHELL_SUBCMD_SET_END
|
SHELL_SUBCMD_SET_END
|
||||||
);
|
);
|
||||||
|
|
||||||
|
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_udp_download,
|
||||||
|
SHELL_CMD(stop, NULL, "Stop UDP server\n", cmd_udp_download_stop),
|
||||||
|
SHELL_SUBCMD_SET_END
|
||||||
|
);
|
||||||
|
|
||||||
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_udp,
|
SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_udp,
|
||||||
SHELL_CMD(upload, NULL,
|
SHELL_CMD(upload, NULL,
|
||||||
"[<options>] <dest ip> [<dest port> <duration> <packet size>[K] "
|
"[<options>] <dest ip> [<dest port> <duration> <packet size>[K] "
|
||||||
|
@ -1246,7 +1288,7 @@ SHELL_STATIC_SUBCMD_SET_CREATE(zperf_cmd_udp,
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
cmd_udp_upload2),
|
cmd_udp_upload2),
|
||||||
SHELL_CMD(download, NULL,
|
SHELL_CMD(download, &zperf_cmd_udp_download,
|
||||||
"[<port>]\n"
|
"[<port>]\n"
|
||||||
"Example: udp download 5001\n",
|
"Example: udp download 5001\n",
|
||||||
cmd_udp_download),
|
cmd_udp_download),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue