summaryrefslogtreecommitdiff
path: root/src/tools/oping/oping.c
diff options
context:
space:
mode:
authorDimitri Staessens <[email protected]>2018-06-06 10:07:02 +0200
committerSander Vrijders <[email protected]>2018-06-06 11:17:42 +0200
commite6ce5160d4de293e69e7d97ddc380ccbc59f16d5 (patch)
treee061c1af79bb7fb88481fcbb8afb11dca2ce15ad /src/tools/oping/oping.c
parentee9bfbed3726140d5601521de7ce8d003c453fb5 (diff)
downloadouroboros-e6ce5160d4de293e69e7d97ddc380ccbc59f16d5.tar.gz
ouroboros-e6ce5160d4de293e69e7d97ddc380ccbc59f16d5.zip
tools: Add quiet option to oping
This adds a --quiet -Q option to oping so it will only print the statistics summary. Also fixes a division by 0 if duration is specified with interval 0. Signed-off-by: Dimitri Staessens <[email protected]> Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/tools/oping/oping.c')
-rw-r--r--src/tools/oping/oping.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index 757bd422..18801c2d 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -78,6 +78,7 @@ struct c {
uint32_t sent;
uint32_t rcvd;
size_t ooo;
+ bool quiet;
double rtt_min;
double rtt_max;
@@ -123,6 +124,7 @@ static void usage(void)
" -n, --server-name Name of the oping server\n"
" -q, --qos QoS (raw, best, video or voice)\n"
" -s, --size Payload size (B, default 64)\n"
+ " -Q, --quiet Only print final statistics\n"
" -D, --timeofday Print time of day before each line"
"\n"
" --help Display this help text and exit\n");
@@ -166,6 +168,7 @@ int main(int argc,
client.count = INT_MAX;
client.timestamp = false;
client.qs = qos_raw;
+ client.quiet = false;
while (argc > 0) {
if (strcmp(*argv, "-i") == 0 ||
@@ -200,6 +203,10 @@ int main(int argc,
} else if (strcmp(*argv, "-D") == 0 ||
strcmp(*argv, "--timeofday") == 0) {
client.timestamp = true;
+ } else if (strcmp(*argv, "-Q") == 0 ||
+ strcmp(*argv, "--quiet") == 0) {
+ client.quiet = true;
+
} else {
goto fail;
}
@@ -207,8 +214,12 @@ int main(int argc,
argv++;
}
- if (duration > 0)
- client.count = duration / client.interval;
+ if (duration > 0) {
+ if (client.interval == 0)
+ client.count = duration * 10;
+ else
+ client.count = duration / client.interval;
+ }
if (qos != NULL) {
if (strcmp(qos, "best") == 0)