Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02ac0090e1 | ||
|
|
b4d0a93b70 | ||
|
|
a19c537fc5 | ||
|
|
6af4d71188 | ||
|
|
ed4202f84f | ||
|
|
a4ef8142b3 | ||
|
|
421abc41b1 | ||
|
|
67d7a10f83 | ||
|
|
bdef483f4b | ||
|
|
e92a68dc4d | ||
|
|
13ce2eae48 | ||
|
|
b16d117a17 | ||
|
|
0e3e404a3d | ||
|
|
5f3ab12ca9 | ||
|
|
4a5c82f6a5 | ||
|
|
7d4eeb403a | ||
|
|
88d54f4505 | ||
|
|
5cf3f7fa4d | ||
|
|
2f09ff2d40 | ||
|
|
2a53cdc62b | ||
|
|
a5828a2795 | ||
|
|
546ba7eb93 | ||
|
|
f062f00568 | ||
|
|
3f0f49da64 | ||
|
|
780865c8ee | ||
|
|
063ee44417 |
@@ -17,4 +17,7 @@ install-sh
|
||||
missing
|
||||
src/*.o
|
||||
src/fping
|
||||
src/fping6
|
||||
stamp-h1
|
||||
doc/fping.8
|
||||
doc/fping6.8
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
2012-05-22 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.2rc1
|
||||
UNRELEAESD David Schweikert <david@schweikert.ch>
|
||||
* Version 3.3-rc1
|
||||
* Do not output icmp errors with -q (#1)
|
||||
* Add --enable-ipv4 and --enable-ipv6 options to configure (Niclas Zeising)
|
||||
* Fix removing of unreachable hosts when doing loop (Thomas Liske, #13 #23)
|
||||
* Fix -A for fping6 (reported by Matt LaPlante, #14)
|
||||
* Fix "options inet6" breaking IPv4 name resolution (reported by Matt LaPlante, #17)
|
||||
* Output statistics to stdout instead of stderr (suggested by Simon Leinen, #9)
|
||||
* Set default data size to 56 bytes on all architectures (#18)
|
||||
* Added contrib/fping.spec (Stephen Schaefer, #24)
|
||||
* Convert man-page source to POD for easier maintenance
|
||||
* Man-page fix: TOS option typo (Thomas Liske, #23)
|
||||
* Man-page fix: inconsistency in regards to numeric arguments (Robert Henney)
|
||||
* Man-page fix: better description of option -q (#15)
|
||||
|
||||
2012-05-29 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.2
|
||||
* Improve documentation for -g option (G.W. Haywood)
|
||||
* Performance optimization for big select timeouts (#10, Andrey Bondarenko)
|
||||
* Fix restart of select call after interrupt signal (#8, Boian Bonev)
|
||||
* Fix infinite loop caused by linked list corruption (#11, Boian Bonev)
|
||||
|
||||
@@ -9,7 +9,7 @@ Current maintainer:
|
||||
David Schweikert <david@schweikert.ch>
|
||||
|
||||
Website:
|
||||
http://www.fping.org
|
||||
http://www.fping.org/
|
||||
|
||||
Installation
|
||||
------------
|
||||
@@ -24,12 +24,23 @@ If you want to install fping from source, proceed as follows:
|
||||
|
||||
sudo setcap cap_net_raw+ep fping
|
||||
|
||||
4. Have a look at the fping(1) manual for usage help
|
||||
4. Have a look at the fping(8) manual for usage help
|
||||
(fping -h will also give a minimal help output)
|
||||
|
||||
IPv6 support
|
||||
------------
|
||||
You can can compile fping with support for IPv6 addresses. A separate binary
|
||||
is used for that, called fping6. To build it, use ./configure --enable-ipv6
|
||||
(possibly combined with --enable-ipv4 to also build fping for IPv4). E.g.:
|
||||
|
||||
# ./configure --prefix=/usr/local --enable-ipv4 --enable-ipv6
|
||||
# make
|
||||
# make install
|
||||
# sudo setcap cap_net_raw+ep /usr/local/bin/fping*
|
||||
|
||||
Credits
|
||||
-------
|
||||
Original author: Roland Schemers (schemers@stanford.edu)
|
||||
Previous maintainer: RL "Bob" Morgan (morgan@stanford.edu)
|
||||
IPv6 Support: Jeroen Massar (jeroen@unfix.org / jeroen@ipng.nl)
|
||||
to enable IPV6 compile with -DIPV6
|
||||
Initial IPv6 Support: Jeroen Massar (jeroen@unfix.org / jeroen@ipng.nl)
|
||||
Other contributors: see ChangeLog
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
[ -f Makefile ] && make clean
|
||||
rm -f Makefile
|
||||
rm -f Makefile.in
|
||||
rm -f aclocal.m4
|
||||
@@ -17,3 +18,4 @@ rm -f mkinstalldirs
|
||||
rm -f stamp-h1
|
||||
rm -f doc/Makefile.in
|
||||
rm -f src/Makefile.in
|
||||
rm -f doc/fping.8
|
||||
|
||||
+24
-1
@@ -3,7 +3,30 @@ dnl Process this file with autoconf to produce a configure script.
|
||||
dnl Minimum Autoconf version required.
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT([fping],[3.2-rc1])
|
||||
AC_INIT([fping],[3.3-rc1])
|
||||
|
||||
dnl make ipv4 and ipv6 options
|
||||
AC_ARG_ENABLE([ipv4],
|
||||
[ --enable-ipv4 Build IPv4 capable fping],
|
||||
[case "${enableval}" in
|
||||
yes) ipv4=true ;;
|
||||
no) ipv4=false ;;
|
||||
*) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv4]) ;;
|
||||
esac],[ipv4=true])
|
||||
AM_CONDITIONAL([IPV4], [test x$ipv4 = xtrue])
|
||||
|
||||
AC_ARG_ENABLE([ipv6],
|
||||
[ --enable-ipv6 Build IPv6 capable fping6],
|
||||
[case "${enableval}" in
|
||||
yes) ipv6=true ;;
|
||||
no) ipv6=false ;;
|
||||
*) AC_MSG_ERROR([bad value ${enableval} for --enable-ipv6]) ;;
|
||||
esac],[ipv6=false])
|
||||
AM_CONDITIONAL([IPV6], [test x$ipv6 = xtrue])
|
||||
|
||||
if test x$ipv4 = xfalse && test x$ipv6 = xfalse; then
|
||||
AC_MSG_ERROR([You must enable at least one of IPv4 and IPv6.])
|
||||
fi
|
||||
|
||||
AC_CANONICAL_TARGET
|
||||
AM_INIT_AUTOMAKE([foreign])
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
Summary: send ICMP echo probes to multiple hosts
|
||||
Name: fping
|
||||
Version: 3.2
|
||||
Release: 1
|
||||
License: MIT
|
||||
Group: Applications/System
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
|
||||
|
||||
%description
|
||||
fping is a program to send ICMP echo probes to network hosts, similar to ping,
|
||||
but much better performing when pinging multiple hosts. fping has a very long
|
||||
history: Roland Schemers did publish a first version of it in 1992 and it has
|
||||
established itself since then as a standard tool for network diagnostics and
|
||||
statistics.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
|
||||
%build
|
||||
%configure
|
||||
|
||||
make
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
/usr/sbin/fping
|
||||
/usr/share/man/man8/fping.8.gz
|
||||
|
||||
%post
|
||||
if [ -x /usr/sbin/setcap ]; then
|
||||
/usr/sbin/setcap cap_net_raw+ep /usr/sbin/fping
|
||||
else
|
||||
chmod 1777 /usr/sbin/fping
|
||||
fi
|
||||
|
||||
%changelog
|
||||
* Mon Jul 16 2012 Stephen Schaefer <sschaefer@acm.org>
|
||||
- Initial build
|
||||
+17
-2
@@ -1,2 +1,17 @@
|
||||
man_MANS = fping.8
|
||||
EXTRA_DIST = $(man_MANS)
|
||||
man_MANS =
|
||||
|
||||
if IPV4
|
||||
man_MANS += fping.8
|
||||
endif
|
||||
|
||||
if IPV6
|
||||
man_MANS += fping6.8
|
||||
endif
|
||||
|
||||
EXTRA_DIST = $(man_MANS) fping.pod README.1992
|
||||
|
||||
fping.8: fping.pod
|
||||
pod2man -c "" -s 8 -r "fping $(VERSION)" $< >$@
|
||||
|
||||
fping6.8: fping.pod
|
||||
pod2man -c "" -s 8 -r "fping $(VERSION)" -n fping6 $< >$@
|
||||
|
||||
-227
@@ -1,227 +0,0 @@
|
||||
.TH fping 8
|
||||
.SH NAME
|
||||
fping \- send ICMP ECHO_REQUEST packets to network hosts
|
||||
.SH SYNOPSIS
|
||||
.B fping
|
||||
[ \fIoptions\fR ]
|
||||
[ \fIsystems...\fR ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.B fping
|
||||
is a program like
|
||||
.B ping(8)
|
||||
which uses the Internet Control
|
||||
Message Protocol (ICMP) echo request to determine if a target host is
|
||||
responding.
|
||||
.B fping
|
||||
differs from ping in that you can specify any
|
||||
number of targets on the command line, or specify a file containing
|
||||
the lists of targets to ping. Instead of sending to one target until it
|
||||
times out or replies,
|
||||
.B fping
|
||||
will send out a ping packet and move
|
||||
on to the next target in a round-robin fashion.
|
||||
.PP
|
||||
In the default mode, if a target replies,
|
||||
it is noted and removed from the list of targets to check; if a target
|
||||
does not respond within a certain time limit and/or retry limit it
|
||||
is designated as unreachable.
|
||||
.B fping
|
||||
also supports sending a specified number of pings to a target, or
|
||||
looping indefinitely (as in
|
||||
.B ping
|
||||
).
|
||||
.PP
|
||||
Unlike
|
||||
.B ping,
|
||||
.B fping
|
||||
is meant to be used in scripts, so its output is designed to be
|
||||
easy to parse.
|
||||
.SH OPTIONS
|
||||
.IP \fB\-a\fR 5
|
||||
Show systems that are alive.
|
||||
.IP \fB\-A\fR 5
|
||||
Display targets by address rather than DNS name.
|
||||
.IP \fB\-b\fIn\fR 5
|
||||
Number of bytes of ping data to send. The minimum size (normally 12)
|
||||
allows room for the data that
|
||||
.B fping
|
||||
needs to do its work (sequence number, timestamp). The reported
|
||||
received data size includes the IP header (normally 20 bytes) and ICMP
|
||||
header (8 bytes), so the minimum total size is 40 bytes. Default is
|
||||
56, as in
|
||||
.B ping.
|
||||
Maximum is the theoretical maximum IP datagram size (64K), though most
|
||||
systems limit this to a smaller, system-dependent number.
|
||||
.IP \fB\-B\fIn\fR 5
|
||||
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.
|
||||
.IP \fB\-c\fR 5
|
||||
Number of request packets to send to each target. In this mode, a
|
||||
line is displayed for each received response (this can suppressed with
|
||||
\-q or \-Q). Also, statistics about responses for each target are displayed
|
||||
when all requests have been sent (or when interrupted).
|
||||
.IP \fB-C\fR 5
|
||||
Similar to \-c, but the per-target statistics are displayed in a format
|
||||
designed for automated response-time statistics gathering. For
|
||||
example:
|
||||
|
||||
% fping \-C 5 \-q somehost
|
||||
|
||||
somehost : 91.7 37.0 29.2 \- 36.8
|
||||
|
||||
shows the response time in milliseconds for each of the five requests,
|
||||
with the "\-" indicating that no response was received to the fourth
|
||||
request.
|
||||
.IP \fB\-d\fR 5
|
||||
Use DNS to lookup address of return ping packet. This allows you to give
|
||||
fping a list of IP addresses as input and print hostnames in the output.
|
||||
.IP \fB\-e\fR 5
|
||||
Show elapsed (round-trip) time of packets.
|
||||
.IP \fB\-f\fR 5
|
||||
Read list of targets from a file. This option can only be used by the
|
||||
root user. Regular users should pipe in the file via stdin:
|
||||
|
||||
% fping < targets_file
|
||||
|
||||
.IP \fB\-g\fR 5
|
||||
Generate a target list from a supplied IP netmask, or a starting and ending IP.
|
||||
Specify the netmask or start/end in the targets portion of the command line. If
|
||||
a network with netmask is given, the network and broadcast addresses will be
|
||||
excluded.
|
||||
|
||||
ex. To ping the network 192.168.1.0/24, the specified command line could look like either:
|
||||
|
||||
fping \-g 192.168.1.0/24
|
||||
|
||||
or
|
||||
|
||||
fping -g 192.168.1.1 192.168.1.254
|
||||
.IP \fB\-h\fR 5
|
||||
Print usage message.
|
||||
.IP \fB\-i\fIn\fR 5
|
||||
The minimum amount of time (in milliseconds) between sending a ping packet to any target (default is 25).
|
||||
.IP \fB\-l\fR 5
|
||||
Loop sending packets to each target indefinitely. Can be interrupted
|
||||
with Ctrl-C; statistics about responses for each target are then displayed.
|
||||
.IP \fB\-m\fR 5
|
||||
Send pings to each of a target host's multiple interfaces.
|
||||
.IP \fB\-n\fR 5
|
||||
Same as \-d.
|
||||
.IP \fB\-p\fR 5
|
||||
In looping or counting modes (\-l, \-c, or \-C), this parameter sets the
|
||||
time in milliseconds that
|
||||
.B fping
|
||||
waits between successive packets to an individual target. Default is
|
||||
1000.
|
||||
.IP \fB\-q\fR 5
|
||||
Quiet. Don't show per-target results, just set final exit status.
|
||||
.IP \fB\-Q\fIn\fR 5
|
||||
Like \-q, but show summary results every n seconds.
|
||||
.IP \fB\-r\fIn\fR 5
|
||||
Retry limit (default 3). This is the number of times an attempt at pinging
|
||||
a target will be made, not including the first try.
|
||||
.IP \fB\-s\fR 5
|
||||
Print cumulative statistics upon exit.
|
||||
.IP \fB\-S\fIaddr\fR 5
|
||||
Set source address.
|
||||
.IP \fB\-I\fIif\fR 5
|
||||
Set the interface (requires SO_BINDTODEVICE support)
|
||||
.IP \fB\-t\fIn\fR 5
|
||||
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.
|
||||
.IP \fB\-T\fIn\fR 5
|
||||
Ignored (for compatibility with fping 2.4).
|
||||
.IP \fB\-u\fR 5
|
||||
Show targets that are unreachable.
|
||||
.IP \fB\-T\fIn\fR 5
|
||||
Set the typ of service flag (TOS). \fIn\fR can be either decimal or hexadecimal (0xh) format.
|
||||
.IP \fB\-v\fR 5
|
||||
Print
|
||||
.B fping
|
||||
version information.
|
||||
.IP \fB-H\fIn\fR 5
|
||||
Set the IP TTL field (time to live hops).
|
||||
|
||||
.SH EXAMPLES
|
||||
The following perl script will check a list of hosts and send mail if
|
||||
any are unreachable. It uses the open2 function which allows a program
|
||||
to be opened for reading and writing. fping does not start pinging the
|
||||
list of systems until it reads EOF, which it gets after INPUT is closed.
|
||||
Sure the open2 usage is not needed in this example, but it's a good open2
|
||||
example none the less.
|
||||
.nf
|
||||
|
||||
#!/usr/bin/perl
|
||||
require 'open2.pl';
|
||||
|
||||
$MAILTO = "root";
|
||||
|
||||
$pid = &open2("OUTPUT","INPUT","/usr/local/bin/fping -u");
|
||||
|
||||
@check=("slapshot","foo","foobar");
|
||||
|
||||
foreach(@check) { print INPUT "$_\\n"; }
|
||||
close(INPUT);
|
||||
@output=<OUTPUT>;
|
||||
|
||||
if ($#output != -1) {
|
||||
chop($date=`date`);
|
||||
open(MAIL,"|mail -s 'unreachable systems' $MAILTO");
|
||||
print MAIL "\\nThe following systems are unreachable as of: $date\\n\\n";
|
||||
print MAIL @output;
|
||||
close MAIL;
|
||||
}
|
||||
|
||||
.fi
|
||||
Another good example is when you want to perform an action only on hosts
|
||||
that are currently reachable.
|
||||
.nf
|
||||
|
||||
#!/usr/bin/perl
|
||||
|
||||
$hosts_to_backup = `cat /etc/hosts.backup | fping -a`;
|
||||
|
||||
foreach $host (split(/\\n/,$hosts_to_backup)) {
|
||||
# do it
|
||||
}
|
||||
|
||||
.fi
|
||||
|
||||
.SH AUTHORS
|
||||
.nf
|
||||
Roland J. Schemers III, Stanford University, concept and versions 1.x
|
||||
RL "Bob" Morgan, Stanford University, versions 2.x
|
||||
David Papp, versions 2.3x and up,
|
||||
David Schweikert, versions 3.0 and up
|
||||
fping website: http://www.fping.org
|
||||
.fi
|
||||
.SH DIAGNOSTICS
|
||||
Exit status is 0 if all the hosts are reachable, 1 if some hosts were
|
||||
unreachable, 2 if any IP addresses were not found, 3 for invalid
|
||||
command line arguments, and 4 for a system call failure.
|
||||
.SH BUGS
|
||||
Ha! If we knew of any we would have fixed them!
|
||||
.SH RESTRICTIONS
|
||||
If certain options are used (i.e, a low value for \-i and \-t, and a
|
||||
high value for \-r) it is possible to flood the network. This program
|
||||
must be installed as setuid root in order to open up a raw socket,
|
||||
or must be run by root. In order to stop mere mortals from hosing the
|
||||
network (when fping is installed setuid root) , normal users can't specify
|
||||
the following:
|
||||
.nf
|
||||
|
||||
-i n where n < 10 msec
|
||||
-r n where n > 20
|
||||
-t n where n < 250 msec
|
||||
|
||||
.fi
|
||||
.SH SEE ALSO
|
||||
netstat(1), ping(8), ifconfig(8c)
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
=head1 NAME
|
||||
|
||||
fping - send ICMP ECHO_REQUEST packets to network hosts
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
B<fping> [ I<options> ] [ I<systems...> ]
|
||||
B<fping6> [ I<options> ] [ I<systems...> ]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<fping> is a program like B<ping> which uses the Internet Control Message
|
||||
Protocol (ICMP) echo request to determine if a target host is responding.
|
||||
B<fping> differs from B<ping> in that you can specify any number of targets on the
|
||||
command line, or specify a file containing the lists of targets to ping.
|
||||
Instead of sending to one target until it times out or replies, B<fping> will
|
||||
send out a ping packet and move on to the next target in a round-robin fashion.
|
||||
In the default mode, if a target replies, it is noted and removed from the list
|
||||
of targets to check; if a target does not respond within a certain time limit
|
||||
and/or retry limit it is designated as unreachable. B<fping> also supports
|
||||
sending a specified number of pings to a target, or looping indefinitely (as in
|
||||
B<ping> ). Unlike B<ping>, B<fping> is meant to be used in scripts, so its
|
||||
output is designed to be easy to parse.
|
||||
|
||||
The binary named B<fping6> is the same as B<fping>, except that it uses IPv6
|
||||
addresses instead of IPv4.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 5
|
||||
|
||||
=item B<-a>
|
||||
|
||||
Show systems that are alive.
|
||||
|
||||
=item B<-A>
|
||||
|
||||
Display targets by address rather than DNS name.
|
||||
|
||||
=item B<-b> I<n>
|
||||
|
||||
Number of bytes of ping data to send. The minimum size (normally 12) allows
|
||||
room for the data that B<fping> needs to do its work (sequence number,
|
||||
timestamp). The reported received data size includes the IP header (normally
|
||||
20 bytes) and ICMP header (8 bytes), so the minimum total size is 40 bytes.
|
||||
Default is 56, as in B<ping>. Maximum is the theoretical maximum IP datagram
|
||||
size (64K), though most systems limit this to a smaller, system-dependent
|
||||
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.
|
||||
|
||||
=item B<-c> I<n>
|
||||
|
||||
Number of request packets to send to each target. In this mode, a line is
|
||||
displayed for each received response (this can suppressed with B<-q> or B<-Q>).
|
||||
Also, statistics about responses for each target are displayed when all
|
||||
requests have been sent (or when interrupted).
|
||||
|
||||
=item B<-C> I<n>
|
||||
|
||||
Similar to B<-c>, but the per-target statistics are displayed in a format
|
||||
designed for automated response-time statistics gathering. For example:
|
||||
|
||||
% fping -C 5 -q somehost
|
||||
somehost : 91.7 37.0 29.2 - 36.8
|
||||
|
||||
shows the response time in milliseconds for each of the five requests, with the
|
||||
C<-> indicating that no response was received to the fourth request.
|
||||
|
||||
=item B<-d>
|
||||
|
||||
Use DNS to lookup address of return ping packet. This allows you to give fping
|
||||
a list of IP addresses as input and print hostnames in the output.
|
||||
|
||||
=item B<-e>
|
||||
|
||||
Show elapsed (round-trip) time of packets.
|
||||
|
||||
=item B<-f>
|
||||
|
||||
Read list of targets from a file. This option can only be used by the root
|
||||
user. Regular users should pipe in the file via stdin:
|
||||
|
||||
% fping < targets_file
|
||||
|
||||
=item B<-g> I<addr/mask>
|
||||
|
||||
Generate a target list from a supplied IP netmask, or a starting and ending IP.
|
||||
Specify the netmask or start/end in the targets portion of the command line. If
|
||||
a network with netmask is given, the network and broadcast addresses will be
|
||||
excluded. ex. To ping the network 192.168.1.0/24, the specified command line
|
||||
could look like either:
|
||||
|
||||
fping -g 192.168.1.0/24
|
||||
|
||||
or
|
||||
|
||||
fping -g 192.168.1.1 192.168.1.254
|
||||
|
||||
=item B<-h>
|
||||
|
||||
Print usage message.
|
||||
|
||||
=item B<-i> I<n>
|
||||
|
||||
The minimum amount of time (in milliseconds) between sending a ping packet
|
||||
to any target (default is 25).
|
||||
|
||||
=item B<-l>
|
||||
|
||||
Loop sending packets to each target indefinitely. Can be interrupted with
|
||||
Ctrl-C; statistics about responses for each target are then displayed.
|
||||
|
||||
=item B<-m>
|
||||
|
||||
Send pings to each of a target host's multiple interfaces.
|
||||
|
||||
=item B<-n>
|
||||
|
||||
Same as -d.
|
||||
|
||||
=item B<-p> <n>
|
||||
|
||||
In looping or counting modes (B<-l>, B<-c>, or B<-C>), this parameter sets
|
||||
the time in milliseconds that B<fping> waits between successive packets to
|
||||
an individual target. Default is 1000.
|
||||
|
||||
=item B<-q>
|
||||
|
||||
Quiet. Don't show per-probe results, but only the final summary. Also don't
|
||||
show ICMP error messages.
|
||||
|
||||
=item B<-Q> I<n>
|
||||
|
||||
Like B<-q>, but show summary results every n seconds.
|
||||
|
||||
=item B<-r> I<n>
|
||||
|
||||
Retry limit (default 3). This is the number of times an attempt at pinging
|
||||
a target will be made, not including the first try.
|
||||
|
||||
=item B<-s>
|
||||
|
||||
Print cumulative statistics upon exit.
|
||||
|
||||
=item B<-S> I<addr>
|
||||
|
||||
Set source address.
|
||||
|
||||
=item B<-I> I<if>
|
||||
|
||||
Set the interface (requires SO_BINDTODEVICE support)
|
||||
|
||||
=item B<-t> I<n>
|
||||
|
||||
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.
|
||||
|
||||
=item B<-T> I<n>
|
||||
|
||||
Ignored (for compatibility with fping 2.4).
|
||||
|
||||
=item B<-u>
|
||||
|
||||
Show targets that are unreachable.
|
||||
|
||||
=item B<-O> I<n>
|
||||
|
||||
Set the typ of service flag (TOS). I<n> can be either decimal or hexadecimal
|
||||
(0xh) format.
|
||||
|
||||
=item B<-v>
|
||||
|
||||
Print B<fping> version information.
|
||||
|
||||
=item B<-H> I<n>
|
||||
|
||||
Set the IP TTL field (time to live hops).
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
Roland J. Schemers III, Stanford University, concept and versions 1.x
|
||||
|
||||
=item *
|
||||
|
||||
RL "Bob" Morgan, Stanford University, versions 2.x
|
||||
|
||||
=item *
|
||||
|
||||
David Papp, versions 2.3x and up
|
||||
|
||||
=item *
|
||||
|
||||
David Schweikert, versions 3.0 and up
|
||||
|
||||
=back
|
||||
|
||||
B<fping website: L<http://www.fping.org>>
|
||||
|
||||
=head1 DIAGNOSTICS
|
||||
|
||||
Exit status is 0 if all the hosts are reachable, 1 if some hosts
|
||||
were unreachable, 2 if any IP addresses were not found, 3 for invalid command
|
||||
line arguments, and 4 for a system call failure.
|
||||
|
||||
=head1 RESTRICTIONS
|
||||
|
||||
If certain options are used (i.e, a low value for B<-i> and B<-t>, and a high value
|
||||
for B<-r>) it is possible to flood the network. This program must be installed as
|
||||
setuid root in order to open up a raw socket, or must be run by root. In order
|
||||
to stop mere mortals from hosing the network, normal users can't specify the following:
|
||||
|
||||
=over 4
|
||||
|
||||
=item *
|
||||
|
||||
B<-i> I<n>, where I<n> < 10 msec
|
||||
|
||||
=item *
|
||||
|
||||
B<-r> I<n>, where I<n> > 20
|
||||
|
||||
=item *
|
||||
|
||||
B<-t> I<n>, where n < 250 msec
|
||||
|
||||
=back
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
C<ping(8)>
|
||||
+14
-1
@@ -1,3 +1,16 @@
|
||||
sbin_PROGRAMS = fping
|
||||
prog =
|
||||
|
||||
if IPV4
|
||||
prog += fping
|
||||
endif
|
||||
if IPV6
|
||||
prog += fping6
|
||||
endif
|
||||
|
||||
sbin_PROGRAMS = ${prog}
|
||||
|
||||
fping_SOURCES = fping.c options.h
|
||||
fping_DEPENDENCIES = ../config.h
|
||||
fping6_SOURCES = fping.c options.h
|
||||
fping6_DEPENDENCIES = ../config.h
|
||||
fping6_CFLAGS = $(AM_CFLAGS) -DIPV6
|
||||
|
||||
+127
-142
@@ -52,6 +52,7 @@ extern "C"
|
||||
#include <time.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
@@ -132,7 +133,7 @@ typedef struct ping_data
|
||||
#define MAX_PING_DATA ( MAX_IP_PACKET - SIZE_IP_HDR - SIZE_ICMP_HDR )
|
||||
|
||||
/* sized so as to be like traditional ping */
|
||||
#define DEFAULT_PING_DATA_SIZE ( MIN_PING_DATA + 44 )
|
||||
#define DEFAULT_PING_DATA_SIZE 56
|
||||
|
||||
/* maxima and minima */
|
||||
#define MAX_COUNT 10000
|
||||
@@ -328,7 +329,6 @@ void add_addr( char *name, char *host, struct in_addr ipaddr );
|
||||
void add_addr( char *name, char *host, FPING_SOCKADDR *ipaddr );
|
||||
#endif
|
||||
char *na_cat( char *name, struct in_addr ipaddr );
|
||||
char *cpystr( char *string );
|
||||
void crash_and_burn( char *message );
|
||||
void errno_crash_and_burn( char *message );
|
||||
char *get_host_by_address( struct in_addr in );
|
||||
@@ -353,6 +353,7 @@ HOST_ENTRY *ev_dequeue();
|
||||
void ev_remove(HOST_ENTRY *h);
|
||||
void add_cidr(char *);
|
||||
void add_range(char *, char *);
|
||||
void print_warning(char *fmt, ...);
|
||||
|
||||
/*** function definitions ***/
|
||||
|
||||
@@ -877,9 +878,7 @@ int main( int argc, char **argv )
|
||||
if( ( !*host ) || ( host[0] == '#' ) ) /* magic to avoid comments */
|
||||
continue;
|
||||
|
||||
p = cpystr( host );
|
||||
add_name( p );
|
||||
|
||||
add_name(p);
|
||||
}/* WHILE */
|
||||
|
||||
fclose( ping_file );
|
||||
@@ -1030,7 +1029,7 @@ void add_cidr(char *addr)
|
||||
char buffer[20];
|
||||
in_addr_tmp.s_addr = htonl(net_addr);
|
||||
inet_ntop(AF_INET, &in_addr_tmp, buffer, sizeof(buffer));
|
||||
add_name(cpystr(buffer));
|
||||
add_name(buffer);
|
||||
}
|
||||
|
||||
freeaddrinfo(addr_res);
|
||||
@@ -1080,7 +1079,7 @@ void add_range(char *start, char *end)
|
||||
char buffer[20];
|
||||
in_addr_tmp.s_addr = htonl(start_long);
|
||||
inet_ntop(AF_INET, &in_addr_tmp, buffer, sizeof(buffer));
|
||||
add_name(cpystr(buffer));
|
||||
add_name(buffer);
|
||||
start_long++;
|
||||
}
|
||||
}
|
||||
@@ -1307,39 +1306,39 @@ void print_per_system_stats( void )
|
||||
fflush( stdout );
|
||||
|
||||
if( verbose_flag || per_recv_flag )
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stdout, "\n" );
|
||||
|
||||
for( i = 0; i < num_hosts; i++ )
|
||||
{
|
||||
h = table[i];
|
||||
fprintf( stderr, "%s%s :", h->host, h->pad );
|
||||
fprintf( stdout, "%s%s :", h->host, h->pad );
|
||||
|
||||
if( report_all_rtts_flag )
|
||||
{
|
||||
for( j = 0; j < h->num_sent; j++ )
|
||||
{
|
||||
if( ( resp = h->resp_times[j] ) >= 0 )
|
||||
fprintf( stderr, " %d.%02d", resp / 100, resp % 100 );
|
||||
fprintf( stdout, " %d.%02d", resp / 100, resp % 100 );
|
||||
else
|
||||
fprintf( stderr, " -" );
|
||||
fprintf( stdout, " -" );
|
||||
|
||||
}/* FOR */
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stdout, "\n" );
|
||||
|
||||
}/* IF */
|
||||
else
|
||||
{
|
||||
if( h->num_recv <= h->num_sent )
|
||||
{
|
||||
fprintf( stderr, " xmt/rcv/%%loss = %d/%d/%d%%",
|
||||
fprintf( stdout, " xmt/rcv/%%loss = %d/%d/%d%%",
|
||||
h->num_sent, h->num_recv, h->num_sent > 0 ?
|
||||
( ( h->num_sent - h->num_recv ) * 100 ) / h->num_sent : 0 );
|
||||
|
||||
}/* IF */
|
||||
else
|
||||
{
|
||||
fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%",
|
||||
fprintf( stdout, " xmt/rcv/%%return = %d/%d/%d%%",
|
||||
h->num_sent, h->num_recv,
|
||||
( ( h->num_recv * 100 ) / h->num_sent ) );
|
||||
|
||||
@@ -1348,13 +1347,13 @@ void print_per_system_stats( void )
|
||||
if( h->num_recv )
|
||||
{
|
||||
avg = h->total_time / h->num_recv;
|
||||
fprintf( stderr, ", min/avg/max = %s", sprint_tm( h->min_reply ) );
|
||||
fprintf( stderr, "/%s", sprint_tm( avg ) );
|
||||
fprintf( stderr, "/%s", sprint_tm( h->max_reply ) );
|
||||
fprintf( stdout, ", min/avg/max = %s", sprint_tm( h->min_reply ) );
|
||||
fprintf( stdout, "/%s", sprint_tm( avg ) );
|
||||
fprintf( stdout, "/%s", sprint_tm( h->max_reply ) );
|
||||
|
||||
}/* IF */
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stdout, "\n");
|
||||
|
||||
}/* ELSE */
|
||||
|
||||
@@ -1364,11 +1363,11 @@ void print_per_system_stats( void )
|
||||
for( j = 0; j < h->num_sent; j++ )
|
||||
{
|
||||
if( ( resp = h->sent_times[j] ) >= 0 )
|
||||
fprintf( stderr, " %s", sprint_tm( resp ) );
|
||||
fprintf( stdout, " %s", sprint_tm( resp ) );
|
||||
else
|
||||
fprintf( stderr, " -" );
|
||||
fprintf( stdout, " -" );
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stdout, "\n" );
|
||||
|
||||
}/* FOR */
|
||||
}/* IF */
|
||||
@@ -1411,27 +1410,27 @@ void print_per_system_splits( void )
|
||||
fflush( stdout );
|
||||
|
||||
if( verbose_flag || per_recv_flag )
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stdout, "\n" );
|
||||
|
||||
curr_tm = localtime( ( time_t* )¤t_time.tv_sec );
|
||||
fprintf( stderr, "[%2.2d:%2.2d:%2.2d]\n", curr_tm->tm_hour,
|
||||
fprintf( stdout, "[%2.2d:%2.2d:%2.2d]\n", curr_tm->tm_hour,
|
||||
curr_tm->tm_min, curr_tm->tm_sec );
|
||||
|
||||
for( i = 0; i < num_hosts; i++ )
|
||||
{
|
||||
h = table[i];
|
||||
fprintf( stderr, "%s%s :", h->host, h->pad );
|
||||
fprintf( stdout, "%s%s :", h->host, h->pad );
|
||||
|
||||
if( h->num_recv_i <= h->num_sent_i )
|
||||
{
|
||||
fprintf( stderr, " xmt/rcv/%%loss = %d/%d/%d%%",
|
||||
fprintf( stdout, " xmt/rcv/%%loss = %d/%d/%d%%",
|
||||
h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ?
|
||||
( ( h->num_sent_i - h->num_recv_i ) * 100 ) / h->num_sent_i : 0 );
|
||||
|
||||
}/* IF */
|
||||
else
|
||||
{
|
||||
fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%",
|
||||
fprintf( stdout, " xmt/rcv/%%return = %d/%d/%d%%",
|
||||
h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ?
|
||||
( ( h->num_recv_i * 100 ) / h->num_sent_i ) : 0 );
|
||||
|
||||
@@ -1440,13 +1439,13 @@ void print_per_system_splits( void )
|
||||
if( h->num_recv_i )
|
||||
{
|
||||
avg = h->total_time_i / h->num_recv_i;
|
||||
fprintf( stderr, ", min/avg/max = %s", sprint_tm( h->min_reply_i ) );
|
||||
fprintf( stderr, "/%s", sprint_tm( avg ) );
|
||||
fprintf( stderr, "/%s", sprint_tm( h->max_reply_i ) );
|
||||
fprintf( stdout, ", min/avg/max = %s", sprint_tm( h->min_reply_i ) );
|
||||
fprintf( stdout, "/%s", sprint_tm( avg ) );
|
||||
fprintf( stdout, "/%s", sprint_tm( h->max_reply_i ) );
|
||||
|
||||
}/* IF */
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stdout, "\n" );
|
||||
h->num_sent_i = h->num_recv_i = h->max_reply_i =
|
||||
h->min_reply_i = h->total_time_i = 0;
|
||||
|
||||
@@ -1473,17 +1472,17 @@ void print_per_system_splits( void )
|
||||
void print_global_stats( void )
|
||||
{
|
||||
fflush( stdout );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, " %7d targets\n", num_hosts );
|
||||
fprintf( stderr, " %7d alive\n", num_alive );
|
||||
fprintf( stderr, " %7d unreachable\n" ,num_unreachable );
|
||||
fprintf( stderr, " %7d unknown addresses\n", num_noaddress );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stderr, " %7d timeouts (waiting for response)\n", num_timeout );
|
||||
fprintf( stderr, " %7d ICMP Echos sent\n", num_pingsent );
|
||||
fprintf( stderr, " %7d ICMP Echo Replies received\n", num_pingreceived );
|
||||
fprintf( stderr, " %7d other ICMP received\n", num_othericmprcvd );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stdout, "\n" );
|
||||
fprintf( stdout, " %7d targets\n", num_hosts );
|
||||
fprintf( stdout, " %7d alive\n", num_alive );
|
||||
fprintf( stdout, " %7d unreachable\n" ,num_unreachable );
|
||||
fprintf( stdout, " %7d unknown addresses\n", num_noaddress );
|
||||
fprintf( stdout, "\n" );
|
||||
fprintf( stdout, " %7d timeouts (waiting for response)\n", num_timeout );
|
||||
fprintf( stdout, " %7d ICMP Echos sent\n", num_pingsent );
|
||||
fprintf( stdout, " %7d ICMP Echo Replies received\n", num_pingreceived );
|
||||
fprintf( stdout, " %7d other ICMP received\n", num_othericmprcvd );
|
||||
fprintf( stdout, "\n" );
|
||||
|
||||
if( total_replies == 0 )
|
||||
{
|
||||
@@ -1494,13 +1493,13 @@ void print_global_stats( void )
|
||||
|
||||
}/* IF */
|
||||
|
||||
fprintf( stderr, " %s ms (min round trip time)\n", sprint_tm( min_reply ) );
|
||||
fprintf( stderr, " %s ms (avg round trip time)\n",
|
||||
fprintf( stdout, " %s ms (min round trip time)\n", sprint_tm( min_reply ) );
|
||||
fprintf( stdout, " %s ms (avg round trip time)\n",
|
||||
sprint_tm( ( int )( sum_replies / total_replies ) ) );
|
||||
fprintf( stderr, " %s ms (max round trip time)\n", sprint_tm( max_reply ) );
|
||||
fprintf( stderr, " %12.3f sec (elapsed real time)\n",
|
||||
fprintf( stdout, " %s ms (max round trip time)\n", sprint_tm( max_reply ) );
|
||||
fprintf( stdout, " %.3f sec (elapsed real time)\n",
|
||||
timeval_diff( &end_time, &start_time ) / 100000.0 );
|
||||
fprintf( stderr, "\n" );
|
||||
fprintf( stdout, "\n" );
|
||||
|
||||
} /* print_global_stats() */
|
||||
|
||||
@@ -1586,10 +1585,11 @@ int send_ping( int s, HOST_ENTRY *h )
|
||||
|
||||
}/* IF */
|
||||
|
||||
num_unreachable++;
|
||||
remove_job( h );
|
||||
h->num_sent++;
|
||||
h->num_sent_i++;
|
||||
num_pingsent++;
|
||||
free( buffer );
|
||||
return(0);
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* mark this trial as outstanding */
|
||||
@@ -1915,7 +1915,7 @@ int handle_random_icmp( FPING_ICMPHDR *p, int psize, FPING_SOCKADDR *addr )
|
||||
|
||||
if( p->icmp_code > ICMP_UNREACH_MAXTYPE )
|
||||
{
|
||||
fprintf( stderr, "ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
|
||||
print_warning("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
|
||||
inet_ntoa( addr->sin_addr ), h->host );
|
||||
|
||||
#else
|
||||
@@ -1928,13 +1928,13 @@ int handle_random_icmp( FPING_ICMPHDR *p, int psize, FPING_SOCKADDR *addr )
|
||||
|
||||
if( p->icmp6_code > ICMP_UNREACH_MAXTYPE )
|
||||
{
|
||||
fprintf( stderr, "ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
|
||||
print_warning("ICMP Unreachable (Invalid Code) from %s for ICMP Echo sent to %s",
|
||||
addr_ascii, h->host );
|
||||
#endif
|
||||
}/* IF */
|
||||
else
|
||||
{
|
||||
fprintf( stderr, "%s from %s for ICMP Echo sent to %s",
|
||||
print_warning("%s from %s for ICMP Echo sent to %s",
|
||||
#ifndef IPV6
|
||||
icmp_unreach_str[p->icmp_code], inet_ntoa( addr->sin_addr ), h->host );
|
||||
#else
|
||||
@@ -1945,12 +1945,12 @@ int handle_random_icmp( FPING_ICMPHDR *p, int psize, FPING_SOCKADDR *addr )
|
||||
|
||||
if( inet_addr( h->host ) == -1 )
|
||||
#ifndef IPV6
|
||||
fprintf( stderr, " (%s)", inet_ntoa( h->saddr.sin_addr ) );
|
||||
print_warning(" (%s)", inet_ntoa( h->saddr.sin_addr ) );
|
||||
#else
|
||||
fprintf( stderr, " (%s)", addr_ascii);
|
||||
print_warning(" (%s)", addr_ascii);
|
||||
#endif
|
||||
|
||||
fprintf( stderr, "\n" );
|
||||
print_warning("\n" );
|
||||
|
||||
}/* IF */
|
||||
|
||||
@@ -2088,11 +2088,14 @@ void add_name( char *name )
|
||||
/* input name is an IP addr, go with it */
|
||||
if( name_flag )
|
||||
{
|
||||
if( addr_flag )
|
||||
add_addr( name, na_cat( get_host_by_address( *ipa ), *ipa ), *ipa );
|
||||
if( addr_flag ) {
|
||||
char namebuf[256];
|
||||
snprintf(namebuf, 256, "%s (%s)", get_host_by_address(*ipa), name);
|
||||
add_addr(name, namebuf, *ipa);
|
||||
}
|
||||
else
|
||||
{
|
||||
nm = cpystr( get_host_by_address( *ipa ) );
|
||||
nm = get_host_by_address( *ipa );
|
||||
add_addr( name, nm, *ipa );
|
||||
|
||||
}/* ELSE */
|
||||
@@ -2125,36 +2128,39 @@ void add_name( char *name )
|
||||
if( getnetgrent( &machine, &user_ignored, &domain_ignored ) == 0 )
|
||||
{
|
||||
endnetgrent();
|
||||
if( !quiet_flag )
|
||||
fprintf( stderr, "%s address not found\n", name );
|
||||
print_warning("%s address not found\n", name );
|
||||
|
||||
num_noaddress++;
|
||||
return;
|
||||
|
||||
}/* IF */
|
||||
else
|
||||
add_name( cpystr( machine ) );
|
||||
add_name(machine);
|
||||
|
||||
while( getnetgrent( &machine, &user_ignored, &domain_ignored ) )
|
||||
add_name( cpystr( machine ) );
|
||||
add_name(machine);
|
||||
|
||||
endnetgrent();
|
||||
return;
|
||||
#else
|
||||
if( !quiet_flag )
|
||||
fprintf( stderr, "%s address not found\n", name );
|
||||
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 );
|
||||
num_noaddress++;
|
||||
return;
|
||||
}
|
||||
|
||||
host_add = ( struct in_addr* )*( host_ent->h_addr_list );
|
||||
if( host_add == NULL )
|
||||
{
|
||||
if( !quiet_flag )
|
||||
fprintf( stderr, "%s has no address data\n", name );
|
||||
print_warning("%s has no address data\n", name );
|
||||
|
||||
num_noaddress++;
|
||||
return;
|
||||
@@ -2165,11 +2171,15 @@ void add_name( char *name )
|
||||
/* it is indeed a hostname with a real address */
|
||||
while( host_add )
|
||||
{
|
||||
if( name_flag && addr_flag )
|
||||
add_addr( name, na_cat( name, *host_add ), *host_add );
|
||||
if( name_flag && addr_flag ) {
|
||||
char namebuf[256];
|
||||
nm = inet_ntoa(*host_add);
|
||||
snprintf(namebuf, 256, "%s (%s)", name, nm);
|
||||
add_addr( name, namebuf, *host_add );
|
||||
}
|
||||
else if( addr_flag )
|
||||
{
|
||||
nm = cpystr( inet_ntoa( *host_add ) );
|
||||
nm = inet_ntoa(*host_add);
|
||||
add_addr( name, nm, *host_add );
|
||||
}/* ELSE IF */
|
||||
else
|
||||
@@ -2214,45 +2224,36 @@ void add_name( char *name )
|
||||
len = res->ai_addrlen;
|
||||
if (len > sizeof(FPING_SOCKADDR)) len = sizeof(FPING_SOCKADDR);
|
||||
(void)memcpy(&dst, res->ai_addr, len);
|
||||
add_addr(name, name, &dst);
|
||||
|
||||
/* numerical addresses requested */
|
||||
if(addr_flag) {
|
||||
char addrbuf[64];
|
||||
int ret;
|
||||
ret = getnameinfo(res->ai_addr, res->ai_addrlen, addrbuf,
|
||||
64, NULL, 0, NI_NUMERICHOST);
|
||||
if (ret) {
|
||||
if(!quiet_flag) {
|
||||
warnx("%s", gai_strerror(ret_ga));
|
||||
}
|
||||
num_noaddress++;
|
||||
return;
|
||||
}
|
||||
if(name_flag) {
|
||||
char nameaddrbuf[256];
|
||||
snprintf(nameaddrbuf, 256, "%s (%s)", name, addrbuf);
|
||||
add_addr(name, nameaddrbuf, &dst);
|
||||
}
|
||||
else {
|
||||
add_addr(name, addrbuf, &dst);
|
||||
}
|
||||
}
|
||||
else {
|
||||
add_addr(name, name, &dst);
|
||||
}
|
||||
#endif
|
||||
} /* add_name() */
|
||||
|
||||
|
||||
/************************************************************
|
||||
|
||||
Function: na_cat
|
||||
|
||||
*************************************************************
|
||||
|
||||
Inputs: char* name, struct in_addr ipaddr
|
||||
|
||||
Returns: char*
|
||||
|
||||
Description:
|
||||
|
||||
************************************************************/
|
||||
|
||||
char *na_cat( char *name, struct in_addr ipaddr )
|
||||
{
|
||||
char *nm, *as;
|
||||
|
||||
as = inet_ntoa( ipaddr );
|
||||
nm = ( char* )malloc( strlen( name ) + strlen( as ) + 4 );
|
||||
|
||||
if( !nm )
|
||||
crash_and_burn( "can't allocate some space for a string" );
|
||||
|
||||
strcpy( nm, name );
|
||||
strcat( nm, " (" );
|
||||
strcat( nm, as );
|
||||
strcat( nm, ")" );
|
||||
|
||||
return( nm );
|
||||
|
||||
} /* na_cat() */
|
||||
|
||||
|
||||
/************************************************************
|
||||
|
||||
Function: add_addr
|
||||
@@ -2283,8 +2284,8 @@ void add_addr( char *name, char *host, FPING_SOCKADDR *ipaddr )
|
||||
|
||||
memset( ( char* ) p, 0, sizeof( HOST_ENTRY ) );
|
||||
|
||||
p->name = name;
|
||||
p->host = host;
|
||||
p->name = strdup(name);
|
||||
p->host = strdup(host);
|
||||
#ifndef IPV6
|
||||
p->saddr.sin_family = AF_INET;
|
||||
p->saddr.sin_addr = ipaddr;
|
||||
@@ -2398,41 +2399,6 @@ char *get_host_by_address( struct in_addr in )
|
||||
|
||||
} /* get_host_by_address() */
|
||||
|
||||
|
||||
/************************************************************
|
||||
|
||||
Function: cpystr
|
||||
|
||||
*************************************************************
|
||||
|
||||
Inputs: char* string
|
||||
|
||||
Returns: char*
|
||||
|
||||
Description:
|
||||
|
||||
************************************************************/
|
||||
|
||||
char *cpystr( char *string )
|
||||
{
|
||||
char *dst;
|
||||
|
||||
if( string )
|
||||
{
|
||||
dst = ( char* )malloc( 1 + strlen( string ) );
|
||||
if( !dst )
|
||||
crash_and_burn( "can't allocate some space for a string" );
|
||||
|
||||
strcpy( dst, string );
|
||||
return dst;
|
||||
|
||||
}/* IF */
|
||||
else
|
||||
return NULL;
|
||||
|
||||
} /* cpystr() */
|
||||
|
||||
|
||||
/************************************************************
|
||||
|
||||
Function: crash_and_burn
|
||||
@@ -2474,6 +2440,25 @@ void errno_crash_and_burn( char *message )
|
||||
} /* errno_crash_and_burn() */
|
||||
|
||||
|
||||
/************************************************************
|
||||
|
||||
Function: print_warning
|
||||
|
||||
Description: fprintf(stderr, ...), unless running with -q
|
||||
|
||||
*************************************************************/
|
||||
|
||||
void print_warning(char *format, ...) {
|
||||
va_list args;
|
||||
if(!quiet_flag) {
|
||||
va_start(args, format );
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/************************************************************
|
||||
|
||||
Function: timeval_diff
|
||||
@@ -2810,7 +2795,7 @@ void usage(int is_error)
|
||||
fprintf(out, "Usage: %s [options] [targets...]\n", prog );
|
||||
fprintf(out, " -a show targets that are alive\n" );
|
||||
fprintf(out, " -A show targets by address\n" );
|
||||
fprintf(out, " -b n amount of ping data to send, in bytes (default %d)\n", ping_data_size );
|
||||
fprintf(out, " -b n amount of ping data to send, in bytes (default %d)\n", DEFAULT_PING_DATA_SIZE);
|
||||
fprintf(out, " -B f set exponential backoff factor to f\n" );
|
||||
fprintf(out, " -c n count of pings to send to each target (default %d)\n", count );
|
||||
fprintf(out, " -C n same as -c, report results in verbose format\n" );
|
||||
|
||||
Reference in New Issue
Block a user