]> git.gsnw.org Git - fping.git/commitdiff
allow combination of -a with --print-tos
authorErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sat, 24 Aug 2024 18:13:37 +0000 (20:13 +0200)
committerErik Auerswald <auerswal@unix-ag.uni-kl.de>
Sat, 7 Sep 2024 18:09:14 +0000 (20:09 +0200)
This is similar to how -e, --elapsed works.
Also adjust -h output regarding --print-tos.

ci/test-05-options-c-e.pl
ci/test-08-options-n-q.pl
src/fping.c

index 7d9050525a2dc34ec6ab6e02a703e025b05c4c56..db5abd6d33dccd59945b6e9b711a7da5219158b9 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-use Test::Command tests => 72;
+use Test::Command tests => 75;
 use Test::More;
 
 #  -c n           count of pings to send to each target (default 1)
@@ -292,6 +292,14 @@ my $cmd = Test::Command->new(cmd => "fping -e 127.0.0.1");
 $cmd->exit_is_num(0);
 $cmd->stdout_like(qr{127\.0\.0\.1 is alive \(\d\.\d+ ms\)
 });
+$cmd->stderr_is_eq("");
+}
 
+# fping -e -a
+{
+my $cmd = Test::Command->new(cmd => "fping -e -a 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_like(qr{127\.0\.0\.1 \(\d\.\d+ ms\)
+});
 $cmd->stderr_is_eq("");
 }
index fc01012712febf33381c496f84d6744eb3264735..d614db149f4e938dc85a4b3ae5665a176557a229 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-use Test::Command tests => 45;
+use Test::Command tests => 48;
 use Test::More;
 
 #  -n         show targets by name (-d is equivalent)
@@ -58,6 +58,15 @@ $cmd->stdout_like(qr{127\.0\.0\.1 is alive \(TOS \d+\)
 $cmd->stderr_is_eq("");
 }
 
+# fping -a -O --print-tos
+{
+my $cmd = Test::Command->new(cmd => "fping -a -O 32 --print-tos 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_like(qr{127\.0\.0\.1 \(TOS \d+\)
+});
+$cmd->stderr_is_eq("");
+}
+
 # fping --print-tos
 {
 my $cmd = Test::Command->new(cmd => "fping --print-tos 127.0.0.1");
index 6245cb6c8b8869df4bf1b9214fbb009a3db8f596..87b5fb9e53819332fa9780733d13789c614ff0f8 100644 (file)
@@ -2518,16 +2518,16 @@ int wait_for_reply(int64_t wait_time)
         if (verbose_flag || alive_flag) {
             printf("%s", h->host);
 
-            if (verbose_flag) {
+            if (verbose_flag)
                 printf(" is alive");
-                  if(print_tos_flag) {
-                      if(ip_header_tos != -1) {
-                          printf(" (TOS %d)", ip_header_tos);
-                      }
-                      else {
-                          printf(" (TOS unknown)");
-                      }
-                  }
+
+            if(print_tos_flag) {
+                if(ip_header_tos != -1) {
+                    printf(" (TOS %d)", ip_header_tos);
+                }
+                else {
+                    printf(" (TOS unknown)");
+                }
             }
 
             if (print_ttl_flag) {
@@ -3108,7 +3108,7 @@ void usage(int is_error)
     fprintf(out, "   -v, --version      show version\n");
     fprintf(out, "   -x, --reachable=N  shows if >=N hosts are reachable or not\n");
     fprintf(out, "   -X, --fast-reachable=N exits true immediately when N hosts are found\n");
-    fprintf(out, "       --print-tos    show tos value\n");
+    fprintf(out, "       --print-tos    show received TOS value\n");
     fprintf(out, "       --print-ttl    show IP TTL value\n");
     exit(is_error);
 }