Release 3.10

pull/67/head
David Schweikert 11 years ago
commit e042466b9a

@ -5,9 +5,6 @@ env:
- secure: "CoI8hwHH1yfQoQxIfWGRS0WfTyScox+5aJn0fDDgz2uKrrIxmBvIw/WKX8wcSiV6fLmLuwgNkKqSM3hdO4qaG+JxfWcuEiZZHm+kxSGMkWbGb/fvAI+gHg8ldKyYttcIX71O5rlZiC2QpNKQi2v18S6pI5p8eqnx7DYx4YrmguQ="
compiler:
- gcc
branches:
only:
- master
before_install:
- sudo apt-get install libcap2-bin
install:

@ -1,3 +1,12 @@
2014-05-03 David Schweikert <david@schweikert.ch>
* Version 3.10
* Fix confusing error message with -g and IPv6 addresses (#58, reported by Axel Beckert)
* Allow option '-f' also for non-root (since setuid privileges are dropped)
* Do not retry twice DNS lookup on DNS lookup problem
* Remove support for NIS groups
* Better document -B backoff-factor and when it can be used (#33, Oleksiy Zagorskyi)
* More tests added
2014-03-08 David Schweikert <david@schweikert.ch>
* Version 3.9
* Fix random output on socket error (reported by Aleksandrs Saveljevs, #56)

@ -10,6 +10,12 @@ if [ "$CC" != "gcc" ]; then
exit 0
fi
# do this only for the master branch
if [ "$TRAVIS_BRANCH" != "master" ]; then
echo "skipped upload branch $TRAVIS_BRANCH isn't master"
exit 0
fi
VERSION=$(ls fping-*.tar.gz | sed -e 's/^fping-//' | sed -e 's/\.tar\.gz$//')
if [[ "$VERSION" =~ ^[0-9]+\.[0-9]+$ ]]; then
REPO=release

@ -0,0 +1,24 @@
#!/usr/bin/perl -w
use Test::Command tests => 6;
# -u show targets that are unreachable
# -v show version
# fping -u
{
my $cmd = Test::Command->new(cmd => "fping -r0 -u 8.8.0.0 127.0.0.1");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("8.8.0.0\n");
$cmd->stderr_is_eq("");
}
# fping -v
{
my $cmd = Test::Command->new(cmd => "fping -v");
$cmd->exit_is_num(0);
$cmd->stdout_like(qr{ping: Version 3\.\d+
fping: comments to david\@schweikert\.ch
});
$cmd->stderr_is_eq("");
}

@ -0,0 +1,25 @@
#!/usr/bin/perl -w
use Test::Command tests => 6;
# run without privileges
my $fping_bin = `which fping`; chomp $fping_bin;
my $fping6_bin = `which fping6`; chomp $fping6_bin;
system("cp $fping_bin /tmp/fping.copy; chmod +x /tmp/fping.copy");
system("cp $fping6_bin /tmp/fping6.copy; chmod +x /tmp/fping6.copy");
# fping
{
my $cmd = Test::Command->new(cmd => "/tmp/fping.copy 127.0.0.1");
$cmd->exit_is_num(4);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\(null\): can't create socket \(must run as root\?\) : .*\n});
}
# fping6
{
my $cmd = Test::Command->new(cmd => "/tmp/fping6.copy ::1");
$cmd->exit_is_num(4);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\(null\): can't create raw socket \(must run as root\?\) : .*\n});
}

@ -0,0 +1,10 @@
#!/usr/bin/perl -w
use Test::Command tests => 36;
for my $arg (qw(i b B c C H i O p Q r t)) {
my $cmd = Test::Command->new(cmd => "fping -$arg xxx");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{Usage:});
}

@ -0,0 +1,19 @@
#!/usr/bin/perl -w
use Test::Command tests => 6;
# fping
{
my $cmd = Test::Command->new(cmd => "fping nosuchname.example.com");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_is_eq("nosuchname.example.com address not found\n");
}
# fping6
{
my $cmd = Test::Command->new(cmd => "fping6 nosuchname.example.com");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_is_eq("nosuchname.example.com: Name or service not known\n");
}

@ -0,0 +1,15 @@
#!/usr/bin/perl -w
use Test::Command tests => 3;
# fping
{
my $cmd = Test::Command->new(cmd => "fping -q -i 10 -p 20 -c 3 -t200 8.8.8.8 4.2.2.5 www.france-telecom.fr www.google.com");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{8\.8\.8\.8\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
4\.2\.2\.5\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
www\.france-telecom\.fr\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
www\.google\.com\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
});
}

@ -22,21 +22,21 @@ Usage: fping [options] [targets...]
(ex. fping -g 192.168.1.0 192.168.1.255 or fping -g 192.168.1.0/24)
-H n Set the IP TTL value (Time To Live hops)
-i n interval between sending ping packets (in millisec) (default 25)
-I if bind to a particular interface
-l loop sending pings forever
-m ping multiple interfaces on target host
-n show targets by name (-d is equivalent)
-O n set the type of service (tos) flag on the ICMP packets
-p n interval between ping packets to one target (in millisec)
(in looping and counting modes, default 1000)
-q quiet (don't show per-target/per-ping results)
-Q n same as -q, but show summary every n seconds
-r n number of retries (default 3)
-s print final stats
-I if bind to a particular interface
-S addr set source address
-t n individual target initial timeout (in millisec) (default 500)
-T n ignored (for compatibility with fping 2.4)
-u show targets that are unreachable
-O n set the type of service (tos) flag on the ICMP packets
-v show version
targets list of targets to check (if no -f specified)

@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use Test::Command tests => 14;
use Test::Command tests => 20;
use Test::More;
use Time::HiRes qw(gettimeofday tv_interval);
@ -10,30 +10,54 @@ use Time::HiRes qw(gettimeofday tv_interval);
# -B f set exponential backoff factor to f
# fping -a
my $cmd1 = Test::Command->new(cmd => "fping -a 127.0.0.1 127.0.0.2");
$cmd1->exit_is_num(0);
$cmd1->stdout_is_eq("127.0.0.1\n127.0.0.2\n");
$cmd1->stderr_is_eq("");
{
my $cmd = Test::Command->new(cmd => "fping -a 127.0.0.1 127.0.0.2");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1\n127.0.0.2\n");
$cmd->stderr_is_eq("");
}
# fping -A
my $cmd2 = Test::Command->new(cmd => "fping -A 127.0.0.1");
$cmd2->exit_is_num(0);
$cmd2->stdout_is_eq("127.0.0.1 is alive\n");
$cmd2->stderr_is_eq("");
{
my $cmd = Test::Command->new(cmd => "fping -A localhost");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -A -n
{
my $cmd = Test::Command->new(cmd => "fping -A -n localhost");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("localhost (127.0.0.1) is alive\n");
$cmd->stderr_is_eq("");
}
# fping6 -A -n
{
my $cmd = Test::Command->new(cmd => "fping6 -n -A 2001:4860:4860::8888");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("google-public-dns-a.google.com (2001:4860:4860::8888) is alive\n");
$cmd->stderr_is_eq("");
}
# fping -b
my $cmd3 = Test::Command->new(cmd => "fping -b 1000 127.0.0.1");
$cmd3->exit_is_num(0);
$cmd3->stdout_is_eq("127.0.0.1 is alive\n");
$cmd3->stderr_is_eq("");
{
my $cmd = Test::Command->new(cmd => "fping -b 1000 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -B
{
my $t0 = [gettimeofday];
my $cmd4 = Test::Command->new(cmd => "fping -t 100 -r 3 -B 2 8.8.8.7");
$cmd4->exit_is_num(1);
$cmd4->stdout_is_eq("8.8.8.7 is unreachable\n");
$cmd4->stderr_is_eq("");
my $cmd = Test::Command->new(cmd => "fping -t 100 -r 3 -B 2 8.8.8.7");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("8.8.8.7 is unreachable\n");
$cmd->stderr_is_eq("");
my $elapsed = tv_interval($t0);
# 0.1 + 0.2 + 0.4 + 0.8 = 1.5
cmp_ok($elapsed, '>=', 1.5);
cmp_ok($elapsed, '<', 1.7);
}

@ -0,0 +1,60 @@
#!/usr/bin/perl -w
use Test::Command tests => 12;
# -c n count of pings to send to each target (default 1)
# -C n same as -c, report results in verbose format
# -D print timestamp before each output line
# -e show elapsed time on return packets
# fping -c n
{
my $cmd = Test::Command->new(cmd => "fping -c 2 -p 100 localhost 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_like(qr{localhost : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
localhost : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
});
$cmd->stderr_like(qr{localhost : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
});
}
# fping -C n
{
my $cmd = Test::Command->new(cmd => "fping -C 2 -p 100 localhost 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_like(qr{localhost : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
localhost : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
});
$cmd->stderr_like(qr{localhost : 0\.\d+ 0\.\d+
127\.0\.0\.1 : 0\.\d+ 0\.\d+
});
}
# fping -D
{
my $cmd = Test::Command->new(cmd => "fping -D -c 2 -p 100 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_like(qr{\[\d{10}\.\d+\] 127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
\[\d{10}\.\d+\] 127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
});
$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
});
}
# fping -e
{
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 \(0\.\d+ ms\)
});
$cmd->stderr_is_eq("");
}

@ -0,0 +1,62 @@
#!/usr/bin/perl -w
use Test::Command tests => 18;
use File::Temp;
# -f file read list of targets from a file ( - means stdin) (only if no -g specified)
# -g generate target list (only if no -f specified)
# (specify the start and end IP in the target list, or supply a IP netmask)
# (ex. ../src/fping -g 192.168.1.0 192.168.1.255 or ../src/fping -g 192.168.1.0/24)
# -H n Set the IP TTL value (Time To Live hops)
my $tmpfile = File::Temp->new();
print $tmpfile "127.0.0.1\n127.0.0.2\n";
close($tmpfile);
# fping without option (-> equivalent to 'fping -f -')
{
my $cmd = Test::Command->new(cmd => "cat ".$tmpfile->filename." | fping");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -f -
{
my $cmd = Test::Command->new(cmd => "cat ".$tmpfile->filename." | fping -f -");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -f file
{
my $cmd = Test::Command->new(cmd => "fping -f ".$tmpfile->filename);
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -g (range)
{
my $cmd = Test::Command->new(cmd => "fping -g 127.0.0.1 127.0.0.5");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n127.0.0.3 is alive\n127.0.0.4 is alive\n127.0.0.5 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -g (cidr)
{
my $cmd = Test::Command->new(cmd => "fping -g 127.0.0.1/30");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -H
{
my $cmd = Test::Command->new(cmd => "fping -H 1 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
$cmd->stderr_is_eq("");
}

@ -0,0 +1,31 @@
#!/usr/bin/perl -w
use Test::Command tests => 7;
# -i n interval between sending ping packets (in millisec) (default 25)
# -l loop sending pings forever
# -m ping multiple interfaces on target host
# fping -i n
{
my $cmd = Test::Command->new(cmd => "fping -i 100 127.0.0.1 127.0.0.2");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -l
{
my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 900 -l 127.0.0.1');
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
});
}
# fping -m
{
my $cmd = Test::Command->new(cmd => "fping -m google-public-dns-a.google.com");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n");
$cmd->stderr_is_eq("");
}

@ -0,0 +1,48 @@
#!/usr/bin/perl -w
use Test::Command tests => 12;
# -n show targets by name (-d is equivalent)
# -O n set the type of service (tos) flag on the ICMP packets
# -p n interval between ping packets to one target (in millisec)
# (in looping and counting modes, default 1000)
# -q quiet (don't show per-target/per-ping results)
# -Q n same as -q, but show summary every n seconds
# fping -n
{
my $cmd = Test::Command->new(cmd => "fping -n 8.8.8.8");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n");
$cmd->stderr_is_eq("");
}
# fping -O
{
my $cmd = Test::Command->new(cmd => "fping -O 2 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -q
{
my $cmd = Test::Command->new(cmd => "fping -q -p 100 -c 3 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
});
}
# fping -Q
{
my $cmd = Test::Command->new(cmd => "fping -Q 1 -p 400 -c 4 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
127\.0\.0\.1 : xmt/rcv/%loss = 4/4/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
});
}

@ -0,0 +1,75 @@
#!/usr/bin/perl -w
use Test::Command tests => 12;
# -r n number of retries (default 3)
# -s print final stats
# -S addr set source address
# -t n individual target initial timeout (in millisec) (default 500)
# -T n ignored (for compatibility with fping 2.4)
# fping -r tested in test-4-options-a-b.pl
# fping -s
{
my $cmd = Test::Command->new(cmd => "fping -s 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
$cmd->stderr_like(qr{\s*
\s*1 targets
\s*1 alive
\s*0 unreachable
\s*0 unknown addresses
\s*
\s*0 timeouts \(waiting for response\)
\s*1 ICMP Echos sent
\s*1 ICMP Echo Replies received
\s*0 other ICMP received
\s*0.\d+ ms \(min round trip time\)
\s*0.\d+ ms \(avg round trip time\)
\s*0.\d+ ms \(max round trip time\)
\s*0.\d+ sec \(elapsed real time\)
});
}
# fping -s (no host reachable)
{
my $cmd = Test::Command->new(cmd => "fping -r0 -t100 -s 8.8.0.0");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("8.8.0.0 is unreachable\n");
$cmd->stderr_like(qr{\s*
\s*1 targets
\s*0 alive
\s*1 unreachable
\s*0 unknown addresses
\s*
\s*1 timeouts \(waiting for response\)
\s*1 ICMP Echos sent
\s*0 ICMP Echo Replies received
\s*0 other ICMP received
\s*0.\d+ ms \(min round trip time\)
\s*0.\d+ ms \(avg round trip time\)
\s*0.\d+ ms \(max round trip time\)
\s*0.\d+ sec \(elapsed real time\)
});
}
# fping -S
{
my $cmd = Test::Command->new(cmd => "fping -S 127.0.0.1 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
$cmd->stderr_is_eq("");
}
# fping6 -S
{
my $cmd = Test::Command->new(cmd => "fping6 -S ::1 ::1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("::1 is alive\n");
$cmd->stderr_is_eq("");
}
# fping -t tested in test-4-options-a-b.pl

@ -0,0 +1,10 @@
#!/usr/bin/perl -w
# regression testing for github issue #58
use Test::Command tests => 3;
my $cmd1 = Test::Command->new(cmd => "fping -a -g 2001:db8:120:4161::4/64");
$cmd1->exit_is_num(1);
$cmd1->stdout_is_eq("");
$cmd1->stderr_is_eq("Error: -g works only with IPv4 addresses\n");

@ -49,10 +49,11 @@ number.
=item B<-B> I<n>
In the default mode, B<fping> sends several requests to a target before giving
up, waiting longer for a reply on each successive request. This parameter is
the value by which the wait time is multiplied on each successive request; it
must be entered as a floating-point number (x.y). The default is 1.5.
Backoff factor. In the default mode, B<fping> sends several requests to a
target before giving up, waiting longer for a reply on each successive request.
This parameter is the value by which the wait time (B<-t>) is multiplied on each
successive request; it must be entered as a floating-point number (x.y). The
default is 1.5.
=item B<-c> I<n>
@ -165,7 +166,9 @@ Set the interface (requires SO_BINDTODEVICE support)
Initial target timeout in milliseconds (default 500). In the default mode, this
is the amount of time that B<fping> waits for a response to its first request.
Successive timeouts are multiplied by the backoff factor.
Successive timeouts are multiplied by the backoff factor specified with B<-B>.
Note that this option has no effect looping or counting modes (B<-l>, B<-c>, or
B<-C>).
=item B<-T> I<n>

@ -369,7 +369,8 @@ int main( int argc, char **argv )
s = open_ping_socket();
if((uid = getuid())) {
seteuid( getuid() );
/* drop privileges */
setuid( getuid() );
}
prog = argv[0];
@ -391,7 +392,8 @@ int main( int argc, char **argv )
break;
case 'r':
retry = ( unsigned int )atoi( optarg );
if (!sscanf(optarg,"%i",&retry))
usage(1);
break;
case 'i':
@ -422,9 +424,7 @@ int main( int argc, char **argv )
break;
case 'b':
errno = 0;
ping_data_size = (unsigned int) strtol(optarg, (char **)NULL, 10);
if( errno )
if (!sscanf(optarg,"%i",&ping_data_size))
usage(1);
break;
@ -509,27 +509,8 @@ int main( int argc, char **argv )
exit( 0 );
case 'f':
#ifdef ENABLE_F_OPTION
filename = optarg;
generate_flag = 0;
break;
#else
if( getuid() )
{
printf( "%s: this option can only be used by root.\n", argv[0] );
printf( "%s: fping will read from stdin by default.\n", argv[0] );
exit( 3 );
}/* IF */
else
{
filename = optarg;
generate_flag = 0;
}/* ELSE */
break;
#endif /* ENABLE_F_OPTION */
case 'g':
/* use IP list generation */
@ -568,6 +549,9 @@ int main( int argc, char **argv )
perror("setting type of service octet IP_TOS");
}
}
else {
usage(1);
}
break;
default:
fprintf(stderr, "see 'fping -h' for usage information\n");
@ -794,7 +778,7 @@ int main( int argc, char **argv )
}
if( !num_hosts )
exit( 2 );
exit(1);
if(src_addr_present) {
socket_set_src_addr(s, src_addr);
@ -880,10 +864,6 @@ void add_cidr(char *addr)
*addr_end = '\0';
mask_str = addr_end + 1;
mask = atoi(mask_str);
if(mask < 1 || mask > 30) {
fprintf(stderr, "Error: netmask must be between 1 and 30 (is: %s)\n", mask_str);
exit(2);
}
/* parse address (IPv4 only) */
memset(&addr_hints, 0, sizeof(struct addrinfo));
@ -892,14 +872,20 @@ void add_cidr(char *addr)
ret = getaddrinfo(addr, NULL, &addr_hints, &addr_res);
if(ret) {
fprintf(stderr, "Error: can't parse address %s: %s\n", addr, gai_strerror(ret));
exit(2);
exit(1);
}
if(addr_res->ai_family != AF_INET) {
fprintf(stderr, "Error: -g works only with IPv4 addresses\n");
exit(2);
exit(1);
}
net_addr = ntohl(((struct sockaddr_in *) addr_res->ai_addr)->sin_addr.s_addr);
/* check mask */
if(mask < 1 || mask > 30) {
fprintf(stderr, "Error: netmask must be between 1 and 30 (is: %s)\n", mask_str);
exit(1);
}
/* convert mask integer from 1 to 32 to a bitmask */
bitmask = ((unsigned long) 0xFFFFFFFF) << (32-mask);
@ -934,11 +920,11 @@ void add_range(char *start, char *end)
ret = getaddrinfo(start, NULL, &addr_hints, &addr_res);
if(ret) {
fprintf(stderr, "Error: can't parse address %s: %s\n", start, gai_strerror(ret));
exit(2);
exit(1);
}
if(addr_res->ai_family != AF_INET) {
fprintf(stderr, "Error: -g works only with IPv4 addresses\n");
exit(2);
exit(1);
}
start_long = ntohl(((struct sockaddr_in *) addr_res->ai_addr)->sin_addr.s_addr);
@ -949,11 +935,11 @@ void add_range(char *start, char *end)
ret = getaddrinfo(end, NULL, &addr_hints, &addr_res);
if(ret) {
fprintf(stderr, "Error: can't parse address %s: %s\n", end, gai_strerror(ret));
exit(2);
exit(1);
}
if(addr_res->ai_family != AF_INET) {
fprintf(stderr, "Error: -g works only with IPv4 addresses\n");
exit(2);
exit(1);
}
end_long = ntohl(((struct sockaddr_in *) addr_res->ai_addr)->sin_addr.s_addr);
@ -2000,45 +1986,10 @@ void add_name( char *name )
host_ent = gethostbyname( name );
if( host_ent == NULL )
{
if( h_errno == TRY_AGAIN )
{
u_sleep( DNS_TIMEOUT );
host_ent = gethostbyname( name );
}/* IF */
if( host_ent == NULL )
{
#ifdef NIS_GROUPS
/* maybe it's the name of a NIS netgroup */
char *machine, *user_ignored, *domain_ignored;
setnetgrent( name );
if( getnetgrent( &machine, &user_ignored, &domain_ignored ) == 0 )
{
endnetgrent();
print_warning("%s address not found\n", name );
num_noaddress++;
return;
}/* IF */
else
add_name(machine);
while( getnetgrent( &machine, &user_ignored, &domain_ignored ) )
add_name(machine);
endnetgrent();
return;
#else
print_warning("%s address not found\n", name );
num_noaddress++;
return ;
#endif /* NIS_GROUPS */
}/* IF */
}/* IF */
}
if(host_ent->h_addrtype != AF_INET) {
print_warning("%s: IPv6 address returned by gethostbyname (options inet6 in resolv.conf?)\n", name );
@ -2703,23 +2654,23 @@ void usage(int is_error)
fprintf(out, " (ex. %s -g 192.168.1.0 192.168.1.255 or %s -g 192.168.1.0/24)\n", prog, prog );
fprintf(out, " -H n Set the IP TTL value (Time To Live hops)\n");
fprintf(out, " -i n interval between sending ping packets (in millisec) (default %d)\n", interval / 100 );
#ifdef SO_BINDTODEVICE
fprintf(out, " -I if bind to a particular interface\n");
#endif
fprintf(out, " -l loop sending pings forever\n" );
fprintf(out, " -m ping multiple interfaces on target host\n" );
fprintf(out, " -n show targets by name (-d is equivalent)\n" );
fprintf(out, " -O n set the type of service (tos) flag on the ICMP packets\n" );
fprintf(out, " -p n interval between ping packets to one target (in millisec)\n" );
fprintf(out, " (in looping and counting modes, default %d)\n", perhost_interval / 100 );
fprintf(out, " -q quiet (don't show per-target/per-ping results)\n" );
fprintf(out, " -Q n same as -q, but show summary every n seconds\n" );
fprintf(out, " -r n number of retries (default %d)\n", DEFAULT_RETRY );
fprintf(out, " -s print final stats\n" );
#ifdef SO_BINDTODEVICE
fprintf(out, " -I if bind to a particular interface\n");
#endif
fprintf(out, " -S addr set source address\n" );
fprintf(out, " -t n individual target initial timeout (in millisec) (default %d)\n", timeout / 100 );
fprintf(out, " -T n ignored (for compatibility with fping 2.4)\n");
fprintf(out, " -u show targets that are unreachable\n" );
fprintf(out, " -O n set the type of service (tos) flag on the ICMP packets\n" );
fprintf(out, " -v show version\n" );
fprintf(out, " targets list of targets to check (if no -f specified)\n" );
fprintf(out, "\n");

@ -49,6 +49,3 @@
#ifndef DNS_TIMEOUT
#define DNS_TIMEOUT 1000 /* time in micro_sec for dns retry */
#endif
/* NIS_GROUPS allows input name to be an NIS netgroup name */
/* #define NIS_GROUPS=1 */

Loading…
Cancel
Save