From 6a8c1133b9804c667104c9939a716b4e4f7a19d9 Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Tue, 10 Nov 2009 11:57:47 +0100 Subject: [PATCH] fwp-timing: Added -v option (verbose) --- fwp/tests/timing/fwp-timing.c | 43 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/fwp/tests/timing/fwp-timing.c b/fwp/tests/timing/fwp-timing.c index 2db8026..a594ef3 100644 --- a/fwp/tests/timing/fwp-timing.c +++ b/fwp/tests/timing/fwp-timing.c @@ -23,6 +23,12 @@ #include #include +bool opt_verbose = false; + +struct stats { + +} stats; + void set_rt_prio(int priority) { int maxpri, minpri; @@ -149,6 +155,7 @@ static struct option long_opts[] = { { "async", 0, 0, 'a' }, { "number", 0, 0, 'n' }, { "count", 0, 0, 'c' }, + { "verbose",0, 0, 'v' }, { 0, 0, 0, 0} }; @@ -164,6 +171,7 @@ usage(void) printf(" -n, --number Number of streams with the same parameters\n"); printf(" -c, --count Number of messages to send [infinity]\n"); printf(" -/, --stream New stream separator\n"); + printf(" -v, --verbose Be more verbose\n"); } int parse_opts(int *argc, char **argv[], struct stream_params *p) @@ -172,7 +180,7 @@ int parse_opts(int *argc, char **argv[], struct stream_params *p) int ret; bool options_found = false; - while ((opt = getopt_long(*argc, *argv, "/ab:c:p:s:d:n:", long_opts, NULL)) != -1) { + while ((opt = getopt_long(*argc, *argv, "/ab:c:p:s:d:n:v", long_opts, NULL)) != -1) { options_found = true; switch (opt) { case 'a': @@ -184,18 +192,6 @@ int parse_opts(int *argc, char **argv[], struct stream_params *p) case 'c': p->count = atoi(optarg); break; - case 'p': - p->period_ms = atoi(optarg); - break; - case 's': - ret = inet_aton(optarg, &p->src); - if (!ret) { - fprintf(stderr, "Source IP address not recognized: %s\n", - optarg); - usage(); - exit(1); - } - break; case 'd': ret = inet_aton(optarg, &p->dst); if (!ret) { @@ -208,6 +204,20 @@ int parse_opts(int *argc, char **argv[], struct stream_params *p) case 'n': p->number = atoi(optarg); break; + case 'p': + p->period_ms = atoi(optarg); + break; + case 's': + ret = inet_aton(optarg, &p->src); + if (!ret) { + fprintf(stderr, "Source IP address not recognized: %s\n", + optarg); + usage(); + exit(1); + } + break; + case 'v': + opt_verbose = true; case '/': break; default: @@ -293,9 +303,10 @@ void *receiver(void *arg) clock_gettime(CLOCK_MONOTONIC, &tsr); tss = msg->ts; if (msg->cnt != last_cnt+1) - printf("packet(s) lost!\n"); - printf("%3d: %10d: %10.3lf ms\n", - rp->id, msg->cnt, tsdiff2d(&tsr, &tss)*1000); + printf("%3d: packet(s) lost!\n", rp->id); + if (opt_verbose) + printf("%3d: %10d: %10.3lf ms\n", + rp->id, msg->cnt, tsdiff2d(&tsr, &tss)*1000); last_cnt = msg->cnt; } free(rp); -- 2.39.2