From da126c8b78674ee35c022b90515efbb36ef070b8 Mon Sep 17 00:00:00 2001 From: luis Date: Tue, 22 Jun 2010 17:24:34 +0000 Subject: [PATCH] Merged nmap-dedup branch from nmap-exp/luis/nmap-dedup. This completes the Nmap/Nping code de-duplication phase. --- Makefile.in | 21 +- Target.h | 1 + configure | 6647 +++++++++++----------------------- configure.ac | 46 +- idle_scan.cc | 11 +- libnetutil/Makefile.in | 40 + libnetutil/libnetutil.vcproj | 178 + libnetutil/netutil.cc | 3686 +++++++++++++++++++ libnetutil/netutil.h | 476 +++ mswin32/nmap.sln | 8 +- mswin32/nmap.vcproj | 10 +- nmap.cc | 165 +- nmap_config.h.in | 2 + nmap_dns.cc | 2 +- nmap_rpc.cc | 17 +- nse_nsock.cc | 7 +- osscan2.cc | 9 +- output.cc | 34 +- output.h | 17 + portlist.cc | 7 +- scan_engine.cc | 8 +- service_scan.cc | 8 +- targets.cc | 42 +- targets.h | 2 - tcpip.cc | 2209 +---------- tcpip.h | 137 +- traceroute.cc | 6 +- utils.cc | 352 -- utils.h | 21 - 29 files changed, 6665 insertions(+), 7504 deletions(-) create mode 100644 libnetutil/Makefile.in create mode 100644 libnetutil/libnetutil.vcproj create mode 100644 libnetutil/netutil.cc create mode 100644 libnetutil/netutil.h diff --git a/Makefile.in b/Makefile.in index 64413fc39..d368c07fb 100644 --- a/Makefile.in +++ b/Makefile.in @@ -8,6 +8,7 @@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ mandir = @mandir@ +top_srcdir = @top_srcdir@ srcdir = @srcdir@ nmapdatadir = @datadir@/nmap deskdir = $(prefix)/share/applications @@ -46,7 +47,7 @@ export CFLAGS = $(CXXFLAGS) # CFLAGS = $(DEFS) $(INCLS) STATIC = LDFLAGS = @LDFLAGS@ $(DBGFLAGS) $(STATIC) -LIBS = @LIBNBASE_LIBS@ @LIBNSOCK_LIBS@ @LIBPCRE_LIBS@ @LIBPCAP_LIBS@ @OPENSSL_LIBS@ @LIBDNET_LIBS@ @LIBLUA_LIBS@ @LIBS@ +LIBS = @LIBNBASE_LIBS@ @LIBNSOCK_LIBS@ @LIBPCRE_LIBS@ @LIBPCAP_LIBS@ @OPENSSL_LIBS@ libnetutil/libnetutil.a @LIBDNET_LIBS@ @LIBLUA_LIBS@ @LIBS@ # LIBS = -lefence @LIBS@ # LIBS = -lrmalloc @LIBS@ INSTALL = @INSTALL@ @@ -101,10 +102,10 @@ OBJS = main.o nmap.o targets.o tcpip.o nmap_error.o utils.o idle_scan.o osscan.o .cc.o: $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@ -all: @LUA_BUILD@ @PCAP_BUILD@ @PCRE_BUILD@ @DNET_BUILD@ @NBASE_BUILD@ @NSOCK_BUILD@ @NCAT_BUILD@ +all: @LUA_BUILD@ @PCAP_BUILD@ @PCRE_BUILD@ @DNET_BUILD@ @NBASE_BUILD@ @NSOCK_BUILD@ @NCAT_BUILD@ netutil_build $(MAKE) $(TARGET) $(BUILDZENMAP) $(BUILDNDIFF) $(BUILDNPING) -$(TARGET): @LUA_DEPENDS@ @PCAP_DEPENDS@ @PCRE_DEPENDS@ @DNET_DEPENDS@ $(NBASEDIR)/libnbase.a $(NSOCKDIR)/src/libnsock.a $(OBJS) +$(TARGET): @LUA_DEPENDS@ @PCAP_DEPENDS@ @PCRE_DEPENDS@ @DNET_DEPENDS@ $(NBASEDIR)/libnbase.a $(NSOCKDIR)/src/libnsock.a libnetutil/libnetutil.a $(OBJS) @echo Compiling nmap rm -f $@ $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) @@ -126,6 +127,10 @@ nsock_build: $(NSOCKDIR)/src/Makefile nbase_build @echo Compiling libnsock; cd $(NSOCKDIR)/src && $(MAKE) +netutil_build: libnetutil/Makefile + @echo Compiling libnetutil; + cd libnetutil && $(MAKE) + ncat_build: $(NCATDIR)/Makefile nbase_build nsock_build $(NCATDIR)/ncat.h cd $(NCATDIR) && $(MAKE) @@ -160,7 +165,7 @@ release-rpms: web: cd $(NMAPDEVDIR) && $(MAKE) web -clean: @LUA_CLEAN@ @PCAP_CLEAN@ @PCRE_CLEAN@ @DNET_CLEAN@ nsock_clean nbase_clean my_clean @NPING_CLEAN@ @ZENMAP_CLEAN@ @NCAT_CLEAN@ +clean: @LUA_CLEAN@ @PCAP_CLEAN@ @PCRE_CLEAN@ @DNET_CLEAN@ nsock_clean nbase_clean netutil_clean my_clean @NPING_CLEAN@ @ZENMAP_CLEAN@ @NCAT_CLEAN@ my_clean: rm -f dependencies.mk makefile.dep @@ -175,6 +180,8 @@ nbase_clean: -cd $(NBASEDIR) && $(MAKE) clean nsock_clean: -cd $(NSOCKDIR)/src && $(MAKE) clean +netutil_clean: + -cd libnetutil && $(MAKE) clean ncat_clean: -cd $(NCATDIR) && $(MAKE) clean lua_clean: @@ -197,6 +204,8 @@ nbase_dist_clean: -cd $(NBASEDIR) && $(MAKE) distclean nsock_dist_clean: -cd $(NSOCKDIR)/src && $(MAKE) distclean +netutil_dist_clean: + -cd libnetutil && $(MAKE) distclean ncat_dist_clean: -cd $(NCATDIR) && $(MAKE) distclean zenmap_dist_clean: zenmap_clean @@ -208,7 +217,7 @@ nping_dist_clean: debugclean: rm -f *.gcov *.gcda *.gcno gmon.out -distclean: my_clean my_distclean @LUA_DIST_CLEAN@ @PCAP_DIST_CLEAN@ @PCRE_DIST_CLEAN@ @DNET_DIST_CLEAN@ @NPING_DIST_CLEAN@ @ZENMAP_DIST_CLEAN@ @NCAT_DIST_CLEAN@ nbase_dist_clean nsock_dist_clean +distclean: my_clean my_distclean @LUA_DIST_CLEAN@ @PCAP_DIST_CLEAN@ @PCRE_DIST_CLEAN@ @DNET_DIST_CLEAN@ @NPING_DIST_CLEAN@ @ZENMAP_DIST_CLEAN@ @NCAT_DIST_CLEAN@ nbase_dist_clean nsock_dist_clean netutil_dist_clean my_distclean: rm -f Makefile Makefile.bak makefile.dep nmap_config.h stamp-h stamp-h.in \ @@ -281,7 +290,7 @@ install-zenmap: $(ZENMAPDIR)/setup.py build-ndiff: cd $(NDIFFDIR) && $(PYTHON) setup.py build $(if $(DESTDIR),--executable "$(DEFAULT_PYTHON_PATH)") -build-nping: $(NPINGDIR)/Makefile nbase_build nsock_build $(NPINGDIR)/nping.h +build-nping: $(NPINGDIR)/Makefile nbase_build nsock_build netutil_build $(NPINGDIR)/nping.h @cd $(NPINGDIR) && $(MAKE) install-ndiff: diff --git a/Target.h b/Target.h index 00b91a5f2..89758949d 100644 --- a/Target.h +++ b/Target.h @@ -96,6 +96,7 @@ #include "nmap.h" #include "FingerPrintResults.h" +#include "libnetutil/netutil.h" #ifndef NOLUA #include "nse_main.h" diff --git a/configure b/configure index be574c918..1ccc2f5d0 100755 --- a/configure +++ b/configure @@ -1,18 +1,22 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63. +# Generated by GNU Autoconf 2.65. +# # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# +# # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -20,23 +24,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -44,7 +40,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -55,7 +57,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -78,13 +80,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -94,15 +89,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -114,12 +109,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -131,7 +130,248 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + # We cannot yet assume a decent shell, so we have to provide a + # neutralization value for shells without unset; and this also + # works around shells that cannot unset nonexistent variables. + BASH_ENV=/dev/null + ENV=/dev/null + (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -145,8 +385,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -166,295 +410,19 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi - - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - -fi - - -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell bug-autoconf@gnu.org about your system, - echo including any error possibly output before this message. - echo This can help us improve future autoconf versions. - echo Configuration will now proceed without shell functions. -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= @@ -471,8 +439,7 @@ test \$exitcode = 0") || { s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the @@ -482,29 +449,18 @@ test \$exitcode = 0") || { exit } - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -534,7 +490,7 @@ rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -553,10 +509,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in + case $1 in #( -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -570,8 +526,8 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - -exec 7<&0 &1 +test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, @@ -589,7 +545,6 @@ cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME= @@ -597,6 +552,7 @@ PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= +PACKAGE_URL= ac_unique_file="nmap.cc" # Factoring default headers for most tests. @@ -709,6 +665,7 @@ COMPAT_OBJS INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM +RANLIB ac_ct_CXX CXXFLAGS CXX @@ -760,6 +717,7 @@ bindir program_transform_name prefix exec_prefix +PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION @@ -910,8 +868,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -937,8 +894,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1142,8 +1098,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1159,8 +1114,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1190,17 +1144,17 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { $as_echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } + -*) as_fn_error "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information." ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error "invalid variable name: \`$ac_envvar'" ;; + esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1217,15 +1171,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { $as_echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } + as_fn_error "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 - { (exit 1); exit 1; }; } ;; + fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1248,8 +1200,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } + as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1279,11 +1230,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { $as_echo "$as_me: error: working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } + as_fn_error "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } + as_fn_error "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1322,13 +1271,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } + as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1436,7 +1383,7 @@ Optional Packages: --without-zenmap Skip installation of the Zenmap graphical frontend --without-nping Skip installation of the Nping utility --with-openssl=DIR Use optional openssl libs and includes from - DIR/lib/ and DIR/include/openssl/) + [DIR]/lib/ and [DIR]/include/openssl/) --with-libpcap=DIR Look for pcap in DIR/include and DIR/libs. --with-libpcap=included Always use version included with Nmap --with-libpcre=DIR Use an existing (compiled) pcre lib from DIR/include @@ -1463,7 +1410,7 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags @@ -1472,6 +1419,7 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. +Report bugs to the package provider. _ACEOF ac_status=$? fi @@ -1535,21 +1483,452 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.63 +generated by GNU Autoconf 2.65 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2009 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_cxx_try_compile LINENO +# ---------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + $as_test_x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_header_compile + +# ac_fn_cxx_try_run LINENO +# ------------------------ +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_cxx_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_run + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + +} # ac_fn_c_check_func cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.65. Invocation command line was $ $0 $@ @@ -1585,8 +1964,8 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" -done + $as_echo "PATH: $as_dir" + done IFS=$as_save_IFS } >&5 @@ -1623,9 +2002,9 @@ do ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" + as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else @@ -1641,13 +2020,13 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args '$ac_arg'" + as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there @@ -1672,13 +2051,13 @@ _ASBOX case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -1750,39 +2129,41 @@ _ASBOX exit $exit_status ' 0 for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h +$as_echo "/* confdefs.h */" > confdefs.h + # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. @@ -1800,8 +2181,8 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then - { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" @@ -1809,10 +2190,10 @@ $as_echo "$as_me: loading site script $ac_site_file" >&6;} done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; @@ -1820,7 +2201,7 @@ $as_echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -1835,11 +2216,11 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; @@ -1849,17 +2230,17 @@ $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac @@ -1871,35 +2252,20 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi - - - - - - - - - - - - - - - - +## -------------------- ## +## Main body of script. ## +## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -1910,23 +2276,23 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu - { $as_echo "$as_me:$LINENO: checking whether NLS is requested" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5 $as_echo_n "checking whether NLS is requested... " >&6; } # Check whether --enable-nls was given. -if test "${enable_nls+set}" = set; then +if test "${enable_nls+set}" = set; then : enableval=$enable_nls; USE_NLS=$enableval else USE_NLS=yes fi - { $as_echo "$as_me:$LINENO: result: $USE_NLS" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5 $as_echo "$USE_NLS" >&6; } # Check whether --with-localdirs was given. -if test "${with_localdirs+set}" = set; then +if test "${with_localdirs+set}" = set; then : withval=$with_localdirs; case "$with_localdirs" in yes) user_localdirs=1 @@ -1962,24 +2328,16 @@ ac_config_headers="$ac_config_headers nmap_config.h" ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - if test -f "$ac_dir/install-sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f "$ac_dir/install.sh"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - elif test -f "$ac_dir/shtool"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/shtool install -c" - break - fi + for ac_t in install-sh install.sh shtool; do + if test -f "$ac_dir/$ac_t"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/$ac_t -c" + break 2 + fi + done done if test -z "$ac_aux_dir"; then - { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 -$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -1993,35 +2351,27 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - { { $as_echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 -$as_echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 -{ $as_echo "$as_me:$LINENO: checking build system type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } -if test "${ac_cv_build+set}" = set; then +if test "${ac_cv_build+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - { { $as_echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 -$as_echo "$as_me: error: cannot guess build type; you must specify one" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 -$as_echo "$as_me: error: invalid value of canonical build" >&2;} - { (exit 1); exit 1; }; };; +*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -2037,28 +2387,24 @@ IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac -{ $as_echo "$as_me:$LINENO: checking host system type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } -if test "${ac_cv_host+set}" = set; then +if test "${ac_cv_host+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - { { $as_echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 -$as_echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) { { $as_echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 -$as_echo "$as_me: error: invalid value of canonical host" >&2;} - { (exit 1); exit 1; }; };; +*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -2082,9 +2428,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2095,24 +2441,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2122,9 +2468,9 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2135,24 +2481,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2161,7 +2507,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2175,9 +2521,9 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2188,24 +2534,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2215,9 +2561,9 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2229,18 +2575,18 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -2259,10 +2605,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2274,9 +2620,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2287,24 +2633,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2318,9 +2664,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2331,24 +2677,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2361,7 +2707,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2372,57 +2718,37 @@ fi fi -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2438,8 +2764,8 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -2455,17 +2781,17 @@ do done rm -f $ac_rmfiles -if { (ac_try="$ac_link_default" +if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -2482,7 +2808,7 @@ do # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -2501,84 +2827,42 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi - -{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -if test -z "$ac_file"; then - $as_echo "$as_me: failed program was:" >&5 +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } -fi - -ac_exeext=$ac_cv_exeext - -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } - fi - fi -fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 +{ as_fn_set_status 77 +as_fn_error "C compiler cannot create executables +See \`config.log' for more details." "$LINENO" 5; }; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } -if { (ac_try="$ac_link" +if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -2593,32 +2877,83 @@ for ac_file in conftest.exe conftest conftest.*; do esac done else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." "$LINENO" 5; } fi - -rm -f conftest$ac_cv_exeext -{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then +if test "${ac_cv_objext+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2630,17 +2965,17 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" +if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -2653,31 +2988,23 @@ else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "cannot compute suffix of object files: cannot compile +See \`config.log' for more details." "$LINENO" 5; } fi - rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2691,37 +3018,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes @@ -2730,20 +3036,16 @@ else fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2754,35 +3056,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2793,36 +3071,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_compile "$LINENO"; then : - ac_c_werror_flag=$ac_save_c_werror_flag +else + ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2833,42 +3087,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -2885,18 +3114,14 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -2953,32 +3178,9 @@ for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done @@ -2989,17 +3191,19 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac +if test "x$ac_cv_prog_cc_c89" != xno; then : +fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3008,18 +3212,14 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking for inline" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } -if test "${ac_cv_c_inline+set}" = set; then +if test "${ac_cv_c_inline+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; @@ -3028,41 +3228,17 @@ $ac_kw foo_t foo () {return 0; } #endif _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } - case $ac_cv_c_inline in inline | yes) ;; *) @@ -3087,9 +3263,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3100,24 +3276,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3127,9 +3303,9 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3140,24 +3316,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3166,7 +3342,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -3180,9 +3356,9 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3193,24 +3369,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3220,9 +3396,9 @@ fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3234,18 +3410,18 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -3264,10 +3440,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3279,9 +3455,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if test "${ac_cv_prog_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3292,24 +3468,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3323,9 +3499,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3336,24 +3512,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3366,7 +3542,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -3377,62 +3553,42 @@ fi fi -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "no acceptable C compiler found in \$PATH +See \`config.log' for more details." "$LINENO" 5; } # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then +if test "${ac_cv_c_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -3446,37 +3602,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes @@ -3485,20 +3620,16 @@ else fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then +if test "${ac_cv_prog_cc_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -3509,35 +3640,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -3548,36 +3655,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_compile "$LINENO"; then : - ac_c_werror_flag=$ac_save_c_werror_flag +else + ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -3588,42 +3671,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -3640,18 +3698,14 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then +if test "${ac_cv_prog_cc_c89+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -3708,32 +3762,9 @@ for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done @@ -3744,17 +3775,19 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac +if test "x$ac_cv_prog_cc_c89" != xno; then : +fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3776,9 +3809,9 @@ if test -z "$CXX"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CXX+set}" = set; then +if test "${ac_cv_prog_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then @@ -3789,24 +3822,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then - { $as_echo "$as_me:$LINENO: result: $CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3820,9 +3853,9 @@ if test -z "$CXX"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then @@ -3833,24 +3866,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -3863,7 +3896,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -3874,53 +3907,36 @@ fi fi fi # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C++ compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } -if test "${ac_cv_cxx_compiler_gnu+set}" = set; then +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -3934,37 +3950,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes @@ -3973,20 +3968,16 @@ else fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } -if test "${ac_cv_prog_cxx_g+set}" = set; then +if test "${ac_cv_prog_cxx_g+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -3997,35 +3988,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CXXFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CXXFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4036,36 +4003,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_cxx_try_compile "$LINENO"; then : - ac_cxx_werror_flag=$ac_save_cxx_werror_flag +else + ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -4076,42 +4019,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS @@ -4134,6 +4052,98 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -4148,10 +4158,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then +if test "${ac_cv_path_install+set}" = set; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4159,11 +4169,11 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -4200,7 +4210,7 @@ case $as_dir/ in ;; esac -done + done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir @@ -4216,7 +4226,7 @@ fi INSTALL=$ac_install_sh fi fi -{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -4235,13 +4245,9 @@ if test -n "$GXX"; then fi # Remember that all following tests will run with this CXXFLAGS by default -{ $as_echo "$as_me:$LINENO: checking for __func__" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __func__" >&5 $as_echo_n "checking for __func__... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -4254,46 +4260,21 @@ printf ("%s", __func__); return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : have_func=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - have_func=no + have_func=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "x$have_func" = "xyes"; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - { $as_echo "$as_me:$LINENO: checking for __FUNCTION__" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __FUNCTION__" >&5 $as_echo_n "checking for __FUNCTION__... " >&6; } - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -4306,46 +4287,21 @@ printf ("%s", __FUNCTION__); return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : have_function=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - have_function=no + have_function=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test "x$have_function" = "xyes"; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } - cat >>confdefs.h <<\_ACEOF -#define __func__ __FUNCTION__ -_ACEOF + $as_echo "#define __func__ __FUNCTION__" >>confdefs.h else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - cat >>confdefs.h <<\_ACEOF -#define __func__ __FILE__ -_ACEOF + $as_echo "#define __func__ __FILE__" >>confdefs.h fi fi @@ -4356,9 +4312,9 @@ fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_STRIP+set}" = set; then +if test "${ac_cv_path_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $STRIP in @@ -4371,14 +4327,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_STRIP="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4386,10 +4342,10 @@ esac fi STRIP=$ac_cv_path_STRIP if test -n "$STRIP"; then - { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4399,9 +4355,9 @@ if test -z "$ac_cv_path_STRIP"; then ac_pt_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_ac_pt_STRIP+set}" = set; then +if test "${ac_cv_path_ac_pt_STRIP+set}" = set; then : $as_echo_n "(cached) " >&6 else case $ac_pt_STRIP in @@ -4414,14 +4370,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_STRIP="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -4429,10 +4385,10 @@ esac fi ac_pt_STRIP=$ac_cv_path_ac_pt_STRIP if test -n "$ac_pt_STRIP"; then - { $as_echo "$as_me:$LINENO: result: $ac_pt_STRIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_STRIP" >&5 $as_echo "$ac_pt_STRIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -4441,7 +4397,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -4458,64 +4414,45 @@ LUA_CFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" case "$host" in *alpha-dec-osf*) - cat >>confdefs.h <<\_ACEOF -#define DEC 1 -_ACEOF + $as_echo "#define DEC 1" >>confdefs.h ;; *-netbsd* | *-knetbsd*-gnu) - cat >>confdefs.h <<\_ACEOF -#define NETBSD 1 -_ACEOF + $as_echo "#define NETBSD 1" >>confdefs.h LDFLAGS="-Wl,-E $LDFLAGS" # needed for nse-C-module support ;; *-openbsd*) - cat >>confdefs.h <<\_ACEOF -#define OPENBSD 1 -_ACEOF + $as_echo "#define OPENBSD 1" >>confdefs.h LDFLAGS="-Wl,-E $LDFLAGS" # needed for nse-C-module support ;; *-freebsd* | *-kfreebsd*-gnu | *-dragonfly*) - cat >>confdefs.h <<\_ACEOF -#define FREEBSD 1 -_ACEOF + $as_echo "#define FREEBSD 1" >>confdefs.h LDFLAGS="-Wl,-E $LDFLAGS" # needed for nse-C-module support ;; *-bsdi*) - cat >>confdefs.h <<\_ACEOF -#define BSDI 1 -_ACEOF + $as_echo "#define BSDI 1" >>confdefs.h ;; *-sgi-irix5* | *-sgi-irix6*) - cat >>confdefs.h <<\_ACEOF -#define IRIX 1 -_ACEOF + $as_echo "#define IRIX 1" >>confdefs.h ;; *-hpux*) - cat >>confdefs.h <<\_ACEOF -#define HPUX 1 -_ACEOF + $as_echo "#define HPUX 1" >>confdefs.h # To link with libnet and NM (/usr/lib/libnm.sl) library # on HP-UX 11.11 (other versions?) Mikhail Zakharov (zmey20000@yahoo.com) - -{ $as_echo "$as_me:$LINENO: checking for open_mib in -lnm" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for open_mib in -lnm" >&5 $as_echo_n "checking for open_mib in -lnm... " >&6; } -if test "${ac_cv_lib_nm_open_mib+set}" = set; then +if test "${ac_cv_lib_nm_open_mib+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnm $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4533,43 +4470,18 @@ return open_mib (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_nm_open_mib=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_nm_open_mib=no + ac_cv_lib_nm_open_mib=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_nm_open_mib" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nm_open_mib" >&5 $as_echo "$ac_cv_lib_nm_open_mib" >&6; } -if test "x$ac_cv_lib_nm_open_mib" = x""yes; then +if test "x$ac_cv_lib_nm_open_mib" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBNM 1 _ACEOF @@ -4581,19 +4493,14 @@ fi ;; *-aix*) # use some AIX specific libraries - -{ $as_echo "$as_me:$LINENO: checking for odm_initialize in -lodm" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for odm_initialize in -lodm" >&5 $as_echo_n "checking for odm_initialize in -lodm... " >&6; } -if test "${ac_cv_lib_odm_odm_initialize+set}" = set; then +if test "${ac_cv_lib_odm_odm_initialize+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lodm $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4611,43 +4518,18 @@ return odm_initialize (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_odm_odm_initialize=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_odm_odm_initialize=no + ac_cv_lib_odm_odm_initialize=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_odm_odm_initialize" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_odm_odm_initialize" >&5 $as_echo "$ac_cv_lib_odm_odm_initialize" >&6; } -if test "x$ac_cv_lib_odm_odm_initialize" = x""yes; then +if test "x$ac_cv_lib_odm_odm_initialize" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBODM 1 _ACEOF @@ -4656,19 +4538,14 @@ _ACEOF fi - -{ $as_echo "$as_me:$LINENO: checking for _system_configuration in -lcfg" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _system_configuration in -lcfg" >&5 $as_echo_n "checking for _system_configuration in -lcfg... " >&6; } -if test "${ac_cv_lib_cfg__system_configuration+set}" = set; then +if test "${ac_cv_lib_cfg__system_configuration+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcfg $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -4686,43 +4563,18 @@ return _system_configuration (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_cfg__system_configuration=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_cfg__system_configuration=no + ac_cv_lib_cfg__system_configuration=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_cfg__system_configuration" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_cfg__system_configuration" >&5 $as_echo "$ac_cv_lib_cfg__system_configuration" >&6; } -if test "x$ac_cv_lib_cfg__system_configuration" = x""yes; then +if test "x$ac_cv_lib_cfg__system_configuration" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBCFG 1 _ACEOF @@ -4733,112 +4585,71 @@ fi ;; *-solaris2.0*) - cat >>confdefs.h <<\_ACEOF -#define STUPID_SOLARIS_CHECKSUM_BUG 1 -_ACEOF + $as_echo "#define STUPID_SOLARIS_CHECKSUM_BUG 1" >>confdefs.h - cat >>confdefs.h <<\_ACEOF -#define SOLARIS 1 -_ACEOF + $as_echo "#define SOLARIS 1" >>confdefs.h ;; *-solaris2.[1-9][0-9]*) - cat >>confdefs.h <<\_ACEOF -#define SOLARIS 1 -_ACEOF + $as_echo "#define SOLARIS 1" >>confdefs.h ;; *-solaris2.1*) - cat >>confdefs.h <<\_ACEOF -#define STUPID_SOLARIS_CHECKSUM_BUG 1 -_ACEOF + $as_echo "#define STUPID_SOLARIS_CHECKSUM_BUG 1" >>confdefs.h - cat >>confdefs.h <<\_ACEOF -#define SOLARIS 1 -_ACEOF + $as_echo "#define SOLARIS 1" >>confdefs.h ;; *-solaris2.2*) - cat >>confdefs.h <<\_ACEOF -#define STUPID_SOLARIS_CHECKSUM_BUG 1 -_ACEOF + $as_echo "#define STUPID_SOLARIS_CHECKSUM_BUG 1" >>confdefs.h - cat >>confdefs.h <<\_ACEOF -#define SOLARIS 1 -_ACEOF + $as_echo "#define SOLARIS 1" >>confdefs.h ;; *-solaris2.3*) - cat >>confdefs.h <<\_ACEOF -#define STUPID_SOLARIS_CHECKSUM_BUG 1 -_ACEOF + $as_echo "#define STUPID_SOLARIS_CHECKSUM_BUG 1" >>confdefs.h - cat >>confdefs.h <<\_ACEOF -#define SOLARIS 1 -_ACEOF + $as_echo "#define SOLARIS 1" >>confdefs.h ;; *-solaris2.4*) - cat >>confdefs.h <<\_ACEOF -#define STUPID_SOLARIS_CHECKSUM_BUG 1 -_ACEOF + $as_echo "#define STUPID_SOLARIS_CHECKSUM_BUG 1" >>confdefs.h - cat >>confdefs.h <<\_ACEOF -#define SOLARIS 1 -_ACEOF + $as_echo "#define SOLARIS 1" >>confdefs.h ;; *-solaris2.5.1) - cat >>confdefs.h <<\_ACEOF -#define STUPID_SOLARIS_CHECKSUM_BUG 1 -_ACEOF + $as_echo "#define STUPID_SOLARIS_CHECKSUM_BUG 1" >>confdefs.h - cat >>confdefs.h <<\_ACEOF -#define SOLARIS 1 -_ACEOF + $as_echo "#define SOLARIS 1" >>confdefs.h ;; *-solaris*) - cat >>confdefs.h <<\_ACEOF -#define SOLARIS 1 -_ACEOF + $as_echo "#define SOLARIS 1" >>confdefs.h ;; *-sunos4*) - cat >>confdefs.h <<\_ACEOF -#define SUNOS 1 -_ACEOF + $as_echo "#define SUNOS 1" >>confdefs.h - cat >>confdefs.h <<\_ACEOF -#define SPRINTF_RETURNS_STRING 1 -_ACEOF + $as_echo "#define SPRINTF_RETURNS_STRING 1" >>confdefs.h ;; *-linux*) - cat >>confdefs.h <<\_ACEOF -#define LINUX 1 -_ACEOF + $as_echo "#define LINUX 1" >>confdefs.h LDFLAGS="-Wl,-E $LDFLAGS" # needed for nse-C-module support ;; *-apple-darwin*) - cat >>confdefs.h <<\_ACEOF -#define MACOSX 1 -_ACEOF + $as_echo "#define MACOSX 1" >>confdefs.h - -{ $as_echo "$as_me:$LINENO: checking for main in -lm" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lm" >&5 $as_echo_n "checking for main in -lm... " >&6; } -if test "${ac_cv_lib_m_main+set}" = set; then +if test "${ac_cv_lib_m_main+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4850,43 +4661,18 @@ return main (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_m_main=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_m_main=no + ac_cv_lib_m_main=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_m_main" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_main" >&5 $as_echo "$ac_cv_lib_m_main" >&6; } -if test "x$ac_cv_lib_m_main" = x""yes; then +if test "x$ac_cv_lib_m_main" = x""yes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBM 1 _ACEOF @@ -4907,14 +4693,14 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then + if test "${ac_cv_prog_CPP+set}" = set; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -4929,11 +4715,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -4942,78 +4724,34 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then +if $ac_preproc_ok; then : break fi @@ -5025,7 +4763,7 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -5036,11 +4774,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -5049,87 +4783,40 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : +if $ac_preproc_ok; then : + else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." "$LINENO" 5; } fi ac_ext=c @@ -5139,9 +4826,9 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then +if test "${ac_cv_path_GREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -5152,7 +4839,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do + for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue @@ -5172,7 +4859,7 @@ case `"$ac_path_GREP" --version 2>&1` in $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" @@ -5187,26 +4874,24 @@ esac $ac_path_GREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" -{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then +if test "${ac_cv_path_EGREP+set}" = set; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -5220,7 +4905,7 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do + for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue @@ -5240,7 +4925,7 @@ case `"$ac_path_EGREP" --version 2>&1` in $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" @@ -5255,12 +4940,10 @@ esac $ac_path_EGREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -5268,21 +4951,17 @@ fi fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then +if test "${ac_cv_header_stdc+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -5297,48 +4976,23 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no + ac_cv_header_stdc=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : + $EGREP "memchr" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -5348,18 +5002,14 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : + $EGREP "free" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -5369,14 +5019,10 @@ fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : : else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -5403,118 +5049,34 @@ main () return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : +if ac_fn_c_try_run "$LINENO"; then : + else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_header_stdc=no + ac_cv_header_stdc=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF +$as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5524,146 +5086,12 @@ fi done - - - for ac_header in pwd.h termios.h sys/sockio.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5672,18 +5100,51 @@ fi done +for ac_header in sys/socket.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_socket_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SOCKET_H 1 +_ACEOF -{ $as_echo "$as_me:$LINENO: checking for library containing setsockopt" >&5 +fi + +done + +for ac_header in net/if.h +do : + ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "#include +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif + +" +if test "x$ac_cv_header_net_if_h" = x""yes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_NET_IF_H 1 +_ACEOF + +fi + +done + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing setsockopt" >&5 $as_echo_n "checking for library containing setsockopt... " >&6; } -if test "${ac_cv_search_setsockopt+set}" = set; then +if test "${ac_cv_search_setsockopt+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5708,69 +5169,38 @@ for ac_lib in '' socket; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_setsockopt=$ac_res -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_setsockopt+set}" = set; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_setsockopt+set}" = set; then : break fi done -if test "${ac_cv_search_setsockopt+set}" = set; then - : +if test "${ac_cv_search_setsockopt+set}" = set; then : + else ac_cv_search_setsockopt=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_setsockopt" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_setsockopt" >&5 $as_echo "$ac_cv_search_setsockopt" >&6; } ac_res=$ac_cv_search_setsockopt -if test "$ac_res" != no; then +if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi -{ $as_echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } -if test "${ac_cv_search_gethostbyname+set}" = set; then +if test "${ac_cv_search_gethostbyname+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -5795,54 +5225,27 @@ for ac_lib in '' nsl; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostbyname=$ac_res -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_gethostbyname+set}" = set; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_gethostbyname+set}" = set; then : break fi done -if test "${ac_cv_search_gethostbyname+set}" = set; then - : +if test "${ac_cv_search_gethostbyname+set}" = set; then : + else ac_cv_search_gethostbyname=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 $as_echo "$ac_cv_search_gethostbyname" >&6; } ac_res=$ac_cv_search_gethostbyname -if test "$ac_res" != no; then +if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi @@ -5851,7 +5254,7 @@ fi # Do they want Ndiff? # Check whether --with-ndiff was given. -if test "${with_ndiff+set}" = set; then +if test "${with_ndiff+set}" = set; then : withval=$with_ndiff; else with_ndiff=check @@ -5865,7 +5268,7 @@ if test "$with_ndiff" != "no"; then if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. - { $as_echo "$as_me:$LINENO: checking whether $PYTHON version >= 2.4" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version >= 2.4" >&5 $as_echo_n "checking whether $PYTHON version >= 2.4... " >&6; } prog="import sys # split strings by '.' and convert to numeric. Append some zeros @@ -5880,22 +5283,19 @@ sys.exit(sys.hexversion < minverhex)" ($PYTHON -c "$prog") >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + (exit $ac_status); }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - { { $as_echo "$as_me:$LINENO: error: too old" >&5 -$as_echo "$as_me: error: too old" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "too old" "$LINENO" 5 fi - am_display_PYTHON=$PYTHON else # Otherwise, try each interpreter until we find one that satisfies # VERSION. - { $as_echo "$as_me:$LINENO: checking for a Python interpreter with version >= 2.4" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 2.4" >&5 $as_echo_n "checking for a Python interpreter with version >= 2.4... " >&6; } -if test "${am_cv_pathless_PYTHON+set}" = set; then +if test "${am_cv_pathless_PYTHON+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -5914,13 +5314,12 @@ sys.exit(sys.hexversion < minverhex)" ($am_cv_pathless_PYTHON -c "$prog") >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + (exit $ac_status); }; then : break fi - done fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_pathless_PYTHON" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_pathless_PYTHON" >&5 $as_echo "$am_cv_pathless_PYTHON" >&6; } # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then @@ -5928,9 +5327,9 @@ $as_echo "$am_cv_pathless_PYTHON" >&6; } else # Extract the first word of "$am_cv_pathless_PYTHON", so it can be a program name with args. set dummy $am_cv_pathless_PYTHON; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PYTHON+set}" = set; then +if test "${ac_cv_path_PYTHON+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PYTHON in @@ -5943,14 +5342,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -5958,10 +5357,10 @@ esac fi PYTHON=$ac_cv_path_PYTHON if test -n "$PYTHON"; then - { $as_echo "$as_me:$LINENO: result: $PYTHON" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 $as_echo "$PYTHON" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -5973,29 +5372,26 @@ fi if test "$PYTHON" = :; then if test "$with_ndiff" = "check"; then - { $as_echo "$as_me:$LINENO: WARNING: Not building Ndiff because Python 2.4 or later was not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Not building Ndiff because Python 2.4 or later was not found" >&5 $as_echo "$as_me: WARNING: Not building Ndiff because Python 2.4 or later was not found" >&2;} else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: --with-ndiff requires Python 2.4 or later -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: --with-ndiff requires Python 2.4 or later -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "--with-ndiff requires Python 2.4 or later +See \`config.log' for more details." "$LINENO" 5; } fi with_ndiff=no else - { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON version" >&5 $as_echo_n "checking for $am_display_PYTHON version... " >&6; } -if test "${am_cv_python_version+set}" = set; then +if test "${am_cv_python_version+set}" = set; then : $as_echo_n "(cached) " >&6 else am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"` fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_python_version" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5 $as_echo "$am_cv_python_version" >&6; } PYTHON_VERSION=$am_cv_python_version @@ -6007,23 +5403,23 @@ $as_echo "$am_cv_python_version" >&6; } - { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON platform" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON platform" >&5 $as_echo_n "checking for $am_display_PYTHON platform... " >&6; } -if test "${am_cv_python_platform+set}" = set; then +if test "${am_cv_python_platform+set}" = set; then : $as_echo_n "(cached) " >&6 else am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"` fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_python_platform" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_platform" >&5 $as_echo "$am_cv_python_platform" >&6; } PYTHON_PLATFORM=$am_cv_python_platform - { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON script directory" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5 $as_echo_n "checking for $am_display_PYTHON script directory... " >&6; } -if test "${am_cv_python_pythondir+set}" = set; then +if test "${am_cv_python_pythondir+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$prefix" = xNONE @@ -6042,7 +5438,7 @@ else esac fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_python_pythondir" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pythondir" >&5 $as_echo "$am_cv_python_pythondir" >&6; } pythondir=$am_cv_python_pythondir @@ -6051,9 +5447,9 @@ $as_echo "$am_cv_python_pythondir" >&6; } pkgpythondir=\${pythondir}/$PACKAGE - { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON extension module directory" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON extension module directory" >&5 $as_echo_n "checking for $am_display_PYTHON extension module directory... " >&6; } -if test "${am_cv_python_pyexecdir+set}" = set; then +if test "${am_cv_python_pyexecdir+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$exec_prefix" = xNONE @@ -6072,7 +5468,7 @@ else esac fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_python_pyexecdir" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pyexecdir" >&5 $as_echo "$am_cv_python_pyexecdir" >&6; } pyexecdir=$am_cv_python_pyexecdir @@ -6105,7 +5501,7 @@ fi # Do they want Zenmap? # Check whether --with-zenmap was given. -if test "${with_zenmap+set}" = set; then +if test "${with_zenmap+set}" = set; then : withval=$with_zenmap; else with_zenmap=check @@ -6119,7 +5515,7 @@ if test "$with_zenmap" != "no"; then if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. - { $as_echo "$as_me:$LINENO: checking whether $PYTHON version >= 2.4" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $PYTHON version >= 2.4" >&5 $as_echo_n "checking whether $PYTHON version >= 2.4... " >&6; } prog="import sys # split strings by '.' and convert to numeric. Append some zeros @@ -6134,22 +5530,19 @@ sys.exit(sys.hexversion < minverhex)" ($PYTHON -c "$prog") >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + (exit $ac_status); }; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - { { $as_echo "$as_me:$LINENO: error: too old" >&5 -$as_echo "$as_me: error: too old" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "too old" "$LINENO" 5 fi - am_display_PYTHON=$PYTHON else # Otherwise, try each interpreter until we find one that satisfies # VERSION. - { $as_echo "$as_me:$LINENO: checking for a Python interpreter with version >= 2.4" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a Python interpreter with version >= 2.4" >&5 $as_echo_n "checking for a Python interpreter with version >= 2.4... " >&6; } -if test "${am_cv_pathless_PYTHON+set}" = set; then +if test "${am_cv_pathless_PYTHON+set}" = set; then : $as_echo_n "(cached) " >&6 else @@ -6168,13 +5561,12 @@ sys.exit(sys.hexversion < minverhex)" ($am_cv_pathless_PYTHON -c "$prog") >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + (exit $ac_status); }; then : break fi - done fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_pathless_PYTHON" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_pathless_PYTHON" >&5 $as_echo "$am_cv_pathless_PYTHON" >&6; } # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then @@ -6182,9 +5574,9 @@ $as_echo "$am_cv_pathless_PYTHON" >&6; } else # Extract the first word of "$am_cv_pathless_PYTHON", so it can be a program name with args. set dummy $am_cv_pathless_PYTHON; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_path_PYTHON+set}" = set; then +if test "${ac_cv_path_PYTHON+set}" = set; then : $as_echo_n "(cached) " >&6 else case $PYTHON in @@ -6197,14 +5589,14 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do + for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PYTHON="$as_dir/$ac_word$ac_exec_ext" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS ;; @@ -6212,10 +5604,10 @@ esac fi PYTHON=$ac_cv_path_PYTHON if test -n "$PYTHON"; then - { $as_echo "$as_me:$LINENO: result: $PYTHON" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PYTHON" >&5 $as_echo "$PYTHON" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -6227,29 +5619,26 @@ fi if test "$PYTHON" = :; then if test "$with_zenmap" = "check"; then - { $as_echo "$as_me:$LINENO: WARNING: Not building Zenmap because Python 2.4 or later was not found" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Not building Zenmap because Python 2.4 or later was not found" >&5 $as_echo "$as_me: WARNING: Not building Zenmap because Python 2.4 or later was not found" >&2;} else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: --with-zenmap requires Python 2.4 or later -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: --with-zenmap requires Python 2.4 or later -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "--with-zenmap requires Python 2.4 or later +See \`config.log' for more details." "$LINENO" 5; } fi with_zenmap=no else - { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON version" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON version" >&5 $as_echo_n "checking for $am_display_PYTHON version... " >&6; } -if test "${am_cv_python_version+set}" = set; then +if test "${am_cv_python_version+set}" = set; then : $as_echo_n "(cached) " >&6 else am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[:3])"` fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_python_version" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_version" >&5 $as_echo "$am_cv_python_version" >&6; } PYTHON_VERSION=$am_cv_python_version @@ -6261,23 +5650,23 @@ $as_echo "$am_cv_python_version" >&6; } - { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON platform" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON platform" >&5 $as_echo_n "checking for $am_display_PYTHON platform... " >&6; } -if test "${am_cv_python_platform+set}" = set; then +if test "${am_cv_python_platform+set}" = set; then : $as_echo_n "(cached) " >&6 else am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"` fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_python_platform" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_platform" >&5 $as_echo "$am_cv_python_platform" >&6; } PYTHON_PLATFORM=$am_cv_python_platform - { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON script directory" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON script directory" >&5 $as_echo_n "checking for $am_display_PYTHON script directory... " >&6; } -if test "${am_cv_python_pythondir+set}" = set; then +if test "${am_cv_python_pythondir+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$prefix" = xNONE @@ -6296,7 +5685,7 @@ else esac fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_python_pythondir" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pythondir" >&5 $as_echo "$am_cv_python_pythondir" >&6; } pythondir=$am_cv_python_pythondir @@ -6305,9 +5694,9 @@ $as_echo "$am_cv_python_pythondir" >&6; } pkgpythondir=\${pythondir}/$PACKAGE - { $as_echo "$as_me:$LINENO: checking for $am_display_PYTHON extension module directory" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $am_display_PYTHON extension module directory" >&5 $as_echo_n "checking for $am_display_PYTHON extension module directory... " >&6; } -if test "${am_cv_python_pyexecdir+set}" = set; then +if test "${am_cv_python_pyexecdir+set}" = set; then : $as_echo_n "(cached) " >&6 else if test "x$exec_prefix" = xNONE @@ -6326,7 +5715,7 @@ else esac fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_python_pyexecdir" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_python_pyexecdir" >&5 $as_echo "$am_cv_python_pyexecdir" >&6; } pyexecdir=$am_cv_python_pyexecdir @@ -6362,7 +5751,7 @@ fi # Do they want Nping? # Check whether --with-nping was given. -if test "${with_nping+set}" = set; then +if test "${with_nping+set}" = set; then : withval=$with_nping; else with_nping=check @@ -6397,7 +5786,7 @@ use_openssl="yes" specialssldir="" # Check whether --with-openssl was given. -if test "${with_openssl+set}" = set; then +if test "${with_openssl+set}" = set; then : withval=$with_openssl; case "$with_openssl" in yes) ;; @@ -6416,143 +5805,15 @@ fi # If they didn't specify it, we try to find it if test "$use_openssl" = "yes" -a -z "$specialssldir"; then - if test "${ac_cv_header_openssl_ssl_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for openssl/ssl.h" >&5 -$as_echo_n "checking for openssl/ssl.h... " >&6; } -if test "${ac_cv_header_openssl_ssl_h+set}" = set; then - $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_openssl_ssl_h" >&5 -$as_echo "$ac_cv_header_openssl_ssl_h" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking openssl/ssl.h usability" >&5 -$as_echo_n "checking openssl/ssl.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + ac_fn_c_check_header_mongrel "$LINENO" "openssl/ssl.h" "ac_cv_header_openssl_ssl_h" "$ac_includes_default" +if test "x$ac_cv_header_openssl_ssl_h" = x""yes; then : - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking openssl/ssl.h presence" >&5 -$as_echo_n "checking openssl/ssl.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: openssl/ssl.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: openssl/ssl.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: openssl/ssl.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: openssl/ssl.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: openssl/ssl.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: openssl/ssl.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: openssl/ssl.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: openssl/ssl.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: openssl/ssl.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: openssl/ssl.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: openssl/ssl.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: openssl/ssl.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: openssl/ssl.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: openssl/ssl.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: openssl/ssl.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: openssl/ssl.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for openssl/ssl.h" >&5 -$as_echo_n "checking for openssl/ssl.h... " >&6; } -if test "${ac_cv_header_openssl_ssl_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_openssl_ssl_h=$ac_header_preproc -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_openssl_ssl_h" >&5 -$as_echo "$ac_cv_header_openssl_ssl_h" >&6; } - -fi -if test "x$ac_cv_header_openssl_ssl_h" = x""yes; then - : else use_openssl="no" if test "$with_openssl" = "yes"; then - { { $as_echo "$as_me:$LINENO: error: OpenSSL was explicitly requested but openssl/ssl.h was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." >&5 -$as_echo "$as_me: error: OpenSSL was explicitly requested but openssl/ssl.h was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." >&2;} - { (exit 1); exit 1; }; } + as_fn_error "OpenSSL was explicitly requested but openssl/ssl.h was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: WARNING: Failed to find openssl/ssl.h so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed to find openssl/ssl.h so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&5 $as_echo "$as_me: WARNING: Failed to find openssl/ssl.h so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&2;} fi @@ -6561,18 +5822,14 @@ fi # use_openssl="yes" given explicitly in next 2 rules to avoid adding lib to $LIBS if test "$use_openssl" = "yes"; then - { $as_echo "$as_me:$LINENO: checking for BIO_int_ctrl in -lcrypto" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BIO_int_ctrl in -lcrypto" >&5 $as_echo_n "checking for BIO_int_ctrl in -lcrypto... " >&6; } -if test "${ac_cv_lib_crypto_BIO_int_ctrl+set}" = set; then +if test "${ac_cv_lib_crypto_BIO_int_ctrl+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lcrypto $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6590,52 +5847,25 @@ return BIO_int_ctrl (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_crypto_BIO_int_ctrl=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_crypto_BIO_int_ctrl=no + ac_cv_lib_crypto_BIO_int_ctrl=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_crypto_BIO_int_ctrl" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypto_BIO_int_ctrl" >&5 $as_echo "$ac_cv_lib_crypto_BIO_int_ctrl" >&6; } -if test "x$ac_cv_lib_crypto_BIO_int_ctrl" = x""yes; then +if test "x$ac_cv_lib_crypto_BIO_int_ctrl" = x""yes; then : use_openssl="yes" else use_openssl="no" if test "$with_openssl" = "yes"; then - { { $as_echo "$as_me:$LINENO: error: OpenSSL was explicitly requested but libcrypto was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." >&5 -$as_echo "$as_me: error: OpenSSL was explicitly requested but libcrypto was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." >&2;} - { (exit 1); exit 1; }; } + as_fn_error "OpenSSL was explicitly requested but libcrypto was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: WARNING: Failed to find libcrypto so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed to find libcrypto so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&5 $as_echo "$as_me: WARNING: Failed to find libcrypto so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&2;} fi @@ -6643,18 +5873,14 @@ fi fi if test "$use_openssl" = "yes"; then - { $as_echo "$as_me:$LINENO: checking for SSL_new in -lssl" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SSL_new in -lssl" >&5 $as_echo_n "checking for SSL_new in -lssl... " >&6; } -if test "${ac_cv_lib_ssl_SSL_new+set}" = set; then +if test "${ac_cv_lib_ssl_SSL_new+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lssl -lcrypto $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6672,52 +5898,25 @@ return SSL_new (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_ssl_SSL_new=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_ssl_SSL_new=no + ac_cv_lib_ssl_SSL_new=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_ssl_SSL_new" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ssl_SSL_new" >&5 $as_echo "$ac_cv_lib_ssl_SSL_new" >&6; } -if test "x$ac_cv_lib_ssl_SSL_new" = x""yes; then +if test "x$ac_cv_lib_ssl_SSL_new" = x""yes; then : use_openssl="yes" else use_openssl="no" if test "$with_openssl" = "yes"; then - { { $as_echo "$as_me:$LINENO: error: OpenSSL was explicitly requested but libssl was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." >&5 -$as_echo "$as_me: error: OpenSSL was explicitly requested but libssl was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." >&2;} - { (exit 1); exit 1; }; } + as_fn_error "OpenSSL was explicitly requested but libssl was not found. Try the --with-openssl=DIR argument to give the location of OpenSSL or run configure with --without-openssl." "$LINENO" 5 fi - { $as_echo "$as_me:$LINENO: WARNING: Failed to find libssl so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Failed to find libssl so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&5 $as_echo "$as_me: WARNING: Failed to find libssl so OpenSSL will not be used. If it is installed you can try the --with-openssl=DIR argument" >&2;} fi @@ -6726,9 +5925,7 @@ fi OPENSSL_LIBS= if test "$use_openssl" = "yes"; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_OPENSSL 1 -_ACEOF + $as_echo "#define HAVE_OPENSSL 1" >>confdefs.h OPENSSL_LIBS="-lssl -lcrypto" fi @@ -6742,150 +5939,20 @@ test "${with_libpcap+set}" != "set" && with_libpcap=yes # Check whether --with-libpcap was given. -if test "${with_libpcap+set}" = set; then +if test "${with_libpcap+set}" = set; then : withval=$with_libpcap; case "$with_libpcap" in yes) - if test "${ac_cv_header_pcap_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for pcap.h" >&5 -$as_echo_n "checking for pcap.h... " >&6; } -if test "${ac_cv_header_pcap_h+set}" = set; then - $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_pcap_h" >&5 -$as_echo "$ac_cv_header_pcap_h" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking pcap.h usability" >&5 -$as_echo_n "checking pcap.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + ac_fn_c_check_header_mongrel "$LINENO" "pcap.h" "ac_cv_header_pcap_h" "$ac_includes_default" +if test "x$ac_cv_header_pcap_h" = x""yes; then : - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking pcap.h presence" >&5 -$as_echo_n "checking pcap.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: pcap.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: pcap.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: pcap.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: pcap.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: pcap.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: pcap.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: pcap.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: pcap.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for pcap.h" >&5 -$as_echo_n "checking for pcap.h... " >&6; } -if test "${ac_cv_header_pcap_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_pcap_h=$ac_header_preproc -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_pcap_h" >&5 -$as_echo "$ac_cv_header_pcap_h" >&6; } - -fi -if test "x$ac_cv_header_pcap_h" = x""yes; then - - { $as_echo "$as_me:$LINENO: checking for pcap_datalink in -lpcap" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_datalink in -lpcap" >&5 $as_echo_n "checking for pcap_datalink in -lpcap... " >&6; } -if test "${ac_cv_lib_pcap_pcap_datalink+set}" = set; then +if test "${ac_cv_lib_pcap_pcap_datalink+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -6903,43 +5970,18 @@ return pcap_datalink (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcap_pcap_datalink=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_pcap_pcap_datalink=no + ac_cv_lib_pcap_pcap_datalink=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcap_pcap_datalink" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_datalink" >&5 $as_echo "$ac_cv_lib_pcap_pcap_datalink" >&6; } -if test "x$ac_cv_lib_pcap_pcap_datalink" = x""yes; then +if test "x$ac_cv_lib_pcap_pcap_datalink" = x""yes; then : have_libpcap=yes fi @@ -6957,147 +5999,17 @@ fi CPPFLAGS="-I$with_libpcap/include $CPPFLAGS" LDFLAGS="-L$with_libpcap/lib $LDFLAGS" - if test "${ac_cv_header_pcap_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for pcap.h" >&5 -$as_echo_n "checking for pcap.h... " >&6; } -if test "${ac_cv_header_pcap_h+set}" = set; then - $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_pcap_h" >&5 -$as_echo "$ac_cv_header_pcap_h" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking pcap.h usability" >&5 -$as_echo_n "checking pcap.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 + ac_fn_c_check_header_mongrel "$LINENO" "pcap.h" "ac_cv_header_pcap_h" "$ac_includes_default" +if test "x$ac_cv_header_pcap_h" = x""yes; then : - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking pcap.h presence" >&5 -$as_echo_n "checking pcap.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: pcap.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: pcap.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: pcap.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: pcap.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: pcap.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: pcap.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: pcap.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcap.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: pcap.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for pcap.h" >&5 -$as_echo_n "checking for pcap.h... " >&6; } -if test "${ac_cv_header_pcap_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_pcap_h=$ac_header_preproc -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_pcap_h" >&5 -$as_echo "$ac_cv_header_pcap_h" >&6; } - -fi -if test "x$ac_cv_header_pcap_h" = x""yes; then - - { $as_echo "$as_me:$LINENO: checking for pcap_datalink in -lpcap" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_datalink in -lpcap" >&5 $as_echo_n "checking for pcap_datalink in -lpcap... " >&6; } -if test "${ac_cv_lib_pcap_pcap_datalink+set}" = set; then +if test "${ac_cv_lib_pcap_pcap_datalink+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -7115,43 +6027,18 @@ return pcap_datalink (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcap_pcap_datalink=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_pcap_pcap_datalink=no + ac_cv_lib_pcap_pcap_datalink=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcap_pcap_datalink" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_datalink" >&5 $as_echo "$ac_cv_lib_pcap_pcap_datalink" >&6; } -if test "x$ac_cv_lib_pcap_pcap_datalink" = x""yes; then +if test "x$ac_cv_lib_pcap_pcap_datalink" = x""yes; then : have_libpcap=yes LIBPCAP_INC=$with_libpcap/include LIBPCAP_LIB=$with_libpcap/lib @@ -7186,146 +6073,12 @@ if test $have_libpcap = yes; then LIBS_OLD="$LIBS" LIBS="$LIBS -lpcap" - - - -for ac_header in sys/ioccom.h sys/time.h net/bpf.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then + for ac_header in sys/ioccom.h sys/time.h net/bpf.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -7334,17 +6087,13 @@ fi done - { $as_echo "$as_me:$LINENO: checking if libpcap is suitable" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libpcap is suitable" >&5 $as_echo_n "checking if libpcap is suitable... " >&6; } - if test "$cross_compiling" = yes; then - { $as_echo "$as_me:$LINENO: result: cross-compiling -- assuming yes" >&5 + if test "$cross_compiling" = yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: cross-compiling -- assuming yes" >&5 $as_echo "cross-compiling -- assuming yes" >&6; }; have_libpcap=yes else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -7362,43 +6111,15 @@ int main() { } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_run "$LINENO"; then : - if test "$cross_compiling" = yes; then - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "cannot run test program while cross compiling +See \`config.log' for more details." "$LINENO" 5; } else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -7427,60 +6148,27 @@ int main() { } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 +if ac_fn_c_try_run "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; }; have_libpcap=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -{ $as_echo "$as_me:$LINENO: result: no -- BPF_TIMEOUT BIOCSRTIMEOUT bug (64-bit OS X)" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no -- BPF_TIMEOUT BIOCSRTIMEOUT bug (64-bit OS X)" >&5 $as_echo "no -- BPF_TIMEOUT BIOCSRTIMEOUT bug (64-bit OS X)" >&6; }; have_libpcap=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -{ $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; have_libpcap=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - LIBS="$LIBS_OLD" fi @@ -7490,7 +6178,7 @@ if test $have_libpcap != yes; then if test "${LIBPCAP_INC+set}" = "set"; then CPPFLAGS="$CPPFLAGS -I$LIBPCAP_INC" else - CPPFLAGS="$CPPFLAGS -I$libpcapdir" + CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/$libpcapdir" fi LIBPCAP_LIBS='$(LIBPCAPDIR)/libpcap.a' PCAP_DEPENDS='$(LIBPCAPDIR)/libpcap.a' @@ -7498,9 +6186,7 @@ if test $have_libpcap != yes; then PCAP_CLEAN="pcap_clean" PCAP_DIST_CLEAN="pcap_dist_clean" else - cat >>confdefs.h <<\_ACEOF -#define HAVE_LIBPCAP 1 -_ACEOF + $as_echo "#define HAVE_LIBPCAP 1" >>confdefs.h LIBPCAP_LIBS="-lpcap" PCAP_DEPENDS="" @@ -7522,7 +6208,7 @@ LIBPCREDIR=libpcre # First we test whether they specified libpcre explicitly # Check whether --with-libpcre was given. -if test "${with_libpcre+set}" = set; then +if test "${with_libpcre+set}" = set; then : withval=$with_libpcre; case "$with_libpcre" in yes) ;; @@ -7541,146 +6227,16 @@ fi # If they didn't specify it, we try to find it if test $have_pcre != yes -a $requested_included_pcre != yes ; then - if test "${ac_cv_header_pcre_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for pcre.h" >&5 -$as_echo_n "checking for pcre.h... " >&6; } -if test "${ac_cv_header_pcre_h+set}" = set; then - $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_pcre_h" >&5 -$as_echo "$ac_cv_header_pcre_h" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking pcre.h usability" >&5 -$as_echo_n "checking pcre.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking pcre.h presence" >&5 -$as_echo_n "checking pcre.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: pcre.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: pcre.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: pcre.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: pcre.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: pcre.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: pcre.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: pcre.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: pcre.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: pcre.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: pcre.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for pcre.h" >&5 -$as_echo_n "checking for pcre.h... " >&6; } -if test "${ac_cv_header_pcre_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_pcre_h=$ac_header_preproc -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_pcre_h" >&5 -$as_echo "$ac_cv_header_pcre_h" >&6; } - -fi -if test "x$ac_cv_header_pcre_h" = x""yes; then - { $as_echo "$as_me:$LINENO: checking for pcre_version in -lpcre" >&5 + ac_fn_c_check_header_mongrel "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default" +if test "x$ac_cv_header_pcre_h" = x""yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_version in -lpcre" >&5 $as_echo_n "checking for pcre_version in -lpcre... " >&6; } -if test "${ac_cv_lib_pcre_pcre_version+set}" = set; then +if test "${ac_cv_lib_pcre_pcre_version+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcre $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -7698,187 +6254,32 @@ return pcre_version (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcre_pcre_version=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_pcre_pcre_version=no + ac_cv_lib_pcre_pcre_version=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_version" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre_pcre_version" >&5 $as_echo "$ac_cv_lib_pcre_pcre_version" >&6; } -if test "x$ac_cv_lib_pcre_pcre_version" = x""yes; then +if test "x$ac_cv_lib_pcre_pcre_version" = x""yes; then : have_pcre=yes fi else - if test "${ac_cv_header_pcre_pcre_h+set}" = set; then - { $as_echo "$as_me:$LINENO: checking for pcre/pcre.h" >&5 -$as_echo_n "checking for pcre/pcre.h... " >&6; } -if test "${ac_cv_header_pcre_pcre_h+set}" = set; then - $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_pcre_pcre_h" >&5 -$as_echo "$ac_cv_header_pcre_pcre_h" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking pcre/pcre.h usability" >&5 -$as_echo_n "checking pcre/pcre.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking pcre/pcre.h presence" >&5 -$as_echo_n "checking pcre/pcre.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: pcre/pcre.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: pcre/pcre.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre/pcre.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: pcre/pcre.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: pcre/pcre.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: pcre/pcre.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre/pcre.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: pcre/pcre.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre/pcre.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: pcre/pcre.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre/pcre.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: pcre/pcre.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre/pcre.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: pcre/pcre.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: pcre/pcre.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: pcre/pcre.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for pcre/pcre.h" >&5 -$as_echo_n "checking for pcre/pcre.h... " >&6; } -if test "${ac_cv_header_pcre_pcre_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_pcre_pcre_h=$ac_header_preproc -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_pcre_pcre_h" >&5 -$as_echo "$ac_cv_header_pcre_pcre_h" >&6; } - -fi -if test "x$ac_cv_header_pcre_pcre_h" = x""yes; then - { $as_echo "$as_me:$LINENO: checking for pcre_version in -lpcre" >&5 + ac_fn_c_check_header_mongrel "$LINENO" "pcre/pcre.h" "ac_cv_header_pcre_pcre_h" "$ac_includes_default" +if test "x$ac_cv_header_pcre_pcre_h" = x""yes; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_version in -lpcre" >&5 $as_echo_n "checking for pcre_version in -lpcre... " >&6; } -if test "${ac_cv_lib_pcre_pcre_version+set}" = set; then +if test "${ac_cv_lib_pcre_pcre_version+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcre $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -7896,43 +6297,18 @@ return pcre_version (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcre_pcre_version=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_pcre_pcre_version=no + ac_cv_lib_pcre_pcre_version=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_pcre_pcre_version" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre_pcre_version" >&5 $as_echo "$ac_cv_lib_pcre_pcre_version" >&6; } -if test "x$ac_cv_lib_pcre_pcre_version" = x""yes; then +if test "x$ac_cv_lib_pcre_pcre_version" = x""yes; then : have_pcre=yes fi @@ -7950,7 +6326,7 @@ fi if test $have_pcre != yes ; then subdirs="$subdirs libpcre" - CPPFLAGS="-I$LIBPCREDIR $CPPFLAGS" + CPPFLAGS="-I\$(top_srcdir)/$LIBPCREDIR $CPPFLAGS" LIBPCRE_LIBS="$LIBPCREDIR/libpcre.a" PCRE_DEPENDS="$LIBPCREDIR/libpcre.a" PCRE_BUILD="pcre_build" @@ -7958,146 +6334,12 @@ if test $have_pcre != yes ; then PCRE_DIST_CLEAN="pcre_dist_clean" else # We only need to check for and use this if we are NOT using included pcre - -for ac_header in pcre/pcre.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then + for ac_header in pcre/pcre.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "pcre/pcre.h" "ac_cv_header_pcre_pcre_h" "$ac_includes_default" +if test "x$ac_cv_header_pcre_pcre_h" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_PCRE_PCRE_H 1 _ACEOF fi @@ -8130,7 +6372,7 @@ LIBDNETDIR=libdnet-stripped # made many improvements and fixes to our version of dnet. # Check whether --with-libdnet was given. -if test "${with_libdnet+set}" = set; then +if test "${with_libdnet+set}" = set; then : withval=$with_libdnet; case "$with_libdnet" in yes) ;; @@ -8150,9 +6392,9 @@ fi if test $have_dnet != yes ; then subdirs="$subdirs libdnet-stripped" - CPPFLAGS="-I$LIBDNETDIR/include $CPPFLAGS" - LIBDNET_LIBS="$LIBDNETDIR/src/.libs/libdnet.a" - DNET_DEPENDS="$LIBDNETDIR/src/.libs/libdnet.a" + CPPFLAGS="-I\$(top_srcdir)/$LIBDNETDIR/include $CPPFLAGS" + LIBDNET_LIBS="\$(top_srcdir)/$LIBDNETDIR/src/.libs/libdnet.a" + DNET_DEPENDS="\$(top_srcdir)/$LIBDNETDIR/src/.libs/libdnet.a" DNET_BUILD="dnet_build" DNET_CLEAN="dnet_clean" DNET_DIST_CLEAN="dnet_dist_clean" @@ -8180,14 +6422,14 @@ no_lua=no # First we test whether they specified liblua explicitly # Check whether --with-liblua was given. -if test "${with_liblua+set}" = set; then +if test "${with_liblua+set}" = set; then : withval=$with_liblua; case "$with_liblua" in yes) ;; included) - CPPFLAGS="-I$LIBLUADIR $CPPFLAGS" - LIBLUA_LIBS="$LIBLUADIR/liblua.a" - LUA_DEPENDS="$LIBLUADIR/liblua.a" + CPPFLAGS="-I\$(top_srcdir)/$LIBLUADIR $CPPFLAGS" + LIBLUA_LIBS="\$(top_srcdir)/$LIBLUADIR/liblua.a" + LUA_DEPENDS="\$(top_srcdir)/$LIBLUADIR/liblua.a" LUA_BUILD="lua_build" LUA_CLEAN="lua_clean" LUA_DIST_CLEAN="lua_dist_clean" @@ -8207,17 +6449,13 @@ fi # OpenSSL and NSE C modules can require dlopen -{ $as_echo "$as_me:$LINENO: checking for library containing dlopen" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 $as_echo_n "checking for library containing dlopen... " >&6; } -if test "${ac_cv_search_dlopen+set}" = set; then +if test "${ac_cv_search_dlopen+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -8242,54 +6480,27 @@ for ac_lib in '' dl; do ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi - rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then + if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_dlopen=$ac_res -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext - if test "${ac_cv_search_dlopen+set}" = set; then +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if test "${ac_cv_search_dlopen+set}" = set; then : break fi done -if test "${ac_cv_search_dlopen+set}" = set; then - : +if test "${ac_cv_search_dlopen+set}" = set; then : + else ac_cv_search_dlopen=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_search_dlopen" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 $as_echo "$ac_cv_search_dlopen" >&6; } ac_res=$ac_cv_search_dlopen -if test "$ac_res" != no; then +if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi @@ -8398,161 +6609,23 @@ else # If they didn't specify it, we try to find it if test $have_lua != yes; then - - - -for ac_header in lua.h lua/lua.h lua5.1/lua.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then + for ac_header in lua.h lua/lua.h lua5.1/lua.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +eval as_val=\$$as_ac_Header + if test "x$as_val" = x""yes; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF - { $as_echo "$as_me:$LINENO: checking for lua_call in -llua" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_call in -llua" >&5 $as_echo_n "checking for lua_call in -llua... " >&6; } -if test "${ac_cv_lib_lua_lua_call+set}" = set; then +if test "${ac_cv_lib_lua_lua_call+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llua -lm $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -8570,58 +6643,29 @@ return lua_call (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_lua_lua_call=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_lua_lua_call=no + ac_cv_lib_lua_lua_call=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_lua_lua_call" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua_lua_call" >&5 $as_echo "$ac_cv_lib_lua_lua_call" >&6; } -if test "x$ac_cv_lib_lua_lua_call" = x""yes; then +if test "x$ac_cv_lib_lua_lua_call" = x""yes; then : have_lua=yes; LIBLUA_LIBS="-llua"; CPPFLAGS="-I/usr/include/lua $CPPFLAGS"; break fi - { $as_echo "$as_me:$LINENO: checking for lua_call in -llua5.1" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua_call in -llua5.1" >&5 $as_echo_n "checking for lua_call in -llua5.1... " >&6; } -if test "${ac_cv_lib_lua5_1_lua_call+set}" = set; then +if test "${ac_cv_lib_lua5_1_lua_call+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-llua5.1 -lm $LIBS" -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. @@ -8639,43 +6683,18 @@ return lua_call (); return 0; } _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then +if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_lua5_1_lua_call=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_lib_lua5_1_lua_call=no + ac_cv_lib_lua5_1_lua_call=no fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_lib_lua5_1_lua_call" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lua5_1_lua_call" >&5 $as_echo "$ac_cv_lib_lua5_1_lua_call" >&6; } -if test "x$ac_cv_lib_lua5_1_lua_call" = x""yes; then +if test "x$ac_cv_lib_lua5_1_lua_call" = x""yes; then : have_lua=yes; LIBLUA_LIBS="-llua5.1"; CPPFLAGS="-I/usr/include/lua5.1 $CPPFLAGS"; break fi @@ -8691,25 +6710,18 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - { $as_echo "$as_me:$LINENO: checking for lua version >= 501" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lua version >= 501" >&5 $as_echo_n "checking for lua version >= 501... " >&6; } -if test "$cross_compiling" = yes; then - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +if test "$cross_compiling" = yes; then : + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run test program while cross compiling -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error "cannot run test program while cross compiling +See \`config.log' for more details." "$LINENO" 5; } else - cat >conftest.$ac_ext <<_ACEOF - /* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include + #include int main () { @@ -8718,42 +6730,15 @@ if(LUA_VERSION_NUM < 501) return 1; return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_cxx_try_run "$LINENO"; then : have_lua=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -have_lua=no + have_lua=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -8769,16 +6754,16 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # if we didn't find we use our own if test $have_lua != yes; then - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - CPPFLAGS="-I$LIBLUADIR $CPPFLAGS" - LIBLUA_LIBS="$LIBLUADIR/liblua.a" - LUA_DEPENDS="$LIBLUADIR/liblua.a" + CPPFLAGS="-I\$(top_srcdir)/$LIBLUADIR $CPPFLAGS" + LIBLUA_LIBS="\$(top_srcdir)/$LIBLUADIR/liblua.a" + LUA_DEPENDS="\$(top_srcdir)/$LIBLUADIR/liblua.a" LUA_BUILD="lua_build" LUA_CLEAN="lua_clean" LUA_DIST_CLEAN="lua_dist_clean" else - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi @@ -8794,16 +6779,12 @@ fi -{ $as_echo "$as_me:$LINENO: checking if sockaddr{} has sa_len member" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sockaddr{} has sa_len member" >&5 $as_echo_n "checking if sockaddr{} has sa_len member... " >&6; } -if test "${ac_cv_sockaddr_has_sa_len+set}" = set; then +if test "${ac_cv_sockaddr_has_sa_len+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -8816,57 +6797,29 @@ unsigned int i = sizeof(((struct sockaddr *)0)->sa_len) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sockaddr_has_sa_len=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_sockaddr_has_sa_len=no + ac_cv_sockaddr_has_sa_len=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_sockaddr_has_sa_len" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sockaddr_has_sa_len" >&5 $as_echo "$ac_cv_sockaddr_has_sa_len" >&6; } if test $ac_cv_sockaddr_has_sa_len = yes ; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_SOCKADDR_SA_LEN 1 -_ACEOF + $as_echo "#define HAVE_SOCKADDR_SA_LEN 1" >>confdefs.h fi #dnl check endedness - - { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then +if test "${ac_cv_c_bigendian+set}" = set; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler @@ -8874,46 +6827,34 @@ cat >>conftest.$ac_ext <<_ACEOF typedef int dummy; _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless - # there are some -arch flags. Note that *ppc* also matches - # ppc64. This check is also rather less than ideal. - case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in #( - *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;; - esac -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -8931,30 +6872,9 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -8970,49 +6890,18 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_bigendian=no + ac_cv_c_bigendian=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -9027,30 +6916,9 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -9065,51 +6933,20 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_bigendian=no + ac_cv_c_bigendian=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; @@ -9135,24 +6972,7 @@ return use_ascii (foo) == use_ebcdic (foo); return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi @@ -9164,20 +6984,10 @@ $as_echo "$ac_try_echo") >&5 ac_cv_c_bigendian=unknown fi fi -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int @@ -9197,78 +7007,40 @@ main () return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_c_bigendian=yes + ac_cv_c_bigendian=yes fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) - cat >>confdefs.h <<\_ACEOF -#define WORDS_BIGENDIAN 1 -_ACEOF + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) -cat >>confdefs.h <<\_ACEOF -#define AC_APPLE_UNIVERSAL_BUILD 1 -_ACEOF +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) - { { $as_echo "$as_me:$LINENO: error: unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" >&5 -$as_echo "$as_me: error: unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} - { (exit 1); exit 1; }; } ;; + as_fn_error "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac -{ $as_echo "$as_me:$LINENO: checking if struct in_addr is a wacky huge structure (some Sun boxes)" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if struct in_addr is a wacky huge structure (some Sun boxes)" >&5 $as_echo_n "checking if struct in_addr is a wacky huge structure (some Sun boxes)... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int @@ -9279,41 +7051,15 @@ struct in_addr i; i._S_un._S_addr; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : \ - cat >>confdefs.h <<\_ACEOF -#define IN_ADDR_DEEPSTRUCT 1 -_ACEOF + $as_echo "#define IN_ADDR_DEEPSTRUCT 1" >>confdefs.h \ - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - \ - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + \ + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -9325,55 +7071,27 @@ struct in_addr i; i.S_un.S_addr; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : \ - cat >>confdefs.h <<\_ACEOF -#define IN_ADDR_DEEPSTRUCT 1 -_ACEOF + $as_echo "#define IN_ADDR_DEEPSTRUCT 1" >>confdefs.h \ - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - \ - { $as_echo "$as_me:$LINENO: result: no" >&5 + \ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: checking if struct icmp exists" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if struct icmp exists" >&5 $as_echo_n "checking if struct icmp exists... " >&6; } -if test "${ac_cv_struct_icmp_exists+set}" = set; then +if test "${ac_cv_struct_icmp_exists+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -9393,53 +7111,26 @@ unsigned int i = sizeof(struct icmp) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_icmp_exists=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_struct_icmp_exists=no + ac_cv_struct_icmp_exists=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_struct_icmp_exists" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_icmp_exists" >&5 $as_echo "$ac_cv_struct_icmp_exists" >&6; } if test $ac_cv_struct_icmp_exists = yes ; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_STRUCT_ICMP 1 -_ACEOF + $as_echo "#define HAVE_STRUCT_ICMP 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking if struct ip exists" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if struct ip exists" >&5 $as_echo_n "checking if struct ip exists... " >&6; } -if test "${ac_cv_struct_ip_exists+set}" = set; then +if test "${ac_cv_struct_ip_exists+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -9458,53 +7149,26 @@ unsigned int i = sizeof(struct ip) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_ip_exists=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_struct_ip_exists=no + ac_cv_struct_ip_exists=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_struct_ip_exists" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_ip_exists" >&5 $as_echo "$ac_cv_struct_ip_exists" >&6; } if test $ac_cv_struct_ip_exists = yes ; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_STRUCT_IP 1 -_ACEOF + $as_echo "#define HAVE_STRUCT_IP 1" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking if struct ip has ip_sum member" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if struct ip has ip_sum member" >&5 $as_echo_n "checking if struct ip has ip_sum member... " >&6; } -if test "${ac_cv_ip_has_ip_sum+set}" = set; then +if test "${ac_cv_ip_has_ip_sum+set}" = set; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -9524,139 +7188,26 @@ unsigned int i = sizeof(((struct ip *)0)->ip_sum) return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_ip_has_ip_sum=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_ip_has_ip_sum=no + ac_cv_ip_has_ip_sum=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_ip_has_ip_sum" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ip_has_ip_sum" >&5 $as_echo "$ac_cv_ip_has_ip_sum" >&6; } if test $ac_cv_ip_has_ip_sum = yes ; then - cat >>confdefs.h <<\_ACEOF -#define HAVE_IP_IP_SUM 1 -_ACEOF + $as_echo "#define HAVE_IP_IP_SUM 1" >>confdefs.h fi - for ac_func in strerror -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + ac_fn_c_check_func "$LINENO" "strerror" "ac_cv_func_strerror" +if test "x$ac_cv_func_strerror" = x""yes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +#define HAVE_STRERROR 1 _ACEOF fi @@ -9669,15 +7220,11 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - { $as_echo "$as_me:$LINENO: checking for type of 6th argument to recvfrom()" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for type of 6th argument to recvfrom()" >&5 $as_echo_n "checking for type of 6th argument to recvfrom()... " >&6; } recvfrom6_t= for t in socklen_t int; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -9694,44 +7241,21 @@ recvfrom (0, NULL, 0, 0, NULL, &arg); return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_cxx_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_cxx_try_compile "$LINENO"; then : recvfrom6_t="$t" break -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done if test "x$recvfrom6_t" = x; then - { $as_echo "$as_me:$LINENO: WARNING: Cannot find type for 6th argument to recvfrom(). Using socklen_t ptr" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot find type for 6th argument to recvfrom(). Using socklen_t ptr" >&5 $as_echo "$as_me: WARNING: Cannot find type for 6th argument to recvfrom(). Using socklen_t ptr" >&2;} recvfrom6_t="socklen_t" fi - { $as_echo "$as_me:$LINENO: result: $recvfrom6_t" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $recvfrom6_t" >&5 $as_echo "$recvfrom6_t" >&6; } cat >>confdefs.h <<_ACEOF @@ -9748,7 +7272,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu # Check whether --with-libnbase was given. -if test "${with_libnbase+set}" = set; then +if test "${with_libnbase+set}" = set; then : withval=$with_libnbase; case "$with_libnbase" in yes) ;; @@ -9765,7 +7289,7 @@ fi LDFLAGS="$LDFLAGS -L$NBASEDIR" -CPPFLAGS="$CPPFLAGS -I$NBASEDIR" +CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/$NBASEDIR" LIBNBASE_LIBS="-lnbase" @@ -9779,7 +7303,7 @@ NSOCKDIR="nsock" NSOCK_BUILD="nsock_build" # Check whether --with-libnsock was given. -if test "${with_libnsock+set}" = set; then +if test "${with_libnsock+set}" = set; then : withval=$with_libnsock; case "$with_libnsock" in yes) ;; @@ -9793,7 +7317,7 @@ fi LDFLAGS="$LDFLAGS -L$NSOCKDIR/src/" -CPPFLAGS="$CPPFLAGS -I$NSOCKDIR/include" +CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/$NSOCKDIR/include" LIBNSOCK_LIBS="-lnsock" @@ -9807,7 +7331,7 @@ NCATDIR="ncat" # Check whether --with-ncat was given. -if test "${with_ncat+set}" = set; then +if test "${with_ncat+set}" = set; then : withval=$with_ncat; else with_ncat=check @@ -9837,7 +7361,7 @@ fi -ac_config_files="$ac_config_files Makefile" +ac_config_files="$ac_config_files Makefile libnetutil/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -9866,13 +7390,13 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -9880,8 +7404,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" @@ -9904,11 +7428,11 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else - { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi @@ -9928,8 +7452,8 @@ for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -9942,9 +7466,10 @@ LTLIBOBJS=$ac_ltlibobjs ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -9954,17 +7479,18 @@ cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 debug=false ac_cs_recheck=false ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -9972,23 +7498,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -9996,7 +7514,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -10007,7 +7531,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -10030,13 +7554,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -10046,15 +7563,15 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -10066,12 +7583,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -10083,7 +7604,89 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error ERROR [LINENO LOG_FD] +# --------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with status $?, using 1 if that was 0. +as_fn_error () +{ + as_status=$?; test $as_status -eq 0 && as_status=1 + if test "$3"; then + as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + fi + $as_echo "$as_me: error: $1" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -10097,8 +7700,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -10118,76 +7725,25 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -10216,8 +7772,56 @@ fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + + +} # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false @@ -10236,10 +7840,10 @@ else if test -d "$1"; then test -d "$1/."; else - case $1 in + case $1 in #( -*)set "./$1";; esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' @@ -10254,13 +7858,19 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 -# Save the log message, to keep $[0] and so on meaningful, and to +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.65. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -10291,13 +7901,15 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. -Usage: $0 [OPTION]... [FILE]... +Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit + --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -10313,16 +7925,17 @@ $config_files Configuration headers: $config_headers -Report bugs to ." +Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.63, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.65, + with options \\"\$ac_cs_config\\" -Copyright (C) 2008 Free Software Foundation, Inc. +Copyright (C) 2009 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -10356,6 +7969,8 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) @@ -10363,20 +7978,19 @@ do case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - { $as_echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; };; + as_fn_error "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ @@ -10384,11 +7998,10 @@ Try \`$0 --help' for more information." >&2 ac_cs_silent=: ;; # This is an error. - -*) { $as_echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; + -*) as_fn_error "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; - *) ac_config_targets="$ac_config_targets $1" + *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac @@ -10436,10 +8049,9 @@ do case $ac_config_target in "nmap_config.h") CONFIG_HEADERS="$CONFIG_HEADERS nmap_config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "libnetutil/Makefile") CONFIG_FILES="$CONFIG_FILES libnetutil/Makefile" ;; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; + *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -10465,7 +8077,7 @@ $debug || trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 + trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. @@ -10476,11 +8088,7 @@ $debug || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || -{ - $as_echo "$as_me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} +} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -10488,10 +8096,16 @@ $debug || if test -n "$CONFIG_FILES"; then -ac_cr=' ' +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\\r' + ac_cs_awk_cr='\r' else ac_cs_awk_cr=$ac_cr fi @@ -10505,24 +8119,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -10544,7 +8152,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -10558,7 +8166,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p @@ -10611,9 +8219,7 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 -$as_echo "$as_me: error: could not setup config files machinery" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), @@ -10654,9 +8260,7 @@ for ac_last_try in false false :; do if test -z "$ac_t"; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -10741,9 +8345,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 -$as_echo "$as_me: error: could not setup config headers machinery" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -10756,9 +8358,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 -$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} - { (exit 1); exit 1; }; };; + :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -10786,12 +8386,10 @@ $as_echo "$as_me: error: invalid tag $ac_tag" >&2;} [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; + as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - ac_file_inputs="$ac_file_inputs '$ac_f'" + as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't @@ -10802,7 +8400,7 @@ $as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. @@ -10815,9 +8413,7 @@ $as_echo "$as_me: creating $ac_file" >&6;} case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } ;; + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -10845,47 +8441,7 @@ $as_echo X"$ac_file" | q } s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } + as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in @@ -10937,7 +8493,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= - ac_sed_dataroot=' /datarootdir/ { p @@ -10947,12 +8502,11 @@ ac_sed_dataroot=' /@docdir@/p /@infodir@/p /@localedir@/p -/@mandir@/p -' +/@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 @@ -10962,7 +8516,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; + s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF @@ -10990,14 +8544,12 @@ s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} @@ -11007,9 +8559,7 @@ which seems to be undefined. Please make sure it is defined." >&2;} -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -11020,25 +8570,19 @@ $as_echo "$as_me: error: could not create $ac_file" >&2;} $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 -$as_echo "$as_me: error: could not create -" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error "could not create -" "$LINENO" 5 fi ;; @@ -11048,15 +8592,12 @@ $as_echo "$as_me: error: could not create -" >&2;} done # for ac_tag -{ (exit 0); exit 0; } +as_fn_exit 0 _ACEOF -chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -11077,7 +8618,7 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } + $ac_cs_success || as_fn_exit $? fi # @@ -11121,7 +8662,7 @@ if test "$no_recursion" != yes; then case $ac_arg in *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - ac_sub_configure_args="$ac_sub_configure_args '$ac_arg'" ;; + as_fn_append ac_sub_configure_args " '$ac_arg'" ;; esac done @@ -11150,49 +8691,9 @@ if test "$no_recursion" != yes; then test -d "$srcdir/$ac_dir" || continue ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)" - $as_echo "$as_me:$LINENO: $ac_msg" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5 $as_echo "$ac_msg" >&6 - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } + as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in @@ -11239,7 +8740,7 @@ ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix # This should be Cygnus configure. ac_sub_configure=$ac_aux_dir/configure else - { $as_echo "$as_me:$LINENO: WARNING: no configuration information is in $ac_dir" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ac_dir" >&5 $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} ac_sub_configure= fi @@ -11253,21 +8754,19 @@ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;} ac_sub_cache_file=$ac_top_build_prefix$cache_file ;; esac - { $as_echo "$as_me:$LINENO: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5 $as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;} # The eval makes quoting arguments work. eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \ --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" || - { { $as_echo "$as_me:$LINENO: error: $ac_sub_configure failed for $ac_dir" >&5 -$as_echo "$as_me: error: $ac_sub_configure failed for $ac_dir" >&2;} - { (exit 1); exit 1; }; } + as_fn_error "$ac_sub_configure failed for $ac_dir" "$LINENO" 5 fi cd "$ac_popdir" done fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi diff --git a/configure.ac b/configure.ac index acce56b2a..715e5eb7e 100644 --- a/configure.ac +++ b/configure.ac @@ -47,6 +47,7 @@ AC_C_INLINE dnl Checks for programs. AC_PROG_CC AC_PROG_CXX +AC_PROG_RANLIB AC_PROG_INSTALL if test -n "$GXX"; then @@ -172,6 +173,23 @@ AC_SUBST(LUA_CFLAGS) dnl Checks for header files. AC_CHECK_HEADERS(pwd.h termios.h sys/sockio.h) +dnl A special check required for on Darwin. See +dnl http://www.gnu.org/software/autoconf/manual/html_node/Header-Portability.html. +AC_CHECK_HEADERS([sys/socket.h]) +AC_CHECK_HEADERS([net/if.h], [], [], +[#include +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +]) dnl If any socket libraries needed AC_SEARCH_LIBS(setsockopt, socket) @@ -382,7 +400,7 @@ if test $have_libpcap != yes; then if test "${LIBPCAP_INC+set}" = "set"; then CPPFLAGS="$CPPFLAGS -I$LIBPCAP_INC" else - CPPFLAGS="$CPPFLAGS -I$libpcapdir" + CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/$libpcapdir" fi LIBPCAP_LIBS='$(LIBPCAPDIR)/libpcap.a' PCAP_DEPENDS='$(LIBPCAPDIR)/libpcap.a' @@ -439,7 +457,7 @@ fi # If we still don't have it, we use our own if test $have_pcre != yes ; then AC_CONFIG_SUBDIRS( libpcre ) - CPPFLAGS="-I$LIBPCREDIR $CPPFLAGS" + CPPFLAGS="-I\$(top_srcdir)/$LIBPCREDIR $CPPFLAGS" LIBPCRE_LIBS="$LIBPCREDIR/libpcre.a" PCRE_DEPENDS="$LIBPCREDIR/libpcre.a" PCRE_BUILD="pcre_build" @@ -491,9 +509,9 @@ AC_HELP_STRING([--with-libdnet=included], [Use the libdnet version included with # If they didn't provide location, we use the included one if test $have_dnet != yes ; then AC_CONFIG_SUBDIRS( libdnet-stripped ) - CPPFLAGS="-I$LIBDNETDIR/include $CPPFLAGS" - LIBDNET_LIBS="$LIBDNETDIR/src/.libs/libdnet.a" - DNET_DEPENDS="$LIBDNETDIR/src/.libs/libdnet.a" + CPPFLAGS="-I\$(top_srcdir)/$LIBDNETDIR/include $CPPFLAGS" + LIBDNET_LIBS="\$(top_srcdir)/$LIBDNETDIR/src/.libs/libdnet.a" + DNET_DEPENDS="\$(top_srcdir)/$LIBDNETDIR/src/.libs/libdnet.a" DNET_BUILD="dnet_build" DNET_CLEAN="dnet_clean" DNET_DIST_CLEAN="dnet_dist_clean" @@ -527,9 +545,9 @@ AC_HELP_STRING([--without-liblua], [Compile without lua (this will exclude all o yes) ;; included) - CPPFLAGS="-I$LIBLUADIR $CPPFLAGS" - LIBLUA_LIBS="$LIBLUADIR/liblua.a" - LUA_DEPENDS="$LIBLUADIR/liblua.a" + CPPFLAGS="-I\$(top_srcdir)/$LIBLUADIR $CPPFLAGS" + LIBLUA_LIBS="\$(top_srcdir)/$LIBLUADIR/liblua.a" + LUA_DEPENDS="\$(top_srcdir)/$LIBLUADIR/liblua.a" LUA_BUILD="lua_build" LUA_CLEAN="lua_clean" LUA_DIST_CLEAN="lua_dist_clean" @@ -588,9 +606,9 @@ else # if we didn't find we use our own if test $have_lua != yes; then AC_MSG_RESULT(no) - CPPFLAGS="-I$LIBLUADIR $CPPFLAGS" - LIBLUA_LIBS="$LIBLUADIR/liblua.a" - LUA_DEPENDS="$LIBLUADIR/liblua.a" + CPPFLAGS="-I\$(top_srcdir)/$LIBLUADIR $CPPFLAGS" + LIBLUA_LIBS="\$(top_srcdir)/$LIBLUADIR/liblua.a" + LUA_DEPENDS="\$(top_srcdir)/$LIBLUADIR/liblua.a" LUA_BUILD="lua_build" LUA_CLEAN="lua_clean" LUA_DIST_CLEAN="lua_dist_clean" @@ -712,7 +730,7 @@ NBASEDIR="nbase" ) LDFLAGS="$LDFLAGS -L$NBASEDIR" -CPPFLAGS="$CPPFLAGS -I$NBASEDIR" +CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/$NBASEDIR" LIBNBASE_LIBS="-lnbase" AC_SUBST(NBASEDIR) @@ -736,7 +754,7 @@ AC_HELP_STRING([--with-libnsock=DIR], [Compile and link to libnsock in DIR]), ) LDFLAGS="$LDFLAGS -L$NSOCKDIR/src/" -CPPFLAGS="$CPPFLAGS -I$NSOCKDIR/include" +CPPFLAGS="$CPPFLAGS -I\$(top_srcdir)/$NSOCKDIR/include" LIBNSOCK_LIBS="-lnsock" AC_SUBST(NSOCKDIR) @@ -772,7 +790,7 @@ AC_SUBST(NCAT_UNINSTALL) AC_SUBST(NCAT_CLEAN) AC_SUBST(NCAT_DIST_CLEAN) -AC_OUTPUT(Makefile) +AC_OUTPUT(Makefile libnetutil/Makefile) # Krad ASCII ART#!#@$!@#$ if test -f docs/leet-nmap-ascii-art.txt; then cat docs/leet-nmap-ascii-art.txt diff --git a/idle_scan.cc b/idle_scan.cc index cc11227c6..36b54a993 100644 --- a/idle_scan.cc +++ b/idle_scan.cc @@ -102,6 +102,7 @@ #include "services.h" #include "Target.h" #include "utils.h" +#include "output.h" #include @@ -329,7 +330,7 @@ static void initialize_idleproxy(struct idle_proxy_info *proxy, char *proxyName, } proxy->host.setHostName(name); - if (resolve(name, &ss, &sslen, o.pf()) == 0) { + if (resolve(name, 0, 0, &ss, &sslen, o.pf()) == 0) { fatal("Could not resolve idle scan zombie host: %s", name); } proxy->host.setTargetSockAddr(&ss, sslen); @@ -337,7 +338,7 @@ static void initialize_idleproxy(struct idle_proxy_info *proxy, char *proxyName, /* Lets figure out the appropriate source address to use when sending the pr0bez */ proxy->host.TargetSockAddr(&ss, &sslen); - if (!route_dst(&ss, &rnfo)) + if (!nmap_route_dst(&ss, &rnfo)) fatal("Unable to find appropriate source address and device interface to use when sending packets to %s", proxyName); if (o.spoofsource) { @@ -390,7 +391,9 @@ static void initialize_idleproxy(struct idle_proxy_info *proxy, char *proxyName, /* Now for the pcap opening nonsense ... */ /* Note that the snaplen is 152 = 64 byte max IPhdr + 24 byte max link_layer * header + 64 byte max TCP header. */ - proxy->pd = my_pcap_open_live(proxy->host.deviceName(), 152, (o.spoofsource)? 1 : 0, 50); + if((proxy->pd=my_pcap_open_live(proxy->host.deviceName(), 152, (o.spoofsource)? 1 : 0, 50))==NULL) + fatal("%s", PCAP_OPEN_ERRMSG); + p = strdup(proxy->host.targetipstr()); q = strdup(inet_ntoa(proxy->host.v4source())); @@ -398,6 +401,8 @@ static void initialize_idleproxy(struct idle_proxy_info *proxy, char *proxyName, free(p); free(q); set_pcap_filter(proxy->host.deviceFullName(), proxy->pd, filter); + if (o.debugging) + log_write(LOG_STDOUT, "Packet capture filter (device %s): %s\n", proxy->host.deviceFullName(), filter); /* Windows nonsense -- I am not sure why this is needed, but I should get rid of it at sometime */ diff --git a/libnetutil/Makefile.in b/libnetutil/Makefile.in new file mode 100644 index 000000000..344364e58 --- /dev/null +++ b/libnetutil/Makefile.in @@ -0,0 +1,40 @@ +top_srcdir = @top_srcdir@ +srcdir = @srcdir@ + +CXX = @CXX@ +AR = ar +RANLIB = @RANLIB@ +DEFS = @DEFS@ +DEFS += -D_FORTIFY_SOURCE=2 +CPPFLAGS = @CPPFLAGS@ + +LIBDNETDIR = @LIBDNETDIR@ +LIBPCAPDIR = @libpcapdir@ + +TARGET = libnetutil.a + +SRCS = $(srcdir)/netutil.cc +OBJS = netutil.o + +all: $(TARGET) + +$(TARGET): $(OBJS) + rm -f $@ + $(AR) cr $@ $(OBJS) + $(RANLIB) $@ + +clean: + rm -f $(OBJS) $(TARGET) + +distclean: clean + rm -rf Makefile + +Makefile: Makefile.in $(top_srcdir)/config.status + cd $(top_srcdir) && ./config.status + +.cc.o: + $(CXX) -c $(CPPFLAGS) $(DEFS) $*.cc + +makefile.dep: + $(CXX) -MM $(CPPFLAGS) $(SRCS) > $@ +include makefile.dep diff --git a/libnetutil/libnetutil.vcproj b/libnetutil/libnetutil.vcproj new file mode 100644 index 000000000..cf70cc75c --- /dev/null +++ b/libnetutil/libnetutil.vcproj @@ -0,0 +1,178 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc new file mode 100644 index 000000000..5bfee095e --- /dev/null +++ b/libnetutil/netutil.cc @@ -0,0 +1,3686 @@ + +/*************************************************************************** + * netutil.cc * + * * + ***********************IMPORTANT NMAP LICENSE TERMS************************ + * * + * The Nmap Security Scanner is (C) 1996-2010 Insecure.Com LLC. Nmap is * + * also a registered trademark of Insecure.Com LLC. This program is free * + * software; you may redistribute and/or modify it under the terms of the * + * GNU General Public License as published by the Free Software * + * Foundation; Version 2 with the clarifications and exceptions described * + * below. This guarantees your right to use, modify, and redistribute * + * this software under certain conditions. If you wish to embed Nmap * + * technology into proprietary software, we sell alternative licenses * + * (contact sales@insecure.com). Dozens of software vendors already * + * license Nmap technology such as host discovery, port scanning, OS * + * detection, and version detection. * + * * + * Note that the GPL places important restrictions on "derived works", yet * + * it does not provide a detailed definition of that term. To avoid * + * misunderstandings, we consider an application to constitute a * + * "derivative work" for the purpose of this license if it does any of the * + * following: * + * o Integrates source code from Nmap * + * o Reads or includes Nmap copyrighted data files, such as * + * nmap-os-db or nmap-service-probes. * + * o Executes Nmap and parses the results (as opposed to typical shell or * + * execution-menu apps, which simply display raw Nmap output and so are * + * not derivative works.) * + * o Integrates/includes/aggregates Nmap into a proprietary executable * + * installer, such as those produced by InstallShield. * + * o Links to a library or executes a program that does any of the above * + * * + * The term "Nmap" should be taken to also include any portions or derived * + * works of Nmap. This list is not exclusive, but is meant to clarify our * + * interpretation of derived works with some common examples. Our * + * interpretation applies only to Nmap--we don't speak for other people's * + * GPL works. * + * * + * If you have any questions about the GPL licensing restrictions on using * + * Nmap in non-GPL works, we would be happy to help. As mentioned above, * + * we also offer alternative license to integrate Nmap into proprietary * + * applications and appliances. These contracts have been sold to dozens * + * of software vendors, and generally include a perpetual license as well * + * as providing for priority support and updates as well as helping to * + * fund the continued development of Nmap technology. Please email * + * sales@insecure.com for further information. * + * * + * As a special exception to the GPL terms, Insecure.Com LLC grants * + * permission to link the code of this program with any version of the * + * OpenSSL library which is distributed under a license identical to that * + * listed in the included COPYING.OpenSSL file, and distribute linked * + * combinations including the two. You must obey the GNU GPL in all * + * respects for all of the code used other than OpenSSL. If you modify * + * this file, you may extend this exception to your version of the file, * + * but you are not obligated to do so. * + * * + * If you received these files with a written license agreement or * + * contract stating terms other than the terms above, then that * + * alternative license agreement takes precedence over these comments. * + * * + * Source is provided to this software because we believe users have a * + * right to know exactly what a program is going to do before they run it. * + * This also allows you to audit the software for security holes (none * + * have been found so far). * + * * + * Source code also allows you to port Nmap to new platforms, fix bugs, * + * and add new features. You are highly encouraged to send your changes * + * to nmap-dev@insecure.org for possible incorporation into the main * + * distribution. By sending these changes to Fyodor or one of the * + * Insecure.Org development mailing lists, it is assumed that you are * + * offering the Nmap Project (Insecure.Com LLC) the unlimited, * + * non-exclusive right to reuse, modify, and relicense the code. Nmap * + * will always be available Open Source, but this is important because the * + * inability to relicense code has caused devastating problems for other * + * Free Software projects (such as KDE and NASM). We also occasionally * + * relicense the code to third parties as discussed above. If you wish to * + * specify special license conditions of your contributions, just say so * + * when you send them. * + * * + * This program is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * General Public License v2.0 for more details at * + * http://www.gnu.org/licenses/gpl-2.0.html , or in the COPYING file * + * included with Nmap. * + * * + ***************************************************************************/ + +#if HAVE_CONFIG_H +#include "../nmap_config.h" +#endif + +#ifdef WIN32 +#include "mswin32/winclude.h" +#include "pcap-int.h" +#else +#include +#endif +#include + +#include +#include + +#if HAVE_NET_IF_H +#ifndef NET_IF_H /* why doesn't OpenBSD do this? */ +#include +#define NET_IF_H +#endif +#endif +#ifndef NETINET_IP_H /* why does OpenBSD not do this? */ +#include +#define NETINET_IP_H +#endif + +#include "nbase.h" +#include "netutil.h" + +#define NBASE_MAX_ERR_STR_LEN 1024 /* Max length of an error message */ + +/** Print fatal error messages to stderr and then exits. A newline + character is printed automatically after the supplied text. + * @warning This function does not return because it calls exit() */ +int netutil_fatal(const char *str, ...){ + va_list list; + char errstr[NBASE_MAX_ERR_STR_LEN]; + memset(errstr,0, NBASE_MAX_ERR_STR_LEN); + + va_start(list, str); + + fflush(stdout); + + /* Print error msg to strerr */ + vfprintf(stderr, str, list); + fprintf(stderr,"\n"); + va_end(list); + + exit(EXIT_FAILURE); + + return 0; + +} /* End of fatal() */ + +/** Print error messages to stderr and then return. A newline + character is printed automatically after the supplied text.*/ +int netutil_error(const char *str, ...){ + va_list list; + char errstr[NBASE_MAX_ERR_STR_LEN]; + memset(errstr,0, NBASE_MAX_ERR_STR_LEN); + + va_start(list, str); + + fflush(stdout); + + /* Print error msg to strerr */ + vfprintf(stderr, str, list); + fprintf(stderr,"\n"); + va_end(list); + + return 0; + +} /* End of error() */ + +/* This function converts zero-terminated 'txt' string to binary 'data'. + It is used to parse user input for ip options. Some examples of possible input + strings and results: + '\x01*2\xA2' -> [0x01,0x01,0xA2] // with 'x' number is parsed in hex + '\01\01\255' -> [0x01,0x01,0xFF] // without 'x' its in decimal + '\x01\x00*2' -> [0x01,0x00,0x00] // '*' is copying char + 'R' -> Record Route with 9 slots + 'S 192.168.0.1 172.16.0.1' -> Strict Route with 2 slots + 'L 192.168.0.1 172.16.0.1' -> Loose Route with 2 slots + 'T' -> Record Timestamp with 9 slots + 'U' -> Record Timestamp and Ip Address with 4 slots + On success, the function returns the length of the final binary + options stored in "data". In case of error, OP_FAILURE is returned + and the "errstr" buffer is filled with an error message + (unless it's NULL). Note that the returned error message does NOT + contain a newline character at the end. */ +int parse_ip_options(const char *txt, u8 *data, int datalen, int* firsthopoff, int* lasthopoff, char *errstr, size_t errstrlen){ + enum{ + NONE = 0, + SLASH = 1, + MUL = 2, + RR = 3, + TIME = 4, + } s = NONE; + char *n, lc; + const char *c = txt; + u8 *d = data; + int i,j; + int base = 10; + u8 *dataend = &data[datalen]; + u8 *len = NULL; + char buf[32]; + memset(data, 0, datalen); + int sourcerouting = 0; + + + for(;*c;c++){ + switch(s){ + case SLASH: + // parse \x00 string + if(*c == 'x'){// just ignore this char + base = 16; + break; + } + if(isxdigit(*c)){ + *d++ = strtol(c, &n, base); + c=n-1; + }else{ + if(errstr) Snprintf(errstr, errstrlen, "not a digit after '\\'"); + return OP_FAILURE; + } + s = NONE; + break; + case MUL: + if(d==data){ + if(errstr) Snprintf(errstr, errstrlen, "nothing before '*' char"); + return OP_FAILURE; + } + i = strtol(c, &n, 10); + if(i<2){ + if(errstr) Snprintf(errstr, errstrlen, "bad number after '*'"); + return OP_FAILURE; + } + c = n-1; // move current txt pointer + lc = *(d-1); // last char, we'll copy this + for(j=1; j='0' && *c<='9')) && n-buf <= ((int)sizeof(buf)-1)) + *n++ = *c++; + *n = '\0'; c--; + if(d+4>=dataend){ + if(errstr) Snprintf(errstr, errstrlen, "Buffer too small. Or input data too big :)"); + return OP_FAILURE; + } + i = inet_pton(AF_INET, buf, d); + if(i<1){ + if(errstr) Snprintf(errstr, errstrlen, "Not a valid ipv4 address '%s'",buf); + return OP_FAILURE; + } + // remember offset of first hop + if(sourcerouting && !*firsthopoff) + *firsthopoff = d - data; + d+=4; + if(*len<37) + *len += 4; + break; + case TIME: + if(errstr) Snprintf(errstr, errstrlen, "No more arguments allowed!"); + return OP_FAILURE; + default: + switch(*c){ + case '\\':s = SLASH;base=10;break; + case '*':s = MUL;break; + case 'R': + case 'S': + case 'L': + if(d != data){ + if(errstr) Snprintf(errstr, errstrlen, "This option can't be used in that way"); + return OP_FAILURE; + } + *d++ = '\x01';//NOP + switch(*c){ + case 'R':*d++ = 7;break; + case 'S':*d++ = 137; sourcerouting=1; break; + case 'L':*d++ = 131; sourcerouting=1; break; + } + len = d; + *d++ = (*c=='R')? 39 : 3; // length: 3+4*9 bytes + *d++ = 4; //pointer + s = RR; + break; + case 'T': + case 'U': + if(d != data){ + if(errstr) Snprintf(errstr, errstrlen, "This option can't be used in that way"); + return OP_FAILURE; + } + *d++ = 68; // option type + len = d; + *d++ = (*c=='U') ? 36 : 40; // length: 3+4*9 bytes or 4+4*9 bytes + *d++ = 5; // pointer + *d++ = (*c=='U') ? 1 : 0; // flag: address and Time fields + s = TIME; + break; + default://*d++ = *c; + if(errstr) Snprintf(errstr, errstrlen, "Bad character in ip option '%c'",*c); + return OP_FAILURE; + } + } + if(d == dataend) + break; + assert(d= 0 && rc < sizeof(portbuf)); + + rc = getaddrinfo(hostname, portbuf, &hints, &result); + if (rc != 0 || result == NULL) + return 0; + assert(result->ai_addrlen > 0 && result->ai_addrlen <= (int) sizeof(struct sockaddr_storage)); + *sslen = result->ai_addrlen; + memcpy(ss, result->ai_addr, *sslen); + freeaddrinfo(result); + return 1; +} + +/* + * Returns 1 if this is a reserved IP address, where "reserved" means + * either a private address, non-routable address, or even a non-reserved + * but unassigned address which has an extremely high probability of being + * black-holed. + * + * We try to optimize speed when ordering the tests. This optimization + * assumes that all byte values are equally likely in the input. + * + * Warning: This function needs frequent attention because IANA has been + * allocating address blocks many times per year (although it's questionable + * how much longer this trend can be kept up). + * + * Check + * + * for the most recent assigments and + * for bogon + * netblocks. + */ +int ip_is_reserved(struct in_addr *ip) +{ + char *ipc = (char *) &(ip->s_addr); + unsigned char i1 = ipc[0], i2 = ipc[1], i3 = ipc[2]; /* i4 not currently used - , i4 = ipc[3]; */ + + /* do all the /7's and /8's with a big switch statement, hopefully the + * compiler will be able to optimize this a little better using a jump table + * or what have you + */ + switch (i1) + { + case 0: /* 000/8 is IANA reserved */ + case 5: /* 005/8 is IANA reserved */ + case 6: /* USA Army ISC */ + case 7: /* used for BGP protocol */ + case 10: /* the infamous 10.0.0.0/8 */ + case 23: /* 023/8 is IANA reserved */ + case 36: /* 036/8 is IANA reserved */ + case 37: /* 037/8 is IANA reserved */ + case 39: /* 039/8 is IANA reserved */ + case 42: /* 042/8 is IANA reserved */ + case 49: /* 049/8 is IANA reserved */ + case 55: /* misc. U.S.A. Armed forces */ + case 127: /* 127/8 is reserved for loopback */ + case 179: /* 179/8 is IANA reserved */ + case 185: /* 185/8 is IANA reserved */ + return 1; + default: + break; + } + + /* 100-106/8 is IANA reserved */ + if (i1 >= 100 && i1 <= 106) + return 1; + + /* 172.16.0.0/12 is reserved for private nets by RFC1819 */ + if (i1 == 172 && i2 >= 16 && i2 <= 31) + return 1; + + /* 192.0.2.0/24 is reserved for documentation and examples (RFC5737) */ + /* 192.88.99.0/24 is used as 6to4 Relay anycast prefix by RFC3068 */ + /* 192.168.0.0/16 is reserved for private nets by RFC1819 */ + if (i1 == 192) { + if (i2 == 0 && i3 == 2) + return 1; + if (i2 == 88 && i3 == 99) + return 1; + if (i2 == 168) + return 1; + } + + /* 198.18.0.0/15 is used for benchmark tests by RFC2544 */ + /* 198.51.100.0/24 is reserved for documentation (RFC5737) */ + if (i1 == 198) { + if (i2 == 18 || i2 == 19) + return 1; + if (i2 == 51 && i3 == 100) + return 1; + } + + /* 169.254.0.0/16 is reserved for DHCP clients seeking addresses */ + if (i1 == 169 && i2 == 254) + return 1; + + /* 203.0.113.0/24 is reserved for documentation (RFC5737) */ + if (i1 == 203 && i2 == 0 && i3 == 113) + return 1; + + /* 224-239/8 is all multicast stuff */ + /* 240-255/8 is IANA reserved */ + if (i1 >= 224) + return 1; + + return 0; +} + +/* A trivial functon that maintains a cache of IP to MAC Address + entries. If the command is ARPCACHE_GET, this func looks for the + IPv4 address in ss and fills in the 'mac' parameter and returns + true if it is found. Otherwise (not found), the function returns + false. If the command is ARPCACHE_SET, the function adds an entry + with the given ip (ss) and mac address. An existing entry for the + IP ss will be overwritten with the new MAC address. true is always + returned for the set command. + WARNING: The caller must ensure that the supplied "ss" is of family + AF_INET. Otherwise the function will return 0 and there would be + no way for the caller to tell tell the difference between an error + or a cache miss. */ +#define ARPCACHE_GET 1 +#define ARPCACHE_SET 2 +static int do_arp_cache(int command, struct sockaddr_storage *ss, u8 *mac) { + struct sockaddr_in *sin = (struct sockaddr_in *) ss; + struct ArpCache { + u32 ip; /* Network byte order */ + u8 mac[6]; + }; + static struct ArpCache *Cache = NULL; + static int ArpCapacity = 0; + static int ArpCacheSz = 0; + int i; + + if (sin->sin_family != AF_INET) + return 0; + + if (command == ARPCACHE_GET) { + for (i = 0; i < ArpCacheSz; i++) { + if (Cache[i].ip == sin->sin_addr.s_addr) { + memcpy(mac, Cache[i].mac, 6); + return 1; + } + } + return 0; + } + assert(command == ARPCACHE_SET); + if (ArpCacheSz == ArpCapacity) { + if (ArpCapacity == 0) + ArpCapacity = 32; + else + ArpCapacity <<= 2; + Cache = (struct ArpCache *) safe_realloc(Cache, ArpCapacity * sizeof(struct ArpCache)); + } + + /* Ensure that it isn't already there ... */ + for (i = 0; i < ArpCacheSz; i++) { + if (Cache[i].ip == sin->sin_addr.s_addr) { + memcpy(Cache[i].mac, mac, 6); + return 1; + } + } + + /* Add it to the end of the list */ + Cache[i].ip = sin->sin_addr.s_addr; + memcpy(Cache[i].mac, mac, 6); + ArpCacheSz++; + return 1; +} + +/* A couple of trivial functions that maintain a cache of IP to MAC + * Address entries. Function arp_cache_get() looks for the IPv4 address + * in ss and fills in the 'mac' parameter and returns true if it is + * found. Otherwise (not found), the function returns false. + * Function arp_cache_set() adds an entry with the given ip (ss) and + * mac address. An existing entry for the IP ss will be overwritten + * with the new MAC address. arp_cache_set() always returns true. + * WARNING: The caller must ensure that the supplied "ss" is of family + * AF_INET. Otherwise the function will return 0 and there would be + * no way for the caller to tell tell the difference between an error + * or a cache miss.*/ +int arp_cache_get(struct sockaddr_storage *ss, u8 *mac){ + return do_arp_cache(ARPCACHE_GET, ss, mac); +} +int arp_cache_set(struct sockaddr_storage *ss, u8 *mac){ + return do_arp_cache(ARPCACHE_SET, ss, mac); +} + +/* Standard BSD internet checksum routine. Uses libdnet helper functions. */ +unsigned short in_cksum(u16 *ptr,int nbytes) { + int sum; + + sum = ip_cksum_add(ptr, nbytes, 0); + + return ip_cksum_carry(sum); + + return 0; +} + + +/* For computing TCP/UDP checksums, see RFC 1071 and TCP/IP Illustrated + sections 3.2, 11.3, and 17.3. */ +unsigned short tcpudp_cksum(const struct in_addr *src, const struct in_addr *dst, + u8 proto, u16 len, const void *hstart){ + struct pseudo { + struct in_addr src; + struct in_addr dst; + u8 zero; + u8 proto; + u16 length; + } hdr; + int sum; + + hdr.src = *src; + hdr.dst = *dst; + hdr.zero = 0; + hdr.proto = proto; + hdr.length = htons(len); + + /* Get the ones'-complement sum of the pseudo-header. */ + sum = ip_cksum_add(&hdr, sizeof(hdr), 0); + /* Add it to the sum of the packet. */ + sum = ip_cksum_add(hstart, len, sum); + + /* Fold in the carry, take the complement, and return. */ + return ip_cksum_carry(sum); +} + +void sethdrinclude(int sd) { +#ifdef IP_HDRINCL + int one = 1; + setsockopt(sd, IPPROTO_IP, IP_HDRINCL, (const char *) &one, sizeof(one)); +#endif +} + +void set_ipoptions(int sd, void *opts, size_t optslen) { +#ifdef IP_OPTIONS + if (sd == -1) + return; + + setsockopt(sd, IPPROTO_IP, IP_OPTIONS, (const char *) opts, optslen); +#endif +} + +void set_ttl(int sd, int ttl) { +#ifdef IP_TTL + if (sd == -1) + return; + + setsockopt(sd, IPPROTO_IP, IP_TTL, (const char *) &ttl, sizeof ttl); +#endif +} + +/* Returns whether the system supports pcap_get_selectable_fd() properly */ +int pcap_selectable_fd_valid() { +#if defined(WIN32) || defined(MACOSX) || (defined(FREEBSD) && (__FreeBSD_version < 500000)) + return 0; +#else + return 1; +#endif +} + +/* Call this instead of pcap_get_selectable_fd directly (or your code + won't compile on Windows). On systems which don't seem to support + the pcap_get_selectable_fd() function properly, returns -1, + otherwise simply calls pcap_selectable_fd and returns the + results. If you just want to test whether the function is supported, + use pcap_selectable_fd_valid() instead. */ +int my_pcap_get_selectable_fd(pcap_t *p) { +#if defined(WIN32) || defined(MACOSX) || (defined(FREEBSD) && (__FreeBSD_version < 500000)) + return -1; +#else + assert(pcap_selectable_fd_valid()); + return pcap_get_selectable_fd(p); +#endif +} + + +/* returns -1 if we can't use select() on the pcap device, 0 for timeout, and + * >0 for success. If select() fails we bail out because it couldn't work with + * the file descriptor we got from my_pcap_get_selectable_fd() + */ +int pcap_select(pcap_t *p, struct timeval *timeout) { + int fd, ret; + fd_set rfds; + + if ((fd = my_pcap_get_selectable_fd(p)) == -1) + return -1; + + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + + do { + errno = 0; + ret = select(fd + 1, &rfds, NULL, NULL, timeout); + if (ret == -1) { + if (errno == EINTR) + netutil_error("%s: %s", __func__, strerror(errno)); + else + netutil_fatal("Your system does not support select()ing on pcap devices (%s). PLEASE REPORT THIS ALONG WITH DETAILED SYSTEM INFORMATION TO THE nmap-dev MAILING LIST!", strerror(errno)); + } + } while (ret == -1); + + return ret; +} + +int pcap_select(pcap_t *p, long usecs) { + struct timeval tv; + + tv.tv_sec = usecs / 1000000; + tv.tv_usec = usecs % 1000000; + + return pcap_select(p, &tv); +} + + +/* These two are for eth_open_cached() and eth_close_cached() */ +static char etht_cache_device_name[64]; +static eth_t *etht_cache_device = NULL; + +/* A simple function that caches the eth_t from dnet for one device, + to avoid opening, closing, and re-opening it thousands of tims. If + you give a different device, this function will close the first + one. Thus this should never be used by programs that need to deal + with multiple devices at once. In addition, you MUST NEVER + eth_close() A DEVICE OBTAINED FROM THIS FUNCTION. Instead, you can + call eth_close_cached() to close whichever device (if any) is + cached. Returns NULL if it fails to open the device. */ +eth_t *eth_open_cached(const char *device) { + if (!device) + netutil_fatal("%s() called with NULL device name!", __func__); + if (!*device) + netutil_fatal("%s() called with empty device name!", __func__); + + if (strcmp(device, etht_cache_device_name) == 0) { + /* Yay, we have it cached. */ + return etht_cache_device; + } + + if (*etht_cache_device_name) { + eth_close(etht_cache_device); + etht_cache_device_name[0] = '\0'; + etht_cache_device = NULL; + } + + etht_cache_device = eth_open(device); + if (etht_cache_device) + Strncpy(etht_cache_device_name, device, + sizeof(etht_cache_device_name)); + + return etht_cache_device; +} + +/* See the description for eth_open_cached */ +void eth_close_cached() { + if (etht_cache_device) { + eth_close(etht_cache_device); + etht_cache_device = NULL; + etht_cache_device_name[0] = '\0'; + } + return; +} + +/* Takes a protocol number like IPPROTO_TCP, IPPROTO_UDP, IPPROTO_IP, + * etc, and returns an ASCII representation (or the string "unknown" if + * it doesn't recognize the number). If uppercase is non zero, the + * returned value will be in uppercase letters, otherwise it'll be + * in lowercase */ +const char *proto2ascii_case(u8 proto, int uppercase) { + switch (proto) { + + case IPPROTO_TCP: + return uppercase ? "TCP" : "tcp"; + break; + case IPPROTO_UDP: + return uppercase ? "UDP" : "udp"; + break; + case IPPROTO_SCTP: + return uppercase ? "SCTP" : "sctp"; + break; + case IPPROTO_IP: + return uppercase ? "IP" : "ip"; + break; +#ifdef IPPROTO_ICMP + case IPPROTO_ICMP: + return uppercase ? "ICMP" : "icmp"; + break; +#endif +#ifdef IPPROTO_IPV6 + case IPPROTO_IPV6: + return uppercase ? "IPv6" : "ipv6"; + break; +#endif +#ifdef IPPROTO_ICMPV6 + case IPPROTO_ICMPV6: + return uppercase ? "ICMPv6" : "icmpv6"; + break; +#endif +#ifdef IPPROTO_GRE + case IPPROTO_GRE: // Generic Routing Encapsulation + return uppercase ? "GRE" : "gre"; + break; +#endif +#ifdef IPPROTO_ESP + case IPPROTO_ESP: // Encapsulating Security Payload (IPSec) + return uppercase ? "IPSec/ESP" : "ipsec/esp"; + break; +#endif +#ifdef IPPROTO_AH + case IPPROTO_AH: // Authentication Header (IPSec) + return uppercase ? "IPSec/AH" : "ipsec/ah"; + break; +#endif + default: + return uppercase ? "UNKNOWN" : "unknown"; + } + + return NULL; // Unreached +} + +const char *proto2ascii_lowercase(u8 proto) { + return proto2ascii_case(proto, 0); +} +const char *proto2ascii_uppercase(u8 proto) { + return proto2ascii_case(proto, 1); +} + +/* Get an ASCII information about a tcp option which is pointed by + optp, with a length of len. The result is stored in the result + buffer. The result may look like "" */ +void tcppacketoptinfo(u8 *optp, int len, char *result, int bufsize) { + assert(optp); + assert(result); + char *p, ch; + u8 *q; + int opcode; + u16 tmpshort; + u32 tmpword1, tmpword2; + unsigned int i=0; + + p = result; + *p = '\0'; + q = optp; + ch = '<'; + + while (len > 0 && bufsize > 2) { + Snprintf(p, bufsize, "%c", ch); + bufsize--; + p++; + opcode = *q++; + if (!opcode) { /* End of List */ + + Snprintf(p, bufsize, "eol"); + bufsize -= strlen(p); + p += strlen(p); + + len--; + + } else if (opcode == 1) { /* No Op */ + Snprintf(p, bufsize, "nop"); + bufsize -= strlen(p); + p += strlen(p); + + len--; + } else if (opcode == 2) { /* MSS */ + if (len < 4) + break; /* MSS has 4 bytes */ + + q++; + memcpy(&tmpshort, q, 2); + + Snprintf(p, bufsize, "mss %u", ntohs(tmpshort)); + bufsize -= strlen(p); + p += strlen(p); + + q += 2; + len -= 4; + } else if (opcode == 3) { /* Window Scale */ + if (len < 3) + break; /* Window Scale option has 3 bytes */ + + q++; + + Snprintf(p, bufsize, "wscale %u", *q); + bufsize -= strlen(p); + p += strlen(p); + + q++; + len -= 3; + } else if (opcode == 4) { /* SACK permitted */ + if (len < 2) + break; /* SACK permitted option has 2 bytes */ + + Snprintf(p, bufsize, "sackOK"); + bufsize -= strlen(p); + p += strlen(p); + + q++; + len -= 2; + } else if (opcode == 5) { /* SACK */ + unsigned sackoptlen = *q; + if ((unsigned) len < sackoptlen) + break; + + /* This would break parsing, so it's best to just give up */ + if (sackoptlen < 2) + break; + + q++; + + if ((sackoptlen - 2) == 0 || ((sackoptlen - 2) % 8 != 0)) { + Snprintf(p, bufsize, "malformed sack"); + bufsize -= strlen(p); + p += strlen(p); + } else { + Snprintf(p, bufsize, "sack %d ", (sackoptlen - 2) / 8); + bufsize -= strlen(p); + p += strlen(p); + for (i = 0; i < sackoptlen - 2; i += 8) { + memcpy(&tmpword1, q + i, 4); + memcpy(&tmpword2, q + i + 4, 4); + Snprintf(p, bufsize, "{%u:%u}", tmpword1, tmpword2); + bufsize -= strlen(p); + p += strlen(p); + } + } + + q += sackoptlen - 2; + len -= sackoptlen; + } else if (opcode == 8) { /* Timestamp */ + if (len < 10) + break; /* Timestamp option has 10 bytes */ + + q++; + memcpy(&tmpword1, q, 4); + memcpy(&tmpword2, q + 4, 4); + + Snprintf(p, bufsize, "timestamp %u %u", ntohl(tmpword1), + ntohl(tmpword2)); + bufsize -= strlen(p); + p += strlen(p); + + q += 8; + len -= 10; + } + + ch = ','; + } + + if (len > 0) { + *result = '\0'; + return; + } + + Snprintf(p, bufsize, ">"); +} + + + +/* A trivial function used with qsort to sort the routes by netmask */ +static int nmaskcmp(const void *a, const void *b) { + struct sys_route *r1 = (struct sys_route *) a; + struct sys_route *r2 = (struct sys_route *) b; + if (r1->netmask == r2->netmask) { + /* Compare addresses of equal elements to make the sort stable, as suggested + by the Glibc manual. */ + if (a < b) + return -1; + else if (a > b) + return 1; + else + return 0; + } + if (ntohl(r1->netmask) > ntohl(r2->netmask)) + return -1; + else + return 1; +} + + + +#if WIN32 +static int collect_dnet_interfaces(const struct intf_entry *entry, void *arg) { + struct dnet_collector_route_nfo *dcrn = (struct dnet_collector_route_nfo *) arg; + bool primary_done; + int num_aliases_done; + + primary_done = false; + num_aliases_done = 0; + while (!primary_done || num_aliases_done < entry->intf_alias_num) { + /* Make sure we have room for the new route */ + if (dcrn->numifaces >= dcrn->capacity) { + dcrn->capacity <<= 2; + dcrn->ifaces = (struct interface_info *) safe_realloc(dcrn->ifaces, + dcrn->capacity * sizeof(struct interface_info)); + } + + /* The first time through the loop we add the primary interface record. + After that we add the aliases one at a time. */ + if (!primary_done) { + if (entry->intf_addr.addr_type == ADDR_TYPE_IP) { + addr_ntos(&entry->intf_addr, (struct sockaddr *) &dcrn->ifaces[dcrn->numifaces].addr); + dcrn->ifaces[dcrn->numifaces].netmask_bits = entry->intf_addr.addr_bits; + } + primary_done = true; + } else if (num_aliases_done < (int) entry->intf_alias_num) { + if (entry->intf_alias_addrs[num_aliases_done].addr_type == ADDR_TYPE_IP) { + addr_ntos(&entry->intf_alias_addrs[num_aliases_done], (struct sockaddr *) &dcrn->ifaces[dcrn->numifaces].addr); + dcrn->ifaces[dcrn->numifaces].netmask_bits = entry->intf_alias_addrs[num_aliases_done].addr_bits; + } + num_aliases_done++; + } + + /* OK, address/netmask found. Let's get the name */ + Strncpy(dcrn->ifaces[dcrn->numifaces].devname, entry->intf_name, + sizeof(dcrn->ifaces[dcrn->numifaces].devname)); + Strncpy(dcrn->ifaces[dcrn->numifaces].devfullname, entry->intf_name, + sizeof(dcrn->ifaces[dcrn->numifaces].devfullname)); + + /* Interface type */ + if (entry->intf_type == INTF_TYPE_ETH) { + dcrn->ifaces[dcrn->numifaces].device_type = devt_ethernet; + /* Collect the MAC address since this is ethernet */ + memcpy(dcrn->ifaces[dcrn->numifaces].mac, &entry->intf_link_addr.addr_eth.data, 6); + } else if (entry->intf_type == INTF_TYPE_LOOPBACK) { + dcrn->ifaces[dcrn->numifaces].device_type = devt_loopback; + } else if (entry->intf_type == INTF_TYPE_TUN) { + dcrn->ifaces[dcrn->numifaces].device_type = devt_p2p; + } else { + dcrn->ifaces[dcrn->numifaces].device_type = devt_other; + } + + /* Is the interface up and running? */ + dcrn->ifaces[dcrn->numifaces].device_up = (entry->intf_flags & INTF_FLAG_UP) ? true : false; + + /* For the rest of the information, we must open the interface directly ... */ + dcrn->numifaces++; + } + + return 0; +} + +/* Get a list of interfaces using dnet and intf_loop. */ +static struct interface_info *getinterfaces_dnet(int *howmany, char *errstr, size_t errstrlen) { + struct dnet_collector_route_nfo dcrn; + intf_t *it; + + dcrn.routes = NULL; + dcrn.numroutes = 0; + dcrn.numifaces = 0; + + assert(howmany); + + /* Initialize the interface array. */ + dcrn.capacity = 16; + dcrn.ifaces = (struct interface_info *) safe_zalloc(sizeof(struct interface_info) * dcrn.capacity); + + it = intf_open(); + if (!it){ + if(errstr) Snprintf(errstr, errstrlen, "%s: intf_open() failed", __func__); + *howmany=-1; + return NULL; + } + if (intf_loop(it, collect_dnet_interfaces, &dcrn) != 0){ + if(errstr) Snprintf(errstr, errstrlen, "%s: intf_loop() failed", __func__); + *howmany=-1; + return NULL; + } + intf_close(it); + + *howmany = dcrn.numifaces; + return dcrn.ifaces; +} + +#else /* !WIN32 */ + +/* Get a list of interfaces using ioctl(SIOCGIFCONF). */ +static struct interface_info *getinterfaces_siocgifconf(int *howmany, char *errstr, size_t errstrlen) { + struct interface_info *devs; + int count = 0; + int capacity = 0; + struct ifconf ifc; + struct ifreq *ifr; + int sd; + int len; + assert(howmany); + capacity = 16; + devs = (struct interface_info *) safe_zalloc(sizeof(struct interface_info) * capacity); + + /* Dummy socket for ioctl */ + sd = socket(AF_INET, SOCK_DGRAM, 0); + if (sd < 0){ + if(errstr) Snprintf(errstr, errstrlen, "socket in %s", __func__); + *howmany=-1; + return NULL; + } + + ifc.ifc_len = 20480; + ifc.ifc_buf = (char *) safe_zalloc(ifc.ifc_len); + /* Returns an array of struct ifreq in ifc.ifc_req, which is a union with + ifc.ifc_buf. */ + if (ioctl(sd, SIOCGIFCONF, &ifc) < 0){ + if(errstr) Snprintf(errstr, errstrlen, "Failed to determine your configured interfaces!\n"); + *howmany=-1; + return NULL; + } + if (ifc.ifc_len == 0){ + if(errstr) Snprintf(errstr, errstrlen, "%s: SIOCGIFCONF claims you have no network interfaces!\n", __func__); + *howmany=-1; + return NULL; + } + ifr = ifc.ifc_req; + + for (ifr = ifc.ifc_req; + ifr && ifr->ifr_name[0] && (void *) ifr < (void *)((char *) ifc.ifc_buf + ifc.ifc_len); + ifr = (struct ifreq *) ((char *) ifr + len)) { + struct sockaddr_in *sin; + struct ifreq tmpifr; + u16 ifflags; + int rc; + char *p; + + len = sizeof(struct ifreq); +#if HAVE_SOCKADDR_SA_LEN + /* Some platforms (such as FreeBSD) have an sa_len member that may make the + ifr longer than sizeof(struct ifreq). */ + if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_ifru)) + len += ifr->ifr_addr.sa_len - sizeof(ifr->ifr_ifru); +#endif + + /* skip any device with no name */ + if (ifr->ifr_name[0] == '\0') + continue; + + /* We currently only handle IPv4 */ + sin = (struct sockaddr_in *) &ifr->ifr_addr; + if (sin->sin_family != AF_INET) + continue; + + /* Make room for this new interface if necessary. */ + if (count >= capacity) { + capacity <<= 2; + devs = (struct interface_info *) safe_realloc(devs, sizeof(struct interface_info) * capacity); + } + + /* We know the address, put it in the array. */ + memcpy(&(devs[count].addr), sin, MIN(sizeof(devs[count].addr), sizeof(*sin))); + Strncpy(devs[count].devname, ifr->ifr_name, sizeof(devs[count].devname)); + Strncpy(devs[count].devfullname, ifr->ifr_name, sizeof(devs[count].devfullname)); + /* devname isn't allowed to have alias qualification */ + p = strchr(devs[count].devname, ':'); + if (p != NULL) + *p = '\0'; + + /* Use tmpifr for further ioctl requests. We're going to make a bunch of + ioctl calls to learn about the interface and set fields in devs[count]. + + The Linux netdevice(7) man page says that you only have to set ifr_name + before making the ioctl, but perhaps other platforms need ifr_addr to be + set too. ifr_name will persist but ifr_addr is in a union with the ioctl + return value, so it has to be reset before every call. The general + pattern is memcpy, then ioctl. */ + Strncpy(tmpifr.ifr_name, ifr->ifr_name, sizeof(tmpifr.ifr_name)); + + /* Look up the netmask. Note setting of ifr_addr. */ + memcpy(&tmpifr.ifr_addr, sin, MIN(sizeof(tmpifr.ifr_addr), sizeof(*sin))); + rc = ioctl(sd, SIOCGIFNETMASK, &tmpifr); + if (rc < 0 && errno != EADDRNOTAVAIL){ + if(errstr) Snprintf(errstr, errstrlen, "Failed to determine the netmask of %s!", tmpifr.ifr_name); + *howmany=-1; + return NULL; + } + else if (rc < 0) + devs[count].netmask_bits = 32; + else { + /* We would use ifr_netmask, but that's only on Linux, so use ifr_addr + which shares the same memory space in a union. */ + addr_stob(&(tmpifr.ifr_addr), &devs[count].netmask_bits); + } + + /* Now we need to determine the device type ... this technique is kinda iffy + ... may not be portable. */ + /* Get the flags. */ + memcpy(&tmpifr.ifr_addr, sin, MIN(sizeof(tmpifr.ifr_addr), sizeof(*sin))); + rc = ioctl(sd, SIOCGIFFLAGS, &tmpifr); + if (rc < 0){ + if(errstr) Snprintf(errstr, errstrlen, "Failed to get IF Flags for device %s", ifr->ifr_name); + *howmany=-1; + return NULL; + } + ifflags = tmpifr.ifr_flags; + + if (ifflags & IFF_LOOPBACK) { + devs[count].device_type = devt_loopback; + } else if (ifflags & IFF_BROADCAST) { + devs[count].device_type = devt_ethernet; + + /* If the device type is ethernet, get the MAC address. */ +#ifdef SIOCGIFHWADDR + memcpy(&tmpifr.ifr_addr, sin, MIN(sizeof(tmpifr.ifr_addr), sizeof(*sin))); + rc = ioctl(sd, SIOCGIFHWADDR, &tmpifr); + if (rc < 0 && errno != EADDRNOTAVAIL){ + if(errstr) Snprintf(errstr, errstrlen, "Failed to determine the MAC address of %s!", tmpifr.ifr_name); + *howmany=-1; + return NULL; + } + else if (rc >= 0) + memcpy(devs[count].mac, &tmpifr.ifr_addr.sa_data, 6); +#else + /* Let's just let libdnet handle it ... */ + eth_t *ethsd = eth_open_cached(devs[count].devname); + eth_addr_t ethaddr; + + if (!ethsd) { + netutil_error("Warning: Unable to open interface %s -- skipping it.", devs[count].devname); + continue; + } + if (eth_get(ethsd, ðaddr) != 0) { + netutil_error("Warning: Unable to get hardware address for interface %s -- skipping it.", devs[count].devname); + continue; + } + memcpy(devs[count].mac, ethaddr.data, 6); +#endif /*SIOCGIFHWADDR*/ + } else if (ifflags & IFF_POINTOPOINT) { + devs[count].device_type = devt_p2p; + } else { + devs[count].device_type = devt_other; + } + + if (ifflags & IFF_UP) + devs[count].device_up = 1; + else + devs[count].device_up = 0; + + /* All done with this interface. Increase the count. */ + count++; + } + free(ifc.ifc_buf); + close(sd); + + *howmany = count; + return devs; +} +#endif + +/* Returns an allocated array of struct interface_info representing the + available interfaces. The number of interfaces is returned in *howmany. This + function just does caching of results; the real work is done in + getinterfaces_dnet() or getinterfaces_siocgifconf(). + On error, NULL is returned, howmany is set to -1 and the supplied + error buffer "errstr", if not NULL, will contain an error message. */ +struct interface_info *getinterfaces(int *howmany, char *errstr, size_t errstrlen) { + static int initialized = 0; + static struct interface_info *mydevs; + static int numifaces = 0; + + if (!initialized) { +#if WIN32 + /* On Win32 we just use Dnet to determine the interface list */ + mydevs = getinterfaces_dnet(&numifaces, errstr, errstrlen); +#else + mydevs = getinterfaces_siocgifconf(&numifaces, errstr, errstrlen); +#endif + initialized = 1; + } + + /* These will propagate any error produced in getinterfaces_xxxx() to + * the caller. */ + if (howmany) + *howmany = numifaces; + return mydevs; +} + + +/* The 'dev' passed in must be at least 32 bytes long. Returns 0 on success. */ +int ipaddr2devname(char *dev, const struct in_addr *addr) { + struct interface_info *ifaces; + struct sockaddr_in *sin; + int numifaces; + int i; + + ifaces = getinterfaces(&numifaces, NULL, 0); + + if (ifaces == NULL) + return -1; + + for (i = 0; i < numifaces; i++) { + sin = (struct sockaddr_in *) &ifaces[i].addr; + if (sin->sin_family != AF_INET) + continue; + if (addr->s_addr == sin->sin_addr.s_addr) { + Strncpy(dev, ifaces[i].devname, 32); + return 0; + } + } + + return -1; +} + +int devname2ipaddr(char *dev, struct in_addr *addr) { + struct interface_info *mydevs; + struct sockaddr_in *s; + int numdevs; + int i; + mydevs = getinterfaces(&numdevs, NULL, 0); + + if (!mydevs) + return -1; + + for (i = 0; i < numdevs; i++) { + s = (struct sockaddr_in *) &mydevs[i].addr; + if (s->sin_family != AF_INET) /* Currently we only support IPv4 */ + continue; + if (!strcmp(dev, mydevs[i].devfullname)) { + memcpy(addr, (char *) &s->sin_addr, sizeof(struct in_addr)); + return 0; + } + } + return -1; +} + +/* Looks for an interface with the given name (iname), and returns the + corresponding interface_info if found. Will accept a match of + devname or devfullname. Returns NULL if none found */ +struct interface_info *getInterfaceByName(char *iname) { + struct interface_info *ifaces; + int numifaces = 0; + int ifnum; + + ifaces = getinterfaces(&numifaces, NULL, 0); + + for (ifnum = 0; ifnum < numifaces; ifnum++) { + if (strcmp(ifaces[ifnum].devfullname, iname) == 0 || + strcmp(ifaces[ifnum].devname, iname) == 0) + return &ifaces[ifnum]; + } + + return NULL; +} + + + +/* Read system routes from a handle to a /proc/net/route file. */ +static struct sys_route *getsysroutes_proc(FILE *routefp, int *howmany, char *errstr, size_t errstrlen) { + struct sys_route *routes = NULL; + int route_capacity = 128; + struct interface_info *ifaces; + char buf[1024]; + char iface[16]; + char *p, *endptr; + struct interface_info *ii; + u32 mask; + struct sockaddr_in *sin; + int numifaces = 0, numroutes = 0; + int i; + assert(howmany); + + /* Obtain list of system network interfaces */ + if( (ifaces=getinterfaces(&numifaces, errstr, errstrlen)) == NULL ){ + *howmany=-1; + return NULL; + } + routes = (struct sys_route *) safe_zalloc(route_capacity * sizeof(struct sys_route)); + + /* Kill the first line (column headers) */ + errno = 0; + if (fgets(buf, sizeof(buf), routefp) == NULL) { + if (errno){ + if(errstr) Snprintf(errstr, errstrlen, "Read error in /proc/net/route"); + }else{ + if(errstr) Snprintf(errstr, errstrlen, "Premature EOF in /proc/net/route"); + } + *howmany=-1; + return NULL; + } + + while (fgets(buf, sizeof(buf), routefp)) { + p = strtok(buf, " \t\n"); + if (!p) { + netutil_error("Could not find interface in /proc/net/route line"); + continue; + } + if (*p == '*') + continue; /* Deleted route -- any other valid reason for a route to start with an asterict? */ + Strncpy(iface, p, sizeof(iface)); + p = strtok(NULL, " \t\n"); + if (!p) { + netutil_error("Could not find destination in /proc/net/route line"); + continue; + } + endptr = NULL; + routes[numroutes].dest = strtoul(p, &endptr, 16); + if (!endptr || *endptr) { + netutil_error("Failed to determine Destination from /proc/net/route"); + continue; + } + + /* Now for the gateway */ + p = strtok(NULL, " \t\n"); + if (!p) { + netutil_error("Could not find gateway in /proc/net/route line"); + continue; + } + endptr = NULL; + routes[numroutes].gw.s_addr = strtoul(p, &endptr, 16); + if (!endptr || *endptr) { + netutil_error("Failed to determine gw for %s from /proc/net/route", iface); + } + for (i = 0; i < 5; i++) { + p = strtok(NULL, " \t\n"); + if (!p) + break; + } + if (!p) { + netutil_error("Failed to find field %d in /proc/net/route", i + 2); + continue; + } + endptr = NULL; + routes[numroutes].netmask = strtoul(p, &endptr, 16); + if (!endptr || *endptr) { + netutil_error("Failed to determine mask from /proc/net/route"); + continue; + } + for (i = 0; i < numifaces; i++) { + if (!strcmp(iface, ifaces[i].devfullname)) { + routes[numroutes].device = &ifaces[i]; + break; + } + } + /* If device name in the route file does not match the full name (including + alias extension) of any interface, then try to find at least an alias of + the proper interface. */ + if (i == numifaces) { + for (i = 0; i < numifaces; i++) { + if (!strcmp(iface, ifaces[i].devname)) { + routes[numroutes].device = &ifaces[i]; + break; + } + } + } + if (i == numifaces) { + netutil_error("Failed to find device %s which was referenced in /proc/net/route", iface); + continue; + } + + /* Now to deal with some alias nonsense ... at least on Linux + this file will just list the short name, even though IP + information (such as source address) from an alias must be + used. So if the purported device can't reach the gateway, + try to find a device that starts with the same short + devname, but can (e.g. eth0 -> eth0:3) */ + ii = &ifaces[i]; + mask = htonl((unsigned long) (0 - 1) << (32 - ii->netmask_bits)); + sin = (struct sockaddr_in *) &ii->addr; + if (routes[numroutes].gw.s_addr && (sin->sin_addr.s_addr & mask) != + (routes[numroutes].gw.s_addr & mask)) { + for (i = 0; i < numifaces; i++) { + if (ii == &ifaces[i]) + continue; + if (strcmp(ii->devname, ifaces[i].devname) == 0) { + sin = (struct sockaddr_in *) &ifaces[i].addr; + if ((sin->sin_addr.s_addr & mask) == + (routes[numroutes].gw.s_addr & mask)) { + routes[numroutes].device = &ifaces[i]; + } + } + } + } + + numroutes++; + if (numroutes >= route_capacity) { + route_capacity <<= 2; + routes = (struct sys_route *) safe_realloc(routes, route_capacity * sizeof(struct sys_route)); + } + } + + *howmany = numroutes; + return routes; +} + + +/* This is a helper for getsysroutes_dnet. Once the table of routes is in + place, this function assigns each to an interface and removes any routes + that can't be assigned. */ +static struct dnet_collector_route_nfo *sysroutes_dnet_find_interfaces(struct dnet_collector_route_nfo *dcrn) +{ + struct interface_info *ifaces; + u32 mask; + struct sockaddr_in *sin; + int numifaces = 0; + int i, j; + int changed=0; + + if( (ifaces=getinterfaces(&numifaces, NULL, 0))==NULL ) + return NULL; + for (i = 0; i < dcrn->numroutes; i++) { + /* First we match up routes whose gateway address directly matches the + address of an interface. */ + for (j = 0; j < numifaces; j++) { + sin = (struct sockaddr_in *) &ifaces[j].addr; + mask = + htonl((unsigned long) (0 - 1) << (32 - ifaces[j].netmask_bits)); + if ((sin->sin_addr.s_addr & mask) == + (dcrn->routes[i].gw.s_addr & mask)) { + dcrn->routes[i].device = &ifaces[j]; + break; + } + } + } + + /* Find any remaining routes that don't yet have an interface, and try to + match them up with the interface of another route. This handles "two-step" + routes like sometimes exist with PPP, where the gateway address of the + default route doesn't match an interface address, but the gateway address + goes through another route that does have an interface. */ + + do { + changed = 0; + for (i = 0; i < dcrn->numroutes; i++) { + if (dcrn->routes[i].device != NULL) + continue; + /* Does this route's gateway go through another route with an assigned + interface? */ + for (j = 0; j < dcrn->numroutes; j++) { + if (dcrn->routes[i].gw.s_addr == dcrn->routes[j].dest + && dcrn->routes[j].device != NULL) { + dcrn->routes[i].device = dcrn->routes[j].device; + changed = 1; + } + } + } + } while (changed); + + /* Cull any routes that still don't have an interface. */ + i = 0; + while (i < dcrn->numroutes) { + if (dcrn->routes[i].device == NULL) { + netutil_error("WARNING: Unable to find appropriate interface for system route to %s", inet_ntoa(dcrn->routes[i].gw)); + /* Remove this entry from the table. */ + memmove(dcrn->routes + i, dcrn->routes + i + 1, sizeof(dcrn->routes[0]) * (dcrn->numroutes - i - 1)); + dcrn->numroutes--; + } else { + i++; + } + } + + return dcrn; +} + + +/* This is the callback for the call to route_loop in getsysroutes_dnet. It + takes a route entry and adds it into the dnet_collector_route_nfo struct. */ +static int collect_dnet_routes(const struct route_entry *entry, void *arg) { + struct dnet_collector_route_nfo *dcrn = (struct dnet_collector_route_nfo *) arg; + /* Make sure that it is the proper type of route ... */ + if (entry->route_dst.addr_type != ADDR_TYPE_IP || entry->route_gw.addr_type != ADDR_TYPE_IP) + return 0; /* Not interested in IPv6 routes at the moment ... */ + + /* Make sure we have room for the new route */ + if (dcrn->numroutes >= dcrn->capacity) { + dcrn->capacity <<= 2; + dcrn->routes = (struct sys_route *) safe_realloc(dcrn->routes, dcrn->capacity * sizeof(struct sys_route)); + } + + /* Now for the important business */ + dcrn->routes[dcrn->numroutes].dest = entry->route_dst.addr_ip; + addr_btom(entry->route_dst.addr_bits, + &dcrn->routes[dcrn->numroutes].netmask, + sizeof(dcrn->routes[dcrn->numroutes].netmask)); + dcrn->routes[dcrn->numroutes].gw.s_addr = entry->route_gw.addr_ip; + dcrn->numroutes++; + + return 0; +} + + +/* Read system routes via libdnet. */ +static struct sys_route *getsysroutes_dnet(int *howmany, char *errstr, size_t errstrlen) { + struct dnet_collector_route_nfo dcrn; + + dcrn.capacity = 128; + dcrn.routes = (struct sys_route *) safe_zalloc(dcrn.capacity * sizeof(struct sys_route)); + dcrn.numroutes = 0; + dcrn.ifaces = NULL; + dcrn.numifaces = 0; + assert(howmany); + route_t *dr = route_open(); + + if (!dr){ + if(errstr) Snprintf(errstr, errstrlen, "%s: route_open() failed", __func__); + *howmany=-1; + return NULL; + } + if (route_loop(dr, collect_dnet_routes, &dcrn) != 0) { + if(errstr) Snprintf(errstr, errstrlen, "%s: route_loop() failed", __func__); + *howmany=-1; + return NULL; + } + route_close(dr); + + /* Now match up the routes to interfaces. */ + if( sysroutes_dnet_find_interfaces(&dcrn) == NULL ){ + if(errstr) Snprintf(errstr, errstrlen, "%s: sysroutes_dnet_find_interfaces() failed", __func__); + return NULL; + } + + *howmany = dcrn.numroutes; + return dcrn.routes; +} + + +/* Parse the system routing table, converting each route into a + sys_route entry. Returns an array of sys_routes. numroutes is set + to the number of routes in the array. The routing table is only + read the first time this is called -- later results are cached. + The returned route array is sorted by netmask with the most + specific matches first. + On error, NULL is returned, howmany is set to -1 and the supplied + error buffer "errstr", if not NULL, will contain an error message. */ +struct sys_route *getsysroutes(int *howmany, char *errstr, size_t errstrlen) { + static struct sys_route *routes = NULL; + static int numroutes = 0; + FILE *routefp; + assert(howmany); + + if (routes != NULL) { + /* We have it cached. */ + *howmany = numroutes; + return routes; + } + + /* First let us try Linux-style /proc/net/route */ + routefp = fopen("/proc/net/route", "r"); + if (routefp) { + routes = getsysroutes_proc(routefp, howmany, errstr, errstrlen); + fclose(routefp); + } else { + routes = getsysroutes_dnet(howmany, errstr, errstrlen); + } + + /* Check if we managed to get the routes and sort them if we did */ + if(routes==NULL){ + *howmany=-1; + return NULL; + }else{ + numroutes = *howmany; + /* Ensure that the route array is sorted by netmask */ + qsort(routes, numroutes, sizeof(routes[0]), nmaskcmp); + } + return routes; +} + + +/* Tries to determine whether the supplied address corresponds to + * localhost. (eg: the address is something like 127.x.x.x, the address + * matches one of the local network interfaces' address, etc). + * Returns 1 if the address is thought to be localhost and 0 otherwise */ +int islocalhost(const struct in_addr *const addr) { + char dev[128]; + /* If it is 0.0.0.0 or starts with 127 then it is + probably localhost */ + if ((addr->s_addr & htonl(0xFF000000)) == htonl(0x7F000000)) + return 1; + + if (!addr->s_addr) + return 1; + + /* If it is the same addy as a local interface, then it is + probably localhost */ + if (ipaddr2devname(dev, addr) != -1) + return 1; + + /* OK, so to a first approximation, this addy is probably not + localhost */ + return 0; +} + + +/* Determines whether the supplied address corresponds to a private, + * non-Internet-routable address. See RFC1918 for details. + * Returns 1 if the address is private or 0 otherwise. */ +int isipprivate(const struct in_addr *const addr) { + char *ipc; + unsigned char i1, i2; + + if (!addr) + return 0; + + ipc = (char *) &(addr->s_addr); + i1 = ipc[0]; + i2 = ipc[1]; + + /* 10.0.0.0/8 */ + if (i1 == 10) + return 1; + + /* 172.16.0.0/12 */ + if (i1 == 172 && i2 >= 16 && i2 <= 31) + return 1; + + /* 192.168.0.0/16 */ + if (i1 == 192 && i2 == 168) + return 1; + + return 0; +} + + +char *nexthdrtoa(u8 nextheader, int acronym){ + +static char buffer[129]; +memset(buffer, 0, 129); + + +switch(nextheader){ + + case 0: + if(acronym) + strncpy(buffer, "HOPOPT", 128); + else + strncpy(buffer, "IPv6 Hop-by-Hop Option", 128); + break; + + + case 1: + if(acronym) + strncpy(buffer, "ICMP", 128); + else + strncpy(buffer, "Internet Control Message", 128); + break; + + + case 2: + if(acronym) + strncpy(buffer, "IGMP", 128); + else + strncpy(buffer, "Internet Group Management", 128); + break; + + + case 4: + if(acronym) + strncpy(buffer, "IP", 128); + else + strncpy(buffer, "IP in IP (encapsulation)", 128); + break; + + + case 6: + if(acronym) + strncpy(buffer, "TCP", 128); + else + strncpy(buffer, "Transmission Control Protocol", 128); + break; + + + case 8: + if(acronym) + strncpy(buffer, "EGP", 128); + else + strncpy(buffer, "Exterior Gateway Protocol", 128); + break; + + + case 9: + if(acronym) + strncpy(buffer, "IGP", 128); + else + strncpy(buffer, "Interior Gateway Protocol", 128); + break; + + + case 17: + if(acronym) + strncpy(buffer, "UDP", 128); + else + strncpy(buffer, "User Datagram", 128); + break; + + + case 41: + if(acronym) + strncpy(buffer, "IPv6", 128); + else + strncpy(buffer, "Internet Protocol version 6", 128); + break; + + + case 43: + if(acronym) + strncpy(buffer, "IPv6-Route", 128); + else + strncpy(buffer, "Routing Header for IPv6", 128); + break; + + + case 44: + if(acronym) + strncpy(buffer, "IPv6-Frag", 128); + else + strncpy(buffer, "Fragment Header for IPv6", 128); + break; + + + case 50: + if(acronym) + strncpy(buffer, "ESP", 128); + else + strncpy(buffer, "Encap Security Payload", 128); + break; + + + case 51: + if(acronym) + strncpy(buffer, "AH", 128); + else + strncpy(buffer, "Authentication Header", 128); + break; + + + case 55: + if(acronym) + strncpy(buffer, "MOBILE", 128); + else + strncpy(buffer, "IP Mobility", 128); + break; + + + case 58: + if(acronym) + strncpy(buffer, "IPv6-ICMP", 128); + else + strncpy(buffer, "ICMP for IPv6", 128); + break; + + + case 59: + if(acronym) + strncpy(buffer, "IPv6-NoNxt", 128); + else + strncpy(buffer, "No Next Header for IPv6", 128); + break; + + + case 60: + if(acronym) + strncpy(buffer, "IPv6-Opts", 128); + else + strncpy(buffer, "Destination Options for IPv6", 128); + break; + + + case 70: + if(acronym) + strncpy(buffer, "VISA", 128); + else + strncpy(buffer, "VISA Protocol", 128); + break; + + + case 88: + if(acronym) + strncpy(buffer, "EIGRP", 128); + else + strncpy(buffer, "Enhanced Interior Gateway Routing Protocol ", 128); + break; + + + case 94: + if(acronym) + strncpy(buffer, "IPIP", 128); + else + strncpy(buffer, "IP-within-IP Encapsulation Protocol", 128); + break; + + + case 132: + if(acronym) + strncpy(buffer, "SCTP", 128); + else + strncpy(buffer, "Stream Control Transmission Protocol", 128); + break; + + + case 133: + if(acronym) + strncpy(buffer, "FC", 128); + else + strncpy(buffer, "Fibre Channel", 128); + break; + + + case 135: + if(acronym) + strncpy(buffer, "MH", 128); + else + strncpy(buffer, "Mobility Header", 128); + break; + + } /* End of switch */ + + + return buffer; + +} /* End of nexthdrtoa() */ + + +/* TODO: Needs refactoring */ +static inline char* STRAPP(const char *fmt, ...) { + static char buf[256]; + static int bp; + int left = (int)sizeof(buf)-bp; + if(!fmt){ + bp = 0; + return(buf); + } + if (left <= 0) + return buf; + va_list ap; + va_start(ap, fmt); + bp += Vsnprintf (buf+bp, left, fmt, ap); + va_end(ap); + + return(buf); +} + +/* TODO: Needs refactoring */ +#define HEXDUMP -2 +#define UNKNOWN -1 + +#define BREAK() \ + {option_type = HEXDUMP; break;} +#define CHECK(tt) \ + if(tt >= option_end) \ + {option_type = HEXDUMP; break;} + +/* Takes binary data found in the IP Options field of an IPv4 packet + * and returns a string containing an ASCII description of the options + * found. The function returns a pointer to a static buffer that + * subsequent calls will overwrite. On error, NULL is returned. */ +char *format_ip_options(u8* ipopt, int ipoptlen) { + char ipstring[32]; + int option_type = UNKNOWN;// option type + int option_len = 0; // option length + int option_pt = 0; // option pointer + int option_fl = 0; // option flag + u8 *tptr; // temp pointer + u32 *tint; // temp int + + int option_sta = 0; // option start offset + int option_end = 0; // option end offset + int pt = 0; // current offset + + // clear buffer + STRAPP(NULL,NULL); + + if(!ipoptlen) + return(NULL); + + while(pt= ipoptlen) // no more chars + {option_type = HEXDUMP;pt--; option_end = 255; continue;} // no length field, hex dump to the end + option_len = ipopt[pt++]; + // end must not be greater than length + option_end = MIN(option_sta + option_len, ipoptlen); + // end must not be smaller than current position + option_end = MAX(option_end, option_sta+2); + } + } + switch(option_type) { + case 0: // IPOPT_END + STRAPP(" EOL", NULL); + option_type = UNKNOWN; + break; + case 1: // IPOPT_NOP + STRAPP(" NOP", NULL); + option_type = UNKNOWN; + break; +/* case 130: // IPOPT_SECURITY + option_type=-1; + break;*/ + case 131: // IPOPT_LSRR -> Loose Source and Record Route + case 137: // IPOPT_SSRR -> Strict Source and Record Route + case 7: // IPOPT_RR -> Record Route + if(pt - option_sta == 2) { + STRAPP(" %s%s{", (option_type==131)?"LS":(option_type==137)?"SS":"", "RR"); + // option pointer + CHECK(pt); + option_pt = ipopt[pt++]; + if(option_pt%4 != 0 || (option_sta + option_pt-1)>option_end || option_pt<4) //bad or too big pointer + STRAPP(" [bad ptr=%02i]", option_pt); + } + if(pt - option_sta > 2) { // ip's + int i, s = (option_pt)%4; + // if pointer is mangled, fix it. it's max 3 bytes wrong + CHECK(pt+3); + for(i=0; i Internet Timestamp + if(pt - option_sta == 2){ + STRAPP(" TM{"); + // pointer + CHECK(pt); + option_pt = ipopt[pt++]; + // bad or too big pointer + if(option_pt%4 != 1 || (option_sta + option_pt-1)>option_end || option_pt<5) + STRAPP(" [bad ptr=%02i]", option_pt); + // flags + overflow + CHECK(pt); + option_fl = ipopt[pt++]; + if((option_fl&0x0C) || (option_fl&0x03)==2) + STRAPP(" [bad flags=\\x%01hhx]", option_fl&0x0F); + STRAPP("[%i hosts not recorded]", option_fl>>4); + option_fl &= 0x03; + } + if(pt - option_sta > 2) {// ip's + int i, s = (option_pt+3)%(option_fl==0?4:8); + // if pointer is mangled, fix it. it's max 3 bytes wrong + CHECK(pt+(option_fl==0?3:7)); + for(i=0; i (SANET) Stream Identifier + if(pt - option_sta == 2){ + u16 *sh; + STRAPP(" SI{",NULL); + // length + if(option_sta+option_len > ipoptlen || option_len!=4) + STRAPP("[bad len %02i]", option_len); + + // stream id + CHECK(pt+1); + sh = (u16*) &ipopt[pt]; pt+=2; + option_pt = ntohs(*sh); + STRAPP("id=%i", option_pt); + if(pt != option_end) + BREAK(); + }else BREAK(); + break; + case UNKNOWN: + default: + // we read option_type and option_len, print them. + STRAPP(" ??{\\x%02hhx\\x%02hhx", option_type, option_len); + // check option_end once more: + if(option_len < ipoptlen) + option_end = MIN(MAX(option_sta+option_len, option_sta+2),ipoptlen); + else + option_end = 255; + option_type = HEXDUMP; + break; + case HEXDUMP: + assert(pt<=option_end); + if(pt == option_end){ + STRAPP("}",NULL); + option_type=-1; + break; + } + STRAPP("\\x%02hhx", ipopt[pt++]); + break; + } + if(pt == option_end && option_type != UNKNOWN) { + STRAPP("}",NULL); + option_type = UNKNOWN; + } + } // while + if(option_type != UNKNOWN) + STRAPP("}"); + + return(STRAPP("",NULL)); +} +#undef CHECK +#undef BREAK +#undef UNKNOWN +#undef HEXDUMP + + + +/* Returns a buffer of ASCII information about an IP packet that may + * look like "TCP 127.0.0.1:50923 > 127.0.0.1:3 S ttl=61 id=39516 + * iplen=40 seq=625950769" or "ICMP PING (0/1) ttl=61 id=39516 iplen=40". + * Returned buffer is static so it is NOT safe to call this in + * multi-threaded environments without appropriate sync protection, or + * call it twice in the same sentence (eg: as two printf parameters). + * Obviously, the caller should never attempt to free() the buffer. The + * returned buffer is guaranteed to be NULL-terminated but no + * assumptions should be made concerning its length. + * + * The function provides full support for IPv4,TCP,UDP,SCTP and ICMPv4. + * It also provides support for standard IPv6 but not for its extension + * headers. If an IPv6 packet contains an ICMPv6 Header, the output will + * reflect this but no parsing of ICMPv6 contents will be performed. + * + * The output has three different levels of detail. Parameter "detail" + * determines how verbose the output should be. It should take one of + * the following values: + * + * LOW_DETAIL (0x01): Traditional output. + * MEDIUM_DETAIL (0x02): More verbose than traditional. + * HIGH_DETAIL (0x03): Contents of virtually every field of the + * protocol headers . + */ +const char *ippackethdrinfo(const u8 *packet, u32 len, int detail) { + struct ip *ip = (struct ip *) packet; /* IPv4 header structure. */ + struct tcp_hdr *tcp = NULL; /* TCP header structure. */ + struct udp_hdr *udp = NULL; /* UDP header structure. */ + struct sctp_hdr *sctp = NULL; /* SCTP header structure. */ + static char protoinfo[1024] = ""; /* Stores final info string. */ + char ipinfo[512] = ""; /* Temp info about IP. */ + char icmpinfo[512] = ""; /* Temp info about ICMP. */ + char icmptype[128]=""; /* Temp info about ICMP type & code */ + char icmpfields[256]=""; /* Temp info for various ICMP fields */ + char fragnfo[64] = ""; /* Temp info about fragmentation. */ + char srchost[INET6_ADDRSTRLEN] = ""; /* Src IP in dot-decimal notation. */ + char dsthost[INET6_ADDRSTRLEN] = ""; /* Dst IP in dot-decimal notation. */ + struct in_addr saddr, daddr; /* Src and Dst IPs in binary. */ + char *p = NULL; /* Aux pointer. */ + int frag_off = 0; /* To compute IP fragment offset. */ + int more_fragments = 0; /* True if IP MF flag is set. */ + int dont_fragment = 0; /* Ture if IP DF flag is set. */ + int reserved_flag = 0; /* True if IP Reserved flag is set. */ + size_t iphdrlen=0; /* Length of the IP (4 or 6) header */ + u8 nextproto=0; /* Protocol after IP (4 or 6) header */ + + /* Ensure IP version makes sense */ + if (ip->ip_v != 4 && ip->ip_v != 6 ) + return "BOGUS! IP Version in packet is not 4"; + + + /* Ensure we end up with a valid detail number */ + if( detail!=LOW_DETAIL && detail!=MEDIUM_DETAIL && detail!=HIGH_DETAIL) + detail=LOW_DETAIL; + +/* IP INFORMATION ************************************************************/ +if( ip->ip_v == 4 ){ /* IPv4 */ + + if (len < 20) + return "BOGUS! Packet too short."; + else{ + iphdrlen=ip->ip_hl * 4; + nextproto=ip->ip_p; + } + + /* Obtain IP source and destination info */ + saddr.s_addr = ip->ip_src.s_addr; + daddr.s_addr = ip->ip_dst.s_addr; + inet_ntop(AF_INET, &saddr, srchost, sizeof(srchost)); + inet_ntop(AF_INET, &daddr, dsthost, sizeof(dsthost)); + + /* Compute fragment offset and check if flags are set */ + frag_off = 8 * (ntohs(ip->ip_off) & 8191) /* 2^13 - 1 */; + more_fragments = ntohs(ip->ip_off) & IP_MF; + dont_fragment = ntohs(ip->ip_off) & IP_DF; + reserved_flag = ntohs(ip->ip_off) & IP_RF; + + /* Is this a fragmented packet? is it the last fragment? */ + if (frag_off || more_fragments) { + Snprintf(fragnfo, sizeof(fragnfo), " frag offset=%d%s", frag_off, more_fragments ? "+" : ""); + } + + /* Create a string with information relevant to the specified level of detail */ + if( detail == LOW_DETAIL ){ + Snprintf(ipinfo, sizeof(ipinfo), "ttl=%d id=%d iplen=%d%s %s%s%s", + ip->ip_ttl, ntohs(ip->ip_id), ntohs(ip->ip_len), fragnfo, + ip->ip_hl==5?"":"ipopts={", + ip->ip_hl==5?"":format_ip_options((u8*)ip + sizeof(struct ip), MIN((unsigned)(ip->ip_hl-5)*4,len-sizeof(struct ip))), + ip->ip_hl==5?"":"}"); + }else if( detail == MEDIUM_DETAIL ){ + Snprintf(ipinfo, sizeof(ipinfo), "ttl=%d id=%d proto=%d csum=0x%04x iplen=%d%s %s%s%s", + ip->ip_ttl, ntohs(ip->ip_id), + ip->ip_p, ntohs(ip->ip_sum), + ntohs(ip->ip_len), fragnfo, + ip->ip_hl==5?"":"ipopts={", + ip->ip_hl==5?"":format_ip_options((u8*)ip + sizeof(struct ip), MIN((unsigned)(ip->ip_hl-5)*4,len-sizeof(struct ip))), + ip->ip_hl==5?"":"}"); + }else if( detail==HIGH_DETAIL ){ + Snprintf(ipinfo, sizeof(ipinfo), "ver=%d ihl=%d tos=0x%02x iplen=%d id=%d%s%s%s%s foff=%d%s ttl=%d proto=%d csum=0x%04x%s%s%s", + ip->ip_v, ip->ip_hl, + ip->ip_tos, ntohs(ip->ip_len), + ntohs(ip->ip_id), + (reserved_flag||dont_fragment||more_fragments) ? " flg=" : "", + (reserved_flag)? "x" : "", + (dont_fragment)? "D" : "", + (more_fragments)? "M": "", + frag_off, (more_fragments) ? "+" : "", + ip->ip_ttl, ip->ip_p, + ntohs(ip->ip_sum), + ip->ip_hl==5?"":" ipopts={", + ip->ip_hl==5?"":format_ip_options((u8*)ip + sizeof(struct ip), MIN((unsigned)(ip->ip_hl-5)*4,len-sizeof(struct ip))), + ip->ip_hl==5?"":"}"); + } + +}else{ /* IPv6 */ + + /* I'd rather use a regular u8 pointer to access the IPv6 header because + * it's surprinsingly easy to fuck the whole thing up using structures due + * to the weird IPv6 field alignment and the f*** compiler padding structs + * when it shouldn't. */ + u8 *ipv6pnt = (u8 *)packet; + + if (len < 40) + return "BOGUS! IPv6 Packet too short."; + else{ + iphdrlen=40; + nextproto=ipv6pnt[6]; + } + + /* Obtain IP source and destination info */ + struct in6_addr ip6_src; + struct in6_addr ip6_dst; + memcpy(ip6_src.s6_addr, &ipv6pnt[8], 16); + memcpy(ip6_dst.s6_addr, &ipv6pnt[24], 16); + inet_ntop(AF_INET6, &ip6_src, srchost, sizeof(srchost)); + inet_ntop(AF_INET6, &ip6_dst, dsthost, sizeof(dsthost)); + + /* Obtain payload length, next protocol and hop limit */ + u16 *ipv6_pl = (u16 *)(&ipv6pnt[4]); + u8 *ipv6_nh = (u8 *)(& ipv6pnt[6]); + u8 *ipv6_hl = (u8 *)(& ipv6pnt[7]); + + + /* Obtain flow label and traffic class */ + u32 *word = (u32 *)(&ipv6pnt[0]); + u32 flow= ntohl( *word ); + + u32 ip6_fl = flow & 0x000fffff; + u32 ip6_tc = (flow & 0x0ff00000) >> 20; + + + /* Create a string with information relevant to the specified level of detail */ + if( detail == LOW_DETAIL ){ + Snprintf(ipinfo, sizeof(ipinfo), "hopl=%d flow=%x payloadlen=%d", + (*ipv6_hl), ip6_fl, ntohs(*ipv6_pl) + ); + }else if( detail == MEDIUM_DETAIL ){ + Snprintf(ipinfo, sizeof(ipinfo), "hopl=%d tclass=%d flow=%x payloadlen=%d", + (*ipv6_hl), ip6_tc, ip6_fl, ntohs(*ipv6_pl) + ); + }else if( detail==HIGH_DETAIL ){ + Snprintf(ipinfo, sizeof(ipinfo), "ver=6, tclass=%x flow=%x payloadlen=%d nh=%s hopl=%d ", + ip6_tc, ip6_fl, ntohs(*ipv6_pl), + nexthdrtoa(*ipv6_nh, 1), *ipv6_hl + ); + } + +} + + +/* TCP INFORMATION ***********************************************************/ + if (nextproto == IPPROTO_TCP) { + char tflags[10]; + char tcpinfo[64] = ""; + char buf[32]; + char tcpoptinfo[256] = ""; + tcp = (struct tcp_hdr *) (packet + iphdrlen); + + + /* Let's parse the TCP header. The following code is very ugly because we + * have to deal with a lot of different situations. We don't want to + * segfault so we have to check every length and every bound to ensure we + * don't read past the packet. We cannot even trust the contents of the + * received packet because, for example, an IPv4 header may state it + * carries a TCP packet but may actually carry nothing at all. + * + * So we distinguish 4 situations. I know the first two are weird but they + * were there when I modified this code so I left them there just in + * case. + * 1. IP datagram is very small or is a fragment where we are missing + * the first part of the TCP header + * 2. IP datagram is a fragment and although we are missing the first + * 8 bytes of the TCP header, we have the rest of it (or some of + * the rest of it) + * 3. IP datagram is NOT a fragment but we don't have the full TCP + * header, we are missing some bytes. + * 4. IP datagram is NOT a fragment and we have at least a full 20 + * byte TCP header. + */ + + + /* CASE 1: where we don't have the first 8 bytes of the TCP header because + * either the fragment belongs to somewhere past that or the IP contains + * less than 8 bytes. This also includes empty IP packets that say they + * contain a TCP packet. */ + if ( (frag_off > 8) || (len < (u32) iphdrlen + 8) ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:?? > %s:?? ?? %s (incomplete)", + srchost, dsthost, ipinfo); + } + + /* CASE 2: where we are missing the first 8 bytes of the TCP header but we + * have, at least, the next 8 bytes so we can see the ACK number, the + * flags and window size. */ + else if ( (frag_off == 8) && (len >= (u32) iphdrlen + 8)) { + + tcp = (struct tcp_hdr *)((u8 *) tcp - frag_off); // ugly? + + /* TCP Flags */ + p = tflags; + /* These are basically in tcpdump order */ + if (tcp->th_flags & TH_SYN) *p++ = 'S'; + if (tcp->th_flags & TH_FIN) *p++ = 'F'; + if (tcp->th_flags & TH_RST) *p++ = 'R'; + if (tcp->th_flags & TH_PUSH) *p++ = 'P'; + if (tcp->th_flags & TH_ACK){ *p++ = 'A'; + Snprintf(tcpinfo, sizeof(tcpinfo), " ack=%lu", + (unsigned long) ntohl(tcp->th_ack)); + } + if (tcp->th_flags & TH_URG) *p++ = 'U'; + if (tcp->th_flags & TH_ECE) *p++ = 'E'; /* rfc 2481/3168 */ + if (tcp->th_flags & TH_CWR) *p++ = 'C'; /* rfc 2481/3168 */ + *p++ = '\0'; + + /* TCP Options */ + if((u32) tcp->th_off * 4 > sizeof(struct tcp_hdr)) { + if(len < (u32) iphdrlen + (u32) tcp->th_off * 4 - frag_off) { + Snprintf(tcpoptinfo, sizeof(tcpoptinfo), "option incomplete"); + } else { + tcppacketoptinfo((u8*) tcp + sizeof(struct tcp_hdr), + tcp->th_off*4 - sizeof(struct tcp_hdr), + tcpoptinfo, sizeof(tcpoptinfo)); + } + } + + /* Create a string with TCP information relevant to the specified level of detail */ + if( detail == LOW_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:?? > %s:?? %s %s %s %s", + srchost, dsthost, tflags, ipinfo, tcpinfo, tcpoptinfo); + }else if( detail == MEDIUM_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:?? > %s:?? %s ack=%ul win=%hu %s IP [%s]", + srchost, dsthost, tflags, + ntohl(tcp->th_ack), ntohs(tcp->th_win), + tcpoptinfo, ipinfo); + }else if( detail==HIGH_DETAIL ){ + if( len >= (u32) iphdrlen + 12 ){ /* We have at least bytes 8-20 */ + Snprintf(protoinfo, sizeof(protoinfo), "TCP [%s:?? > %s:?? %s seq=%lu ack=%lu off=%d res=%d win=%hu csum=0x%04X urp=%d%s%s] IP [%s]", + srchost, dsthost, tflags, + (unsigned long) ntohl(tcp->th_seq), + (unsigned long) ntohl(tcp->th_ack), + (u8)tcp->th_off, (u8)tcp->th_x2, ntohs(tcp->th_win), + ntohs(tcp->th_sum), ntohs(tcp->th_urp), + (tcpoptinfo[0]!='\0') ? " " : "", + tcpoptinfo, ipinfo ); + }else{ /* We only have bytes 8-16 */ + Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:?? > %s:?? %s ack=%ul win=%hu %s IP [%s]", + srchost, dsthost, tflags, + ntohl(tcp->th_ack), ntohs(tcp->th_win), + tcpoptinfo, ipinfo); + } + } + + } + + /* CASE 3: where the IP packet is not a fragment but for some reason, we + * don't have the entire TCP header, just part of it.*/ + else if ((len > (u32)iphdrlen) && (len < (u32) iphdrlen + 20)) { + + /* We only have the first 32 bits: source and dst port */ + if( (len >= (u32)iphdrlen + 4) && (len < (u32)iphdrlen + 8) ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:%d > %s:%d ?? (incomplete) %s", + srchost, ntohs(tcp->th_sport), dsthost, ntohs(tcp->th_dport), ipinfo); + } + + /* We only have the first 64 bits: ports and seq number */ + if( (len >= (u32)iphdrlen + 8) && (len < (u32)iphdrlen + 12) ) { + Snprintf(tcpinfo, sizeof(tcpinfo), "TCP %s:%d > %s:%d ?? seq=%lu (incomplete) %s", + srchost, ntohs(tcp->th_sport), dsthost, + ntohs(tcp->th_dport), (unsigned long) ntohl(tcp->th_seq), ipinfo); + } + + /* We only have the first 96 bits: ports, seq and ack number */ + if( (len >= (u32)iphdrlen + 12) && (len < (u32)iphdrlen + 16) ) { + if(detail == LOW_DETAIL){ /* We don't print ACK in low detail */ + Snprintf(tcpinfo, sizeof(tcpinfo), "TCP %s:%d > %s:%d seq=%lu (incomplete), %s", + srchost, ntohs(tcp->th_sport), dsthost, + ntohs(tcp->th_dport), (unsigned long) ntohl(tcp->th_seq), ipinfo); + }else{ + Snprintf(tcpinfo, sizeof(tcpinfo), "TCP [%s:%d > %s:%d seq=%lu ack=%lu (incomplete)] IP [%s]", + srchost, ntohs(tcp->th_sport), dsthost, + ntohs(tcp->th_dport), (unsigned long) ntohl(tcp->th_seq), + (unsigned long) ntohl(tcp->th_ack), ipinfo); + } + } + + /* We are missing the last 32 bits (checksum and urgent pointer) */ + if( (len >= (u32)iphdrlen + 16) && (len < (u32)iphdrlen + 20) ) { + p = tflags; + /* These are basically in tcpdump order */ + if (tcp->th_flags & TH_SYN) *p++ = 'S'; + if (tcp->th_flags & TH_FIN) *p++ = 'F'; + if (tcp->th_flags & TH_RST) *p++ = 'R'; + if (tcp->th_flags & TH_PUSH) *p++ = 'P'; + if (tcp->th_flags & TH_ACK){ *p++ = 'A'; + Snprintf(buf, sizeof(buf), " ack=%lu", + (unsigned long) ntohl(tcp->th_ack)); + strncat(tcpinfo, buf, sizeof(tcpinfo) - strlen(tcpinfo) - 1); + } + if (tcp->th_flags & TH_URG) *p++ = 'U'; + if (tcp->th_flags & TH_ECE) *p++ = 'E'; /* rfc 2481/3168 */ + if (tcp->th_flags & TH_CWR) *p++ = 'C'; /* rfc 2481/3168 */ + *p++ = '\0'; + + + /* Create a string with TCP information relevant to the specified level of detail */ + if(detail == LOW_DETAIL){ /* We don't print ACK in low detail */ + Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:%d > %s:%d %s %s seq=%lu win=%hu (incomplete)", + srchost, ntohs(tcp->th_sport), dsthost, ntohs(tcp->th_dport), + tflags, ipinfo, (unsigned long) ntohl(tcp->th_seq), + ntohs(tcp->th_win)); + }else if( detail == MEDIUM_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP [%s:%d > %s:%d %s seq=%lu ack=%lu win=%hu (incomplete)] IP [%s]", + srchost, ntohs(tcp->th_sport), dsthost, ntohs(tcp->th_dport), + tflags, (unsigned long) ntohl(tcp->th_seq), + (unsigned long) ntohl(tcp->th_ack), + ntohs(tcp->th_win), ipinfo); + }else if( detail == HIGH_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP [%s:%d > %s:%d %s seq=%lu ack=%lu off=%d res=%d win=%hu (incomplete)] IP [%s]", + srchost, ntohs(tcp->th_sport), + dsthost, ntohs(tcp->th_dport), + tflags, (unsigned long) ntohl(tcp->th_seq), + (unsigned long) ntohl(tcp->th_ack), + (u8)tcp->th_off, (u8)tcp->th_x2, ntohs(tcp->th_win), + ipinfo ); + } + + } + } + + /* CASE 4: where we (finally!) have a full 20 byte TCP header so we can + * safely print all fields */ + else if (len >= (u32) iphdrlen + 20){ + + /* TCP Flags */ + p = tflags; + /* These are basically in tcpdump order */ + if (tcp->th_flags & TH_SYN) *p++ = 'S'; + if (tcp->th_flags & TH_FIN) *p++ = 'F'; + if (tcp->th_flags & TH_RST) *p++ = 'R'; + if (tcp->th_flags & TH_PUSH) *p++ = 'P'; + if (tcp->th_flags & TH_ACK){ *p++ = 'A'; + Snprintf(buf, sizeof(buf), " ack=%lu", + (unsigned long) ntohl(tcp->th_ack)); + strncat(tcpinfo, buf, sizeof(tcpinfo) - strlen(tcpinfo) - 1); + } + if (tcp->th_flags & TH_URG) *p++ = 'U'; + if (tcp->th_flags & TH_ECE) *p++ = 'E'; /* rfc 2481/3168 */ + if (tcp->th_flags & TH_CWR) *p++ = 'C'; /* rfc 2481/3168 */ + *p++ = '\0'; + + + /* TCP Options */ + if((u32) tcp->th_off * 4 > sizeof(struct tcp_hdr)) { + if(len < (u32) iphdrlen + (u32) tcp->th_off * 4) { + Snprintf(tcpoptinfo, sizeof(tcpoptinfo), "option incomplete"); + + } else { + tcppacketoptinfo((u8*) tcp + sizeof(struct tcp_hdr), + tcp->th_off*4 - sizeof(struct tcp_hdr), + tcpoptinfo, sizeof(tcpoptinfo)); + } + } + + /* Rest of header fields */ + if( detail == LOW_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:%d > %s:%d %s %s seq=%lu win=%hu %s", + srchost, ntohs(tcp->th_sport), dsthost, ntohs(tcp->th_dport), + tflags, ipinfo, (unsigned long) ntohl(tcp->th_seq), + ntohs(tcp->th_win), tcpoptinfo); + }else if( detail == MEDIUM_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP [%s:%d > %s:%d %s seq=%lu win=%hu csum=0x%04X%s%s] IP [%s]", + srchost, ntohs(tcp->th_sport), dsthost, ntohs(tcp->th_dport), + tflags, (unsigned long) ntohl(tcp->th_seq), + ntohs(tcp->th_win), ntohs(tcp->th_sum), + (tcpoptinfo[0]!='\0') ? " " : "", + tcpoptinfo, ipinfo ); + }else if( detail==HIGH_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "TCP [%s:%d > %s:%d %s seq=%lu ack=%lu off=%d res=%d win=%hu csum=0x%04X urp=%d%s%s] IP [%s]", + srchost, ntohs(tcp->th_sport), + dsthost, ntohs(tcp->th_dport), + tflags, (unsigned long) ntohl(tcp->th_seq), + (unsigned long) ntohl(tcp->th_ack), + (u8)tcp->th_off, (u8)tcp->th_x2, ntohs(tcp->th_win), + ntohs(tcp->th_sum), ntohs(tcp->th_urp), + (tcpoptinfo[0]!='\0') ? " " : "", + tcpoptinfo, ipinfo ); + } + } + else{ + /* If the packet does not fall into any other category, then we have a + * really screwed up packet. */ + Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:?? > %s:?? ?? %s (invalid TCP)", + srchost, dsthost, ipinfo); + } + + +/* UDP INFORMATION ***********************************************************/ + } else if (nextproto == IPPROTO_UDP && frag_off) { + Snprintf(protoinfo, sizeof(protoinfo), "UDP %s:?? > %s:?? fragment %s (incomplete)", srchost, dsthost, ipinfo); + } else if (nextproto == IPPROTO_UDP) { + udp = (struct udp_hdr *) (packet + sizeof(struct ip)); + /* TODO: See if we can segfault if we receive a fragmented packet whose IP packet does not say a thing about fragmentation */ + + + if( detail == LOW_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "UDP %s:%d > %s:%d %s", + srchost, ntohs(udp->uh_sport), dsthost, ntohs(udp->uh_dport), + ipinfo); + }else if( detail == MEDIUM_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "UDP [%s:%d > %s:%d csum=0x%04X] IP [%s]", + srchost, ntohs(udp->uh_sport), dsthost, ntohs(udp->uh_dport), ntohs(udp->uh_sum), + ipinfo); + }else if( detail==HIGH_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "UDP [%s:%d > %s:%d len=%d csum=0x%04X] IP [%s]", + srchost, ntohs(udp->uh_sport), dsthost, ntohs(udp->uh_dport), + ntohs(udp->uh_ulen), ntohs(udp->uh_sum), + ipinfo); + } + + +/* SCTP INFORMATION **********************************************************/ + } else if (nextproto == IPPROTO_SCTP && frag_off) { + Snprintf(protoinfo, sizeof(protoinfo), "SCTP %s:?? > %s:?? fragment %s (incomplete)", srchost, dsthost, ipinfo); + } else if (nextproto == IPPROTO_SCTP) { + sctp = (struct sctp_hdr *) (packet + sizeof(struct ip)); + + if( detail == LOW_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "SCTP %s:%d > %s:%d %s", + srchost, ntohs(sctp->sh_sport), dsthost, ntohs(sctp->sh_dport), + ipinfo); + }else if( detail == MEDIUM_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "SCTP [%s:%d > %s:%d csum=0x%04x] IP [%s]", + srchost, ntohs(sctp->sh_sport), dsthost, ntohs(sctp->sh_dport), ntohl(sctp->sh_sum), + ipinfo); + }else if( detail==HIGH_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "SCTP [%s:%d > %s:%d vtag=%ul csum=0x%08x] IP [%s]", + srchost, ntohs(sctp->sh_sport), dsthost, ntohs(sctp->sh_dport), + ntohl(sctp->sh_sum), ntohl(sctp->sh_vtag), + ipinfo); + } + + +/* ICMP INFORMATION **********************************************************/ + } else if (nextproto == IPPROTO_ICMP && frag_off) { + Snprintf(protoinfo, sizeof(protoinfo), "ICMP %s > %s fragment %s (incomplete)", srchost, dsthost, ipinfo); + } else if (nextproto == IPPROTO_ICMP) { + + struct ip *ip2; /* Points to the IP datagram carried by some ICMP messages */ + char *ip2dst; /* Dest IP in caried IP datagram */ + u16 *nextmtu=NULL; /* Store next hop MTU when ICMP==Frag required */ + char auxbuff[128]; /* Aux buffer */ + struct icmp_packet{ /* Generic ICMP struct */ + u8 type; + u8 code; + u16 checksum; + u8 data[128]; + }*icmppkt; + struct ppkt { /* Beginning of ICMP Echo/Timestamp header */ + u8 type; + u8 code; + u16 checksum; + u16 id; + u16 seq; + } *ping = NULL; + struct icmp_redir{ + u8 type; + u8 code; + u16 checksum; + u32 addr; + } *icmpredir=NULL; + struct icmp_router{ + u8 type; + u8 code; + u16 checksum; + u8 addrs; + u8 addrlen; + u16 lifetime; + } *icmprouter=NULL; + struct icmp_param{ + u8 type; + u8 code; + u16 checksum; + u8 pnt; + u8 unused; + u16 unused2; + } *icmpparam=NULL; + struct icmp_tstamp{ + u8 type; + u8 code; + u16 checksum; + u16 id; + u16 seq; + u32 orig; + u32 recv; + u32 trans; + } *icmptstamp=NULL; + struct icmp_mask{ + u8 type; + u8 code; + u16 checksum; + u16 id; + u16 seq; + u32 mask; + } *icmpmask=NULL; + + /* Compute the length of the IP datagram + ICMP minimum length */ + unsigned pktlen = (iphdrlen) + 8; + + /* We need the ICMP packet to be at least 8 bytes long */ + if (pktlen > len) + goto icmpbad; + + ping = (struct ppkt *) ((iphdrlen) + (char *) ip); + icmppkt=(struct icmp_packet *) ((iphdrlen) + (char *) ip); + + switch(icmppkt->type) { + + /* Echo Reply **************************/ + case 0: + strcpy(icmptype, "Echo reply"); + Snprintf(icmpfields, sizeof(icmpfields), "id=%u seq=%u", ntohs(ping->id), ntohs(ping->seq) ); + break; + + /* Destination Unreachable *************/ + case 3: + /* Point to the start of the original datagram */ + ip2 = (struct ip *) ((char *) ip + (iphdrlen) + 8); + + /* Check we have a full IP datagram included in the ICMP message */ + pktlen += MAX( (ip2->ip_hl * 4), 20 ); + if (pktlen > len){ + if(len==(u32)(iphdrlen) + 8 ) + Snprintf(icmptype, sizeof icmptype, "Destination unreachable%s", + (detail!=LOW_DETAIL)? " (original datagram missing)" : "" ); + else + Snprintf(icmptype, sizeof icmptype, "Destination unreachable%s", + (detail!=LOW_DETAIL)? " (part of original datagram missing)" : "" ); + goto icmpbad; + } + + /* Basic check to ensure we have an IPv4 datagram attached */ + /* TODO: We should actually check the datagram checksum to + * see if it validates becuase just checking the version number + * is not enough. On average, if we get random data 1 out of + * 16 (2^4bits) times we will have value 4. */ + if( (ip2->ip_v != (u8)4) || ((ip2->ip_hl * 4)<20) || ((ip2->ip_hl * 4)>60) ){ + Snprintf(icmptype, sizeof icmptype, "Destination unreachable (bogus original datagram)"); + goto icmpbad; + }else + + /* We have the original datagram + the first 8 bytes of the + * transport layer header */ + if ( (pktlen+8) < len) { + tcp = (struct tcp_hdr *) ((char *) ip2 + (ip2->ip_hl * 4)); + udp = (struct udp_hdr *) ((char *) ip2 + (ip2->ip_hl * 4)); + sctp = (struct sctp_hdr *) ((char *) ip2 + (ip2->ip_hl * 4)); + } + + /* Determine the IP the original datagram was sent to */ + ip2dst = inet_ntoa(ip2->ip_dst); + + /* Determine type of Destination unreachable from the code value */ + switch (icmppkt->code) { + case 0: + Snprintf(icmptype, sizeof icmptype, "Network %s unreachable", ip2dst); + break; + + case 1: + Snprintf(icmptype, sizeof icmptype, "Host %s unreachable", ip2dst); + break; + + case 2: + Snprintf(icmptype, sizeof icmptype, "Protocol %u unreachable", ip2->ip_p); + break; + + case 3: + if ( (pktlen+8) < len){ + if (ip2->ip_p == IPPROTO_UDP && udp) + Snprintf(icmptype, sizeof icmptype, "Port %u unreachable", ntohs(udp->uh_dport)); + else if (ip2->ip_p == IPPROTO_TCP && tcp) + Snprintf(icmptype, sizeof icmptype, "Port %u unreachable", ntohs(tcp->th_dport)); + else if (ip2->ip_p == IPPROTO_SCTP && sctp) + Snprintf(icmptype, sizeof icmptype, "Port %u unreachable", ntohs(sctp->sh_dport)); + else + Snprintf(icmptype, sizeof icmptype, "Port unreachable (unknown protocol %u)", ip2->ip_p); + } + else + strcpy(icmptype, "Port unreachable"); + break; + + case 4: + strcpy(icmptype, "Fragmentation required"); + nextmtu = (u16 *)(&(icmppkt->data[6])); + Snprintf(icmpfields, sizeof(icmpfields), "Next-Hop-MTU=%u", ntohs(*nextmtu) ); + break; + + case 5: + strcpy(icmptype, "Source route failed"); + break; + + case 6: + Snprintf(icmptype, sizeof icmptype, "Destination network %s unknown", ip2dst); + break; + + case 7: + Snprintf(icmptype, sizeof icmptype, "Destination host %s unknown", ip2dst); + break; + + case 8: + strcpy(icmptype, "Source host isolated"); + break; + + case 9: + Snprintf(icmptype, sizeof icmptype, "Destination network %s administratively prohibited", ip2dst); + break; + + case 10: + Snprintf(icmptype, sizeof icmptype, "Destination host %s administratively prohibited", ip2dst); + break; + + case 11: + Snprintf(icmptype, sizeof icmptype, "Network %s unreachable for TOS", ip2dst); + break; + + case 12: + Snprintf(icmptype, sizeof icmptype, "Host %s unreachable for TOS", ip2dst); + break; + + case 13: + strcpy(icmptype, "Communication administratively prohibited by filtering"); + break; + + case 14: + strcpy(icmptype, "Host precedence violation"); + break; + + case 15: + strcpy(icmptype, "Precedence cutoff in effect"); + break; + + default: + strcpy(icmptype, "Destination unreachable (unknown code)"); + break; + } /* End of ICMP Code switch */ + break; + + + /* Source Quench ***********************/ + case 4: + strcpy(icmptype, "Source quench"); + break; + + /* Redirect ****************************/ + case 5: + if (ping->code == 0) + strcpy(icmptype, "Network redirect"); + else if (ping->code == 1) + strcpy(icmptype, "Host redirect"); + else strcpy(icmptype, "Redirect (unknown code)"); + icmpredir=(struct icmp_redir *)icmppkt; + inet_ntop(AF_INET, &icmpredir->addr, auxbuff, sizeof(auxbuff) ); + Snprintf(icmpfields, sizeof(icmpfields), "addr=%s", auxbuff); + break; + + /* Echo Request ************************/ + case 8: + strcpy(icmptype, "Echo request"); + Snprintf(icmpfields, sizeof(icmpfields), "id=%u seq=%u", ntohs(ping->id), ntohs(ping->seq) ); + break; + + /* Router Advertisement ****************/ + case 9: + if(icmppkt->code==16) + strcpy(icmptype, "Router advertisement (Mobile Agent Only)"); + else + strcpy(icmptype, "Router advertisement"); + icmprouter=(struct icmp_router *)icmppkt; + Snprintf(icmpfields, sizeof(icmpfields), "addrs=%u addrlen=%u lifetime=%d", + icmprouter->addrs, + icmprouter->addrlen, + ntohs(icmprouter->lifetime) ); + break; + + /* Router Solicitation *****************/ + case 10: + strcpy(icmptype, "Router solicitation"); + break; + + /* Time Exceeded ***********************/ + case 11: + if (icmppkt->code == 0) + strcpy(icmptype, "TTL=0 during transit"); + else if (icmppkt->code == 1) + strcpy(icmptype, "TTL=0 during reassembly"); + else strcpy(icmptype, "TTL exceeded (unknown code)"); + break; + + /* Parameter Problem *******************/ + case 12: + if (ping->code == 0) + strcpy(icmptype, "Parameter problem (pointer indicates error)"); + else if (ping->code == 1) + strcpy(icmptype, "Parameter problem (option missing)"); + else if (ping->code == 2) + strcpy(icmptype, "Parameter problem (bad length)"); + else + strcpy(icmptype, "Parameter problem (unknown code)"); + icmpparam=(struct icmp_param *)icmppkt; + Snprintf(icmpfields, sizeof(icmpfields), "pointer=%d", icmpparam->pnt); + break; + + /* Timestamp Request/Reply *************/ + case 13: + case 14: + Snprintf(icmptype, sizeof(icmptype), "Timestamp %s", (icmppkt->type==13)? "request" : "reply" ); + icmptstamp=(struct icmp_tstamp *)icmppkt; + Snprintf(icmpfields, sizeof(icmpfields), "id=%u seq=%u orig=%lu recv=%lu trans=%lu", + ntohs(icmptstamp->id), ntohs(icmptstamp->seq), + (unsigned long)ntohl(icmptstamp->orig), + (unsigned long)ntohl(icmptstamp->recv), + (unsigned long)ntohl(icmptstamp->trans) ); + break; + + /* Information Request *****************/ + case 15: + strcpy(icmptype, "Information request"); + Snprintf(icmpfields, sizeof(icmpfields), "id=%u seq=%u", ntohs(ping->id), ntohs(ping->seq) ); + break; + + /* Information Reply *******************/ + case 16: + strcpy(icmptype, "Information reply"); + Snprintf(icmpfields, sizeof(icmpfields), "id=%u seq=%u", ntohs(ping->id), ntohs(ping->seq) ); + break; + + /* Netmask Request/Reply ***************/ + case 17: + case 18: + Snprintf(icmptype, sizeof(icmptype), "Address mask %s", (icmppkt->type==17)? "request" : "reply" ); + icmpmask=(struct icmp_mask *)icmppkt; + inet_ntop(AF_INET, &icmpmask->mask, auxbuff, sizeof(auxbuff) ); + Snprintf(icmpfields, sizeof(icmpfields), "id=%u seq=%u mask=%s", + ntohs(ping->id), ntohs(ping->seq), auxbuff); + break; + + /* Traceroute **************************/ + case 30: + strcpy(icmptype, "Traceroute"); + break; + + /* Domain Name Request *****************/ + case 37: + strcpy(icmptype, "Domain name request"); + break; + + /* Domain Name Reply *******************/ + case 38: + strcpy(icmptype, "Domain name reply"); + break; + + /* Security ****************************/ + case 40: + strcpy(icmptype, "Security failures"); /* rfc 2521 */ + break; + + default: + strcpy(icmptype, "Unknown type"); break; + break; + } /* End of ICMP Type switch */ + + + if (pktlen > len) { + icmpbad: + if (ping) { + /* We still have this information */ + Snprintf(protoinfo, sizeof(protoinfo), "ICMP %s > %s %s (type=%d/code=%d) %s", + srchost, dsthost, icmptype, ping->type, ping->code, ipinfo); + } else { + Snprintf(protoinfo, sizeof(protoinfo), "ICMP %s > %s [??] %s", + srchost, dsthost, ipinfo); + } + } else { + if(ping) + sprintf(icmpinfo,"type=%d/code=%d", ping->type, ping->code); + else + strncpy(icmpinfo,"type=?/code=?", sizeof(icmpinfo) ); + + if( detail==LOW_DETAIL ){ + Snprintf(protoinfo, sizeof(protoinfo), "ICMP %s > %s %s (%s) %s", + srchost, dsthost, icmptype, icmpinfo, ipinfo); + }else{ + Snprintf(protoinfo, sizeof(protoinfo), "ICMP [%s > %s %s (%s) %s] IP [%s]", + srchost, dsthost, icmptype, icmpinfo, icmpfields, ipinfo); + } + + } + +/* UNKNOWN PROTOCOL **********************************************************/ + } else if( nextproto == IPPROTO_ICMPV6){ + Snprintf(protoinfo, sizeof(protoinfo), "ICMPv6 (%d) %s > %s: %s", + ip->ip_p, srchost, dsthost, ipinfo); + }else{ + + if( nexthdrtoa(nextproto, 1) == NULL ){ + Snprintf(protoinfo, sizeof(protoinfo), "Unknown protocol (%d) %s > %s: %s", + ip->ip_p, srchost, dsthost, ipinfo); + }else{ + Snprintf(protoinfo, sizeof(protoinfo), "%s (%d) %s > %s: %s", + nexthdrtoa(nextproto, 1), ip->ip_p, srchost, dsthost, ipinfo); + } + } + + return protoinfo; +} + + +static int match_netmask(u32 addr1, u32 addr2, u32 mask) { + return (addr1 & mask) == (addr2 & mask); +} + +static int match_netmask_bits(u32 addr1, u32 addr2, int bits) { + return match_netmask(addr1, addr2, htonl((unsigned long) (0 - 1) << (32 - bits))); +} + +static int match_netmask_bits(const struct sockaddr_in *addr1, + const struct sockaddr_in *addr2, int bits) { + return match_netmask_bits(addr1->sin_addr.s_addr, addr2->sin_addr.s_addr, bits); +} + +static struct interface_info *find_loopback_iface(struct interface_info *ifaces, + int numifaces) { + int i; + + for (i = 0; i < numifaces; i++) { + if (ifaces[i].device_type == devt_loopback) + return &ifaces[i]; + } + + return NULL; +} + +/* Takes an IPv4 destination address (dst) and tries to determine the + * source address and interface necessary to route to this address. + * If no route is found, 0 is returned and "rnfo" is undefined. If + * a route is found, 1 is returned and "rnfo" is filled in with all + * of the routing details. If the source address needs to be spoofed, + * it should be passed through "spoofss" (otherwise NULL should be + * specified), along with a suitable network device (parameter "device"). + * Even if spoofss is NULL, if user specified a network device with -e, + * it should still be passed. Note that it's OK to pass either NULL or + * an empty string as the "device", as long as spoofss==NULL. */ +int route_dst(const struct sockaddr_storage * const dst, struct route_nfo *rnfo, + char *device, struct sockaddr_storage *spoofss) { + struct interface_info *ifaces; + struct interface_info *iface; + int numifaces = 0; + struct sys_route *routes; + int numroutes = 0; + int i; + struct sockaddr_in *ifsin, *dstsin; + char errstr[256]; + errstr[0]='\0'; + + if (!dst) + netutil_fatal("%s passed a NULL dst address", __func__); + dstsin = (struct sockaddr_in *) dst; + + if (dstsin->sin_family != AF_INET) + netutil_fatal("Sorry -- %s currently only supports IPv4", __func__); + + if(spoofss!=NULL){ + /* Throughout the rest of this function we only change rnfo->srcaddr if the source isnt spoofed */ + memcpy(&rnfo->srcaddr, spoofss, sizeof(rnfo->srcaddr)); + /* The device corresponding to this spoofed address should already have been set elsewhere. */ + assert(device!=NULL && device[0]!='\0'); + } + + if (device!=NULL && device[0]!='\0'){ + iface = getInterfaceByName(device); + if (!iface) + netutil_fatal("Could not find interface %s which was specified by -e", device); + } else { + iface = NULL; + } + + if((routes=getsysroutes(&numroutes, errstr, sizeof(errstr)))==NULL) + netutil_fatal("%s: Failed to obtain system routes: %s", __func__, errstr); + if((ifaces=getinterfaces(&numifaces, errstr, sizeof(errstr)))==NULL) + netutil_fatal("%s: Failed to obtain system interfaces: %s", __func__, errstr); + + /* First check if dst is one of the localhost's own addresses. We need to use + a localhost device for these. */ + for (i = 0; i < numifaces; i++) { + struct interface_info *loopback; + + ifsin = (struct sockaddr_in *) &ifaces[i].addr; + if (dstsin->sin_addr.s_addr != ifsin->sin_addr.s_addr) + continue; + if (iface != NULL && strcmp(ifaces[i].devname, iface->devname) != 0) + continue; + + if (ifaces[i].device_type == devt_loopback) + loopback = &ifaces[i]; + else + loopback = find_loopback_iface(ifaces, numifaces); + if (loopback == NULL) + /* Hmmm ... no localhost -- move on to the routing table. */ + break; + + rnfo->ii = *loopback; + rnfo->direct_connect = 1; + /* But the source address we want to use is the target address. */ + if (!spoofss) + rnfo->srcaddr = ifaces[i].addr; + + return 1; + } + + /* Go through the routing table and take the first match. getsysroutes sorts + so more-specific routes come first. */ + for (i = 0; i < numroutes; i++) { + if (!match_netmask(dstsin->sin_addr.s_addr, routes[i].dest, routes[i].netmask)) + continue; + /* Ignore routes that aren't on the device we specified. */ + if (iface != NULL && strcmp(routes[i].device->devname, iface->devname) != 0) + continue; + + rnfo->ii = *routes[i].device; + /* At this point we don't whether this route is direct or indirect ("G" flag + in netstat). We guess that a route is direct when the gateway address is + 0.0.0.0, when it exactly matches the interface address, or when it + exactly matches the destination address. */ + rnfo->direct_connect = (routes[i].gw.s_addr == 0) || + (routes[i].gw.s_addr == ((struct sockaddr_in *) &routes[i].device->addr)->sin_addr.s_addr) || + (routes[i].gw.s_addr == dstsin->sin_addr.s_addr); + if (!spoofss) + rnfo->srcaddr = routes[i].device->addr; + ifsin = (struct sockaddr_in *) &rnfo->nexthop; + ifsin->sin_family = AF_INET; + ifsin->sin_addr = routes[i].gw; + + return 1; + } + + /* No match on routes. Try interfaces directly. */ + for (i = 0; i < numifaces; i++) { + if (ifaces[i].addr.ss_family != AF_INET) + continue; + ifsin = (struct sockaddr_in *) &ifaces[i].addr; + if (!match_netmask_bits(dstsin, ifsin, ifaces[i].netmask_bits)) + continue; + if (iface != NULL && strcmp(ifaces[i].devname, iface->devname) != 0) + continue; + + rnfo->ii = ifaces[i]; + rnfo->direct_connect = 1; + if (!spoofss) + rnfo->srcaddr = ifaces[i].addr; + + return 1; + } + + return 0; +} + +/* Wrapper for system function sendto(), which retries a few times when + * the call fails. It also prints informational messages about the + * errors encountered. It returns the number of bytes sent or -1 in + * case of error. */ +int Sendto(const char *functionname, int sd, + const unsigned char *packet, int len, unsigned int flags, + struct sockaddr *to, int tolen) { + + struct sockaddr_in *sin = (struct sockaddr_in *) to; + int res; + int retries = 0; + int sleeptime = 0; + static int numerrors = 0; + + do { + if ((res = sendto(sd, (const char *) packet, len, flags, to, tolen)) == -1) { + int err = socket_errno(); + + numerrors++; + if(numerrors <= 10) { + netutil_error("sendto in %s: sendto(%d, packet, %d, 0, %s, %d) => %s", + functionname, sd, len, inet_ntoa(sin->sin_addr), tolen, + strerror(err)); + netutil_error("Offending packet: %s", ippackethdrinfo(packet, len, LOW_DETAIL)); + if (numerrors == 10) { + netutil_error("Omitting future %s error messages now that %d have been shown. Use -d2 if you really want to see them.", __func__, numerrors); + } + } +#if WIN32 + return -1; +#else + if (retries > 2 || err == EPERM || err == EACCES + || err == EADDRNOTAVAIL || err == EINVAL) + return -1; + sleeptime = 15 * (1 << (2 * retries)); + netutil_error("Sleeping %d seconds then retrying", sleeptime); + fflush(stderr); + sleep(sleeptime); +#endif + } + retries++; + } while (res == -1); + + return res; +} + + + +/* Send an IP packet over an ethernet handle. */ +int send_ip_packet_eth(struct eth_nfo *eth, u8 *packet, unsigned int packetlen) { + eth_t *ethsd; + u8 *eth_frame; + int res; + + eth_frame = (u8 *) safe_malloc(14 + packetlen); + memcpy(eth_frame + 14, packet, packetlen); + eth_pack_hdr(eth_frame, eth->dstmac, eth->srcmac, ETH_TYPE_IP); + if (!eth->ethsd) { + ethsd = eth_open_cached(eth->devname); + if (!ethsd) + netutil_fatal("%s: Failed to open ethernet device (%s)", __func__, eth->devname); + } else { + ethsd = eth->ethsd; + } + res = eth_send(ethsd, eth_frame, 14 + packetlen); + /* No need to close ethsd due to caching */ + free(eth_frame); + + return res; +} + + +/* Send an IP packet over a raw socket. */ +int send_ip_packet_sd(int sd, u8 *packet, unsigned int packetlen) { + struct sockaddr_in sock; + struct ip *ip = (struct ip *) packet; + struct tcp_hdr *tcp; + struct udp_hdr *udp; + int res; + + assert(sd >= 0); + memset(&sock, 0, sizeof(sock)); + sock.sin_family = AF_INET; +#if HAVE_SOCKADDR_SA_LEN + sock.sin_len = sizeof(sock); +#endif + + /* It is bogus that I need the address and port info when sending a RAW IP + packet, but it doesn't seem to work w/o them */ + if (packetlen >= 20) { + sock.sin_addr.s_addr = ip->ip_dst.s_addr; + if (ip->ip_p == IPPROTO_TCP + && packetlen >= (unsigned int) ip->ip_hl * 4 + 20) { + tcp = (struct tcp_hdr *) ((u8 *) ip + ip->ip_hl * 4); + sock.sin_port = tcp->th_dport; + } else if (ip->ip_p == IPPROTO_UDP + && packetlen >= (unsigned int) ip->ip_hl * 4 + 8) { + udp = (struct udp_hdr *) ((u8 *) ip + ip->ip_hl * 4); + sock.sin_port = udp->uh_dport; + } + } + + /* Equally bogus is that the IP total len and IP fragment offset + fields need to be in host byte order on certain BSD variants. I + must deal with it here rather than when building the packet, + because they should be in NBO when I'm sending over raw + ethernet */ +#if FREEBSD || BSDI || NETBSD || DEC || MACOSX + ip->ip_len = ntohs(ip->ip_len); + ip->ip_off = ntohs(ip->ip_off); +#endif + + res = Sendto("send_ip_packet_sd", sd, packet, packetlen, 0, + (struct sockaddr *) &sock, + (int) sizeof(struct sockaddr_in)); + + /* Undo the byte order switching. */ +#if FREEBSD || BSDI || NETBSD || DEC || MACOSX + ip->ip_len = htons(ip->ip_len); + ip->ip_off = htons(ip->ip_off); +#endif + + return res; +} + + + +/* Sends the supplied pre-built IPv4 packet. The packet is sent through + * the raw socket "sd" if "eth" is NULL. Otherwise, it gets sent at raw + * ethernet level. */ +int send_ip_packet_eth_or_sd(int sd, struct eth_nfo *eth, u8 *packet, unsigned int packetlen){ + if(eth) + return send_ip_packet_eth(eth, packet, packetlen); + else + return send_ip_packet_sd(sd, packet, packetlen); +} + + + +/* Create and send all fragments of a pre-built IPv4 packet + * Minimal MTU for IPv4 is 68 and maximal IPv4 header size is 60 + * which gives us a right to cut TCP header after 8th byte + * (shouldn't we inflate the header to 60 bytes too?) */ +int send_frag_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, + unsigned int packetlen, unsigned int mtu) { + struct ip *ip = (struct ip *) packet; + int headerlen = ip->ip_hl * 4; // better than sizeof(struct ip) + unsigned int datalen = packetlen - headerlen; + int fdatalen = 0, res = 0; + int fragment=0; + + assert(headerlen <= (int) packetlen); + assert(headerlen >= 20 && headerlen <= 60); // sanity check (RFC791) + assert(mtu > 0 && mtu % 8 == 0); // otherwise, we couldn't set Fragment offset (ip->ip_off) correctly + + if (datalen <= mtu) { + netutil_error("Warning: fragmentation (mtu=%i) requested but the payload is too small already (%i)", mtu, datalen); + return send_ip_packet_eth_or_sd(sd, eth, packet, packetlen); + } + + u8 *fpacket = (u8 *) safe_malloc(headerlen + mtu); + memcpy(fpacket, packet, headerlen + mtu); + ip = (struct ip *) fpacket; + + // create fragments and send them + for (fragment = 1; fragment * mtu < datalen + mtu; fragment++) { + fdatalen = (fragment * mtu <= datalen ? mtu : datalen % mtu); + ip->ip_len = htons(headerlen + fdatalen); + ip->ip_off = htons((fragment - 1) * mtu / 8); + if ((fragment - 1) * mtu + fdatalen < datalen) + ip->ip_off |= htons(IP_MF); +#if HAVE_IP_IP_SUM + ip->ip_sum = 0; + ip->ip_sum = in_cksum((unsigned short *) ip, headerlen); +#endif + if (fragment > 1) // copy data payload + memcpy(fpacket + headerlen, + packet + headerlen + (fragment - 1) * mtu, fdatalen); + res = send_ip_packet_eth_or_sd(sd, eth, packet, packetlen); + if (res == -1) + break; + } + free(fpacket); + return res; +} + + + +#ifdef WIN32 +/* Convert a dnet interface name into the long pcap style. This also caches the + data to speed things up. Fills out pcapdev (up to pcapdevlen) and returns + true if it finds anything. Otherwise returns false. This is only necessary + on Windows. */ +int DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen) { + static struct NameCorrelationCache { + char dnetd[64]; + char pcapd[128]; + } *NCC = NULL; + static int NCCsz = 0; + static int NCCcapacity = 0; + int i; + char tmpdev[128]; + + // Init the cache if not done yet + if (!NCC) { + NCCcapacity = 5; + NCC = + (struct NameCorrelationCache *) safe_zalloc(NCCcapacity * + sizeof(*NCC)); + NCCsz = 0; + } + // First check if the name is already in the cache + for (i = 0; i < NCCsz; i++) { + if (strcmp(NCC[i].dnetd, dnetdev) == 0) { + Strncpy(pcapdev, NCC[i].pcapd, pcapdevlen); + return 1; + } + } + + // OK, so it isn't in the cache. Let's ask dnet for it. +/* Converts a dnet interface name (ifname) to its pcap equivalent, which is stored in +pcapdev (up to a length of pcapdevlen). Returns 0 and fills in pcapdev if successful. */ + if (eth_get_pcap_devname(dnetdev, tmpdev, sizeof(tmpdev)) != 0) + return 0; + + // We've got it. Let's add it to the cache + if (NCCsz >= NCCcapacity) { + NCCcapacity <<= 2; + NCC = + (struct NameCorrelationCache *) safe_realloc(NCC, + NCCcapacity * + sizeof(*NCC)); + } + Strncpy(NCC[NCCsz].dnetd, dnetdev, sizeof(NCC[0].dnetd)); + Strncpy(NCC[NCCsz].pcapd, tmpdev, sizeof(NCC[0].pcapd)); + NCCsz++; + Strncpy(pcapdev, tmpdev, pcapdevlen); + return 1; +} +#endif + + +/* Compute exponential sleep time for my_pcap_open_live(). Returned + * value is 5 to the times-th power (5^times) */ +static unsigned int compute_sleep_time(unsigned int times){ + int i=0; + unsigned int result=1; + for(i=0; i= 3) { + return NULL; + } else { + netutil_error("pcap_open_live(%s, %d, %d, %d) FAILED. Reported error: %s. Will wait %d seconds then retry.", pcapdev, snaplen, promisc, to_ms, err0r, compute_sleep_time(failed)); + } + sleep( compute_sleep_time(failed) ); + } + } while (!pt); + +#ifdef WIN32 + /* We want any responses back ASAP */ + pcap_setmintocopy(pt, 1); +#endif + + return pt; +} + + +/* Set a pcap filter */ +void set_pcap_filter(const char *device, pcap_t *pd, const char *bpf, ...) { + va_list ap; + char buf[3072]; + struct bpf_program fcode; +#ifndef __amigaos__ + unsigned int localnet, netmask; +#else + bpf_u_int32 localnet, netmask; +#endif + char err0r[256]; + + // Cast below is becaue OpenBSD apparently has a version that takes a + // non-const device (hopefully they don't actually write to it). + if (pcap_lookupnet((char *) device, &localnet, &netmask, err0r) < 0) + netutil_fatal("Failed to lookup subnet/netmask for device (%s): %s", device, err0r); + + va_start(ap, bpf); + if (Vsnprintf(buf, sizeof(buf), bpf, ap) >= (int) sizeof(buf)) + netutil_fatal("%s called with too-large filter arg\n", __func__); + va_end(ap); + + /* Due to apparent bug in libpcap */ + /* Maybe this bug no longer exists ... I'll comment out for now + * if (islocalhost(target->v4hostip())) + * buf[0] = '\0'; */ + + if (pcap_compile(pd, &fcode, buf, 0, netmask) < 0) + netutil_fatal("Error compiling our pcap filter: %s", pcap_geterr(pd)); + if (pcap_setfilter(pd, &fcode) < 0) + netutil_fatal("Failed to set the pcap filter: %s\n", pcap_geterr(pd)); + pcap_freecode(&fcode); +} + + +/* Returns true if the captured frame is ARP. This function understands the + datalink types DLT_EN10MB and DLT_LINUX_SLL. */ +static bool frame_is_arp(const u8 *frame, int datalink) { + if (datalink == DLT_EN10MB) { + return ntohs(*((u16 *) (frame + 12))) == ETH_TYPE_ARP; + } else if (datalink == DLT_LINUX_SLL) { + return ntohs(*((u16 *) (frame + 2))) == ARPHRD_ETHER && /* sll_hatype */ + ntohs(*((u16 *) (frame + 4))) == 6 && /* sll_halen */ + ntohs(*((u16 *) (frame + 14))) == ETH_TYPE_ARP; /* sll_protocol */ + } else { + return false; + } +} + +/* Attempts to read one IPv4/Ethernet ARP reply packet from the pcap + descriptor pd. If it receives one, fills in sendermac (must pass + in 6 bytes), senderIP, and rcvdtime (can be NULL if you don't care) + and returns 1. If it times out and reads no arp requests, returns + 0. to_usec is the timeout period in microseconds. Use 0 to avoid + blocking to the extent possible. Returns -1 or exits if there is + an error. The last parameter is a pointer to a callback function + that can be used for packet tracing. This is intended to be used + by Nmap only. Any other calling this should pass NULL instead. */ +int read_arp_reply_pcap(pcap_t *pd, u8 *sendermac, + struct in_addr *senderIP, long to_usec, + struct timeval *rcvdtime, + void (*traceArp_callback)(int, const u8 *, u32 , struct timeval *)) { + static int warning = 0; + int datalink; + struct pcap_pkthdr head; + u8 *p; + int timedout = 0; + int badcounter = 0; + unsigned int offset; + struct timeval tv_start, tv_end; + + if (!pd) + netutil_fatal("NULL packet device passed to %s", __func__); + + if (to_usec < 0) { + if (!warning) { + warning = 1; + netutil_error("WARNING: Negative timeout value (%lu) passed to %s() -- using 0", to_usec, __func__); + } + to_usec = 0; + } + + /* New packet capture device, need to recompute offset */ + if ((datalink = pcap_datalink(pd)) < 0) + netutil_fatal("Cannot obtain datalink information: %s", pcap_geterr(pd)); + + if (datalink == DLT_EN10MB) { + offset = ETH_HDR_LEN; + } else if (datalink == DLT_LINUX_SLL) { + /* The datalink type is Linux "cooked" sockets. See pcap-linktype(7). */ + offset = 16; + } else { + netutil_fatal("%s called on interface that is datatype %d rather than DLT_EN10MB (%d) or DLT_LINUX_SLL (%d)", __func__, datalink, DLT_EN10MB, DLT_LINUX_SLL); + } + + if (to_usec > 0) { + gettimeofday(&tv_start, NULL); + } + + do { +#ifdef WIN32 + if (to_usec == 0) { + PacketSetReadTimeout(pd->adapter, 1); + } else { + gettimeofday(&tv_end, NULL); + long to_left = + MAX(1, (to_usec - TIMEVAL_SUBTRACT(tv_end, tv_start)) / 1000); + // Set the timeout (BUGBUG: this is cheating) + PacketSetReadTimeout(pd->adapter, to_left); + } +#endif + + p = NULL; + + if (pcap_select(pd, to_usec) == 0) + timedout = 1; + else + p = (u8 *) pcap_next(pd, &head); + + if (p && head.caplen >= offset + 28) { + /* hw type eth (0x0001), prot ip (0x0800), + hw size (0x06), prot size (0x04) */ + if (frame_is_arp(p, datalink) && + memcmp(p + offset, "\x00\x01\x08\x00\x06\x04\x00\x02", 8) == 0) { + memcpy(sendermac, p + offset + 8, 6); + /* I think alignment should allow this ... */ + memcpy(&senderIP->s_addr, p + offset + 14, 4); + break; + } + } + + if (!p) { + /* Should we timeout? */ + if (to_usec == 0) { + timedout = 1; + } else if (to_usec > 0) { + gettimeofday(&tv_end, NULL); + if (TIMEVAL_SUBTRACT(tv_end, tv_start) >= to_usec) { + timedout = 1; + } + } + } else { + /* We'll be a bit patient if we're getting actual packets back, but + not indefinitely so */ + if (badcounter++ > 50) + timedout = 1; + } + } while (!timedout); + + if (timedout) + return 0; + + if (rcvdtime) { + // FIXME: I eventually need to figure out why Windows head.ts time is sometimes BEFORE the time I + // sent the packet (which is according to gettimeofday() in nbase). For now, I will sadly have to + // use gettimeofday() for Windows in this case + // Actually I now allow .05 discrepancy. So maybe this isn't needed. I'll comment out for now. + // Nope: it is still needed at least for Windows. Sometimes the time from he pcap header is a + // COUPLE SECONDS before the gettimeofday() results :(. +#if defined(WIN32) || defined(__amigaos__) + gettimeofday(&tv_end, NULL); + *rcvdtime = tv_end; +#else + rcvdtime->tv_sec = head.ts.tv_sec; + rcvdtime->tv_usec = head.ts.tv_usec; + assert(head.ts.tv_sec); +#endif + } + if(traceArp_callback!=NULL){ + /* TODO: First parameter "2" is a hardcoded value for Nmap's PacketTrace::RECV*/ + traceArp_callback(2, (u8 *) p + offset, ARP_HDR_LEN + ARP_ETHIP_LEN, rcvdtime); + } + + return 1; +} + +/* Issues an ARP request for the MAC of targetss (which will be placed + in targetmac if obtained) from the source IP (srcip) and source mac + (srcmac) given. "The request is ussued using device dev to the + broadcast MAC address. The transmission is attempted up to 3 + times. If none of these elicit a response, false will be returned. + If the mac is determined, true is returned. The last parameter is + a pointer to a callback function that can be used for packet tracing. + This is intended to be used by Nmap only. Any other calling this + should pass NULL instead. */ +bool doArp(const char *dev, const u8 *srcmac, + const struct sockaddr_storage *srcip, + const struct sockaddr_storage *targetip, + u8 *targetmac, + void (*traceArp_callback)(int, const u8 *, u32 , struct timeval *) + ) { + /* timeouts in microseconds ... the first ones are retransmit times, while + the final one is when we give up */ + int timeouts[] = { 100000, 400000, 800000 }; + int max_sends = 3; + int num_sends = 0; // How many we have sent so far + eth_t *ethsd; + u8 frame[ETH_HDR_LEN + ARP_HDR_LEN + ARP_ETHIP_LEN]; + const struct sockaddr_in *targetsin = (struct sockaddr_in *) targetip; + const struct sockaddr_in *srcsin = (struct sockaddr_in *) srcip; + struct timeval start, now, rcvdtime; + int timeleft; + int listenrounds; + int rc; + pcap_t *pd; + struct in_addr rcvdIP; + bool foundit = false; + char filterstr[256]; + + if (targetsin->sin_family != AF_INET || srcsin->sin_family != AF_INET) + netutil_fatal("%s can only handle IPv4 addresses", __func__); + + /* Start listening */ + if((pd=my_pcap_open_live(dev, 50, 1, 25))==NULL) + netutil_fatal("my_pcap_open_live(%s, 50, 1, 25) failed three times.", dev); + Snprintf(filterstr, 256, "arp and arp[18:4] = 0x%02X%02X%02X%02X and arp[22:2] = 0x%02X%02X", + srcmac[0], srcmac[1], srcmac[2], srcmac[3], srcmac[4], srcmac[5]); + set_pcap_filter(dev, pd, filterstr); + + /* Prepare probe and sending stuff */ + ethsd = eth_open_cached(dev); + if (!ethsd) + netutil_fatal("%s: failed to open device %s", __func__, dev); + eth_pack_hdr(frame, ETH_ADDR_BROADCAST, *srcmac, ETH_TYPE_ARP); + arp_pack_hdr_ethip(frame + ETH_HDR_LEN, ARP_OP_REQUEST, *srcmac, + srcsin->sin_addr, ETH_ADDR_BROADCAST, + targetsin->sin_addr); + gettimeofday(&start, NULL); + gettimeofday(&now, NULL); + + while (!foundit && num_sends < max_sends) { + /* Send the sucker */ + rc = eth_send(ethsd, frame, sizeof(frame)); + if (rc != sizeof(frame)) { + netutil_error("WARNING: %s: eth_send of ARP packet returned %u rather than expected %d bytes", __func__, rc, (int) sizeof(frame)); + } + if(traceArp_callback!=NULL){ + /* TODO: First parameter "1" is a hardcoded value for Nmap's PacketTrace::SENT*/ + traceArp_callback(1, (u8 *) frame + ETH_HDR_LEN, ARP_HDR_LEN + ARP_ETHIP_LEN, &now); + } + num_sends++; + + listenrounds = 0; + while (!foundit) { + gettimeofday(&now, NULL); + timeleft = timeouts[num_sends - 1] - TIMEVAL_SUBTRACT(now, start); + if (timeleft < 0) { + if (listenrounds > 0) + break; + else + timeleft = 25000; + } + listenrounds++; + /* Now listen until we reach our next timeout or get an answer */ + rc = read_arp_reply_pcap(pd, targetmac, &rcvdIP, timeleft, + &rcvdtime, traceArp_callback); + if (rc == -1) + netutil_fatal("%s: Received -1 response from readarp_reply_pcap", __func__); + if (rc == 1) { + /* Yay, I got one! But is it the right one? */ + if (rcvdIP.s_addr != targetsin->sin_addr.s_addr) + continue; /* D'oh! */ + foundit = true; /* WOOHOO! */ + } + } + } + + /* OK - let's close up shop ... */ + pcap_close(pd); + /* No need to close ethsd due to caching */ + return foundit; +} + + + +static inline bool is_host_separator(int c) { + return c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == '\0'; +} + +/* Read a single host specification from a file, as for -iL and --excludefile. + It returns the length of the string read; an overflow is indicated when the + return value is >= n. Returns 0 if there was no specification to be read. The + buffer is always null-terminated. */ +size_t read_host_from_file(FILE *fp, char *buf, size_t n) +{ + int ch; + size_t i; + + i = 0; + ch = getc(fp); + while (is_host_separator(ch) || ch == '#') { + if (ch == '#') { + /* Skip comments to the end of the line. */ + while ((ch = getc(fp)) != EOF && ch != '\n') + ; + } else { + ch = getc(fp); + } + } + while (ch != EOF && !(is_host_separator(ch) || ch == '#')) { + if (i < n) + buf[i] = ch; + i++; + ch = getc(fp); + } + if (ch != EOF) + ungetc(ch, fp); + if (i < n) + buf[i] = '\0'; + else if (n > 0) + /* Null-terminate even though it was too long. */ + buf[n - 1] = '\0'; + + return i; +} + + +/* Return next target host specification from the supplied stream. + * if parameter "random" is set to true, then the function will + * return a random, non-reserved, IP address in decimal-dot notation */ +char *grab_next_host_spec(FILE *inputfd, bool random, int argc, char **fakeargv) { + static char host_spec[1024]; + struct in_addr ip; + size_t n; + + if (random) { + do { + ip.s_addr = get_random_unique_u32(); + } while (ip_is_reserved(&ip)); + Strncpy(host_spec, inet_ntoa(ip), sizeof(host_spec)); + } else if (!inputfd) { + return( (optind < argc)? fakeargv[optind++] : NULL); + } else { + n = read_host_from_file(inputfd, host_spec, sizeof(host_spec)); + if (n == 0) + return NULL; + else if (n >= sizeof(host_spec)) + netutil_fatal("One of the host specifications from your input file is too long (>= %u chars)", (unsigned int) sizeof(host_spec)); + } + return host_spec; +} + diff --git a/libnetutil/netutil.h b/libnetutil/netutil.h new file mode 100644 index 000000000..58a315eb2 --- /dev/null +++ b/libnetutil/netutil.h @@ -0,0 +1,476 @@ + +/*************************************************************************** + * netutil.h -- The main include file exposing the external API for * + * libnetutil, a library that provides network-related functions or * + * classes that make it easier to handle things like network interfaces, * + * routing tables, raw packet manipulation, etc. The lib was originally * + * written for use in the Nmap Security Scanner ( http://nmap.org ). * + * * + ***********************IMPORTANT NMAP LICENSE TERMS************************ + * * + * The Nmap Security Scanner is (C) 1996-2010 Insecure.Com LLC. Nmap is * + * also a registered trademark of Insecure.Com LLC. This program is free * + * software; you may redistribute and/or modify it under the terms of the * + * GNU General Public License as published by the Free Software * + * Foundation; Version 2 with the clarifications and exceptions described * + * below. This guarantees your right to use, modify, and redistribute * + * this software under certain conditions. If you wish to embed Nmap * + * technology into proprietary software, we sell alternative licenses * + * (contact sales@insecure.com). Dozens of software vendors already * + * license Nmap technology such as host discovery, port scanning, OS * + * detection, and version detection. * + * * + * Note that the GPL places important restrictions on "derived works", yet * + * it does not provide a detailed definition of that term. To avoid * + * misunderstandings, we consider an application to constitute a * + * "derivative work" for the purpose of this license if it does any of the * + * following: * + * o Integrates source code from Nmap * + * o Reads or includes Nmap copyrighted data files, such as * + * nmap-os-db or nmap-service-probes. * + * o Executes Nmap and parses the results (as opposed to typical shell or * + * execution-menu apps, which simply display raw Nmap output and so are * + * not derivative works.) * + * o Integrates/includes/aggregates Nmap into a proprietary executable * + * installer, such as those produced by InstallShield. * + * o Links to a library or executes a program that does any of the above * + * * + * The term "Nmap" should be taken to also include any portions or derived * + * works of Nmap. This list is not exclusive, but is meant to clarify our * + * interpretation of derived works with some common examples. Our * + * interpretation applies only to Nmap--we don't speak for other people's * + * GPL works. * + * * + * If you have any questions about the GPL licensing restrictions on using * + * Nmap in non-GPL works, we would be happy to help. As mentioned above, * + * we also offer alternative license to integrate Nmap into proprietary * + * applications and appliances. These contracts have been sold to dozens * + * of software vendors, and generally include a perpetual license as well * + * as providing for priority support and updates as well as helping to * + * fund the continued development of Nmap technology. Please email * + * sales@insecure.com for further information. * + * * + * As a special exception to the GPL terms, Insecure.Com LLC grants * + * permission to link the code of this program with any version of the * + * OpenSSL library which is distributed under a license identical to that * + * listed in the included COPYING.OpenSSL file, and distribute linked * + * combinations including the two. You must obey the GNU GPL in all * + * respects for all of the code used other than OpenSSL. If you modify * + * this file, you may extend this exception to your version of the file, * + * but you are not obligated to do so. * + * * + * If you received these files with a written license agreement or * + * contract stating terms other than the terms above, then that * + * alternative license agreement takes precedence over these comments. * + * * + * Source is provided to this software because we believe users have a * + * right to know exactly what a program is going to do before they run it. * + * This also allows you to audit the software for security holes (none * + * have been found so far). * + * * + * Source code also allows you to port Nmap to new platforms, fix bugs, * + * and add new features. You are highly encouraged to send your changes * + * to nmap-dev@insecure.org for possible incorporation into the main * + * distribution. By sending these changes to Fyodor or one of the * + * Insecure.Org development mailing lists, it is assumed that you are * + * offering the Nmap Project (Insecure.Com LLC) the unlimited, * + * non-exclusive right to reuse, modify, and relicense the code. Nmap * + * will always be available Open Source, but this is important because the * + * inability to relicense code has caused devastating problems for other * + * Free Software projects (such as KDE and NASM). We also occasionally * + * relicense the code to third parties as discussed above. If you wish to * + * specify special license conditions of your contributions, just say so * + * when you send them. * + * * + * This program is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * General Public License v2.0 for more details at * + * http://www.gnu.org/licenses/gpl-2.0.html , or in the COPYING file * + * included with Nmap. * + * * + ***************************************************************************/ + +/* $Id: netutil.h 18098 2010-06-14 11:50:12Z luis $ */ + +#ifndef _NETUTIL_H_ +#define _NETUTIL_H_ 1 + +#ifdef __cplusplus +extern "C" { +#endif +#include +#ifdef __cplusplus +} +#endif + +#include "dnet.h" + +enum { OP_FAILURE = -1, OP_SUCCESS = 0 }; + + +/* For systems without SCTP in netinet/in.h, such as MacOS X or Win */ +#ifndef IPPROTO_SCTP +#define IPPROTO_SCTP 132 +#endif + +int netutil_fatal(const char *str, ...) + __attribute__ ((format (printf, 1, 2))); + +int netutil_error(const char *str, ...) + __attribute__ ((format (printf, 1, 2))); + +/* This function converts zero-terminated 'txt' string to binary 'data'. + It is used to parse user input for ip options. Some examples of possible input + strings and results: + '\x01*2\xA2' -> [0x01,0x01,0xA2] // with 'x' number is parsed in hex + '\01\01\255' -> [0x01,0x01,0xFF] // without 'x' its in decimal + '\x01\x00*2' -> [0x01,0x00,0x00] // '*' is copying char + 'R' -> Record Route with 9 slots + 'S 192.168.0.1 172.16.0.1' -> Strict Route with 2 slots + 'L 192.168.0.1 172.16.0.1' -> Loose Route with 2 slots + 'T' -> Record Timestamp with 9 slots + 'U' -> Record Timestamp and Ip Address with 4 slots + On success, the function returns the length of the final binary + options stored in "data". In case of error, OP_FAILURE is returned + and the "errstr" buffer is filled with an error message + (unless it's NULL). Note that the returned error message does NOT + contain a newline character at the end. */ +int parse_ip_options(const char *txt, u8 *data, int datalen, int* firsthopoff, int* lasthopoff, char *errstr, size_t errstrlen); + +/* Tries to resolve the given name (or literal IP) into a sockaddr structure. + - Parameter "hostname" is the name to be resolved. + - Parameter "port" sets the port in each returned address structure + (you can safely pass 0 for the port if you don't care) + - Parameter "nodns": If set, it means that the supplied hostname is actually a + numeric IP address. The flag prevents any type of name resolution service + from being called. In 99% of the cases this should be 0. + Returns 1 on success or 0 if hostname could not be resolved. */ +int resolve(const char *hostname, u16 port, int nodns, struct sockaddr_storage *ss, size_t *sslen, int af); + +/* + * Returns 1 if this is a reserved IP address, where "reserved" means + * either a private address, non-routable address, or even a non-reserved + * but unassigned address which has an extremely high probability of being + * black-holed. + * + * We try to optimize speed when ordering the tests. This optimization + * assumes that all byte values are equally likely in the input. + * + * Warning: This function needs frequent attention because IANA has been + * allocating address blocks many times per year (although it's questionable + * how much longer this trend can be kept up). + * + * Check + * + * for the most recent assigments and + * for bogon + * netblocks. + */ +int ip_is_reserved(struct in_addr *ip); + + +/* A couple of trivial functions that maintain a cache of IP to MAC + * Address entries. Function arp_cache_get() looks for the IPv4 address + * in ss and fills in the 'mac' parameter and returns true if it is + * found. Otherwise (not found), the function returns false. + * Function arp_cache_set() adds an entry with the given ip (ss) and + * mac address. An existing entry for the IP ss will be overwritten + * with the new MAC address. arp_cache_set() always returns true. */ +int arp_cache_get(struct sockaddr_storage *ss, u8 *mac); +int arp_cache_set(struct sockaddr_storage *ss, u8 *mac); + +/* Standard BSD internet checksum routine. */ +unsigned short in_cksum(u16 *ptr, int nbytes); + +/* For computing TCP/UDP checksums, see RFC 1071 and TCP/IP Illustrated + sections 3.2, 11.3, and 17.3.*/ +unsigned short tcpudp_cksum(const struct in_addr *src, const struct in_addr *dst, + u8 proto, u16 len, const void *hstart); + +void sethdrinclude(int sd); +void set_ipoptions(int sd, void *opts, size_t optslen); +void set_ttl(int sd, int ttl); + +/* Returns whether the system supports pcap_get_selectable_fd() properly */ +int pcap_selectable_fd_valid(); + +/* Call this instead of pcap_get_selectable_fd directly (or your code + won't compile on Windows). On systems which don't seem to support + the pcap_get_selectable_fd() function properly, returns -1, + otherwise simply calls pcap_selectable_fd and returns the + results. If you just want to test whether the function is supported, + use pcap_selectable_fd_valid() instead. */ +int my_pcap_get_selectable_fd(pcap_t *p); + + +/* These two function return -1 if we can't use select() on the pcap + * device, 0 for timeout, and >0 for success. If select() fails we bail + * out because it couldn't work with the file descriptor we got from + * my_pcap_get_selectable_fd() */ +int pcap_select(pcap_t *p, struct timeval *timeout); +int pcap_select(pcap_t *p, long usecs); + +typedef enum { devt_ethernet, devt_loopback, devt_p2p, devt_other } devtype; + +#define MAX_LINK_HEADERSZ 24 +struct link_header { + int datalinktype; /* pcap_datalink(), such as DLT_EN10MB */ + int headerlen; /* 0 if header was too big or unavailaable */ + u8 header[MAX_LINK_HEADERSZ]; +}; + +/* Relevant (to Nmap) information about an interface */ +struct interface_info { + char devname[16]; + char devfullname[16]; /* can include alias info, such as eth0:2. */ + struct sockaddr_storage addr; + u16 netmask_bits; /* CIDR-style. So 24 means class C (255.255.255.0)*/ + devtype device_type; /* devt_ethernet, devt_loopback, devt_p2p, devt_other */ + int device_up; /* True if the device is up (enabled) */ + u8 mac[6]; /* Interface MAC address if device_type is devt_ethernet */ +}; + +struct route_nfo { + struct interface_info ii; + +/* true if the target is directly connected on the network (no routing + required). */ + int direct_connect; + +/* This is the source address that should be used by the packets. It + may be different than ii.addr if you are using localhost interface + to scan the IP of another interface on the machine */ + struct sockaddr_storage srcaddr; + + /* If direct_connect is 0, this is filled in with the next hop + required to route to the target */ + struct sockaddr_storage nexthop; +}; + +struct sys_route { + struct interface_info *device; + u32 dest; + u32 netmask; + struct in_addr gw; /* gateway - 0 if none */ +}; + +struct eth_nfo { + char srcmac[6]; + char dstmac[6]; + eth_t *ethsd; // Optional, but improves performance. Set to NULL if unavail + char devname[16]; // Only needed if ethsd is NULL. +}; + +/* A simple function that caches the eth_t from dnet for one device, + to avoid opening, closing, and re-opening it thousands of tims. If + you give a different device, this function will close the first + one. Thus this should never be used by programs that need to deal + with multiple devices at once. In addition, you MUST NEVER + eth_close() A DEVICE OBTAINED FROM THIS FUNCTION. Instead, you can + call eth_close_cached() to close whichever device (if any) is + cached. Returns NULL if it fails to open the device. */ +eth_t *eth_open_cached(const char *device); + +/* See the description for eth_open_cached */ +void eth_close_cached(); + +/* Takes a protocol number like IPPROTO_TCP, IPPROTO_UDP, or + * IPPROTO_IP and returns a ascii representation (or "unknown" if it + * doesn't recognize the number). Returned string is in lowercase. */ +const char *proto2ascii_lowercase(u8 proto) ; + +/* Same as proto2ascii() but returns a string in uppercase. */ +const char *proto2ascii_uppercase(u8 proto); + +/* Get an ASCII information about a tcp option which is pointed by + optp, with a length of len. The result is stored in the result + buffer. The result may look like "" */ +void tcppacketoptinfo(u8 *optp, int len, char *result, int bufsize); + +/* Convert an IP address to the device (IE ppp0 eth0) using that + * address. Supplied "dev" must be able to hold at least 32 bytes. + * Returns 0 on success or -1 in case of error. */ +int ipaddr2devname( char *dev, const struct in_addr *addr ); + +/* Convert a network interface name (IE ppp0 eth0) to an IPv4 address. + * Returns 0 on success or -1 in case of error. */ +int devname2ipaddr(char *dev, struct in_addr *addr); + +/* Returns an allocated array of struct interface_info representing the + available interfaces. The number of interfaces is returned in *howmany. This + function just does caching of results; the real work is done in + getinterfaces_dnet() or getinterfaces_siocgifconf(). + On error, NULL is returned, howmany is set to -1 and the supplied + error buffer "errstr", if not NULL, will contain an error message. */ +struct interface_info *getinterfaces(int *howmany, char *errstr, size_t errstrlen); + +/* This struct is abused to carry either routes or interfaces, depending on the + function it's used in. */ +struct dnet_collector_route_nfo { + struct sys_route *routes; + int numroutes; + int capacity; /* Capacity of routes or ifaces, depending on context */ + struct interface_info *ifaces; + int numifaces; +}; + +/* Looks for an interface with the given name (iname), and returns the + corresponding interface_info if found. Will accept a match of + devname or devfullname. Returns NULL if none found */ +struct interface_info *getInterfaceByName(char *iname); + +/* Parse the system routing table, converting each route into a + sys_route entry. Returns an array of sys_routes. numroutes is set + to the number of routes in the array. The routing table is only + read the first time this is called -- later results are cached. + The returned route array is sorted by netmask with the most + specific matches first. + On error, NULL is returned, howmany is set to -1 and the supplied + error buffer "errstr", if not NULL, will contain an error message. */ +struct sys_route *getsysroutes(int *howmany, char *errstr, size_t errstrlen); + +/* Tries to determine whether the supplied address corresponds to + * localhost. (eg: the address is something like 127.x.x.x, the address + * matches one of the local network interfaces' address, etc). + * Returns 1 if the address is thought to be localhost and 0 otherwise */ +int islocalhost(const struct in_addr *const addr); + +/* Determines whether the supplied address corresponds to a private, + * non-Internet-routable address. See RFC1918 for details. + * Returns 1 if the address is private or 0 otherwise. */ +int isipprivate(const struct in_addr *const addr); + +/* Takes binary data found in the IP Options field of an IPv4 packet + * and returns a string containing an ASCII description of the options + * found. The function returns a pointer to a static buffer that + * subsequent calls will overwrite. On error, NULL is returned. */ +char *format_ip_options(u8* ipopt, int ipoptlen); + +/* Returns a buffer of ASCII information about an IP packet that may + * look like "TCP 127.0.0.1:50923 > 127.0.0.1:3 S ttl=61 id=39516 + * iplen=40 seq=625950769" or "ICMP PING (0/1) ttl=61 id=39516 iplen=40". + * Returned buffer is static so it is NOT safe to call this in + * multi-threaded environments without appropriate sync protection, or + * call it twice in the same sentence (eg: as two printf parameters). + * Obviously, the caller should never attempt to free() the buffer. The + * returned buffer is guaranteed to be NULL-terminated but no + * assumptions should be made concerning its length. + * + * The function provides full support for IPv4,TCP,UDP,SCTP and ICMPv4. + * It also provides support for standard IPv6 but not for its extension + * headers. If an IPv6 packet contains an ICMPv6 Header, the output will + * reflect this but no parsing of ICMPv6 contents will be performed. + * + * The output has three different levels of detail. Parameter "detail" + * determines how verbose the output should be. It should take one of + * the following values: + * + * LOW_DETAIL (0x01): Traditional output. + * MEDIUM_DETAIL (0x02): More verbose than traditional. + * HIGH_DETAIL (0x03): Contents of virtually every field of the + * protocol headers . + */ +#define LOW_DETAIL 1 +#define MEDIUM_DETAIL 2 +#define HIGH_DETAIL 3 +const char *ippackethdrinfo(const u8 *packet, u32 len, int detail); + + +/* Takes an IPv4 destination address (dst) and tries to determine the + * source address and interface necessary to route to this address. + * If no route is found, 0 is returned and "rnfo" is undefined. If + * a route is found, 1 is returned and "rnfo" is filled in with all + * of the routing details. If the source address needs to be spoofed, + * it should be passed through "spoofss" (otherwise NULL should be + * specified), along with a suitable network device (parameter "device"). + * Even if spoofss is NULL, if user specified a network device with -e, + * it should still be passed. Note that it's OK to pass either NULL or + * an empty string as the "device", as long as spoofss==NULL. */ +int route_dst(const struct sockaddr_storage * const dst, struct route_nfo *rnfo, + char *device, struct sockaddr_storage *spoofss); + +/* Send an IP packet over a raw socket. */ +int send_ip_packet_sd(int sd, u8 *packet, unsigned int packetlen); + +/* Send an IP packet over an ethernet handle. */ +int send_ip_packet_eth(struct eth_nfo *eth, u8 *packet, unsigned int packetlen); + +/* Sends the supplied pre-built IPv4 packet. The packet is sent through + * the raw socket "sd" if "eth" is NULL. Otherwise, it gets sent at raw + * ethernet level. */ +int send_ip_packet_eth_or_sd(int sd, struct eth_nfo *eth, u8 *packet, unsigned int packetlen); + +/* Create and send all fragments of a pre-built IPv4 packet. + * Minimal MTU for IPv4 is 68 and maximal IPv4 header size is 60 + * which gives us a right to cut TCP header after 8th byte */ +int send_frag_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, + unsigned int packetlen, unsigned int mtu); + +/* Wrapper for system function sendto(), which retries a few times when + * the call fails. It also prints informational messages about the + * errors encountered. It returns the number of bytes sent or -1 in + * case of error. */ +int Sendto(const char *functionname, int sd, const unsigned char *packet, + int len, unsigned int flags, struct sockaddr *to, int tolen); + +/* This function is used to obtain a packet capture handle to look at + * packets on the network. It is actually a wrapper for libpcap's + * pcap_open_live() that takes care of compatibility issues and error + * checking. Prints an error and fatal()s if the call fails, so a + * valid pcap_t will always be returned. */ +pcap_t *my_pcap_open_live(const char *device, int snaplen, int promisc, int to_ms); + +/* Set a pcap filter */ +void set_pcap_filter(const char *device, pcap_t *pd, const char *bpf, ...); + +/* Issues an ARP request for the MAC of targetss (which will be placed + in targetmac if obtained) from the source IP (srcip) and source mac + (srcmac) given. "The request is ussued using device dev to the + broadcast MAC address. The transmission is attempted up to 3 + times. If none of these elicit a response, false will be returned. + If the mac is determined, true is returned. The last parameter is + a pointer to a callback function that can be used for packet traceing. + This is intended to be used by Nmap only. Any other calling this + should pass NULL instead. */ +bool doArp(const char *dev, const u8 *srcmac, + const struct sockaddr_storage *srcip, + const struct sockaddr_storage *targetip, + u8 *targetmac, + void (*traceArp_callback)(int, const u8 *, u32 , struct timeval *)); + +/* Attempts to read one IPv4/Ethernet ARP reply packet from the pcap + descriptor pd. If it receives one, fills in sendermac (must pass + in 6 bytes), senderIP, and rcvdtime (can be NULL if you don't care) + and returns 1. If it times out and reads no arp requests, returns + 0. to_usec is the timeout period in microseconds. Use 0 to avoid + blocking to the extent possible. Returns -1 or exits if there is + an error. The last parameter is a pointer to a callback function + that can be used for packet tracing. This is intended to be used + by Nmap only. Any other calling this should pass NULL instead. */ +int read_arp_reply_pcap(pcap_t *pd, u8 *sendermac, + struct in_addr *senderIP, long to_usec, + struct timeval *rcvdtime, + void (*traceArp_callback)(int, const u8 *, u32 , struct timeval *)); + +/* Read a single host specification from a file, as for -iL and --excludefile. + It returns the length of the string read; an overflow is indicated when the + return value is >= n. Returns 0 if there was no specification to be read. The + buffer is always null-terminated. */ +size_t read_host_from_file(FILE *fp, char *buf, size_t n); + +/* Return next target host specification from the supplied stream. + * if parameter "random" is set to true, then the function will + * return a random, non-reserved, IP address in decimal-dot notation */ +char *grab_next_host_spec(FILE *inputfd, bool random, int argc, char **fakeargv); + +#ifdef WIN32 +/* Convert a dnet interface name into the long pcap style. This also caches the + data to speed things up. Fills out pcapdev (up to pcapdevlen) and returns + true if it finds anything. Otherwise returns false. This is only necessary + on Windows. */ +int DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen); +#endif + +#endif /* _NETUTIL_H_ */ diff --git a/mswin32/nmap.sln b/mswin32/nmap.sln index f840087e9..a5bf2e73b 100644 --- a/mswin32/nmap.sln +++ b/mswin32/nmap.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 +# Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nmap", "nmap.vcproj", "{361719F0-AB42-4C93-9DE8-7D2144B96625}" ProjectSection(ProjectDependencies) = postProject {31FB0767-A71F-4575-8379-002D72B8AF86} = {31FB0767-A71F-4575-8379-002D72B8AF86} @@ -30,6 +30,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ncat", "..\ncat\ncat.vcproj EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nping", "..\nping\nping.vcproj", "{CDB10BBA-9085-4B9B-AC8F-BA31D3906B36}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libnetutil", "..\libnetutil\libnetutil.vcproj", "{99157C3F-39F6-4663-99D7-1D9C1484494E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -68,6 +70,10 @@ Global {CDB10BBA-9085-4B9B-AC8F-BA31D3906B36}.Debug|Win32.Build.0 = Debug|Win32 {CDB10BBA-9085-4B9B-AC8F-BA31D3906B36}.Release|Win32.ActiveCfg = Release|Win32 {CDB10BBA-9085-4B9B-AC8F-BA31D3906B36}.Release|Win32.Build.0 = Release|Win32 + {99157C3F-39F6-4663-99D7-1D9C1484494E}.Debug|Win32.ActiveCfg = Debug|Win32 + {99157C3F-39F6-4663-99D7-1D9C1484494E}.Debug|Win32.Build.0 = Debug|Win32 + {99157C3F-39F6-4663-99D7-1D9C1484494E}.Release|Win32.ActiveCfg = Release|Win32 + {99157C3F-39F6-4663-99D7-1D9C1484494E}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/mswin32/nmap.vcproj b/mswin32/nmap.vcproj index 7abaceaf1..4bf927801 100644 --- a/mswin32/nmap.vcproj +++ b/mswin32/nmap.vcproj @@ -1,7 +1,7 @@ - * for the most recent assigments and - * for bogon - * netblocks. - */ -static int ip_is_reserved(struct in_addr *ip) -{ - char *ipc = (char *) &(ip->s_addr); - unsigned char i1 = ipc[0], i2 = ipc[1], i3 = ipc[2]; /* i4 not currently used - , i4 = ipc[3]; */ - - /* do all the /7's and /8's with a big switch statement, hopefully the - * compiler will be able to optimize this a little better using a jump table - * or what have you - */ - switch (i1) - { - case 0: /* 000/8 is IANA reserved */ - case 5: /* 005/8 is IANA reserved */ - case 6: /* USA Army ISC */ - case 7: /* used for BGP protocol */ - case 10: /* the infamous 10.0.0.0/8 */ - case 23: /* 023/8 is IANA reserved */ - case 36: /* 036/8 is IANA reserved */ - case 37: /* 037/8 is IANA reserved */ - case 39: /* 039/8 is IANA reserved */ - case 42: /* 042/8 is IANA reserved */ - case 49: /* 049/8 is IANA reserved */ - case 55: /* misc. U.S.A. Armed forces */ - case 127: /* 127/8 is reserved for loopback */ - case 179: /* 179/8 is IANA reserved */ - case 185: /* 185/8 is IANA reserved */ - return 1; - default: - break; - } - - /* 100-106/8 is IANA reserved */ - if (i1 >= 100 && i1 <= 106) - return 1; - - /* 172.16.0.0/12 is reserved for private nets by RFC1819 */ - if (i1 == 172 && i2 >= 16 && i2 <= 31) - return 1; - - /* 192.0.2.0/24 is reserved for documentation and examples (RFC5737) */ - /* 192.88.99.0/24 is used as 6to4 Relay anycast prefix by RFC3068 */ - /* 192.168.0.0/16 is reserved for private nets by RFC1819 */ - if (i1 == 192) { - if (i2 == 0 && i3 == 2) - return 1; - if (i2 == 88 && i3 == 99) - return 1; - if (i2 == 168) - return 1; - } - - /* 198.18.0.0/15 is used for benchmark tests by RFC2544 */ - /* 198.51.100.0/24 is reserved for documentation (RFC5737) */ - if (i1 == 198) { - if (i2 == 18 || i2 == 19) - return 1; - if (i2 == 51 && i3 == 100) - return 1; - } - - /* 169.254.0.0/16 is reserved for DHCP clients seeking addresses */ - if (i1 == 169 && i2 == 254) - return 1; - - /* 203.0.113.0/24 is reserved for documentation (RFC5737) */ - if (i1 == 203 && i2 == 0 && i3 == 113) - return 1; - - /* 224-239/8 is all multicast stuff */ - /* 240-255/8 is IANA reserved */ - if (i1 >= 224) - return 1; - - return 0; -} - -static char *grab_next_host_spec(FILE *inputfd, int argc, char **fakeargv) { - static char host_spec[1024]; - struct in_addr ip; - size_t n; - - if (o.generate_random_ips) { - do { - ip.s_addr = get_random_unique_u32(); - } while (ip_is_reserved(&ip)); - Strncpy(host_spec, inet_ntoa(ip), sizeof(host_spec)); - } else if (!inputfd) { - return( (optind < argc)? fakeargv[optind++] : NULL); - } else { - n = read_host_from_file(inputfd, host_spec, sizeof(host_spec)); - if (n == 0) - return NULL; - else if (n >= sizeof(host_spec)) - fatal("One of the host specifications from your input file is too long (>= %u chars)", (unsigned int) sizeof(host_spec)); - } - return host_spec; -} - static void insert_port_into_merge_list(unsigned short *mlist, int *merged_port_count, unsigned short p) { @@ -581,6 +464,7 @@ int nmap_main(int argc, char *argv[]) { time_t timep; char mytime[128]; char tbuf[128]; + char errstr[256]; struct sockaddr_storage ss; size_t sslen; int option_index; @@ -980,7 +864,8 @@ int nmap_main(int argc, char *argv[]) { fatal("--top-ports should be an integer 1 or greater"); } else if (optcmp(long_options[option_index].name, "ip-options") == 0){ o.ipoptions = (u8*) safe_malloc(4*10+1); - o.ipoptionslen = parse_ip_options(optarg, o.ipoptions, 4*10+1, &o.ipopt_firsthop, &o.ipopt_lasthop); + if( (o.ipoptionslen=parse_ip_options(optarg, o.ipoptions, 4*10+1, &o.ipopt_firsthop, &o.ipopt_lasthop, errstr, sizeof(errstr)))==OP_FAILURE ) + fatal("%s", errstr); if(o.ipoptionslen > 4*10) fatal("Ip options can't be more than 40 bytes long"); if(o.ipoptionslen %4 != 0) @@ -1060,7 +945,12 @@ int nmap_main(int argc, char *argv[]) { } else { if (o.numdecoys >= MAX_DECOYS -1) fatal("You are only allowed %d decoys (if you need more redefine MAX_DECOYS in nmap.h)", MAX_DECOYS); - if (resolve(p, &o.decoys[o.numdecoys])) { + + /* Try to resolve it */ + struct sockaddr_in decoytemp; + size_t decoytemplen=sizeof(struct sockaddr_in); + if( resolve(p, 0, 0, (sockaddr_storage*)&decoytemp, &decoytemplen, AF_INET) == 1 ){ + o.decoys[o.numdecoys]=decoytemp.sin_addr; o.numdecoys++; } else { fatal("Failed to resolve decoy host: %s (must be hostname or IP address)", p); @@ -1244,7 +1134,7 @@ int nmap_main(int argc, char *argv[]) { case 'S': if (o.spoofsource) fatal("You can only use the source option once! Use -D -D etc. for decoys\n"); - if (resolve(optarg, &ss, &sslen, o.af()) == 0) { + if (resolve(optarg, 0, 0, &ss, &sslen, o.af()) == 0) { fatal("Failed to resolve/decode supposed %s source address %s. Note that if you are using IPv6, the -6 argument must come before -S", (o.af() == AF_INET)? "IPv4" : "IPv6", optarg); } o.setSourceSockAddr(&ss, sslen); @@ -1384,7 +1274,7 @@ int nmap_main(int argc, char *argv[]) { if (o.ipoptionslen >= 8) // at least one ip address log_write(LOG_STDOUT, "Binary ip options to be send:\n%s", buf); log_write(LOG_STDOUT, "Parsed ip options to be send:\n%s\n", - print_ip_options(o.ipoptions, o.ipoptionslen)); + format_ip_options(o.ipoptions, o.ipoptionslen)); } /* Open the log files, now that we know whether the user wants them appended @@ -1740,7 +1630,7 @@ int nmap_main(int argc, char *argv[]) { /* Now grab any new expressions */ while(num_host_exp_groups < o.ping_group_sz && (!o.max_ips_to_scan || o.max_ips_to_scan > o.numhosts_scanned + (int) Targets.size() + num_host_exp_groups) && - (host_spec = grab_next_host_spec(inputfd, argc, fakeargv))) { + (host_spec = grab_next_host_spec(inputfd, o.generate_random_ips, argc, fakeargv))) { // For purposes of random scan host_exp_group[num_host_exp_groups++] = strdup(host_spec); } @@ -1804,7 +1694,7 @@ int nmap_main(int argc, char *argv[]) { currenths->setSourceSockAddr(&ss, sslen); } else { if (gethostname(myname, MAXHOSTNAMELEN) || - resolve(myname, &ss, &sslen, o.af()) == 0) + resolve(myname, 0, 0, &ss, &sslen, o.af()) == 0) fatal("Cannot get hostname! Try using -S or -e \n"); o.setSourceSockAddr(&ss, sslen); @@ -2782,36 +2672,7 @@ int ftp_anon_connect(struct ftpinfo *ftp) { return sd; } -/* Returns one if the file pathname given exists, is not a directory and - * is readable by the executing process. Returns two if it is readable - * and is a directory. Otherwise returns 0. - */ -int fileexistsandisreadable(const char *pathname) { - char *pathname_buf = strdup(pathname); - int status = 0; - -#ifdef WIN32 - // stat on windows only works for "dir_name" not for "dir_name/" or "dir_name\\" - int pathname_len = strlen(pathname_buf); - char last_char = pathname_buf[pathname_len - 1]; - - if( last_char == '/' - || last_char == '\\') - pathname_buf[pathname_len - 1] = '\0'; - -#endif - - struct stat st; - - if (stat(pathname_buf, &st) == -1) - status = 0; - else if (access(pathname_buf, R_OK) != -1) - status = S_ISDIR(st.st_mode) ? 2 : 1; - - free(pathname_buf); - return status; -} int nmap_fileexistsandisreadable(const char* pathname) { return fileexistsandisreadable(pathname); diff --git a/nmap_config.h.in b/nmap_config.h.in index ed200abef..3ea9e5967 100644 --- a/nmap_config.h.in +++ b/nmap_config.h.in @@ -132,6 +132,8 @@ #undef HAVE_SYS_STAT_H +#undef HAVE_NET_IF_H + #undef HAVE_FCNTL_H #undef HAVE_TERMIOS_H diff --git a/nmap_dns.cc b/nmap_dns.cc index 86ca5fde6..bdb188132 100644 --- a/nmap_dns.cc +++ b/nmap_dns.cc @@ -799,7 +799,7 @@ static void add_dns_server(char *ipaddrs) { for (hostname = strtok(ipaddrs, " ,"); hostname != NULL; hostname = strtok(NULL, " ,")) { - if (!resolve(hostname, (struct sockaddr_storage *) &addr, &addr_len, PF_UNSPEC)) continue; + if (!resolve(hostname, 0, 0, (struct sockaddr_storage *) &addr, &addr_len, PF_UNSPEC)) continue; for(servI = servs.begin(); servI != servs.end(); servI++) { tpserv = *servI; diff --git a/nmap_rpc.cc b/nmap_rpc.cc index 84d113cab..38393cebd 100644 --- a/nmap_rpc.cc +++ b/nmap_rpc.cc @@ -100,6 +100,7 @@ #include "timing.h" #include "nmap_error.h" #include "utils.h" +#include "nbase.h" extern NmapOps o; static struct rpc_info ri; @@ -230,7 +231,7 @@ int send_rpc_query(Target *target_host, unsigned short portno, rpc_xid_base = (unsigned long) get_random_uint(); if (o.debugging > 1) { - log_write(LOG_PLAIN, "Sending RPC probe for program %li to %hu/%s -- scan_offset=%d trynum=%d xid=%lX\n", program, portno, proto2ascii(ipproto), scan_offset, trynum, rpc_xid_base + ((portno & 0x3FFF) << 16) + (trynum << 30) + scan_offset); + log_write(LOG_PLAIN, "Sending RPC probe for program %li to %hu/%s -- scan_offset=%d trynum=%d xid=%lX\n", program, portno, proto2ascii_lowercase(ipproto), scan_offset, trynum, rpc_xid_base + ((portno & 0x3FFF) << 16) + (trynum << 30) + scan_offset); } memset(&sock, 0, sizeof(sock)); @@ -372,7 +373,7 @@ static int rpc_are_we_done(char *msg, int msg_len, Target *target, if (o.debugging > 1) { log_write(LOG_PLAIN, "Port %hu/%s labelled NON_RPC because of invalid sized message (%d)\n", rsi->rpc_current_port->portno, - proto2ascii(rsi->rpc_current_port->proto, true), msg_len); + proto2ascii_uppercase(rsi->rpc_current_port->proto), msg_len); } rsi->rpc_status = RPC_STATUS_NOT_RPC; ss->numqueries_outstanding = 0; @@ -385,7 +386,7 @@ static int rpc_are_we_done(char *msg, int msg_len, Target *target, if (((scan_offset >> 16) & 0x3FFF) != (unsigned long) (rsi->rpc_current_port->portno & 0x3FFF)) { /* Doh -- this doesn't seem right */ if (o.debugging > 1) { - log_write(LOG_PLAIN, "Port %hu/%s labelled NON_RPC because ((scan_offset >> 16) & 0x3FFF) is %li\n", rsi->rpc_current_port->portno, proto2ascii(rsi->rpc_current_port->proto, true), ((scan_offset >> 16) & 0x3FFF)); + log_write(LOG_PLAIN, "Port %hu/%s labelled NON_RPC because ((scan_offset >> 16) & 0x3FFF) is %li\n", rsi->rpc_current_port->portno, proto2ascii_uppercase(rsi->rpc_current_port->proto), ((scan_offset >> 16) & 0x3FFF)); } rsi->rpc_status = RPC_STATUS_NOT_RPC; ss->numqueries_outstanding = 0; @@ -465,13 +466,13 @@ static int rpc_are_we_done(char *msg, int msg_len, Target *target, if (o.debugging > 1) { error("Port %hu/%s claims that it is not RPC service %li", rsi->rpc_current_port->portno, - proto2ascii(rsi->rpc_current_port->proto, true), current->portno); + proto2ascii_uppercase(rsi->rpc_current_port->proto), current->portno); } rsi->valid_responses_this_port++; return 0; } else if (ntohl(rpc_pack->accept_stat) == PROG_MISMATCH) { if (o.debugging > 1) { - error("Port %hu/%s claims IT IS RPC service %li", rsi->rpc_current_port->portno, proto2ascii(rsi->rpc_current_port->proto, true), current->portno); + error("Port %hu/%s claims IT IS RPC service %li", rsi->rpc_current_port->portno, proto2ascii_uppercase(rsi->rpc_current_port->proto), current->portno); } current->state = PORT_OPEN; rsi->rpc_status = RPC_STATUS_GOOD_PROG; @@ -589,7 +590,7 @@ void get_rpc_results(Target *target, struct portinfo *scan, if (o.debugging > 1) { log_write(LOG_PLAIN, "Port %hu/%s labelled NON_RPC because tcp_readlen is %d (should be at least 28)\n", rsi->rpc_current_port->portno, - proto2ascii(rsi->rpc_current_port->proto, true), + proto2ascii_uppercase(rsi->rpc_current_port->proto), (int) tcp_readlen); } ss->numqueries_outstanding = 0; @@ -603,7 +604,7 @@ void get_rpc_results(Target *target, struct portinfo *scan, if (o.debugging > 1) { log_write(LOG_PLAIN, "Port %hu/%s labelled NON_RPC because current_msg_len is %li while tcp_readlen is %d\n", rsi->rpc_current_port->portno, - proto2ascii(rsi->rpc_current_port->proto, true), + proto2ascii_uppercase(rsi->rpc_current_port->proto), current_msg_len, (int) tcp_readlen); } ss->numqueries_outstanding = 0; @@ -634,7 +635,7 @@ void get_rpc_results(Target *target, struct portinfo *scan, if (o.debugging > 1) { log_write(LOG_PLAIN, "Port %hu/%s labelled NON_RPC because current_msg_len is %li\n", rsi->rpc_current_port->portno, - proto2ascii(rsi->rpc_current_port->proto, true), + proto2ascii_uppercase(rsi->rpc_current_port->proto), current_msg_len); } rsi->rpc_status = RPC_STATUS_NOT_RPC; diff --git a/nse_nsock.cc b/nse_nsock.cc index 2bd6f3d51..9bf5354e1 100644 --- a/nse_nsock.cc +++ b/nse_nsock.cc @@ -21,6 +21,7 @@ extern "C" #include "utils.h" #include "tcpip.h" #include "protocols.h" +#include "libnetutil/netutil.h" #if HAVE_OPENSSL # include @@ -1324,10 +1325,6 @@ int l_nsock_sleep(lua_State * L) } /****************** NCAP_SOCKET ***********************************************/ -#ifdef WIN32 -/* From tcpip.cc. Gets pcap device name from dnet name. */ -bool DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen); -#endif /* fuckin' C++ maps stuff */ /* here we store ncap_sockets */ @@ -2144,7 +2141,7 @@ static int l_dnet_send_ip(lua_State * L) dstsin->sin_family = AF_INET; dstsin->sin_addr.s_addr = ip->ip_dst.s_addr; - if (!route_dst(&dstss, &route)) + if (!nmap_route_dst(&dstss, &route)) goto usesock; strncpy(dev, route.ii.devname, sizeof(dev)); diff --git a/osscan2.cc b/osscan2.cc index 622f909c6..a0dc9179f 100644 --- a/osscan2.cc +++ b/osscan2.cc @@ -2992,7 +2992,7 @@ int HostOsScan::send_closedudp_probe(HostOsScanStats *hss, udp->uh_ulen = htons(8 + datalen); /* OK, now we should be able to compute a valid checksum */ - realcheck = magic_tcpudp_cksum(source, hss->target->v4hostip(), IPPROTO_UDP, + realcheck = tcpudp_cksum(source, hss->target->v4hostip(), IPPROTO_UDP, sizeof(struct udp_hdr) + datalen, (char *) udp); #if STUPID_SOLARIS_CHECKSUM_BUG udp->uh_sum = sizeof(struct udp_hdr) + datalen; @@ -3207,7 +3207,8 @@ static void begin_sniffer(HostOsScan *HOS, vector &Targets) { } filterlen = 0; - HOS->pd = my_pcap_open_live(Targets[0]->deviceName(), 8192, (o.spoofsource)? 1 : 0, pcap_selectable_fd_valid()? 200 : 2); + if((HOS->pd=my_pcap_open_live(Targets[0]->deviceName(), 8192, (o.spoofsource)? 1 : 0, pcap_selectable_fd_valid()? 200 : 2))==NULL) + fatal("%s", PCAP_OPEN_ERRMSG); if (doIndividual) len = Snprintf(pcap_filter, sizeof(pcap_filter), "dst host %s and (icmp or (tcp and (%s", @@ -3219,9 +3220,9 @@ static void begin_sniffer(HostOsScan *HOS, vector &Targets) { fatal("ran out of space in pcap filter"); filterlen = len; - if (o.debugging > 2) log_write(LOG_PLAIN, "Pcap filter: %s\n", pcap_filter); + if (o.debugging) log_write(LOG_PLAIN, "Packet capture filter (device %s): %s\n", Targets[0]->deviceFullName(), pcap_filter); set_pcap_filter(Targets[0]->deviceFullName(), HOS->pd, pcap_filter); - + return; } diff --git a/output.cc b/output.cc index cae249fad..ae134f5ff 100644 --- a/output.cc +++ b/output.cc @@ -105,6 +105,8 @@ #include "Target.h" #include "utils.h" #include "xml.h" +#include "nbase.h" +#include "libnetutil/netutil.h" #include @@ -251,9 +253,6 @@ void win32_warn_raw_sockets(const char *devname) { } } -/* From tcpip.cc. */ -bool DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen); - /* Display the mapping from libdnet interface names (like "eth0") to WinPcap interface names (like "\Device\NPF_{...}"). This is the same mapping used by eth_open and so can help diagnose connection problems. Additionally display @@ -325,11 +324,17 @@ int print_iflist(void) { struct interface_info *iflist; struct sys_route *routes; NmapOutputTable *Tbl = NULL; - iflist = getinterfaces(&numifs); + char errstr[256]; + errstr[0]='\0'; + + iflist = getinterfaces(&numifs, errstr, sizeof(errstr)); + int i; /* First let's handle interfaces ... */ - if (numifs == 0) { + if (iflist==NULL || numifs<=0) { log_write(LOG_PLAIN, "INTERFACES: NONE FOUND(!)\n"); + if (o.debugging) + log_write(LOG_STDOUT, "Reason: %s\n", errstr); } else { int devcol = 0, shortdevcol = 1, ipcol = 2, typecol = 3, upcol = 4, maccol = 5; Tbl = new NmapOutputTable(numifs + 1, 6); @@ -374,12 +379,15 @@ int print_iflist(void) { #endif /* OK -- time to handle routes */ - routes = getsysroutes(&numroutes); + errstr[0]='\0'; + routes = getsysroutes(&numroutes, errstr, sizeof(errstr)); u32 mask_nbo; u16 nbits; struct in_addr ia; - if (numroutes == 0) { + if (routes==NULL || numroutes<= 0) { log_write(LOG_PLAIN, "ROUTES: NONE FOUND(!)\n"); + if (o.debugging) + log_write(LOG_STDOUT, "Reason: %s\n", errstr); } else { int dstcol = 0, devcol = 1, gwcol = 2; Tbl = new NmapOutputTable(numroutes + 1, 3); @@ -1950,13 +1958,13 @@ static void printtraceroute_normal(Target * currenths) { probe = currenths->traceroute_probespec; if (probe.type == PS_TCP) { log_write(LOG_PLAIN, "TRACEROUTE (using port %d/%s)\n", - probe.pd.tcp.dport, proto2ascii(probe.proto)); + probe.pd.tcp.dport, proto2ascii_lowercase(probe.proto)); } else if (probe.type == PS_UDP) { log_write(LOG_PLAIN, "TRACEROUTE (using port %d/%s)\n", - probe.pd.udp.dport, proto2ascii(probe.proto)); + probe.pd.udp.dport, proto2ascii_lowercase(probe.proto)); } else if (probe.type == PS_SCTP) { log_write(LOG_PLAIN, "TRACEROUTE (using port %d/%s)\n", - probe.pd.sctp.dport, proto2ascii(probe.proto)); + probe.pd.sctp.dport, proto2ascii_lowercase(probe.proto)); } else if (probe.type == PS_ICMP || probe.type == PS_PROTO) { struct protoent *proto = nmap_getprotbynum(htons(probe.proto)); log_write(LOG_PLAIN, "TRACEROUTE (using proto %d/%s)\n", @@ -2055,13 +2063,13 @@ static void printtraceroute_xml(Target * currenths) { probe = currenths->traceroute_probespec; if (probe.type == PS_TCP) { xml_attribute("port", "%d", probe.pd.tcp.dport); - xml_attribute("proto", "%s", proto2ascii(probe.proto)); + xml_attribute("proto", "%s", proto2ascii_lowercase(probe.proto)); } else if (probe.type == PS_UDP) { xml_attribute("port", "%d", probe.pd.udp.dport); - xml_attribute("proto", "%s", proto2ascii(probe.proto)); + xml_attribute("proto", "%s", proto2ascii_lowercase(probe.proto)); } else if (probe.type == PS_SCTP) { xml_attribute("port", "%d", probe.pd.sctp.dport); - xml_attribute("proto", "%s", proto2ascii(probe.proto)); + xml_attribute("proto", "%s", proto2ascii_lowercase(probe.proto)); } else if (probe.type == PS_ICMP || probe.type == PS_PROTO) { struct protoent *proto = nmap_getprotbynum(htons(probe.proto)); if (proto == NULL) diff --git a/output.h b/output.h index 0ff437e77..c7fcab05f 100644 --- a/output.h +++ b/output.h @@ -112,6 +112,23 @@ #define LOG_NAMES {"normal", "machine", "$Cr!pT |; or use mknod).\n*WINDOWS: Nmap only supports "\ + "ethernet interfaces on Windows for most operations because Microsoft "\ + "disabled raw sockets as of Windows XP SP2. Depending on the reason for "\ + "this error, it is possible that the --unprivileged command-line argument "\ + "will help.\nSOLARIS: If you are trying to scan localhost or the "\ + "address of an interface and are getting '/dev/lo0: No such file or "\ + "directory' or 'lo0: No DLPI device found', complain to Sun. I don't "\ + "think Solaris can support advanced localhost scans. You can probably "\ + "use \"-Pn -sT localhost\" though.\n\n" + #include "portlist.h" #include "nmap.h" #include "global_structures.h" diff --git a/portlist.cc b/portlist.cc index 84f449874..0113274dd 100644 --- a/portlist.cc +++ b/portlist.cc @@ -98,6 +98,7 @@ #include "protocols.h" #include "nmap_rpc.h" #include "tcpip.h" +#include "libnetutil/netutil.h" using namespace std; @@ -503,7 +504,7 @@ void PortList::setPortState(u16 portno, u8 protocol, int state) { if ((state == PORT_OPEN && o.verbose) || (o.debugging > 1)) { log_write(LOG_STDOUT, "Discovered %s port %hu/%s%s\n", statenum2str(state), portno, - proto2ascii(protocol), idstr? idstr : ""); + proto2ascii_lowercase(protocol), idstr? idstr : ""); log_flush(LOG_STDOUT); } @@ -521,7 +522,7 @@ void PortList::setPortState(u16 portno, u8 protocol, int state) { /* We must discount our statistics from the old values. Also warn if a complete duplicate */ if (o.debugging && oldport->state == state) { - error("Duplicate port (%hu/%s)", portno, proto2ascii(protocol)); + error("Duplicate port (%hu/%s)", portno, proto2ascii_lowercase(protocol)); } state_counts_proto[proto][oldport->state]--; } else { @@ -716,7 +717,7 @@ int PortList::forgetPort(u16 portno, u8 protocol) { if (o.verbose) { log_write(LOG_STDOUT, "Deleting port %hu/%s, which we thought was %s\n", - portno, proto2ascii(answer->proto), + portno, proto2ascii_lowercase(answer->proto), statenum2str(answer->state)); log_flush(LOG_STDOUT); } diff --git a/scan_engine.cc b/scan_engine.cc index 27ad31468..23af4887d 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -3933,7 +3933,7 @@ static bool get_arp_result(UltraScanInfo *USI, struct timeval *stime) { do { to_usec = TIMEVAL_SUBTRACT(*stime, USI->now); if (to_usec < 2000) to_usec = 2000; - rc = read_arp_reply_pcap(USI->pd, rcvdmac, &rcvdIP, to_usec, &rcvdtime); + rc = read_arp_reply_pcap(USI->pd, rcvdmac, &rcvdIP, to_usec, &rcvdtime, PacketTrace::traceArp); gettimeofday(&USI->now, NULL); if (rc == -1) fatal("Received -1 response from readarp_reply_pcap"); if (rc == 0) { @@ -4884,7 +4884,9 @@ static void begin_sniffer(UltraScanInfo *USI, vector &Targets) { } } - USI->pd = my_pcap_open_live(Targets[0]->deviceName(), 100, (o.spoofsource)? 1 : 0, pcap_selectable_fd_valid()? 200 : 2); + if((USI->pd=my_pcap_open_live(Targets[0]->deviceName(), 100, (o.spoofsource)? 1 : 0, pcap_selectable_fd_valid()? 200 : 2))==NULL) + fatal("%s", PCAP_OPEN_ERRMSG); + if (USI->ping_scan_arp){ /* Some OSs including Windows 7 and Solaris 10 have been seen to send their ARP replies to the broadcast address, not to the (unicast) address that @@ -4931,7 +4933,7 @@ static void begin_sniffer(UltraScanInfo *USI, vector &Targets) { pcap_filter+=" and (icmp or tcp or udp or sctp)"; } }else assert(0); - if (o.debugging > 2) log_write(LOG_PLAIN, "Pcap filter: %s\n", pcap_filter.c_str()); + if (o.debugging) log_write(LOG_PLAIN, "Packet capture filter (device %s): %s\n", Targets[0]->deviceFullName(), pcap_filter.c_str()); set_pcap_filter(Targets[0]->deviceFullName(), USI->pd, pcap_filter.c_str()); /* pcap_setnonblock(USI->pd, 1, NULL); */ return; diff --git a/service_scan.cc b/service_scan.cc index 3b117e2c7..b7e1df8c9 100644 --- a/service_scan.cc +++ b/service_scan.cc @@ -1420,7 +1420,7 @@ void ServiceNFO::addToServiceFingerprint(const char *probeName, const u8 *resp, if (servicefplen == 0) { timep = time(NULL); ltime = localtime(&timep); - servicefplen = Snprintf(servicefp, spaceleft, "SF-Port%hu-%s:V=%s%s%%I=%d%%D=%d/%d%%Time=%X%%P=%s", portno, proto2ascii(proto, true), NMAP_VERSION, (tunnel == SERVICE_TUNNEL_SSL)? "%T=SSL" : "", o.version_intensity, ltime->tm_mon + 1, ltime->tm_mday, (int) timep, NMAP_PLATFORM); + servicefplen = Snprintf(servicefp, spaceleft, "SF-Port%hu-%s:V=%s%s%%I=%d%%D=%d/%d%%Time=%X%%P=%s", portno, proto2ascii_uppercase(proto), NMAP_VERSION, (tunnel == SERVICE_TUNNEL_SSL)? "%T=SSL" : "", o.version_intensity, ltime->tm_mon + 1, ltime->tm_mday, (int) timep, NMAP_PLATFORM); } // Note that we give the total length of the response, even though we @@ -1711,7 +1711,7 @@ static void adjustPortStateIfNecessary(ServiceNFO *svc) { svc->target->NameIP(host, sizeof(host)); log_write(LOG_STDOUT, "Discovered %s port %hu/%s on %s is actually open\n", - statenum2str(oldstate), svc->portno, proto2ascii(svc->proto), host); + statenum2str(oldstate), svc->portno, proto2ascii_lowercase(svc->proto), host); log_flush(LOG_STDOUT); } } @@ -1728,7 +1728,7 @@ static void adjustPortStateIfNecessary(ServiceNFO *svc) { // Report data as probes are sent if --version-trace has been requested if (o.debugging > 1 || o.versionTrace()) { - log_write(LOG_PLAIN, "Service scan sending probe %s to %s:%hu (%s)\n", probe->getName(), svc->target->targetipstr(), svc->portno, proto2ascii(svc->proto)); + log_write(LOG_PLAIN, "Service scan sending probe %s to %s:%hu (%s)\n", probe->getName(), svc->target->targetipstr(), svc->portno, proto2ascii_lowercase(svc->proto)); } assert(probe); @@ -1984,7 +1984,7 @@ static int launchSomeServiceProbes(nsock_pool nsp, ServiceGroup *SG) { fatal("Failed to allocate Nsock I/O descriptor in %s()", __func__); } if (o.debugging > 1) { - log_write(LOG_PLAIN, "Starting probes against new service: %s:%hu (%s)\n", svc->target->targetipstr(), svc->portno, proto2ascii(svc->proto)); + log_write(LOG_PLAIN, "Starting probes against new service: %s:%hu (%s)\n", svc->target->targetipstr(), svc->portno, proto2ascii_lowercase(svc->proto)); } if (o.spoofsource) { o.SourceSockAddr(&ss, &ss_len); diff --git a/targets.cc b/targets.cc index b2425a7c2..21426e9d2 100644 --- a/targets.cc +++ b/targets.cc @@ -285,46 +285,6 @@ TargetGroup* load_exclude_string(const char *s) { return specs_to_targetgroups(specs); } -static inline bool is_host_separator(int c) { - return c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == '\0'; -} - -/* Read a single host specification from a file, as for -iL and --excludefile. - It returns the length of the string read; an overflow is indicated when the - return value is >= n. Returns 0 if there was no specification to be read. The - buffer is always null-terminated. */ -size_t read_host_from_file(FILE *fp, char *buf, size_t n) -{ - int ch; - size_t i; - - i = 0; - ch = getc(fp); - while (is_host_separator(ch) || ch == '#') { - if (ch == '#') { - /* Skip comments to the end of the line. */ - while ((ch = getc(fp)) != EOF && ch != '\n') - ; - } else { - ch = getc(fp); - } - } - while (ch != EOF && !(is_host_separator(ch) || ch == '#')) { - if (i < n) - buf[i] = ch; - i++; - ch = getc(fp); - } - if (ch != EOF) - ungetc(ch, fp); - if (i < n) - buf[i] = '\0'; - else if (n > 0) - /* Null-terminate even though it was too long. */ - buf[n - 1] = '\0'; - - return i; -} /* A debug routine to dump some information to stdout. Invoked if debugging is set to 3 or higher. I had to make significant changes from wam's code. @@ -505,7 +465,7 @@ Target *nexthost(HostGroupState *hs, TargetGroup *exclude_group, #endif // WIN32 )) { t->TargetSockAddr(&ss, &sslen); - if (!route_dst(&ss, &rnfo)) { + if (!nmap_route_dst(&ss, &rnfo)) { fatal("%s: failed to determine route to %s", __func__, t->NameIP()); } if (rnfo.direct_connect) { diff --git a/targets.h b/targets.h index 80f79910b..1bc1eb42b 100644 --- a/targets.h +++ b/targets.h @@ -161,8 +161,6 @@ Target *nexthost(HostGroupState *hs, TargetGroup *exclude_group, struct scan_lists *ports, int pingtype); TargetGroup* load_exclude_file(FILE *fp); TargetGroup* load_exclude_string(const char *s); -/* Read a single host specification from a file, as for -iL and --excludefile. */ -size_t read_host_from_file(FILE *fp, char *buf, size_t n); /* a debugging routine to dump an exclude list to stdout. */ int dumpExclude(TargetGroup*exclude_group); /* Returns the last host obtained by nexthost. It will be given again the next diff --git a/tcpip.cc b/tcpip.cc index 09604cba7..59ee48d87 100644 --- a/tcpip.cc +++ b/tcpip.cc @@ -93,6 +93,8 @@ #ifdef WIN32 #include "nmap_winconfig.h" #endif + +#include "nbase.h" #include "portreasons.h" #include #include @@ -101,6 +103,7 @@ #include "Target.h" #include "utils.h" + #if HAVE_SYS_TIME_H #include #endif @@ -114,13 +117,6 @@ #include #endif -#if HAVE_NET_IF_H -#ifndef NET_IF_H /* why doesn't OpenBSD do this? */ -#include -#define NET_IF_H -#endif -#endif - #if HAVE_NETINET_IF_ETHER_H #ifndef NETINET_IF_ETHER_H #include @@ -136,106 +132,12 @@ extern NmapOps o; static PacketCounter PktCt; -/* These two are for eth_open_cached() and eth_close_cached() */ -static char etht_cache_device_name[64]; -static eth_t *etht_cache_device = NULL; -void sethdrinclude(int sd) { -#ifdef IP_HDRINCL - int one = 1; - setsockopt(sd, IPPROTO_IP, IP_HDRINCL, (const char *) &one, sizeof(one)); -#endif -} -void set_ipoptions(int sd, void *opts, size_t optslen) { -#ifdef IP_OPTIONS - if (sd == -1) - return; - setsockopt(sd, IPPROTO_IP, IP_OPTIONS, (const char *) opts, optslen); -#endif -} -void set_ttl(int sd, int ttl) { -#ifdef IP_TTL - if (sd == -1) - return; - setsockopt(sd, IPPROTO_IP, IP_TTL, (const char *) &ttl, sizeof ttl); -#endif -} -// Takes a protocol number like IPPROTO_TCP, IPPROTO_UDP, or -// IPPROTO_IP and returns a ascii representation (or "unknown" if it -// doesn't recognize the number). If uppercase is true, the returned -// value will be in all uppercase letters. You can skip this -// parameter to use lowercase. -const char *proto2ascii(u8 proto, bool uppercase) { - switch (proto) { - - case IPPROTO_TCP: - return uppercase ? "TCP" : "tcp"; - break; - case IPPROTO_UDP: - return uppercase ? "UDP" : "udp"; - break; - case IPPROTO_SCTP: - return uppercase ? "SCTP" : "sctp"; - break; - case IPPROTO_IP: - return uppercase ? "IP" : "ip"; - break; -#ifdef IPPROTO_ICMP - case IPPROTO_ICMP: - return uppercase ? "ICMP" : "icmp"; - break; -#endif -#ifdef IPPROTO_IPV6 - case IPPROTO_IPV6: - return uppercase ? "IPv6" : "ipv6"; - break; -#endif -#ifdef IPPROTO_ICMPV6 - case IPPROTO_ICMPV6: - return uppercase ? "ICMPv6" : "icmpv6"; - break; -#endif -#ifdef IPPROTO_GRE - case IPPROTO_GRE: // Generic Routing Encapsulation - return uppercase ? "GRE" : "gre"; - break; -#endif -#ifdef IPPROTO_ESP - case IPPROTO_ESP: // Encapsulating Security Payload (IPSec) - return uppercase ? "IPSec/ESP" : "ipsec/esp"; - break; -#endif -#ifdef IPPROTO_AH - case IPPROTO_AH: // Authentication Header (IPSec) - return uppercase ? "IPSec/AH" : "ipsec/ah"; - break; -#endif - default: - return uppercase ? "UNKNOWN" : "unknown"; - } - - return NULL; // Unreached -} - -static char *ll2shortascii(unsigned long long bytes, char *buf, int buflen) { - if (buflen < 2 || !buf) - fatal("Bogus parameter passed to %s", __func__); - - if (bytes > 1000000) { - Snprintf(buf, buflen, "%.3fMB", bytes / 1000000.0); - } else if (bytes > 10000) { - Snprintf(buf, buflen, "%.3fKB", bytes / 1000.0); - } else { - Snprintf(buf, buflen, "%uB", (unsigned int) bytes); - } - - return buf; -} /* Fill buf (up to buflen -- truncate if necessary but always terminate) with a short representation of the packet stats. @@ -253,9 +155,9 @@ char *getFinalPacketStats(char *buf, int buflen) { "Raw packets sent: %llu (%s) | Rcvd: %llu (%s)", #endif PktCt.sendPackets, - ll2shortascii(PktCt.sendBytes, sendbytesasc, + format_bytecount(PktCt.sendBytes, sendbytesasc, sizeof(sendbytesasc)), PktCt.recvPackets, - ll2shortascii(PktCt.recvBytes, recvbytesasc, + format_bytecount(PktCt.recvBytes, recvbytesasc, sizeof(recvbytesasc))); return buf; } @@ -311,480 +213,25 @@ void PacketTrace::traceArp(pdirection pdir, const u8 *frame, u32 len, return; } -/* Get an ASCII information about a tcp option which is pointed by - optp, with a length of len. The result is stored in the result - buffer. The result may look like "" */ -static void tcppacketoptinfo(u8 *optp, int len, char *result, int bufsize) { - assert(optp); - assert(result); - char *p, ch; - u8 *q; - int opcode; - u16 tmpshort; - u32 tmpword1, tmpword2; - - p = result; - *p = '\0'; - q = optp; - ch = '<'; - - while (len > 0 && bufsize > 2) { - Snprintf(p, bufsize, "%c", ch); - bufsize--; - p++; - opcode = *q++; - if (!opcode) { /* End of List */ - - Snprintf(p, bufsize, "eol"); - bufsize -= strlen(p); - p += strlen(p); - - len--; - - } else if (opcode == 1) { /* No Op */ - Snprintf(p, bufsize, "nop"); - bufsize -= strlen(p); - p += strlen(p); - - len--; - } else if (opcode == 2) { /* MSS */ - if (len < 4) - break; /* MSS has 4 bytes */ - - q++; - memcpy(&tmpshort, q, 2); - - Snprintf(p, bufsize, "mss %u", ntohs(tmpshort)); - bufsize -= strlen(p); - p += strlen(p); - - q += 2; - len -= 4; - } else if (opcode == 3) { /* Window Scale */ - if (len < 3) - break; /* Window Scale option has 3 bytes */ - - q++; - - Snprintf(p, bufsize, "wscale %u", *q); - bufsize -= strlen(p); - p += strlen(p); - - q++; - len -= 3; - } else if (opcode == 4) { /* SACK permitted */ - if (len < 2) - break; /* SACK permitted option has 2 bytes */ - - Snprintf(p, bufsize, "sackOK"); - bufsize -= strlen(p); - p += strlen(p); - - q++; - len -= 2; - } else if (opcode == 5) { /* SACK */ - unsigned sackoptlen = *q; - if ((unsigned) len < sackoptlen) - break; - - /* This would break parsing, so it's best to just give up */ - if (sackoptlen < 2) - break; - - q++; - - if ((sackoptlen - 2) == 0 || ((sackoptlen - 2) % 8 != 0)) { - Snprintf(p, bufsize, "malformed sack"); - bufsize -= strlen(p); - p += strlen(p); - } else { - Snprintf(p, bufsize, "sack %d ", (sackoptlen - 2) / 8); - bufsize -= strlen(p); - p += strlen(p); - for (unsigned i = 0; i < sackoptlen - 2; i += 8) { - memcpy(&tmpword1, q + i, 4); - memcpy(&tmpword2, q + i + 4, 4); - Snprintf(p, bufsize, "{%u:%u}", tmpword1, tmpword2); - bufsize -= strlen(p); - p += strlen(p); - } - } - - q += sackoptlen - 2; - len -= sackoptlen; - } else if (opcode == 8) { /* Timestamp */ - if (len < 10) - break; /* Timestamp option has 10 bytes */ - - q++; - memcpy(&tmpword1, q, 4); - memcpy(&tmpword2, q + 4, 4); - - Snprintf(p, bufsize, "timestamp %u %u", ntohl(tmpword1), - ntohl(tmpword2)); - bufsize -= strlen(p); - p += strlen(p); - - q += 8; - len -= 10; - } - - ch = ','; - } - - if (len > 0) { - *result = '\0'; - return; - } - - Snprintf(p, bufsize, ">"); -} /* Returns a buffer of ASCII information about a packet that may look like "TCP 127.0.0.1:50923 > 127.0.0.1:3 S ttl=61 id=39516 iplen=40 seq=625950769" or "ICMP PING (0/1) ttl=61 id=39516 iplen=40". - Since this is a static buffer, don't use threads or call twice - within (say) printf(). And certainly don't try to free() it! The - returned buffer is NUL-terminated */ -static const char *ippackethdrinfo(const u8 *packet, u32 len) { - static char protoinfo[512]; - struct ip *ip = (struct ip *) packet; - struct tcp_hdr *tcp = NULL; - struct udp_hdr *udp = NULL; - struct sctp_hdr *sctp = NULL; - char ipinfo[512]; - char srchost[INET6_ADDRSTRLEN], dsthost[INET6_ADDRSTRLEN]; - char *p; - struct in_addr saddr, daddr; - int frag_off = 0, more_fragments = 0; - char fragnfo[64] = ""; - if (ip->ip_v != 4) - return "BOGUS! IP Version in packet is not 4"; - - if (len < sizeof(struct ip)) - return "BOGUS! Packet too short."; - - saddr.s_addr = ip->ip_src.s_addr; - daddr.s_addr = ip->ip_dst.s_addr; - - inet_ntop(AF_INET, &saddr, srchost, sizeof(srchost)); - inet_ntop(AF_INET, &daddr, dsthost, sizeof(dsthost)); - - frag_off = 8 * (ntohs(ip->ip_off) & IP_OFFMASK); - more_fragments = ntohs(ip->ip_off) & IP_MF; - if (frag_off || more_fragments) { - Snprintf(fragnfo, sizeof(fragnfo), " frag offset=%d%s", frag_off, more_fragments ? "+" : ""); - } - - - Snprintf(ipinfo, sizeof(ipinfo), "ttl=%d id=%d iplen=%d%s %s%s%s", - ip->ip_ttl, ntohs(ip->ip_id), ntohs(ip->ip_len), fragnfo, - ip->ip_hl == 5 ? "" : "ipopts={", - ip->ip_hl == 5 ? "" : print_ip_options((u8 *) ip + sizeof(struct ip), MIN((unsigned) (ip->ip_hl - 5) * 4, len - sizeof(struct ip))), - ip->ip_hl == 5 ? "" : "}"); - - if (ip->ip_p == IPPROTO_TCP) { - char tflags[10]; - char tcpinfo[64] = ""; - char buf[32]; - char tcpoptinfo[256] = ""; - - tcp = (struct tcp_hdr *) (packet + ip->ip_hl * 4); - if (frag_off > 8 || len < (u32) ip->ip_hl * 4 + 8) - Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:?? > %s:?? ?? %s (incomplete)", srchost, dsthost, ipinfo); - else if (frag_off == 8) { // at least we can get TCP flags and ACKn - tcp = (struct tcp_hdr *) ((u8 *) tcp - frag_off); // ugly? - p = tflags; - /* These are basically in tcpdump order */ - if (tcp->th_flags & TH_SYN) - *p++ = 'S'; - if (tcp->th_flags & TH_FIN) - *p++ = 'F'; - if (tcp->th_flags & TH_RST) - *p++ = 'R'; - if (tcp->th_flags & TH_PUSH) - *p++ = 'P'; - if (tcp->th_flags & TH_ACK) { - *p++ = 'A'; - Snprintf(tcpinfo, sizeof(tcpinfo), " ack=%lu", (unsigned long) ntohl(tcp->th_ack)); - } - if (tcp->th_flags & TH_URG) - *p++ = 'U'; - if (tcp->th_flags & TH_ECE) - *p++ = 'E'; /* rfc 2481/3168 */ - if (tcp->th_flags & TH_CWR) - *p++ = 'C'; /* rfc 2481/3168 */ - *p++ = '\0'; - - if ((u32) tcp->th_off * 4 > sizeof(struct tcp_hdr)) { - // tcp options - if (len < (u32) ip->ip_hl * 4 + (u32) tcp->th_off * 4 - frag_off) { - Snprintf(tcpoptinfo, sizeof(tcpoptinfo), "option incomplete"); - - } else { - tcppacketoptinfo((u8 *) tcp + sizeof(struct tcp_hdr), - tcp->th_off * 4 - sizeof(struct tcp_hdr), - tcpoptinfo, sizeof(tcpoptinfo)); - } - } - - Snprintf(protoinfo, sizeof(protoinfo), - "TCP %s:?? > %s:?? %s %s %s %s", srchost, dsthost, tflags, - ipinfo, tcpinfo, tcpoptinfo); - } else if (len < (u32) ip->ip_hl * 4 + 16) { // we can get ports and seq - Snprintf(tcpinfo, sizeof(tcpinfo), "seq=%lu (incomplete)", - (unsigned long) ntohl(tcp->th_seq)); - Snprintf(protoinfo, sizeof(protoinfo), "TCP %s:%d > %s:%d ?? %s %s", - srchost, ntohs(tcp->th_sport), dsthost, - ntohs(tcp->th_dport), ipinfo, tcpinfo); - } else { // at least first 16 bytes of TCP header are there - Snprintf(tcpinfo, sizeof(tcpinfo), "seq=%lu win=%hu", - (unsigned long) ntohl(tcp->th_seq), ntohs(tcp->th_win)); - p = tflags; - /* These are basically in tcpdump order */ - if (tcp->th_flags & TH_SYN) - *p++ = 'S'; - if (tcp->th_flags & TH_FIN) - *p++ = 'F'; - if (tcp->th_flags & TH_RST) - *p++ = 'R'; - if (tcp->th_flags & TH_PUSH) - *p++ = 'P'; - if (tcp->th_flags & TH_ACK) { - *p++ = 'A'; - Snprintf(buf, sizeof(buf), " ack=%lu", - (unsigned long) ntohl(tcp->th_ack)); - strncat(tcpinfo, buf, sizeof(tcpinfo) - strlen(tcpinfo) - 1); - } - if (tcp->th_flags & TH_URG) - *p++ = 'U'; - if (tcp->th_flags & TH_ECE) - *p++ = 'E'; /* rfc 2481/3168 */ - if (tcp->th_flags & TH_CWR) - *p++ = 'C'; /* rfc 2481/3168 */ - *p++ = '\0'; - - if ((u32) tcp->th_off * 4 > sizeof(struct tcp_hdr)) { - // tcp options - if (len < (u32) ip->ip_hl * 4 + (u32) tcp->th_off * 4) { - Snprintf(tcpoptinfo, sizeof(tcpoptinfo), "option incomplete"); - - } else { - tcppacketoptinfo((u8 *) tcp + sizeof(struct tcp_hdr), - tcp->th_off * 4 - sizeof(struct tcp_hdr), - tcpoptinfo, sizeof(tcpoptinfo)); - } - } - - Snprintf(protoinfo, sizeof(protoinfo), - "TCP %s:%d > %s:%d %s %s %s %s", srchost, - ntohs(tcp->th_sport), dsthost, ntohs(tcp->th_dport), tflags, - ipinfo, tcpinfo, tcpoptinfo); - } - } else if (ip->ip_p == IPPROTO_UDP && frag_off) { - Snprintf(protoinfo, sizeof(protoinfo), - "UDP %s:?? > %s:?? fragment %s (incomplete)", srchost, - dsthost, ipinfo); - } else if (ip->ip_p == IPPROTO_UDP) { - udp = (struct udp_hdr *) (packet + sizeof(struct ip)); - - Snprintf(protoinfo, sizeof(protoinfo), "UDP %s:%d > %s:%d %s", - srchost, ntohs(udp->uh_sport), dsthost, ntohs(udp->uh_dport), - ipinfo); - } else if (ip->ip_p == IPPROTO_SCTP && frag_off) { - Snprintf(protoinfo, sizeof(protoinfo), - "SCTP %s:?? > %s:?? fragment %s (incomplete)", srchost, - dsthost, ipinfo); - } else if (ip->ip_p == IPPROTO_SCTP) { - sctp = (struct sctp_hdr *) (packet + sizeof(struct ip)); - - Snprintf(protoinfo, sizeof(protoinfo), "SCTP %s:%d > %s:%d %s", - srchost, ntohs(sctp->sh_sport), dsthost, - ntohs(sctp->sh_dport), ipinfo); - } else if (ip->ip_p == IPPROTO_ICMP && frag_off) { - Snprintf(protoinfo, sizeof(protoinfo), - "ICMP %s > %s fragment %s (incomplete)", srchost, dsthost, - ipinfo); - } else if (ip->ip_p == IPPROTO_ICMP) { - char icmptype[128]; - char *ip2dst; - struct ip *ip2; - struct ppkt { - unsigned char type; - unsigned char code; - unsigned short checksum; - unsigned short id; - unsigned short seq; - } *ping = NULL; - unsigned pktlen = (ip->ip_hl * 4) + sizeof(struct ppkt); - if (pktlen > len) - goto icmpbad; - ping = (struct ppkt *) ((ip->ip_hl * 4) + (char *) ip); - switch (ping->type) { - case 0: - strcpy(icmptype, "echo reply"); - break; - case 3: - ip2 = (struct ip *) ((char *) ip + (ip->ip_hl * 4) + 8); - pktlen += (ip2->ip_hl * 4); - if (pktlen > len) - goto icmpbad; - if (pktlen + 8 < len) { - tcp = (struct tcp_hdr *) ((char *) ip2 + (ip2->ip_hl * 4)); - udp = (struct udp_hdr *) ((char *) ip2 + (ip2->ip_hl * 4)); - sctp = (struct sctp_hdr *) ((char *) ip2 + (ip2->ip_hl * 4)); - } - ip2dst = inet_ntoa(ip2->ip_dst); - switch (ping->code) { - case 0: - Snprintf(icmptype, sizeof icmptype, "network %s unreachable", ip2dst); - break; - case 1: - Snprintf(icmptype, sizeof icmptype, "host %s unreachable", ip2dst); - break; - case 2: - Snprintf(icmptype, sizeof icmptype, "protocol %u unreachable", ip2->ip_p); - break; - case 3: - if (ip2->ip_p == IPPROTO_UDP && udp) - Snprintf(icmptype, sizeof icmptype, "port %u unreachable", ntohs(udp->uh_dport)); - else if (ip2->ip_p == IPPROTO_TCP && tcp) - Snprintf(icmptype, sizeof icmptype, "port %u unreachable", ntohs(tcp->th_dport)); - else if (ip2->ip_p == IPPROTO_SCTP && sctp) - Snprintf(icmptype, sizeof icmptype, "port %u unreachable", ntohs(sctp->sh_dport)); - else - strcpy(icmptype, "port unreachable"); - break; - case 4: - strcpy(icmptype, "fragmentation required"); - break; - case 5: - strcpy(icmptype, "source route failed"); - break; - case 6: - Snprintf(icmptype, sizeof icmptype, "destination network %s unknown", ip2dst); - break; - case 7: - Snprintf(icmptype, sizeof icmptype, "destination host %s unknown", ip2dst); - break; - case 8: - strcpy(icmptype, "source host isolated"); - break; - case 9: - Snprintf(icmptype, sizeof icmptype, "destination network %s administratively prohibited", ip2dst); - break; - case 10: - Snprintf(icmptype, sizeof icmptype, "destination host %s administratively prohibited", ip2dst); - break; - case 11: - Snprintf(icmptype, sizeof icmptype, "network %s unreachable for TOS", ip2dst); - break; - case 12: - Snprintf(icmptype, sizeof icmptype, "host %s unreachable for TOS", ip2dst); - break; - case 13: - strcpy(icmptype, - "communication administratively prohibited by filtering"); - break; - case 14: - strcpy(icmptype, "host precedence violation"); - break; - case 15: - strcpy(icmptype, "precedence cutoff in effect"); - break; - default: - strcpy(icmptype, "unknown unreachable code"); - break; - } - break; - case 4: - strcpy(icmptype, "source quench"); - break; - case 5: - if (ping->code == 0) - strcpy(icmptype, "network redirect"); - else if (ping->code == 1) - strcpy(icmptype, "host redirect"); - else - strcpy(icmptype, "unknown redirect"); - break; - case 8: - strcpy(icmptype, "echo request"); - break; - case 11: - if (ping->code == 0) - strcpy(icmptype, "TTL=0 during transit"); - else if (ping->code == 1) - strcpy(icmptype, "TTL=0 during reassembly"); - else - strcpy(icmptype, "TTL exceeded (unknown code)"); - break; - case 12: - if (ping->code == 0) - strcpy(icmptype, "IP header bad"); - else - strcpy(icmptype, "Misc. parameter problem"); - break; - case 13: - strcpy(icmptype, "Timestamp request"); - break; - case 14: - strcpy(icmptype, "Timestamp reply"); - break; - case 15: - strcpy(icmptype, "Information request"); - break; - case 16: - strcpy(icmptype, "Information reply"); - break; - case 17: - strcpy(icmptype, "Address mask request"); - break; - case 18: - strcpy(icmptype, "Address mask reply"); - break; - case 30: - strcpy(icmptype, "Traceroute"); - break; - case 37: - strcpy(icmptype, "Domain name request"); - break; - case 38: - strcpy(icmptype, "Domain name reply"); - break; - case 40: - strcpy(icmptype, "Security failures"); /* rfc 2521 */ - break; - default: - strcpy(icmptype, "Unknown type"); - break; - break; - } - if (pktlen > len) { - icmpbad: - if (ping) { - /* We still have this information */ - Snprintf(protoinfo, sizeof(protoinfo), - "ICMP %s > %s (type=%d/code=%d) %s", srchost, dsthost, - ping->type, ping->code, ipinfo); - } else { - Snprintf(protoinfo, sizeof(protoinfo), "ICMP %s > %s [??] %s", srchost, dsthost, ipinfo); - } - } else { - Snprintf(protoinfo, sizeof(protoinfo), - "ICMP %s > %s %s (type=%d/code=%d) %s", srchost, dsthost, - icmptype, ping->type, ping->code, ipinfo); - } - } else { - Snprintf(protoinfo, sizeof(protoinfo), - "Unknown protocol (%d) %s > %s: %s", ip->ip_p, srchost, - dsthost, ipinfo); - } - - return protoinfo; + IMPORTANT: This is a wrapper for function ippackethdrinfo(). Check + nbase/nbase_net.c for details on the returned buffer. */ +static const char *nmap_format_ippacket(const u8 *packet, u32 len) { + int detail=LOW_DETAIL; + if(o.debugging==2){ + detail=MEDIUM_DETAIL; + }else if(o.debugging>=3){ + detail=HIGH_DETAIL; + } + return ippackethdrinfo(packet, len, detail); } + + + /* Takes an IP PACKET and prints it if packet tracing is enabled. 'packet' must point to the IPv4 header. The direction must be PacketTrace::SENT or PacketTrace::RCVD . Optional 'now' argument @@ -817,7 +264,7 @@ void PacketTrace::trace(pdirection pdir, const u8 *packet, u32 len, log_write(LOG_STDOUT | LOG_NORMAL, "%s (%.4fs) %s\n", (pdir == SENT) ? "SENT" : "RCVD", - o.TimeSinceStartMS(&tv) / 1000.0, ippackethdrinfo(packet, len)); + o.TimeSinceStartMS(&tv) / 1000.0, nmap_format_ippacket(packet, len)); return; } @@ -932,267 +379,6 @@ struct addrinfo *resolve_all(char *hostname, int pf) return result; } -/* Tries to resolve the given name (or literal IP) into a sockaddr structure. - The af should be PF_INET (for IPv4) or PF_INET6. Returns 0 if hostname - cannot be resolved. It is OK to pass in a sockaddr_in or sockaddr_in6 casted - to a sockaddr_storage as long as you use the matching pf. */ -int resolve(char *hostname, struct sockaddr_storage *ss, size_t *sslen, int pf) { - struct addrinfo *result; - - assert(ss); - assert(sslen); - result = resolve_all(hostname, pf); - assert(result->ai_addrlen > 0 - && result->ai_addrlen <= (int) sizeof(struct sockaddr_storage)); - *sslen = result->ai_addrlen; - memcpy(ss, result->ai_addr, *sslen); - freeaddrinfo(result); - return 1; -} - -int islocalhost(const struct in_addr *const addr) { - char dev[128]; - /* If it is 0.0.0.0 or starts with 127 then it is - probably localhost */ - if ((addr->s_addr & htonl(0xFF000000)) == htonl(0x7F000000)) - return 1; - - if (!addr->s_addr) - return 1; - - /* If it is the same addy as a local interface, then it is - probably localhost */ - if (ipaddr2devname(dev, addr) != -1) - return 1; - - /* OK, so to a first approximation, this addy is probably not - localhost */ - return 0; -} - -int isipprivate(const struct in_addr *const addr) { - char *ipc; - unsigned char i1, i2; - - if (!addr) - return 0; - - ipc = (char *) &(addr->s_addr); - i1 = ipc[0]; - i2 = ipc[1]; - - /* 10.0.0.0/8 */ - if (i1 == 10) - return 1; - - /* 172.16.0.0/12 */ - if (i1 == 172 && i2 >= 16 && i2 <= 31) - return 1; - - /* 192.168.0.0/16 */ - if (i1 == 192 && i2 == 168) - return 1; - - return 0; -} - -#ifdef WIN32 -/* Convert a dnet interface name into the long pcap style. This also caches the - data to speed things up. Fills out pcapdev (up to pcapdevlen) and returns - true if it finds anything. Otherwise returns false. This is only necessary - on Windows. */ -bool DnetName2PcapName(const char *dnetdev, char *pcapdev, int pcapdevlen) { - static struct NameCorrelationCache { - char dnetd[64]; - char pcapd[128]; - } *NCC = NULL; - static int NCCsz = 0; - static int NCCcapacity = 0; - int i; - char tmpdev[128]; - - // Init the cache if not done yet - if (!NCC) { - NCCcapacity = 5; - NCC = - (struct NameCorrelationCache *) safe_zalloc(NCCcapacity * - sizeof(*NCC)); - NCCsz = 0; - } - // First check if the name is already in the cache - for (i = 0; i < NCCsz; i++) { - if (strcmp(NCC[i].dnetd, dnetdev) == 0) { - Strncpy(pcapdev, NCC[i].pcapd, pcapdevlen); - return true; - } - } - - // OK, so it isn't in the cache. Let's ask dnet for it. -/* Converts a dnet interface name (ifname) to its pcap equivalent, which is stored in -pcapdev (up to a length of pcapdevlen). Returns 0 and fills in pcapdev if successful. */ - if (eth_get_pcap_devname(dnetdev, tmpdev, sizeof(tmpdev)) != 0) - return false; - - // We've got it. Let's add it to the cache - if (NCCsz >= NCCcapacity) { - NCCcapacity <<= 2; - NCC = - (struct NameCorrelationCache *) safe_realloc(NCC, - NCCcapacity * - sizeof(*NCC)); - } - Strncpy(NCC[NCCsz].dnetd, dnetdev, sizeof(NCC[0].dnetd)); - Strncpy(NCC[NCCsz].pcapd, tmpdev, sizeof(NCC[0].pcapd)); - NCCsz++; - Strncpy(pcapdev, tmpdev, pcapdevlen); - return true; -} -#endif - -pcap_t *my_pcap_open_live(const char *device, int snaplen, int promisc, int to_ms) { - char err0r[PCAP_ERRBUF_SIZE]; - pcap_t *pt; - char pcapdev[128]; - int failed = 0; - - assert(device != NULL); - -#ifdef WIN32 - /* Nmap normally uses device names obtained through dnet for interfaces, but - Pcap has its own naming system. So the conversion is done here */ - if (!DnetName2PcapName(device, pcapdev, sizeof(pcapdev))) { - /* Oh crap -- couldn't find the corresponding dev apparently. Let's just go - with what we have then ... */ - Strncpy(pcapdev, device, sizeof(pcapdev)); - } -#else - Strncpy(pcapdev, device, sizeof(pcapdev)); -#endif - do { - pt = pcap_open_live(pcapdev, snaplen, promisc, to_ms, err0r); - if (!pt) { - failed++; - if (failed >= 3) { - fatal("Call to pcap_open_live(%s, %d, %d, %d) failed three times. Reported error: %s\nThere are several possible reasons for this, depending on your operating system:\n" - "LINUX: If you are getting Socket type not supported, try modprobe af_packet or recompile your kernel with SOCK_PACKET enabled.\n" - "*BSD: If you are getting device not configured, you need to recompile your kernel with Berkeley Packet Filter support. If you are getting No such file or directory, try creating the device (eg cd /dev; MAKEDEV ; or use mknod).\n" - "*WINDOWS: Nmap only supports ethernet interfaces on Windows for most operations because Microsoft disabled raw sockets as of Windows XP SP2. Depending on the reason for this error, it is possible that the --unprivileged command-line argument will help.\n" - "SOLARIS: If you are trying to scan localhost or the address of an interface and are getting '/dev/lo0: No such file or directory' or 'lo0: No DLPI device found', complain to Sun. I don't think Solaris can support advanced localhost scans. You can probably use \"-Pn -sT localhost\" though.\n\n", - pcapdev, snaplen, promisc, to_ms, err0r); - } else { - error("pcap_open_live(%s, %d, %d, %d) FAILED. Reported error: %s. Will wait %d seconds then retry.", pcapdev, snaplen, promisc, to_ms, err0r, (int) pow(5.0, failed)); - } - sleep((int) pow(5.0, failed)); - } - } while (!pt); - -#ifdef WIN32 - /* We want any responses back ASAP */ - pcap_setmintocopy(pt, 1); -#endif - - return pt; -} - -/* Standard BSD internet checksum routine. Uses libdnet helper functions. */ -unsigned short in_cksum(u16 *ptr, int nbytes) { - int sum; - - sum = ip_cksum_add(ptr, nbytes, 0); - - return ip_cksum_carry(sum); -} - -/* For computing TCP/UDP checksums, see RFC 1071 and TCP/IP Illustrated - sections 3.2, 11.3, and 17.3. */ -unsigned short magic_tcpudp_cksum(const struct in_addr *src, - const struct in_addr *dst, - u8 proto, u16 len, const void *hstart) { - struct pseudo { - struct in_addr src; - struct in_addr dst; - u8 zero; - u8 proto; - u16 length; - } hdr; - int sum; - - hdr.src = *src; - hdr.dst = *dst; - hdr.zero = 0; - hdr.proto = proto; - hdr.length = htons(len); - - /* Get the ones'-complement sum of the pseudo-header. */ - sum = ip_cksum_add(&hdr, sizeof(hdr), 0); - /* Add it to the sum of the packet. */ - sum = ip_cksum_add(hstart, len, sum); - - /* Fold in the carry, take the complement, and return. */ - return ip_cksum_carry(sum); -} - -/* LEGACY resolve() function that only supports IPv4 -- see IPv6 version - above. Tries to resolve given hostname and stores - result in ip . returns 0 if hostname cannot - be resolved */ -int resolve(char *hostname, struct in_addr *ip) { - struct hostent *h; - - if (!hostname || !*hostname) - fatal("NULL or zero-length hostname passed to %s()", __func__); - - if (inet_pton(AF_INET, hostname, ip)) - return 1; /* damn, that was easy ;) */ - if ((h = gethostbyname(hostname))) { - memcpy(ip, h->h_addr_list[0], sizeof(struct in_addr)); - return 1; - } - return 0; -} - -/* A simple function that caches the eth_t from dnet for one device, - to avoid opening, closing, and re-opening it thousands of tims. If - you give a different device, this function will close the first - one. Thus this should never be used by programs that need to deal - with multiple devices at once. In addition, you MUST NEVER - eth_close() A DEVICE OBTAINED FROM THIS FUNCTION. Instead, you can - call eth_close_cached() to close whichever device (if any) is - cached. Returns NULL if it fails to open the device. */ -eth_t *eth_open_cached(const char *device) { - if (!device) - fatal("%s() called with NULL device name!", __func__); - if (!*device) - fatal("%s() called with empty device name!", __func__); - - if (strcmp(device, etht_cache_device_name) == 0) { - /* Yay, we have it cached. */ - return etht_cache_device; - } - - if (*etht_cache_device_name) { - eth_close(etht_cache_device); - etht_cache_device_name[0] = '\0'; - etht_cache_device = NULL; - } - - etht_cache_device = eth_open(device); - if (etht_cache_device) - Strncpy(etht_cache_device_name, device, - sizeof(etht_cache_device_name)); - - return etht_cache_device; -} - -/* See the description for eth_open_cached */ -void eth_close_cached() { - if (etht_cache_device) { - eth_close(etht_cache_device); - etht_cache_device = NULL; - etht_cache_device_name[0] = '\0'; - } - return; -} // fill ip header. no error check. // This function is also changing what's needed from host to network order. @@ -1330,7 +516,7 @@ u8 *build_tcp_raw(const struct in_addr *source, #if STUPID_SOLARIS_CHECKSUM_BUG tcp->th_sum = sizeof(struct tcp_hdr) + tcpoptlen + datalen; #else - tcp->th_sum = magic_tcpudp_cksum(source, victim, IPPROTO_TCP, + tcp->th_sum = tcpudp_cksum(source, victim, IPPROTO_TCP, sizeof(struct tcp_hdr) + tcpoptlen + datalen, (char *) tcp); #endif @@ -1371,96 +557,8 @@ int send_tcp_raw(int sd, struct eth_nfo *eth, return res; } -/* Create and send all fragments of a pre-built IPv4 packet - * Minimal MTU for IPv4 is 68 and maximal IPv4 header size is 60 - * which gives us a right to cut TCP header after 8th byte - * (shouldn't we inflate the header to 60 bytes too?) */ -int send_frag_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, - unsigned int packetlen, unsigned int mtu) { - struct ip *ip = (struct ip *) packet; - int headerlen = ip->ip_hl * 4; // better than sizeof(struct ip) - unsigned int datalen = packetlen - headerlen; - int fdatalen = 0, res = 0; - assert(headerlen <= (int) packetlen); - assert(headerlen >= 20 && headerlen <= 60); // sanity check (RFC791) - assert(mtu > 0 && mtu % 8 == 0); // otherwise, we couldn't set Fragment offset (ip->ip_off) correctly - if (datalen <= mtu) { - error("Warning: fragmentation (mtu=%i) requested but the payload is too small already (%i)", mtu, datalen); - return send_ip_packet(sd, eth, packet, packetlen); - } - - u8 *fpacket = (u8 *) safe_malloc(headerlen + mtu); - memcpy(fpacket, packet, headerlen + mtu); - ip = (struct ip *) fpacket; - - // create fragments and send them - for (int fragment = 1; fragment * mtu < datalen + mtu; fragment++) { - fdatalen = (fragment * mtu <= datalen ? mtu : datalen % mtu); - ip->ip_len = htons(headerlen + fdatalen); - ip->ip_off = htons((fragment - 1) * mtu / 8); - if ((fragment - 1) * mtu + fdatalen < datalen) - ip->ip_off |= htons(IP_MF); -#if HAVE_IP_IP_SUM - ip->ip_sum = 0; - ip->ip_sum = in_cksum((unsigned short *) ip, headerlen); -#endif - if (fragment > 1) // copy data payload - memcpy(fpacket + headerlen, - packet + headerlen + (fragment - 1) * mtu, fdatalen); - res = send_ip_packet(sd, eth, fpacket, headerlen + fdatalen); - if (res == -1) - break; - } - free(fpacket); - return res; -} - -static int Sendto(const char *functionname, int sd, - const unsigned char *packet, int len, unsigned int flags, - struct sockaddr *to, int tolen) { - - struct sockaddr_in *sin = (struct sockaddr_in *) to; - int res; - int retries = 0; - int sleeptime = 0; - static int numerrors = 0; - - do { - if ((res = sendto(sd, (const char *) packet, len, flags, to, tolen)) == -1) { - int err = socket_errno(); - - numerrors++; - if (o.debugging > 1 || numerrors <= 10) { - error("sendto in %s: sendto(%d, packet, %d, 0, %s, %d) => %s", - functionname, sd, len, inet_ntoa(sin->sin_addr), tolen, - strerror(err)); - error("Offending packet: %s", ippackethdrinfo(packet, len)); - if (numerrors == 10) { - error("Omitting future %s error messages now that %d have been shown. Use -d2 if you really want to see them.", __func__, numerrors); - } - } -#if WIN32 - return -1; -#else - if (retries > 2 || err == EPERM || err == EACCES - || err == EADDRNOTAVAIL || err == EINVAL) - return -1; - sleeptime = 15 * (1 << (2 * retries)); - error("Sleeping %d seconds then retrying", sleeptime); - fflush(stderr); - sleep(sleeptime); -#endif - } - retries++; - } while (res == -1); - - return res; -} - -static int send_ip_packet_eth(struct eth_nfo *eth, u8 *packet, unsigned int packetlen); -static int send_ip_packet_sd(int sd, u8 *packet, unsigned int packetlen); /* Send a pre-built IPv4 packet. Handles fragmentation and whether to send with an ethernet handle or a socket. */ @@ -1472,95 +570,18 @@ int send_ip_packet(int sd, struct eth_nfo *eth, u8 *packet, assert(packet); assert((int) packetlen > 0); - // fragmentation requested && packet is bigger than MTU - if (o.fragscan && (packetlen - ip->ip_hl * 4 > (unsigned int) o.fragscan)) - return send_frag_ip_packet(sd, eth, packet, packetlen, o.fragscan); - - if (eth) - res = send_ip_packet_eth(eth, packet, packetlen); - else - res = send_ip_packet_sd(sd, packet, packetlen); - + /* Fragmentation requested && packet is bigger than MTU */ + if(o.fragscan && (packetlen - ip->ip_hl * 4 > (unsigned int) o.fragscan)){ + res = send_frag_ip_packet(sd, eth, packet, packetlen, o.fragscan); + }else{ + res = send_ip_packet_eth_or_sd(sd, eth, packet, packetlen); + } PacketTrace::trace(PacketTrace::SENT, packet, packetlen); return res; } -/* Send an IP packet over an ethernet handle. */ -static int send_ip_packet_eth(struct eth_nfo *eth, u8 *packet, unsigned int packetlen) { - eth_t *ethsd; - u8 *eth_frame; - int res; - eth_frame = (u8 *) safe_malloc(14 + packetlen); - memcpy(eth_frame + 14, packet, packetlen); - eth_pack_hdr(eth_frame, eth->dstmac, eth->srcmac, ETH_TYPE_IP); - if (!eth->ethsd) { - ethsd = eth_open_cached(eth->devname); - if (!ethsd) - fatal("%s: Failed to open ethernet device (%s)", __func__, eth->devname); - } else { - ethsd = eth->ethsd; - } - res = eth_send(ethsd, eth_frame, 14 + packetlen); - /* No need to close ethsd due to caching */ - free(eth_frame); - - return res; -} - -/* Send an IP packet over a raw socket. */ -static int send_ip_packet_sd(int sd, u8 *packet, unsigned int packetlen) { - struct sockaddr_in sock; - struct ip *ip = (struct ip *) packet; - struct tcp_hdr *tcp; - struct udp_hdr *udp; - int res; - - assert(sd >= 0); - memset(&sock, 0, sizeof(sock)); - sock.sin_family = AF_INET; -#if HAVE_SOCKADDR_SA_LEN - sock.sin_len = sizeof(sock); -#endif - - /* It is bogus that I need the address and port info when sending a RAW IP - packet, but it doesn't seem to work w/o them */ - if (packetlen >= 20) { - sock.sin_addr.s_addr = ip->ip_dst.s_addr; - if (ip->ip_p == IPPROTO_TCP - && packetlen >= (unsigned int) ip->ip_hl * 4 + 20) { - tcp = (struct tcp_hdr *) ((u8 *) ip + ip->ip_hl * 4); - sock.sin_port = tcp->th_dport; - } else if (ip->ip_p == IPPROTO_UDP - && packetlen >= (unsigned int) ip->ip_hl * 4 + 8) { - udp = (struct udp_hdr *) ((u8 *) ip + ip->ip_hl * 4); - sock.sin_port = udp->uh_dport; - } - } - - /* Equally bogus is that the IP total len and IP fragment offset - fields need to be in host byte order on certain BSD variants. I - must deal with it here rather than when building the packet, - because they should be in NBO when I'm sending over raw - ethernet */ -#if FREEBSD || BSDI || NETBSD || DEC || MACOSX - ip->ip_len = ntohs(ip->ip_len); - ip->ip_off = ntohs(ip->ip_off); -#endif - - res = Sendto("send_ip_packet_sd", sd, packet, packetlen, 0, - (struct sockaddr *) &sock, - (int) sizeof(struct sockaddr_in)); - - /* Undo the byte order switching. */ -#if FREEBSD || BSDI || NETBSD || DEC || MACOSX - ip->ip_len = htons(ip->ip_len); - ip->ip_off = htons(ip->ip_off); -#endif - - return res; -} /* Builds an ICMP packet (including an IP header) by packing the fields with the given information. It allocates a new buffer to store the @@ -1877,7 +898,7 @@ u8 *build_udp_raw(const struct in_addr *source, const struct in_addr *victim, #if STUPID_SOLARIS_CHECKSUM_BUG udp->uh_sum = sizeof(struct udp_hdr) + datalen; #else - udp->uh_sum = magic_tcpudp_cksum(source, victim, IPPROTO_UDP, + udp->uh_sum = tcpudp_cksum(source, victim, IPPROTO_UDP, sizeof(struct udp_hdr) + datalen, (char *) udp); #endif @@ -2043,42 +1064,6 @@ int send_ip_raw(int sd, struct eth_nfo *eth, return res; } -/* returns -1 if we can't use select() on the pcap device, 0 for timeout, and - * >0 for success. If select() fails we bail out because it couldn't work with - * the file descriptor we got from my_pcap_get_selectable_fd() - */ -int pcap_select(pcap_t *p, struct timeval *timeout) { - int fd, ret; - fd_set rfds; - - if ((fd = my_pcap_get_selectable_fd(p)) == -1) - return -1; - - FD_ZERO(&rfds); - FD_SET(fd, &rfds); - - do { - errno = 0; - ret = select(fd + 1, &rfds, NULL, NULL, timeout); - if (ret == -1) { - if (errno == EINTR) - error("%s: %s", __func__, strerror(errno)); - else - fatal("Your system does not support select()ing on pcap devices (%s). PLEASE REPORT THIS ALONG WITH DETAILED SYSTEM INFORMATION TO THE nmap-dev MAILING LIST!", strerror(errno)); - } - } while (ret == -1); - - return ret; -} - -int pcap_select(pcap_t *p, long usecs) { - struct timeval tv; - - tv.tv_sec = usecs / 1000000; - tv.tv_usec = usecs % 1000000; - - return pcap_select(p, &tv); -} /* Used by validatepkt() to validate the TCP header (including option lengths). The options checked are MSS, WScale, SackOK, Sack, and Timestamp. */ @@ -2455,29 +1440,9 @@ char *readip_pcap(pcap_t *pd, unsigned int *len, long to_usec, return alignedbuf; } -// Returns whether the system supports pcap_get_selectable_fd() properly -bool pcap_selectable_fd_valid() { -#if defined(WIN32) || defined(MACOSX) || (defined(FREEBSD) && (__FreeBSD_version < 500000)) - return false; -#else - return true; -#endif -} -/* Call this instead of pcap_get_selectable_fd directly (or your code - won't compile on Windows). On systems which don't seem to support - the pcap_get_selectable_fd() function properly, returns -1, - otherwise simply calls pcap_selectable_fd and returns the - results. If you just want to test whether the function is supported, - use pcap_selectable_fd_valid() instead. */ -int my_pcap_get_selectable_fd(pcap_t *p) { -#if defined(WIN32) || defined(MACOSX) || (defined(FREEBSD) && (__FreeBSD_version < 500000)) - return -1; -#else - assert(pcap_selectable_fd_valid()); - return pcap_get_selectable_fd(p); -#endif -} + + // Returns whether the packet receive time value obtained from libpcap // (and thus by readip_pcap()) should be considered valid. When @@ -2505,197 +1470,7 @@ void pcap_print_stats(int logt, pcap_t *pd) { log_write(logt, "pcap stats: %u packets received by filter, %u dropped by kernel.\n", stat.ps_recv, stat.ps_drop); } -/* A trivial functon that maintains a cache of IP to MAC Address - entries. If the command is ARPCACHE_GET, this func looks for the - IPv4 address in ss and fills in the 'mac' parameter and returns - true if it is found. Otherwise (not found), the function returns - false. If the command is ARPCACHE_SET, the function adds an entry - with the given ip (ss) and mac address. An existing entry for the - IP ss will be overwritten with the new MAC address. true is always - returned for the set command. */ -#define ARPCACHE_GET 1 -#define ARPCACHE_SET 2 -static bool NmapArpCache(int command, struct sockaddr_storage *ss, u8 *mac) { - struct sockaddr_in *sin = (struct sockaddr_in *) ss; - struct ArpCache { - u32 ip; /* Network byte order */ - u8 mac[6]; - }; - static struct ArpCache *Cache = NULL; - static int ArpCapacity = 0; - static int ArpCacheSz = 0; - int i; - if (sin->sin_family != AF_INET) - fatal("%s() can only take IPv4 addresses. Sorry", __func__); - - if (command == ARPCACHE_GET) { - for (i = 0; i < ArpCacheSz; i++) { - if (Cache[i].ip == sin->sin_addr.s_addr) { - memcpy(mac, Cache[i].mac, 6); - return true; - } - } - return false; - } - assert(command == ARPCACHE_SET); - if (ArpCacheSz == ArpCapacity) { - if (ArpCapacity == 0) - ArpCapacity = 32; - else - ArpCapacity <<= 2; - Cache = (struct ArpCache *) safe_realloc(Cache, ArpCapacity * sizeof(struct ArpCache)); - } - - /* Ensure that it isn't already there ... */ - for (i = 0; i < ArpCacheSz; i++) { - if (Cache[i].ip == sin->sin_addr.s_addr) { - memcpy(Cache[i].mac, mac, 6); - return true; - } - } - - /* Add it to the end of the list */ - Cache[i].ip = sin->sin_addr.s_addr; - memcpy(Cache[i].mac, mac, 6); - ArpCacheSz++; - return true; -} - -/* Returns true if the captured frame is ARP. This function understands the - datalink types DLT_EN10MB and DLT_LINUX_SLL. */ -static bool frame_is_arp(const u8 *frame, int datalink) { - if (datalink == DLT_EN10MB) { - return ntohs(*((u16 *) (frame + 12))) == ETH_TYPE_ARP; - } else if (datalink == DLT_LINUX_SLL) { - return ntohs(*((u16 *) (frame + 2))) == ARPHRD_ETHER && /* sll_hatype */ - ntohs(*((u16 *) (frame + 4))) == 6 && /* sll_halen */ - ntohs(*((u16 *) (frame + 14))) == ETH_TYPE_ARP; /* sll_protocol */ - } else { - return false; - } -} - -/* Attempts to read one IPv4/Ethernet ARP reply packet from the pcap - descriptor pd. If it receives one, fills in sendermac (must pass - in 6 bytes), senderIP, and rcvdtime (can be NULL if you don't care) - and returns 1. If it times out and reads no arp requests, returns - 0. to_usec is the timeout period in microseconds. Use 0 to avoid - blocking to the extent possible. Returns - -1 or exits if there is an error. */ -int read_arp_reply_pcap(pcap_t *pd, u8 *sendermac, - struct in_addr *senderIP, long to_usec, - struct timeval *rcvdtime) { - static int warning = 0; - int datalink; - struct pcap_pkthdr head; - u8 *p; - int timedout = 0; - int badcounter = 0; - unsigned int offset; - struct timeval tv_start, tv_end; - - if (!pd) - fatal("NULL packet device passed to %s", __func__); - - if (to_usec < 0) { - if (!warning) { - warning = 1; - error("WARNING: Negative timeout value (%lu) passed to %s() -- using 0", to_usec, __func__); - } - to_usec = 0; - } - - /* New packet capture device, need to recompute offset */ - if ((datalink = pcap_datalink(pd)) < 0) - fatal("Cannot obtain datalink information: %s", pcap_geterr(pd)); - - if (datalink == DLT_EN10MB) { - offset = ETH_HDR_LEN; - } else if (datalink == DLT_LINUX_SLL) { - /* The datalink type is Linux "cooked" sockets. See pcap-linktype(7). */ - offset = 16; - } else { - fatal("%s called on interface that is datatype %d rather than DLT_EN10MB (%d) or DLT_LINUX_SLL (%d)", __func__, datalink, DLT_EN10MB, DLT_LINUX_SLL); - } - - if (to_usec > 0) { - gettimeofday(&tv_start, NULL); - } - - do { -#ifdef WIN32 - if (to_usec == 0) { - PacketSetReadTimeout(pd->adapter, 1); - } else { - gettimeofday(&tv_end, NULL); - long to_left = - MAX(1, (to_usec - TIMEVAL_SUBTRACT(tv_end, tv_start)) / 1000); - // Set the timeout (BUGBUG: this is cheating) - PacketSetReadTimeout(pd->adapter, to_left); - } -#endif - - p = NULL; - - if (pcap_select(pd, to_usec) == 0) - timedout = 1; - else - p = (u8 *) pcap_next(pd, &head); - - if (p && head.caplen >= offset + 28) { - /* hw type eth (0x0001), prot ip (0x0800), - hw size (0x06), prot size (0x04) */ - if (frame_is_arp(p, datalink) && - memcmp(p + offset, "\x00\x01\x08\x00\x06\x04\x00\x02", 8) == 0) { - memcpy(sendermac, p + offset + 8, 6); - /* I think alignment should allow this ... */ - memcpy(&senderIP->s_addr, p + offset + 14, 4); - break; - } - } - - if (!p) { - /* Should we timeout? */ - if (to_usec == 0) { - timedout = 1; - } else if (to_usec > 0) { - gettimeofday(&tv_end, NULL); - if (TIMEVAL_SUBTRACT(tv_end, tv_start) >= to_usec) { - timedout = 1; - } - } - } else { - /* We'll be a bit patient if we're getting actual packets back, but - not indefinitely so */ - if (badcounter++ > 50) - timedout = 1; - } - } while (!timedout); - - if (timedout) - return 0; - - if (rcvdtime) { - // FIXME: I eventually need to figure out why Windows head.ts time is sometimes BEFORE the time I - // sent the packet (which is according to gettimeofday() in nbase). For now, I will sadly have to - // use gettimeofday() for Windows in this case - // Actually I now allow .05 discrepancy. So maybe this isn't needed. I'll comment out for now. - // Nope: it is still needed at least for Windows. Sometimes the time from he pcap header is a - // COUPLE SECONDS before the gettimeofday() results :(. -#if defined(WIN32) || defined(__amigaos__) - gettimeofday(&tv_end, NULL); - *rcvdtime = tv_end; -#else - rcvdtime->tv_sec = head.ts.tv_sec; - rcvdtime->tv_usec = head.ts.tv_usec; - assert(head.ts.tv_sec); -#endif - } - PacketTrace::traceArp(PacketTrace::RCVD, (u8 *) p + offset, ARP_HDR_LEN + ARP_ETHIP_LEN, rcvdtime); - - return 1; -} /* This function tries to determine the target's ethernet MAC address @@ -2737,95 +1512,6 @@ int setTargetMACIfAvailable(Target *target, struct link_header *linkhdr, return 5; } -/* Issues an ARP request for the MAC of targetss (which will be placed - in targetmac if obtained) from the source IP (srcip) and source mac - (srcmac) given. "The request is ussued using device dev to the - broadcast MAC address. The transmission is attempted up to 3 - times. If none of these elicit a response, false will be returned. - If the mac is determined, true is returned. */ -static bool doArp(const char *dev, const u8 *srcmac, - const struct sockaddr_storage *srcip, - const struct sockaddr_storage *targetip, - u8 *targetmac) { - /* timeouts in microseconds ... the first ones are retransmit times, while - the final one is when we give up */ - int timeouts[] = { 100000, 400000, 800000 }; - int max_sends = 3; - int num_sends = 0; // How many we have sent so far - eth_t *ethsd; - u8 frame[ETH_HDR_LEN + ARP_HDR_LEN + ARP_ETHIP_LEN]; - const struct sockaddr_in *targetsin = (struct sockaddr_in *) targetip; - const struct sockaddr_in *srcsin = (struct sockaddr_in *) srcip; - struct timeval start, now, rcvdtime; - int timeleft; - int listenrounds; - int rc; - pcap_t *pd; - struct in_addr rcvdIP; - bool foundit = false; - - if (targetsin->sin_family != AF_INET || srcsin->sin_family != AF_INET) - fatal("%s can only handle IPv4 addresses", __func__); - - /* Start listening */ - pd = my_pcap_open_live(dev, 50, 1, 25); - set_pcap_filter(dev, pd, - "arp and arp[18:4] = 0x%02X%02X%02X%02X and arp[22:2] = 0x%02X%02X", - srcmac[0], srcmac[1], srcmac[2], srcmac[3], srcmac[4], - srcmac[5]); - - /* Prepare probe and sending stuff */ - ethsd = eth_open_cached(dev); - if (!ethsd) - fatal("%s: failed to open device %s", __func__, dev); - eth_pack_hdr(frame, ETH_ADDR_BROADCAST, *srcmac, ETH_TYPE_ARP); - arp_pack_hdr_ethip(frame + ETH_HDR_LEN, ARP_OP_REQUEST, *srcmac, - srcsin->sin_addr, ETH_ADDR_BROADCAST, - targetsin->sin_addr); - gettimeofday(&start, NULL); - gettimeofday(&now, NULL); - - while (!foundit && num_sends < max_sends) { - /* Send the sucker */ - rc = eth_send(ethsd, frame, sizeof(frame)); - if (rc != sizeof(frame)) { - error("WARNING: %s: eth_send of ARP packet returned %u rather than expected %d bytes", __func__, rc, (int) sizeof(frame)); - } - PacketTrace::traceArp(PacketTrace::SENT, (u8 *) frame + ETH_HDR_LEN, - ARP_HDR_LEN + ARP_ETHIP_LEN, &now); - num_sends++; - - listenrounds = 0; - while (!foundit) { - gettimeofday(&now, NULL); - timeleft = timeouts[num_sends - 1] - TIMEVAL_SUBTRACT(now, start); - if (timeleft < 0) { - if (listenrounds > 0) - break; - else - timeleft = 25000; - } - listenrounds++; - /* Now listen until we reach our next timeout or get an answer */ - rc = read_arp_reply_pcap(pd, targetmac, &rcvdIP, timeleft, - &rcvdtime); - if (rc == -1) - fatal("%s: Received -1 response from readarp_reply_pcap", __func__); - if (rc == 1) { - /* Yay, I got one! But is it the right one? */ - if (rcvdIP.s_addr != targetsin->sin_addr.s_addr) - continue; /* D'oh! */ - foundit = true; /* WOOHOO! */ - } - } - } - - /* OK - let's close up shop ... */ - pcap_close(pd); - /* No need to close ethsd due to caching */ - return foundit; -} - /* This function ensures that the next hop MAC address for a target is filled in. This address is the target's own MAC if it is directly @@ -2865,7 +1551,7 @@ bool setTargetNextHopMAC(Target *target) { } /* First, let us check the Nmap arp cache ... */ - if (NmapArpCache(ARPCACHE_GET, &targetss, mac)) { + if (arp_cache_get(&targetss, mac)) { target->setNextHopMACAddress(mac); return true; } @@ -2874,7 +1560,7 @@ bool setTargetNextHopMAC(Target *target) { a = arp_open(); addr_ston((sockaddr *) & targetss, &ae.arp_pa); if (arp_get(a, &ae) == 0) { - NmapArpCache(ARPCACHE_SET, &targetss, ae.arp_ha.addr_eth.data); + arp_cache_set(&targetss, ae.arp_ha.addr_eth.data); target->setNextHopMACAddress(ae.arp_ha.addr_eth.data); arp_close(a); return true; @@ -2885,8 +1571,8 @@ bool setTargetNextHopMAC(Target *target) { retransmissions if necessary) to determine the MAC */ target->SourceSockAddr(&srcss, NULL); if (doArp(target->deviceFullName(), target->SrcMACAddress(), - &srcss, &targetss, mac)) { - NmapArpCache(ARPCACHE_SET, &targetss, mac); + &srcss, &targetss, mac, PacketTrace::traceArp)) { + arp_cache_set(&targetss, mac); target->setNextHopMACAddress(mac); return true; } @@ -2903,14 +1589,14 @@ bool getNextHopMAC(char *iface, u8 *srcmac, struct sockaddr_storage *srcss, struct arp_entry ae; /* Nmap's ARP cache */ - if (NmapArpCache(ARPCACHE_GET, dstss, dstmac)) + if (arp_cache_get(dstss, dstmac)) return true; /* System ARP cache */ a = arp_open(); addr_ston((sockaddr *) dstss, &ae.arp_pa); if (arp_get(a, &ae) == 0) { - NmapArpCache(ARPCACHE_SET, dstss, ae.arp_ha.addr_eth.data); + arp_cache_set(dstss, ae.arp_ha.addr_eth.data); memcpy(dstmac, ae.arp_ha.addr_eth.data, 6); arp_close(a); return true; @@ -2918,390 +1604,20 @@ bool getNextHopMAC(char *iface, u8 *srcmac, struct sockaddr_storage *srcss, arp_close(a); /* Send ARP */ - if (doArp(iface, srcmac, srcss, dstss, dstmac)) { - NmapArpCache(ARPCACHE_SET, dstss, dstmac); + if (doArp(iface, srcmac, srcss, dstss, dstmac, PacketTrace::traceArp)) { + arp_cache_set(dstss, dstmac); return true; } return false; } -/* Set a pcap filter */ -void set_pcap_filter(const char *device, pcap_t *pd, const char *bpf, ...) { - va_list ap; - char buf[3072]; - struct bpf_program fcode; -#ifndef __amigaos__ - unsigned int localnet, netmask; -#else - bpf_u_int32 localnet, netmask; -#endif - char err0r[256]; - // Cast below is becaue OpenBSD apparently has a version that takes a - // non-const device (hopefully they don't actually write to it). - if (pcap_lookupnet((char *) device, &localnet, &netmask, err0r) < 0) - fatal("Failed to lookup subnet/netmask for device (%s): %s", device, err0r); - va_start(ap, bpf); - if (Vsnprintf(buf, sizeof(buf), bpf, ap) >= (int) sizeof(buf)) - fatal("%s called with too-large filter arg\n", __func__); - va_end(ap); - /* Due to apparent bug in libpcap */ - /* Maybe this bug no longer exists ... I'll comment out for now - * if (islocalhost(target->v4hostip())) - * buf[0] = '\0'; */ - if (o.debugging) - log_write(LOG_STDOUT, "Packet capture filter (device %s): %s\n", - device, buf); - if (pcap_compile(pd, &fcode, buf, 0, netmask) < 0) - fatal("Error compiling our pcap filter: %s", pcap_geterr(pd)); - if (pcap_setfilter(pd, &fcode) < 0) - fatal("Failed to set the pcap filter: %s\n", pcap_geterr(pd)); - pcap_freecode(&fcode); -} -/* The 'dev' passed in must be at least 32 bytes long. Returns 0 on success. */ -int ipaddr2devname(char *dev, const struct in_addr *addr) { - struct interface_info *ifaces; - struct sockaddr_in *sin; - int numifaces; - int i; - - ifaces = getinterfaces(&numifaces); - - if (ifaces == NULL) - return -1; - - for (i = 0; i < numifaces; i++) { - sin = (struct sockaddr_in *) &ifaces[i].addr; - if (sin->sin_family != AF_INET) - continue; - if (addr->s_addr == sin->sin_addr.s_addr) { - Strncpy(dev, ifaces[i].devname, 32); - return 0; - } - } - - return -1; -} - -int devname2ipaddr(char *dev, struct in_addr *addr) { - struct interface_info *mydevs; - struct sockaddr_in *s; - int numdevs; - int i; - mydevs = getinterfaces(&numdevs); - - if (!mydevs) - return -1; - - for (i = 0; i < numdevs; i++) { - s = (struct sockaddr_in *) &mydevs[i].addr; - if (s->sin_family != AF_INET) /* Currently we only support IPv4 */ - continue; - if (!strcmp(dev, mydevs[i].devfullname)) { - memcpy(addr, (char *) &s->sin_addr, sizeof(struct in_addr)); - return 0; - } - } - return -1; -} - -/* This struct is abused to carry either routes or interfaces, depending on the - function it's used in. */ -struct dnet_collector_route_nfo { - struct sys_route *routes; - int numroutes; - int capacity; /* Capacity of routes or ifaces, depending on context */ - struct interface_info *ifaces; - int numifaces; -}; - -#if WIN32 -static int collect_dnet_interfaces(const struct intf_entry *entry, void *arg) { - struct dnet_collector_route_nfo *dcrn = (struct dnet_collector_route_nfo *) arg; - bool primary_done; - int num_aliases_done; - - primary_done = false; - num_aliases_done = 0; - while (!primary_done || num_aliases_done < entry->intf_alias_num) { - /* Make sure we have room for the new route */ - if (dcrn->numifaces >= dcrn->capacity) { - dcrn->capacity <<= 2; - dcrn->ifaces = (struct interface_info *) safe_realloc(dcrn->ifaces, - dcrn->capacity * sizeof(struct interface_info)); - } - - /* The first time through the loop we add the primary interface record. - After that we add the aliases one at a time. */ - if (!primary_done) { - if (entry->intf_addr.addr_type == ADDR_TYPE_IP) { - addr_ntos(&entry->intf_addr, (struct sockaddr *) &dcrn->ifaces[dcrn->numifaces].addr); - dcrn->ifaces[dcrn->numifaces].netmask_bits = entry->intf_addr.addr_bits; - } - primary_done = true; - } else if (num_aliases_done < (int) entry->intf_alias_num) { - if (entry->intf_alias_addrs[num_aliases_done].addr_type == ADDR_TYPE_IP) { - addr_ntos(&entry->intf_alias_addrs[num_aliases_done], (struct sockaddr *) &dcrn->ifaces[dcrn->numifaces].addr); - dcrn->ifaces[dcrn->numifaces].netmask_bits = entry->intf_alias_addrs[num_aliases_done].addr_bits; - } - num_aliases_done++; - } - - /* OK, address/netmask found. Let's get the name */ - Strncpy(dcrn->ifaces[dcrn->numifaces].devname, entry->intf_name, - sizeof(dcrn->ifaces[dcrn->numifaces].devname)); - Strncpy(dcrn->ifaces[dcrn->numifaces].devfullname, entry->intf_name, - sizeof(dcrn->ifaces[dcrn->numifaces].devfullname)); - - /* Interface type */ - if (entry->intf_type == INTF_TYPE_ETH) { - dcrn->ifaces[dcrn->numifaces].device_type = devt_ethernet; - /* Collect the MAC address since this is ethernet */ - memcpy(dcrn->ifaces[dcrn->numifaces].mac, &entry->intf_link_addr.addr_eth.data, 6); - } else if (entry->intf_type == INTF_TYPE_LOOPBACK) { - dcrn->ifaces[dcrn->numifaces].device_type = devt_loopback; - } else if (entry->intf_type == INTF_TYPE_TUN) { - dcrn->ifaces[dcrn->numifaces].device_type = devt_p2p; - } else { - dcrn->ifaces[dcrn->numifaces].device_type = devt_other; - } - - /* Is the interface up and running? */ - dcrn->ifaces[dcrn->numifaces].device_up = (entry->intf_flags & INTF_FLAG_UP) ? true : false; - - /* For the rest of the information, we must open the interface directly ... */ - dcrn->numifaces++; - } - - return 0; -} - -/* Get a list of interfaces using dnet and intf_loop. */ -static struct interface_info *getinterfaces_dnet(int *howmany) { - struct dnet_collector_route_nfo dcrn; - intf_t *it; - - dcrn.routes = NULL; - dcrn.numroutes = 0; - dcrn.numifaces = 0; - - /* Initialize the interface array. */ - dcrn.capacity = 16; - dcrn.ifaces = (struct interface_info *) safe_zalloc(sizeof(struct interface_info) * dcrn.capacity); - - it = intf_open(); - if (!it) - fatal("%s: intf_open() failed", __func__); - if (intf_loop(it, collect_dnet_interfaces, &dcrn) != 0) - fatal("%s: intf_loop() failed", __func__); - intf_close(it); - - *howmany = dcrn.numifaces; - return dcrn.ifaces; -} - -#else /* !WIN32 */ - -/* Get a list of interfaces using ioctl(SIOCGIFCONF). */ -static struct interface_info *getinterfaces_siocgifconf(int *howmany) { - struct interface_info *devs; - int count = 0; - int capacity = 0; - struct ifconf ifc; - struct ifreq *ifr; - int sd; - int len; - - capacity = 16; - devs = (struct interface_info *) safe_zalloc(sizeof(struct interface_info) * capacity); - - /* Dummy socket for ioctl */ - sd = socket(AF_INET, SOCK_DGRAM, 0); - if (sd < 0) - pfatal("socket in %s", __func__); - - ifc.ifc_len = 20480; - ifc.ifc_buf = (char *) safe_zalloc(ifc.ifc_len); - /* Returns an array of struct ifreq in ifc.ifc_req, which is a union with - ifc.ifc_buf. */ - if (ioctl(sd, SIOCGIFCONF, &ifc) < 0) - fatal("Failed to determine your configured interfaces!\n"); - if (ifc.ifc_len == 0) - fatal("%s: SIOCGIFCONF claims you have no network interfaces!\n", __func__); - ifr = ifc.ifc_req; - - for (ifr = ifc.ifc_req; - ifr && ifr->ifr_name[0] && (void *) ifr < (char *) ifc.ifc_buf + ifc.ifc_len; - ifr = (struct ifreq *) ((char *) ifr + len)) { - struct sockaddr_in *sin; - struct ifreq tmpifr; - u16 ifflags; - int rc; - char *p; - - len = sizeof(struct ifreq); -#if HAVE_SOCKADDR_SA_LEN - /* Some platforms (such as FreeBSD) have an sa_len member that may make the - ifr longer than sizeof(struct ifreq). */ - if (ifr->ifr_addr.sa_len > sizeof(ifr->ifr_ifru)) - len += ifr->ifr_addr.sa_len - sizeof(ifr->ifr_ifru); -#endif - - /* skip any device with no name */ - if (ifr->ifr_name[0] == '\0') - continue; - - /* We currently only handle IPv4 */ - sin = (struct sockaddr_in *) &ifr->ifr_addr; - if (sin->sin_family != AF_INET) - continue; - - /* Make room for this new interface if necessary. */ - if (count >= capacity) { - capacity <<= 2; - devs = (struct interface_info *) safe_realloc(devs, sizeof(struct interface_info) * capacity); - } - - /* We know the address, put it in the array. */ - memcpy(&(devs[count].addr), sin, MIN(sizeof(devs[count].addr), sizeof(*sin))); - Strncpy(devs[count].devname, ifr->ifr_name, sizeof(devs[count].devname)); - Strncpy(devs[count].devfullname, ifr->ifr_name, sizeof(devs[count].devfullname)); - /* devname isn't allowed to have alias qualification */ - p = strchr(devs[count].devname, ':'); - if (p != NULL) - *p = '\0'; - - /* Use tmpifr for further ioctl requests. We're going to make a bunch of - ioctl calls to learn about the interface and set fields in devs[count]. - - The Linux netdevice(7) man page says that you only have to set ifr_name - before making the ioctl, but perhaps other platforms need ifr_addr to be - set too. ifr_name will persist but ifr_addr is in a union with the ioctl - return value, so it has to be reset before every call. The general - pattern is memcpy, then ioctl. */ - Strncpy(tmpifr.ifr_name, ifr->ifr_name, sizeof(tmpifr.ifr_name)); - - /* Look up the netmask. Note setting of ifr_addr. */ - memcpy(&tmpifr.ifr_addr, sin, MIN(sizeof(tmpifr.ifr_addr), sizeof(*sin))); - rc = ioctl(sd, SIOCGIFNETMASK, &tmpifr); - if (rc < 0 && errno != EADDRNOTAVAIL) - pfatal("Failed to determine the netmask of %s!", tmpifr.ifr_name); - else if (rc < 0) - devs[count].netmask_bits = 32; - else { - /* We would use ifr_netmask, but that's only on Linux, so use ifr_addr - which shares the same memory space in a union. */ - addr_stob(&(tmpifr.ifr_addr), &devs[count].netmask_bits); - } - - /* Now we need to determine the device type ... this technique is kinda iffy - ... may not be portable. */ - /* Get the flags. */ - memcpy(&tmpifr.ifr_addr, sin, MIN(sizeof(tmpifr.ifr_addr), sizeof(*sin))); - rc = ioctl(sd, SIOCGIFFLAGS, &tmpifr); - if (rc < 0) - pfatal("Failed to get IF Flags for device %s", ifr->ifr_name); - - ifflags = tmpifr.ifr_flags; - - if (ifflags & IFF_LOOPBACK) { - devs[count].device_type = devt_loopback; - } else if (ifflags & IFF_BROADCAST) { - devs[count].device_type = devt_ethernet; - - /* If the device type is ethernet, get the MAC address. */ -#ifdef SIOCGIFHWADDR - memcpy(&tmpifr.ifr_addr, sin, MIN(sizeof(tmpifr.ifr_addr), sizeof(*sin))); - rc = ioctl(sd, SIOCGIFHWADDR, &tmpifr); - if (rc < 0 && errno != EADDRNOTAVAIL) - pfatal("Failed to determine the MAC address of %s!", tmpifr.ifr_name); - else if (rc >= 0) - memcpy(devs[count].mac, &tmpifr.ifr_addr.sa_data, 6); -#else - /* Let's just let libdnet handle it ... */ - eth_t *ethsd = eth_open_cached(devs[count].devname); - eth_addr_t ethaddr; - - if (!ethsd) { - error("Warning: Unable to open interface %s -- skipping it.", devs[count].devname); - continue; - } - if (eth_get(ethsd, ðaddr) != 0) { - error("Warning: Unable to get hardware address for interface %s -- skipping it.", devs[count].devname); - continue; - } - memcpy(devs[count].mac, ethaddr.data, 6); -#endif /*SIOCGIFHWADDR*/ - } else if (ifflags & IFF_POINTOPOINT) { - devs[count].device_type = devt_p2p; - } else { - devs[count].device_type = devt_other; - } - - if (ifflags & IFF_UP) - devs[count].device_up = true; - else - devs[count].device_up = false; - - /* All done with this interface. Increase the count. */ - count++; - } - free(ifc.ifc_buf); - close(sd); - - *howmany = count; - return devs; -} -#endif - -/* Returns an allocated array of struct interface_info representing the - available interfaces. The number of interfaces is returned in *howmany. This - function just does caching of results; the real work is done in - getinterfaces_dnet or getinterfaces_siocgifconf. */ -struct interface_info *getinterfaces(int *howmany) { - static bool initialized = 0; - static struct interface_info *mydevs; - static int numifaces = 0; - - if (!initialized) { -#if WIN32 - /* On Win32 we just use Dnet to determine the interface list */ - mydevs = getinterfaces_dnet(&numifaces); -#else - mydevs = getinterfaces_siocgifconf(&numifaces); -#endif - initialized = 1; - } - - if (howmany) - *howmany = numifaces; - return mydevs; -} - -/* Looks for an interface with the given name (iname), and returns the - corresponding interface_info if found. Will accept a match of - devname or devfullname. Returns NULL if none found */ -struct interface_info *getInterfaceByName(char *iname) { - struct interface_info *ifaces; - int numifaces = 0; - int ifnum; - - ifaces = getinterfaces(&numifaces); - - for (ifnum = 0; ifnum < numifaces; ifnum++) { - if (strcmp(ifaces[ifnum].devfullname, iname) == 0 || - strcmp(ifaces[ifnum].devname, iname) == 0) - return &ifaces[ifnum]; - } - - return NULL; -} pcap_if_t *getpcapinterfaces() { #ifndef WIN32 @@ -3317,452 +1633,17 @@ pcap_if_t *getpcapinterfaces() { } -/* A trivial function used with qsort to sort the routes by netmask */ -static int nmaskcmp(const void *a, const void *b) { - struct sys_route *r1 = (struct sys_route *) a; - struct sys_route *r2 = (struct sys_route *) b; - if (r1->netmask == r2->netmask) { - /* Compare addresses of equal elements to make the sort stable, as suggested - by the Glibc manual. */ - if (a < b) - return -1; - else if (a > b) - return 1; - else - return 0; - } - if (ntohl(r1->netmask) > ntohl(r2->netmask)) - return -1; - else - return 1; -} -/* Read system routes from a handle to a /proc/net/route file. */ -static struct sys_route *getsysroutes_proc(FILE *routefp, int *howmany) { - struct sys_route *routes = NULL; - int route_capacity = 128; - struct interface_info *ifaces; - char buf[1024]; - char iface[16]; - char *p, *endptr; - struct interface_info *ii; - u32 mask; - struct sockaddr_in *sin; - int numifaces = 0, numroutes = 0; - int i; - ifaces = getinterfaces(&numifaces); - routes = (struct sys_route *) safe_zalloc(route_capacity * sizeof(struct sys_route)); - - /* Kill the first line (column headers) */ - errno = 0; - if (fgets(buf, sizeof(buf), routefp) == NULL) { - if (errno) - error("Read error in /proc/net/route"); - else - error("Premature EOF in /proc/net/route"); - goto done; - } - while (fgets(buf, sizeof(buf), routefp)) { - p = strtok(buf, " \t\n"); - if (!p) { - error("Could not find interface in /proc/net/route line"); - continue; +int nmap_route_dst(const struct sockaddr_storage * const dst, struct route_nfo *rnfo){ + struct sockaddr_storage spoofss; + size_t spoofsslen; + if(o.spoofsource){ + o.SourceSockAddr(&spoofss, &spoofsslen); + return route_dst(dst, rnfo, o.device, &spoofss); + }else{ + return route_dst(dst, rnfo, o.device, NULL); } - if (*p == '*') - continue; /* Deleted route -- any other valid reason for a route to start with an asterict? */ - Strncpy(iface, p, sizeof(iface)); - p = strtok(NULL, " \t\n"); - if (!p) { - error("Could not find destination in /proc/net/route line"); - continue; - } - endptr = NULL; - routes[numroutes].dest = strtoul(p, &endptr, 16); - if (!endptr || *endptr) { - error("Failed to determine Destination from /proc/net/route"); - continue; - } - - /* Now for the gateway */ - p = strtok(NULL, " \t\n"); - if (!p) { - error("Could not find gateway in /proc/net/route line"); - continue; - } - endptr = NULL; - routes[numroutes].gw.s_addr = strtoul(p, &endptr, 16); - if (!endptr || *endptr) { - error("Failed to determine gw for %s from /proc/net/route", iface); - } - for (i = 0; i < 5; i++) { - p = strtok(NULL, " \t\n"); - if (!p) - break; - } - if (!p) { - error("Failed to find field %d in /proc/net/route", i + 2); - continue; - } - endptr = NULL; - routes[numroutes].netmask = strtoul(p, &endptr, 16); - if (!endptr || *endptr) { - error("Failed to determine mask from /proc/net/route"); - continue; - } - for (i = 0; i < numifaces; i++) { - if (!strcmp(iface, ifaces[i].devfullname)) { - routes[numroutes].device = &ifaces[i]; - break; - } - } - /* If device name in the route file does not match the full name (including - alias extension) of any interface, then try to find at least an alias of - the proper interface. */ - if (i == numifaces) { - for (i = 0; i < numifaces; i++) { - if (!strcmp(iface, ifaces[i].devname)) { - routes[numroutes].device = &ifaces[i]; - break; - } - } - } - if (i == numifaces) { - error("Failed to find device %s which was referenced in /proc/net/route", iface); - continue; - } - - /* Now to deal with some alias nonsense ... at least on Linux - this file will just list the short name, even though IP - information (such as source address) from an alias must be - used. So if the purported device can't reach the gateway, - try to find a device that starts with the same short - devname, but can (e.g. eth0 -> eth0:3) */ - ii = &ifaces[i]; - mask = htonl((unsigned long) (0 - 1) << (32 - ii->netmask_bits)); - sin = (struct sockaddr_in *) &ii->addr; - if (routes[numroutes].gw.s_addr && (sin->sin_addr.s_addr & mask) != - (routes[numroutes].gw.s_addr & mask)) { - for (i = 0; i < numifaces; i++) { - if (ii == &ifaces[i]) - continue; - if (strcmp(ii->devname, ifaces[i].devname) == 0) { - sin = (struct sockaddr_in *) &ifaces[i].addr; - if ((sin->sin_addr.s_addr & mask) == - (routes[numroutes].gw.s_addr & mask)) { - routes[numroutes].device = &ifaces[i]; - } - } - } - } - - numroutes++; - if (numroutes >= route_capacity) { - route_capacity <<= 2; - routes = (struct sys_route *) safe_realloc(routes, route_capacity * sizeof(struct sys_route)); - } - } - -done: - *howmany = numroutes; - return routes; -} - -/* This is the callback for the call to route_loop in getsysroutes_dnet. It - takes a route entry and adds it into the dnet_collector_route_nfo struct. */ -static int collect_dnet_routes(const struct route_entry *entry, void *arg) { - struct dnet_collector_route_nfo *dcrn = (struct dnet_collector_route_nfo *) arg; - /* Make sure that it is the proper type of route ... */ - if (entry->route_dst.addr_type != ADDR_TYPE_IP || entry->route_gw.addr_type != ADDR_TYPE_IP) - return 0; /* Not interested in IPv6 routes at the moment ... */ - - /* Make sure we have room for the new route */ - if (dcrn->numroutes >= dcrn->capacity) { - dcrn->capacity <<= 2; - dcrn->routes = (struct sys_route *) safe_realloc(dcrn->routes, dcrn->capacity * sizeof(struct sys_route)); - } - - /* Now for the important business */ - dcrn->routes[dcrn->numroutes].dest = entry->route_dst.addr_ip; - addr_btom(entry->route_dst.addr_bits, - &dcrn->routes[dcrn->numroutes].netmask, - sizeof(dcrn->routes[dcrn->numroutes].netmask)); - dcrn->routes[dcrn->numroutes].gw.s_addr = entry->route_gw.addr_ip; - dcrn->numroutes++; - - return 0; -} - -/* This is a helper for getsysroutes_dnet. Once the table of routes is in - place, this function assigns each to an interface and removes any routes - that can't be assigned. */ -static struct dnet_collector_route_nfo *sysroutes_dnet_find_interfaces(struct dnet_collector_route_nfo *dcrn) -{ - struct interface_info *ifaces; - u32 mask; - struct sockaddr_in *sin; - int numifaces = 0; - int i, j; - - ifaces = getinterfaces(&numifaces); - for (i = 0; i < dcrn->numroutes; i++) { - /* First we match up routes whose gateway address directly matches the - address of an interface. */ - for (j = 0; j < numifaces; j++) { - sin = (struct sockaddr_in *) &ifaces[j].addr; - mask = - htonl((unsigned long) (0 - 1) << (32 - ifaces[j].netmask_bits)); - if ((sin->sin_addr.s_addr & mask) == - (dcrn->routes[i].gw.s_addr & mask)) { - dcrn->routes[i].device = &ifaces[j]; - break; - } - } - } - - /* Find any remaining routes that don't yet have an interface, and try to - match them up with the interface of another route. This handles "two-step" - routes like sometimes exist with PPP, where the gateway address of the - default route doesn't match an interface address, but the gateway address - goes through another route that does have an interface. */ - bool changed; - do { - changed = false; - for (i = 0; i < dcrn->numroutes; i++) { - if (dcrn->routes[i].device != NULL) - continue; - /* Does this route's gateway go through another route with an assigned - interface? */ - for (j = 0; j < dcrn->numroutes; j++) { - if (dcrn->routes[i].gw.s_addr == dcrn->routes[j].dest - && dcrn->routes[j].device != NULL) { - dcrn->routes[i].device = dcrn->routes[j].device; - changed = true; - } - } - } - } while (changed); - - /* Cull any routes that still don't have an interface. */ - i = 0; - while (i < dcrn->numroutes) { - if (dcrn->routes[i].device == NULL) { - error("WARNING: Unable to find appropriate interface for system route to %s", inet_ntoa(dcrn->routes[i].gw)); - /* Remove this entry from the table. */ - memmove(dcrn->routes + i, dcrn->routes + i + 1, sizeof(dcrn->routes[0]) * (dcrn->numroutes - i - 1)); - dcrn->numroutes--; - } else { - i++; - } - } - - return dcrn; -} - -/* Read system routes via libdnet. */ -static struct sys_route *getsysroutes_dnet(int *howmany) { - struct dnet_collector_route_nfo dcrn; - - dcrn.capacity = 128; - dcrn.routes = (struct sys_route *) safe_zalloc(dcrn.capacity * sizeof(struct sys_route)); - dcrn.numroutes = 0; - dcrn.ifaces = NULL; - dcrn.numifaces = 0; - route_t *dr = route_open(); - if (!dr) - fatal("%s: route_open() failed", __func__); - if (route_loop(dr, collect_dnet_routes, &dcrn) != 0) { - fatal("%s: route_loop() failed", __func__); - } - route_close(dr); - - /* Now match up the routes to interfaces. */ - sysroutes_dnet_find_interfaces(&dcrn); - - *howmany = dcrn.numroutes; - return dcrn.routes; -} - -/* Parse the system routing table, converting each route into a - sys_route entry. Returns an array of sys_routes. numroutes is set - to the number of routes in the array. The routing table is only - read the first time this is called -- later results are cached. - The returned route array is sorted by netmask with the most - specific matches first. */ -struct sys_route *getsysroutes(int *howmany) { - static struct sys_route *routes = NULL; - static int numroutes = 0; - FILE *routefp; - - if (!howmany) - fatal("NULL howmany ptr passed to %s()", __func__); - - if (routes != NULL) { - /* We have it cached. */ - *howmany = numroutes; - return routes; - } - - /* First let us try Linux-style /proc/net/route */ - routefp = fopen("/proc/net/route", "r"); - if (routefp) { - routes = getsysroutes_proc(routefp, howmany); - fclose(routefp); - } else { - routes = getsysroutes_dnet(howmany); - } - - numroutes = *howmany; - - /* Ensure that the route array is sorted by netmask */ - qsort(routes, numroutes, sizeof(routes[0]), nmaskcmp); - - return routes; -} - -static bool match_netmask(u32 addr1, u32 addr2, u32 mask) { - return (addr1 & mask) == (addr2 & mask); -} - -static bool match_netmask_bits(u32 addr1, u32 addr2, int bits) { - return match_netmask(addr1, addr2, htonl((unsigned long) (0 - 1) << (32 - bits))); -} - -static bool match_netmask_bits(const struct sockaddr_in *addr1, - const struct sockaddr_in *addr2, int bits) { - return match_netmask_bits(addr1->sin_addr.s_addr, addr2->sin_addr.s_addr, bits); -} - -static struct interface_info *find_loopback_iface(struct interface_info *ifaces, - int numifaces) { - int i; - - for (i = 0; i < numifaces; i++) { - if (ifaces[i].device_type == devt_loopback) - return &ifaces[i]; - } - - return NULL; -} - -/* Takes a destination address (dst) and tries to determine the - source address and interface necessary to route to this address. - If no route is found, false is returned and rnfo is undefined. If - a route is found, true is returned and rnfo is filled in with all - of the routing details. This function takes into account -S and -e - options set by user (o.spoofsource, o.device) */ -bool route_dst(const struct sockaddr_storage * const dst, - struct route_nfo *rnfo) { - struct interface_info *ifaces; - struct interface_info *iface; - int numifaces = 0; - struct sys_route *routes; - struct sockaddr_storage spoofss; - size_t spoofsslen; - int numroutes = 0; - int i; - struct sockaddr_in *ifsin, *dstsin; - - if (!dst) - fatal("%s passed a NULL dst address", __func__); - dstsin = (struct sockaddr_in *) dst; - - if (dstsin->sin_family != AF_INET) - fatal("Sorry -- %s currently only supports IPv4", __func__); - - if (o.spoofsource) { - o.SourceSockAddr(&spoofss, &spoofsslen); - //throughout the rest of this function we only change rnfo->srcaddr if the source isnt spoofed - memcpy(&rnfo->srcaddr, &spoofss, sizeof(rnfo->srcaddr)); - /* The device corresponding to this spoofed address should already have been - set elsewhere. */ - assert(o.device[0] != '\0'); - } - - if (*o.device) { - iface = getInterfaceByName(o.device); - if (!iface) - fatal("Could not find interface %s which was specified by -e", o.device); - } else { - iface = NULL; - } - - routes = getsysroutes(&numroutes); - ifaces = getinterfaces(&numifaces); - - /* First check if dst is one of the localhost's own addresses. We need to use - a localhost device for these. */ - for (i = 0; i < numifaces; i++) { - struct interface_info *loopback; - - ifsin = (struct sockaddr_in *) &ifaces[i].addr; - if (dstsin->sin_addr.s_addr != ifsin->sin_addr.s_addr) - continue; - if (iface != NULL && strcmp(ifaces[i].devname, iface->devname) != 0) - continue; - - if (ifaces[i].device_type == devt_loopback) - loopback = &ifaces[i]; - else - loopback = find_loopback_iface(ifaces, numifaces); - if (loopback == NULL) - /* Hmmm ... no localhost -- move on to the routing table. */ - break; - - rnfo->ii = *loopback; - rnfo->direct_connect = true; - /* But the source address we want to use is the target address. */ - if (!o.spoofsource) - rnfo->srcaddr = ifaces[i].addr; - - return true; - } - - /* Go through the routing table and take the first match. getsysroutes sorts - so more-specific routes come first. */ - for (i = 0; i < numroutes; i++) { - if (!match_netmask(dstsin->sin_addr.s_addr, routes[i].dest, routes[i].netmask)) - continue; - /* Ignore routes that aren't on the device we specified. */ - if (iface != NULL && strcmp(routes[i].device->devname, iface->devname) != 0) - continue; - - rnfo->ii = *routes[i].device; - /* At this point we don't whether this route is direct or indirect ("G" flag - in netstat). We guess that a route is direct when the gateway address is - 0.0.0.0, when it exactly matches the interface address, or when it - exactly matches the destination address. */ - rnfo->direct_connect = (routes[i].gw.s_addr == 0) || - (routes[i].gw.s_addr == ((struct sockaddr_in *) &routes[i].device->addr)->sin_addr.s_addr) || - (routes[i].gw.s_addr == dstsin->sin_addr.s_addr); - if (!o.spoofsource) - rnfo->srcaddr = routes[i].device->addr; - ifsin = (struct sockaddr_in *) &rnfo->nexthop; - ifsin->sin_family = AF_INET; - ifsin->sin_addr = routes[i].gw; - - return true; - } - - /* No match on routes. Try interfaces directly. */ - for (i = 0; i < numifaces; i++) { - if (ifaces[i].addr.ss_family != AF_INET) - continue; - ifsin = (struct sockaddr_in *) &ifaces[i].addr; - if (!match_netmask_bits(dstsin, ifsin, ifaces[i].netmask_bits)) - continue; - if (iface != NULL && strcmp(ifaces[i].devname, iface->devname) != 0) - continue; - - rnfo->ii = ifaces[i]; - rnfo->direct_connect = true; - if (!o.spoofsource) - rnfo->srcaddr = ifaces[i].addr; - - return true; - } - - return false; } diff --git a/tcpip.h b/tcpip.h index d3037b4ca..743af706f 100644 --- a/tcpip.h +++ b/tcpip.h @@ -212,7 +212,7 @@ extern "C" { #include #endif -typedef enum { devt_ethernet, devt_loopback, devt_p2p, devt_other } devtype; + #include "nmap.h" #include "global_structures.h" @@ -224,11 +224,12 @@ typedef enum { devt_ethernet, devt_loopback, devt_p2p, devt_other } devtype; /* Used for tracing all packets sent or received (eg the --packet-trace option) */ + class PacketTrace { public: - /* static const int SEND=1; - static const int RCV=2; */ - enum pdirection { SENT=1, RCVD=2 }; + static const int SENT=1; /* These two values must not be changed */ + static const int RCVD=2; + typedef int pdirection; /* Takes an IP PACKET and prints it if packet tracing is enabled. 'packet' must point to the IPv4 header. The direction must be PacketTrace::SENT or PacketTrace::RCVD . Optional 'now' argument @@ -265,54 +266,6 @@ class PacketCounter { sendPackets, sendBytes, recvPackets, recvBytes; }; -#define MAX_LINK_HEADERSZ 24 -struct link_header { - int datalinktype; /* pcap_datalink(), such as DLT_EN10MB */ - int headerlen; /* 0 if header was too big or unavailaable */ - u8 header[MAX_LINK_HEADERSZ]; -}; - -/* Relevant (to Nmap) information about an interface */ -struct interface_info { - char devname[16]; - char devfullname[16]; /* can include alias info, such as eth0:2. */ - struct sockaddr_storage addr; - u16 netmask_bits; /* CIDR-style. So 24 means class C (255.255.255.0)*/ - devtype device_type; /* devt_ethernet, devt_loopback, devt_p2p, devt_other */ - bool device_up; /* True if the device is up (enabled) */ - u8 mac[6]; /* Interface MAC address if device_type is devt_ethernet */ -}; - -struct route_nfo { - struct interface_info ii; - -/* true if the target is directly connected on the network (no routing - required). */ - bool direct_connect; - -/* This is the source address that should be used by the packets. It - may be different than ii.addr if you are using localhost interface - to scan the IP of another interface on the machine */ - struct sockaddr_storage srcaddr; - - /* If direct_connect is 0, this is filled in with the next hop - required to route to the target */ - struct sockaddr_storage nexthop; -}; - -struct sys_route { - struct interface_info *device; - u32 dest; - u32 netmask; - struct in_addr gw; /* gateway - 0 if none */ -}; - -struct eth_nfo { - char srcmac[6]; - char dstmac[6]; - eth_t *ethsd; // Optional, but improves performance. Set to NULL if unavail - char devname[16]; // Only needed if ethsd is NULL. -}; #ifndef HAVE_STRUCT_IP #define HAVE_STRUCT_IP @@ -435,23 +388,12 @@ struct icmp not thread-safe and can only be used once in calls like printf() */ const char *inet_socktop(struct sockaddr_storage *ss); + /* Tries to resolve the given name (or literal IP) into a sockaddr structure. This function calls getaddrinfo and returns the same addrinfo linked list that getaddrinfo produces. Returns NULL for any error or failure to resolve. */ struct addrinfo *resolve_all(char *hostname, int pf); -/* Tries to resolve the given name (or literal IP) into a sockaddr - structure. The af should be PF_INET (for IPv4) or PF_INET6. Returns 0 - if hostname cannot be resolved. It is OK to pass in a sockaddr_in or - sockaddr_in6 casted to a sockaddr_storage as long as you use the matching - pf.*/ -int resolve(char *hostname, struct sockaddr_storage *ss, size_t *sslen, - int pf); -/* LEGACY resolve() function that only supports IPv4 -- see IPv6 version - above. Tries to resolve given hostname and stores - result in ip . returns 0 if hostname cannot - be resolved */ -int resolve(char *hostname, struct in_addr *ip); /* Takes a destination address (dst) and tries to determine the source address and interface necessary to route to this address. @@ -459,7 +401,7 @@ int resolve(char *hostname, struct in_addr *ip); a route is found, true is returned and rnfo is filled in with all of the routing details. This function takes into account -S and -e options set by user (o.spoofsource, o.device) */ -bool route_dst(const struct sockaddr_storage *const dst, struct route_nfo *rnfo); +int nmap_route_dst(const struct sockaddr_storage * const dst, struct route_nfo *rnfo); /* Determines what interface packets destined to 'dest' should be routed through. It can also discover the appropriate next hop (if @@ -475,9 +417,6 @@ bool routethrough(const struct sockaddr_storage * const dest, unsigned short in_cksum(u16 *ptr,int nbytes); -unsigned short magic_tcpudp_cksum(const struct in_addr *src, - const struct in_addr *dst, - u8 proto, u16 len, const void *hstart); /* Build and send a raw tcp packet. If TTL is -1, a partially random (but likely large enough) one is chosen */ @@ -606,22 +545,6 @@ int send_udp_raw_decoys( int sd, struct eth_nfo *eth, char *data, u16 datalen); -/* Calls pcap_open_live and spits out an error (and quits) if the call fails. - So a valid pcap_t will always be returned. */ -pcap_t *my_pcap_open_live(const char *device, int snaplen, int promisc, - int to_ms); - -// Returns whether the system supports pcap_get_selectable_fd() properly -bool pcap_selectable_fd_valid(); - -/* Call this instead of pcap_get_selectable_fd directly (or your code - won't compile on Windows). On systems which don't seem to support - the pcap_get_selectable_fd() function properly, returns -1, - otherwise simply calls pcap_selectable_fd and returns the - results. If you just want to test whether the function is supported, - use pcap_selectable_fd_valid() instead. */ -int my_pcap_get_selectable_fd(pcap_t *p); - // Returns whether the packet receive time value obtaned from libpcap // (and thus by readip_pcap()) should be considered valid. When // invalid (Windows and Amiga), readip_pcap returns the time you called it. @@ -631,51 +554,20 @@ bool pcap_recv_timeval_valid(); packets). */ void pcap_print_stats(int logt, pcap_t *pd); -/* A simple function that caches the eth_t from dnet for one device, - to avoid opening, closing, and re-opening it thousands of tims. If - you give a different device, this function will close the first - one. Thus this should never be used by programs that need to deal - with multiple devices at once. In addition, you MUST NEVER - eth_close() A DEVICE OBTAINED FROM THIS FUNCTION. Instead, you can - call eth_close_cached() to close whichever device (if any) is - cached. Returns NULL if it fails to open the device. */ -eth_t *eth_open_cached(const char *device); -/* See the description for eth_open_cached */ -void eth_close_cached(); /* A simple function I wrote to help in debugging, shows the important fields of a TCP packet*/ int readtcppacket(const u8 *packet, int readdata); int readudppacket(const u8 *packet, int readdata); -/* Convert an IP address to the device (IE ppp0 eth0) using that address. Dev passed in must be at least - 32 bytes long */ -int ipaddr2devname( char *dev, const struct in_addr *addr ); -/* And vice versa */ -int devname2ipaddr(char *dev, struct in_addr *addr); + /* Looks for an interface assigned to the given IP (ss), and returns the interface_info for the first one found. If non found, returns NULL */ struct interface_info *getInterfaceByIP(struct sockaddr_storage *ss); -/* Looks for an interface with the given name (iname), and returns the - corresponding interface_info if found. Will accept a match of - devname or devfullname. Returns NULL if none found */ -struct interface_info *getInterfaceByName(char *iname); -/* Where the above 4 functions get their info */ -struct interface_info *getinterfaces(int *howmany); + + pcap_if_t *getpcapinterfaces(); -/* Parse the system routing table, converting each route into a - sys_route entry. Returns an array of sys_routes. numroutes is set - to the number of routes in the array. The routing table is only - read the first time this is called -- later results are cached. - The returned route array is sorted by netmask with the most - specific matches first. */ -struct sys_route *getsysroutes(int *howmany); -void sethdrinclude(int sd); - -void set_ipoptions(int sd, void *opts, size_t optslen); - -void set_ttl(int sd, int ttl); /* Fill buf (up to buflen -- truncate if necessary but always terminate) with a short representation of the packet stats. @@ -711,15 +603,8 @@ bool setTargetNextHopMAC(Target *target); bool getNextHopMAC(char *iface, u8 *srcmac, struct sockaddr_storage *srcss, struct sockaddr_storage *dstss, u8 *dstmac); -int islocalhost(const struct in_addr * const addr); -int isipprivate(const struct in_addr * const addr); -// Takes a protocol number like IPPROTO_TCP, IPPROTO_UDP, or -// IPPROTO_IP and returns a ascii representation (or "unknown" if it -// doesn't recognize the number). If uppercase is true, the returned -// value will be in all uppercase letters. You can skip this -// parameter to use lowercase. -const char *proto2ascii(u8 proto, bool uppercase=false); + /* Hex dump */ int get_link_offset(char *device); /* If rcvdtime is non-null and a packet is returned, rcvd will be diff --git a/traceroute.cc b/traceroute.cc index c56548375..bfe181f3a 100644 --- a/traceroute.cc +++ b/traceroute.cc @@ -781,14 +781,16 @@ TracerouteState::TracerouteState(std::vector &targets) { } /* Assume that all the targets share the same device. */ - pd = my_pcap_open_live(targets[0]->deviceName(), 128, o.spoofsource, 2); + if((pd=my_pcap_open_live(targets[0]->deviceName(), 128, o.spoofsource, 2))==NULL) + fatal("%s", PCAP_OPEN_ERRMSG); sslen = sizeof(srcaddr); targets[0]->SourceSockAddr(&srcaddr, &sslen); n = Snprintf(pcap_filter, sizeof(pcap_filter), "dst host %s", ss_to_string(&srcaddr)); assert(n < (int) sizeof(pcap_filter)); set_pcap_filter(targets[0]->deviceFullName(), pd, pcap_filter); - + if (o.debugging) + log_write(LOG_STDOUT, "Packet capture filter (device %s): %s\n", targets[0]->deviceFullName(), pcap_filter); for (it = targets.begin(); it != targets.end(); it++) { HostState *state = new HostState(*it); hosts.push_back(state); diff --git a/utils.cc b/utils.cc index c64d8809d..d09b19153 100644 --- a/utils.cc +++ b/utils.cc @@ -171,24 +171,6 @@ char *chomp(char *string) { return string; } -/* Compare a canonical option name (e.g. "max-scan-delay") with a - user-generated option such as "max_scan_delay" and returns 0 if the - two values are considered equivalant (for example, - and _ are - considered to be the same), nonzero otherwise. */ -int optcmp(const char *a, const char *b) { - while(*a && *b) { - if (*a == '_' || *a == '-') { - if (*b != '_' && *b != '-') - return 1; - } - else if (*a != *b) - return 1; - a++; b++; - } - if (*a || *b) - return 1; - return 0; -} /* Scramble the contents of an array*/ void genfry(unsigned char *arr, int elem_sz, int num_elem) { @@ -447,143 +429,6 @@ char *cstring_unescape(char *str, unsigned int *newlen) { return str; } -/* This function converts zero-terminated 'txt' string to binary 'data'. - It is used to parse user input for ip options. Some examples of possible input - strings and results: - '\x01*2\xA2' -> [0x01,0x01,0xA2] // with 'x' number is parsed in hex - '\01\01\255' -> [0x01,0x01,0xFF] // without 'x' its in decimal - '\x01\x00*2' -> [0x01,0x00,0x00] // '*' is copying char - 'R' -> Record Route with 9 slots - 'S 192.168.0.1 172.16.0.1' -> Strict Route with 2 slots - 'L 192.168.0.1 172.16.0.1' -> Loose Route with 2 slots - 'T' -> Record Timestamp with 9 slots - 'U' -> Record Timestamp and Ip Address with 4 slots -*/ -int parse_ip_options(char *txt, u8 *data, int datalen, int* firsthopoff, int* lasthopoff){ - enum{ - NONE = 0, - SLASH = 1, - MUL = 2, - RR = 3, - TIME = 4, - } s = NONE; - char *n, lc; - char *c = txt; - u8 *d = data; - int i,j; - int base = 10; - u8 *dataend = &data[datalen]; - u8 *len = NULL; - char buf[32]; - memset(data, 0, datalen); - bool sourcerouting = false; - - - for(;*c;c++){ - switch(s){ - case SLASH: - // parse \x00 string - if(*c == 'x'){// just ignore this char - base = 16; - break; - } - if(isxdigit((int) (unsigned char) *c)){ - *d++ = strtol(c, &n, base); - c=n-1; - }else - fatal("not a digit after '\\'"); - s = NONE; - break; - case MUL: - if(d==data) - fatal("nothing before '*' char"); - i = strtol(c, &n, 10); - if(i<2) - fatal("bad number after '*'"); - c = n-1; // move current txt pointer - lc = *(d-1); // last char, we'll copy this - for(j=1; j='0' && *c<='9')) && n-buf <= ((int)sizeof(buf)-1)) - *n++ = *c++; - *n = '\0'; c--; - if(d+4>=dataend) - fatal("Buffer too small. Or input data too big :)"); - i = inet_pton(AF_INET, buf, d); - if(i<1) - fatal("Not a valid ipv4 address '%s'",buf); - // remember offset of first hop - if(sourcerouting && !*firsthopoff) - *firsthopoff = d - data; - d+=4; - if(*len<37) - *len += 4; - break; - case TIME: - fatal("No more arguments allowed!"); - default: - switch(*c){ - case '\\':s = SLASH;base=10;break; - case '*':s = MUL;break; - case 'R': - case 'S': - case 'L': - if(d != data) - fatal("This option can't be used in that way"); - *d++ = '\x01';//NOP - switch(*c){ - case 'R':*d++ = 7;break; - case 'S':*d++ = 137; sourcerouting=true; break; - case 'L':*d++ = 131; sourcerouting=true; break; - } - len = d; - *d++ = (*c=='R')? 39 : 3; // length: 3+4*9 bytes - *d++ = 4; //pointer - s = RR; - break; - case 'T': - case 'U': - if(d != data) - fatal("This option can't be used in that way"); - *d++ = 68; // option type - len = d; - *d++ = (*c=='U') ? 36 : 40; // length: 3+4*9 bytes or 4+4*9 bytes - *d++ = 5; // pointer - *d++ = (*c=='U') ? 1 : 0; // flag: address and Time fields - s = TIME; - break; - default://*d++ = *c; - fatal("Bad character in ip option '%c'",*c); - } - } - if(d == dataend) - break; - assert(d= option_end) \ - {option_type = HEXDUMP; break;} -/* It tries to decode ip options. - Returns static buffer. watch out. */ -char* print_ip_options(u8* ipopt, int ipoptlen) { - char ipstring[32]; - int option_type = UNKNOWN;// option type - int option_len = 0; // option length - int option_pt = 0; // option pointer - int option_fl = 0; // option flag - u8 *tptr; // temp pointer - u32 *tint; // temp int - - int option_sta = 0; // option start offset - int option_end = 0; // option end offset - int pt = 0; // current offset - - // clear buffer - STRAPP(NULL,NULL); - - if(!ipoptlen) - return(NULL); - - while(pt= ipoptlen) // no more chars - {option_type = HEXDUMP;pt--; option_end = 255; continue;} // no length field, hex dump to the end - option_len = ipopt[pt++]; - // end must not be greater than length - option_end = MIN(option_sta + option_len, ipoptlen); - // end must not be smaller than current position - option_end = MAX(option_end, option_sta+2); - } - } - switch(option_type) { - case 0: // IPOPT_END - STRAPP(" EOL", NULL); - option_type = UNKNOWN; - break; - case 1: // IPOPT_NOP - STRAPP(" NOP", NULL); - option_type = UNKNOWN; - break; -/* case 130: // IPOPT_SECURITY - option_type=-1; - break;*/ - case 131: // IPOPT_LSRR -> Loose Source and Record Route - case 137: // IPOPT_SSRR -> Strict Source and Record Route - case 7: // IPOPT_RR -> Record Route - if(pt - option_sta == 2) { - STRAPP(" %s%s{", (option_type==131)?"LS":(option_type==137)?"SS":"", "RR"); - // option pointer - CHECK(pt); - option_pt = ipopt[pt++]; - if(option_pt%4 != 0 || (option_sta + option_pt-1)>option_end || option_pt<4) //bad or too big pointer - STRAPP(" [bad ptr=%02i]", option_pt); - } - if(pt - option_sta > 2) { // ip's - int i, s = (option_pt)%4; - // if pointer is mangled, fix it. it's max 3 bytes wrong - CHECK(pt+3); - for(i=0; i Internet Timestamp - if(pt - option_sta == 2){ - STRAPP(" TM{"); - // pointer - CHECK(pt); - option_pt = ipopt[pt++]; - // bad or too big pointer - if(option_pt%4 != 1 || (option_sta + option_pt-1)>option_end || option_pt<5) - STRAPP(" [bad ptr=%02i]", option_pt); - // flags + overflow - CHECK(pt); - option_fl = ipopt[pt++]; - if((option_fl&0x0C) || (option_fl&0x03)==2) - STRAPP(" [bad flags=\\x%01hhx]", option_fl&0x0F); - STRAPP("[%i hosts not recorded]", option_fl>>4); - option_fl &= 0x03; - } - if(pt - option_sta > 2) {// ip's - int i, s = (option_pt+3)%(option_fl==0?4:8); - // if pointer is mangled, fix it. it's max 3 bytes wrong - CHECK(pt+(option_fl==0?3:7)); - for(i=0; i (SANET) Stream Identifier - if(pt - option_sta == 2){ - u16 *sh; - STRAPP(" SI{",NULL); - // length - if(option_sta+option_len > ipoptlen || option_len!=4) - STRAPP("[bad len %02i]", option_len); - - // stream id - CHECK(pt+1); - sh = (u16*) &ipopt[pt]; pt+=2; - option_pt = ntohs(*sh); - STRAPP("id=%i", option_pt); - if(pt != option_end) - BREAK(); - }else BREAK(); - break; - case UNKNOWN: - default: - // we read option_type and option_len, print them. - STRAPP(" ??{\\x%02hhx\\x%02hhx", option_type, option_len); - // check option_end once more: - if(option_len < ipoptlen) - option_end = MIN(MAX(option_sta+option_len, option_sta+2),ipoptlen); - else - option_end = 255; - option_type = HEXDUMP; - break; - case HEXDUMP: - assert(pt<=option_end); - if(pt == option_end){ - STRAPP("}",NULL); - option_type=-1; - break; - } - STRAPP("\\x%02hhx", ipopt[pt++]); - break; - } - if(pt == option_end && option_type != UNKNOWN) { - STRAPP("}",NULL); - option_type = UNKNOWN; - } - } // while - if(option_type != UNKNOWN) - STRAPP("}"); - - return(STRAPP("",NULL)); -} -#undef CHECK -#undef BREAK -#undef UNKNOWN -#undef HEXDUMP /* mmap() an entire file into the address space. Returns a pointer diff --git a/utils.h b/utils.h index b53754e73..61a801f89 100644 --- a/utils.h +++ b/utils.h @@ -175,12 +175,6 @@ int wildtest(char *wild, char *test); void nmap_hexdump(unsigned char *cp, unsigned int length); -/* Compare a canonical option name (e.g. "max-scan-delay") with a - user-generated option such as "max_scan_delay" and returns 0 if the - two values are considered equivalant (for example, - and _ are - considered to be the same), nonzero otherwise. */ -int optcmp(const char *canonical, const char *instance); - /* Scramble the contents of an array*/ void genfry(unsigned char *arr, int elem_sz, int num_elem); void shortfry(unsigned short *arr, int num_elem); @@ -204,23 +198,8 @@ void arg_parse_free(char **argv); str is returned. */ char *cstring_unescape(char *str, unsigned int *len); -/* This function converts zero-terminated 'txt' string to binary 'data'. - It is used to parse user input for ip options. Some examples of possible input - strings and results: - '\x01*2\xA2' -> [0x01,0x01,0xA2] // with 'x' number is parsed in hex - '\01\01\255' -> [0x01,0x01,0xFF] // without 'x' its in decimal - '\x01\x00*2' -> [0x01,0x00,0x00] // '*' is copying char - 'R' -> Record Route with 9 slots - 'S 192.168.0.1 172.16.0.1' -> Strict Route with 2 slots - 'L 192.168.0.1 172.16.0.1' -> Loose Route with 2 slots - 'T' -> Record Timestamp with 9 slots - 'U' -> Record Timestamp and Ip Address with 4 slots -*/ -int parse_ip_options(char *txt, u8 *data, int datalen, int* firsthopoff, int* lasthopoff); - void bintohexstr(char *buf, int buflen, char *src, int srclen); -char* print_ip_options(u8* ipopt, int ipoptlen); #ifndef HAVE_STRERROR char *strerror(int errnum);