Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow combination of -a with --print-tos #347

Merged
merged 1 commit into from
Sep 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ci/test-05-options-c-e.pl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -292,6 +292,14 @@
$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("");
}
11 changes: 10 additions & 1 deletion ci/test-08-options-n-q.pl
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -58,6 +58,15 @@
$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");
Expand Down
20 changes: 10 additions & 10 deletions src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Loading