First IPv6 version

Initial
Stephane Bortzmeyer 22 years ago
parent 1a192ee308
commit abcf574c26

@ -19,6 +19,9 @@ and porting.
Glen Turner <glen.turner@aarnet.edu.au> for the Type Of Service code.
An unknown KAME contributor for the adaptation to the new API, which
allows IPv6.
The Pasteur Institute because the work was done when working on the
French national Web cache project, while being an employee of the
Institute.

@ -1,3 +1,6 @@
* Now displays the standard deviation for repeated tests. Warning:
this may break some scripts which parse the output of echoping.
4.2.0 (2001-03-16)
* New -a and -A options to control the proxy/cache (disable caching).

@ -93,7 +93,7 @@ Use all of them with care, the result is not obvious to interpret.
And don't forget to read RFC 1470 ("Tools for Monitoring and Debugging
TCP/IP Internets and Interconnected Devices"), specially its
"Benchmark" section and the Richard Stevens' books (all of them),
"Benchmark" section and the W. Richard Stevens' books (all of them),
published by Addison-Wesley.

@ -43,6 +43,11 @@ moretest: $(MORE_TESTS)
echo "$$dashes"; \
test "$$failed" -eq 0
internal_test: internal_tests
internal_tests: internal_tests.o $(echoping_OBJECTS)
$(CC) $(LDFLAGS) -o $@ $< util.o
./internal_tests
debug:
$(MAKE) CFLAGS='-g -O0'

@ -1,4 +1,4 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
@ -127,7 +127,7 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
$(ACLOCAL_M4): configure.in acinclude.m4
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
config.status: $(srcdir)/configure.in $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
@ -498,6 +498,11 @@ moretest: $(MORE_TESTS)
echo "$$dashes"; \
test "$$failed" -eq 0
internal_test: internal_tests
internal_tests: internal_tests.o $(echoping_OBJECTS)
$(CC) $(LDFLAGS) -o $@ $< util.o
./internal_tests
debug:
$(MAKE) CFLAGS='-g -O0'

@ -8,7 +8,7 @@ http://sourceforge.net/bugs/?group_id=4581&func=detailbug&bug_id=132001
Wishes:
Display other calculations such as standard deviation.
Display other calculations such as kurtosis.
Check the TCP timeout with T/TCP. Difficult to test, few T/TCP
machines exist.
@ -50,3 +50,7 @@ echoping.c:540: warning: passing arg 5 of `sendto' from incompatible pointer typ
$Id$

@ -125,6 +125,18 @@ AC_TRY_LINK([#include <sys/types.h>
[AC_MSG_RESULT(yes); LIBS="${LIBS} -lsocket"])
])
])
AC_DEFUN([CF_LIB_MATH],
[
AC_CHECK_LIB(m,pow,
[
AC_MSG_CHECKING(if libmath is mandatory)
AC_TRY_LINK([#include <math.h>
double a,b; ],
[pow(a,b)], dnl
[AC_MSG_RESULT(no)], dnl
[AC_MSG_RESULT(yes); LIBS="${LIBS} -lm"])
])
])
dnl Check the port name for HTTP. Everyone should declare "http" but

14
SRC/aclocal.m4 vendored

@ -1,4 +1,4 @@
dnl aclocal.m4 generated automatically by aclocal 1.4
dnl aclocal.m4 generated automatically by aclocal 1.4-p4
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
@ -137,6 +137,18 @@ AC_TRY_LINK([#include <sys/types.h>
[AC_MSG_RESULT(yes); LIBS="${LIBS} -lsocket"])
])
])
AC_DEFUN([CF_LIB_MATH],
[
AC_CHECK_LIB(m,pow,
[
AC_MSG_CHECKING(if libmath is mandatory)
AC_TRY_LINK([#include <math.h>
double a,b; ],
[pow(a,b)], dnl
[AC_MSG_RESULT(no)], dnl
[AC_MSG_RESULT(yes); LIBS="${LIBS} -lm"])
])
])
dnl Check the port name for HTTP. Everyone should declare "http" but

@ -1,4 +1,4 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */
/* Define to empty if the keyword does not work. */
#undef const
@ -18,12 +18,18 @@
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Define if you have the gethostbyname function. */
#undef HAVE_GETHOSTBYNAME
/* Define if you have the getaddrinfo function. */
#undef HAVE_GETADDRINFO
/* Define if you have the getnameinfo function. */
#undef HAVE_GETNAMEINFO
/* Define if you have the gettimeofday function. */
#undef HAVE_GETTIMEOFDAY
/* Define if you have the inet_ntop function. */
#undef HAVE_INET_NTOP
/* Define if you have the sigaction function. */
#undef HAVE_SIGACTION

199
SRC/configure vendored

@ -732,7 +732,7 @@ fi
PACKAGE=echoping
VERSION=4.2.1-BETA
VERSION=5.0-BETA
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
{ echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; }
@ -1519,7 +1519,7 @@ else
int main() {
/* Ultrix mips cc rejects this. */
typedef int charset[2]; const charset x = {0,0};
typedef int charset[2]; const charset x;
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
@ -1755,13 +1755,77 @@ else
fi
echo $ac_n "checking for pow in -lm""... $ac_c" 1>&6
echo "configure:1761: checking for pow in -lm" >&5
ac_lib_var=`echo m'_'pow | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_save_LIBS="$LIBS"
LIBS="-lm $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1769 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char pow();
int main() {
pow()
; return 0; }
EOF
if { (eval echo configure:1780: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=no"
fi
rm -f conftest*
LIBS="$ac_save_LIBS"
fi
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
echo "$ac_t""yes" 1>&6
echo $ac_n "checking if libmath is mandatory""... $ac_c" 1>&6
echo "configure:1797: checking if libmath is mandatory" >&5
cat > conftest.$ac_ext <<EOF
#line 1799 "configure"
#include "confdefs.h"
#include <math.h>
double a,b;
int main() {
pow(a,b)
; return 0; }
EOF
if { (eval echo configure:1807: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
echo "$ac_t""no" 1>&6
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
echo "$ac_t""yes" 1>&6; LIBS="${LIBS} -lm"
fi
rm -f conftest*
else
echo "$ac_t""no" 1>&6
fi
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
echo "configure:1760: checking return type of signal handlers" >&5
echo "configure:1824: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1765 "configure"
#line 1829 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@ -1778,7 +1842,7 @@ int main() {
int i;
; return 0; }
EOF
if { (eval echo configure:1782: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1846: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@ -1797,12 +1861,12 @@ EOF
echo $ac_n "checking for vprintf""... $ac_c" 1>&6
echo "configure:1801: checking for vprintf" >&5
echo "configure:1865: checking for vprintf" >&5
if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1806 "configure"
#line 1870 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vprintf(); below. */
@ -1825,7 +1889,7 @@ vprintf();
; return 0; }
EOF
if { (eval echo configure:1829: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_vprintf=yes"
else
@ -1849,12 +1913,12 @@ fi
if test "$ac_cv_func_vprintf" != yes; then
echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
echo "configure:1853: checking for _doprnt" >&5
echo "configure:1917: checking for _doprnt" >&5
if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1858 "configure"
#line 1922 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char _doprnt(); below. */
@ -1877,7 +1941,7 @@ _doprnt();
; return 0; }
EOF
if { (eval echo configure:1881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1945: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func__doprnt=yes"
else
@ -1901,15 +1965,15 @@ fi
fi
for ac_func in gettimeofday socket gethostbyname sigaction
for ac_func in getnameinfo getaddrinfo inet_ntop
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1908: checking for $ac_func" >&5
echo "configure:1972: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1913 "configure"
#line 1977 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1932,7 +1996,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1936: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2000: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1953,19 +2017,19 @@ EOF
else
echo "$ac_t""no" 1>&6
{ echo "configure: error: Missing mandatory function" 1>&2; exit 1; }
{ echo "configure: error: Missing mandatory function - echoping now uses the new network functions which are mandatory for IPv6" 1>&2; exit 1; }
fi
done
for ac_func in usleep
for ac_func in gettimeofday socket sigaction
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1964: checking for $ac_func" >&5
echo "configure:2028: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1969 "configure"
#line 2033 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1988,7 +2052,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1992: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2056: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -2009,45 +2073,70 @@ EOF
else
echo "$ac_t""no" 1>&6
{ echo "configure: error: Missing mandatory function" 1>&2; exit 1; }
fi
done
echo $ac_n "checking for getaddrinfo function prototype in netdb.h""... $ac_c" 1>&6
echo "configure:2017: checking for getaddrinfo function prototype in netdb.h" >&5
if eval "test \"`echo '$''{'ac_cv_have_getaddrinfo_proto'+set}'`\" = set"; then
for ac_func in usleep
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2084: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2022 "configure"
#line 2089 "configure"
#include "confdefs.h"
#include <netdb.h>
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char $ac_func();
int main() {
/* The GNU C library defines this for functions which it implements
to always fail with ENOSYS. Some functions are actually named
something starting with __ and the normal name is an alias. */
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
choke me
#else
$ac_func();
#endif
; return 0; }
EOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
egrep "getaddrinfo" >/dev/null 2>&1; then
if { (eval echo configure:2112: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
ac_cv_have_getaddrinfo_proto=yes
eval "ac_cv_func_$ac_func=yes"
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
ac_cv_have_getaddrinfo_proto=no
eval "ac_cv_func_$ac_func=no"
fi
rm -f conftest*
fi
echo "$ac_t""$ac_cv_have_getaddrinfo_proto" 1>&6
if test $ac_cv_have_getaddrinfo_proto = yes ; then
ac_tr_func=HAVE_`echo getaddrinfo | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`_PROTO
cat >> confdefs.h <<EOF
if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
echo "$ac_t""yes" 1>&6
ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
cat >> confdefs.h <<EOF
#define $ac_tr_func 1
EOF
fi
else
echo "$ac_t""no" 1>&6
fi
done
if test "$OPENSSL" = "1"; then
echo $ac_n "checking for SSL_CTX_new in -lssl""... $ac_c" 1>&6
echo "configure:2051: checking for SSL_CTX_new in -lssl" >&5
echo "configure:2140: checking for SSL_CTX_new in -lssl" >&5
ac_lib_var=`echo ssl'_'SSL_CTX_new | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -2056,7 +2145,7 @@ else
LIBS="-lssl -lcrypto
$LIBS"
cat > conftest.$ac_ext <<EOF
#line 2060 "configure"
#line 2149 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -2067,7 +2156,7 @@ int main() {
SSL_CTX_new()
; return 0; }
EOF
if { (eval echo configure:2071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2160: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -2091,9 +2180,9 @@ fi
fi
echo $ac_n "checking T/TCP""... $ac_c" 1>&6
echo "configure:2095: checking T/TCP" >&5
echo "configure:2184: checking T/TCP" >&5
cat > conftest.$ac_ext <<EOF
#line 2097 "configure"
#line 2186 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@ -2102,7 +2191,7 @@ int main() {
int foobar = MSG_EOF;
; return 0; }
EOF
if { (eval echo configure:2106: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2195: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cat >> confdefs.h <<\EOF
#define TTCP 1
@ -2143,9 +2232,9 @@ fi
echo $ac_n "checking Type Of Service""... $ac_c" 1>&6
echo "configure:2147: checking Type Of Service" >&5
echo "configure:2236: checking Type Of Service" >&5
cat > conftest.$ac_ext <<EOF
#line 2149 "configure"
#line 2238 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <netinet/in.h>
@ -2154,7 +2243,7 @@ int main() {
int foobar = IP_TOS;
; return 0; }
EOF
if { (eval echo configure:2158: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2247: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cat >> confdefs.h <<\EOF
#define HAVE_TOS 1
@ -2195,9 +2284,9 @@ fi
echo $ac_n "checking Socket priority""... $ac_c" 1>&6
echo "configure:2199: checking Socket priority" >&5
echo "configure:2288: checking Socket priority" >&5
cat > conftest.$ac_ext <<EOF
#line 2201 "configure"
#line 2290 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/socket.h>
@ -2206,7 +2295,7 @@ int main() {
int foobar = SO_PRIORITY;
; return 0; }
EOF
if { (eval echo configure:2210: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2299: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
cat >> confdefs.h <<\EOF
#define HAVE_SOCKET_PRIORITY 1
@ -2628,7 +2717,7 @@ echo "Configuration of echoping:"
echo $ac_n "checking HTTP""... $ac_c" 1>&6
echo "configure:2632: checking HTTP" >&5
echo "configure:2721: checking HTTP" >&5
if eval 'test "$HTTP" = "1"' > /dev/null; then
echo "$ac_t""enabled" 1>&6
else
@ -2637,7 +2726,7 @@ fi
echo $ac_n "checking ICP""... $ac_c" 1>&6
echo "configure:2641: checking ICP" >&5
echo "configure:2730: checking ICP" >&5
if eval 'test "$ICP" = "1"' > /dev/null; then
echo "$ac_t""enabled" 1>&6
else
@ -2646,7 +2735,7 @@ fi
echo $ac_n "checking OPENSSL""... $ac_c" 1>&6
echo "configure:2650: checking OPENSSL" >&5
echo "configure:2739: checking OPENSSL" >&5
if eval 'test "$OPENSSL" = "1"' > /dev/null; then
echo "$ac_t""enabled" 1>&6
else
@ -2655,7 +2744,7 @@ fi
echo $ac_n "checking SMTP""... $ac_c" 1>&6
echo "configure:2659: checking SMTP" >&5
echo "configure:2748: checking SMTP" >&5
if eval 'test "$SMTP" = "1"' > /dev/null; then
echo "$ac_t""enabled" 1>&6
else
@ -2664,7 +2753,7 @@ fi
echo $ac_n "checking TTCP""... $ac_c" 1>&6
echo "configure:2668: checking TTCP" >&5
echo "configure:2757: checking TTCP" >&5
if eval 'test "$TTCP" = "1"' > /dev/null; then
echo "$ac_t""enabled" 1>&6
else
@ -2673,7 +2762,7 @@ fi
echo $ac_n "checking TOS""... $ac_c" 1>&6
echo "configure:2677: checking TOS" >&5
echo "configure:2766: checking TOS" >&5
if eval 'test "$TOS" = "1"' > /dev/null; then
echo "$ac_t""enabled" 1>&6
else
@ -2682,7 +2771,7 @@ fi
echo $ac_n "checking PRIORITY""... $ac_c" 1>&6
echo "configure:2686: checking PRIORITY" >&5
echo "configure:2775: checking PRIORITY" >&5
if eval 'test "$PRIORITY" = "1"' > /dev/null; then
echo "$ac_t""enabled" 1>&6
else

@ -3,7 +3,7 @@ dnl $Id$
dnl Process this file with autoconf to produce a configure script.
AC_INIT(echoping.h)
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE(echoping, 4.2.1-BETA)
AM_INIT_AUTOMAKE(echoping, 5.0-BETA)
AM_CONFIG_HEADER(config.h)
dnl User options
@ -73,11 +73,12 @@ AC_HEADER_TIME
dnl Checks for library functions.
CF_LIB_SOCKET
CF_LIB_NSL
CF_LIB_MATH
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(gettimeofday socket gethostbyname sigaction, , AC_MSG_ERROR(Missing mandatory function))
AC_CHECK_FUNCS(getnameinfo getaddrinfo inet_ntop, , AC_MSG_ERROR(Missing mandatory function - echoping now uses the new network functions which are mandatory for IPv6))
AC_CHECK_FUNCS(gettimeofday socket sigaction, , AC_MSG_ERROR(Missing mandatory function))
AC_CHECK_FUNCS(usleep)
AC_CHECK_FUNC_PROTO(getaddrinfo, netdb.h)
if test "$OPENSSL" = "1"; then
CF_LIB_OPENSSL

@ -51,11 +51,16 @@ Verbose
Size of the data to send. Large values can produce strange results with
some echo servers.
.IP -n\ nnn
Numbers of repeated tests. With this option, you have also the minimum, maximum, average and median
time. The median is the value such that half of the measures are under it
and the other half is above. When you measure highly variables values, like
it is often the case on the whole Internet, median is better than average
to avoid "extreme" values.
Numbers of repeated tests. With this option, you have also the
minimum, maximum, average and median time, as well as the standard
deviation. The median is the value such that half of the measures are
under it and the other half is above. When you measure highly
variables values, like it is often the case on the whole Internet,
median is better than average to avoid "extreme" values. You can check
the "value" of the average by looking at the standard deviation: very
roughly, if the standard deviation is more than the half of the
average, the average does not mean anything. (See a book about
statistics for the details: the reality is far more complicated.)
.IP -w\ nnn
Number of seconds to wait between two tests (default is one). On
systems which have usleep(), you can write it as a fractional number,

@ -25,15 +25,11 @@ unsigned short timeout_flag;
int return_code = 0;
unsigned int number = 1;
struct timeval max, min, total, median, temp;
struct timeval max, min, total, median, stddev, temp;
unsigned int successes, attempts = 0;
unsigned int size = DEFLINE;
unsigned int j = 0;
struct result
{
unsigned short valid;
struct timeval timevalue;
};
int family = PF_UNSPEC;
struct result results[MAXNUMBER];
struct timeval good_results[MAXNUMBER];
extern int tvcmp ();
@ -49,17 +45,18 @@ main (argc, argv)
signed char ch;
int sockfd;
struct addrinfo hints, *res;
int error;
char hbuf[NI_MAXHOST], pbuf[NI_MAXSERV];
#ifdef NI_WITHSCOPEID
const int niflags = NI_NUMERICHOST | NI_NUMERICSERV | NI_WITHSCOPEID;
#else
const int niflags = NI_NUMERICHOST | NI_NUMERICSERV;
#endif
FILE *files = NULL;
CHANNEL channel;
struct hostent *hostptr;
struct sockaddr_in serv_addr;
struct sockaddr_in udp_cli_addr; /* client's Internet socket
* addr */
struct servent *sp = NULL;
int verbose = FALSE;
char *server_address;
u_int addr;
struct in_addr *ptr;
int n, nr = 0;
int rc;
#ifdef OPENSSL
@ -89,13 +86,11 @@ main (argc, argv)
unsigned short timeout_requested = 0;
unsigned short size_requested = 0;
char *url = "";
short port = 0;
char *text_port = malloc (6);
#if USE_SIGACTION
struct sigaction mysigaction;
#endif
char *port_name = ECHO_TCP_PORT;
char port_name[NI_MAXSERV];
unsigned short port_to_use = USE_ECHO;
unsigned short http = 0;
unsigned short smtp = 0;
@ -137,13 +132,16 @@ main (argc, argv)
median = null_timeval;
max = null_timeval;
min = max_timeval;
stddev = null_timeval;
strcpy(port_name, ECHO_TCP_PORT);
for (i = 0; i <= MAXNUMBER; i++)
{
results[i].valid = 0;
}
progname = argv[0];
while ((ch = getopt (argc, argv, "vs:n:w:dch:i:rut:f:SCp:P:aA")) != EOF)
while ((ch = getopt (argc, argv, "vs:n:w:dch:i:rut:f:SCp:P:aA46")) != EOF)
{
switch (ch)
{
@ -160,23 +158,23 @@ main (argc, argv)
ssl = 1;
break;
case 'd':
port_name = DISCARD_TCP_PORT;
strcpy(port_name, DISCARD_TCP_PORT);
port_to_use = USE_DISCARD;
break;
case 'c':
port_name = CHARACTER_GENERATOR_TCP_PORT;
strcpy(port_name, CHARACTER_GENERATOR_TCP_PORT);
port_to_use = USE_CHARGEN;
stop_at_newlines = 0;
break;
case 'i':
port_name = DEFAULT_ICP_UDP_PORT;
strcpy(port_name, DEFAULT_ICP_UDP_PORT);
port_to_use = USE_ICP;
udp = 1;
icp = 1;
url = optarg;
break;
case 'h':
port_name = DEFAULT_HTTP_TCP_PORT;
strcpy(port_name, DEFAULT_HTTP_TCP_PORT);
port_to_use = USE_HTTP;
http = 1;
url = optarg;
@ -192,7 +190,7 @@ main (argc, argv)
fill_requested = 1;
break;
case 'S':
port_name = "smtp";
strcpy(port_name, "smtp");
port_to_use = USE_SMTP;
smtp = 1;
break;
@ -281,6 +279,12 @@ main (argc, argv)
exit (1);
}
break;
case '4':
family = AF_INET;
break;
case '6':
family = AF_INET6;
break;
default:
usage ();
}
@ -372,7 +376,7 @@ main (argc, argv)
}
if (ssl && http)
{
port_name = DEFAULT_HTTPS_TCP_PORT;
strcpy(port_name, DEFAULT_HTTPS_TCP_PORT);
}
#ifndef USE_TOS
if (tos_requested)
@ -407,88 +411,75 @@ main (argc, argv)
printf ("\nThis is %s, version %s.\n\n", progname, VERSION);
}
server = argv[0];
signal (SIGINT, interrupted);
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = udp ? SOCK_DGRAM : SOCK_STREAM;
#ifdef HTTP
if (http || icp)
{
if (icp)
{
find_server_and_port (server, &port, port_name);
if (port == 0)
port = 3130;
}
else
char *text_port = NULL, *p;
for (p = server; *p; p++)
{
find_server_and_port (server, &port, port_name);
if (port == 0)
port = 80;
if (*p == ':')
{
*p = 0;
text_port = p + 1;
strncpy(port_name, text_port, NI_MAXSERV);
}
}
sprintf (text_port, "(port %d)", ntohs (port));
if (text_port == NULL)
{
error = getaddrinfo(server, port_name, &hints, &res);
if (error)
{
if (error == EAI_SERVICE)
{
if (strcmp (port_name, DEFAULT_HTTP_TCP_PORT) == 0)
{
strcpy(port_name, "80");
}
else if (strcmp (port_name, DEFAULT_HTTPS_TCP_PORT) == 0)
{
strcpy(port_name, "443");
}
else if (strcmp (port_name, DEFAULT_ICP_UDP_PORT) == 0)
{
strcpy(port_name, "3130");
}
}
}
}
}
#endif
signal (SIGINT, interrupted);
if ((addr = inet_addr (server)) == INADDR_NONE)
error = getaddrinfo(server, port_name, &hints, &res);
if (error)
{
if ((hostptr = gethostbyname (server)) == NULL)
{
err_quit ("gethostbyname error for host: %s %s",
server, sys_err_str ());
}
server_address = *(hostptr->h_addr_list); /* First item of the
* list */
/*
* addr = (u_long) *server_address;
*/
/* ptr.s_addr = addr; */
ptr = (struct in_addr *) server_address; /* hostptr->h_addr_list
* points actually to
* u_longs, not strings */
addr = ptr->s_addr;
err_quit("getaddrinfo error for host: %s %s",
server, gai_strerror(error));
}
else
if (getnameinfo(res->ai_addr, res->ai_addrlen, hbuf, sizeof(hbuf),
pbuf, sizeof(pbuf), niflags) != 0)
{
ptr = (struct in_addr *) malloc (sizeof (struct in_addr));
ptr->s_addr = addr;
}
if (!http && !icp) /* Already find */
{
if (!udp)
{
if ((sp = getservbyname (port_name, "tcp")) == NULL)
{
err_quit ("tcp_open: unknown service: %s/tcp", port_name);
}
}
else
{
if ((sp = getservbyname (port_name, "udp")) == NULL)
{
err_quit ("tcp_open: unknown service: %s/udp", port_name);
}
}
strcpy(hbuf, "?");
strcpy(pbuf, "?");
}
/*
* Fill in the structure "serv_addr" with the address of the server
* that we want to connect with.
*/
bzero ((char *) &serv_addr, sizeof (serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = addr;
if (!http && !icp)
{
serv_addr.sin_port = sp->s_port;
}
else
{
serv_addr.sin_port = port;
}
#ifdef HTTP
if (http)
{
sendline =
make_http_sendline (url, server, (int) ntohs (port), nocache);
make_http_sendline (url, server, (int) ntohs (atoi(pbuf)), nocache);
}
else
#endif
@ -504,7 +495,15 @@ main (argc, argv)
#ifdef ICP
if (icp)
{
sendline = make_icp_sendline (url, &addr, opcode, &length);
if (res->ai_family == AF_INET)
{
sendline = make_icp_sendline (url, &((struct sockaddr_in *)(res->ai_addrlen))->sin_addr,
opcode, &length);
}
else
{
sendline = make_icp_sendline (url, NULL, opcode, &length);
}
}
else
#endif
@ -550,26 +549,25 @@ main (argc, argv)
if ((sslh = SSL_new (ctx)) == NULL)
err_sys ("Cannot initialize SSL context");
#endif
if (!udp)
/*
* Open a socket.
*/
if ((sockfd = socket (res->ai_family, res->ai_socktype, res->ai_protocol)) < 0)
err_sys ("Can't open socket");
if (udp)
{
/*
* Open a TCP socket (an Internet stream socket).
*/
struct addrinfo hints2, *res2;
if ((sockfd = socket (AF_INET, SOCK_STREAM, 0)) < 0)
err_sys ("Can't open stream socket");
}
else
{
if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
err_sys ("Can't open datagram socket");
/* Bind socket for reply. Not necessary? */
bzero ((char *) &udp_cli_addr, sizeof (udp_cli_addr));
udp_cli_addr.sin_family = AF_INET;
udp_cli_addr.sin_addr.s_addr = htonl (INADDR_ANY);
udp_cli_addr.sin_port = htons (0);
if (bind (sockfd, (struct sockaddr *) &udp_cli_addr,
sizeof (udp_cli_addr)) < 0)
memset(&hints2, 0, sizeof(hints2));
hints2.ai_family = res->ai_family;
hints2.ai_flags = AI_PASSIVE;
hints2.ai_socktype = SOCK_DGRAM;
error = getaddrinfo(NULL, "0", &hints2, &res2);
if (error)
{
err_sys ("getaddrinfo error");
}
if (bind (sockfd, res2->ai_addr, res2->ai_addrlen) < 0)
{
err_sys ("bind error");
}
@ -613,20 +611,20 @@ main (argc, argv)
{
printf
("Trying to connect to internet address %s %s to transmit %u bytes...\n",
inet_ntoa (*ptr), (port == 0 ? "" : text_port), n);
hbuf, pbuf, n);
}
#ifdef ICP
if (icp)
{
printf
("Trying to send an ICP packet of %u bytes to the internet address %s...\n",
length, inet_ntoa (*ptr));
length, hbuf);
}
#endif
else
{
printf ("Trying to send %u bytes to internet address %s...\n",
size, inet_ntoa (*ptr));
size, hbuf);
}
#ifdef FLUSH_OUTPUT
if (fflush ((FILE *) NULL) != 0)
@ -661,8 +659,7 @@ main (argc, argv)
* Connect to the server.
*/
if (connect (sockfd, (struct sockaddr *) &serv_addr,
sizeof (serv_addr)) < 0)
if (connect (sockfd, res->ai_addr, res->ai_addrlen) < 0)
{
if ((errno == EINTR) && (timeout_flag))
{
@ -721,8 +718,7 @@ main (argc, argv)
if (ttcp)
{
if (sendto (sockfd, sendline, n, MSG_EOF,
(struct sockaddr *) &serv_addr,
sizeof (serv_addr)) != n)
res->ai_addr, res->ai_addrlen) != n)
err_sys ("sendto error on socket");
if (verbose)
{
@ -787,7 +783,7 @@ main (argc, argv)
if (icp)
{
if (sendto (sockfd, sendline, length, 0,
&serv_addr, sizeof (serv_addr)) != length)
res->ai_addr, res->ai_addrlen) != length)
err_sys ("sendto error on socket");
}
else
@ -1070,6 +1066,9 @@ printstats ()
/* The number of bytes/second, as printed above, is not really
meaningful: size does not reflect the number of bytes exchanged.
With echo, N = 2*size, with discard, N = size, with http, N = size + (response)... */
tvstddev (&stddev, successes, total, results);
printf ("Standard deviation: %d.%06d\n",
(int) stddev.tv_sec, (int) stddev.tv_usec);
for (i = 0; i < number; i++)
{
if (results[i].valid)

@ -34,6 +34,7 @@
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <math.h>
#ifdef OPENSSL
#include <openssl/crypto.h>
@ -99,8 +100,13 @@ typedef union _CHANNEL
#endif
}
CHANNEL;
#endif
struct result
{
unsigned short valid;
struct timeval timevalue;
};
#endif
struct timeval null_timeval;
struct timeval max_timeval;
@ -150,7 +156,10 @@ void tvadd ();
void tvavg ();
void tvmin ();
void tvmax ();
int tvcmp ();
void tvstddev ();
double tv2double ();
struct timeval double2tv ();
/* http.c */
#ifdef HTTP
char *make_http_sendline ();
@ -164,7 +173,6 @@ int read_from_server (CHANNEL fs, short ssl);
void *make_icp_sendline ();
int recv_icp ();
#ifndef HTTP
void find_server_and_port ();
int read_from_server ();
#endif
#endif

@ -88,7 +88,7 @@ void
usage ()
{
fprintf (stderr,
"Usage: %s [-v] [-r] [-f fill] [-t timeout] [-c] [-d] [-u] [-s size] [-n number] [-w delay] [-h url] [-i url] [-p priority] [-P tos] [-C] [-S] hostname[:port]\n",
"Usage: %s [-4] [-6] [-v] [-r] [-f fill] [-t timeout] [-c] [-d] [-u] [-s size] [-n number] [-w delay] [-h url] [-i url] [-p priority] [-P tos] [-C] [-S] hostname[:port]\n",
progname);
exit (1);
}

@ -49,65 +49,6 @@ make_http_sendline (char *url, char *host, int port, int nocache)
return sendline;
}
void
find_server_and_port (char *server, short *port, char *default_port)
{
char *text_port, *p;
struct servent *sp;
for (p = server; *p; p++)
{
if (*p == ':')
{
*p = 0;
text_port = p + 1;
*port = atoi (text_port);
}
}
if (*port == 0)
{
if (strcmp (default_port, DEFAULT_HTTP_TCP_PORT) == 0)
{
if ((sp = getservbyname ("http", "tcp")) == NULL)
{
if ((sp = getservbyname ("www", "tcp")) == NULL)
{
*port = htons (80);
return;
}
}
*port = sp->s_port;
return;
}
else if (strcmp (default_port, DEFAULT_HTTPS_TCP_PORT) == 0)
{
if ((sp = getservbyname ("https", "tcp")) == NULL)
{
*port = htons (443);
return;
}
*port = sp->s_port;
return;
}
else if (strcmp (default_port, DEFAULT_ICP_UDP_PORT) == 0)
{
if ((sp = getservbyname ("icp", "udp")) == NULL)
{
*port = htons (3130);
return;
}
*port = sp->s_port;
return;
}
else if ((sp = getservbyname (default_port, "tcp")) == NULL)
{
err_quit ("tcp_open: unknown service: %s/tcp", default_port);
}
*port = sp->s_port;
}
else
*port = htons (*port);
}
int
read_from_server (CHANNEL fs, short ssl)
{

@ -38,7 +38,8 @@ make_icp_sendline (url, shost, opcode, length)
headerp->reqnum = htonl (reqnum);
headerp->flags = htonl (flags);
headerp->pad = pad;
headerp->shostid = htonl (*shost);
if (shost)
headerp->shostid = htonl (*shost);
/* urloffset = (char *) ((int) buf + sizeof(icp_common_t)); */
urloffset = (char *) (buf + sizeof (icp_common_t));
if (opcode == ICP_OP_QUERY)

@ -82,6 +82,48 @@ tvavg (out, number)
out->tv_usec = (long) (result - (out->tv_sec * 1000000));
}
/* tvstddev -- Computes the standard deviation of a set of results */
void
tvstddev (out, number, average, results)
struct timeval *out;
int number;
struct timeval average;
struct result *results;
{
int i;
struct timeval result, avg, var = null_timeval;
struct timeval square, large, small;
*out = null_timeval;
for (i = 0; i < number; i++)
{
if (results[i].valid == 1)
{
result = results[i].timevalue;
/* printf ("value is %f (average is %f)\n",
tv2double (result), tv2double (average)); */
avg = average;
if (tvcmp (&result, &avg) == -1)
{
small = result;
large = avg;
}
else
{
large = result;
small = avg;
}
tvsub (&large, &small);
/* printf ("abs offset is %f\n", tv2double (large)); */
square = double2tv (pow (tv2double (large), 2));
tvadd (&var, &square);
/* printf ("variance is now %f\n", tv2double (var)); */
}
}
result = double2tv (sqrt (tv2double (var) / number));
out->tv_sec = result.tv_sec;
out->tv_usec = result.tv_usec;
}
/* tvcmp -- Compares two timeval structs */
int
tvcmp (left, right)
@ -136,7 +178,18 @@ tv2double (tv)
struct timeval tv;
{
double result;
result = (((((double) tv.tv_sec) * 1000000.0) + (double) tv.tv_usec) / 1000000.0);
result =
(((((double) tv.tv_sec) * 1000000.0) + (double) tv.tv_usec) / 1000000.0);
/* printf ("Double is %9.3f\n", result); */
return result;
}
struct timeval
double2tv (x)
double x;
{
struct timeval result;
result.tv_sec = (int) (x);
result.tv_usec = (int) ((x - result.tv_sec) * 1000000);
return result;
}

Loading…
Cancel
Save