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 |
@@ -1,11 +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
|
||||
@@ -22,3 +26,4 @@ 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,3 +1,12 @@
|
||||
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
|
||||
|
||||
@@ -19,3 +19,6 @@ 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
|
||||
+1
-1
@@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
|
||||
dnl Minimum Autoconf version required.
|
||||
AC_PREREQ(2.59)
|
||||
|
||||
AC_INIT([fping],[3.7])
|
||||
AC_INIT([fping],[3.9])
|
||||
|
||||
dnl make ipv4 and ipv6 options
|
||||
AC_ARG_ENABLE([ipv4],
|
||||
|
||||
+32
-34
@@ -136,6 +136,7 @@ extern int h_errno;
|
||||
/* response time array flags */
|
||||
#define RESP_WAITING -1
|
||||
#define RESP_UNUSED -2
|
||||
#define RESP_ERROR -3
|
||||
|
||||
/* debugging flags */
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
@@ -367,7 +368,7 @@ int main( int argc, char **argv )
|
||||
|
||||
s = open_ping_socket();
|
||||
|
||||
if(uid = getuid()) {
|
||||
if((uid = getuid())) {
|
||||
seteuid( getuid() );
|
||||
}
|
||||
|
||||
@@ -569,7 +570,8 @@ int main( int argc, char **argv )
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage(1);
|
||||
fprintf(stderr, "see 'fping -h' for usage information\n");
|
||||
exit(1);
|
||||
break;
|
||||
|
||||
}/* SWITCH */
|
||||
@@ -578,21 +580,21 @@ int main( int argc, char **argv )
|
||||
/* validate various option settings */
|
||||
|
||||
if (ttl > 255) {
|
||||
fprintf(stderr, "ping: ttl %u out of range\n", ttl);
|
||||
usage(1);
|
||||
fprintf(stderr, "ttl %u out of range\n", ttl);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if( unreachable_flag && alive_flag )
|
||||
{
|
||||
fprintf( stderr, "%s: specify only one of a, u\n", argv[0] );
|
||||
usage(1);
|
||||
exit(1);
|
||||
|
||||
}/* IF */
|
||||
|
||||
if( count_flag && loop_flag )
|
||||
{
|
||||
fprintf( stderr, "%s: specify only one of c, l\n", argv[0] );
|
||||
usage(1);
|
||||
exit(1);
|
||||
|
||||
}/* IF */
|
||||
|
||||
@@ -605,15 +607,14 @@ int main( int argc, char **argv )
|
||||
fprintf( stderr, "%s: these options are too risky for mere mortals.\n", prog );
|
||||
fprintf( stderr, "%s: You need i >= %u, p >= %u, r < %u, and t >= %u\n",
|
||||
prog, MIN_INTERVAL, MIN_PERHOST_INTERVAL, MAX_RETRY, MIN_TIMEOUT );
|
||||
usage(1);
|
||||
|
||||
exit(1);
|
||||
}/* IF */
|
||||
|
||||
if( ( ping_data_size > MAX_PING_DATA ) || ( ping_data_size < MIN_PING_DATA ) )
|
||||
{
|
||||
fprintf( stderr, "%s: data size %u not valid, must be between %u and %u\n",
|
||||
prog, ping_data_size, (unsigned int) MIN_PING_DATA, (unsigned int) MAX_PING_DATA );
|
||||
usage(1);
|
||||
exit(1);
|
||||
|
||||
}/* IF */
|
||||
|
||||
@@ -621,7 +622,7 @@ int main( int argc, char **argv )
|
||||
{
|
||||
fprintf( stderr, "%s: backoff factor %.1f not valid, must be between %.1f and %.1f\n",
|
||||
prog, backoff, MIN_BACKOFF_FACTOR, MAX_BACKOFF_FACTOR );
|
||||
usage(1);
|
||||
exit(1);
|
||||
|
||||
}/* IF */
|
||||
|
||||
@@ -629,7 +630,7 @@ int main( int argc, char **argv )
|
||||
{
|
||||
fprintf( stderr, "%s: count %u not valid, must be less than %u\n",
|
||||
prog, count, MAX_COUNT );
|
||||
usage(1);
|
||||
exit(1);
|
||||
|
||||
}/* IF */
|
||||
|
||||
@@ -991,7 +992,7 @@ void main_loop()
|
||||
|
||||
/* Send the ping */
|
||||
/*printf("Sending ping after %d ms\n", lt/100); */
|
||||
if(!send_ping(s, h)) goto wait_for_reply;
|
||||
send_ping(s, h);
|
||||
|
||||
/* Check what needs to be done next */
|
||||
if(!loop_flag && !count_flag) {
|
||||
@@ -1410,7 +1411,8 @@ int send_ping( int s, HOST_ENTRY *h )
|
||||
char *buffer;
|
||||
FPING_ICMPHDR *icp;
|
||||
int n;
|
||||
int myseq;
|
||||
int myseq;
|
||||
int ret = 1;
|
||||
|
||||
buffer = ( char* )malloc( ( size_t )ping_pkt_size );
|
||||
if( !buffer )
|
||||
@@ -1452,42 +1454,38 @@ int send_ping( int s, HOST_ENTRY *h )
|
||||
&& errno != EHOSTDOWN
|
||||
#endif
|
||||
) {
|
||||
if( verbose_flag || unreachable_flag )
|
||||
{
|
||||
if( verbose_flag || unreachable_flag ) {
|
||||
printf( "%s", h->host );
|
||||
if( verbose_flag )
|
||||
printf( " error while sending ping: %s\n", strerror( errno ) );
|
||||
|
||||
printf( "\n" );
|
||||
|
||||
}/* IF */
|
||||
}
|
||||
|
||||
h->num_sent++;
|
||||
h->num_sent_i++;
|
||||
h->waiting++;
|
||||
num_pingsent++;
|
||||
last_send_time = h->last_send_time;
|
||||
free( buffer );
|
||||
return(1);
|
||||
}
|
||||
if( !loop_flag )
|
||||
h->resp_times[h->num_sent] = RESP_ERROR;
|
||||
|
||||
/* mark this trial as outstanding */
|
||||
if( !loop_flag )
|
||||
h->resp_times[h->num_sent] = RESP_WAITING;
|
||||
ret = 0;
|
||||
}
|
||||
else {
|
||||
/* mark this trial as outstanding */
|
||||
if( !loop_flag )
|
||||
h->resp_times[h->num_sent] = RESP_WAITING;
|
||||
|
||||
#if defined( DEBUG ) || defined( _DEBUG )
|
||||
if( sent_times_flag )
|
||||
h->sent_times[h->num_sent] = timeval_diff( &h->last_send_time, &start_time );
|
||||
#endif /* DEBUG || _DEBUG */
|
||||
if( sent_times_flag )
|
||||
h->sent_times[h->num_sent] = timeval_diff( &h->last_send_time, &start_time );
|
||||
#endif
|
||||
}
|
||||
|
||||
h->num_sent++;
|
||||
h->num_sent_i++;
|
||||
h->waiting++;
|
||||
num_pingsent++;
|
||||
last_send_time = h->last_send_time;
|
||||
|
||||
free( buffer );
|
||||
return(1);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
@@ -1637,7 +1635,7 @@ int wait_for_reply(long wait_time)
|
||||
{
|
||||
if( ( this_count >= 0 ) && ( this_count < trials ) )
|
||||
{
|
||||
if( h->resp_times[this_count] != RESP_WAITING )
|
||||
if( h->resp_times[this_count] >= 0 )
|
||||
{
|
||||
if( !per_recv_flag )
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#define __APPLE_USE_RFC_3542 1
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifndef IPV6
|
||||
|
||||
Reference in New Issue
Block a user