diff -ur mtr-0.60/Makefile.in mtr-0.61/Makefile.in --- mtr-0.60/Makefile.in Tue Aug 10 10:08:37 2004 +++ mtr-0.61/Makefile.in Wed Aug 11 07:51:44 2004 @@ -68,6 +68,7 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ +PKG_CONFIG = @PKG_CONFIG@ VERSION = @VERSION@ am__include = @am__include@ am__quote = @am__quote@ diff -ur mtr-0.60/NEWS mtr-0.61/NEWS --- mtr-0.60/NEWS Tue Aug 10 23:23:54 2004 +++ mtr-0.61/NEWS Wed Aug 11 13:33:58 2004 @@ -1,4 +1,10 @@ WHAT'S NEW? + v0.61 Attempt to get/print the local IP address. Now shows as + 0.0.0.0 :-( Hints and tips appreciated! -- REW + Lots of blank space reformatting. + moved the interface address setting to net.c (where it + belongs). + v0.60 John Thacker submitted a surprisingly simple patch to enable linking against GTK2. (up to 2.4.0) diff -ur mtr-0.60/aclocal.m4 mtr-0.61/aclocal.m4 --- mtr-0.60/aclocal.m4 Tue Aug 10 10:08:37 2004 +++ mtr-0.61/aclocal.m4 Wed Aug 11 07:51:39 2004 @@ -492,6 +492,203 @@ fi]) # Configure paths for GTK+ +# Owen Taylor 1997-2001 + +dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) +dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES, +dnl pass to pkg-config +dnl +AC_DEFUN(AM_PATH_GTK_2_0, +[dnl +dnl Get the cflags and libraries from pkg-config +dnl +AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program], + , enable_gtktest=yes) + + pkg_config_args=gtk+-2.0 + for module in . $4 + do + case "$module" in + gthread) + pkg_config_args="$pkg_config_args gthread-2.0" + ;; + esac + done + + no_gtk="" + + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + + if test x$PKG_CONFIG != xno ; then + if pkg-config --atleast-pkgconfig-version 0.7 ; then + : + else + echo *** pkg-config too old; version 0.7 or better required. + no_gtk=yes + PKG_CONFIG=no + fi + else + no_gtk=yes + fi + + min_gtk_version=ifelse([$1], ,2.0.0,$1) + AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version) + + if test x$PKG_CONFIG != xno ; then + ## don't try to run the test against uninstalled libtool libs + if $PKG_CONFIG --uninstalled $pkg_config_args; then + echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH" + enable_gtktest=no + fi + + if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then + : + else + no_gtk=yes + fi + fi + + if test x"$no_gtk" = x ; then + GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags` + GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs` + gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_gtktest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$GTK_LIBS $LIBS" +dnl +dnl Now check if the installed GTK+ is sufficiently new. (Also sanity +dnl checks the results of pkg-config to some extent) +dnl + rm -f conf.gtktest + AC_TRY_RUN([ +#include +#include +#include + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gtktest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gtk_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gtk_version"); + exit(1); + } + + if ((gtk_major_version != $gtk_config_major_version) || + (gtk_minor_version != $gtk_config_minor_version) || + (gtk_micro_version != $gtk_config_micro_version)) + { + printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", + $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf ("*** was found! If pkg-config was correct, then it is best\n"); + printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); + printf("*** to point to the correct configuration files\n"); + } + else if ((gtk_major_version != GTK_MAJOR_VERSION) || + (gtk_minor_version != GTK_MINOR_VERSION) || + (gtk_micro_version != GTK_MICRO_VERSION)) + { + printf("*** GTK+ header files (version %d.%d.%d) do not match\n", + GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + } + else + { + if ((gtk_major_version > major) || + ((gtk_major_version == major) && (gtk_minor_version > minor)) || + ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n"); + printf("*** correct copy of pkg-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} +],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gtk" = x ; then + AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version)) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$PKG_CONFIG" = "no" ; then + echo "*** A new enough version of pkg-config was not found." + echo "*** See http://pkgconfig.sourceforge.net" + else + if test -f conf.gtktest ; then + : + else + echo "*** Could not run GTK+ test program, checking why..." + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$LIBS $GTK_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GTK+ or finding the wrong" + echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GTK+ was incorrectly installed" + echo "*** or that you have moved GTK+ since it was installed. In the latter case, you" + echo "*** may want to edit the pkg-config script: $PKG_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GTK_CFLAGS="" + GTK_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(GTK_CFLAGS) + AC_SUBST(GTK_LIBS) + rm -f conf.gtktest +]) + +# Configure paths for GTK+ # Owen Taylor 97-11-3 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]]) diff -ur mtr-0.60/configure mtr-0.61/configure --- mtr-0.60/configure Tue Aug 10 10:08:38 2004 +++ mtr-0.61/configure Wed Aug 11 07:51:49 2004 @@ -17,6 +17,10 @@ ac_help="$ac_help --without-gtk Do not try to use GTK+ at all" ac_help="$ac_help + --enable-gtk2 Compile against GTK2 instead of GTK+" +ac_help="$ac_help + --disable-gtktest do not try to compile and run a test GTK+ program" +ac_help="$ac_help --with-gtk-prefix=PFX Prefix where GTK is installed (optional)" ac_help="$ac_help --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)" @@ -567,7 +571,7 @@ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:571: checking for a BSD compatible install" >&5 +echo "configure:575: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -620,7 +624,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:624: checking whether build environment is sane" >&5 +echo "configure:628: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftest.file @@ -691,7 +695,7 @@ # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:695: checking for $ac_word" >&5 +echo "configure:699: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -721,7 +725,7 @@ done echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:725: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:729: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -789,7 +793,7 @@ # Define the identity of the package. PACKAGE=mtr -VERSION=0.60 +VERSION=0.61 cat >> confdefs.h <&6 -echo "configure:852: checking for $ac_word" >&5 +echo "configure:856: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -878,7 +882,7 @@ # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:882: checking for $ac_word" >&5 +echo "configure:886: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -929,7 +933,7 @@ # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:933: checking for $ac_word" >&5 +echo "configure:937: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -961,7 +965,7 @@ fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:965: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:969: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -972,12 +976,12 @@ cat > conftest.$ac_ext << EOF -#line 976 "configure" +#line 980 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:981: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:985: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1003,12 +1007,12 @@ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1007: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1011: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1012: checking whether we are using GNU C" >&5 +echo "configure:1016: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1017,7 +1021,7 @@ yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1021: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1025: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1036,7 +1040,7 @@ ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1040: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1044: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1075,7 +1079,7 @@ END # If we don't find an include directive, just comment out the code. echo $ac_n "checking for style of include used by $am_make""... $ac_c" 1>&6 -echo "configure:1079: checking for style of include used by $am_make" >&5 +echo "configure:1083: checking for style of include used by $am_make" >&5 am__include='#' am__quote= _am_result=none @@ -1109,7 +1113,7 @@ depcc="$CC" am_compiler_list= echo $ac_n "checking dependency style of $depcc""... $ac_c" 1>&6 -echo "configure:1113: checking dependency style of $depcc" >&5 +echo "configure:1117: checking dependency style of $depcc" >&5 if eval "test \"`echo '$''{'am_cv_CC_dependencies_compiler_type'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1177,7 +1181,7 @@ echo $ac_n "checking size of unsigned char""... $ac_c" 1>&6 -echo "configure:1181: checking size of unsigned char" >&5 +echo "configure:1185: checking size of unsigned char" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_char'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1185,7 +1189,7 @@ ac_cv_sizeof_unsigned_char=1 else cat > conftest.$ac_ext < #include @@ -1197,7 +1201,7 @@ exit(0); } EOF -if { (eval echo configure:1201: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_unsigned_char=`cat conftestval` else @@ -1217,7 +1221,7 @@ echo $ac_n "checking size of unsigned short""... $ac_c" 1>&6 -echo "configure:1221: checking size of unsigned short" >&5 +echo "configure:1225: checking size of unsigned short" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_short'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1225,7 +1229,7 @@ ac_cv_sizeof_unsigned_short=2 else cat > conftest.$ac_ext < #include @@ -1237,7 +1241,7 @@ exit(0); } EOF -if { (eval echo configure:1241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1245: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_unsigned_short=`cat conftestval` else @@ -1257,7 +1261,7 @@ echo $ac_n "checking size of unsigned int""... $ac_c" 1>&6 -echo "configure:1261: checking size of unsigned int" >&5 +echo "configure:1265: checking size of unsigned int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1265,7 +1269,7 @@ ac_cv_sizeof_unsigned_int=4 else cat > conftest.$ac_ext < #include @@ -1277,7 +1281,7 @@ exit(0); } EOF -if { (eval echo configure:1281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_unsigned_int=`cat conftestval` else @@ -1297,7 +1301,7 @@ echo $ac_n "checking size of unsigned long""... $ac_c" 1>&6 -echo "configure:1301: checking size of unsigned long" >&5 +echo "configure:1305: checking size of unsigned long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1305,7 +1309,7 @@ ac_cv_sizeof_unsigned_long=4 else cat > conftest.$ac_ext < #include @@ -1317,7 +1321,7 @@ exit(0); } EOF -if { (eval echo configure:1321: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1325: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_unsigned_long=`cat conftestval` else @@ -1345,7 +1349,7 @@ # We have to trust the linker not to mess things up... (It should not # pull in anything if we don't refer to anything in the lib). echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6 -echo "configure:1349: checking for tgetent in -ltermcap" >&5 +echo "configure:1353: checking for tgetent in -ltermcap" >&5 ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1353,7 +1357,7 @@ ac_save_LIBS="$LIBS" LIBS="-ltermcap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1372: \"$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 @@ -1393,12 +1397,12 @@ echo $ac_n "checking for initscr""... $ac_c" 1>&6 -echo "configure:1397: checking for initscr" >&5 +echo "configure:1401: checking for initscr" >&5 if eval "test \"`echo '$''{'ac_cv_func_initscr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1429: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_initscr=yes" else @@ -1439,7 +1443,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for initscr in -lncurses""... $ac_c" 1>&6 -echo "configure:1443: checking for initscr in -lncurses" >&5 +echo "configure:1447: checking for initscr in -lncurses" >&5 ac_lib_var=`echo ncurses'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1447,7 +1451,7 @@ ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1466: \"$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 @@ -1484,7 +1488,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for initscr in -lcurses""... $ac_c" 1>&6 -echo "configure:1488: checking for initscr in -lcurses" >&5 +echo "configure:1492: checking for initscr in -lcurses" >&5 ac_lib_var=`echo curses'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1492,7 +1496,7 @@ ac_save_LIBS="$LIBS" LIBS="-lcurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1511: \"$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 @@ -1529,7 +1533,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for initscr in -lcursesX""... $ac_c" 1>&6 -echo "configure:1533: checking for initscr in -lcursesX" >&5 +echo "configure:1537: checking for initscr in -lcursesX" >&5 ac_lib_var=`echo cursesX'_'initscr | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1537,7 +1541,7 @@ ac_save_LIBS="$LIBS" LIBS="-lcursesX $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1556: \"$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 @@ -1591,12 +1595,12 @@ for ac_func in attron do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:1595: checking for $ac_func" >&5 +echo "configure:1599: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1627: \"$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 @@ -1646,7 +1650,7 @@ echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1650: checking how to run the C preprocessor" >&5 +echo "configure:1654: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1661,13 +1665,13 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1671: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1675: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1678,13 +1682,13 @@ rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1688: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1692: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1695,13 +1699,13 @@ rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1705: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1709: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1729,17 +1733,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1733: checking for $ac_hdr" >&5 +echo "configure:1737: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1743: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1747: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1769,17 +1773,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1773: checking for $ac_hdr" >&5 +echo "configure:1777: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1783: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1787: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -1807,7 +1811,7 @@ echo $ac_n "checking for floor in -lm""... $ac_c" 1>&6 -echo "configure:1811: checking for floor in -lm" >&5 +echo "configure:1815: checking for floor in -lm" >&5 ac_lib_var=`echo m'_'floor | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1815,7 +1819,7 @@ ac_save_LIBS="$LIBS" LIBS="-lm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1834: \"$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 @@ -1864,8 +1868,282 @@ fi +# Check whether --enable-gtk2 or --disable-gtk2 was given. +if test "${enable_gtk2+set}" = set; then + enableval="$enable_gtk2" + WANTS_GTK2=$enableval +else + WANTS_GTK2=no +fi + + if test "x$WANTS_GTK" = "xyes"; then - # Check whether --with-gtk-prefix or --without-gtk-prefix was given. + if test "x$WANTS_GTK2" = "xyes"; then + # Check whether --enable-gtktest or --disable-gtktest was given. +if test "${enable_gtktest+set}" = set; then + enableval="$enable_gtktest" + : +else + enable_gtktest=yes +fi + + + pkg_config_args=gtk+-2.0 + for module in . + do + case "$module" in + gthread) + pkg_config_args="$pkg_config_args gthread-2.0" + ;; + esac + done + + no_gtk="" + + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1907: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$PKG_CONFIG" in + /*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no" + ;; +esac +fi +PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +if test -n "$PKG_CONFIG"; then + echo "$ac_t""$PKG_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + + if test x$PKG_CONFIG != xno ; then + if pkg-config --atleast-pkgconfig-version 0.7 ; then + : + else + echo *** pkg-config too old; version 0.7 or better required. + no_gtk=yes + PKG_CONFIG=no + fi + else + no_gtk=yes + fi + + min_gtk_version=2.0.0 + echo $ac_n "checking for GTK+ - version >= $min_gtk_version""... $ac_c" 1>&6 +echo "configure:1955: checking for GTK+ - version >= $min_gtk_version" >&5 + + if test x$PKG_CONFIG != xno ; then + ## don't try to run the test against uninstalled libtool libs + if $PKG_CONFIG --uninstalled $pkg_config_args; then + echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH" + enable_gtktest=no + fi + + if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then + : + else + no_gtk=yes + fi + fi + + if test x"$no_gtk" = x ; then + GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags` + GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs` + gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_gtktest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$GTK_LIBS $LIBS" + rm -f conf.gtktest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat > conftest.$ac_ext < +#include +#include + +int +main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.gtktest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = g_strdup("$min_gtk_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_gtk_version"); + exit(1); + } + + if ((gtk_major_version != $gtk_config_major_version) || + (gtk_minor_version != $gtk_config_minor_version) || + (gtk_micro_version != $gtk_config_micro_version)) + { + printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", + $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf ("*** was found! If pkg-config was correct, then it is best\n"); + printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); + printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); + printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); + printf("*** required on your system.\n"); + printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n"); + printf("*** to point to the correct configuration files\n"); + } + else if ((gtk_major_version != GTK_MAJOR_VERSION) || + (gtk_minor_version != GTK_MINOR_VERSION) || + (gtk_micro_version != GTK_MICRO_VERSION)) + { + printf("*** GTK+ header files (version %d.%d.%d) do not match\n", + GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION); + printf("*** library (version %d.%d.%d)\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + } + else + { + if ((gtk_major_version > major) || + ((gtk_major_version == major) && (gtk_minor_version > minor)) || + ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", + gtk_major_version, gtk_minor_version, gtk_micro_version); + printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", + major, minor, micro); + printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n"); + printf("***\n"); + printf("*** If you have already installed a sufficiently new version, this error\n"); + printf("*** probably means that the wrong copy of the pkg-config shell script is\n"); + printf("*** being found. The easiest way to fix this is to remove the old version\n"); + printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n"); + printf("*** correct copy of pkg-config. (In this case, you will have to\n"); + printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); + printf("*** so that the correct libraries are found at run-time))\n"); + } + } + return 1; +} + +EOF +if { (eval echo configure:2065: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + no_gtk=yes +fi +rm -fr conftest* +fi + + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_gtk" = x ; then + echo "$ac_t""yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version)" 1>&6 + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$LIBS $GTK_LIBS" + else + echo "$ac_t""no" 1>&6 + if test "$PKG_CONFIG" = "no" ; then + echo "*** A new enough version of pkg-config was not found." + echo "*** See http://pkgconfig.sourceforge.net" + else + if test -f conf.gtktest ; then + : + else + echo "*** Could not run GTK+ test program, checking why..." + CFLAGS="$CFLAGS $GTK_CFLAGS" + LIBS="$LIBS $GTK_LIBS" + cat > conftest.$ac_ext < +#include + +int main() { + return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); +; return 0; } +EOF +if { (eval echo configure:2108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding GTK+ or finding the wrong" + echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means GTK+ was incorrectly installed" + echo "*** or that you have moved GTK+ since it was installed. In the latter case, you" + echo "*** may want to edit the pkg-config script: $PKG_CONFIG" +fi +rm -f conftest* + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + GTK_CFLAGS="" + GTK_LIBS="" + echo "configure: warning: Building without GTK2 display support" 1>&2 + cat >> confdefs.h <<\EOF +#define NO_GTK 1 +EOF + + GTK_OBJ="" + fi + + + rm -f conf.gtktest + + else + # Check whether --with-gtk-prefix or --without-gtk-prefix was given. if test "${with_gtk_prefix+set}" = set; then withval="$with_gtk_prefix" gtk_config_prefix="$withval" @@ -1915,7 +2193,7 @@ # Extract the first word of "gtk-config", so it can be a program name with args. set dummy gtk-config; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1919: checking for $ac_word" >&5 +echo "configure:2197: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_GTK_CONFIG'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1950,7 +2228,7 @@ min_gtk_version=1.0.0 echo $ac_n "checking for GTK - version >= $min_gtk_version""... $ac_c" 1>&6 -echo "configure:1954: checking for GTK - version >= $min_gtk_version" >&5 +echo "configure:2232: checking for GTK - version >= $min_gtk_version" >&5 no_gtk="" if test "$GTK_CONFIG" = "no" ; then no_gtk=yes @@ -1973,7 +2251,7 @@ echo $ac_n "cross compiling; assumed OK... $ac_c" else cat > conftest.$ac_ext < @@ -2051,7 +2329,7 @@ } EOF -if { (eval echo configure:2055: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2070,7 +2348,7 @@ if test "x$no_gtk" = x ; then echo "$ac_t""yes" 1>&6 CFLAGS="$CFLAGS $GTK_CFLAGS" - LIBS="$LIBS $GTK_LIBS" + LIBS="$LIBS $GTK_LIBS" else echo "$ac_t""no" 1>&6 if test "$GTK_CONFIG" = "no" ; then @@ -2086,7 +2364,7 @@ CFLAGS="$CFLAGS $GTK_CFLAGS" LIBS="$LIBS $GTK_LIBS" cat > conftest.$ac_ext < @@ -2096,7 +2374,7 @@ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ; return 0; } EOF -if { (eval echo configure:2100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2378: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding GTK or finding the wrong" @@ -2129,16 +2407,17 @@ GTK_CFLAGS="" GTK_LIBS="" echo "configure: warning: Building without GTK+ display support" 1>&2 - cat >> confdefs.h <<\EOF + cat >> confdefs.h <<\EOF #define NO_GTK 1 EOF - GTK_OBJ="" + GTK_OBJ="" fi rm -f conf.gtktest + fi else cat >> confdefs.h <<\EOF #define NO_GTK 1 @@ -2148,12 +2427,12 @@ fi echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:2152: checking for socket" >&5 +echo "configure:2431: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else @@ -2194,7 +2473,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:2198: checking for socket in -lsocket" >&5 +echo "configure:2477: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2202,7 +2481,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2496: \"$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 @@ -2245,12 +2524,12 @@ echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:2249: checking for gethostbyname" >&5 +echo "configure:2528: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -2291,7 +2570,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:2295: checking for gethostbyname in -lnsl" >&5 +echo "configure:2574: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2299,7 +2578,7 @@ ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2593: \"$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 @@ -2348,12 +2627,12 @@ for ac_func in seteuid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2352: checking for $ac_func" >&5 +echo "configure:2631: 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 <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2659: \"$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 @@ -2403,12 +2682,12 @@ # AC_CHECK_FUNC(setuid, , AC_MSG_ERROR (I Need either seteuid or setuid)) echo $ac_n "checking for res_mkquery""... $ac_c" 1>&6 -echo "configure:2407: checking for res_mkquery" >&5 +echo "configure:2686: checking for res_mkquery" >&5 if eval "test \"`echo '$''{'ac_cv_func_res_mkquery'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2714: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_res_mkquery=yes" else @@ -2449,7 +2728,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for res_mkquery in -lbind""... $ac_c" 1>&6 -echo "configure:2453: checking for res_mkquery in -lbind" >&5 +echo "configure:2732: checking for res_mkquery in -lbind" >&5 ac_lib_var=`echo bind'_'res_mkquery | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2457,7 +2736,7 @@ ac_save_LIBS="$LIBS" LIBS="-lbind $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2751: \"$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 @@ -2494,7 +2773,7 @@ else echo "$ac_t""no" 1>&6 echo $ac_n "checking for res_mkquery in -lresolv""... $ac_c" 1>&6 -echo "configure:2498: checking for res_mkquery in -lresolv" >&5 +echo "configure:2777: checking for res_mkquery in -lresolv" >&5 ac_lib_var=`echo resolv'_'res_mkquery | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2502,7 +2781,7 @@ ac_save_LIBS="$LIBS" LIBS="-lresolv $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2796: \"$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 @@ -2547,12 +2826,12 @@ echo $ac_n "checking for herror""... $ac_c" 1>&6 -echo "configure:2551: checking for herror" >&5 +echo "configure:2830: checking for herror" >&5 if eval "test \"`echo '$''{'ac_cv_func_herror'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2858: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_herror=yes" else @@ -2599,12 +2878,12 @@ fi echo $ac_n "checking for strerror""... $ac_c" 1>&6 -echo "configure:2603: checking for strerror" >&5 +echo "configure:2882: checking for strerror" >&5 if eval "test \"`echo '$''{'ac_cv_func_strerror'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2910: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_strerror=yes" else @@ -2653,7 +2932,7 @@ echo $ac_n "checking for C flags to get more warnings""... $ac_c" 1>&6 -echo "configure:2657: checking for C flags to get more warnings" >&5 +echo "configure:2936: checking for C flags to get more warnings" >&5 ac_save_CFLAGS="$CFLAGS" if test "x$ac_cv_prog_gcc" = "xyes" ; then warning_CFLAGS="-Wall" @@ -2662,14 +2941,14 @@ irix*) CFLAGS="$CFLAGS -fullwarn" cat > conftest.$ac_ext < int main() { printf("test"); ; return 0; } EOF -if { (eval echo configure:2673: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2952: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* warning_CFLAGS="-fullwarn" else @@ -2683,14 +2962,14 @@ if "$CC" = "acc" ; then CFLAGS="$CFLAGS -vc" cat > conftest.$ac_ext < int main() { printf("test"); ; return 0; } EOF -if { (eval echo configure:2694: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2973: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* warning_CFLAGS="-vc" else @@ -2881,9 +3160,10 @@ s%@am__quote@%$am__quote%g s%@CCDEPMODE@%$CCDEPMODE%g s%@CPP@%$CPP%g -s%@GTK_CONFIG@%$GTK_CONFIG%g +s%@PKG_CONFIG@%$PKG_CONFIG%g s%@GTK_CFLAGS@%$GTK_CFLAGS%g s%@GTK_LIBS@%$GTK_LIBS%g +s%@GTK_CONFIG@%$GTK_CONFIG%g CEOF EOF diff -ur mtr-0.60/configure.in mtr-0.61/configure.in --- mtr-0.60/configure.in Tue Aug 10 23:21:48 2004 +++ mtr-0.61/configure.in Tue Aug 10 23:25:06 2004 @@ -1,5 +1,5 @@ AC_INIT(mtr.c) -AM_INIT_AUTOMAKE(mtr, 0.60) +AM_INIT_AUTOMAKE(mtr, 0.61) AC_SUBST(GTK_OBJ) diff -ur mtr-0.60/curses.c mtr-0.61/curses.c --- mtr-0.60/curses.c Tue Aug 10 09:45:37 2004 +++ mtr-0.61/curses.c Wed Aug 11 13:25:25 2004 @@ -23,6 +23,9 @@ #include #include #include +#include +#include +#include #if defined(HAVE_NCURSES_H) # include @@ -471,6 +474,7 @@ int hd_len = 0; char buf[1024]; char fmt[16]; + erase(); getmaxyx(stdscr, maxy, maxx); @@ -482,7 +486,7 @@ pwcenter("My traceroute [v" VERSION "]"); attroff(A_BOLD); - mvprintw(1, 0, "%s", LocalHostname); + mvprintw(1, 0, "%s (%s)", LocalHostname, inet_ntoa(*net_localaddr())); printw("(tos=0x%X ", tos); printw("psize=%d ", abs(packetsize) ); printw("bitpattern=0x%02X)", (unsigned char)(abs(bitpattern))); diff -ur mtr-0.60/dns.c mtr-0.61/dns.c --- mtr-0.60/dns.c Wed Apr 7 14:33:55 2004 +++ mtr-0.61/dns.c Wed Aug 11 13:37:37 2004 @@ -280,9 +280,10 @@ char nullstring[] = ""; -/* Code */ +int use_dns = 1; +/* Code */ #ifdef CorruptCheck #define TOT_SLACK 2 #define HEAD_SLACK 1 @@ -301,925 +302,982 @@ void *statmalloc(size_t size) { - void *p; - size_t mallocsize; - mem+= size; - mallocsize = size + TOT_SLACK * sizeof(dword); - - p = malloc(mallocsize); - if (!p) { - fprintf(stderr,"malloc() of %u bytes failed: %s\n", (unsigned int)size, strerror(errno)); - exit(-1); - } - *((dword *)p) = (dword)size; + void *p; + size_t mallocsize; + + mem+= size; + mallocsize = size + TOT_SLACK * sizeof(dword); + + p = malloc(mallocsize); + if (!p) { + fprintf(stderr,"malloc() of %u bytes failed: %s\n", (unsigned int)size, strerror(errno)); + exit(-1); + } + *((dword *)p) = (dword)size; #ifdef CorruptCheck - *(byte *)((char *)p + size + sizeof(dword) + sizeof(byte) * 0) = 0xde; - *(byte *)((char *)p + size + sizeof(dword) + sizeof(byte) * 1) = 0xad; - *(byte *)((char *)p + size + sizeof(dword) + sizeof(byte) * 2) = 0xbe; - *(byte *)((char *)p + size + sizeof(dword) + sizeof(byte) * 3) = 0xef; + *(byte *)((char *)p + size + sizeof(dword) + sizeof(byte) * 0) = 0xde; + *(byte *)((char *)p + size + sizeof(dword) + sizeof(byte) * 1) = 0xad; + *(byte *)((char *)p + size + sizeof(dword) + sizeof(byte) * 2) = 0xbe; + *(byte *)((char *)p + size + sizeof(dword) + sizeof(byte) * 3) = 0xef; #endif - p = (void *)((dword *)p + HEAD_SLACK); + p = (void *)((dword *)p + HEAD_SLACK); #ifdef WipeMallocs - memset(p,0xf0,size); + memset(p,0xf0,size); #endif - return p; + return p; } + void statfree(void *p) { - if (p) { - if (*((dword *)p - HEAD_SLACK) == 0) { - fprintf(stderr,"ERROR: Attempt to free pointer twice.\n"); - *(int*)0=0; - exit(-1); - } else { - if (*((dword *)p - HEAD_SLACK) > 8192) { - fprintf(stderr,"ERROR: Corrupted free() buffer. (header)\n"); - *(int*)0=0; - exit(-1); - } + if (p) { + if (*((dword *)p - HEAD_SLACK) == 0) { + fprintf(stderr,"ERROR: Attempt to free pointer twice.\n"); + *(int*)0=0; + exit(-1); + } else { + if (*((dword *)p - HEAD_SLACK) > 8192) { + fprintf (stderr,"ERROR: Corrupted free() buffer. (header)\n"); + *(int*)0=0; + exit(-1); + } #ifdef CorruptCheck - if ((*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 0) != 0xde) || - (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 1) != 0xad) || - (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 2) != 0xbe) || - (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 3) != 0xef)) { - fprintf(stderr,"ERROR: Corrupted free() buffer. (footer)\n"); - *(int*)0=0; - exit(-1); - } + if ((*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 0) != 0xde) || + (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 1) != 0xad) || + (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 2) != 0xbe) || + (*(byte *)((char *)p + (*((dword *)p - 1)) + sizeof(byte) * 3) != 0xef)) { + fprintf(stderr,"ERROR: Corrupted free() buffer. (footer)\n"); + *(int*)0=0; + exit(-1); + } #endif - mem-= *((dword *)p - HEAD_SLACK); + mem-= *((dword *)p - HEAD_SLACK); #ifdef WipeFrees - memset(p,0xfe,*((dword *)p - HEAD_SLACK)); - *((dword *)p - 1) = 0; + memset(p,0xfe,*((dword *)p - HEAD_SLACK)); + *((dword *)p - 1) = 0; #endif - free((dword *)p - HEAD_SLACK); - } - } + free((dword *)p - HEAD_SLACK); + } + } } + char *strtdiff(char *d,long signeddiff) { - dword diff; - dword seconds,minutes,hours; - long days; - if ((diff = labs(signeddiff))) { - seconds = diff % 60; diff/= 60; - minutes = diff % 60; diff/= 60; - hours = diff % 24; - days = signeddiff / (60 * 60 * 24); - if (days) - sprintf(d,"%lid",days); - else - *d = '\0'; - if (hours) - sprintf(d + strlen(d),"%luh",hours); - if (minutes) - sprintf(d + strlen(d),"%lum",minutes); - if (seconds) - sprintf(d + strlen(d),"%lus",seconds); - } else - sprintf(d,"0s"); - return d; + dword diff; + dword seconds,minutes,hours; + long days; + + if ((diff = labs(signeddiff))) { + seconds = diff % 60; diff/= 60; + minutes = diff % 60; diff/= 60; + hours = diff % 24; + days = signeddiff / (60 * 60 * 24); + if (days) + sprintf(d,"%lid",days); + else + *d = '\0'; + if (hours) + sprintf(d + strlen(d),"%luh",hours); + if (minutes) + sprintf(d + strlen(d),"%lum",minutes); + if (seconds) + sprintf(d + strlen(d),"%lus",seconds); + } else + sprintf(d,"0s"); + return d; } + int issetfd(fd_set *set,int fd) { - return (int)((FD_ISSET(fd,set)) && 1); + return (int)((FD_ISSET(fd,set)) && 1); } + void setfd(fd_set *set,int fd) { - FD_SET(fd,set); + FD_SET(fd,set); } + void clearfd(fd_set *set,int fd) { - FD_CLR(fd,set); + FD_CLR(fd,set); } + void clearset(fd_set *set) { - FD_ZERO(set); + FD_ZERO(set); } + char *strlongip(ip_t ip) { - struct in_addr a; - a.s_addr = htonl(ip); - return inet_ntoa(a); + struct in_addr a; + a.s_addr = htonl(ip); + return inet_ntoa(a); } + ip_t longipstr(char *s) { - return inet_addr(s); + return inet_addr(s); } + int dns_forward(char *name) { - struct hostent *host; - if ((host = gethostbyname(name))) - return *(int *)host->h_addr; - else - return 0; + struct hostent *host; + + if ((host = gethostbyname(name))) + return *(int *)host->h_addr; + else + return 0; } + int dns_waitfd(void) { - return resfd; + return resfd; } + void dns_open(void) { - int option,i; + int option,i; - res_init(); - if (!_res.nscount) { - fprintf(stderr,"No nameservers defined.\n"); - exit(-1); - } - _res.options|= RES_RECURSE | RES_DEFNAMES | RES_DNSRCH; - for (i = 0;i < _res.nscount;i++) - _res.nsaddr_list[i].sin_family = AF_INET; - resfd = socket(AF_INET, SOCK_DGRAM, 0); - if (resfd == -1) { - fprintf(stderr,"Unable to allocate socket for nameserver communication: %s\n", - strerror(errno)); - exit(-1); - } - option = 1; - if (setsockopt(resfd,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) { - fprintf(stderr,"Unable to setsockopt() on nameserver communication socket: %s\n", - strerror(errno)); - exit(-1); - } - localhost = longipstr("127.0.0.1"); - aseed = time(NULL) ^ (time(NULL) << 3) ^ (dword)getpid(); - for (i = 0;i < BashSize;i++) { - idbash[i] = NULL; - hostbash[i] = NULL; - } + res_init(); + if (!_res.nscount) { + fprintf(stderr,"No nameservers defined.\n"); + exit(-1); + } + _res.options|= RES_RECURSE | RES_DEFNAMES | RES_DNSRCH; + for (i = 0;i < _res.nscount;i++) + _res.nsaddr_list[i].sin_family = AF_INET; + resfd = socket(AF_INET, SOCK_DGRAM, 0); + if (resfd == -1) { + fprintf(stderr,"Unable to allocate socket for nameserver communication: %s\n", + strerror(errno)); + exit(-1); + } + option = 1; + if (setsockopt(resfd,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) { + fprintf(stderr,"Unable to setsockopt() on nameserver communication socket: %s\n", + strerror(errno)); + exit(-1); + } + localhost = longipstr("127.0.0.1"); + aseed = time(NULL) ^ (time(NULL) << 3) ^ (dword)getpid(); + for (i = 0;i < BashSize;i++) { + idbash[i] = NULL; + hostbash[i] = NULL; + } } + struct resolve *allocresolve(void) { - struct resolve *rp; - rp = (struct resolve *)statmalloc(sizeof(struct resolve)); - if (!rp) { - fprintf(stderr,"statmalloc() failed: %s\n",strerror(errno)); - exit(-1); - } - memset(rp,0, sizeof(struct resolve)); - return rp; + struct resolve *rp; + + rp = (struct resolve *)statmalloc(sizeof(struct resolve)); + if (!rp) { + fprintf(stderr,"statmalloc() failed: %s\n",strerror(errno)); + exit(-1); + } + memset(rp,0, sizeof(struct resolve)); + return rp; } + dword getidbash(word id) { - return (dword)BashModulo(id); + return (dword)BashModulo(id); } + dword getipbash(ip_t ip) { - return (dword)BashModulo(ip); + return (dword)BashModulo(ip); } + dword gethostbash(char *host) { - dword bashvalue = 0; - for (;*host;host++) { - bashvalue^= *host; - bashvalue+= (*host >> 1) + (bashvalue >> 1); - } - return BashModulo(bashvalue); + dword bashvalue = 0; + + for (;*host;host++) { + bashvalue^= *host; + bashvalue+= (*host >> 1) + (bashvalue >> 1); + } + return BashModulo(bashvalue); } + void linkresolveid(struct resolve *addrp) { - struct resolve *rp; - dword bashnum; - bashnum = getidbash(addrp->id); - rp = idbash[bashnum]; - if (rp) { - while ((rp->nextid) && (addrp->id > rp->nextid->id)) - rp = rp->nextid; - while ((rp->previousid) && (addrp->id < rp->previousid->id)) - rp = rp->previousid; - if (rp->id < addrp->id) { - addrp->previousid = rp; - addrp->nextid = rp->nextid; - if (rp->nextid) - rp->nextid->previousid = addrp; - rp->nextid = addrp; - } else { - addrp->previousid = rp->previousid; - addrp->nextid = rp; - if (rp->previousid) - rp->previousid->nextid = addrp; - rp->previousid = addrp; - } - } else - addrp->nextid = addrp->previousid = NULL; - idbash[bashnum] = addrp; + struct resolve *rp; + dword bashnum; + + bashnum = getidbash(addrp->id); + rp = idbash[bashnum]; + if (rp) { + while ((rp->nextid) && (addrp->id > rp->nextid->id)) + rp = rp->nextid; + while ((rp->previousid) && (addrp->id < rp->previousid->id)) + rp = rp->previousid; + if (rp->id < addrp->id) { + addrp->previousid = rp; + addrp->nextid = rp->nextid; + if (rp->nextid) + rp->nextid->previousid = addrp; + rp->nextid = addrp; + } else { + addrp->previousid = rp->previousid; + addrp->nextid = rp; + if (rp->previousid) + rp->previousid->nextid = addrp; + rp->previousid = addrp; + } + } else + addrp->nextid = addrp->previousid = NULL; + idbash[bashnum] = addrp; } + void unlinkresolveid(struct resolve *rp) { - dword bashnum; - bashnum = getidbash(rp->id); - if (idbash[bashnum] == rp) - idbash[bashnum] = (rp->previousid)? rp->previousid : rp->nextid; - if (rp->nextid) - rp->nextid->previousid = rp->previousid; - if (rp->previousid) - rp->previousid->nextid = rp->nextid; + dword bashnum; + + bashnum = getidbash(rp->id); + if (idbash[bashnum] == rp) + idbash[bashnum] = (rp->previousid)? rp->previousid : rp->nextid; + if (rp->nextid) + rp->nextid->previousid = rp->previousid; + if (rp->previousid) + rp->previousid->nextid = rp->nextid; } + void linkresolvehost(struct resolve *addrp) { - struct resolve *rp; - dword bashnum; - bashnum = gethostbash(addrp->hostname); - rp = hostbash[bashnum]; - if (rp) { - while ((rp->nexthost) && (strcasecmp(addrp->hostname,rp->nexthost->hostname) < 0)) - rp = rp->nexthost; - while ((rp->previoushost) && (strcasecmp(addrp->hostname,rp->previoushost->hostname) > 0)) - rp = rp->previoushost; - if (strcasecmp(addrp->hostname,rp->hostname) < 0) { - addrp->previoushost = rp; - addrp->nexthost = rp->nexthost; - if (rp->nexthost) - rp->nexthost->previoushost = addrp; - rp->nexthost = addrp; - } else { - addrp->previoushost = rp->previoushost; - addrp->nexthost = rp; - if (rp->previoushost) - rp->previoushost->nexthost = addrp; - rp->previoushost = addrp; - } - } else - addrp->nexthost = addrp->previoushost = NULL; - hostbash[bashnum] = addrp; + struct resolve *rp; + dword bashnum; + + bashnum = gethostbash(addrp->hostname); + rp = hostbash[bashnum]; + if (rp) { + while ((rp->nexthost) && (strcasecmp(addrp->hostname,rp->nexthost->hostname) < 0)) + rp = rp->nexthost; + while ((rp->previoushost) && (strcasecmp(addrp->hostname,rp->previoushost->hostname) > 0)) + rp = rp->previoushost; + if (strcasecmp(addrp->hostname,rp->hostname) < 0) { + addrp->previoushost = rp; + addrp->nexthost = rp->nexthost; + if (rp->nexthost) + rp->nexthost->previoushost = addrp; + rp->nexthost = addrp; + } else { + addrp->previoushost = rp->previoushost; + addrp->nexthost = rp; + if (rp->previoushost) + rp->previoushost->nexthost = addrp; + rp->previoushost = addrp; + } + } else + addrp->nexthost = addrp->previoushost = NULL; + hostbash[bashnum] = addrp; } + void unlinkresolvehost(struct resolve *rp) { - dword bashnum; - bashnum = gethostbash(rp->hostname); - if (hostbash[bashnum] == rp) - hostbash[bashnum] = (rp->previoushost)? rp->previoushost : rp->nexthost; - if (rp->nexthost) - rp->nexthost->previoushost = rp->previoushost; - if (rp->previoushost) - rp->previoushost->nexthost = rp->nexthost; - statfree(rp->hostname); + dword bashnum; + + bashnum = gethostbash(rp->hostname); + if (hostbash[bashnum] == rp) + hostbash[bashnum] = (rp->previoushost)? rp->previoushost : rp->nexthost; + if (rp->nexthost) + rp->nexthost->previoushost = rp->previoushost; + if (rp->previoushost) + rp->previoushost->nexthost = rp->nexthost; + statfree(rp->hostname); } + void linkresolveip(struct resolve *addrp) { - struct resolve *rp; - dword bashnum; - bashnum = getipbash(addrp->ip); - rp = ipbash[bashnum]; - if (rp) { - while ((rp->nextip) && (addrp->ip > rp->nextip->ip)) - rp = rp->nextip; - while ((rp->previousip) && (addrp->ip < rp->previousip->ip)) - rp = rp->previousip; - if (rp->ip < addrp->ip) { - addrp->previousip = rp; - addrp->nextip = rp->nextip; - if (rp->nextip) - rp->nextip->previousip = addrp; - rp->nextip = addrp; - } else { - addrp->previousip = rp->previousip; - addrp->nextip = rp; - if (rp->previousip) - rp->previousip->nextip = addrp; - rp->previousip = addrp; - } - } else - addrp->nextip = addrp->previousip = NULL; - ipbash[bashnum] = addrp; + struct resolve *rp; + dword bashnum; + + bashnum = getipbash(addrp->ip); + rp = ipbash[bashnum]; + if (rp) { + while ((rp->nextip) && (addrp->ip > rp->nextip->ip)) + rp = rp->nextip; + while ((rp->previousip) && (addrp->ip < rp->previousip->ip)) + rp = rp->previousip; + if (rp->ip < addrp->ip) { + addrp->previousip = rp; + addrp->nextip = rp->nextip; + if (rp->nextip) + rp->nextip->previousip = addrp; + rp->nextip = addrp; + } else { + addrp->previousip = rp->previousip; + addrp->nextip = rp; + if (rp->previousip) + rp->previousip->nextip = addrp; + rp->previousip = addrp; + } + } else + addrp->nextip = addrp->previousip = NULL; + ipbash[bashnum] = addrp; } + void unlinkresolveip(struct resolve *rp) { - dword bashnum; - bashnum = getipbash(rp->ip); - if (ipbash[bashnum] == rp) - ipbash[bashnum] = (rp->previousip)? rp->previousip : rp->nextip; - if (rp->nextip) - rp->nextip->previousip = rp->previousip; - if (rp->previousip) - rp->previousip->nextip = rp->nextip; + dword bashnum; + + bashnum = getipbash(rp->ip); + if (ipbash[bashnum] == rp) + ipbash[bashnum] = (rp->previousip)? rp->previousip : rp->nextip; + if (rp->nextip) + rp->nextip->previousip = rp->previousip; + if (rp->previousip) + rp->previousip->nextip = rp->nextip; } + void linkresolve(struct resolve *rp) { - struct resolve *irp; - if (expireresolves) { - irp = expireresolves; - while ((irp->next) && (rp->expiretime >= irp->expiretime)) irp = irp->next; - if (rp->expiretime >= irp->expiretime) { - rp->next = NULL; - rp->previous = irp; - irp->next = rp; - lastresolve = rp; - } else { - rp->previous = irp->previous; - rp->next = irp; - if (irp->previous) - irp->previous->next = rp; - else - expireresolves = rp; - irp->previous = rp; - } - } else { + struct resolve *irp; + + if (expireresolves) { + irp = expireresolves; + while ((irp->next) && (rp->expiretime >= irp->expiretime)) irp = irp->next; + if (rp->expiretime >= irp->expiretime) { rp->next = NULL; - rp->previous = NULL; - expireresolves = lastresolve = rp; - } - resolvecount++; + rp->previous = irp; + irp->next = rp; + lastresolve = rp; + } else { + rp->previous = irp->previous; + rp->next = irp; + if (irp->previous) + irp->previous->next = rp; + else + expireresolves = rp; + irp->previous = rp; + } + } else { + rp->next = NULL; + rp->previous = NULL; + expireresolves = lastresolve = rp; + } + resolvecount++; } + void lastlinkresolve(struct resolve *rp) { - struct resolve *irp; - if (lastresolve) { - irp = lastresolve; - while ((irp->previous) && (rp->expiretime < irp->expiretime)) irp = irp->previous; - while ((irp->next) && (rp->expiretime >= irp->expiretime)) irp = irp->next; - if (rp->expiretime >= irp->expiretime) { - rp->next = NULL; - rp->previous = irp; - irp->next = rp; - lastresolve = rp; - } else { - rp->previous = irp->previous; - rp->next = irp; - if (irp->previous) - irp->previous->next = rp; - else - expireresolves = rp; - irp->previous = rp; - } - } else { + struct resolve *irp; + + if (lastresolve) { + irp = lastresolve; + while ((irp->previous) && (rp->expiretime < irp->expiretime)) irp = irp->previous; + while ((irp->next) && (rp->expiretime >= irp->expiretime)) irp = irp->next; + if (rp->expiretime >= irp->expiretime) { rp->next = NULL; - rp->previous = NULL; - expireresolves = lastresolve = rp; - } - resolvecount++; + rp->previous = irp; + irp->next = rp; + lastresolve = rp; + } else { + rp->previous = irp->previous; + rp->next = irp; + if (irp->previous) + irp->previous->next = rp; + else + expireresolves = rp; + irp->previous = rp; + } + } else { + rp->next = NULL; + rp->previous = NULL; + expireresolves = lastresolve = rp; + } + resolvecount++; } + void untieresolve(struct resolve *rp) { - if (rp->previous) - rp->previous->next = rp->next; - else - expireresolves = rp->next; - if (rp->next) - rp->next->previous = rp->previous; - else - lastresolve = rp->previous; - resolvecount--; + if (rp->previous) + rp->previous->next = rp->next; + else + expireresolves = rp->next; + if (rp->next) + rp->next->previous = rp->previous; + else + lastresolve = rp->previous; + resolvecount--; } + void unlinkresolve(struct resolve *rp) { - untieresolve(rp); - unlinkresolveid(rp); - unlinkresolveip(rp); - if (rp->hostname) - unlinkresolvehost(rp); + untieresolve(rp); + unlinkresolveid(rp); + unlinkresolveip(rp); + if (rp->hostname) + unlinkresolvehost(rp); } + struct resolve *findid(word id) { - struct resolve *rp; - int bashnum; - bashnum = getidbash(id); - rp = idbash[bashnum]; - if (rp) { - while ((rp->nextid) && (id >= rp->nextid->id)) - rp = rp->nextid; - while ((rp->previousid) && (id <= rp->previousid->id)) - rp = rp->previousid; - if (id == rp->id) { - idbash[bashnum] = rp; - return rp; - } else - return NULL; - } - return rp; /* NULL */ + struct resolve *rp; + int bashnum; + + bashnum = getidbash(id); + rp = idbash[bashnum]; + if (rp) { + while ((rp->nextid) && (id >= rp->nextid->id)) + rp = rp->nextid; + while ((rp->previousid) && (id <= rp->previousid->id)) + rp = rp->previousid; + if (id == rp->id) { + idbash[bashnum] = rp; + return rp; + } else + return NULL; + } + return rp; /* NULL */ } + struct resolve *findhost(char *hostname) { - struct resolve *rp; - int bashnum; - bashnum = gethostbash(hostname); - rp = hostbash[bashnum]; - if (rp) { - while ((rp->nexthost) && (strcasecmp(hostname,rp->nexthost->hostname) >= 0)) - rp = rp->nexthost; - while ((rp->previoushost) && (strcasecmp(hostname,rp->nexthost->hostname) <= 0)) - rp = rp->previoushost; - if (strcasecmp(hostname,rp->hostname)) - return NULL; - else { - hostbash[bashnum] = rp; - return rp; - } - } - return rp; /* NULL */ + struct resolve *rp; + int bashnum; + + bashnum = gethostbash(hostname); + rp = hostbash[bashnum]; + if (rp) { + while ((rp->nexthost) && (strcasecmp(hostname,rp->nexthost->hostname) >= 0)) + rp = rp->nexthost; + while ((rp->previoushost) && (strcasecmp(hostname,rp->nexthost->hostname) <= 0)) + rp = rp->previoushost; + if (strcasecmp(hostname,rp->hostname)) + return NULL; + else { + hostbash[bashnum] = rp; + return rp; + } + } + return rp; /* NULL */ } + struct resolve *findip(ip_t ip) { - struct resolve *rp; - dword bashnum; - bashnum = getipbash(ip); - rp = ipbash[bashnum]; - if (rp) { - while ((rp->nextip) && (ip >= rp->nextip->ip)) - rp = rp->nextip; - while ((rp->previousip) && (ip <= rp->previousip->ip)) - rp = rp->previousip; - if (ip == rp->ip) { - ipbash[bashnum] = rp; - return rp; - } else - return NULL; - } - return rp; /* NULL */ + struct resolve *rp; + dword bashnum; + + bashnum = getipbash(ip); + rp = ipbash[bashnum]; + if (rp) { + while ((rp->nextip) && (ip >= rp->nextip->ip)) + rp = rp->nextip; + while ((rp->previousip) && (ip <= rp->previousip->ip)) + rp = rp->previousip; + if (ip == rp->ip) { + ipbash[bashnum] = rp; + return rp; + } else + return NULL; + } + return rp; /* NULL */ } + void restell(char *s) { - fputs(s,stderr); - fputs("\r",stderr); + fputs(s,stderr); + fputs("\r",stderr); } + void dorequest(char *s,int type,word id) { - packetheader *hp; - int r,i; - int buf[(MaxPacketsize/sizeof (int))+1]; - r = res_mkquery(QUERY,s,C_IN,type,NULL,0,NULL,(unsigned char*)buf,MaxPacketsize); - if (r == -1) { - restell("Resolver error: Query too large."); - return; - } - hp = (packetheader *)buf; - hp->id = id; /* htons() deliberately left out (redundant) */ - for (i = 0;i < _res.nscount;i++) - (void)sendto(resfd,buf,r,0,(struct sockaddr *)&_res.nsaddr_list[i], - sizeof(struct sockaddr)); + packetheader *hp; + int r,i; + int buf[(MaxPacketsize/sizeof (int))+1]; + + r = res_mkquery(QUERY,s,C_IN,type,NULL,0,NULL,(unsigned char*)buf,MaxPacketsize); + if (r == -1) { + restell("Resolver error: Query too large."); + return; + } + hp = (packetheader *)buf; + hp->id = id; /* htons() deliberately left out (redundant) */ + for (i = 0;i < _res.nscount;i++) + (void)sendto(resfd,buf,r,0,(struct sockaddr *)&_res.nsaddr_list[i], + sizeof(struct sockaddr)); } void resendrequest(struct resolve *rp,int type) { - if (type == T_A) { - dorequest(rp->hostname,type,rp->id); - if (debug) { - sprintf(tempstring,"Resolver: Sent reverse authentication request for \"%s\".", - rp->hostname); - restell(tempstring); - } - } else if (type == T_PTR) { - sprintf(tempstring,"%u.%u.%u.%u.in-addr.arpa", - ((byte *)&rp->ip)[3], - ((byte *)&rp->ip)[2], - ((byte *)&rp->ip)[1], - ((byte *)&rp->ip)[0]); - dorequest(tempstring,type,rp->id); - if (debug) { - sprintf(tempstring,"Resolver: Sent domain lookup request for \"%s\".", - strlongip(rp->ip)); - restell(tempstring); - } - } + if (type == T_A) { + dorequest(rp->hostname,type,rp->id); + if (debug) { + sprintf(tempstring,"Resolver: Sent reverse authentication request for \"%s\".", + rp->hostname); + restell(tempstring); + } + } else if (type == T_PTR) { + sprintf(tempstring,"%u.%u.%u.%u.in-addr.arpa", + ((byte *)&rp->ip)[3], + ((byte *)&rp->ip)[2], + ((byte *)&rp->ip)[1], + ((byte *)&rp->ip)[0]); + dorequest(tempstring,type,rp->id); + if (debug) { + sprintf(tempstring,"Resolver: Sent domain lookup request for \"%s\".", + strlongip(rp->ip)); + restell(tempstring); + } + } } void sendrequest(struct resolve *rp,int type) { - do { - idseed = (((idseed + idseed) | (long)time(NULL)) + idseed - 0x54bad4a) ^ aseed; - aseed^= idseed; - rp->id = (word)idseed; - } while (findid(rp->id)); - linkresolveid(rp); - resendrequest(rp,type); + do { + idseed = (((idseed + idseed) | (long)time(NULL)) + idseed - 0x54bad4a) ^ aseed; + aseed^= idseed; + rp->id = (word)idseed; + } while (findid(rp->id)); + linkresolveid(rp); + resendrequest(rp,type); } + void failrp(struct resolve *rp) { - if (rp->state == STATE_FINISHED) - return; - rp->state = STATE_FAILED; - untieresolve(rp); - if (debug) - restell("Resolver: Lookup failed.\n"); + if (rp->state == STATE_FINISHED) + return; + rp->state = STATE_FAILED; + untieresolve(rp); + if (debug) + restell("Resolver: Lookup failed.\n"); } + void passrp(struct resolve *rp,long ttl) { - rp->state = STATE_FINISHED; - rp->expiretime = sweeptime + (double)ttl; - untieresolve(rp); - if (debug) { - sprintf(tempstring,"Resolver: Lookup successful: %s\n",rp->hostname); - restell(tempstring); - } + rp->state = STATE_FINISHED; + rp->expiretime = sweeptime + (double)ttl; + untieresolve(rp); + if (debug) { + sprintf(tempstring,"Resolver: Lookup successful: %s\n",rp->hostname); + restell(tempstring); + } } + void parserespacket(byte *s,int l) { - struct resolve *rp; - packetheader *hp; - byte *eob; - byte *c; - long ttl; - int r,usefulanswer; - word rr,datatype,class,qdatatype,qclass; - byte rdatalength; - if (l < sizeof(packetheader)) { - restell("Resolver error: Packet smaller than standard header size."); - return; - } - if (l == sizeof(packetheader)) { - restell("Resolver error: Packet has empty body."); - return; - } - hp = (packetheader *)s; - /* Convert data to host byte order */ - /* hp->id does not need to be redundantly byte-order flipped, it is only echoed by nameserver */ - rp = findid(hp->id); - if (!rp) { - res_unknownid++; - return; - } - if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)) - return; - hp->qdcount = ntohs(hp->qdcount); - hp->ancount = ntohs(hp->ancount); - hp->nscount = ntohs(hp->nscount); - hp->arcount = ntohs(hp->arcount); - if (getheader_tc(hp)) { /* Packet truncated */ - restell("Resolver error: Nameserver packet truncated."); - return; - } - if (!getheader_qr(hp)) { /* Not a reply */ - restell("Resolver error: Query packet received on nameserver communication socket."); - return; - } - if (getheader_opcode(hp)) { /* Not opcode 0 (standard query) */ - restell("Resolver error: Invalid opcode in response packet."); - return; - } - eob = s + l; - c = s + HFIXEDSZ; - switch (getheader_rcode(hp)) { - case NOERROR: - if (hp->ancount) { - if (debug) { - sprintf(tempstring,"Resolver: Received nameserver reply. (qd:%u an:%u ns:%u ar:%u)", + struct resolve *rp; + packetheader *hp; + byte *eob; + byte *c; + long ttl; + int r,usefulanswer; + word rr,datatype,class,qdatatype,qclass; + byte rdatalength; + + if (l < sizeof(packetheader)) { + restell("Resolver error: Packet smaller than standard header size."); + return; + } + if (l == sizeof(packetheader)) { + restell("Resolver error: Packet has empty body."); + return; + } + hp = (packetheader *)s; + /* Convert data to host byte order */ + /* hp->id does not need to be redundantly byte-order flipped, it is only echoed by nameserver */ + rp = findid(hp->id); + if (!rp) { + res_unknownid++; + return; + } + if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)) + return; + hp->qdcount = ntohs(hp->qdcount); + hp->ancount = ntohs(hp->ancount); + hp->nscount = ntohs(hp->nscount); + hp->arcount = ntohs(hp->arcount); + if (getheader_tc(hp)) { /* Packet truncated */ + restell("Resolver error: Nameserver packet truncated."); + return; + } + if (!getheader_qr(hp)) { /* Not a reply */ + restell("Resolver error: Query packet received on nameserver communication socket."); + return; + } + if (getheader_opcode(hp)) { /* Not opcode 0 (standard query) */ + restell("Resolver error: Invalid opcode in response packet."); + return; + } + eob = s + l; + c = s + HFIXEDSZ; + switch (getheader_rcode(hp)) { + case NOERROR: + if (hp->ancount) { + if (debug) { + sprintf(tempstring,"Resolver: Received nameserver reply. (qd:%u an:%u ns:%u ar:%u)", hp->qdcount,hp->ancount,hp->nscount,hp->arcount); - restell(tempstring); - } - if (hp->qdcount != 1) { - restell("Resolver error: Reply does not contain one query."); - return; - } - if (c > eob) { - restell("Resolver error: Reply too short."); - return; - } - switch (rp->state) { /* Construct expected query reply */ - case STATE_PTRREQ1: - case STATE_PTRREQ2: - case STATE_PTRREQ3: - sprintf(stackstring,"%u.%u.%u.%u.in-addr.arpa", - ((byte *)&rp->ip)[3], - ((byte *)&rp->ip)[2], - ((byte *)&rp->ip)[1], - ((byte *)&rp->ip)[0]); - break; - } - *namestring = '\0'; - r = dn_expand(s,s + l,c,namestring,MAXDNAME); - if (r == -1) { - restell("Resolver error: dn_expand() failed while expanding query domain."); - return; - } - namestring[strlen(stackstring)] = '\0'; - if (strcasecmp(stackstring,namestring)) { - if (debug) { - sprintf(tempstring,"Resolver: Unknown query packet dropped. (\"%s\" does not match \"%s\")", - stackstring,namestring); - restell(tempstring); - } - return; - } - if (debug) { - sprintf(tempstring,"Resolver: Queried domain name: \"%s\"",namestring); - restell(tempstring); - } - c+= r; - if (c + 4 > eob) { - restell("Resolver error: Query resource record truncated."); - return; - } - qdatatype = sucknetword(c); - qclass = sucknetword(c); - if (qclass != C_IN) { - sprintf(tempstring,"Resolver error: Received unsupported query class: %u (%s)", + restell(tempstring); + } + if (hp->qdcount != 1) { + restell("Resolver error: Reply does not contain one query."); + return; + } + if (c > eob) { + restell("Resolver error: Reply too short."); + return; + } + switch (rp->state) { /* Construct expected query reply */ + case STATE_PTRREQ1: + case STATE_PTRREQ2: + case STATE_PTRREQ3: + sprintf(stackstring,"%u.%u.%u.%u.in-addr.arpa", + ((byte *)&rp->ip)[3], + ((byte *)&rp->ip)[2], + ((byte *)&rp->ip)[1], + ((byte *)&rp->ip)[0]); + break; + } + *namestring = '\0'; + r = dn_expand(s,s + l,c,namestring,MAXDNAME); + if (r == -1) { + restell("Resolver error: dn_expand() failed while expanding query domain."); + return; + } + namestring[strlen(stackstring)] = '\0'; + if (strcasecmp(stackstring,namestring)) { + if (debug) { + sprintf(tempstring,"Resolver: Unknown query packet dropped. (\"%s\" does not match \"%s\")", + stackstring,namestring); + restell(tempstring); + } + return; + } + if (debug) { + sprintf(tempstring,"Resolver: Queried domain name: \"%s\"",namestring); + restell(tempstring); + } + c+= r; + if (c + 4 > eob) { + restell("Resolver error: Query resource record truncated."); + return; + } + qdatatype = sucknetword(c); + qclass = sucknetword(c); + if (qclass != C_IN) { + sprintf(tempstring,"Resolver error: Received unsupported query class: %u (%s)", qclass,qclass < ClasstypeCount ? classtypes[qclass] : - classtypes[ClasstypeCount]); - restell(tempstring); - } - switch (qdatatype) { - case T_PTR: - if (!Is_PTR(rp)) - if (debug) { - restell("Resolver warning: Ignoring response with unexpected query type \"PTR\"."); - return; - } - break; - default: - sprintf(tempstring,"Resolver error: Received unimplemented query type: %u (%s)", - qdatatype,qdatatype < ResourcetypeCount ? - resourcetypes[qdatatype] : resourcetypes[ResourcetypeCount]); - restell(tempstring); - } - for (rr = hp->ancount + hp->nscount + hp->arcount;rr;rr--) { - if (c > eob) { - restell("Resolver error: Packet does not contain all specified resouce records."); - return; - } - *namestring = '\0'; - r = dn_expand(s,s + l,c,namestring,MAXDNAME); - if (r == -1) { - restell("Resolver error: dn_expand() failed while expanding answer domain."); - return; - } - namestring[strlen(stackstring)] = '\0'; - if (strcasecmp(stackstring,namestring)) - usefulanswer = 0; - else - usefulanswer = 1; - if (debug) { - sprintf(tempstring,"Resolver: answered domain query: \"%s\"",namestring); - restell(tempstring); - } - c+= r; - if (c + 10 > eob) { - restell("Resolver error: Resource record truncated."); - return; - } - datatype = sucknetword(c); - class = sucknetword(c); - ttl = sucknetlong(c); - rdatalength = sucknetword(c); - if (class != qclass) { - sprintf(tempstring,"query class: %u (%s)",qclass,qclass < ClasstypeCount ? - classtypes[qclass] : classtypes[ClasstypeCount]); - restell(tempstring); - sprintf(tempstring,"rr class: %u (%s)",class,class < ClasstypeCount ? - classtypes[class] : classtypes[ClasstypeCount]); - restell(tempstring); - restell("Resolver error: Answered class does not match queried class."); - return; - } - if (!rdatalength) { - restell("Resolver error: Zero size rdata."); - return; - } - if (c + rdatalength > eob) { - restell("Resolver error: Specified rdata length exceeds packet size."); - return; - } - if (datatype == qdatatype || datatype == T_CNAME) { - if (debug) { - sprintf(tempstring,"Resolver: TTL: %s",strtdiff(sendstring,ttl)); - restell(tempstring); - } - if (usefulanswer) - switch (datatype) { - case T_A: - if (rdatalength != 4) { - sprintf(tempstring,"Resolver error: Unsupported rdata format for \"A\" type. (%u bytes)", - rdatalength); - restell(tempstring); - return; - } - if (memcmp(&rp->ip,(ip_t *)c,sizeof(ip_t))) { - sprintf(tempstring,"Resolver: Reverse authentication failed: %s != ", - strlongip(rp->ip)); - memcpy(&alignedip,(ip_t *)c,sizeof(ip_t)); - strcat(tempstring,strlongip(alignedip)); - restell(tempstring); - res_hostipmismatch++; - failrp(rp); - } else { - sprintf(tempstring,"Resolver: Reverse authentication complete: %s == \"%s\".", - strlongip(rp->ip),nonull(rp->hostname)); - restell(tempstring); - res_reversesuccess++; - passrp(rp,ttl); - return; - } - break; - case T_PTR: - case T_CNAME: - *namestring = '\0'; - r = dn_expand(s,s + l,c,namestring,MAXDNAME); - if (r == -1) { - restell("Resolver error: dn_expand() failed while expanding domain in rdata."); - return; - } - if (debug) { - sprintf(tempstring,"Resolver: Answered domain: \"%s\"",namestring); - restell(tempstring); - } - if (r > HostnameLength) { - restell("Resolver error: Domain name too long."); - failrp(rp); - return; - } - if (datatype == T_CNAME) { - strcpy(stackstring,namestring); - break; - } - if (!rp->hostname) { - rp->hostname = (char *)statmalloc(strlen(namestring) + 1); - if (!rp->hostname) { - fprintf(stderr,"statmalloc() error: %s\n",strerror(errno)); - exit(-1); - } - strcpy(rp->hostname,namestring); - linkresolvehost(rp); - passrp(rp,ttl); - res_iplookupsuccess++; - } - break; - default: - sprintf(tempstring,"Resolver error: Received unimplemented data type: %u (%s)", - datatype,datatype < ResourcetypeCount ? - resourcetypes[datatype] : resourcetypes[ResourcetypeCount]); - restell(tempstring); - } - } else { - if (debug) { - sprintf(tempstring,"Resolver: Ignoring resource type %u. (%s)", - datatype,datatype < ResourcetypeCount ? - resourcetypes[datatype] : resourcetypes[ResourcetypeCount]); - restell(tempstring); - } - } - c+= rdatalength; - } - } else - restell("Resolver error: No error returned but no answers given."); - break; - case NXDOMAIN: - if (debug) - restell("Resolver: Host not found."); - res_nxdomain++; - failrp(rp); - break; + classtypes[ClasstypeCount]); + restell(tempstring); + } + switch (qdatatype) { + case T_PTR: + if (!Is_PTR(rp)) + if (debug) { + restell("Resolver warning: Ignoring response with unexpected query type \"PTR\"."); + return; + } + break; default: - sprintf(tempstring,"Resolver: Received error response %u. (%s)", - getheader_rcode(hp),getheader_rcode(hp) < ResponsecodeCount ? - responsecodes[getheader_rcode(hp)] : responsecodes[ResponsecodeCount]); - restell(tempstring); - res_nserror++; - } + sprintf(tempstring,"Resolver error: Received unimplemented query type: %u (%s)", + qdatatype,qdatatype < ResourcetypeCount ? + resourcetypes[qdatatype] : resourcetypes[ResourcetypeCount]); + restell(tempstring); + } + for (rr = hp->ancount + hp->nscount + hp->arcount;rr;rr--) { + if (c > eob) { + restell("Resolver error: Packet does not contain all specified resouce records."); + return; + } + *namestring = '\0'; + r = dn_expand(s,s + l,c,namestring,MAXDNAME); + if (r == -1) { + restell("Resolver error: dn_expand() failed while expanding answer domain."); + return; + } + namestring[strlen(stackstring)] = '\0'; + if (strcasecmp(stackstring,namestring)) + usefulanswer = 0; + else + usefulanswer = 1; + if (debug) { + sprintf(tempstring,"Resolver: answered domain query: \"%s\"",namestring); + restell(tempstring); + } + c+= r; + if (c + 10 > eob) { + restell("Resolver error: Resource record truncated."); + return; + } + datatype = sucknetword(c); + class = sucknetword(c); + ttl = sucknetlong(c); + rdatalength = sucknetword(c); + if (class != qclass) { + sprintf(tempstring,"query class: %u (%s)",qclass,qclass < ClasstypeCount ? + classtypes[qclass] : classtypes[ClasstypeCount]); + restell(tempstring); + sprintf(tempstring,"rr class: %u (%s)",class,class < ClasstypeCount ? + classtypes[class] : classtypes[ClasstypeCount]); + restell(tempstring); + restell("Resolver error: Answered class does not match queried class."); + return; + } + if (!rdatalength) { + restell("Resolver error: Zero size rdata."); + return; + } + if (c + rdatalength > eob) { + restell("Resolver error: Specified rdata length exceeds packet size."); + return; + } + if (datatype == qdatatype || datatype == T_CNAME) { + if (debug) { + sprintf(tempstring,"Resolver: TTL: %s",strtdiff(sendstring,ttl)); + restell(tempstring); + } + if (usefulanswer) + switch (datatype) { + case T_A: + if (rdatalength != 4) { + sprintf(tempstring,"Resolver error: Unsupported rdata format for \"A\" type. (%u bytes)", + rdatalength); + restell(tempstring); + return; + } + if (memcmp(&rp->ip,(ip_t *)c,sizeof(ip_t))) { + sprintf(tempstring,"Resolver: Reverse authentication failed: %s != ", + strlongip(rp->ip)); + memcpy(&alignedip,(ip_t *)c,sizeof(ip_t)); + strcat(tempstring,strlongip(alignedip)); + restell(tempstring); + res_hostipmismatch++; + failrp(rp); + } else { + sprintf(tempstring,"Resolver: Reverse authentication complete: %s == \"%s\".", + strlongip(rp->ip),nonull(rp->hostname)); + restell(tempstring); + res_reversesuccess++; + passrp(rp,ttl); + return; + } + break; + case T_PTR: + case T_CNAME: + *namestring = '\0'; + r = dn_expand(s,s + l,c,namestring,MAXDNAME); + if (r == -1) { + restell("Resolver error: dn_expand() failed while expanding domain in rdata."); + return; + } + if (debug) { + sprintf(tempstring,"Resolver: Answered domain: \"%s\"",namestring); + restell(tempstring); + } + if (r > HostnameLength) { + restell("Resolver error: Domain name too long."); + failrp(rp); + return; + } + if (datatype == T_CNAME) { + strcpy(stackstring,namestring); + break; + } + if (!rp->hostname) { + rp->hostname = (char *)statmalloc(strlen(namestring) + 1); + if (!rp->hostname) { + fprintf(stderr,"statmalloc() error: %s\n",strerror(errno)); + exit(-1); + } + strcpy(rp->hostname,namestring); + linkresolvehost(rp); + passrp(rp,ttl); + res_iplookupsuccess++; + } + break; + default: + sprintf(tempstring,"Resolver error: Received unimplemented data type: %u (%s)", + datatype,datatype < ResourcetypeCount ? + resourcetypes[datatype] : resourcetypes[ResourcetypeCount]); + restell(tempstring); + } + } else { + if (debug) { + sprintf(tempstring,"Resolver: Ignoring resource type %u. (%s)", + datatype,datatype < ResourcetypeCount ? + resourcetypes[datatype] : resourcetypes[ResourcetypeCount]); + restell(tempstring); + } + } + c+= rdatalength; + } + } else + restell("Resolver error: No error returned but no answers given."); + break; + case NXDOMAIN: + if (debug) + restell("Resolver: Host not found."); + res_nxdomain++; + failrp(rp); + break; + default: + sprintf(tempstring,"Resolver: Received error response %u. (%s)", + getheader_rcode(hp),getheader_rcode(hp) < ResponsecodeCount ? + responsecodes[getheader_rcode(hp)] : responsecodes[ResponsecodeCount]); + restell(tempstring); + res_nserror++; + } } + void dns_ack(void) { - int r,i; - r = recvfrom(resfd,(byte *)resrecvbuf,MaxPacketsize,0,(struct sockaddr *)&from,&fromlen); - if (r > 0) { - /* Check to see if this server is actually one we sent to */ - if (from.sin_addr.s_addr == localhost) { - for (i = 0;i < _res.nscount;i++) - if ((_res.nsaddr_list[i].sin_addr.s_addr == from.sin_addr.s_addr) || - (!_res.nsaddr_list[i].sin_addr.s_addr)) /* 0.0.0.0 replies as 127.0.0.1 */ - break; - } else - for (i = 0;i < _res.nscount;i++) - if (_res.nsaddr_list[i].sin_addr.s_addr == from.sin_addr.s_addr) - break; - if (i == _res.nscount) { - sprintf(tempstring,"Resolver error: Received reply from unknown source: %s", - inet_ntoa(from.sin_addr)); - restell(tempstring); - } else - parserespacket((byte *)resrecvbuf,r); - } else { - sprintf(tempstring,"Resolver: Socket error: %s",strerror(errno)); + int r,i; + + r = recvfrom(resfd,(byte *)resrecvbuf,MaxPacketsize,0,(struct sockaddr *)&from,&fromlen); + if (r > 0) { + /* Check to see if this server is actually one we sent to */ + if (from.sin_addr.s_addr == localhost) { + for (i = 0;i < _res.nscount;i++) + if ((_res.nsaddr_list[i].sin_addr.s_addr == from.sin_addr.s_addr) || + (!_res.nsaddr_list[i].sin_addr.s_addr)) /* 0.0.0.0 replies as 127.0.0.1 */ + break; + } else + for (i = 0;i < _res.nscount;i++) + if (_res.nsaddr_list[i].sin_addr.s_addr == from.sin_addr.s_addr) + break; + if (i == _res.nscount) { + sprintf(tempstring,"Resolver error: Received reply from unknown source: %s", + inet_ntoa(from.sin_addr)); restell(tempstring); - } + } else + parserespacket((byte *)resrecvbuf,r); + } else { + sprintf(tempstring,"Resolver: Socket error: %s",strerror(errno)); + restell(tempstring); + } } + int istime(double x,double *sinterval) { if (x) { - if (x > sweeptime) { - if (*sinterval > x - sweeptime) - *sinterval = x - sweeptime; - } else - return 1; + if (x > sweeptime) { + if (*sinterval > x - sweeptime) + *sinterval = x - sweeptime; + } else + return 1; } return 0; } + void dns_events(double *sinterval) { - struct resolve *rp,*nextrp; - for (rp = expireresolves;(rp) && (sweeptime >= rp->expiretime);rp = nextrp) { - nextrp = rp->next; - switch (rp->state) { - case STATE_FINISHED: /* TTL has expired */ - case STATE_FAILED: /* Fake TTL has expired */ - if (debug) { - sprintf(tempstring,"Resolver: Cache record for \"%s\" (%s) has expired. (state: %u) Marked for expire at: %g, time: %g.", + struct resolve *rp,*nextrp; + + for (rp = expireresolves;(rp) && (sweeptime >= rp->expiretime);rp = nextrp) { + nextrp = rp->next; + switch (rp->state) { + case STATE_FINISHED: /* TTL has expired */ + case STATE_FAILED: /* Fake TTL has expired */ + if (debug) { + sprintf(tempstring,"Resolver: Cache record for \"%s\" (%s) has expired. (state: %u) Marked for expire at: %g, time: %g.", nonull(rp->hostname),strlongip(rp->ip),rp->state,rp->expiretime,sweeptime); - restell(tempstring); - } - unlinkresolve(rp); - break; - case STATE_PTRREQ1: /* First T_PTR send timed out */ - resendrequest(rp,T_PTR); - restell("Resolver: Send #2 for \"PTR\" query..."); - rp->state++; - rp->expiretime = sweeptime + ResRetryDelay2; - (void)istime(rp->expiretime,sinterval); - res_resend++; - break; - case STATE_PTRREQ2: /* Second T_PTR send timed out */ - resendrequest(rp,T_PTR); - restell("Resolver: Send #3 for \"PTR\" query..."); - rp->state++; - rp->expiretime = sweeptime + ResRetryDelay3; - (void)istime(rp->expiretime,sinterval); - res_resend++; - break; - case STATE_PTRREQ3: /* Third T_PTR timed out */ - restell("Resolver: \"PTR\" query timed out."); - failrp(rp); - (void)istime(rp->expiretime,sinterval); - res_timeout++; - break; - } - } - if (expireresolves) - (void)istime(expireresolves->expiretime,sinterval); + restell(tempstring); + } + unlinkresolve(rp); + break; + case STATE_PTRREQ1: /* First T_PTR send timed out */ + resendrequest(rp,T_PTR); + restell("Resolver: Send #2 for \"PTR\" query..."); + rp->state++; + rp->expiretime = sweeptime + ResRetryDelay2; + (void)istime(rp->expiretime,sinterval); + res_resend++; + break; + case STATE_PTRREQ2: /* Second T_PTR send timed out */ + resendrequest(rp,T_PTR); + restell("Resolver: Send #3 for \"PTR\" query..."); + rp->state++; + rp->expiretime = sweeptime + ResRetryDelay3; + (void)istime(rp->expiretime,sinterval); + res_resend++; + break; + case STATE_PTRREQ3: /* Third T_PTR timed out */ + restell("Resolver: \"PTR\" query timed out."); + failrp(rp); + (void)istime(rp->expiretime,sinterval); + res_timeout++; + break; + } + } + if (expireresolves) + (void)istime(expireresolves->expiretime,sinterval); } + char *dns_lookup2(ip_t ip) { - struct resolve *rp; - ip = htonl(ip); - if ((rp = findip(ip))) { - if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)) { - if ((rp->state == STATE_FINISHED) && (rp->hostname)) { - if (debug) { - sprintf(tempstring,"Resolver: Used cached record: %s == \"%s\".\n", - strlongip(ip),rp->hostname); - restell(tempstring); - } - return rp->hostname; - } else { - if (debug) { - sprintf(tempstring,"Resolver: Used failed record: %s == ???\n", - strlongip(ip)); - restell(tempstring); - } - return NULL; - } + struct resolve *rp; + + ip = htonl(ip); + if ((rp = findip(ip))) { + if ((rp->state == STATE_FINISHED) || (rp->state == STATE_FAILED)) { + if ((rp->state == STATE_FINISHED) && (rp->hostname)) { + if (debug) { + sprintf(tempstring,"Resolver: Used cached record: %s == \"%s\".\n", + strlongip(ip),rp->hostname); + restell(tempstring); + } + return rp->hostname; + } else { + if (debug) { + sprintf(tempstring,"Resolver: Used failed record: %s == ???\n", + strlongip(ip)); + restell(tempstring); + } + return NULL; } - return NULL; - } - if (debug) - fprintf(stderr,"Resolver: Added to new record.\n"); - rp = allocresolve(); - rp->state = STATE_PTRREQ1; - rp->expiretime = sweeptime + ResRetryDelay1; - rp->ip = ip; - linkresolve(rp); - rp->ip = ip; - linkresolveip(rp); - sendrequest(rp,T_PTR); - return NULL; + } + return NULL; + } + if (debug) + fprintf(stderr,"Resolver: Added to new record.\n"); + rp = allocresolve(); + rp->state = STATE_PTRREQ1; + rp->expiretime = sweeptime + ResRetryDelay1; + rp->ip = ip; + linkresolve(rp); + rp->ip = ip; + linkresolveip(rp); + sendrequest(rp,T_PTR); + return NULL; } -int use_dns = 1; char *dns_lookup(ip_t ip) { diff -ur mtr-0.60/img/Makefile.in mtr-0.61/img/Makefile.in --- mtr-0.60/img/Makefile.in Tue Aug 10 09:14:13 2004 +++ mtr-0.61/img/Makefile.in Wed Aug 11 13:06:07 2004 @@ -1,6 +1,7 @@ -# Makefile.in generated automatically by automake 1.4-p4 from Makefile.am +# Makefile.in generated automatically by automake 1.5 from Makefile.am. -# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -10,6 +11,7 @@ # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. +@SET_MAKE@ SHELL = @SHELL@ @@ -31,13 +33,9 @@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include - -DESTDIR = - pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ - top_builddir = .. ACLOCAL = @ACLOCAL@ @@ -46,131 +44,151 @@ AUTOHEADER = @AUTOHEADER@ INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS) +INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ - NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : +AMTAR = @AMTAR@ +AWK = @AWK@ CC = @CC@ CURSES_OBJ = @CURSES_OBJ@ +DEPDIR = @DEPDIR@ +EXEEXT = @EXEEXT@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_CONFIG = @GTK_CONFIG@ GTK_LIBS = @GTK_LIBS@ GTK_OBJ = @GTK_OBJ@ -MAKEINFO = @MAKEINFO@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ +PKG_CONFIG = @PKG_CONFIG@ VERSION = @VERSION@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ EXTRA_DIST = mtr_icon.xpm +subdir = img mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs -CONFIG_HEADER = ../config.h -CONFIG_CLEAN_FILES = -DIST_COMMON = Makefile.am Makefile.in - +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DIST_COMMON = Makefile.am Makefile.in +all: all-am -DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) - -TAR = tar -GZIP_ENV = --best -all: all-redirect .SUFFIXES: -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --gnu img/Makefile - -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) - cd $(top_builddir) \ - && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status - +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu img/Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +uninstall-info-am: tags: TAGS TAGS: -distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -subdir = img +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) - here=`cd $(top_builddir) && pwd`; \ - top_distdir=`cd $(top_distdir) && pwd`; \ - distdir=`cd $(distdir) && pwd`; \ - cd $(top_srcdir) \ - && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu img/Makefile @for file in $(DISTFILES); do \ - d=$(srcdir); \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ if test -d $$d/$$file; then \ - cp -pr $$d/$$file $(distdir)/$$file; \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ else \ test -f $(distdir)/$$file \ - || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ - || cp -p $$d/$$file $(distdir)/$$file || :; \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ fi; \ done -info-am: -info: info-am -dvi-am: -dvi: dvi-am check-am: all-am check: check-am -installcheck-am: -installcheck: installcheck-am -install-exec-am: -install-exec: install-exec-am +all-am: Makefile -install-data-am: -install-data: install-data-am +installdirs: -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am install: install-am -uninstall-am: +install-exec: install-exec-am +install-data: install-data-am uninstall: uninstall-am -all-am: Makefile -all-redirect: all-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install -installdirs: +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) - -rm -f config.cache config.log stamp-h stamp-h[0-9]* + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* maintainer-clean-generic: -mostlyclean-am: mostlyclean-generic + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am -mostlyclean: mostlyclean-am +clean-am: clean-generic mostlyclean-am -clean-am: clean-generic mostlyclean-am +distclean: distclean-am -clean: clean-am +distclean-am: clean-am distclean-generic -distclean-am: distclean-generic clean-am +dvi: dvi-am -distclean: distclean-am +dvi-am: -maintainer-clean-am: maintainer-clean-generic distclean-am - @echo "This command is intended for maintainers to use;" - @echo "it deletes files that may require special tools to rebuild." +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: maintainer-clean: maintainer-clean-am -.PHONY: tags distdir info-am info dvi-am dvi check check-am \ -installcheck-am installcheck install-exec-am install-exec \ -install-data-am install-data install-am install uninstall-am uninstall \ -all-redirect all-am all installdirs mostlyclean-generic \ -distclean-generic clean-generic maintainer-clean-generic clean \ -mostlyclean distclean maintainer-clean +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic + +uninstall-am: uninstall-info-am +.PHONY: all all-am check check-am clean clean-generic distclean \ + distclean-generic distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic uninstall uninstall-am uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -ur mtr-0.60/missing mtr-0.61/missing --- mtr-0.60/missing Thu Mar 7 13:19:11 2002 +++ mtr-0.61/missing Wed Aug 11 13:07:20 2004 @@ -1,7 +1,7 @@ #! /bin/sh # Common stub for a few missing GNU programs while installing. -# Copyright (C) 1996, 1997 Free Software Foundation, Inc. -# Franc,ois Pinard , 1996. +# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,11 +18,37 @@ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. case "$1" in -h|--h|--he|--hel|--help) @@ -35,19 +61,24 @@ Options: -h, --help display this help and exit -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files - bison touch file \`y.tab.c' + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file - yacc touch file \`y.tab.c'" + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing - GNU libit 0.0" + echo "missing 0.3 - GNU automake" ;; -*) @@ -59,7 +90,7 @@ aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acinclude.m4' or \`configure.in'. You might want + you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 @@ -68,7 +99,7 @@ autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if - you modified \`configure.in'. You might want to install the + you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure @@ -77,29 +108,31 @@ autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if - you modified \`acconfig.h' or \`configure.in'. You might want + you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER([^):]*:\([^)]*\)).*/\1/p' configure.in` - if test -z "$files"; then - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^):]*\)).*/\1/p' configure.in` - test -z "$files" || files="$files.in" - else - files=`echo "$files" | sed -e 's/:/ /g'` - fi - test -z "$files" && files="config.h.in" - touch $files + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." - find . -type f -name Makefile.am -print \ - | sed 's/^\(.*\).am$/touch \1.in/' \ - | sh + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done ;; bison|yacc) @@ -108,10 +141,79 @@ you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." - touch y.tab.c + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi ;; makeinfo) + if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then + # We have makeinfo, but it failed. + exit 1 + fi + echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file @@ -125,6 +227,45 @@ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file + ;; + + tar) + shift + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + fi + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar ${1+"$@"} && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar ${1+"$@"} && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" ${1+"$@"} && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" ${1+"$@"} && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 ;; *) diff -ur mtr-0.60/mtr.c mtr-0.61/mtr.c --- mtr-0.60/mtr.c Tue Aug 10 09:58:06 2004 +++ mtr-0.61/mtr.c Wed Aug 11 13:08:11 2004 @@ -35,32 +35,6 @@ #include "net.h" -#ifndef HAVE_SETEUID -/* HPUX doesn't have seteuid, but setuid works fine in that case for us */ -#define seteuid setuid -#endif - -int DisplayMode; -int display_mode; -int Interactive = 1; -int PrintVersion = 0; -int PrintHelp = 0; -int MaxPing = 10; -int ForceMaxPing = 0; -float WaitTime = 1.0; -char *Hostname = NULL; -char *InterfaceAddress = NULL; -char LocalHostname[128]; -int dns = 1; -int packetsize = 64; /* default packet size */ -int bitpattern = 0; -int tos = 0; -/* begin ttl windows addByMin */ -int fstTTL = 1; /* default start at first hop */ -//int maxTTL = MaxHost-1; /* max you can go is 255 hops */ -int maxTTL = 30; /* inline with traceroute */ -/* end ttl */ - #ifdef ENABLE_IPV6 #define DEFAULT_AF AF_UNSPEC #else @@ -69,35 +43,58 @@ #ifdef NO_HERROR -#define herror(str) printf(str ": error looking up \"%s\"\n", Hostname); +#define herror(str) fprintf(stderr, str ": error looking up \"%s\"\n", Hostname); #endif + +int DisplayMode; +int display_mode; +int Interactive = 1; +int PrintVersion = 0; +int PrintHelp = 0; +int MaxPing = 10; +int ForceMaxPing = 0; +float WaitTime = 1.0; +char *Hostname = NULL; +char *InterfaceAddress = NULL; +char LocalHostname[128]; +int dns = 1; +int packetsize = 64; /* default packet size */ +int bitpattern = 0; +int tos = 0; int af = DEFAULT_AF; + /* begin ttl windows addByMin */ +int fstTTL = 1; /* default start at first hop */ +//int maxTTL = MaxHost-1; /* max you can go is 255 hops */ +int maxTTL = 30; /* inline with traceroute */ + /* end ttl window stuff. */ + + /* default display field(defined by key in net.h) and order */ unsigned char fld_active[2*MAXFLD] = "LS NABWV"; -char fld_index[256]; -char available_options[MAXFLD]; +char fld_index[256]; +char available_options[MAXFLD]; struct fields data_fields[MAXFLD] = { /* key, Remark, Header, Format, Width, CallBackFunc */ - {' ', ": Space between fields", " ", " ", 1, &net_drop }, /* 0 */ - {'L', "L: Loss Ratio", "Loss%", " %4.1f%%", 6, &net_loss }, /* 1 */ - {'D', "D: Dropped Packets", "Drop", " %4d", 5, &net_drop }, /* 2 */ - {'R', "R: Received Packets", "Rcv", " %5d", 6, &net_returned}, /* 3 */ - {'S', "S: Sent Packets", "Snt", " %5d", 6, &net_xmit }, /* 4 */ - {'N', "N: Newest RTT(ms)", "Last", " %5.1f", 6, &net_last }, /* 5 */ - {'B', "B: Min/Best RTT(ms)", "Best", " %5.1f", 6, &net_best }, /* 6 */ - {'A', "A: Average RTT(ms)", "Avg", " %5.1f", 6, &net_avg }, /* 7 */ - {'W', "W: Max/Worst RTT(ms)", "Wrst", " %5.1f", 6, &net_worst }, /* 8 */ - {'V', "V: Standard Deviation", "StDev", " %5.1f", 6, &net_stdev }, /* 9 */ - {'G', "G: Geometric Mean", "Gmean", " %5.1f", 6, &net_gmean }, /* 10 */ - {'J', "J: Current Jitter", "Jttr", " %4.1f", 5, &net_jitter}, /* 11 */ - {'M', "M: Jitter Mean/Avg.", "Javg", " %4.1f", 5, &net_javg }, /* 12 */ - {'X', "X: Worst Jitter", "Jmax", " %4.1f", 5, &net_jworst}, /* 13 */ - {'I', "I: Interarrival Jitter", "Jint", " %4.1f", 5, &net_jinta }, /* 14 */ - {'\0', 0, 0, 0, 0, 0 } + {' ', ": Space between fields", " ", " ", 1, &net_drop }, + {'L', "L: Loss Ratio", "Loss%", " %4.1f%%", 6, &net_loss }, + {'D', "D: Dropped Packets", "Drop", " %4d", 5, &net_drop }, + {'R', "R: Received Packets", "Rcv", " %5d", 6, &net_returned}, + {'S', "S: Sent Packets", "Snt", " %5d", 6, &net_xmit }, + {'N', "N: Newest RTT(ms)", "Last", " %5.1f", 6, &net_last }, + {'B', "B: Min/Best RTT(ms)", "Best", " %5.1f", 6, &net_best }, + {'A', "A: Average RTT(ms)", "Avg", " %5.1f", 6, &net_avg }, + {'W', "W: Max/Worst RTT(ms)", "Wrst", " %5.1f", 6, &net_worst }, + {'V', "V: Standard Deviation", "StDev", " %5.1f", 6, &net_stdev }, + {'G', "G: Geometric Mean", "Gmean", " %5.1f", 6, &net_gmean }, + {'J', "J: Current Jitter", "Jttr", " %4.1f", 5, &net_jitter}, + {'M', "M: Jitter Mean/Avg.", "Javg", " %4.1f", 5, &net_javg }, + {'X', "X: Worst Jitter", "Jmax", " %4.1f", 5, &net_jworst}, + {'I', "I: Interarrival Jitter", "Jint", " %4.1f", 5, &net_jinta }, + {'\0', NULL, NULL, NULL, 0, NULL} }; @@ -116,7 +113,7 @@ } -void parse_arg(int argc, char **argv) +void parse_arg (int argc, char **argv) { int opt; int i; @@ -188,9 +185,9 @@ break; case 's': packetsize = atoi (optarg); - if( packetsize >=0 ) { - if ( packetsize < MINPACKET ) packetsize = MINPACKET; - if ( packetsize > MAXPACKET ) packetsize = MAXPACKET; + if (packetsize >=0) { + if (packetsize < MINPACKET) packetsize = MINPACKET; + if (packetsize > MAXPACKET) packetsize = MAXPACKET; } break; case 'a': @@ -210,19 +207,19 @@ break; case 'f': fstTTL = atoi (optarg); - if( fstTTL > maxTTL ) { + if (fstTTL > maxTTL) { fstTTL = maxTTL; } - if( fstTTL < 1) { /* prevent 0 hop */ + if (fstTTL < 1) { /* prevent 0 hop */ fstTTL = 1; } break; case 'm': maxTTL = atoi (optarg); - if( maxTTL > (MaxHost - 1) ) { + if (maxTTL > (MaxHost - 1)) { maxTTL = MaxHost-1; } - if( maxTTL < 1) { /* prevent 0 hop */ + if (maxTTL < 1) { /* prevent 0 hop */ maxTTL = 1; } if (fstTTL > maxTTL) { /* don't know the pos of -m or -f */ @@ -236,7 +233,7 @@ exit (1); } for (i=0; optarg[i]; i++) { - if(!strchr(available_options, optarg[i])) { + if(!strchr (available_options, optarg[i])) { fprintf (stderr, "Unknown field identifier: %c\n", optarg[i]); exit (1); } @@ -245,12 +242,12 @@ break; case 'b': bitpattern = atoi (optarg); - if( bitpattern > 255 ) + if (bitpattern > 255) bitpattern = -1; break; case 'Q': tos = atoi (optarg); - if( tos > 255 || tos <0 ) { + if (tos > 255 || tos < 0) { /* error message, should do more checking for valid values, * details in rfc2474 */ tos = 0; @@ -258,24 +255,24 @@ break; } } - - if(DisplayMode == DisplayReport || - DisplayMode == DisplayTXT || - DisplayMode == DisplayXML || - DisplayMode == DisplayRaw || - DisplayMode == DisplayCSV ) + + if (DisplayMode == DisplayReport || + DisplayMode == DisplayTXT || + DisplayMode == DisplayXML || + DisplayMode == DisplayRaw || + DisplayMode == DisplayCSV) Interactive = 0; - if(optind > argc - 1) + if (optind > argc - 1) return; Hostname = argv[optind++]; if (argc > optind) { - packetsize = atoi(argv[optind]); - if( packetsize >=0 ) { - if ( packetsize < MINPACKET ) packetsize = MINPACKET; - if ( packetsize > MAXPACKET ) packetsize = MAXPACKET; + packetsize = atoi (argv[optind]); + if (packetsize >=0 ) { + if (packetsize < MINPACKET) packetsize = MINPACKET; + if (packetsize > MAXPACKET) packetsize = MAXPACKET; } } } @@ -304,7 +301,8 @@ } -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ int traddr; struct hostent * host = NULL; int net_preopen_result; @@ -314,19 +312,19 @@ net_preopen_result = net_preopen (); /* Now drop to user permissions */ - if(setuid(getuid())) { - printf("mtr: Unable to drop permissions.\n"); + if (setuid(getuid())) { + fprintf (stderr, "mtr: Unable to drop permissions.\n"); exit(1); } /* Double check, just in case */ - if(geteuid() != getuid()) { - printf("mtr: Unable to drop permissions.\n"); + if (geteuid() != getuid()) { + fprintf (stderr, "mtr: Unable to drop permissions.\n"); exit(1); } /* reset the random seed */ - srand(getpid()); + srand (getpid()); display_detect(&argc, &argv); @@ -336,14 +334,14 @@ parse_mtr_options (getenv ("MTR_OPTIONS")); - parse_arg(argc, argv); + parse_arg (argc, argv); - if(PrintVersion) { - printf("mtr " VERSION "\n"); + if (PrintVersion) { + printf ("mtr " VERSION "\n"); exit(0); } - if(PrintHelp) { + if (PrintHelp) { printf("usage: %s [-hvrctglsni] [--help] [--version] [--report]\n" "\t\t[--report-cycles=COUNT] [--curses] [--gtk]\n" "\t\t[--raw] [--split] [--no-dns] [--address interface]\n" /* BL */ @@ -351,44 +349,22 @@ "\t\t[--interval=SECONDS] HOSTNAME [PACKETSIZE]\n", argv[0]); exit(0); } + if (Hostname == NULL) Hostname = "localhost"; - if(gethostname(LocalHostname, sizeof(LocalHostname))) { + if (gethostname(LocalHostname, sizeof(LocalHostname))) { strcpy(LocalHostname, "UNKNOWNHOST"); } - if(net_preopen_result != 0) { - printf("mtr: Unable to get raw socket. (Executable not suid?)\n"); + if (net_preopen_result != 0) { + fprintf(stderr, "mtr: Unable to get raw socket. (Executable not suid?)\n"); exit(1); } - - if (InterfaceAddress) { /* Mostly borrowed from ping(1) code */ - int i1, i2, i3, i4; - char dummy; - extern int sendsock; /* from net.c:118 */ - extern struct sockaddr_in sourceaddress; /* from net.c:120 */ - - sourceaddress.sin_family = AF_INET; - sourceaddress.sin_port = 0; - sourceaddress.sin_addr.s_addr = 0; - - if(sscanf(InterfaceAddress, "%u.%u.%u.%u%c", &i1, &i2, &i3, &i4, &dummy) != 4) { - printf("mtr: bad interface address: %s\n", InterfaceAddress); - exit(1); - } else { - unsigned char *ptr; - ptr = (unsigned char*)&sourceaddress.sin_addr; - ptr[0] = i1; - ptr[1] = i2; - ptr[2] = i3; - ptr[3] = i4; - } - - if(bind(sendsock, (struct sockaddr*)&sourceaddress, sizeof(sourceaddress)) == -1) { - perror("mtr: failed to bind to interface"); - exit(1); - } + + if (net_set_interfaceaddress (InterfaceAddress) != 0) { + fprintf (stderr, "mtr: Couldn't set interface addres.\n"); + exit (1); } #ifdef ENABLE_IPV6 @@ -403,24 +379,17 @@ host = gethostbyname2(Hostname, af); } - if(host == NULL) { + if (host == NULL) { herror("mtr"); exit(1); } - traddr = *(int *)host->h_addr; - - if(net_open(traddr) != 0) { - printf("mtr: Unable to get raw socket. (Executable not suid?)\n"); - exit(1); - } - switch (af) { case AF_INET: traddr = *(int *)host->h_addr; - if(net_open(traddr) != 0) { - printf("mtr: Unable to get raw socket. (Executable not suid?)\n"); + if (net_open(traddr) != 0) { + fprintf(stderr, "mtr: Unable to start net module.\n"); exit(1); } break; diff -ur mtr-0.60/net.c mtr-0.61/net.c --- mtr-0.60/net.c Thu Apr 1 17:54:00 2004 +++ mtr-0.61/net.c Wed Aug 11 13:29:10 2004 @@ -41,8 +41,6 @@ #include "display.h" -#define MaxTransit 4 - /* We can't rely on header files to provide this information, because the fields have different names between, for instance, Linux and Solaris */ @@ -54,6 +52,7 @@ uint16 sequence; }; + /* Structure of an IP header. */ struct IPHeader { uint8 version; @@ -68,6 +67,7 @@ uint32 daddr; }; + #define ICMP_ECHO 8 #define ICMP_ECHOREPLY 0 @@ -80,8 +80,6 @@ #define SOL_IP 0 #endif -#define saddr_correction(addr) BSDfix ? addr : 0 - struct nethost { uint32 addr; uint32 addrs[MAXPATH]; /* for multi paths byMin */ @@ -105,32 +103,41 @@ int saved_seq_offset; }; + struct sequence { - int index; - int transit; - int saved_seq; - struct timeval time; + int index; + int transit; + int saved_seq; + struct timeval time; }; /* Configuration parameter: How many queries to unknown hosts do we send? (This limits the amount of traffic generated if a host is not - reachable) */ + reachable) -- REW */ #define MAX_UNKNOWN_HOSTS 5 +/* There is something stupid with BSD. We now detect this automatically */ +static int BSDfix = 0; +#define saddr_correction(addr) BSDfix ? addr : 0 + static struct nethost host[MaxHost]; static struct sequence sequence[MaxSequence]; static struct timeval reset = { 0, 0 }; -int timestamp; -int sendsock; -int recvsock; +int timestamp; +int sendsock; +int recvsock; struct sockaddr_in sourceaddress; struct sockaddr_in remoteaddress; +/* XXX How do I code this to be IPV6 compatible??? -- REW */ +struct in_addr localaddr; + static int batch_at = 0; static int numhosts = 10; + extern int fstTTL; /* initial hub(ttl) to ping byMin */ extern int maxTTL; /* last hub to ping byMin*/ extern int packetsize; /* packet size used by ping */ @@ -138,6 +145,7 @@ extern int tos; /* type of service set in ping packet*/ + /* return the number of microseconds to wait before sending the next ping */ int calc_deltatime (float waittime) @@ -149,14 +157,15 @@ /* This doesn't work for odd sz. I don't know enough about this to say that this is wrong. It doesn't seem to cripple mtr though. -- REW */ -int checksum(void *data, int sz) { +int checksum(void *data, int sz) +{ unsigned short *ch; unsigned int sum; sum = 0; ch = data; sz = sz / 2; - while(sz--) { + while (sz--) { sum += *(ch++); } @@ -166,14 +175,13 @@ } -static int BSDfix = 0; - -int new_sequence(int index) { +int new_sequence(int index) +{ static int next_sequence = 0; int seq; seq = next_sequence++; - if(next_sequence >= MaxSequence) + if (next_sequence >= MaxSequence) next_sequence = 0; sequence[seq].index = index; @@ -190,6 +198,7 @@ return seq; } + /* Attempt to find the host at a particular number of hops away */ void net_send_query(int index) { @@ -247,19 +256,21 @@ first = 0; } + /* We got a return on something we sent out. Record the address and time. */ -void net_process_ping(int seq, uint32 addr, struct timeval now) { +void net_process_ping(int seq, uint32 addr, struct timeval now) +{ int index; int totusec; int oldavg; /* usedByMin */ int oldjavg; /* usedByMin */ int i; /* usedByMin */ - if(seq < 0 || seq >= MaxSequence) + if (seq < 0 || seq >= MaxSequence) return; - if(!sequence[seq].transit) + if (!sequence[seq].transit) return; sequence[seq].transit = 0; @@ -269,7 +280,7 @@ (now.tv_usec - sequence[seq].time.tv_usec); /* impossible? if( totusec < 0 ) totusec = 0 */; - if(host[index].addr == 0) { + if (host[index].addr == 0) { host[index].addr = addr; // should be out of if as addr can change display_rawhost(index, host[index].addr); @@ -287,10 +298,10 @@ } host[index].jitter = totusec - host[index].last; - if( host[index].jitter < 0 ) host[index].jitter = - host[index].jitter; + if (host[index].jitter < 0 ) host[index].jitter = - host[index].jitter; host[index].last = totusec; - if(host[index].returned < 1) { + if (host[index].returned < 1) { host[index].best = host[index].worst = host[index].gmean = totusec; host[index].avg = host[index].var = 0; @@ -302,17 +313,17 @@ * safe guard 1) best[index]>=best[index-1] if index>0 * 2) best >= average-20,000 usec (good number?) * Min - if( index > 0 ) { - if(totusec < host[index].best && - totusec>= host[index-1].best ) host[index].best = totusec; + if (index > 0) { + if (totusec < host[index].best && + totusec>= host[index-1].best) host[index].best = totusec; } else { - if(totusec < host[index].best ) host[index].best = totusec; + if(totusec < host[index].best) host[index].best = totusec; } */ - if(totusec < host[index].best ) host[index].best = totusec; - if(totusec > host[index].worst) host[index].worst = totusec; + if (totusec < host[index].best ) host[index].best = totusec; + if (totusec > host[index].worst) host[index].worst = totusec; - if(host[index].jitter > host[index].jworst) + if (host[index].jitter > host[index].jworst) host[index].jworst = host[index].jitter; host[index].returned++; @@ -338,10 +349,12 @@ display_rawping(index, totusec); } + /* We know a packet has come in, because the main select loop has called us, now we just need to read it, see if it is for us, and if it is a reply to something we sent, then call net_process_ping() */ -void net_process_return() { +void net_process_return() +{ char packet[MAXPACKET]; struct sockaddr_in fromaddr; int fromaddrsize; @@ -378,9 +391,12 @@ } } + int net_addr(int at) { return ntohl(host[at].addr); } + + int net_addrs(int at, int i) { return ntohl(host[at].addrs[i]); } @@ -389,39 +405,49 @@ int net_loss(int at) { - if((host[at].xmit - host[at].transit) == 0) return 0; + if ((host[at].xmit - host[at].transit) == 0) + return 0; /* times extra 1000 */ return 1000*(100 - (100.0 * host[at].returned / (host[at].xmit - host[at].transit)) ); } + int net_drop(int at) { return (host[at].xmit - host[at].transit) - host[at].returned; } + int net_last(int at) { return (host[at].last); } + int net_best(int at) { return (host[at].best); } + int net_worst(int at) { return (host[at].worst); } + int net_avg(int at) { return (host[at].avg); } + + int net_gmean(int at) { return (host[at].gmean); } + + int net_stdev(int at) { if( host[at].returned > 1 ) { @@ -430,11 +456,31 @@ return( 0 ); } } + + /* jitter stuff */ -int net_jitter(int at) { return (host[at].jitter); } -int net_jworst(int at) { return (host[at].jworst); } -int net_javg(int at) { return (host[at].javg); } -int net_jinta(int at) { return (host[at].jinta); } +int net_jitter(int at) +{ + return (host[at].jitter); +} + + +int net_jworst(int at) +{ + return (host[at].jworst); +} + + +int net_javg(int at) +{ + return (host[at].javg); +} + + +int net_jinta(int at) +{ + return (host[at].jinta); +} /* end jitter */ @@ -457,6 +503,7 @@ return max; } + /* add by Min (wonder its named net_min;-)) because of ttl stuff */ int net_min () { @@ -469,21 +516,32 @@ { return host[at].returned; } + + int net_xmit(int at) { return host[at].xmit; } + int net_transit(int at) { return host[at].transit; } + int net_up(int at) { return host[at].up; } + +struct in_addr *net_localaddr (void) +{ + return &localaddr; +} + + void net_end_transit() { int at; @@ -494,7 +552,6 @@ } - int net_send_batch() { int n_unknown=0, i; @@ -542,36 +599,47 @@ int trueopt = 1; sendsock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW); - if(sendsock < 0) + if (sendsock < 0) return -1; #ifdef IP_HDRINCL /* FreeBSD wants this to avoid sending out packets with protocol type RAW to the network. */ - if(setsockopt(sendsock, SOL_IP, IP_HDRINCL, &trueopt, sizeof(trueopt))) - { + if (setsockopt(sendsock, SOL_IP, IP_HDRINCL, &trueopt, sizeof(trueopt))) { perror("setsockopt(IP_HDRINCL,1)"); return -1; } #endif recvsock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); - if(recvsock < 0) + if (recvsock < 0) return -1; return 0; } + int net_open(int addr) { + struct sockaddr_in name; + int len; + net_reset(); remoteaddress.sin_family = AF_INET; remoteaddress.sin_addr.s_addr = addr; + len = sizeof (name); + getsockname (recvsock, (struct sockaddr *)&name, &len); + localaddr = name.sin_addr; +#if 0 + printf ("got localaddr: %x\n", *(int *)&localaddr); +#endif + return 0; } + void net_reopen(int addr) { int at; @@ -587,6 +655,7 @@ net_send_batch(); } + void net_reset() { int at; @@ -595,7 +664,7 @@ batch_at = fstTTL - 1; /* above replacedByMin */ numhosts = 10; - for(at = 0; at < MaxHost; at++) { + for (at = 0; at < MaxHost; at++) { host[at].xmit = 0; host[at].transit = 0; host[at].returned = 0; @@ -617,19 +686,51 @@ host[at].saved_seq_offset = -SAVED_PINGS+2; } - for(at = 0; at < MaxSequence; at++) { + for (at = 0; at < MaxSequence; at++) { sequence[at].transit = 0; } gettimeofday(&reset, NULL); } + +int net_set_interfaceaddress (char *InterfaceAddress) +{ + int i1, i2, i3, i4; + char dummy; + + if (!InterfaceAddress) return 0; + + sourceaddress.sin_family = AF_INET; + sourceaddress.sin_port = 0; + sourceaddress.sin_addr.s_addr = 0; + + if(sscanf(InterfaceAddress, "%u.%u.%u.%u%c", &i1, &i2, &i3, &i4, &dummy) != 4) { + printf("mtr: bad interface address: %s\n", InterfaceAddress); + exit(1); + } + + ((unsigned char*)&sourceaddress.sin_addr)[0] = i1; + ((unsigned char*)&sourceaddress.sin_addr)[1] = i2; + ((unsigned char*)&sourceaddress.sin_addr)[2] = i3; + ((unsigned char*)&sourceaddress.sin_addr)[3] = i4; + + if(bind(sendsock, (struct sockaddr*)&sourceaddress, sizeof(sourceaddress)) == -1) { + perror("mtr: failed to bind to interface"); + exit(1); + } + return 0; +} + + + void net_close() { close(sendsock); close(recvsock); } + int net_waitfd() { return recvsock; @@ -641,6 +742,7 @@ return host[at].saved; } + void net_save_increment() { int at; @@ -651,12 +753,14 @@ } } + void net_save_xmit(int at) { if (host[at].saved[SAVED_PINGS-1] != -2) net_save_increment(); host[at].saved[SAVED_PINGS-1] = -1; } + void net_save_return(int at, int seq, int ms) { diff -ur mtr-0.60/net.h mtr-0.61/net.h --- mtr-0.60/net.h Tue Aug 10 09:46:37 2004 +++ mtr-0.61/net.h Wed Aug 11 13:12:38 2004 @@ -22,6 +22,7 @@ int net_preopen(); int net_open(int address); void net_reopen(int address); +int net_set_interfaceaddress (char *InterfaceAddress); void net_reset(); void net_close(); int net_waitfd(); @@ -44,7 +45,7 @@ int net_javg(int at); int net_jinta(int at); int net_addrs(int at, int i); - +struct in_addr *net_localaddr(void); int net_send_batch(); void net_end_transit(); .