]> git.gsnw.org Git - fping.git/commitdiff
Allow the parameter --icmp-timestamp only without --size
authorGerman Service Network <support@gsnw.de>
Sun, 13 Oct 2024 21:50:04 +0000 (23:50 +0200)
committerSebastian <176771227+gsnw-sebast@users.noreply.github.com>
Mon, 11 Nov 2024 10:58:22 +0000 (11:58 +0100)
ci/test-04-options-a-b.pl
src/fping.c

index ec5b0f01617a1b1d1a5ad763e3aab835cffe8135..90afa9bbd1ff080f89fd751daa718e27bee177b8 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 
-use Test::Command tests => 44;
+use Test::Command tests => 47;
 use Test::More;
 use Time::HiRes qw(gettimeofday tv_interval);
 
@@ -122,6 +122,14 @@ $cmd->stdout_is_eq("127.0.0.1 is alive\n");
 $cmd->stderr_is_eq("");
 }
 
+# fping --icmp-timestamp -b
+{
+my $cmd = Test::Command->new(cmd => "fping --icmp-timestamp -b 1000 127.0.0.1");
+$cmd->exit_is_num(1);
+$cmd->stdout_is_eq("");
+$cmd->stderr_like(qr{Usage:});
+}
+
 # fping -B
 SKIP: {
     if($^O eq 'darwin') {
index 55dabef37483cab3053dcc44a8c09465fc60998a..39a53b8f283ed848f2c5160e5fd6fbc4441b7162 100644 (file)
@@ -691,6 +691,8 @@ int main(int argc, char **argv)
         case 'b':
             if (sscanf(optparse_state.optarg, "%u", &ping_data_size) != 1)
                 usage(1);
+            if (icmp_request_typ > 0)
+                usage(1);
 
             break;
 
@@ -3129,7 +3131,7 @@ void usage(int is_error)
     fprintf(out, "   -t, --timeout=MSEC individual target initial timeout (default: %.0f ms,\n", timeout / 1e6);
     fprintf(out, "                      except with -l/-c/-C, where it's the -p period up to 2000 ms)\n");
     fprintf(out, "       --check-source discard replies not from target address\n");
-    fprintf(out, "       --icmp-timestamp send ping type Timestamp Request\n");
+    fprintf(out, "       --icmp-timestamp send ping type Timestamp Request (only if no -b specified)\n");
     fprintf(out, "\n");
     fprintf(out, "Output options:\n");
     fprintf(out, "   -a, --alive        show targets that are alive\n");