Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6f37022a4 | ||
|
|
c786c34334 | ||
|
|
cd21d0bb91 | ||
|
|
b359c0e7a3 | ||
|
|
9d71f4e809 | ||
|
|
af0446b046 | ||
|
|
930af0fc54 | ||
|
|
00e3384d5c | ||
|
|
6fa8c4c175 | ||
|
|
8cda80898e | ||
|
|
56c431df13 | ||
|
|
def79d3590 | ||
|
|
0990bf1c61 | ||
|
|
a6721ac2d2 | ||
|
|
49f24acda6 | ||
|
|
37158fe9fe | ||
|
|
86ecd82263 | ||
|
|
382ab64e5c | ||
|
|
3f37397c58 | ||
|
|
8bd200905d | ||
|
|
91130ebd28 | ||
|
|
358ac75c21 | ||
|
|
c5e7e911b0 | ||
|
|
e2705a01c1 | ||
|
|
d9506b335f | ||
|
|
782524e489 | ||
|
|
956b851d47 | ||
|
|
e27fd71935 | ||
|
|
4989d94eb7 | ||
|
|
ff44de71b1 | ||
|
|
e7ace04516 | ||
|
|
18aa33e13a | ||
|
|
71bf72527b | ||
|
|
e07a6e9dfc | ||
|
|
71616ec77e | ||
|
|
42574667d6 | ||
|
|
2604b40743 | ||
|
|
e39e24e933 | ||
|
|
bd768a44f8 | ||
|
|
e9daacdf81 | ||
|
|
2f9cd95bbd | ||
|
|
219dbd893d | ||
|
|
7dd45384e4 | ||
|
|
f9c68a6dc7 | ||
|
|
540057dfd9 | ||
|
|
fdddda1c22 | ||
|
|
a2ac03c210 | ||
|
|
3eccad8ee1 | ||
|
|
c6d311a7d4 | ||
|
|
5851422798 | ||
|
|
57595638ec | ||
|
|
801051eeec | ||
|
|
806ad042b8 | ||
|
|
5dc8afb265 | ||
|
|
f27a89d40d | ||
|
|
b973451021 | ||
|
|
63c73e0697 | ||
|
|
5dd8c5de50 | ||
|
|
0decb829d8 | ||
|
|
3e8eb6c613 | ||
|
|
85abf34b0a | ||
|
|
bda0744d2c | ||
|
|
d6808efd81 | ||
|
|
3a714b275f | ||
|
|
d141744adb | ||
|
|
e1cdf8e1d3 | ||
|
|
d862dd962b | ||
|
|
5c68d6f338 | ||
|
|
a2ac5d0fae | ||
|
|
b01f282727 | ||
|
|
0ab66f80de | ||
|
|
741236e576 | ||
|
|
9fca2a141b | ||
|
|
9ee22bd46a | ||
|
|
f55397336b | ||
|
|
82722a31fe | ||
|
|
4aad0b2c14 | ||
|
|
fb5f5779cc | ||
|
|
a0252f6e79 | ||
|
|
3dee903b41 | ||
|
|
7e55f0b073 | ||
|
|
8daad08e1d | ||
|
|
b7343ed256 | ||
|
|
ecba31b2dd | ||
|
|
28eea9c273 | ||
|
|
121bea1d24 | ||
|
|
5d6db6f08d | ||
|
|
543d22122d | ||
|
|
70a29a11af | ||
|
|
b0e09ce6fe | ||
|
|
6400ffb339 | ||
|
|
98d44d02bb | ||
|
|
69fff78ca4 | ||
|
|
5b6784a4ea | ||
|
|
25dc120355 | ||
|
|
f906225fbd | ||
|
|
3e29f0631c | ||
|
|
10d0a54c07 | ||
|
|
ad4ca1609d | ||
|
|
e0edbf28fc | ||
|
|
1c85a422c1 | ||
|
|
86cfc7cf74 | ||
|
|
fd020977b5 | ||
|
|
81c96c0807 | ||
|
|
aff259bbd0 | ||
|
|
4cab2f8598 | ||
|
|
aa5f849c5d | ||
|
|
1bb43dc07f | ||
|
|
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 |
@@ -1,10 +1,15 @@
|
||||
.*.swp
|
||||
*.tar.gz
|
||||
*~
|
||||
src/*.gcno
|
||||
src/*.gcda
|
||||
src/*.gcov
|
||||
.deps
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
autom4te.cache
|
||||
compile
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
@@ -17,4 +22,8 @@ install-sh
|
||||
missing
|
||||
src/*.o
|
||||
src/fping
|
||||
src/fping6
|
||||
stamp-h1
|
||||
doc/fping.8
|
||||
doc/fping6.8
|
||||
ci/build
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
# travis-ci.org configuration
|
||||
language: c
|
||||
env:
|
||||
global:
|
||||
- secure: "CoI8hwHH1yfQoQxIfWGRS0WfTyScox+5aJn0fDDgz2uKrrIxmBvIw/WKX8wcSiV6fLmLuwgNkKqSM3hdO4qaG+JxfWcuEiZZHm+kxSGMkWbGb/fvAI+gHg8ldKyYttcIX71O5rlZiC2QpNKQi2v18S6pI5p8eqnx7DYx4YrmguQ="
|
||||
compiler:
|
||||
- gcc
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
before_install:
|
||||
- sudo apt-get install libcap2-bin
|
||||
install:
|
||||
- ci/build-1-autotools.sh
|
||||
- curl -L http://cpanmin.us | perl - --sudo App::cpanminus
|
||||
- cpanm --sudo Test::Command
|
||||
script:
|
||||
- ci/build-2-install.sh
|
||||
- env PATH=`pwd`/src:$PATH prove ci/test-*.pl
|
||||
- ci/test-tarball.sh
|
||||
after_success:
|
||||
- ci/coveralls.sh
|
||||
- ci/deploy-bintray.sh
|
||||
@@ -1,5 +1,9 @@
|
||||
|
||||
/*
|
||||
* Original author: Roland Schemers <schemers@stanford.edu>
|
||||
* IPv6 Support: Jeroen Massar <jeroen@unfix.org / jeroen@ipng.nl>
|
||||
* Improved main loop: David Schweikert <david@schweikert.ch>
|
||||
* Debian Merge, TOS settings: Tobi Oetiker <tobi@oetiker.ch>
|
||||
* Bugfixes, byte order & senseful seq.-numbers: Stephan Fuhrmann (stephan.fuhrmann AT 1und1.de)
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
@@ -11,5 +15,3 @@
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,68 @@
|
||||
2012-05-22 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.2rc1
|
||||
2014-03-08 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.9
|
||||
* Fix random output on socket error (reported by Aleksandrs Saveljevs, #56)
|
||||
* Support ppc64le architecture by including alpha libtool version
|
||||
(reported by Amit Kumar Gupta and Aravinda B Thunug)
|
||||
* Fix compilation problem on FreeBSD (#57)
|
||||
* Initial test suite and continous intergration (with travis-ci.org / coveralls.io)
|
||||
* Don't output usage information on error
|
||||
|
||||
2013-11-08 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.8
|
||||
* Fix segmentation fault introduced in version 3.7 with loop mode (reported
|
||||
by Vlad Glagolev, #55)
|
||||
|
||||
2013-11-04 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.7
|
||||
* Allow running as non-root on Mac OS X by using non-privileged ICMP (#7)
|
||||
* Remove unnecessary IPv6 socket options
|
||||
* Fix again compatibility issue with FreeBSD (Shawn Chu)
|
||||
* Fix fping hanging forever on permanent sendto failure (Shawn Chu)
|
||||
* Fix duplicate echo reply packets causing early stop in count mode
|
||||
(reported by Ramon Schwammberger, #53)
|
||||
|
||||
2013-10-10 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.6
|
||||
* Fix loop issue after 65536 pings (reported by Peter Folk and GBert, #12)
|
||||
* Minimum ping data size is now 0
|
||||
* Removed setsockopt IPV6_CHECKSUM, which shouldn't be set and breaks
|
||||
compiling on Solaris (reported by Juergen Arndt)
|
||||
* Fix wrong min RTT value with -Q option (reported by Alexander Ivanov, #51)
|
||||
|
||||
2013-05-22 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.5
|
||||
* Fix sprint_tm buffer size crash (reported by Japheth Cleaver)
|
||||
* Addded -D flag to print timestamps (Toke Høiland-Jørgensen)
|
||||
* Fix fping6 build on OS X 10.8 (unknown contributor)
|
||||
* Fix compatibility issue with FreeBSD (Alexandre Raynaud, Jason Harris, #39)
|
||||
* Fping.spec: fix setuid permissions and provides fping6 (Marcus Vinicius Ferreira)
|
||||
* Re-create configure script with autoconf 2.69 for aarch64 support (Chuck Anderson, #45)
|
||||
|
||||
2012-09-04 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.4
|
||||
* Revert "Output statistics to stdout instead of stderr", because it breaks
|
||||
tools assuming the output goes to stderr
|
||||
|
||||
2012-08-19 David Schweikert <david@schweikert.ch>
|
||||
* Version 3.3
|
||||
* 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
|
||||
* Fix error message on DNS error for IPv6 hosts (#27)
|
||||
* Fix -n flag in fping6 (#28)
|
||||
* 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,11 @@ Current maintainer:
|
||||
David Schweikert <david@schweikert.ch>
|
||||
|
||||
Website:
|
||||
http://www.fping.org
|
||||
http://fping.org/
|
||||
|
||||
Mailing-list:
|
||||
https://groups.google.com/group/fping-users
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
@@ -24,12 +28,25 @@ 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,7 @@ rm -f mkinstalldirs
|
||||
rm -f stamp-h1
|
||||
rm -f doc/Makefile.in
|
||||
rm -f src/Makefile.in
|
||||
rm -f doc/fping.8
|
||||
rm -f src/*.gcda
|
||||
rm -f src/*.gcno
|
||||
rm -f src/*.gcov
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
AUTOCONF=http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
|
||||
AUTOMAKE=http://ftp.gnu.org/gnu/automake/automake-1.14.1.tar.gz
|
||||
LIBTOOL=http://alpha.gnu.org/gnu/libtool/libtool-2.4.2.418.tar.gz
|
||||
PREFIX=$(pwd)/ci/build
|
||||
PATH=$(pwd)/ci/build/bin:$PATH
|
||||
|
||||
if [ ! -d ci ]; then
|
||||
echo "you must run this in the root fping directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# remove standard versions
|
||||
sudo apt-get remove -qq autoconf automake autotools-dev libtool
|
||||
|
||||
# prepare build environment
|
||||
cd ci
|
||||
rm -rf build
|
||||
mkdir -p build/src
|
||||
cd build/src
|
||||
|
||||
# autoconf
|
||||
(
|
||||
AUTOCONF_FILE=$(basename $AUTOCONF)
|
||||
AUTOCONF_DIR=$(echo $AUTOCONF_FILE | sed -e 's/\.tar.*//')
|
||||
wget $AUTOCONF
|
||||
tar xf $AUTOCONF_FILE
|
||||
cd $AUTOCONF_DIR
|
||||
./configure --prefix=$PREFIX
|
||||
make install
|
||||
)
|
||||
|
||||
# automake
|
||||
(
|
||||
AUTOMAKE_FILE=$(basename $AUTOMAKE)
|
||||
AUTOMAKE_DIR=$(echo $AUTOMAKE_FILE | sed -e 's/\.tar.*//')
|
||||
wget $AUTOMAKE
|
||||
tar xf $AUTOMAKE_FILE
|
||||
cd $AUTOMAKE_DIR
|
||||
./configure --prefix=$PREFIX
|
||||
make install
|
||||
)
|
||||
|
||||
# libtool
|
||||
(
|
||||
LIBTOOL_FILE=$(basename $LIBTOOL)
|
||||
LIBTOOL_DIR=$(echo $LIBTOOL_FILE | sed -e 's/\.tar.*//')
|
||||
wget $LIBTOOL
|
||||
tar xf $LIBTOOL_FILE
|
||||
cd $LIBTOOL_DIR
|
||||
./configure --prefix=$PREFIX
|
||||
make install
|
||||
)
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
PATH=$(pwd)/ci/build/bin:$PATH
|
||||
|
||||
if [ ! -d ci ]; then
|
||||
echo "you must run this in the root fping directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
autoreconf -i
|
||||
./configure --enable-ipv4 --enable-ipv6 --prefix=/opt/fping
|
||||
make CFLAGS="-g -fprofile-arcs -ftest-coverage"
|
||||
sudo setcap cap_net_raw+ep src/fping
|
||||
sudo setcap cap_net_raw+ep src/fping6
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
sudo pip install cpp-coveralls --use-mirrors
|
||||
|
||||
cd src
|
||||
|
||||
ls -l
|
||||
|
||||
gcov *.o
|
||||
cd ..
|
||||
coveralls --exclude ci --no-gcov
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
# upload to bintray.com/schweikert
|
||||
|
||||
set -e
|
||||
|
||||
# do this only for the gcc run
|
||||
if [ "$CC" != "gcc" ]; then
|
||||
echo "skipped upload because $CC != gcc"
|
||||
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
|
||||
else
|
||||
REPO=beta
|
||||
fi
|
||||
curl -T fping-$VERSION.tar.gz -uschweikert:$BINTRAY_API_KEY https://api.bintray.com/content/schweikert/$REPO/fping/$VERSION/fping-$VERSION.tar.gz
|
||||
echo
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use Test::Command tests => 9;
|
||||
|
||||
# ping 127.0.0.1
|
||||
my $cmd1 = Test::Command->new(cmd => "fping 127.0.0.1");
|
||||
$cmd1->exit_is_num(0);
|
||||
$cmd1->stdout_is_eq("127.0.0.1 is alive\n");
|
||||
$cmd1->stderr_is_eq("");
|
||||
|
||||
# ping ::1
|
||||
my $cmd2 = Test::Command->new(cmd => "fping6 ::1");
|
||||
$cmd2->exit_is_num(0);
|
||||
$cmd2->stdout_is_eq("::1 is alive\n");
|
||||
$cmd2->stderr_is_eq("");
|
||||
|
||||
# ping 3 times 127.0.0.1
|
||||
my $cmd3 = Test::Command->new(cmd => "fping -p 100 -C3 127.0.0.1");
|
||||
$cmd3->exit_is_num(0);
|
||||
$cmd3->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\)
|
||||
127\.0\.0\.1 : \[2\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
|
||||
});
|
||||
$cmd3->stderr_like(qr{127\.0\.0\.1 : 0\.\d+ 0\.\d+ 0\.\d+\n});
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use Test::Command tests => 9;
|
||||
|
||||
# fping -h
|
||||
my $cmd1 = Test::Command->new(cmd => "fping -h");
|
||||
$cmd1->exit_is_num(0);
|
||||
$cmd1->stdout_is_eq(<<END);
|
||||
|
||||
Usage: fping [options] [targets...]
|
||||
-a show targets that are alive
|
||||
-A show targets by address
|
||||
-b n amount of ping data to send, in bytes (default 56)
|
||||
-B f set exponential backoff factor to f
|
||||
-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
|
||||
-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. 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)
|
||||
-l loop sending pings forever
|
||||
-m ping multiple interfaces on target host
|
||||
-n show targets by name (-d is equivalent)
|
||||
-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)
|
||||
|
||||
END
|
||||
$cmd1->stderr_is_eq("");
|
||||
|
||||
# fping -v
|
||||
my $cmd2 = Test::Command->new(cmd => "fping -v");
|
||||
$cmd2->exit_is_num(0);
|
||||
$cmd2->stdout_like(qr{fping: Version \S+
|
||||
fping: comments to david\@schweikert\.ch\n});
|
||||
$cmd2->stderr_is_eq("");
|
||||
|
||||
# fping with unknown option
|
||||
my $cmd3 = Test::Command->new(cmd => "fping -Z");
|
||||
$cmd3->exit_is_num(1);
|
||||
$cmd3->stdout_is_eq("");
|
||||
$cmd3->stderr_is_eq("fping: invalid option -- 'Z'
|
||||
see 'fping -h' for usage information\n");
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use Test::Command tests => 33;
|
||||
|
||||
# fping -i 9
|
||||
my $cmd1 = Test::Command->new(cmd => "fping -i 9 -T10 -g 127.0.0.1/29");
|
||||
$cmd1->exit_is_num(1);
|
||||
$cmd1->stdout_is_eq("");
|
||||
$cmd1->stderr_is_eq(<<END);
|
||||
fping: these options are too risky for mere mortals.
|
||||
fping: You need i >= 10, p >= 20, r < 20, and t >= 50
|
||||
END
|
||||
|
||||
# fping -p 15
|
||||
my $cmd2 = Test::Command->new(cmd => "fping -c3 -p 15 127.0.0.1");
|
||||
$cmd2->exit_is_num(1);
|
||||
$cmd2->stdout_is_eq("");
|
||||
$cmd2->stderr_is_eq(<<END);
|
||||
fping: these options are too risky for mere mortals.
|
||||
fping: You need i >= 10, p >= 20, r < 20, and t >= 50
|
||||
END
|
||||
|
||||
# fping -r 30
|
||||
my $cmd3 = Test::Command->new(cmd => "fping -r 30 127.0.0.1");
|
||||
$cmd3->exit_is_num(1);
|
||||
$cmd3->stdout_is_eq("");
|
||||
$cmd3->stderr_is_eq(<<END);
|
||||
fping: these options are too risky for mere mortals.
|
||||
fping: You need i >= 10, p >= 20, r < 20, and t >= 50
|
||||
END
|
||||
|
||||
# fping -t 40
|
||||
my $cmd4 = Test::Command->new(cmd => "fping -t 40 127.0.0.1");
|
||||
$cmd4->exit_is_num(1);
|
||||
$cmd4->stdout_is_eq("");
|
||||
$cmd4->stderr_is_eq(<<END);
|
||||
fping: these options are too risky for mere mortals.
|
||||
fping: You need i >= 10, p >= 20, r < 20, and t >= 50
|
||||
END
|
||||
|
||||
# fping -H 300
|
||||
my $cmd5 = Test::Command->new(cmd => "fping -H 300 127.0.0.1");
|
||||
$cmd5->exit_is_num(1);
|
||||
$cmd5->stdout_is_eq("");
|
||||
$cmd5->stderr_is_eq("ttl 300 out of range\n");
|
||||
|
||||
# fping -a -u
|
||||
my $cmd6 = Test::Command->new(cmd => "fping -a -u 127.0.0.1");
|
||||
$cmd6->exit_is_num(1);
|
||||
$cmd6->stdout_is_eq("");
|
||||
$cmd6->stderr_is_eq("fping: specify only one of a, u\n");
|
||||
|
||||
# fping -c -l
|
||||
my $cmd7 = Test::Command->new(cmd => "fping -c3 -l 127.0.0.1");
|
||||
$cmd7->exit_is_num(1);
|
||||
$cmd7->stdout_is_eq("");
|
||||
$cmd7->stderr_is_eq("fping: specify only one of c, l\n");
|
||||
|
||||
# fping -b 65509
|
||||
my $cmd8 = Test::Command->new(cmd => "fping -b 65509 127.0.0.1");
|
||||
$cmd8->exit_is_num(1);
|
||||
$cmd8->stdout_is_eq("");
|
||||
$cmd8->stderr_is_eq("fping: data size 65509 not valid, must be between 0 and 65508\n");
|
||||
|
||||
# fping -B 0.9
|
||||
my $cmd9 = Test::Command->new(cmd => "fping -B 0.9 127.0.0.1");
|
||||
$cmd9->exit_is_num(1);
|
||||
$cmd9->stdout_is_eq("");
|
||||
$cmd9->stderr_is_eq("fping: backoff factor 0.9 not valid, must be between 1.0 and 5.0\n");
|
||||
|
||||
# fping -B 0.9
|
||||
my $cmd10 = Test::Command->new(cmd => "fping -B 5.1 127.0.0.1");
|
||||
$cmd10->exit_is_num(1);
|
||||
$cmd10->stdout_is_eq("");
|
||||
$cmd10->stderr_is_eq("fping: backoff factor 5.1 not valid, must be between 1.0 and 5.0\n");
|
||||
|
||||
# fping -C 11000
|
||||
my $cmd11 = Test::Command->new(cmd => "fping -C 11000 127.0.0.1");
|
||||
$cmd11->exit_is_num(1);
|
||||
$cmd11->stdout_is_eq("");
|
||||
$cmd11->stderr_is_eq("fping: count 11000 not valid, must be less than 10000\n");
|
||||
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use Test::Command tests => 14;
|
||||
use Test::More;
|
||||
use Time::HiRes qw(gettimeofday tv_interval);
|
||||
|
||||
# -a show targets that are alive
|
||||
# -A show targets by address
|
||||
# -b n amount of ping data to send, in bytes (default 56)
|
||||
# -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("");
|
||||
|
||||
# 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("");
|
||||
|
||||
# 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("");
|
||||
|
||||
# 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 $elapsed = tv_interval($t0);
|
||||
# 0.1 + 0.2 + 0.4 + 0.8 = 1.5
|
||||
cmp_ok($elapsed, '>=', 1.5);
|
||||
cmp_ok($elapsed, '<', 1.7);
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# regression testing for github issue #56
|
||||
|
||||
use Test::Command tests => 3;
|
||||
|
||||
my $cmd1 = Test::Command->new(cmd => "fping -t100 -p100 -C3 255.255.255.255");
|
||||
$cmd1->exit_is_num(1);
|
||||
$cmd1->stdout_is_eq("");
|
||||
$cmd1->stderr_is_eq("\n255.255.255.255 : - - -\n");
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# make sure that the .tar.gz file contains everything necessary
|
||||
# to build fping
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
make dist
|
||||
VERSION=$(ls fping-*.tar.gz | sed -e 's/^fping-//' | sed -e 's/\.tar\.gz$//')
|
||||
if [ -z "$VERSION" ]; then
|
||||
echo "tar.gz file not found." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# unarchive
|
||||
TMPDIR=$(mktemp -d --tmpdir=ci)
|
||||
cd $TMPDIR
|
||||
tar xf ../../fping-$VERSION.tar.gz
|
||||
DIRNAME=$(ls)
|
||||
|
||||
# build
|
||||
cd $DIRNAME
|
||||
./configure --enable-ipv4 --enable-ipv6 --prefix=/opt/fping
|
||||
make
|
||||
sudo make install
|
||||
+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.9])
|
||||
|
||||
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,73 @@
|
||||
Summary: send ICMP echo probes to multiple hosts
|
||||
Name: fping
|
||||
Version: 3.4
|
||||
Release: 1
|
||||
License: MIT
|
||||
Group: Applications/System
|
||||
Source0: http://fping.org/dist/%{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
|
||||
|
||||
if [ ! -f ./configure ] ; then
|
||||
./autogen.sh
|
||||
fi
|
||||
|
||||
# fping
|
||||
%configure --enable-ipv4
|
||||
make
|
||||
|
||||
# fping6
|
||||
%configure --enable-ipv6
|
||||
make
|
||||
%{__mv} -f src/fping src/fping6
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
|
||||
# fping6
|
||||
%{__install} -Dp -m4755 src/fping6 %{buildroot}%{_sbindir}/fping6
|
||||
%{__ln_s} -f fping.8 %{buildroot}%{_mandir}/man8/fping6.8
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%attr(4755, root, root) /usr/sbin/fping
|
||||
%attr(4755, root, root) /usr/sbin/fping6
|
||||
%doc README COPYING ChangeLog
|
||||
/usr/share/man/man8/fping.8.gz
|
||||
/usr/share/man/man8/fping6.8.gz
|
||||
|
||||
%post
|
||||
if [ -x /usr/sbin/setcap ]; then
|
||||
/bin/chmod 0755 /usr/sbin/fping*
|
||||
/usr/sbin/setcap cap_net_raw+ep /usr/sbin/fping*
|
||||
fi
|
||||
|
||||
%changelog
|
||||
* Mon Dec 24 2012 Marcus Vinicius Ferreira <ferreira.mv@gmail.com>
|
||||
- Missing './configure' script when cloning from master.
|
||||
- Making 'fping6'.
|
||||
- Fix setuid permission to 'rwsr-xr-x'.
|
||||
- doc files.
|
||||
- Replacing setuid permission if 'setcap' is present on post-install.
|
||||
- Using 'http://fping.org/dist/' for release source distributions.
|
||||
|
||||
* Mon Jul 16 2012 Stephen Schaefer <sschaefer@acm.org>
|
||||
- Initial build
|
||||
|
||||
# vim:ft=spec:
|
||||
|
||||
+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 = fping.8 fping6.8 fping.pod README.1992
|
||||
|
||||
fping.8: fping.pod
|
||||
pod2man -c "" -s 8 -r "fping" $< >$@
|
||||
|
||||
fping6.8: fping.pod
|
||||
pod2man -c "" -s 8 -r "fping" -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)
|
||||
+248
@@ -0,0 +1,248 @@
|
||||
=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<-D>
|
||||
|
||||
Add Unix timestamps in front of output lines generated with in looping or counting
|
||||
modes (B<-l>, B<-c>, or B<-C>).
|
||||
|
||||
=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)>
|
||||
+15
-2
@@ -1,3 +1,16 @@
|
||||
sbin_PROGRAMS = fping
|
||||
fping_SOURCES = fping.c options.h
|
||||
prog =
|
||||
|
||||
if IPV4
|
||||
prog += fping
|
||||
endif
|
||||
if IPV6
|
||||
prog += fping6
|
||||
endif
|
||||
|
||||
sbin_PROGRAMS = ${prog}
|
||||
|
||||
fping_SOURCES = fping.c seqmap.c socket.c socket4.c fping.h options.h seqmap.h
|
||||
fping_DEPENDENCIES = ../config.h
|
||||
fping6_SOURCES = fping.c seqmap.c socket.c socket6.c fping.h options.h seqmap.h
|
||||
fping6_DEPENDENCIES = ../config.h
|
||||
fping6_CFLAGS = $(AM_CFLAGS) -DIPV6
|
||||
|
||||
+260
-378
File diff suppressed because it is too large
Load Diff
+28
@@ -0,0 +1,28 @@
|
||||
#ifndef _FPING_H
|
||||
#define _FPING_H
|
||||
|
||||
#define __APPLE_USE_RFC_3542 1
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifndef IPV6
|
||||
#define FPING_SOCKADDR struct sockaddr_in
|
||||
#define FPING_INADDR struct in_addr
|
||||
#define FPING_ICMPHDR struct icmp
|
||||
#else
|
||||
#define FPING_SOCKADDR struct sockaddr_in6
|
||||
#define FPING_INADDR struct in6_addr
|
||||
#define FPING_ICMPHDR struct icmp6_hdr
|
||||
#endif
|
||||
|
||||
/* fping.c */
|
||||
void crash_and_burn( char *message );
|
||||
void errno_crash_and_burn( char *message );
|
||||
|
||||
/* socket.c */
|
||||
int open_ping_socket();
|
||||
void socket_set_src_addr(int s, FPING_INADDR src_addr);
|
||||
|
||||
#endif
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* fping: fast-ping, file-ping, favorite-ping, funky-ping
|
||||
*
|
||||
* Ping a list of target hosts in a round robin fashion.
|
||||
* A better ping overall.
|
||||
*
|
||||
* fping website: http://www.fping.org
|
||||
*
|
||||
* Current maintainer of fping: David Schweikert
|
||||
* Please send suggestions and patches to: david@schweikert.ch
|
||||
*
|
||||
*
|
||||
* Original author: Roland Schemers <schemers@stanford.edu>
|
||||
* IPv6 Support: Jeroen Massar <jeroen@unfix.org / jeroen@ipng.nl>
|
||||
* Improved main loop: David Schweikert <david@schweikert.ch>
|
||||
* Debian Merge, TOS settings: Tobi Oetiker <tobi@oetiker.ch>
|
||||
* Bugfixes, byte order & senseful seq.-numbers: Stephan Fuhrmann (stephan.fuhrmann AT 1und1.de)
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by Stanford University. The name of the University may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* seqmap.c: implementation of a mapping between sequence number and (host, ping_nr)
|
||||
* we can't just use ping_nr*host_count + host_nr, because it can
|
||||
* overflow the 16 bit of the icmp header field. See also:
|
||||
* https://github.com/schweikert/fping/issues/48
|
||||
*/
|
||||
|
||||
#include "seqmap.h"
|
||||
#include "options.h"
|
||||
#include "limits.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* description of the data structure used:
|
||||
*
|
||||
* - we assume that no more than SEQMAP_MAXSEQ (65535) pings are sent in
|
||||
* the timeout interval (SEQMAP_TIMEOUT_IN_S)
|
||||
* - we store the values in an array with SEQMAP_MAXSEQ elements
|
||||
* - current sequence number % SEQMAP_MAXSEQ gives the current index
|
||||
* - when entering a value, we check that the current entry is expired
|
||||
*/
|
||||
|
||||
static SEQMAP_VALUE *seqmap_map = NULL;
|
||||
static unsigned int seqmap_next_id = 0;
|
||||
static SEQMAP_VALUE *seqmap_free_list;
|
||||
|
||||
#define SEQMAP_TIMEOUT_IN_S 10
|
||||
#define SEQMAP_UNASSIGNED_HOST_NR UINT_MAX
|
||||
|
||||
void seqmap_init()
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
seqmap_map = calloc(SEQMAP_MAXSEQ, sizeof(SEQMAP_VALUE));
|
||||
if(seqmap_map == NULL) {
|
||||
perror("malloc error (can't allocate seqmap_map)");
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int seqmap_add(unsigned int host_nr, unsigned int ping_count, struct timeval *now)
|
||||
{
|
||||
unsigned int current_id;
|
||||
SEQMAP_VALUE *next_value;
|
||||
|
||||
if(!seqmap_map) {
|
||||
fprintf(stderr, "fping internal error: seqmap not initialized.\n");
|
||||
exit(4);
|
||||
}
|
||||
|
||||
/* check if expired (note that unused seqmap values will have fields set to
|
||||
* 0, so will be seen as expired */
|
||||
next_value = &seqmap_map[seqmap_next_id];
|
||||
if(next_value->ping_ts.tv_sec != 0 && (now->tv_sec - next_value->ping_ts.tv_sec) < SEQMAP_TIMEOUT_IN_S) {
|
||||
fprintf(stderr, "fping error: not enough sequence numbers available! (expire_timeout=%d, host_nr=%d, ping_count=%d, seqmap_next_id=%d)\n",
|
||||
SEQMAP_TIMEOUT_IN_S, host_nr, ping_count, seqmap_next_id);
|
||||
exit(4);
|
||||
}
|
||||
|
||||
/* store the value */
|
||||
next_value->host_nr = host_nr;
|
||||
next_value->ping_count = ping_count;
|
||||
next_value->ping_ts.tv_sec = now->tv_sec;
|
||||
next_value->ping_ts.tv_usec = now->tv_usec;
|
||||
|
||||
/* increase next id */
|
||||
current_id = seqmap_next_id;
|
||||
seqmap_next_id = (seqmap_next_id + 1) % SEQMAP_MAXSEQ;
|
||||
|
||||
return current_id;
|
||||
}
|
||||
|
||||
SEQMAP_VALUE *seqmap_fetch(unsigned int id, struct timeval *now)
|
||||
{
|
||||
SEQMAP_VALUE *value;
|
||||
|
||||
if(id > SEQMAP_MAXSEQ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
value = &seqmap_map[id];
|
||||
|
||||
/* verify that value is not expired */
|
||||
if(now->tv_sec - value->ping_ts.tv_sec >= SEQMAP_TIMEOUT_IN_S) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef SEQMAP_H
|
||||
#define SEQMAP_H
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
typedef struct seqmap_value
|
||||
{
|
||||
unsigned int host_nr;
|
||||
unsigned int ping_count;
|
||||
struct timeval ping_ts;
|
||||
|
||||
} SEQMAP_VALUE;
|
||||
|
||||
#define SEQMAP_MAXSEQ 65535
|
||||
|
||||
void seqmap_init();
|
||||
unsigned int seqmap_add(unsigned int host_nr, unsigned int ping_count, struct timeval *now);
|
||||
SEQMAP_VALUE *seqmap_fetch(unsigned int id, struct timeval *now);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* fping: fast-ping, file-ping, favorite-ping, funky-ping
|
||||
*
|
||||
* Ping a list of target hosts in a round robin fashion.
|
||||
* A better ping overall.
|
||||
*
|
||||
* fping website: http://www.fping.org
|
||||
*
|
||||
* Current maintainer of fping: David Schweikert
|
||||
* Please send suggestions and patches to: david@schweikert.ch
|
||||
*
|
||||
*
|
||||
* Original author: Roland Schemers <schemers@stanford.edu>
|
||||
* IPv6 Support: Jeroen Massar <jeroen@unfix.org / jeroen@ipng.nl>
|
||||
* Improved main loop: David Schweikert <david@schweikert.ch>
|
||||
* Debian Merge, TOS settings: Tobi Oetiker <tobi@oetiker.ch>
|
||||
* Bugfixes, byte order & senseful seq.-numbers: Stephan Fuhrmann (stephan.fuhrmann AT 1und1.de)
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by Stanford University. The name of the University may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include "fping.h"
|
||||
#include "config.h"
|
||||
|
||||
int open_ping_socket_ipv4();
|
||||
int open_ping_socket_ipv6();
|
||||
void socket_set_src_addr_ipv4(int s, FPING_INADDR src_addr);
|
||||
void socket_set_src_addr_ipv6(int s, FPING_INADDR src_addr);
|
||||
|
||||
int open_ping_socket()
|
||||
{
|
||||
#ifndef IPV6
|
||||
return open_ping_socket_ipv4();
|
||||
#else
|
||||
return open_ping_socket_ipv6();
|
||||
#endif
|
||||
}
|
||||
|
||||
void socket_set_src_addr(int s, FPING_INADDR src_addr)
|
||||
{
|
||||
#ifndef IPV6
|
||||
socket_set_src_addr_ipv4(s, src_addr);
|
||||
#else
|
||||
socket_set_src_addr_ipv6(s, src_addr);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* fping: fast-ping, file-ping, favorite-ping, funky-ping
|
||||
*
|
||||
* Ping a list of target hosts in a round robin fashion.
|
||||
* A better ping overall.
|
||||
*
|
||||
* fping website: http://www.fping.org
|
||||
*
|
||||
* Current maintainer of fping: David Schweikert
|
||||
* Please send suggestions and patches to: david@schweikert.ch
|
||||
*
|
||||
*
|
||||
* Original author: Roland Schemers <schemers@stanford.edu>
|
||||
* IPv6 Support: Jeroen Massar <jeroen@unfix.org / jeroen@ipng.nl>
|
||||
* Improved main loop: David Schweikert <david@schweikert.ch>
|
||||
* Debian Merge, TOS settings: Tobi Oetiker <tobi@oetiker.ch>
|
||||
* Bugfixes, byte order & senseful seq.-numbers: Stephan Fuhrmann (stephan.fuhrmann AT 1und1.de)
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by Stanford University. The name of the University may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include "fping.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int open_ping_socket_ipv4()
|
||||
{
|
||||
struct protoent *proto;
|
||||
int s;
|
||||
|
||||
/* confirm that ICMP is available on this machine */
|
||||
if( ( proto = getprotobyname( "icmp" ) ) == NULL )
|
||||
crash_and_burn( "icmp: unknown protocol" );
|
||||
|
||||
/* create raw socket for ICMP calls (ping) */
|
||||
s = socket( AF_INET, SOCK_RAW, proto->p_proto );
|
||||
if( s < 0 ) {
|
||||
/* try non-privileged icmp (works on Mac OSX without privileges, for example) */
|
||||
s = socket( AF_INET, SOCK_DGRAM, proto->p_proto );
|
||||
if( s < 0 ) {
|
||||
errno_crash_and_burn( "can't create socket (must run as root?)" );
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void socket_set_src_addr_ipv4(int s, FPING_INADDR src_addr)
|
||||
{
|
||||
struct sockaddr_in sa;
|
||||
memset( &sa, 0, sizeof( sa ) );
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_addr = src_addr;
|
||||
|
||||
if ( bind( s, (struct sockaddr *)&sa, sizeof( sa ) ) < 0 )
|
||||
errno_crash_and_burn( "cannot bind source address" );
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* fping: fast-ping, file-ping, favorite-ping, funky-ping
|
||||
*
|
||||
* Ping a list of target hosts in a round robin fashion.
|
||||
* A better ping overall.
|
||||
*
|
||||
* fping website: http://www.fping.org
|
||||
*
|
||||
* Current maintainer of fping: David Schweikert
|
||||
* Please send suggestions and patches to: david@schweikert.ch
|
||||
*
|
||||
*
|
||||
* Original author: Roland Schemers <schemers@stanford.edu>
|
||||
* IPv6 Support: Jeroen Massar <jeroen@unfix.org / jeroen@ipng.nl>
|
||||
* Improved main loop: David Schweikert <david@schweikert.ch>
|
||||
* Debian Merge, TOS settings: Tobi Oetiker <tobi@oetiker.ch>
|
||||
* Bugfixes, byte order & senseful seq.-numbers: Stephan Fuhrmann (stephan.fuhrmann AT 1und1.de)
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms are permitted
|
||||
* provided that the above copyright notice and this paragraph are
|
||||
* duplicated in all such forms and that any documentation,
|
||||
* advertising materials, and other materials related to such
|
||||
* distribution and use acknowledge that the software was developed
|
||||
* by Stanford University. The name of the University may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include "fping.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <netinet/icmp6.h>
|
||||
|
||||
int open_ping_socket_ipv6()
|
||||
{
|
||||
struct protoent *proto;
|
||||
int opton = 1;
|
||||
int s;
|
||||
|
||||
/* confirm that ICMP is available on this machine */
|
||||
if( ( proto = getprotobyname( "ipv6-icmp" ) ) == NULL )
|
||||
crash_and_burn( "icmp: unknown protocol" );
|
||||
|
||||
/* create raw socket for ICMP calls (ping) */
|
||||
s = socket( AF_INET6, SOCK_RAW, proto->p_proto );
|
||||
if( s < 0 ) {
|
||||
/* try non-privileged icmp (works on Mac OSX without privileges, for example) */
|
||||
s = socket( AF_INET6, SOCK_DGRAM, proto->p_proto );
|
||||
if( s < 0 ) {
|
||||
errno_crash_and_burn( "can't create raw socket (must run as root?)" );
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void socket_set_src_addr_ipv6(int s, FPING_INADDR src_addr)
|
||||
{
|
||||
struct sockaddr_in6 sa;
|
||||
memset( &sa, 0, sizeof( sa ) );
|
||||
sa.sin6_family = AF_INET6;
|
||||
sa.sin6_addr = src_addr;
|
||||
|
||||
if ( bind( s, (struct sockaddr *)&sa, sizeof( sa ) ) < 0 )
|
||||
errno_crash_and_burn( "cannot bind source address" );
|
||||
}
|
||||
Reference in New Issue
Block a user