From: German Service Network Date: Sun, 13 Oct 2024 21:50:04 +0000 (+0200) Subject: Allow the parameter --icmp-timestamp only without --size X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa5ff16c05b987afcbf10fcd01bd9835607ac1b1;p=fping.git Allow the parameter --icmp-timestamp only without --size --- diff --git a/ci/test-04-options-a-b.pl b/ci/test-04-options-a-b.pl index ec5b0f0..90afa9b 100755 --- a/ci/test-04-options-a-b.pl +++ b/ci/test-04-options-a-b.pl @@ -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') { diff --git a/src/fping.c b/src/fping.c index 55dabef..39a53b8 100644 --- a/src/fping.c +++ b/src/fping.c @@ -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");