Index: ncftp3/README.v6 diff -u /dev/null ncftp3/README.v6:1.1 --- /dev/null Wed Jul 28 23:18:37 2004 +++ ncftp3/README.v6 Tue Aug 6 14:06:35 2002 @@ -0,0 +1,2 @@ +If you have problem/trouble/suggestion for IPv6 related code, +Please contact to core@kame.net Index: ncftp3/config.h.in diff -u ncftp3/config.h.in:1.1.1.10 ncftp3/config.h.in:1.12 --- ncftp3/config.h.in:1.1.1.10 Thu Jan 8 19:51:00 2004 +++ ncftp3/config.h.in Thu Jan 8 20:09:32 2004 @@ -222,6 +222,9 @@ /* Define if you have the doupdate function. */ #undef HAVE_DOUPDATE +/* Define if you have the getaddrinfo function. */ +#undef HAVE_GETADDRINFO + /* Define if you have the fstat64 function. */ #undef HAVE_FSTAT64 @@ -243,6 +246,9 @@ /* Define if you have the gethostname function. */ #undef HAVE_GETHOSTNAME +/* Define if you have the getaddrname function. */ +#undef HAVE_GETNAMEINFO + /* Define if you have the getlogin_r function. */ #undef HAVE_GETLOGIN_R @@ -345,6 +351,9 @@ /* Define if you have the snprintf function. */ #undef HAVE_SNPRINTF +/* Define if sockaddr has sa_len member */ +#undef HAVE_SOCKADDR_SA_LEN + /* Define if you have the stat64 function. */ #undef HAVE_STAT64 @@ -494,3 +503,19 @@ /* Define if you have the socket library (-lsocket). */ #undef HAVE_LIBSOCKET + +/* Define if you have the socks5 library (-lsocks5). */ +#undef HAVE_LIBSOCKS5 + +/* Define if you want IPv6 support. */ +#undef ENABLE_IPV6 + +/* Define if sockaddr has sa_len member */ +#undef HAVE_SOCKADDR_SA_LEN + +/* Define if sockaddr_storage has ss_family member */ +#undef HAVE_SOCKADDR_STORAGE_SS_FAMILY + +/* Define if sockaddr_storage has __ss_family member */ +#undef HAVE_SOCKADDR_STORAGE___SS_FAMILY + Index: ncftp3/configure diff -u ncftp3/configure:1.1.1.15 ncftp3/configure:1.28 --- ncftp3/configure:1.1.1.15 Thu Jan 8 19:50:59 2004 +++ ncftp3/configure Thu Jan 8 20:09:32 2004 @@ -23,6 +23,9 @@ --disable-precomp disable use of precompiled header files" ac_help="$ac_help --with-socks5 try to find and use the SOCKS5 library" +ac_help="$ac_help + --enable-ipv6 Enable ipv6 (with ipv4) support + --disable-ipv6 Disable ipv6 support" # Initialize some variables set by options. # The variables have the same names as the options, with @@ -40,6 +43,7 @@ program_transform_name=s,x,x, silent= site= +sitefile= srcdir= target=NONE verbose= @@ -154,6 +158,7 @@ --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages + --site-file=FILE use FILE as the site file --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX @@ -324,6 +329,11 @@ -site=* | --site=* | --sit=*) site="$ac_optarg" ;; + -site-file | --site-file | --site-fil | --site-fi | --site-f) + ac_prev=sitefile ;; + -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*) + sitefile="$ac_optarg" ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) @@ -489,12 +499,16 @@ srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. -if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" +if test -z "$sitefile"; then + if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi fi +else + CONFIG_SITE="$sitefile" fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then @@ -607,30 +621,28 @@ - - echo $ac_n "checking if you set and exported the environment variable CC""... $ac_c" 1>&6 -echo "configure:614: checking if you set and exported the environment variable CC" >&5 +echo "configure:626: checking if you set and exported the environment variable CC" >&5 if test "x$CC" = x ; then echo "$ac_t""no (you may want to do that since configure scripts look for gcc first)" 1>&6 else echo "$ac_t""$CC" 1>&6 fi echo $ac_n "checking for environment variable CFLAGS""... $ac_c" 1>&6 -echo "configure:621: checking for environment variable CFLAGS" >&5 +echo "configure:633: checking for environment variable CFLAGS" >&5 if test "x$CFLAGS" = x ; then echo "$ac_t""no (we will choose a default set for you)" 1>&6 else echo "$ac_t""$CFLAGS" 1>&6 fi echo $ac_n "checking for environment variable CPPFLAGS""... $ac_c" 1>&6 -echo "configure:628: checking for environment variable CPPFLAGS" >&5 +echo "configure:640: checking for environment variable CPPFLAGS" >&5 echo "$ac_t""${CPPFLAGS-no}" 1>&6 echo $ac_n "checking for environment variable LDFLAGS""... $ac_c" 1>&6 -echo "configure:631: checking for environment variable LDFLAGS" >&5 +echo "configure:643: checking for environment variable LDFLAGS" >&5 echo "$ac_t""${LDFLAGS-no}" 1>&6 echo $ac_n "checking for environment variable LIBS""... $ac_c" 1>&6 -echo "configure:634: checking for environment variable LIBS" >&5 +echo "configure:646: checking for environment variable LIBS" >&5 echo "$ac_t""${LIBS-no}" 1>&6 @@ -1074,7 +1086,7 @@ # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1078: checking for $ac_word" >&5 +echo "configure:1090: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1104,7 +1116,7 @@ # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1108: checking for $ac_word" >&5 +echo "configure:1120: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1155,7 +1167,7 @@ # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1159: checking for $ac_word" >&5 +echo "configure:1171: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1187,7 +1199,7 @@ fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1191: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1203: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1198,12 +1210,12 @@ cat > conftest.$ac_ext << EOF -#line 1202 "configure" +#line 1214 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:1207: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -1229,12 +1241,12 @@ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:1233: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:1245: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1238: checking whether we are using GNU C" >&5 +echo "configure:1250: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1243,7 +1255,7 @@ yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1247: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1259: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1262,7 +1274,7 @@ ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1266: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1278: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1295,7 +1307,7 @@ echo $ac_n "checking if the C compiler can use precompiled headers""... $ac_c" 1>&6 -echo "configure:1299: checking if the C compiler can use precompiled headers" >&5 +echo "configure:1311: checking if the C compiler can use precompiled headers" >&5 if eval "test \"`echo '$''{'wi_cv_cc_precomp'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1335,14 +1347,14 @@ # echo "Successfully compiled pchtest.h into the precompiled header file pchtest.h.gch." >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1358: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* result="yes" ; wi_cv_cc_precomp_type="gcc_gch_files" else @@ -1361,14 +1373,14 @@ ${CC-cc} $CPPFLAGS -precomp pchtest.h -o pchtest.p >&5 2>&5 if test -s pchtest.p ; then cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1384: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* result="yes" ; wi_cv_cc_precomp_type="gcc_dash_precomp" else @@ -1432,7 +1444,7 @@ wi_request_no_y2k_warnings=yes echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1436: checking how to run the C preprocessor" >&5 +echo "configure:1448: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1447,13 +1459,13 @@ # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1457: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1469: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1464,13 +1476,13 @@ rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1474: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1486: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1481,13 +1493,13 @@ rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1491: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1503: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1518,7 +1530,7 @@ if test "$GCC" = yes ; then echo $ac_n "checking the version of GCC""... $ac_c" 1>&6 -echo "configure:1522: checking the version of GCC" >&5 +echo "configure:1534: checking the version of GCC" >&5 if eval "test \"`echo '$''{'wi_cv_gcc_version'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1541,7 +1553,7 @@ wi_cv_sunwspro_cc_version2="0" else echo $ac_n "checking if the C compiler is Sun WorkShop C""... $ac_c" 1>&6 -echo "configure:1545: checking if the C compiler is Sun WorkShop C" >&5 +echo "configure:1557: checking if the C compiler is Sun WorkShop C" >&5 if eval "test \"`echo '$''{'wi_cv_cc_is_sunwspro_cc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1575,14 +1587,14 @@ echo "$ac_t""$wi_cv_cc_is_sunwspro_cc" 1>&6 if test "$wi_cv_cc_is_sunwspro_cc" = yes ; then echo $ac_n "checking output of "cc -V" to determine version of Sun WorkShop C""... $ac_c" 1>&6 -echo "configure:1579: checking output of "cc -V" to determine version of Sun WorkShop C" >&5 +echo "configure:1591: checking output of "cc -V" to determine version of Sun WorkShop C" >&5 echo "$ac_t"""version $wi_cv_sunwspro_cc_version"" 1>&6 fi fi echo $ac_n "checking if we should customize your CFLAGS environment variable""... $ac_c" 1>&6 -echo "configure:1586: checking if we should customize your CFLAGS environment variable" >&5 +echo "configure:1598: checking if we should customize your CFLAGS environment variable" >&5 wi_replace_O_with_g="no" case "$wi_orig_CFLAGS" in "") @@ -1770,14 +1782,14 @@ # accepts this flag... # cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1793: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 @@ -1817,7 +1829,7 @@ # Was it ./configure --enable-debug ? # echo $ac_n "checking if this is a debug build""... $ac_c" 1>&6 -echo "configure:1821: checking if this is a debug build" >&5 +echo "configure:1833: checking if this is a debug build" >&5 if test "$DEBUGBUILD" = yes ; then echo "$ac_t""yes" 1>&6 CFLAGS="$DEBUGCFLAGS" @@ -1825,19 +1837,19 @@ echo "$ac_t""no" 1>&6 fi echo $ac_n "checking NOOPTCFLAGS""... $ac_c" 1>&6 -echo "configure:1829: checking NOOPTCFLAGS" >&5 +echo "configure:1841: checking NOOPTCFLAGS" >&5 echo "$ac_t""$NOOPTCFLAGS" 1>&6 echo $ac_n "checking DEBUGCFLAGS""... $ac_c" 1>&6 -echo "configure:1832: checking DEBUGCFLAGS" >&5 +echo "configure:1844: checking DEBUGCFLAGS" >&5 echo "$ac_t""$DEBUGCFLAGS" 1>&6 echo $ac_n "checking CFLAGS""... $ac_c" 1>&6 -echo "configure:1835: checking CFLAGS" >&5 +echo "configure:1847: checking CFLAGS" >&5 echo "$ac_t""$CFLAGS" 1>&6 if test "os_${os}_gcc_${GCC}" = os_hp-ux_gcc_yes ; then echo $ac_n "checking if -D__STDC_EXT__ is needed with GCC on HP-UX""... $ac_c" 1>&6 -echo "configure:1841: checking if -D__STDC_EXT__ is needed with GCC on HP-UX" >&5 +echo "configure:1853: checking if -D__STDC_EXT__ is needed with GCC on HP-UX" >&5 if test "$cross_compiling" = yes; then # action if cross-compiling, guess @@ -1846,7 +1858,7 @@ else cat > conftest.$ac_ext < @@ -1862,7 +1874,7 @@ #endif } EOF -if { (eval echo configure:1866: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:1878: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -1901,7 +1913,7 @@ ;; esac echo $ac_n "checking if we should add to CFLAGS for LFS64 support""... $ac_c" 1>&6 -echo "configure:1905: checking if we should add to CFLAGS for LFS64 support" >&5 +echo "configure:1917: checking if we should add to CFLAGS for LFS64 support" >&5 echo "$ac_t""$CFLAGS" 1>&6 @@ -1913,7 +1925,7 @@ ;; esac echo $ac_n "checking if we should add -D_REENTRANT to CFLAGS""... $ac_c" 1>&6 -echo "configure:1917: checking if we should add -D_REENTRANT to CFLAGS" >&5 +echo "configure:1929: checking if we should add -D_REENTRANT to CFLAGS" >&5 echo "$ac_t""$CFLAGS" 1>&6 @@ -1943,13 +1955,13 @@ STRIPFLAG="$SFLAG" echo $ac_n "checking for object suffix""... $ac_c" 1>&6 -echo "configure:1947: checking for object suffix" >&5 +echo "configure:1959: checking for object suffix" >&5 if eval "test \"`echo '$''{'ac_cv_objext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else rm -f conftest* echo 'int i = 1;' > conftest.$ac_ext -if { (eval echo configure:1953: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1965: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then for ac_file in conftest.*; do case $ac_file in *.c) ;; @@ -1967,12 +1979,12 @@ ac_objext=$ac_cv_objext echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:1971: checking for Cygwin environment" >&5 +echo "configure:1983: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1999: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -2000,19 +2012,19 @@ CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:2004: checking for mingw32 environment" >&5 +echo "configure:2016: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2028: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -2031,7 +2043,7 @@ echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:2035: checking for executable suffix" >&5 +echo "configure:2047: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2041,10 +2053,10 @@ rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:2045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:2057: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in - *.c | *.o | *.obj) ;; + *.c | *.C | *.o | *.obj | *.ilk | *.pdb) ;; *) ac_cv_exeext=`echo $file | sed -e s/conftest//` ;; esac done @@ -2075,7 +2087,7 @@ if test "${SYS-sunos}" = sunos ; then echo $ac_n "checking for System V compatibility directories""... $ac_c" 1>&6 -echo "configure:2079: checking for System V compatibility directories" >&5 +echo "configure:2091: checking for System V compatibility directories" >&5 echo "$ac_t""" 1>&6 incdir=""/usr/5include"" @@ -2118,12 +2130,12 @@ echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 -echo "configure:2122: checking for ANSI C header files" >&5 +echo "configure:2134: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2131,7 +2143,7 @@ #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2135: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2147: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2148,7 +2160,7 @@ if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF @@ -2166,7 +2178,7 @@ 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 < EOF @@ -2187,7 +2199,7 @@ : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') @@ -2198,7 +2210,7 @@ exit (0); } EOF -if { (eval echo configure:2202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2214: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else @@ -2225,17 +2237,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2229: checking for $ac_hdr" >&5 +echo "configure:2241: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2239: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2251: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2262,12 +2274,12 @@ done echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 -echo "configure:2266: checking whether time.h and sys/time.h may both be included" >&5 +echo "configure:2278: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include @@ -2276,7 +2288,7 @@ struct tm *tp; ; return 0; } EOF -if { (eval echo configure:2280: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2292: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else @@ -2308,17 +2320,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2312: checking for $ac_hdr" >&5 +echo "configure:2324: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2322: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2334: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2345,7 +2357,7 @@ done echo $ac_n "checking for UNIX domain sockets""... $ac_c" 1>&6 -echo "configure:2349: checking for UNIX domain sockets" >&5 +echo "configure:2361: checking for UNIX domain sockets" >&5 if eval "test \"`echo '$''{'wi_cv_unix_domain_sockets'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2357,7 +2369,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2399: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -2413,13 +2425,13 @@ fi echo $ac_n "checking for sun_len field in struct sockaddr_un""... $ac_c" 1>&6 -echo "configure:2417: checking for sun_len field in struct sockaddr_un" >&5 +echo "configure:2429: checking for sun_len field in struct sockaddr_un" >&5 if eval "test \"`echo '$''{'wi_cv_sockaddr_un_sun_len'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2454: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* wi_cv_sockaddr_un_sun_len=yes @@ -2480,12 +2492,12 @@ # Mostly for SunOS 4 -- needs to come first because other libs depend on it echo $ac_n "checking for strerror""... $ac_c" 1>&6 -echo "configure:2484: checking for strerror" >&5 +echo "configure:2496: checking for strerror" >&5 if eval "test \"`echo '$''{'ac_cv_func_strerror'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2524: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_strerror=yes" else @@ -2531,7 +2543,7 @@ if test "$a" = no ; then # Not in libc, try lib44bsd. echo $ac_n "checking for strerror in -l44bsd""... $ac_c" 1>&6 -echo "configure:2535: checking for strerror in -l44bsd" >&5 +echo "configure:2547: checking for strerror in -l44bsd" >&5 ac_lib_var=`echo 44bsd'_'strerror | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2539,7 +2551,7 @@ ac_save_LIBS="$LIBS" LIBS="-l44bsd $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2566: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2582,12 +2594,12 @@ echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:2586: checking for socket" >&5 +echo "configure:2598: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2626: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else @@ -2633,7 +2645,7 @@ if test "$a" = no ; then # Not in libc, try libsocket. echo $ac_n "checking for socket in -lsocket""... $ac_c" 1>&6 -echo "configure:2637: checking for socket in -lsocket" >&5 +echo "configure:2649: checking for socket in -lsocket" >&5 ac_lib_var=`echo socket'_'socket | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2641,7 +2653,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsocket $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2668: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2687,7 +2699,7 @@ unixware2*) # So far, only UnixWare needs this. echo $ac_n "checking for syslog in -lgen""... $ac_c" 1>&6 -echo "configure:2691: checking for syslog in -lgen" >&5 +echo "configure:2703: checking for syslog in -lgen" >&5 ac_lib_var=`echo gen'_'syslog | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2695,7 +2707,7 @@ ac_save_LIBS="$LIBS" LIBS="-lgen $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2753,12 +2765,12 @@ # AC_CHECK_FUNC(socket,[a=yes],[a=no]) # echo $ac_n "checking for socket""... $ac_c" 1>&6 -echo "configure:2757: checking for socket" >&5 +echo "configure:2769: checking for socket" >&5 if eval "test \"`echo '$''{'ac_cv_func_socket'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_socket=yes" else @@ -2814,7 +2826,7 @@ hpux1123456789*) # HP-UX 11 uses NSL for YP services echo $ac_n "checking for getpwent in -lnsl""... $ac_c" 1>&6 -echo "configure:2818: checking for getpwent in -lnsl" >&5 +echo "configure:2830: checking for getpwent in -lnsl" >&5 ac_lib_var=`echo nsl'_'getpwent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2822,7 +2834,7 @@ ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2849: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2864,12 +2876,12 @@ *) echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 -echo "configure:2868: checking for gethostbyname" >&5 +echo "configure:2880: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2908: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else @@ -2915,7 +2927,7 @@ if test "$a" = no ; then # Not in libc, try libnsl. echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 -echo "configure:2919: checking for gethostbyname in -lnsl" >&5 +echo "configure:2931: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2923,7 +2935,7 @@ ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2970,7 +2982,7 @@ # See if we could access two well-known sites without help of any special # libraries, like resolv. echo $ac_n "checking if we need to look for -lresolv""... $ac_c" 1>&6 -echo "configure:2974: checking if we need to look for -lresolv" >&5 +echo "configure:2986: checking if we need to look for -lresolv" >&5 if eval "test \"`echo '$''{'wi_cv_look_for_resolv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2984,7 +2996,7 @@ wi_cv_look_for_resolv=yes else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3027: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then wi_cv_look_for_resolv=no else @@ -3030,7 +3042,7 @@ if test "$wi_cv_look_for_resolv" = yes ; then echo $ac_n "checking for main in -lresolv""... $ac_c" 1>&6 -echo "configure:3034: checking for main in -lresolv" >&5 +echo "configure:3046: checking for main in -lresolv" >&5 ac_lib_var=`echo resolv'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3038,14 +3050,14 @@ ac_save_LIBS="$LIBS" LIBS="-lresolv $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3061: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3096,7 +3108,7 @@ # if test "x$ac_cv_lib_db_main" = "x" ; then echo $ac_n "checking for main in -ldb""... $ac_c" 1>&6 -echo "configure:3100: checking for main in -ldb" >&5 +echo "configure:3112: checking for main in -ldb" >&5 ac_lib_var=`echo db'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3104,14 +3116,14 @@ ac_save_LIBS="$LIBS" LIBS="-ldb $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3127: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3134,7 +3146,7 @@ fi if test "x$ac_cv_lib_isode_main" = "x" ; then echo $ac_n "checking for main in -lisode""... $ac_c" 1>&6 -echo "configure:3138: checking for main in -lisode" >&5 +echo "configure:3150: checking for main in -lisode" >&5 ac_lib_var=`echo isode'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3142,14 +3154,14 @@ ac_save_LIBS="$LIBS" LIBS="-lisode $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3165: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3172,7 +3184,7 @@ fi if test "x$ac_cv_lib_com_err_main" = "x" ; then echo $ac_n "checking for main in -lcom_err""... $ac_c" 1>&6 -echo "configure:3176: checking for main in -lcom_err" >&5 +echo "configure:3188: checking for main in -lcom_err" >&5 ac_lib_var=`echo com_err'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3180,14 +3192,14 @@ ac_save_LIBS="$LIBS" LIBS="-lcom_err $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3210,7 +3222,7 @@ fi if test "x$ac_cv_lib_crypto_main" = "x" ; then echo $ac_n "checking for main in -lcrypto""... $ac_c" 1>&6 -echo "configure:3214: checking for main in -lcrypto" >&5 +echo "configure:3226: checking for main in -lcrypto" >&5 ac_lib_var=`echo crypto'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3218,14 +3230,14 @@ ac_save_LIBS="$LIBS" LIBS="-lcrypto $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3241: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3248,7 +3260,7 @@ fi if test "x$ac_cv_lib_krb5_main" = "x" ; then echo $ac_n "checking for main in -lkrb5""... $ac_c" 1>&6 -echo "configure:3252: checking for main in -lkrb5" >&5 +echo "configure:3264: checking for main in -lkrb5" >&5 ac_lib_var=`echo krb5'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3256,14 +3268,14 @@ ac_save_LIBS="$LIBS" LIBS="-lkrb5 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3286,7 +3298,7 @@ fi if test "x$ac_cv_lib_gssapi_krb5_main" = "x" ; then echo $ac_n "checking for main in -lgssapi_krb5""... $ac_c" 1>&6 -echo "configure:3290: checking for main in -lgssapi_krb5" >&5 +echo "configure:3302: checking for main in -lgssapi_krb5" >&5 ac_lib_var=`echo gssapi_krb5'_'main | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3294,14 +3306,14 @@ ac_save_LIBS="$LIBS" LIBS="-lgssapi_krb5 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3317: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3324,7 +3336,7 @@ fi echo $ac_n "checking for SOCKSinit in -lsocks5""... $ac_c" 1>&6 -echo "configure:3328: checking for SOCKSinit in -lsocks5" >&5 +echo "configure:3340: checking for SOCKSinit in -lsocks5" >&5 ac_lib_var=`echo socks5'_'SOCKSinit | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -3332,7 +3344,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsocks5 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:3359: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -3367,17 +3379,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3371: checking for $ac_hdr" >&5 +echo "configure:3383: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3381: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3393: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3416,7 +3428,7 @@ fi fi echo $ac_n "checking if SOCKS5 will be used""... $ac_c" 1>&6 -echo "configure:3420: checking if SOCKS5 will be used" >&5 +echo "configure:3432: checking if SOCKS5 will be used" >&5 echo "$ac_t""$ac_cv_lib_socks5_SOCKSinit" 1>&6 @@ -3425,23 +3437,23 @@ echo $ac_n "checking for curses library headers""... $ac_c" 1>&6 -echo "configure:3429: checking for curses library headers" >&5 +echo "configure:3441: checking for curses library headers" >&5 if test "$wi_cv_ncurses" != "no" ; then for ac_hdr in ncurses.h curses.h termios.h termio.h sgtty.h sys/ioctl.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3435: checking for $ac_hdr" >&5 +echo "configure:3447: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3445: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3457: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3472,17 +3484,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:3476: checking for $ac_hdr" >&5 +echo "configure:3488: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:3486: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:3498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -3520,7 +3532,7 @@ fi echo $ac_n "checking for curses library""... $ac_c" 1>&6 -echo "configure:3524: checking for curses library" >&5 +echo "configure:3536: checking for curses library" >&5 wi_cv_lib_curses=no wi_cv_lib_curses_result=no @@ -3539,7 +3551,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -3629,12 +3641,12 @@ echo $ac_n "checking for working const""... $ac_c" 1>&6 -echo "configure:3633: checking for working const" >&5 +echo "configure:3645: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:3699: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else @@ -3704,12 +3716,12 @@ fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 -echo "configure:3708: checking for size_t" >&5 +echo "configure:3720: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3737,12 +3749,12 @@ fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 -echo "configure:3741: checking for off_t" >&5 +echo "configure:3753: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3770,12 +3782,12 @@ fi echo $ac_n "checking for mode_t""... $ac_c" 1>&6 -echo "configure:3774: checking for mode_t" >&5 +echo "configure:3786: checking for mode_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_mode_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3803,12 +3815,12 @@ fi echo $ac_n "checking for pid_t""... $ac_c" 1>&6 -echo "configure:3807: checking for pid_t" >&5 +echo "configure:3819: checking for pid_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS @@ -3836,12 +3848,12 @@ fi echo $ac_n "checking for uid_t in sys/types.h""... $ac_c" 1>&6 -echo "configure:3840: checking for uid_t in sys/types.h" >&5 +echo "configure:3852: checking for uid_t in sys/types.h" >&5 if eval "test \"`echo '$''{'ac_cv_type_uid_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF @@ -3871,7 +3883,7 @@ echo $ac_n "checking what type main() should return""... $ac_c" 1>&6 -echo "configure:3875: checking what type main() should return" >&5 +echo "configure:3887: checking what type main() should return" >&5 if eval "test \"`echo '$''{'wi_cv_main_void_return_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3898,7 +3910,7 @@ fi echo $ac_n "checking for 64-bit integral type: long long""... $ac_c" 1>&6 -echo "configure:3902: checking for 64-bit integral type: long long" >&5 +echo "configure:3914: checking for 64-bit integral type: long long" >&5 LONGEST_INT="long" if test "$cross_compiling" = yes; then @@ -3907,7 +3919,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:3951: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -3959,7 +3971,7 @@ if test "$wi_cv_type_long_long" = yes ; then echo $ac_n "checking how to print a 64-bit integral type""... $ac_c" 1>&6 -echo "configure:3963: checking how to print a 64-bit integral type" >&5 +echo "configure:3975: checking how to print a 64-bit integral type" >&5 wi_cv_printf_long_long=fail if test "$cross_compiling" = yes; then @@ -3969,7 +3981,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4014: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -4027,7 +4039,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4072: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -4086,7 +4098,7 @@ echo $ac_n "checking how to scan a 64-bit integral type""... $ac_c" 1>&6 -echo "configure:4090: checking how to scan a 64-bit integral type" >&5 +echo "configure:4102: checking how to scan a 64-bit integral type" >&5 wi_cv_scanf_long_long=fail if test "$cross_compiling" = yes; then @@ -4096,7 +4108,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4144: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -4157,7 +4169,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -4220,7 +4232,7 @@ fi echo $ac_n "checking if everything was available to use the 64-bit integral type""... $ac_c" 1>&6 -echo "configure:4224: checking if everything was available to use the 64-bit integral type" >&5 +echo "configure:4236: checking if everything was available to use the 64-bit integral type" >&5 if test "$wi_cv_type_long_long" = no ; then wi_cv_use_long_long_msg_result="no (long long type not available)" @@ -4299,7 +4311,7 @@ wi_struct_timeval_field_checks="cached" echo $ac_n "checking what type the tv_sec field of struct timeval is""... $ac_c" 1>&6 -echo "configure:4303: checking what type the tv_sec field of struct timeval is" >&5 +echo "configure:4315: checking what type the tv_sec field of struct timeval is" >&5 if eval "test \"`echo '$''{'wi_cv_struct_timeval_tv_sec'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4318,7 +4330,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:4414: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -4427,11 +4439,11 @@ echo "$ac_t""$wi_cv_struct_timeval_tv_sec" 1>&6 if test "$wi_struct_timeval_field_checks" = "uncached" ; then echo $ac_n "checking what type the tv_usec field of struct timeval is""... $ac_c" 1>&6 -echo "configure:4431: checking what type the tv_usec field of struct timeval is" >&5 +echo "configure:4443: checking what type the tv_usec field of struct timeval is" >&5 echo "$ac_t""$wi_cv_struct_timeval_tv_usec" 1>&6 else echo $ac_n "checking what type the tv_usec field of struct timeval is""... $ac_c" 1>&6 -echo "configure:4435: checking what type the tv_usec field of struct timeval is" >&5 +echo "configure:4447: checking what type the tv_usec field of struct timeval is" >&5 if eval "test \"`echo '$''{'wi_cv_struct_timeval_tv_usec'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4453,7 +4465,7 @@ # Extract the first word of ""perl"", so it can be a program name with args. set dummy "perl"; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4457: checking for $ac_word" >&5 +echo "configure:4469: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_PERL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4491,7 +4503,7 @@ # Extract the first word of ""mktemp"", so it can be a program name with args. set dummy "mktemp"; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4495: checking for $ac_word" >&5 +echo "configure:4507: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MKTEMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4536,7 +4548,7 @@ fi echo $ac_n "checking for return type from write""... $ac_c" 1>&6 -echo "configure:4540: checking for return type from write" >&5 +echo "configure:4552: checking for return type from write" >&5 if eval "test \"`echo '$''{'wi_cv_write_return_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4847,35 +4859,35 @@ echo "$ac_t""$wi_cv_write_return_t" 1>&6 if test "x$used_cache_for_wi_unistd_fpt" = "xno" ; then echo $ac_n "checking for size parameter to write""... $ac_c" 1>&6 -echo "configure:4851: checking for size parameter to write" >&5 +echo "configure:4863: checking for size parameter to write" >&5 echo "$ac_t""$wi_cv_write_size_t" 1>&6 echo $ac_n "checking for return type from send""... $ac_c" 1>&6 -echo "configure:4854: checking for return type from send" >&5 +echo "configure:4866: checking for return type from send" >&5 echo "$ac_t""$wi_cv_send_return_t" 1>&6 echo $ac_n "checking for size parameter to send""... $ac_c" 1>&6 -echo "configure:4857: checking for size parameter to send" >&5 +echo "configure:4869: checking for size parameter to send" >&5 echo "$ac_t""$wi_cv_send_size_t" 1>&6 echo $ac_n "checking for size parameter to connect""... $ac_c" 1>&6 -echo "configure:4860: checking for size parameter to connect" >&5 +echo "configure:4872: checking for size parameter to connect" >&5 echo "$ac_t""$wi_cv_sockaddr_size_t" 1>&6 echo $ac_n "checking for size parameter to setsockopt""... $ac_c" 1>&6 -echo "configure:4863: checking for size parameter to setsockopt" >&5 +echo "configure:4875: checking for size parameter to setsockopt" >&5 echo "$ac_t""$wi_cv_sockopt_size_t" 1>&6 echo $ac_n "checking for backlog parameter to listen""... $ac_c" 1>&6 -echo "configure:4866: checking for backlog parameter to listen" >&5 +echo "configure:4878: checking for backlog parameter to listen" >&5 echo "$ac_t""$wi_cv_listen_backlog_t" 1>&6 echo $ac_n "checking for seconds parameter to alarm""... $ac_c" 1>&6 -echo "configure:4869: checking for seconds parameter to alarm" >&5 +echo "configure:4881: checking for seconds parameter to alarm" >&5 echo "$ac_t""$wi_cv_alarm_time_t" 1>&6 echo $ac_n "checking for address parameter to gethostbyaddr""... $ac_c" 1>&6 -echo "configure:4872: checking for address parameter to gethostbyaddr" >&5 +echo "configure:4884: checking for address parameter to gethostbyaddr" >&5 echo "$ac_t""$wi_cv_gethost_addrptr_t" 1>&6 echo $ac_n "checking for size parameter to gethostname""... $ac_c" 1>&6 -echo "configure:4875: checking for size parameter to gethostname" >&5 +echo "configure:4887: checking for size parameter to gethostname" >&5 echo "$ac_t""$wi_cv_gethostname_size_t" 1>&6 else echo $ac_n "checking for size parameter to write""... $ac_c" 1>&6 -echo "configure:4879: checking for size parameter to write" >&5 +echo "configure:4891: checking for size parameter to write" >&5 if eval "test \"`echo '$''{'wi_cv_write_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4884,7 +4896,7 @@ echo "$ac_t""$wi_cv_write_size_t" 1>&6 echo $ac_n "checking for return type from send""... $ac_c" 1>&6 -echo "configure:4888: checking for return type from send" >&5 +echo "configure:4900: checking for return type from send" >&5 if eval "test \"`echo '$''{'wi_cv_send_return_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4893,7 +4905,7 @@ echo "$ac_t""$wi_cv_send_return_t" 1>&6 echo $ac_n "checking for size parameter to send""... $ac_c" 1>&6 -echo "configure:4897: checking for size parameter to send" >&5 +echo "configure:4909: checking for size parameter to send" >&5 if eval "test \"`echo '$''{'wi_cv_send_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4902,7 +4914,7 @@ echo "$ac_t""$wi_cv_send_size_t" 1>&6 echo $ac_n "checking for size parameter to connect""... $ac_c" 1>&6 -echo "configure:4906: checking for size parameter to connect" >&5 +echo "configure:4918: checking for size parameter to connect" >&5 if eval "test \"`echo '$''{'wi_cv_sockaddr_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4911,7 +4923,7 @@ echo "$ac_t""$wi_cv_sockaddr_size_t" 1>&6 echo $ac_n "checking for size parameter to setsockopt""... $ac_c" 1>&6 -echo "configure:4915: checking for size parameter to setsockopt" >&5 +echo "configure:4927: checking for size parameter to setsockopt" >&5 if eval "test \"`echo '$''{'wi_cv_sockopt_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4920,7 +4932,7 @@ echo "$ac_t""$wi_cv_sockopt_size_t" 1>&6 echo $ac_n "checking for backlog parameter to listen""... $ac_c" 1>&6 -echo "configure:4924: checking for backlog parameter to listen" >&5 +echo "configure:4936: checking for backlog parameter to listen" >&5 if eval "test \"`echo '$''{'wi_cv_listen_backlog_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4929,7 +4941,7 @@ echo "$ac_t""$wi_cv_listen_backlog_t" 1>&6 echo $ac_n "checking for seconds parameter to alarm""... $ac_c" 1>&6 -echo "configure:4933: checking for seconds parameter to alarm" >&5 +echo "configure:4945: checking for seconds parameter to alarm" >&5 if eval "test \"`echo '$''{'wi_cv_alarm_time_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4938,7 +4950,7 @@ echo "$ac_t""$wi_cv_alarm_time_t" 1>&6 echo $ac_n "checking for address parameter to gethostbyaddr""... $ac_c" 1>&6 -echo "configure:4942: checking for address parameter to gethostbyaddr" >&5 +echo "configure:4954: checking for address parameter to gethostbyaddr" >&5 if eval "test \"`echo '$''{'wi_cv_gethost_addrptr_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4947,7 +4959,7 @@ echo "$ac_t""$wi_cv_gethost_addrptr_t" 1>&6 echo $ac_n "checking for size parameter to gethostname""... $ac_c" 1>&6 -echo "configure:4951: checking for size parameter to gethostname" >&5 +echo "configure:4963: checking for size parameter to gethostname" >&5 if eval "test \"`echo '$''{'wi_cv_gethostname_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5021,7 +5033,7 @@ fi echo $ac_n "checking types of arguments for select()""... $ac_c" 1>&6 -echo "configure:5025: checking types of arguments for select()" >&5 +echo "configure:5037: checking types of arguments for select()" >&5 if eval "test \"`echo '$''{'ac_cv_func_select_arg234'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5035,7 +5047,7 @@ for ac_cv_func_select_arg1 in 'int' 'size_t' 'unsigned long' 'unsigned'; do for ac_cv_func_select_arg5 in 'struct timeval *' 'const struct timeval *'; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5070: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_not_found=no ; break 3 else @@ -5094,9 +5106,9 @@ echo $ac_n "checking for struct stat64""... $ac_c" 1>&6 -echo "configure:5098: checking for struct stat64" >&5 +echo "configure:5110: checking for struct stat64" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5129: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* wi_cv_struct_stat64=yes @@ -5140,9 +5152,9 @@ fi echo $ac_n "checking for sig_atomic_t""... $ac_c" 1>&6 -echo "configure:5144: checking for sig_atomic_t" >&5 +echo "configure:5156: checking for sig_atomic_t" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5183: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_type_sig_atomic_t=yes @@ -5191,7 +5203,7 @@ echo $ac_n "checking how to access getopt() global variables""... $ac_c" 1>&6 -echo "configure:5195: checking how to access getopt() global variables" >&5 +echo "configure:5207: checking how to access getopt() global variables" >&5 if eval "test \"`echo '$''{'wi_cv_getopt_decl'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5202,7 +5214,7 @@ fi cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5237: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wi_cv_getopt_decl="automatic" else @@ -5233,7 +5245,7 @@ rm -f conftest* if test "$wi_cv_getopt_decl" = unknown ; then cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5269: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* wi_cv_getopt_decl="getopt.h" else @@ -5282,9 +5294,9 @@ echo $ac_n "checking for useable _res global variable""... $ac_c" 1>&6 -echo "configure:5286: checking for useable _res global variable" >&5 +echo "configure:5298: checking for useable _res global variable" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5327: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* wi_cv__res_defdname=yes @@ -5332,13 +5344,13 @@ echo "$ac_t""$wi_cv__res_defdname" 1>&6 echo $ac_n "checking for struct cmsghdr""... $ac_c" 1>&6 -echo "configure:5336: checking for struct cmsghdr" >&5 +echo "configure:5348: checking for struct cmsghdr" >&5 if eval "test \"`echo '$''{'wi_cv_struct_cmsghdr'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5375: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* wi_cv_struct_cmsghdr=yes @@ -5385,13 +5397,13 @@ fi echo $ac_n "checking for msg_control field in struct msghdr""... $ac_c" 1>&6 -echo "configure:5389: checking for msg_control field in struct msghdr" >&5 +echo "configure:5401: checking for msg_control field in struct msghdr" >&5 if eval "test \"`echo '$''{'wi_cv_msghdr_control'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5427: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* wi_cv_msghdr_control=yes @@ -5437,13 +5449,13 @@ fi echo $ac_n "checking for msg_accrights field in struct msghdr""... $ac_c" 1>&6 -echo "configure:5441: checking for msg_accrights field in struct msghdr" >&5 +echo "configure:5453: checking for msg_accrights field in struct msghdr" >&5 if eval "test \"`echo '$''{'wi_cv_msghdr_accrights'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5479: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* wi_cv_msghdr_accrights=yes @@ -5503,17 +5515,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5507: checking for $ac_hdr" >&5 +echo "configure:5519: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5517: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5529: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5541,11 +5553,11 @@ if test "$ac_cv_header_sys_select_h" = yes ; then echo $ac_n "checking if is compatible with ""... $ac_c" 1>&6 -echo "configure:5545: checking if is compatible with " >&5 +echo "configure:5557: checking if is compatible with " >&5 selecth=yes if test "$ac_cv_header_sys_time_h" = yes ; then cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:5581: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* selecth=yes else @@ -5586,6 +5598,354 @@ fi +echo $ac_n "checking whether to enable ipv6""... $ac_c" 1>&6 +echo "configure:5603: checking whether to enable ipv6" >&5 +# Check whether --enable-ipv6 or --disable-ipv6 was given. +if test "${enable_ipv6+set}" = set; then + enableval="$enable_ipv6" + case "$enableval" in + no) + echo "$ac_t""no" 1>&6 + ipv6=no + ;; + *) echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define ENABLE_IPV6 1 +EOF + + ipv6=yes + ;; + esac +else + if test "$cross_compiling" = yes; then + echo "$ac_t""no" 1>&6 + ipv6=no + +else + cat > conftest.$ac_ext < +#include +main() +{ + if (socket(AF_INET6, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} + +EOF +if { (eval echo configure:5642: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define ENABLE_IPV6 1 +EOF + + ipv6=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + echo "$ac_t""no" 1>&6 + ipv6=no +fi +rm -fr conftest* +fi + +fi + + +echo $ac_n "checking for getnameinfo""... $ac_c" 1>&6 +echo "configure:5664: checking for getnameinfo" >&5 +if eval "test \"`echo '$''{'ac_cv_func_getnameinfo'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char getnameinfo(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_getnameinfo) || defined (__stub___getnameinfo) +choke me +#else +getnameinfo(); +#endif + +; return 0; } +EOF +if { (eval echo configure:5692: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_getnameinfo=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_getnameinfo=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'getnameinfo`\" = yes"; then + echo "$ac_t""yes" 1>&6 + + cat >> confdefs.h <<\EOF +#define HAVE_GETNAMEINFO 1 +EOF + +else + echo "$ac_t""no" 1>&6 + + LIBOBJS="$LIBOBJS getnameinfo.o" + LIBSOBJS="$LIBSOBJS getnameinfo.so" + +fi + + +echo $ac_n "checking for getaddrinfo""... $ac_c" 1>&6 +echo "configure:5721: checking for getaddrinfo" >&5 +if eval "test \"`echo '$''{'ac_cv_func_getaddrinfo'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char getaddrinfo(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_getaddrinfo) || defined (__stub___getaddrinfo) +choke me +#else +getaddrinfo(); +#endif + +; return 0; } +EOF +if { (eval echo configure:5749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_getaddrinfo=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_getaddrinfo=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'getaddrinfo`\" = yes"; then + echo "$ac_t""yes" 1>&6 + +echo $ac_n "checking getaddrinfo bug""... $ac_c" 1>&6 +echo "configure:5765: checking getaddrinfo bug" >&5 +if test "$cross_compiling" = yes; then + { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } +else + cat > conftest.$ac_ext < +#include +#include +#include +#include + +main() +{ + int passive, gaierr, inet4 = 0, inet6 = 0; + struct addrinfo hints, *ai, *aitop; + char straddr[INET6_ADDRSTRLEN], strport[16]; + + for (passive = 0; passive <= 1; passive++) { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_flags = passive ? AI_PASSIVE : 0; + hints.ai_socktype = SOCK_STREAM; + if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { + (void)gai_strerror(gaierr); + goto bad; + } + for (ai = aitop; ai; ai = ai->ai_next) { + if (ai->ai_addr == NULL || + ai->ai_addrlen == 0 || + getnameinfo(ai->ai_addr, ai->ai_addrlen, + straddr, sizeof(straddr), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV) != 0) { + goto bad; + } + switch (ai->ai_family) { + case AF_INET: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "0.0.0.0") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "127.0.0.1") != 0) { + goto bad; + } + } + inet4++; + break; + case AF_INET6: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "::") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "::1") != 0) { + goto bad; + } + } + inet6++; + break; + case AF_UNSPEC: + goto bad; + break; + default: + /* another family support? */ + break; + } + } + } + + if (!(inet4 == 0 || inet4 == 2)) + goto bad; + if (!(inet6 == 0 || inet6 == 2)) + goto bad; + + if (aitop) + freeaddrinfo(aitop); + exit(0); + + bad: + if (aitop) + freeaddrinfo(aitop); + exit(1); +} + +EOF +if { (eval echo configure:5859: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + + echo "$ac_t""good" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_GETADDRINFO 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + + echo "$ac_t""buggy" 1>&6 + LIBOBJS="$LIBOBJS getaddrinfo.o" + LIBSOBJS="$LIBSOBJS getaddrinfo.so" +fi +rm -fr conftest* +fi + +else + echo "$ac_t""no" 1>&6 + + LIBOBJS="$LIBOBJS getaddrinfo.o" + LIBSOBJS="$LIBSOBJS getaddrinfo.so" + +fi + + +# check if sockaddr has sa_len member +echo $ac_n "checking if sockaddr has sa_len member""... $ac_c" 1>&6 +echo "configure:5890: checking if sockaddr has sa_len member" >&5 +cat > conftest.$ac_ext < +#include +int main() { +struct sockaddr x; +x.sa_len = 0; +; return 0; } +EOF +if { (eval echo configure:5901: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_SOCKADDR_SA_LEN 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 +fi +rm -f conftest* + +# check if sockaddr_storage has ss_family member +echo $ac_n "checking if sockaddr_storage has ss_family member""... $ac_c" 1>&6 +echo "configure:5918: checking if sockaddr_storage has ss_family member" >&5 +cat > conftest.$ac_ext < +#include +int main() { +struct sockaddr_storage x; +x.__ss_family = 0; +; return 0; } +EOF +if { (eval echo configure:5929: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 +EOF + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "$ac_t""no" 1>&6 + cat >> confdefs.h <<\EOF +#define HAVE_SOCKADDR_STORAGE___SS_FAMILY 1 +EOF + + CPPFLAGS="$CPPFLAGS -D__ss_family=ss_family -D__ss_len=ss_len" +fi +rm -f conftest* + +CPPFLAGS="-I$MAINDIR $CPPFLAGS" if test "${SYS}" = sunos ; then @@ -5594,12 +5954,12 @@ for ac_func in getwd do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5598: checking for $ac_func" >&5 +echo "configure:5958: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5986: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5650,12 +6010,12 @@ for ac_func in getcwd getwd do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5654: checking for $ac_func" >&5 +echo "configure:6014: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6042: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5716,12 +6076,12 @@ for ac_func in fstat64 getdomainname gethostname getpass getpassphrase gnu_get_libc_release gnu_get_libc_version inet_aton inet_ntop llseek lseek64 lstat64 memmove mktime open64 pathconf readlink res_init setlocale setpgid setpgrp setsid setvbuf sigaction sigsetjmp stat64 strcasecmp strcoll strdup strerror strncoll strstr strtoq symlink sysconf sysctl sysinfo syslog uname waitpid do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5720: checking for $ac_func" >&5 +echo "configure:6080: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5771,12 +6131,12 @@ for ac_func in gethostbyaddr_r gethostbyname_r gethostbyname2_r getlogin_r getpwnam_r _posix_getpwnam_r getpwuid_r _posix_getpwuid_r getservbyname_r getservbyport_r gmtime_r localtime_r readdir_r do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5775: checking for $ac_func" >&5 +echo "configure:6135: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5826,7 +6186,7 @@ echo $ac_n "checking what sprintf() returns""... $ac_c" 1>&6 -echo "configure:5830: checking what sprintf() returns" >&5 +echo "configure:6190: checking what sprintf() returns" >&5 if test "$cross_compiling" = yes; then # action if cross compiling @@ -5835,7 +6195,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6219: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -5887,12 +6247,12 @@ for ac_func in snprintf vsnprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5891: checking for $ac_func" >&5 +echo "configure:6251: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5942,10 +6302,10 @@ if test "$ac_cv_func_snprintf" != "no" ; then echo $ac_n "checking if snprintf works correctly""... $ac_c" 1>&6 -echo "configure:5946: checking if snprintf works correctly" >&5 +echo "configure:6306: checking if snprintf works correctly" >&5 if test "$ac_cv_func_snprintf" = "no" ; then echo $ac_n "checking for snprintf in -lsnprintf""... $ac_c" 1>&6 -echo "configure:5949: checking for snprintf in -lsnprintf" >&5 +echo "configure:6309: checking for snprintf in -lsnprintf" >&5 ac_lib_var=`echo snprintf'_'snprintf | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -5953,7 +6313,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsnprintf $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6328: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6005,7 +6365,7 @@ else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6404: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # action if true @@ -6070,7 +6430,7 @@ if test "$ac_cv_func_snprintf" = "no" ; then echo $ac_n "checking for snprintf in -lsnprintf""... $ac_c" 1>&6 -echo "configure:6074: checking for snprintf in -lsnprintf" >&5 +echo "configure:6434: checking for snprintf in -lsnprintf" >&5 ac_lib_var=`echo snprintf'_'snprintf | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -6078,7 +6438,7 @@ ac_save_LIBS="$LIBS" LIBS="-lsnprintf $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6453: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -6122,17 +6482,17 @@ do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:6126: checking for $ac_hdr" >&5 +echo "configure:6486: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:6136: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:6496: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -6161,12 +6521,12 @@ for ac_func in snprintf vsnprintf do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6165: checking for $ac_func" >&5 +echo "configure:6525: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6553: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6224,14 +6584,14 @@ fi echo $ac_n "checking for sigsetjmp and siglongjmp""... $ac_c" 1>&6 -echo "configure:6228: checking for sigsetjmp and siglongjmp" >&5 +echo "configure:6588: checking for sigsetjmp and siglongjmp" >&5 if eval "test \"`echo '$''{'wi_cv_func_sigsetjmp'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:6618: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* wi_cv_func_sigsetjmp=yes @@ -6280,7 +6640,7 @@ fi echo $ac_n "checking whether setpgrp takes no argument""... $ac_c" 1>&6 -echo "configure:6284: checking whether setpgrp takes no argument" >&5 +echo "configure:6644: checking whether setpgrp takes no argument" >&5 if eval "test \"`echo '$''{'ac_cv_func_setpgrp_void'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6288,7 +6648,7 @@ { echo "configure: error: cannot check setpgrp if cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6672: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_setpgrp_void=no else @@ -6332,7 +6692,7 @@ fi echo $ac_n "checking whether setvbuf arguments are reversed""... $ac_c" 1>&6 -echo "configure:6336: checking whether setvbuf arguments are reversed" >&5 +echo "configure:6696: checking whether setvbuf arguments are reversed" >&5 if eval "test \"`echo '$''{'ac_cv_func_setvbuf_reversed'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6340,7 +6700,7 @@ { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < /* If setvbuf has the reversed format, exit 0. */ @@ -6354,7 +6714,7 @@ exit(0); /* Non-reversed systems segv here. */ } EOF -if { (eval echo configure:6358: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:6718: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_setvbuf_reversed=yes else @@ -6398,7 +6758,7 @@ fi echo $ac_n "checking string parameter to waddstr""... $ac_c" 1>&6 -echo "configure:6402: checking string parameter to waddstr" >&5 +echo "configure:6762: checking string parameter to waddstr" >&5 if eval "test \"`echo '$''{'wi_cv_waddstr_str_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6601,9 +6961,9 @@ # maxx or _maxx echo $ac_n "checking whether curses structure has maxx or _maxx field""... $ac_c" 1>&6 -echo "configure:6605: checking whether curses structure has maxx or _maxx field" >&5 +echo "configure:6965: checking whether curses structure has maxx or _maxx field" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:6997: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""maxx" 1>&6 @@ -6656,12 +7016,12 @@ for ac_func in __getcurx __getcury __getmaxx __getmaxy __getbegx __getbegy do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:6660: checking for $ac_func" >&5 +echo "configure:7020: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7048: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -6712,9 +7072,9 @@ # getcurx echo $ac_n "checking for getcurx() functionality in curses library""... $ac_c" 1>&6 -echo "configure:6716: checking for getcurx() functionality in curses library" >&5 +echo "configure:7076: checking for getcurx() functionality in curses library" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7108: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF @@ -6765,9 +7125,9 @@ # getyx echo $ac_n "checking for getyx() functionality in curses library""... $ac_c" 1>&6 -echo "configure:6769: checking for getyx() functionality in curses library" >&5 +echo "configure:7129: checking for getyx() functionality in curses library" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7161: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF @@ -6818,9 +7178,9 @@ # getmaxx echo $ac_n "checking for getmaxx() functionality in curses library""... $ac_c" 1>&6 -echo "configure:6822: checking for getmaxx() functionality in curses library" >&5 +echo "configure:7182: checking for getmaxx() functionality in curses library" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7213: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF @@ -6870,9 +7230,9 @@ # getmaxyx echo $ac_n "checking for getmaxyx() functionality in curses library""... $ac_c" 1>&6 -echo "configure:6874: checking for getmaxyx() functionality in curses library" >&5 +echo "configure:7234: checking for getmaxyx() functionality in curses library" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7265: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF @@ -6922,9 +7282,9 @@ # getbegx echo $ac_n "checking for getbegx() functionality in curses library""... $ac_c" 1>&6 -echo "configure:6926: checking for getbegx() functionality in curses library" >&5 +echo "configure:7286: checking for getbegx() functionality in curses library" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF @@ -6975,9 +7335,9 @@ # getbegyx echo $ac_n "checking for getbegyx() functionality in curses library""... $ac_c" 1>&6 -echo "configure:6979: checking for getbegyx() functionality in curses library" >&5 +echo "configure:7339: checking for getbegyx() functionality in curses library" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF @@ -7027,9 +7387,9 @@ # touchwin echo $ac_n "checking for touchwin() functionality in curses library""... $ac_c" 1>&6 -echo "configure:7031: checking for touchwin() functionality in curses library" >&5 +echo "configure:7391: checking for touchwin() functionality in curses library" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF @@ -7077,9 +7437,9 @@ # beep echo $ac_n "checking for beep() functionality in curses library""... $ac_c" 1>&6 -echo "configure:7081: checking for beep() functionality in curses library" >&5 +echo "configure:7441: checking for beep() functionality in curses library" >&5 cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7469: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* cat >> confdefs.h <<\EOF @@ -7127,12 +7487,12 @@ for ac_func in keypad nodelay curs_set doupdate wnoutrefresh do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7131: checking for $ac_func" >&5 +echo "configure:7491: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7519: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7192,7 +7552,7 @@ echo $ac_n "checking for long file names""... $ac_c" 1>&6 -echo "configure:7196: checking for long file names" >&5 +echo "configure:7556: checking for long file names" >&5 if eval "test \"`echo '$''{'ac_cv_sys_long_file_names'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7236,7 +7596,7 @@ fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:7240: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:7600: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7266,7 +7626,7 @@ # Extract the first word of ""gtar"", so it can be a program name with args. set dummy "gtar"; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7270: checking for $ac_word" >&5 +echo "configure:7630: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TAR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7305,7 +7665,7 @@ # Extract the first word of ""tar"", so it can be a program name with args. set dummy "tar"; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7309: checking for $ac_word" >&5 +echo "configure:7669: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TAR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7353,7 +7713,7 @@ echo $ac_n "checking how to create TAR files""... $ac_c" 1>&6 -echo "configure:7357: checking how to create TAR files" >&5 +echo "configure:7717: checking how to create TAR files" >&5 x="" if [ -x /usr/bin/what ] ; then x=`/usr/bin/what "$TAR" 2>&1 | sed -n 's/.*pax.*/pax/g;/pax/p'` @@ -7380,7 +7740,7 @@ # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7384: checking for $ac_word" >&5 +echo "configure:7744: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7419,7 +7779,7 @@ # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:7423: checking for a BSD compatible install" >&5 +echo "configure:7783: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -7475,7 +7835,7 @@ # Extract the first word of ""pwd"", so it can be a program name with args. set dummy "pwd"; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:7479: checking for $ac_word" >&5 +echo "configure:7839: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_wi_PWD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7512,13 +7872,13 @@ if test "x$use_ccdv" = "xno" ; then echo $ac_n "checking for ccdv""... $ac_c" 1>&6 -echo "configure:7516: checking for ccdv" >&5 +echo "configure:7876: checking for ccdv" >&5 echo "$ac_t""(disabled)" 1>&6 else unset wi_cv_path_ccdv # can't use cache if it was a temp prog last time wi_used_cache_path_ccdv="yes" echo $ac_n "checking for ccdv""... $ac_c" 1>&6 -echo "configure:7522: checking for ccdv" >&5 +echo "configure:7882: checking for ccdv" >&5 if eval "test \"`echo '$''{'wi_cv_path_ccdv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8028,7 +8388,7 @@ echo $ac_n "checking if shell can test for symlinks""... $ac_c" 1>&6 -echo "configure:8032: checking if shell can test for symlinks" >&5 +echo "configure:8392: checking if shell can test for symlinks" >&5 if eval "test \"`echo '$''{'wi_cv_shell_test_symlinks'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8495,6 +8855,8 @@ + + trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure @@ -8661,6 +9023,8 @@ s%@MAKE@%$MAKE%g s%@Z30@%$Z30%g s%@LIBSET@%$LIBSET%g +s%@LIBOBJS@%$LIBOBJS%g +s%@LIBSOBJS@%$LIBSOBJS%g s%@MAINDIR@%$MAINDIR%g s%@NCFTP_VERSION@%$NCFTP_VERSION%g s%@LIBNCFTP_VERSION@%$LIBNCFTP_VERSION%g Index: ncftp3/configure.in diff -u ncftp3/configure.in:1.1.1.11 ncftp3/configure.in:1.20 --- ncftp3/configure.in:1.1.1.11 Thu Jan 8 19:50:58 2004 +++ ncftp3/configure.in Thu Jan 8 20:09:32 2004 @@ -11,8 +11,6 @@ dnl AC_ARG_WITH(readline,[ --without-readline do not try to find and use the readline library],nc_cv_readline=$withval,nc_cv_readline=yes) wi_ARG_WITH_SOCKS5 - - dnl --------------------------------------------------------------------------- dnl Environment and compiler settings. dnl --------------------------------------------------------------------------- @@ -99,6 +97,172 @@ wi_HEADER_SYS_SELECT_H dnl # sio +dnl --------------------------------------------------------------------------- +dnl Checks for IPv6. +dnl --------------------------------------------------------------------------- +dnl +AC_MSG_CHECKING([whether to enable ipv6]) +AC_ARG_ENABLE(ipv6, +[ --enable-ipv6 Enable ipv6 (with ipv4) support + --disable-ipv6 Disable ipv6 support], +[ case "$enableval" in + no) + AC_MSG_RESULT(no) + ipv6=no + ;; + *) AC_MSG_RESULT(yes) + AC_DEFINE(ENABLE_IPV6) + ipv6=yes + ;; + esac ], + + AC_TRY_RUN([ /* AF_INET6 avalable check */ +#define INET6 +#include +#include +main() +{ + if (socket(AF_INET6, SOCK_STREAM, 0) < 0) + exit(1); + else + exit(0); +} +], + AC_MSG_RESULT(yes) + AC_DEFINE(ENABLE_IPV6) + ipv6=yes, + AC_MSG_RESULT(no) + ipv6=no, + AC_MSG_RESULT(no) + ipv6=no +)) + +AC_CHECK_FUNC(getnameinfo, [ + AC_DEFINE(HAVE_GETNAMEINFO)], [ + LIBOBJS="$LIBOBJS getnameinfo.o" + LIBSOBJS="$LIBSOBJS getnameinfo.so" +]) + +AC_CHECK_FUNC(getaddrinfo, [ +AC_MSG_CHECKING(getaddrinfo bug) +AC_TRY_RUN([ +#include +#include +#include +#include +#include + +main() +{ + int passive, gaierr, inet4 = 0, inet6 = 0; + struct addrinfo hints, *ai, *aitop; + char straddr[INET6_ADDRSTRLEN], strport[16]; + + for (passive = 0; passive <= 1; passive++) { + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; + hints.ai_flags = passive ? AI_PASSIVE : 0; + hints.ai_socktype = SOCK_STREAM; + if ((gaierr = getaddrinfo(NULL, "54321", &hints, &aitop)) != 0) { + (void)gai_strerror(gaierr); + goto bad; + } + for (ai = aitop; ai; ai = ai->ai_next) { + if (ai->ai_addr == NULL || + ai->ai_addrlen == 0 || + getnameinfo(ai->ai_addr, ai->ai_addrlen, + straddr, sizeof(straddr), strport, sizeof(strport), + NI_NUMERICHOST|NI_NUMERICSERV) != 0) { + goto bad; + } + switch (ai->ai_family) { + case AF_INET: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "0.0.0.0") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "127.0.0.1") != 0) { + goto bad; + } + } + inet4++; + break; + case AF_INET6: + if (strcmp(strport, "54321") != 0) { + goto bad; + } + if (passive) { + if (strcmp(straddr, "::") != 0) { + goto bad; + } + } else { + if (strcmp(straddr, "::1") != 0) { + goto bad; + } + } + inet6++; + break; + case AF_UNSPEC: + goto bad; + break; + default: + /* another family support? */ + break; + } + } + } + + if (!(inet4 == 0 || inet4 == 2)) + goto bad; + if (!(inet6 == 0 || inet6 == 2)) + goto bad; + + if (aitop) + freeaddrinfo(aitop); + exit(0); + + bad: + if (aitop) + freeaddrinfo(aitop); + exit(1); +} +], [ + AC_MSG_RESULT(good) + AC_DEFINE(HAVE_GETADDRINFO)], [ + AC_MSG_RESULT(buggy) + LIBOBJS="$LIBOBJS getaddrinfo.o" + LIBSOBJS="$LIBSOBJS getaddrinfo.so"])], [ + LIBOBJS="$LIBOBJS getaddrinfo.o" + LIBSOBJS="$LIBSOBJS getaddrinfo.so" +]) + +# check if sockaddr has sa_len member +AC_MSG_CHECKING(if sockaddr has sa_len member) +AC_TRY_COMPILE([#include +#include ], +[struct sockaddr x; +x.sa_len = 0;], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SOCKADDR_SA_LEN), + AC_MSG_RESULT(no)) + +# check if sockaddr_storage has ss_family member +AC_MSG_CHECKING(if sockaddr_storage has ss_family member) +AC_TRY_COMPILE([#include +#include ], +[struct sockaddr_storage x; +x.__ss_family = 0;], + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_SOCKADDR_STORAGE_SS_FAMILY), + AC_MSG_RESULT(no) + AC_DEFINE(HAVE_SOCKADDR_STORAGE___SS_FAMILY) + CPPFLAGS="$CPPFLAGS -D__ss_family=ss_family -D__ss_len=ss_len") + +CPPFLAGS="-I$MAINDIR $CPPFLAGS" dnl --------------------------------------------------------------------------- dnl Checks for library functions. @@ -222,6 +386,8 @@ AC_SUBST(MAKE) AC_SUBST(Z30) AC_SUBST(LIBSET) +AC_SUBST(LIBOBJS) +AC_SUBST(LIBSOBJS) AC_SUBST(MAINDIR) AC_SUBST(NCFTP_VERSION) AC_SUBST(LIBNCFTP_VERSION) Index: ncftp3/Strn/tester Index: ncftp3/autoconf/acconfig.h diff -u ncftp3/autoconf/acconfig.h:1.1.1.9 ncftp3/autoconf/acconfig.h:1.6 --- ncftp3/autoconf/acconfig.h:1.1.1.9 Tue Jul 20 00:01:36 2004 +++ ncftp3/autoconf/acconfig.h Tue Jul 20 00:16:53 2004 @@ -224,6 +224,24 @@ /* Define if you have the wait3 system call. */ #undef HAVE_WAIT3 +/* Define if you have the getaddrinfo function. */ +#undef HAVE_GETADDRINFO + +/* Define if you have the getaddrname function. */ +#undef HAVE_GETNAMEINFO + +/* Define if sockaddr has sa_len member */ +#undef HAVE_SOCKADDR_SA_LEN + +/* Define if sockaddr_storage has ss_family member */ +#undef HAVE_SOCKADDR_STORAGE_SS_FAMILY + +/* Define if sockaddr_storage has __ss_family member */ +#undef HAVE_SOCKADDR_STORAGE___SS_FAMILY + +/* Define if you want IPv6 support. */ +#undef ENABLE_IPV6 + /* Define as __inline if that's what the C compiler calls it. */ #undef inline Index: ncftp3/libncftp/addrinfo.h diff -u /dev/null ncftp3/libncftp/addrinfo.h:1.2 --- /dev/null Wed Jul 28 23:18:38 2004 +++ ncftp3/libncftp/addrinfo.h Tue Nov 20 02:53:11 2001 @@ -0,0 +1,104 @@ +/* + * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef HAVE_GETADDRINFO + +/* + * Error return codes from getaddrinfo() + */ +#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */ +#define EAI_AGAIN 2 /* temporary failure in name resolution */ +#define EAI_BADFLAGS 3 /* invalid value for ai_flags */ +#define EAI_FAIL 4 /* non-recoverable failure in name resolution */ +#define EAI_FAMILY 5 /* ai_family not supported */ +#define EAI_MEMORY 6 /* memory allocation failure */ +#define EAI_NODATA 7 /* no address associated with hostname */ +#define EAI_NONAME 8 /* hostname nor servname provided, or not known */ +#define EAI_SERVICE 9 /* servname not supported for ai_socktype */ +#define EAI_SOCKTYPE 10 /* ai_socktype not supported */ +#define EAI_SYSTEM 11 /* system error returned in errno */ +#define EAI_BADHINTS 12 +#define EAI_PROTOCOL 13 +#define EAI_MAX 14 + +/* + * Flag values for getaddrinfo() + */ +#define AI_PASSIVE 0x00000001 /* get address to use bind() */ +#define AI_CANONNAME 0x00000002 /* fill ai_canonname */ +#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */ +/* valid flags for addrinfo */ +#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST) + +#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */ +#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */ +#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */ +#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */ +/* special recommended flags for getipnodebyname */ +#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG) + +/* + * Constants for getnameinfo() + */ +#define NI_MAXHOST 1025 +#define NI_MAXSERV 32 + +/* + * Flag values for getnameinfo() + */ +#define NI_NOFQDN 0x00000001 +#define NI_NUMERICHOST 0x00000002 +#define NI_NAMEREQD 0x00000004 +#define NI_NUMERICSERV 0x00000008 +#define NI_DGRAM 0x00000010 + +struct addrinfo { + int ai_flags; /* AI_PASSIVE, AI_CANONNAME */ + int ai_family; /* PF_xxx */ + int ai_socktype; /* SOCK_xxx */ + int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */ + size_t ai_addrlen; /* length of ai_addr */ + char *ai_canonname; /* canonical name for hostname */ + struct sockaddr *ai_addr; /* binary address */ + struct addrinfo *ai_next; /* next structure in linked list */ +}; + +struct sockaddr_storage { +#ifdef HAVE_SOCKADDR_SA_LEN + u_int8_t ss_len; /* address length */ + u_int8_t ss_family; /* address family */ +#else + u_int16_t ss_family; +#endif + u_int8_t fill[126]; +}; + +extern void freehostent __P((struct hostent *)); +extern char *gai_strerror __P((int)); +#endif Index: ncftp3/libncftp/ftp.c diff -u ncftp3/libncftp/ftp.c:1.1.1.16 ncftp3/libncftp/ftp.c:1.49 --- ncftp3/libncftp/ftp.c:1.1.1.16 Wed Jul 28 23:10:58 2004 +++ ncftp3/libncftp/ftp.c Wed Jul 28 23:18:12 2004 @@ -48,6 +48,17 @@ # define DisposeSocket(a) close(a) #endif +#ifndef HAVE_SOCKADDR_SA_LEN +#ifndef SA_LEN +#ifdef ENABLE_IPV6 +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#else /* ENABLE_IPV6 */ +#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_IPV6 */ +#endif /* SA_LEN */ +#endif /* HAVE_SOCKADDR_SA_LEN */ void FTPCloseControlConnection(const FTPCIPtr cip) @@ -75,9 +86,9 @@ static int -GetSocketAddress(const FTPCIPtr cip, int sockfd, struct sockaddr_in *saddr) +GetSocketAddress(const FTPCIPtr cip, int sockfd, struct sockaddr *saddr) { - sockaddr_size_t len = (sockaddr_size_t) sizeof (struct sockaddr_in); + sockaddr_size_t len = (sockaddr_size_t) sizeof (struct sockaddr_storage); int result = 0; if (getsockname(sockfd, (struct sockaddr *)saddr, &len) < 0) { @@ -111,16 +122,16 @@ int OpenControlConnection(const FTPCIPtr cip, char *host, unsigned int port) { - struct in_addr ip_address; int err = 0; int result; int oerrno; volatile int sockfd = -1; volatile int sock2fd = -1; ResponsePtr rp = NULL; - char **volatile curaddr; - int hpok; - struct hostent hp; + struct addrinfo hints; + struct addrinfo *res, *res0; + int error; + char buf[NI_MAXHOST]; char *volatile fhost; unsigned int fport; #ifndef NO_SIGNALS @@ -154,27 +165,17 @@ cip->cin = NULL; cip->cout = NULL; - /* Make sure we use network byte-order. */ - fport = (unsigned int) htons((unsigned short) fport); - - cip->servCtlAddr.sin_port = (unsigned short) fport; - - if (GetHostEntry(&hp, fhost, &ip_address, cip->buf, cip->bufSize) != 0) { - hpok = 0; - /* Okay, no Host entry, but maybe we have a numeric address - * in ip_address we can try. - */ - if (ip_address.s_addr == INADDR_NONE) { - FTPLogError(cip, kDontPerror, "%s: unknown host.\n", fhost); - cip->errNo = kErrHostUnknown; - return (kErrHostUnknown); - } - cip->servCtlAddr.sin_family = AF_INET; - cip->servCtlAddr.sin_addr.s_addr = ip_address.s_addr; - } else { - hpok = 1; - cip->servCtlAddr.sin_family = hp.h_addrtype; - /* We'll fill in the rest of the structure below. */ + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_CANONNAME; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = IPPROTO_TCP; + sprintf(buf, "%d\0", fport); + error = getaddrinfo(fhost, buf, &hints, &res0); + if (error) { + FTPLogError(cip, kDontPerror, "%s: %s.\n", fhost, gai_strerror(error)); + cip->errNo = kErrHostUnknown; + return (kErrHostUnknown); } /* After obtaining a socket, try to connect it to a remote @@ -183,13 +184,14 @@ * every address in the list from the host entry. */ - if (hpok == 0) { - /* Since we're given a single raw address, and not a host entry, - * we can only try this one address and not any other addresses - * that could be present for a site with a host entry. - */ - - if ((sockfd = socket(cip->servCtlAddr.sin_family, SOCK_STREAM, 0)) < 0) { + /* We can try each address in the list. We'll quit when we + * run out of addresses to try or get a successful connection. + */ + for (res = res0; res; res = res->ai_next) { + (void) memcpy(&cip->servCtlAddr, res->ai_addr, (size_t)res->ai_addrlen); + if ((sockfd = socket(cip->servCtlAddr.ss_family, SOCK_STREAM, 0)) < 0) { + if (res0->ai_next) + continue; FTPLogError(cip, kDoPerror, "Could not get a socket.\n"); cip->errNo = kErrNewStreamSocket; return (kErrNewStreamSocket); @@ -203,14 +205,14 @@ (void) SetSocketBufSize(sockfd, cip->ctrlSocketRBufSize, cip->ctrlSocketSBufSize); #ifdef NO_SIGNALS - err = SConnect(sockfd, &cip->servCtlAddr, (int) cip->connTimeout); + err = SConnect(sockfd, (struct sockaddr *)&cip->servCtlAddr, (int) cip->connTimeout); - if (err < 0) { - oerrno = errno; - (void) SClose(sockfd, 3); - errno = oerrno; - sockfd = -1; - } + if (err == 0) + break; + oerrno = errno; + (void) SClose(sockfd, 3); + errno = oerrno; + sockfd = -1; #else /* NO_SIGNALS */ osigint = (volatile FTPSigProc) signal(SIGINT, CancelConnect); if (cip->connTimeout > 0) { @@ -239,6 +241,8 @@ Error(vcip, kDontPerror, "Connection attempt canceled.\n"); (void) kill(getpid(), SIGINT); } else if (gGotSig == SIGALRM) { + if (res0->ai_next) + continue; result = vcip->errNo = kErrConnectRetryableErr; Error(vcip, kDontPerror, "Connection attempt timed-out.\n"); (void) kill(getpid(), SIGALRM); @@ -247,9 +251,14 @@ Error(vcip, kDontPerror, "Connection attempt failed due to an unexpected signal (%d).\n", gGotSig); } return (result); - } else { + } else { err = connect(sockfd, (struct sockaddr *) &cip->servCtlAddr, - (int) sizeof (cip->servCtlAddr)); +#ifdef HAVE_SOCKADDR_SA_LEN + cip->servCtlAddr.ss_len +#else + SA_LEN((struct sockaddr *)&cip->servCtlAddr) +#endif + ); if (cip->connTimeout > 0) { (void) alarm(0); (void) signal(SIGALRM, (FTPSigProc) osigalrm); @@ -257,99 +266,13 @@ (void) signal(SIGINT, (FTPSigProc) osigint); } - if (err < 0) { - oerrno = errno; - (void) DisposeSocket(sockfd); - errno = oerrno; - sockfd = -1; - } -#endif /* NO_SIGNALS */ - } else { - /* We can try each address in the list. We'll quit when we - * run out of addresses to try or get a successful connection. - */ - for (curaddr = hp.h_addr_list; *curaddr != NULL; curaddr++) { - if ((sockfd = socket(cip->servCtlAddr.sin_family, SOCK_STREAM, 0)) < 0) { - FTPLogError(cip, kDoPerror, "Could not get a socket.\n"); - cip->errNo = kErrNewStreamSocket; - return (kErrNewStreamSocket); - } - /* This could overwrite the address field in the structure, - * but this is okay because the structure has a junk field - * just for this purpose. - */ - (void) memcpy(&cip->servCtlAddr.sin_addr, *curaddr, (size_t) hp.h_length); - - /* This doesn't do anything if you left these - * at their defaults (zero). Otherwise it - * tries to set the buffer size to the - * size specified. - */ - (void) SetSocketBufSize(sockfd, cip->ctrlSocketRBufSize, cip->ctrlSocketSBufSize); - -#ifdef NO_SIGNALS - err = SConnect(sockfd, &cip->servCtlAddr, (int) cip->connTimeout); - - if (err == 0) - break; - oerrno = errno; - (void) SClose(sockfd, 3); - errno = oerrno; - sockfd = -1; -#else /* NO_SIGNALS */ - - osigint = (volatile FTPSigProc) signal(SIGINT, CancelConnect); - if (cip->connTimeout > 0) { - osigalrm = (volatile FTPSigProc) signal(SIGALRM, CancelConnect); - (void) alarm(cip->connTimeout); - } - - vcip = cip; -#ifdef HAVE_SIGSETJMP - sj = sigsetjmp(gCancelConnectJmp, 1); -#else - sj = setjmp(gCancelConnectJmp); -#endif /* HAVE_SIGSETJMP */ - - if (sj != 0) { - /* Interrupted by a signal. */ - (void) DisposeSocket(sockfd); - (void) signal(SIGINT, (FTPSigProc) osigint); - if (vcip->connTimeout > 0) { - (void) alarm(0); - (void) signal(SIGALRM, (FTPSigProc) osigalrm); - } - if (gGotSig == SIGINT) { - result = vcip->errNo = kErrConnectMiscErr; - Error(vcip, kDontPerror, "Connection attempt canceled.\n"); - (void) kill(getpid(), SIGINT); - } else if (gGotSig == SIGALRM) { - result = vcip->errNo = kErrConnectRetryableErr; - Error(vcip, kDontPerror, "Connection attempt timed-out.\n"); - (void) kill(getpid(), SIGALRM); - } else { - result = vcip->errNo = kErrConnectMiscErr; - Error(vcip, kDontPerror, "Connection attempt failed due to an unexpected signal (%d).\n", gGotSig); - } - return (result); - } else { - err = connect(sockfd, (struct sockaddr *) &cip->servCtlAddr, - (int) sizeof (cip->servCtlAddr)); - if (cip->connTimeout > 0) { - (void) alarm(0); - (void) signal(SIGALRM, (FTPSigProc) osigalrm); - } - (void) signal(SIGINT, (FTPSigProc) osigint); - } - - if (err == 0) - break; - oerrno = errno; - (void) DisposeSocket(sockfd); - errno = oerrno; - sockfd = -1; + if (err == 0) + break; + oerrno = errno; + (void) DisposeSocket(sockfd); + errno = oerrno; + sockfd = -1; #endif /* NO_SIGNALS */ - } } if (err < 0) { @@ -408,7 +331,7 @@ } /* Get our end of the socket address for later use. */ - if ((result = GetSocketAddress(cip, sockfd, &cip->ourCtlAddr)) < 0) + if ((result = GetSocketAddress(cip, sockfd, (struct sockaddr *)&cip->ourCtlAddr)) < 0) goto fatal; /* We want Out-of-band data to appear in the regular stream, @@ -479,11 +402,20 @@ #endif #endif /* NO_SIGNALS */ - InetNtoA(cip->ip, &cip->servCtlAddr.sin_addr, sizeof(cip->ip)); - if ((hpok == 0) || (hp.h_name == NULL)) + getnameinfo((struct sockaddr*)&cip->servCtlAddr, +#ifdef HAVE_SOCKADDR_SA_LEN + cip->servCtlAddr.ss_len, +#else + SA_LEN((struct sockaddr *)&cip->servCtlAddr), +#endif + buf, sizeof(buf), NULL, 0, NI_NUMERICHOST); + (void) STRNCPY(cip->ip, buf); + if ((res0 == NULL) || (res0->ai_canonname == NULL)) (void) STRNCPY(cip->actualHost, fhost); else - (void) STRNCPY(cip->actualHost, (char *) hp.h_name); + (void) STRNCPY(cip->actualHost, (char *) res0->ai_canonname); + freeaddrinfo(res0); + res0 = NULL; /* Read the startup message from the server. */ rp = InitResponse(); @@ -587,6 +519,10 @@ CloseFile(&cip->cout); cip->ctrlSocketR = kClosedFileDescriptor; cip->ctrlSocketW = kClosedFileDescriptor; + if (res0) { + freeaddrinfo(res0); + res0 = NULL; + } return (result); } /* OpenControlConnection */ @@ -680,11 +616,15 @@ int -FTPSendPort(const FTPCIPtr cip, struct sockaddr_in *saddr) +FTPSendPort(const FTPCIPtr cip, struct sockaddr *saddr) { char *a, *p; int result; ResponsePtr rp; + struct sockaddr_in *saddr4; +#ifdef ENABLE_IPV6 + struct sockaddr_in6 *saddr6; +#endif rp = InitResponse(); if (rp == NULL) { @@ -693,16 +633,46 @@ return (cip->errNo); } - /* These will point to data in network byte order. */ - a = (char *) &saddr->sin_addr; - p = (char *) &saddr->sin_port; #define UC(x) (int) (((int) x) & 0xff) +#ifdef ENABLE_IPV6 + if (saddr->sa_family == AF_INET6) { + char host[NI_MAXHOST]; + char port[NI_MAXSERV]; + + getnameinfo(saddr, sizeof(struct sockaddr_in6), host, sizeof(host), + port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); + + saddr6 = (struct sockaddr_in6 *)saddr; + /* These will point to data in network byte order. */ + a = (char *) &saddr6->sin6_addr; + p = (char *) &saddr6->sin6_port; + /* Need to tell the other side which host (the address) and + * which process (port) on that host to send data to. + */ + result = RCmd(cip, rp, "EPRT |2|%s|%s|", host, port); + if (result != 2) { + result = RCmd(cip, rp, "LPRT 6,16,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,2,%d,%d", + UC(a[ 0]), UC(a[ 1]), UC(a[ 2]), UC(a[ 3]), + UC(a[ 4]), UC(a[ 5]), UC(a[ 6]), UC(a[ 7]), + UC(a[ 8]), UC(a[ 9]), UC(a[10]), UC(a[11]), + UC(a[12]), UC(a[13]), UC(a[14]), UC(a[15]), + UC(p[0]), UC(p[1])); + } + } else { +#endif + saddr4 = (struct sockaddr_in *)saddr; + /* These will point to data in network byte order. */ + a = (char *) &saddr4->sin_addr; + p = (char *) &saddr4->sin_port; - /* Need to tell the other side which host (the address) and - * which process (port) on that host to send data to. - */ - result = RCmd(cip, rp, "PORT %d,%d,%d,%d,%d,%d", - UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), UC(p[0]), UC(p[1])); + /* Need to tell the other side which host (the address) and + * which process (port) on that host to send data to. + */ + result = RCmd(cip, rp, "PORT %d,%d,%d,%d,%d,%d", + UC(a[0]), UC(a[1]), UC(a[2]), UC(a[3]), UC(p[0]), UC(p[1])); +#ifdef ENABLE_IPV6 + } +#endif DoneWithResponse(cip, rp); if (result < 0) { @@ -719,13 +689,18 @@ int -FTPSendPassive(const FTPCIPtr cip, struct sockaddr_in *saddr, int *weird) +FTPSendPassive(const FTPCIPtr cip, struct sockaddr *saddr, int *weird) { ResponsePtr rp; - int i[6], j; - unsigned char n[6]; + int i[18], j; + unsigned char n[18]; char *cp; int result; + struct sockaddr_in *saddr4 = (struct sockaddr_in *)saddr; +#ifdef ENABLE_IPV6 + struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *)saddr; +#endif + unsigned short port; rp = InitResponse(); if (rp == NULL) { @@ -734,56 +709,162 @@ return (cip->errNo); } - result = RCmd(cip, rp, "PASV"); - if (result < 0) - goto done; - - if (rp->codeType != 2) { - /* Didn't understand or didn't want passive port selection. */ - cip->errNo = result = kErrPASVFailed; - goto done; - } - - /* The other side returns a specification in the form of - * an internet address as the first four integers (each - * integer stands for 8-bits of the real 32-bit address), - * and two more integers for the port (16-bit port). - * - * It should give us something like: - * "Entering Passive Mode (129,93,33,1,10,187)", so look for - * digits with sscanf() starting 24 characters down the string. - */ + result = RCmd(cip, rp, "EPSV"); + if (result != 2) + goto next; + + if (rp->codeType != 2) + goto next; + for (cp = rp->msg.first->line; ; cp++) { if (*cp == '\0') { - FTPLogError(cip, kDontPerror, "Cannot parse PASV response: %s\n", rp->msg.first->line); - goto done; + FTPLogError(cip, kDontPerror, "Cannot parse EPSV response: %s\n", rp->msg.first->line); + goto next; } if (isdigit((int) *cp)) break; } + if (sscanf(cp, "%hd|", &port) != 1) { + FTPLogError(cip, kDontPerror, "Cannot parse EPSV response: %s\n", rp->msg.first->line); + goto next; + } - if (sscanf(cp, "%d,%d,%d,%d,%d,%d", - &i[0], &i[1], &i[2], &i[3], &i[4], &i[5]) != 6) { - FTPLogError(cip, kDontPerror, "Cannot parse PASV response: %s\n", rp->msg.first->line); - goto done; + +#ifdef ENABLE_IPV6 + if (saddr->sa_family == AF_INET6) { + saddr6->sin6_addr = + ((struct sockaddr_in6 *)&cip->servCtlAddr)->sin6_addr; + saddr6->sin6_port = htons(port); + } else { +#endif + saddr4->sin_addr = + ((struct sockaddr_in *)&cip->servCtlAddr)->sin_addr; + saddr4->sin_port = htons(port); +#ifdef ENABLE_IPV6 } +#endif + goto done; - if (weird != (int *) 0) - *weird = 0; - - for (j=0; j<6; j++) { - /* Some ftp servers return bogus port octets, such as - * boombox.micro.umn.edu. Let the caller know if we got a - * weird looking octet. - */ - if (((i[j] < 0) || (i[j] > 255)) && (weird != (int *) 0)) - *weird = *weird + 1; - n[j] = (unsigned char) (i[j] & 0xff); + next: + rp = InitResponse(); + if (rp == NULL) { + FTPLogError(cip, kDontPerror, "Malloc failed.\n"); + cip->errNo = kErrMallocFailed; + return (cip->errNo); } - (void) memcpy(&saddr->sin_addr, &n[0], (size_t) 4); - (void) memcpy(&saddr->sin_port, &n[4], (size_t) 2); +#ifdef ENABLE_IPV6 + if (saddr->sa_family == AF_INET6) { + int af, hal, pal; + + result = RCmd(cip, rp, "LPSV"); + if (result < 0) + goto done; + + if (rp->codeType != 2) { + /* Didn't understand or didn't want passive port selection. */ + cip->errNo = result = kErrPASVFailed; + goto done; + } + + /* The other side returns a specification in the form of + * an internet address as the first four integers (each + * integer stands for 8-bits of the real 32-bit address), + * and two more integers for the port (16-bit port). + * + * It should give us something like: + * "Entering Passive Mode (129,93,33,1,10,187)", so look for + * digits with sscanf() starting 24 characters down the string. + */ + for (cp = rp->msg.first->line; ; cp++) { + if (*cp == '\0') { + FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line); + goto done; + } + if (isdigit((int) *cp)) + break; + } + + if (sscanf(cp, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", + &af, &hal, + &i[ 0], &i[ 1], &i[ 2], &i[ 3], + &i[ 4], &i[ 5], &i[ 6], &i[ 7], + &i[ 8], &i[ 9], &i[10], &i[11], + &i[12], &i[13], &i[14], &i[15], + &pal, + &i[16], &i[17]) != 21) { + FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line); + goto done; + } + if (af != 6 || hal != 16 || pal != 2) { + FTPLogError(cip, kDontPerror, "Cannot parse LPSV response: %s\n", rp->msg.first->line); + goto done; + } + + for (j=0, *weird = 0; j<18; j++) { + /* Some ftp servers return bogus port octets, such as + * boombox.micro.umn.edu. Let the caller know if we got a + * weird looking octet. + */ + if ((i[j] < 0) || (i[j] > 255)) + *weird = *weird + 1; + n[j] = (unsigned char) (i[j] & 0xff); + } + (void) memcpy(&saddr6->sin6_addr, &n[ 0], (size_t) 16); + (void) memcpy(&saddr6->sin6_port, &n[16], (size_t) 2); + } else { +#endif + result = RCmd(cip, rp, "PASV"); + if (result < 0) + goto done; + + if (rp->codeType != 2) { + /* Didn't understand or didn't want passive port selection. */ + cip->errNo = result = kErrPASVFailed; + goto done; + } + /* The other side returns a specification in the form of + * an internet address as the first four integers (each + * integer stands for 8-bits of the real 32-bit address), + * and two more integers for the port (16-bit port). + * + * It should give us something like: + * "Entering Passive Mode (129,93,33,1,10,187)", so look for + * digits with sscanf() starting 24 characters down the string. + */ + for (cp = rp->msg.first->line; ; cp++) { + if (*cp == '\0') { + FTPLogError(cip, kDontPerror, "Cannot parse PASV response: %s\n", rp->msg.first->line); + goto done; + } + if (isdigit((int) *cp)) + break; + } + + if (sscanf(cp, "%d,%d,%d,%d,%d,%d", + &i[0], &i[1], &i[2], &i[3], &i[4], &i[5]) != 6) { + FTPLogError(cip, kDontPerror, "Cannot parse PASV response: %s\n", rp->msg.first->line); + goto done; + } + + if (weird != (int *) 0) + *weird = 0; + + for (j=0; j<6; j++) { + /* Some ftp servers return bogus port octets, such as + * boombox.micro.umn.edu. Let the caller know if we got a + * weird looking octet. + */ + if (((i[j] < 0) || (i[j] > 255)) && (weird != (int *) 0)) + *weird = *weird + 1; + n[j] = (unsigned char) (i[j] & 0xff); + } + (void) memcpy(&saddr4->sin_addr, &n[0], (size_t) 4); + (void) memcpy(&saddr4->sin_port, &n[4], (size_t) 2); +#ifdef ENABLE_IPV6 + } +#endif result = kNoErr; done: DoneWithResponse(cip, rp); @@ -794,30 +875,45 @@ static int -BindToEphemeralPortNumber(int sockfd, struct sockaddr_in *addrp, int ephemLo, int ephemHi) +BindToEphemeralPortNumber(int sockfd, struct sockaddr *addrp, int ephemLo, int ephemHi) { int i; int result; int rangesize; unsigned short port; - addrp->sin_family = AF_INET; if (((int) ephemLo == 0) || ((int) ephemLo >= (int) ephemHi)) { /* Do it the normal way. System will * pick one, typically in the range * of 1024-4999. */ - addrp->sin_port = 0; /* Let system pick one. */ - - result = bind(sockfd, (struct sockaddr *) addrp, sizeof(struct sockaddr_in)); +#ifdef ENABLE_IPV6 + if (addrp->sa_family == AF_INET6) + ((struct sockaddr_in6 *)addrp)->sin6_port = 0; /* Let system pick one. */ + else +#endif + ((struct sockaddr_in *)addrp)->sin_port = 0; /* Let system pick one. */ +#ifdef HAVE_SOCKADDR_SA_LEN + result = bind(sockfd, addrp, addrp->sa_len); +#else + result = bind(sockfd, addrp, SA_LEN(addrp)); +#endif } else { rangesize = (int) ((int) ephemHi - (int) ephemLo); result = 0; for (i=0; i<10; i++) { port = (unsigned short) (((int) rand() % rangesize) + (int) ephemLo); - addrp->sin_port = htons(port); - - result = bind(sockfd, (struct sockaddr *) addrp, sizeof(struct sockaddr_in)); +#ifdef ENABLE_IPV6 + if (addrp->sa_family == AF_INET6) + ((struct sockaddr_in6 *)addrp)->sin6_port = htons(port); + else +#endif + ((struct sockaddr_in *)addrp)->sin_port = htons(port); +#ifdef HAVE_SOCKADDR_SA_LEN + result = bind(sockfd, addrp, addrp->sa_len); +#else + result = bind(sockfd, addrp, SA_LEN(addrp)); +#endif if (result == 0) break; if ((errno != 999) @@ -854,7 +950,11 @@ result = 0; CloseDataConnection(cip); /* In case we didn't before... */ +#ifdef ENABLE_IPV6 + dataSocket = socket(cip->ourCtlAddr.ss_family, SOCK_STREAM, 0); +#else dataSocket = socket(AF_INET, SOCK_STREAM, 0); +#endif if (dataSocket < 0) { FTPLogError(cip, kDoPerror, "Could not get a data socket.\n"); result = kErrNewStreamSocket; @@ -885,7 +985,6 @@ if ((cip->hasPASV == kCommandNotAvailable) || (mode == kSendPortMode)) { tryPort: cip->ourDataAddr = cip->ourCtlAddr; - cip->ourDataAddr.sin_family = AF_INET; #ifdef HAVE_LIBSOCKS cip->ourDataAddr.sin_port = 0; @@ -893,7 +992,7 @@ (int) sizeof (cip->ourDataAddr), cip->servCtlAddr.sin_addr.s_addr) < 0) #else - if (BindToEphemeralPortNumber(dataSocket, &cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0) + if (BindToEphemeralPortNumber(dataSocket, (struct sockaddr *)&cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0) #endif { FTPLogError(cip, kDoPerror, "Could not bind the data socket"); @@ -905,7 +1004,7 @@ /* Need to do this so we can figure out which port the system * gave to us. */ - if ((result = GetSocketAddress(cip, dataSocket, &cip->ourDataAddr)) < 0) + if ((result = GetSocketAddress(cip, dataSocket, (struct sockaddr *)&cip->ourDataAddr)) < 0) goto bad; if (listen(dataSocket, 1) < 0) { @@ -915,7 +1014,7 @@ goto bad; } - if ((result = FTPSendPort(cip, &cip->ourDataAddr)) < 0) + if ((result = FTPSendPort(cip, (struct sockaddr *)&cip->ourDataAddr)) < 0) goto bad; cip->dataPortMode = kSendPortMode; @@ -923,11 +1022,9 @@ /* Passive mode. Let the other side decide where to send. */ cip->servDataAddr = cip->servCtlAddr; - cip->servDataAddr.sin_family = AF_INET; cip->ourDataAddr = cip->ourCtlAddr; - cip->ourDataAddr.sin_family = AF_INET; - if (FTPSendPassive(cip, &cip->servDataAddr, &weirdPort) < 0) { + if (FTPSendPassive(cip, (struct sockaddr *)&cip->servDataAddr, &weirdPort) < 0) { FTPLogError(cip, kDontPerror, "Passive mode refused.\n"); cip->hasPASV = kCommandNotAvailable; @@ -951,7 +1048,7 @@ (int) sizeof (cip->ourDataAddr), cip->servCtlAddr.sin_addr.s_addr) < 0) #else - if (BindToEphemeralPortNumber(dataSocket, &cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0) + if (BindToEphemeralPortNumber(dataSocket, (struct sockaddr *)&cip->ourDataAddr, (int) cip->ephemLo, (int) cip->ephemHi) < 0) #endif { FTPLogError(cip, kDoPerror, "Could not bind the data socket"); @@ -959,14 +1056,25 @@ cip->errNo = kErrBindDataSocket; goto bad; } + + /* Need to do this so we can figure out which port the system + * gave to us. + */ + if ((result = GetSocketAddress(cip, dataSocket, (struct sockaddr *)&cip->ourDataAddr)) < 0) + goto bad; #ifdef NO_SIGNALS - result = SConnect(dataSocket, &cip->servDataAddr, (int) cip->connTimeout); + result = SConnect(dataSocket, (struct sockaddr *)&cip->servDataAddr, (int) cip->connTimeout); #else /* NO_SIGNALS */ if (cip->connTimeout > 0) (void) alarm(cip->connTimeout); - - result = connect(dataSocket, (struct sockaddr *) &cip->servDataAddr, (int) sizeof(cip->servDataAddr)); + result = connect(dataSocket, (struct sockaddr *) &cip->servDataAddr, +#ifdef HAVE_SOCKADDR_SA_LEN + cip->servDataAddr.ss_len +#else + SA_LEN((struct sockaddr*)&cip->servDataAddr) +#endif + ); if (cip->connTimeout > 0) (void) alarm(0); #endif /* NO_SIGNALS */ @@ -1018,7 +1126,7 @@ /* Need to do this so we can figure out which port the system * gave to us. */ - if ((result = GetSocketAddress(cip, dataSocket, &cip->ourDataAddr)) < 0) + if ((result = GetSocketAddress(cip, dataSocket, (struct sockaddr *) &cip->ourDataAddr)) < 0) goto bad; cip->dataPortMode = kPassiveMode; @@ -1064,7 +1172,7 @@ memset(&cip->servDataAddr, 0, sizeof(cip->servDataAddr)); #ifdef NO_SIGNALS - newSocket = SAccept(cip->dataSocket, &cip->servDataAddr, (int) cip->connTimeout); + newSocket = SAccept(cip->dataSocket, (struct sockaddr *)&cip->servDataAddr, (int) cip->connTimeout); #else /* NO_SIGNALS */ len = (int) sizeof(cip->servDataAddr); if (cip->connTimeout > 0) @@ -1081,11 +1189,16 @@ cip->errNo = kErrAcceptDataSocket; return (kErrAcceptDataSocket); } - if (cip->allowProxyForPORT == 0) { - if (memcmp(&cip->servDataAddr.sin_addr.s_addr, &cip->servCtlAddr.sin_addr.s_addr, sizeof(cip->servDataAddr.sin_addr.s_addr)) != 0) { - AddrToAddrStr(ctrlAddrStr, sizeof(ctrlAddrStr), &cip->servCtlAddr, 0, NULL); - AddrToAddrStr(dataAddrStr, sizeof(dataAddrStr), &cip->servDataAddr, 0, NULL); + if (memcmp(&cip->servDataAddr, &cip->servCtlAddr, +#ifdef HAVE_SOCKADDR_SA_LEN + cip->servDataAddr.ss_len +#else + SA_LEN((struct sockaddr *)&cip->servDataAddr) +#endif + ) != 0) { + AddrToAddrStr(ctrlAddrStr, sizeof(ctrlAddrStr), (struct sockaddr *)&cip->servCtlAddr, 0, NULL); + AddrToAddrStr(dataAddrStr, sizeof(dataAddrStr), (struct sockaddr *)&cip->servDataAddr, 0, NULL); FTPLogError(cip, kDontPerror, "Data connection from %s did not originate from remote server %s!\n", dataAddrStr, ctrlAddrStr); (void) DisposeSocket(newSocket); cip->dataSocket = kClosedFileDescriptor; @@ -1093,21 +1206,57 @@ return (kErrProxyDataConnectionsDisabled); } } - if (cip->require20 != 0) { - remoteDataPort = ntohs(cip->servDataAddr.sin_port); - remoteCtrlPort = ntohs(cip->servCtlAddr.sin_port); - if ((int) remoteDataPort != ((int) remoteCtrlPort - 1)) { - FTPLogError(cip, kDontPerror, "Data connection did not originate on correct port (expecting %d, got %d)!\n", (int) remoteCtrlPort - 1, (int) remoteDataPort); - (void) DisposeSocket(newSocket); - cip->dataSocket = kClosedFileDescriptor; - cip->errNo = kErrDataConnOriginatedFromBadPort; - return (kErrDataConnOriginatedFromBadPort); +#ifdef ENABLE_IPV6 + if (cip->servDataAddr.ss_family == AF_INET6) { + struct sockaddr_in6 *servDataAddr = + (struct sockaddr_in6 *) &cip->servDataAddr; + struct sockaddr_in6 *servCtlAddr = + (struct sockaddr_in6 *) &cip->servCtlAddr; + + remoteDataPort = ntohs(servDataAddr->sin6_port); + remoteCtrlPort = ntohs(servCtlAddr->sin6_port); + if ((int) remoteDataPort != ((int) remoteCtrlPort - 1)) { + FTPLogError(cip, kDontPerror, "Data connection did not originate on correct port!\n"); + (void) DisposeSocket(newSocket); + cip->dataSocket = kClosedFileDescriptor; + cip->errNo = kErrAcceptDataSocket; + return (kErrAcceptDataSocket); + } else if (memcmp(&servDataAddr->sin6_addr, &servCtlAddr->sin6_addr, sizeof(servDataAddr->sin6_addr)) != 0) { + FTPLogError(cip, kDontPerror, "Data connection did not originate from remote server!\n"); + (void) DisposeSocket(newSocket); + cip->dataSocket = kClosedFileDescriptor; + cip->errNo = kErrAcceptDataSocket; + return (kErrAcceptDataSocket); + } + } else { +#endif + struct sockaddr_in *servDataAddr = + (struct sockaddr_in *) &cip->servDataAddr; + struct sockaddr_in *servCtlAddr = + (struct sockaddr_in *) &cip->servCtlAddr; + + remoteDataPort = ntohs(servDataAddr->sin_port); + remoteCtrlPort = ntohs(servCtlAddr->sin_port); + if ((int) remoteDataPort != ((int) remoteCtrlPort - 1)) { + FTPLogError(cip, kDontPerror, "Data connection did not originate on correct port!\n"); + (void) DisposeSocket(newSocket); + cip->dataSocket = kClosedFileDescriptor; + cip->errNo = kErrAcceptDataSocket; + return (kErrAcceptDataSocket); + } else if (memcmp(&servDataAddr->sin_addr.s_addr, &servCtlAddr->sin_addr.s_addr, sizeof(servDataAddr->sin_addr.s_addr)) != 0) { + FTPLogError(cip, kDontPerror, "Data connection did not originate on correct port (expecting %d, got %d)!\n", (int) remoteCtrlPort - 1, (int) remoteDataPort); + (void) DisposeSocket(newSocket); + cip->errNo = kErrDataConnOriginatedFromBadPort; + cip->errNo = kErrAcceptDataSocket; + return (kErrDataConnOriginatedFromBadPort); + } +#ifdef ENABLE_IPV6 } +#endif } cip->dataSocket = newSocket; } - return (0); } /* AcceptDataConnection */ Index: ncftp3/libncftp/getaddrinfo.c diff -u /dev/null ncftp3/libncftp/getaddrinfo.c:1.1 --- /dev/null Wed Jul 28 23:18:38 2004 +++ ncftp3/libncftp/getaddrinfo.c Tue Nov 6 23:50:46 2001 @@ -0,0 +1,607 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * "#ifdef FAITH" part is local hack for supporting IPv4-v6 translator. + * + * Issues to be discussed: + * - Thread safe-ness must be checked. + * - Return values. There are nonstandard return values defined and used + * in the source code. This is because RFC2133 is silent about which error + * code must be returned for which situation. + * - PF_UNSPEC case would be handled in getipnodebyname() with the AI_ALL flag. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "addrinfo.h" + +#if defined(__KAME__) && defined(INET6) +# define FAITH +#endif + +#define SUCCESS 0 +#define ANY 0 +#define YES 1 +#define NO 0 + +#ifdef FAITH +static int translate = NO; +static struct in6_addr faith_prefix = IN6ADDR_ANY_INIT; +#endif + +static const char in_addrany[] = { 0, 0, 0, 0 }; +static const char in6_addrany[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; +static const char in_loopback[] = { 127, 0, 0, 1 }; +static const char in6_loopback[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 +}; + +struct sockinet { + u_char si_len; + u_char si_family; + u_short si_port; +}; + +static struct afd { + int a_af; + int a_addrlen; + int a_socklen; + int a_off; + const char *a_addrany; + const char *a_loopback; +} afdl [] = { +#ifdef INET6 +#define N_INET6 0 + {PF_INET6, sizeof(struct in6_addr), + sizeof(struct sockaddr_in6), + offsetof(struct sockaddr_in6, sin6_addr), + in6_addrany, in6_loopback}, +#define N_INET 1 +#else +#define N_INET 0 +#endif + {PF_INET, sizeof(struct in_addr), + sizeof(struct sockaddr_in), + offsetof(struct sockaddr_in, sin_addr), + in_addrany, in_loopback}, + {0, 0, 0, 0, NULL, NULL}, +}; + +#ifdef INET6 +#define PTON_MAX 16 +#else +#define PTON_MAX 4 +#endif + + +static int get_name __P((const char *, struct afd *, + struct addrinfo **, char *, struct addrinfo *, + int)); +static int get_addr __P((const char *, int, struct addrinfo **, + struct addrinfo *, int)); +static int str_isnumber __P((const char *)); + +static char *ai_errlist[] = { + "success.", + "address family for hostname not supported.", /* EAI_ADDRFAMILY */ + "temporary failure in name resolution.", /* EAI_AGAIN */ + "invalid value for ai_flags.", /* EAI_BADFLAGS */ + "non-recoverable failure in name resolution.", /* EAI_FAIL */ + "ai_family not supported.", /* EAI_FAMILY */ + "memory allocation failure.", /* EAI_MEMORY */ + "no address associated with hostname.", /* EAI_NODATA */ + "hostname nor servname provided, or not known.",/* EAI_NONAME */ + "servname not supported for ai_socktype.", /* EAI_SERVICE */ + "ai_socktype not supported.", /* EAI_SOCKTYPE */ + "system error returned in errno.", /* EAI_SYSTEM */ + "invalid value for hints.", /* EAI_BADHINTS */ + "resolved protocol is unknown.", /* EAI_PROTOCOL */ + "unknown error.", /* EAI_MAX */ +}; + +#define GET_CANONNAME(ai, str) \ +if (pai->ai_flags & AI_CANONNAME) {\ + if (((ai)->ai_canonname = (char *)malloc(strlen(str) + 1)) != NULL) {\ + strcpy((ai)->ai_canonname, (str));\ + } else {\ + error = EAI_MEMORY;\ + goto free;\ + }\ +} + +#define GET_AI(ai, afd, addr, port) {\ + char *p;\ + if (((ai) = (struct addrinfo *)malloc(sizeof(struct addrinfo) +\ + ((afd)->a_socklen)))\ + == NULL) goto free;\ + memcpy(ai, pai, sizeof(struct addrinfo));\ + (ai)->ai_addr = (struct sockaddr *)((ai) + 1);\ + memset((ai)->ai_addr, 0, (afd)->a_socklen);\ + (ai)->ai_addr->sa_len = (ai)->ai_addrlen = (afd)->a_socklen;\ + (ai)->ai_addr->sa_family = (ai)->ai_family = (afd)->a_af;\ + ((struct sockinet *)(ai)->ai_addr)->si_port = port;\ + p = (char *)((ai)->ai_addr);\ + memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\ +} + +#define ERR(err) { error = (err); goto bad; } + +char * +gai_strerror(ecode) + int ecode; +{ + if (ecode < 0 || ecode > EAI_MAX) + ecode = EAI_MAX; + return ai_errlist[ecode]; +} + +void +freeaddrinfo(ai) + struct addrinfo *ai; +{ + struct addrinfo *next; + + do { + next = ai->ai_next; + if (ai->ai_canonname) + free(ai->ai_canonname); + /* no need to free(ai->ai_addr) */ + free(ai); + } while ((ai = next) != NULL); +} + +static int +str_isnumber(p) + const char *p; +{ + char *q = (char *)p; + while (*q) { + if (! isdigit(*q)) + return NO; + q++; + } + return YES; +} + +int +getaddrinfo(hostname, servname, hints, res) + const char *hostname, *servname; + const struct addrinfo *hints; + struct addrinfo **res; +{ + struct addrinfo sentinel; + struct addrinfo *top = NULL; + struct addrinfo *cur; + int i, error = 0; + char pton[PTON_MAX]; + struct addrinfo ai; + struct addrinfo *pai; + u_short port; + +#ifdef FAITH + static int firsttime = 1; + + if (firsttime) { + /* translator hack */ + { + char *q = getenv("GAI"); + if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1) + translate = YES; + } + firsttime = 0; + } +#endif + + /* initialize file static vars */ + sentinel.ai_next = NULL; + cur = &sentinel; + pai = &ai; + pai->ai_flags = 0; + pai->ai_family = PF_UNSPEC; + pai->ai_socktype = ANY; + pai->ai_protocol = ANY; + pai->ai_addrlen = 0; + pai->ai_canonname = NULL; + pai->ai_addr = NULL; + pai->ai_next = NULL; + port = ANY; + + if (hostname == NULL && servname == NULL) + return EAI_NONAME; + if (hints) { + /* error check for hints */ + if (hints->ai_addrlen || hints->ai_canonname || + hints->ai_addr || hints->ai_next) + ERR(EAI_BADHINTS); /* xxx */ + if (hints->ai_flags & ~AI_MASK) + ERR(EAI_BADFLAGS); + switch (hints->ai_family) { + case PF_UNSPEC: + case PF_INET: +#ifdef INET6 + case PF_INET6: +#endif + break; + default: + ERR(EAI_FAMILY); + } + memcpy(pai, hints, sizeof(*pai)); + switch (pai->ai_socktype) { + case ANY: + switch (pai->ai_protocol) { + case ANY: + break; + case IPPROTO_UDP: + pai->ai_socktype = SOCK_DGRAM; + break; + case IPPROTO_TCP: + pai->ai_socktype = SOCK_STREAM; + break; + default: + pai->ai_socktype = SOCK_RAW; + break; + } + break; + case SOCK_RAW: + break; + case SOCK_DGRAM: + if (pai->ai_protocol != IPPROTO_UDP && + pai->ai_protocol != ANY) + ERR(EAI_BADHINTS); /*xxx*/ + pai->ai_protocol = IPPROTO_UDP; + break; + case SOCK_STREAM: + if (pai->ai_protocol != IPPROTO_TCP && + pai->ai_protocol != ANY) + ERR(EAI_BADHINTS); /*xxx*/ + pai->ai_protocol = IPPROTO_TCP; + break; + default: + ERR(EAI_SOCKTYPE); + break; + } + } + + /* + * service port + */ + if (servname) { + if (str_isnumber(servname)) { + if (pai->ai_socktype == ANY) { + /* caller accept *ANY* socktype */ + pai->ai_socktype = SOCK_DGRAM; + pai->ai_protocol = IPPROTO_UDP; + } + port = htons(atoi(servname)); + } else { + struct servent *sp; + char *proto; + + proto = NULL; + switch (pai->ai_socktype) { + case ANY: + proto = NULL; + break; + case SOCK_DGRAM: + proto = "udp"; + break; + case SOCK_STREAM: + proto = "tcp"; + break; + default: + fprintf(stderr, "panic!\n"); + break; + } + if ((sp = getservbyname(servname, proto)) == NULL) + ERR(EAI_SERVICE); + port = sp->s_port; + if (pai->ai_socktype == ANY) + if (strcmp(sp->s_proto, "udp") == 0) { + pai->ai_socktype = SOCK_DGRAM; + pai->ai_protocol = IPPROTO_UDP; + } else if (strcmp(sp->s_proto, "tcp") == 0) { + pai->ai_socktype = SOCK_STREAM; + pai->ai_protocol = IPPROTO_TCP; + } else + ERR(EAI_PROTOCOL); /*xxx*/ + } + } + + /* + * hostname == NULL. + * passive socket -> anyaddr (0.0.0.0 or ::) + * non-passive socket -> localhost (127.0.0.1 or ::1) + */ + if (hostname == NULL) { + struct afd *afd; + + for (afd = &afdl[0]; afd->a_af; afd++) { + if (!(pai->ai_family == PF_UNSPEC + || pai->ai_family == afd->a_af)) { + continue; + } + + if (pai->ai_flags & AI_PASSIVE) { + GET_AI(cur->ai_next, afd, afd->a_addrany, port); + /* xxx meaningless? + * GET_CANONNAME(cur->ai_next, "anyaddr"); + */ + } else { + GET_AI(cur->ai_next, afd, afd->a_loopback, + port); + /* xxx meaningless? + * GET_CANONNAME(cur->ai_next, "localhost"); + */ + } + cur = cur->ai_next; + } + top = sentinel.ai_next; + if (top) + goto good; + else + ERR(EAI_FAMILY); + } + + /* hostname as numeric name */ + for (i = 0; afdl[i].a_af; i++) { + if (inet_pton(afdl[i].a_af, hostname, pton)) { + u_long v4a; + u_char pfx; + + switch (afdl[i].a_af) { + case AF_INET: + v4a = ((struct in_addr *)pton)->s_addr; + if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) + pai->ai_flags &= ~AI_CANONNAME; + v4a >>= IN_CLASSA_NSHIFT; + if (v4a == 0 || v4a == IN_LOOPBACKNET) + pai->ai_flags &= ~AI_CANONNAME; + break; +#ifdef INET6 + case AF_INET6: + pfx = ((struct in6_addr *)pton)->s6_addr8[0]; + if (pfx == 0 || pfx == 0xfe || pfx == 0xff) + pai->ai_flags &= ~AI_CANONNAME; + break; +#endif + } + + if (pai->ai_family == afdl[i].a_af || + pai->ai_family == PF_UNSPEC) { + if (! (pai->ai_flags & AI_CANONNAME)) { + GET_AI(top, &afdl[i], pton, port); + goto good; + } + /* + * if AI_CANONNAME and if reverse lookup + * fail, return ai anyway to pacify + * calling application. + * + * XXX getaddrinfo() is a name->address + * translation function, and it looks strange + * that we do addr->name translation here. + */ + get_name(pton, &afdl[i], &top, pton, pai, port); + goto good; + } else + ERR(EAI_FAMILY); /*xxx*/ + } + } + + if (pai->ai_flags & AI_NUMERICHOST) + ERR(EAI_NONAME); + + /* hostname as alphabetical name */ + error = get_addr(hostname, pai->ai_family, &top, pai, port); + if (error == 0) { + if (top) { + good: + *res = top; + return SUCCESS; + } else + error = EAI_FAIL; + } + free: + if (top) + freeaddrinfo(top); + bad: + *res = NULL; + return error; +} + +static int +get_name(addr, afd, res, numaddr, pai, port0) + const char *addr; + struct afd *afd; + struct addrinfo **res; + char *numaddr; + struct addrinfo *pai; + int port0; +{ + u_short port = port0 & 0xffff; + struct hostent *hp; + struct addrinfo *cur; + int error = 0, h_error; + +#ifdef INET6 + hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); +#else + hp = gethostbyaddr(addr, afd->a_addrlen, AF_INET); +#endif + if (hp && hp->h_name && hp->h_name[0] && hp->h_addr_list[0]) { + GET_AI(cur, afd, hp->h_addr_list[0], port); + GET_CANONNAME(cur, hp->h_name); + } else + GET_AI(cur, afd, numaddr, port); + +#ifdef INET6 + if (hp) + freehostent(hp); +#endif + *res = cur; + return SUCCESS; + free: + if (cur) + freeaddrinfo(cur); +#ifdef INET6 + if (hp) + freehostent(hp); +#endif + /* bad: */ + *res = NULL; + return error; +} + +static int +get_addr(hostname, af, res, pai, port0) + const char *hostname; + int af; + struct addrinfo **res; + struct addrinfo *pai; + int port0; +{ + u_short port = port0 & 0xffff; + struct addrinfo sentinel; + struct hostent *hp; + struct addrinfo *top, *cur; + struct afd *afd; + int i, error = 0, h_error; + char *ap; +#ifndef INET6 + extern int h_errno; +#endif + + top = NULL; + sentinel.ai_next = NULL; + cur = &sentinel; +#ifdef INET6 + if (af == AF_UNSPEC) { + hp = getipnodebyname(hostname, AF_INET6, + AI_ADDRCONFIG|AI_ALL|AI_V4MAPPED, &h_error); + } else + hp = getipnodebyname(hostname, af, AI_ADDRCONFIG, &h_error); +#else + hp = gethostbyname(hostname); + h_error = h_errno; +#endif + if (hp == NULL) { + switch (h_error) { + case HOST_NOT_FOUND: + case NO_DATA: + error = EAI_NODATA; + break; + case TRY_AGAIN: + error = EAI_AGAIN; + break; + case NO_RECOVERY: + default: + error = EAI_FAIL; + break; + } + goto bad; + } + + if ((hp->h_name == NULL) || (hp->h_name[0] == 0) || + (hp->h_addr_list[0] == NULL)) + ERR(EAI_FAIL); + + for (i = 0; (ap = hp->h_addr_list[i]) != NULL; i++) { + switch (af) { +#ifdef INET6 + case AF_INET6: + afd = &afdl[N_INET6]; + break; +#endif +#ifndef INET6 + default: /* AF_UNSPEC */ +#endif + case AF_INET: + afd = &afdl[N_INET]; + break; +#ifdef INET6 + default: /* AF_UNSPEC */ + if (IN6_IS_ADDR_V4MAPPED((struct in6_addr *)ap)) { + ap += sizeof(struct in6_addr) - + sizeof(struct in_addr); + afd = &afdl[N_INET]; + } else + afd = &afdl[N_INET6]; + break; +#endif + } +#ifdef FAITH + if (translate && afd->a_af == AF_INET) { + struct in6_addr *in6; + + GET_AI(cur->ai_next, &afdl[N_INET6], ap, port); + in6 = &((struct sockaddr_in6 *)cur->ai_next->ai_addr)->sin6_addr; + memcpy(&in6->s6_addr32[0], &faith_prefix, + sizeof(struct in6_addr) - sizeof(struct in_addr)); + memcpy(&in6->s6_addr32[3], ap, sizeof(struct in_addr)); + } else +#endif /* FAITH */ + GET_AI(cur->ai_next, afd, ap, port); + if (cur == &sentinel) { + top = cur->ai_next; + GET_CANONNAME(top, hp->h_name); + } + cur = cur->ai_next; + } +#ifdef INET6 + freehostent(hp); +#endif + *res = top; + return SUCCESS; + free: + if (top) + freeaddrinfo(top); +#ifdef INET6 + if (hp) + freehostent(hp); +#endif + bad: + *res = NULL; + return error; +} Index: ncftp3/libncftp/getnameinfo.c diff -u /dev/null ncftp3/libncftp/getnameinfo.c:1.1 --- /dev/null Wed Jul 28 23:18:38 2004 +++ ncftp3/libncftp/getnameinfo.c Tue Nov 6 23:50:47 2001 @@ -0,0 +1,203 @@ +/* + * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Issues to be discussed: + * - Thread safe-ness must be checked + * - Return values. There seems to be no standard for return value (RFC2133) + * but INRIA implementation returns EAI_xxx defined for getaddrinfo(). + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "addrinfo.h" + +#define SUCCESS 0 +#define ANY 0 +#define YES 1 +#define NO 0 + +static struct afd { + int a_af; + int a_addrlen; + int a_socklen; + int a_off; +} afdl [] = { +#ifdef INET6 + {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), + offsetof(struct sockaddr_in6, sin6_addr)}, +#endif + {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), + offsetof(struct sockaddr_in, sin_addr)}, + {0, 0, 0}, +}; + +struct sockinet { + u_char si_len; + u_char si_family; + u_short si_port; +}; + +#define ENI_NOSOCKET 0 +#define ENI_NOSERVNAME 1 +#define ENI_NOHOSTNAME 2 +#define ENI_MEMORY 3 +#define ENI_SYSTEM 4 +#define ENI_FAMILY 5 +#define ENI_SALEN 6 + +int +getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) + const struct sockaddr *sa; + size_t salen; + char *host; + size_t hostlen; + char *serv; + size_t servlen; + int flags; +{ + struct afd *afd; + struct servent *sp; + struct hostent *hp; + u_short port; + int family, len, i; + char *addr, *p; + u_long v4a; + u_char pfx; + int h_error; + char numserv[512]; + char numaddr[512]; + + if (sa == NULL) + return ENI_NOSOCKET; + + len = sa->sa_len; + if (len != salen) return ENI_SALEN; + + family = sa->sa_family; + for (i = 0; afdl[i].a_af; i++) + if (afdl[i].a_af == family) { + afd = &afdl[i]; + goto found; + } + return ENI_FAMILY; + + found: + if (len != afd->a_socklen) return ENI_SALEN; + + port = ((struct sockinet *)sa)->si_port; /* network byte order */ + addr = (char *)sa + afd->a_off; + + if (serv == NULL || servlen == 0) { + /* what we should do? */ + } else if (flags & NI_NUMERICSERV) { + snprintf(numserv, sizeof(numserv), "%d", ntohs(port)); + if (strlen(numserv) > servlen) + return ENI_MEMORY; + strcpy(serv, numserv); + } else { + sp = getservbyport(port, (flags & NI_DGRAM) ? "udp" : "tcp"); + if (sp) { + if (strlen(sp->s_name) > servlen) + return ENI_MEMORY; + strcpy(serv, sp->s_name); + } else + return ENI_NOSERVNAME; + } + + switch (sa->sa_family) { + case AF_INET: + v4a = ((struct sockaddr_in *)sa)->sin_addr.s_addr; + if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) + flags |= NI_NUMERICHOST; + v4a >>= IN_CLASSA_NSHIFT; + if (v4a == 0 || v4a == IN_LOOPBACKNET) + flags |= NI_NUMERICHOST; + break; +#ifdef INET6 + case AF_INET6: + pfx = ((struct sockaddr_in6 *)sa)->sin6_addr.s6_addr8[0]; + if (pfx == 0 || pfx == 0xfe || pfx == 0xff) + flags |= NI_NUMERICHOST; + break; +#endif + } + if (host == NULL || hostlen == 0) { + /* what should we do? */ + } else if (flags & NI_NUMERICHOST) { + if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) + == NULL) + return ENI_SYSTEM; + if (strlen(numaddr) > hostlen) + return ENI_MEMORY; + strcpy(host, numaddr); + } else { +#ifdef INET6 + hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error); +#else + hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af); + h_error = h_errno; +#endif + + if (hp) { + if (flags & NI_NOFQDN) { + p = strchr(hp->h_name, '.'); + if (p) *p = '\0'; + } + if (strlen(hp->h_name) > hostlen) { +#ifdef INET6 + freehostent(hp); +#endif + return ENI_MEMORY; + } + strcpy(host, hp->h_name); +#ifdef INET6 + freehostent(hp); +#endif + } else { + if (flags & NI_NAMEREQD) + return ENI_NOHOSTNAME; + if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr)) + == NULL) + return ENI_NOHOSTNAME; + if (strlen(numaddr) > hostlen) + return ENI_MEMORY; + strcpy(host, numaddr); + } + } + return SUCCESS; +} Index: ncftp3/libncftp/ncftp.h diff -u ncftp3/libncftp/ncftp.h:1.1.1.17 ncftp3/libncftp/ncftp.h:1.22 --- ncftp3/libncftp/ncftp.h:1.1.1.17 Tue Jul 20 00:01:06 2004 +++ ncftp3/libncftp/ncftp.h Tue Jul 20 00:58:43 2004 @@ -377,11 +377,10 @@ int mlsFeatures; /* Do not modify this field. */ int STATfileParamWorks; /* Do not modify this field. */ int NLSTfileParamWorks; /* Do not modify this field. */ - - struct sockaddr_in servCtlAddr; /* Do not modify this field. */ - struct sockaddr_in servDataAddr; /* Do not modify this field. */ - struct sockaddr_in ourCtlAddr; /* Do not modify this field. */ - struct sockaddr_in ourDataAddr; /* Do not modify this field. */ + struct sockaddr_storage servCtlAddr; /* Do not modify this field. */ + struct sockaddr_storage servDataAddr; /* Do not modify this field. */ + struct sockaddr_storage ourCtlAddr; /* Do not modify this field. */ + struct sockaddr_storage ourDataAddr; /* Do not modify this field. */ int netMode; /* Do not use or modify. */ char *buf; /* Do not modify this field. */ size_t bufSize; /* Do not modify this field. */ @@ -747,9 +746,9 @@ /* The following block may be changed by configure script */ #ifndef Stat -#define Stat stat64 -#define Lstat lstat64 -#define Fstat fstat64 +#define Stat stat +#define Lstat lstat +#define Fstat fstat #endif #define kFtwNoAutoGrowButContinue (-1) @@ -966,8 +965,8 @@ /* Everything else below are private routines, or stuff for testing */ int FTPInitConnectionInfo2(const FTPLIPtr lip, const FTPCIPtr cip, char *const buf, size_t bufSize); -int FTPSendPort(const FTPCIPtr cip, struct sockaddr_in *saddr); -int FTPSendPassive(const FTPCIPtr cip, struct sockaddr_in *saddr, int *weird); +int FTPSendPort(const FTPCIPtr cip, struct sockaddr *saddr); +int FTPSendPassive(const FTPCIPtr cip, struct sockaddr *saddr, int *weird); int FTPSetStartOffset(const FTPCIPtr cip, longest_int restartPt); void FTPCloseControlConnection(const FTPCIPtr cip); int FTPSendCommand(const FTPCIPtr cip, const char *const cmdspec, va_list ap) Index: ncftp3/libncftp/syshdrs.h diff -u ncftp3/libncftp/syshdrs.h:1.1.1.10 ncftp3/libncftp/syshdrs.h:1.9 --- ncftp3/libncftp/syshdrs.h:1.1.1.10 Thu Jan 8 19:51:01 2004 +++ ncftp3/libncftp/syshdrs.h Thu Jan 8 20:09:32 2004 @@ -23,6 +23,10 @@ # define _WIN32_WINNT 0x0400 # endif # include /* includes if _WIN32_WINNT >= 0x400 */ +# ifdef ENABLE_IPV6 +# include +# define INET6_ADDRSTRLEN 46 +# endif /* ENABLE_IPV6 */ # include # include # include @@ -161,6 +165,9 @@ # include # endif +# ifndef HAVE_GETADDRINFO +# include "addrinfo.h" +# endif # ifdef CAN_USE_SYS_SELECT_H # include # endif Index: ncftp3/ncftp/cmds.c diff -u ncftp3/ncftp/cmds.c:1.1.1.16 ncftp3/ncftp/cmds.c:1.15 --- ncftp3/ncftp/cmds.c:1.1.1.16 Tue Jul 20 00:01:31 2004 +++ ncftp3/ncftp/cmds.c Tue Jul 20 00:16:54 2004 @@ -2255,8 +2255,7 @@ (void) printf("Unknown host \"%s\".\n", ohost); return (-1); } - (void) STRNCPY(gConn.host, ipstr); - OpenMsg("Connecting to %s...", ipstr); + OpenMsg("Connecting to %s...", gConn.host); } else { OpenMsg("Connecting to %s via %s...", gConn.host, gConn.firewallHost); Trace(0, "Fw: %s Type: %d User: %s Pass: %s Port: %u\n", Index: ncftp3/ncftp/syshdrs.h diff -u ncftp3/ncftp/syshdrs.h:1.1.1.12 ncftp3/ncftp/syshdrs.h:1.10 --- ncftp3/ncftp/syshdrs.h:1.1.1.12 Thu Jan 8 19:51:13 2004 +++ ncftp3/ncftp/syshdrs.h Thu Jan 8 20:09:33 2004 @@ -32,6 +32,9 @@ # define _WIN32_WINNT 0x0400 # endif # include /* includes if _WIN32_WINNT >= 0x400 */ +#ifdef ENABLE_IPV6 +# include +#endif /* ENABLE_IPV6 */ # include # include # include @@ -155,6 +158,9 @@ # include # include # include +# ifndef HAVE_GETADDRINFO +# include "addrinfo.h" +# endif # if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_TERMIOS_H) # include # include Index: ncftp3/ncftp/util.c diff -u ncftp3/ncftp/util.c:1.1.1.13 ncftp3/ncftp/util.c:1.23 --- ncftp3/ncftp/util.c:1.1.1.13 Thu Jan 8 19:51:13 2004 +++ ncftp3/ncftp/util.c Thu Jan 8 20:09:33 2004 @@ -664,44 +664,30 @@ int MyGetHostByName(char *const volatile dst, size_t dsize, const char *const hn, int t) { + struct addrinfo hints; + struct addrinfo *res; + int error; #if (defined(WIN32) || defined(_WINDOWS)) && !defined(__CYGWIN__) - struct hostent *hp; - struct in_addr ina; - if (inet_addr(hn) != (unsigned long) 0xFFFFFFFF) { - /* Address is an IP address string, which is what we want. */ - (void) Strncpy(dst, hn, dsize); - return (0); - } - - hp = gethostbyname(hn); - if (hp != NULL) { - (void) memcpy(&ina.s_addr, hp->h_addr_list[0], (size_t) hp->h_length); - InetNtoA(dst, ((struct in_addr **) hp->h_addr_list)[0], dsize); + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + error = getaddrinfo(hn, NULL, &hints, &res); + + if (error == 0) { + char buf[NI_MAXHOST]; + + getnameinfo(res->ai_addr, res->ai_addrlen, + buf, sizeof(buf), + NULL, 0, NI_NUMERICHOST); + (void) Strncpy(dst, buf, dsize); + freeaddrinfo(res); return (0); } #else int sj; vsigproc_t osigpipe, osigint, osigalrm; - struct hostent *hp; -#ifdef HAVE_INET_ATON - struct in_addr ina; -#endif - -#ifdef HAVE_INET_ATON - if (inet_aton(hn, &ina) != 0) { - /* Address is an IP address string, which is what we want. */ - (void) Strncpy(dst, hn, dsize); - return (0); - } -#else - if (inet_addr(hn) != (unsigned long) 0xFFFFFFFF) { - /* Address is an IP address string, which is what we want. */ - (void) Strncpy(dst, hn, dsize); - return (0); - } -#endif #ifdef HAVE_SIGSETJMP osigpipe = osigint = osigalrm = (sigproc_t) 0; @@ -726,14 +712,25 @@ osigalrm = NcSignal(SIGALRM, CancelGetHostByName); if (t > 0) (void) alarm((unsigned int) t); - hp = gethostbyname(hn); + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = 0; + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = 0; + error = getaddrinfo(hn, NULL, &hints, &res); if (t > 0) (void) alarm(0); (void) NcSignal(SIGPIPE, osigpipe); (void) NcSignal(SIGINT, osigint); (void) NcSignal(SIGALRM, osigalrm); - if (hp != NULL) { - InetNtoA(dst, ((struct in_addr **) hp->h_addr_list)[0], dsize); + if (error == 0) { + char buf[NI_MAXHOST]; + + getnameinfo(res->ai_addr, res->ai_addrlen, + buf, sizeof(buf), + NULL, 0, NI_NUMERICHOST); + (void) Strncpy(dst, buf, dsize); + freeaddrinfo(res); return (0); } } Index: ncftp3/sh_util/syshdrs.h diff -u ncftp3/sh_util/syshdrs.h:1.1.1.8 ncftp3/sh_util/syshdrs.h:1.8 --- ncftp3/sh_util/syshdrs.h:1.1.1.8 Thu May 30 23:40:49 2002 +++ ncftp3/sh_util/syshdrs.h Thu May 30 23:49:39 2002 @@ -32,6 +32,9 @@ # define _WIN32_WINNT 0x0400 # endif # include /* includes if _WIN32_WINNT >= 0x400 */ +#ifdef ENABLE_IPV6 +# include +#endif /* ENABLE_IPV6 */ # include # include # include @@ -162,6 +165,9 @@ # include # include # include +# ifndef HAVE_GETADDRINFO +# include "addrinfo.h" +# endif # ifdef HAVE_LOCALE_H # include # endif Index: ncftp3/sio/SAccept.c diff -u ncftp3/sio/SAccept.c:1.1.1.1 ncftp3/sio/SAccept.c:1.3 --- ncftp3/sio/SAccept.c:1.1.1.1 Thu Jan 8 19:51:19 2004 +++ ncftp3/sio/SAccept.c Mon Jan 19 19:38:25 2004 @@ -3,8 +3,20 @@ # pragma hdrstop #endif +#ifndef HAVE_SOCKADDR_SA_LEN +#ifndef SA_LEN +#ifdef ENABLE_IPV6 +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#else /* ENABLE_IPV6 */ +#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_IPV6 */ +#endif /* SA_LEN */ +#endif /* HAVE_SOCKADDR_SA_LEN */ + int -SAccept(int sfd, struct sockaddr_in *const addr, int tlen) +SAccept(int sfd, struct sockaddr *const addr, int tlen) { int result; fd_set ss; @@ -22,7 +34,11 @@ if (tlen <= 0) { errno = 0; for (;;) { - size = (sockaddr_size_t) sizeof(struct sockaddr_in); +#ifdef HAVE_SOCKADDR_SA_LEN + size = (sockaddr_size_t) (addr->sa_len); +#else + size = (sockaddr_size_t) SA_LEN(addr); +#endif result = accept(sfd, (struct sockaddr *) addr, &size); if ((result >= 0) || (errno != EINTR)) { RESTORE_SIGPIPE @@ -61,7 +77,11 @@ } do { - size = (sockaddr_size_t) sizeof(struct sockaddr_in); +#ifdef HAVE_SOCKADDR_SA_LEN + size = (sockaddr_size_t) (addr->sa_len); +#else + size = (sockaddr_size_t) SA_LEN(addr); +#endif result = accept(sfd, (struct sockaddr *) addr, &size); } while ((result < 0) && (errno == EINTR)); Index: ncftp3/sio/SConnect.c diff -u ncftp3/sio/SConnect.c:1.1.1.7 ncftp3/sio/SConnect.c:1.15 --- ncftp3/sio/SConnect.c:1.1.1.7 Thu Jan 8 19:51:17 2004 +++ ncftp3/sio/SConnect.c Thu Jan 8 20:09:33 2004 @@ -3,14 +3,30 @@ # pragma hdrstop #endif -int _SConnect(const int sfd, const struct sockaddr_in *const addr, const size_t saddrsiz, const int tlen); +int _SConnect(const int sfd, const struct sockaddr *const addr, const size_t saddrsiz, const int tlen); + +#ifndef HAVE_SOCKADDR_SA_LEN +#ifndef SA_LEN +#ifdef ENABLE_IPV6 +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#else /* ENABLE_IPV6 */ +#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_IPV6 */ +#endif /* SA_LEN */ +#endif /* HAVE_SOCKADDR_SA_LEN */ int -SConnect(int sfd, const struct sockaddr_in *const addr, int tlen) +SConnect(int sfd, const struct sockaddr *const addr, int tlen) { int result; - result = _SConnect(sfd, addr, (size_t) sizeof(struct sockaddr_in), tlen); +#ifdef HAVE_SOCKADDR_SA_LEN + result = _SConnect(sfd, addr, addr->sa_len, tlen); +#else + result = _SConnect(sfd, addr, SA_LEN(addr), tlen); +#endif return (result); } /* SConnect */ @@ -54,7 +70,7 @@ int -_SConnect(const int sfd, const struct sockaddr_in *const addr, const size_t saddrsiz, const int tlen) +_SConnect(const int sfd, const struct sockaddr *const addr, const size_t saddrsiz, const int tlen) { fd_set ss, xx; struct timeval tv; Index: ncftp3/sio/SConnectByName.c diff -u ncftp3/sio/SConnectByName.c:1.1.1.3 ncftp3/sio/SConnectByName.c:1.3 --- ncftp3/sio/SConnectByName.c:1.1.1.3 Thu Jan 8 19:51:16 2004 +++ ncftp3/sio/SConnectByName.c Thu Jan 8 20:09:33 2004 @@ -7,15 +7,15 @@ SConnectByName(int sfd, const char * const addrStr, const int tlen) { int result; - struct sockaddr_in remoteAddr; + struct sockaddr_storage remoteAddr; if (addrStr == NULL) { errno = EINVAL; return (-1); } - if ((result = AddrStrToAddr(addrStr, &remoteAddr, -1)) == 0) { - result = SConnect(sfd, &remoteAddr, tlen); + if ((result = AddrStrToAddr(addrStr, (struct sockaddr *)&remoteAddr, -1)) == 0) { + result = SConnect(sfd, (struct sockaddr *)&remoteAddr, tlen); } return (result); } /* SConnectByName */ Index: ncftp3/sio/SRecvfrom.c diff -u ncftp3/sio/SRecvfrom.c:1.1.1.5 ncftp3/sio/SRecvfrom.c:1.4 --- ncftp3/sio/SRecvfrom.c:1.1.1.5 Thu Jan 8 19:51:18 2004 +++ ncftp3/sio/SRecvfrom.c Thu Jan 8 20:09:33 2004 @@ -4,7 +4,7 @@ #endif int -SRecvfrom(int sfd, char *const buf, size_t size, int fl, struct sockaddr_in *const fromAddr, int tlen) +SRecvfrom(int sfd, char *const buf, size_t size, int fl, struct sockaddr *const fromAddr, int tlen) { recv_return_t nread; int tleft; @@ -56,7 +56,7 @@ IGNORE_SIGPIPE nread = recvfrom(sfd, buf, (recv_size_t) size, fl, - (struct sockaddr *) fromAddr, &alen); + fromAddr, &alen); RESTORE_SIGPIPE if (nread >= 0) Index: ncftp3/sio/SSendto.c diff -u ncftp3/sio/SSendto.c:1.1.1.5 ncftp3/sio/SSendto.c:1.5 --- ncftp3/sio/SSendto.c:1.1.1.5 Thu Jan 8 19:51:18 2004 +++ ncftp3/sio/SSendto.c Thu Jan 8 20:09:33 2004 @@ -3,8 +3,21 @@ # pragma hdrstop #endif +#ifndef HAVE_SOCKADDR_SA_LEN +#ifndef SA_LEN +#ifdef ENABLE_IPV6 +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#else /* ENABLE_IPV6 */ +#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_IPV6 */ +#endif /* SA_LEN */ +#endif /* HAVE_SOCKADDR_SA_LEN */ + + int -SSendto(int sfd, const char *const buf, size_t size, int fl, const struct sockaddr_in *const toAddr, int tlen) +SSendto(int sfd, const char *const buf, size_t size, int fl, const struct sockaddr *const toAddr, int tlen) { send_return_t nwrote; int tleft; @@ -58,9 +71,15 @@ } IGNORE_SIGPIPE +#ifdef HAVE_SOCKADDR_SA_LEN + nwrote = sendto(sfd, buf, (send_size_t) size, fl, + toAddr, + toAddr->sa_len); +#else nwrote = sendto(sfd, buf, (send_size_t) size, fl, - (const struct sockaddr *) toAddr, - (sockaddr_size_t) sizeof(struct sockaddr_in)); + toAddr, + SA_LEN(toAddr)); +#endif RESTORE_SIGPIPE if (nwrote >= 0) @@ -77,7 +96,7 @@ int -Sendto(int sfd, const char *const buf, size_t size, const struct sockaddr_in *const toAddr) +Sendto(int sfd, const char *const buf, size_t size, const struct sockaddr *toAddr) { int result; DECL_SIGPIPE_VARS @@ -89,9 +108,15 @@ IGNORE_SIGPIPE do { +#ifdef HAVE_SOCKADDR_SA_LEN + result = (int) sendto(sfd, buf, (send_size_t) size, 0, + toAddr, + toAddr->sa_len); +#else result = (int) sendto(sfd, buf, (send_size_t) size, 0, - (const struct sockaddr *) toAddr, - (sockaddr_size_t) sizeof(struct sockaddr_in)); + toAddr, + SA_LEN(toAddr)); +#endif } while ((result < 0) && (errno == EINTR)); RESTORE_SIGPIPE return (result); Index: ncftp3/sio/SSendtoByName.c diff -u ncftp3/sio/SSendtoByName.c:1.1.1.5 ncftp3/sio/SSendtoByName.c:1.4 --- ncftp3/sio/SSendtoByName.c:1.1.1.5 Thu Jan 8 19:51:18 2004 +++ ncftp3/sio/SSendtoByName.c Thu Jan 8 20:09:33 2004 @@ -11,7 +11,7 @@ time_t done, now; fd_set ss; struct timeval tv; - struct sockaddr_in toAddr; + struct sockaddr_storage toAddr; DECL_SIGPIPE_VARS if ((buf == NULL) || (size == 0) || (toAddrStr == NULL) || (toAddrStr[0] == '\0') || (tlen <= 0)) { @@ -19,7 +19,7 @@ return (-1); } - if ((result = AddrStrToAddr(toAddrStr, &toAddr, -1)) < 0) { + if ((result = AddrStrToAddr(toAddrStr, (struct sockaddr *)&toAddr, -1)) < 0) { return (result); } @@ -81,7 +81,7 @@ SendtoByName(int sfd, const char *const buf, size_t size, const char *const toAddrStr) { int result; - struct sockaddr_in toAddr; + struct sockaddr_storage toAddr; DECL_SIGPIPE_VARS if ((buf == NULL) || (size == 0) || (toAddrStr == NULL)) { @@ -89,8 +89,7 @@ return (-1); } - - if ((result = AddrStrToAddr(toAddrStr, &toAddr, -1)) < 0) { + if ((result = AddrStrToAddr(toAddrStr, (struct sockaddr *)&toAddr, -1)) < 0) { return (result); } Index: ncftp3/sio/StrAddr.c diff -u ncftp3/sio/StrAddr.c:1.1.1.5 ncftp3/sio/StrAddr.c:1.7 --- ncftp3/sio/StrAddr.c:1.1.1.5 Sun Jan 12 11:26:09 2003 +++ ncftp3/sio/StrAddr.c Fri Feb 7 09:54:58 2003 @@ -3,6 +3,19 @@ # pragma hdrstop #endif +#ifndef HAVE_SOCKADDR_SA_LEN +#ifndef SA_LEN +#ifdef ENABLE_IPV6 +#define SA_LEN(x) (((x)->sa_family == AF_INET6) ? sizeof(struct sockaddr_in6) \ + : (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) \ + : -1)) +#else /* ENABLE_IPV6 */ +#define SA_LEN(x) (((x)->sa_family == AF_INET) ? sizeof(struct sockaddr_in) : -1) +#endif /* ENABLE_IPV6 */ +#endif /* SA_LEN */ +#endif /* HAVE_SOCKADDR_SA_LEN */ + + #ifndef INADDR_ANY # define INADDR_ANY ((unsigned long int) 0x00000000) #endif @@ -200,15 +213,13 @@ int -AddrStrToAddr(const char * const s, struct sockaddr_in * const sa, const int defaultport) +AddrStrToAddr(const char * const s, struct sockaddr * const sa, const int defaultport) { - char portstr[128]; - unsigned int ipnum; - unsigned int port; - struct hostent *hp; - char *hostcp, *atsign, *colon, *cp, *p2; + char portstr[128], portstr2[128]; + struct addrinfo hints, *res; + char *hostcp, *atsign, *colon, *cp, *p2, *portp; + int error; - memset(sa, 0, sizeof(struct sockaddr_in)); strncpy(portstr, s, sizeof(portstr)); portstr[sizeof(portstr) - 1] = '\0'; @@ -216,7 +227,6 @@ /* Does it look like a URL? http://host ? */ if ((colon[1] == '/') && (colon[2] == '/')) { *colon = '\0'; - port = 0; hostcp = colon + 3; for (cp = hostcp; *cp != '\0'; cp++) { if ((!ISALNUM(*cp)) && (*cp != '.')) { @@ -227,29 +237,27 @@ while (isdigit((int) *cp)) cp++; *cp = '\0'; - port = atoi(p2); } *cp = '\0'; break; } } - if (port == 0) - port = ServiceNameToPortNumber(portstr, 0); } else { /* Look for host.name.domain:port */ *colon = '\0'; hostcp = portstr; - port = (unsigned int) atoi(colon + 1); } + portp = portstr; } else if ((atsign = strchr(portstr, '@')) != NULL) { /* Look for port@host.name.domain */ *atsign = '\0'; hostcp = atsign + 1; - port = (unsigned int) atoi(portstr); + portp = portstr; } else if (defaultport > 0) { /* Have just host.name.domain, use that w/ default port. */ - port = (unsigned int) defaultport; + sprintf(portstr2, "%d", defaultport); hostcp = portstr; + portp = portstr2; } else { /* If defaultport <= 0, they must supply a port number * in the host/port string. @@ -258,34 +266,28 @@ return (kAddrStrToAddrMiscErr); } - sa->sin_port = htons((short) port); - - ipnum = inet_addr(hostcp); - if (ipnum != INADDR_NONE) { - sa->sin_family = AF_INET; - sa->sin_addr.s_addr = ipnum; - } else { - errno = 0; - hp = gethostbyname(hostcp); - if (hp == NULL) { - if (errno == 0) - errno = ENOENT; - return (kAddrStrToAddrBadHost); - } - sa->sin_family = hp->h_addrtype; - memcpy(&sa->sin_addr.s_addr, hp->h_addr_list[0], - (size_t) hp->h_length); - } + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + error = getaddrinfo(hostcp, portp, &hints, &res); + if (error != 0) + return (kAddrStrToAddrBadHost); + memcpy(sa, res->ai_addr, res->ai_addrlen); + freeaddrinfo(res); return (0); } /* AddrStrToAddr */ char * -AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in * const saddrp, int dns, const char *fmt) +AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr * const saddrp, int dns, const char *fmt) { char addrName[128]; char *addrNamePtr; + char portName[128]; + char *portNamePtr; + char portNum[128]; + char *portNumPtr; struct hostent *hp; char str[128]; char s_name[64]; @@ -293,18 +295,24 @@ const char *cp; addrNamePtr = NULL; - if (dns == 0) { - InetNtoA(addrName, &saddrp->sin_addr, sizeof(addrName)); - addrNamePtr = addrName; - } else { - hp = gethostbyaddr((gethost_addrptr_t) &saddrp->sin_addr, sizeof(struct in_addr), AF_INET); - if ((hp != NULL) && (hp->h_name != NULL) && (hp->h_name[0] != '\0')) { - addrNamePtr = hp->h_name; - } else { - InetNtoA(addrName, &saddrp->sin_addr, sizeof(addrName)); - addrNamePtr = addrName; - } - } + if (dns == 0) + dns = NI_NUMERICHOST; + else + dns = 0; + getnameinfo(saddrp, +#ifdef HAVE_SOCKADDR_SA_LEN + saddrp->sa_len, +#else + SA_LEN(saddrp), +#endif + addrName, sizeof(addrName), portName, sizeof(portName), dns); + getnameinfo(saddrp, +#ifdef HAVE_SOCKADDR_SA_LEN + saddrp->sa_len, +#else + SA_LEN(saddrp), +#endif + NULL, 0, portNum, sizeof(portNum), NI_NUMERICSERV); if (fmt == NULL) fmt = "%h:%p"; for (dp = dst, dlim = dp + dsize - 1; ; fmt++) { @@ -316,8 +324,7 @@ if (dp < dlim) *dp++ = '%'; } else if (*fmt == 'p') { - sprintf(str, "%u", (unsigned int) ntohs(saddrp->sin_port)); - for (cp = str; *cp != '\0'; cp++) + for (cp = portNum; *cp != '\0'; cp++) if (dp < dlim) *dp++ = *cp; *dp = '\0'; @@ -332,13 +339,12 @@ *dp++ = *cp; *dp = '\0'; } else if (*fmt == 's') { - cp = s_name; - (void) ServicePortNumberToName(ntohs(saddrp->sin_port), s_name, sizeof(s_name), 0); - for ( ; *cp != '\0'; cp++) + for (cp = portName ; *cp != '\0'; cp++) if (dp < dlim) *dp++ = *cp; /* endservent(); */ *dp = '\0'; +#if 0 } else if ((*fmt == 't') || (*fmt == 'u')) { cp = s_name; (void) ServicePortNumberToName(ntohs(saddrp->sin_port), s_name, sizeof(s_name), (int) *fmt); @@ -347,6 +353,7 @@ *dp++ = *cp; /* endservent(); */ *dp = '\0'; +#endif } else if (*fmt == '\0') { break; } else { Index: ncftp3/sio/sio.h diff -u ncftp3/sio/sio.h:1.1.1.8 ncftp3/sio/sio.h:1.12 --- ncftp3/sio/sio.h:1.1.1.8 Thu Jan 8 19:51:19 2004 +++ ncftp3/sio/sio.h Thu Jan 8 20:09:34 2004 @@ -197,7 +197,7 @@ int PWrite(int, const char *const, size_t); /* SAccept.c */ -int SAccept(int, struct sockaddr_in *const, int); +int SAccept(int, struct sockaddr *const, int); /* SBind.c */ int SBind(int, const int, const int, const int); @@ -208,7 +208,7 @@ int SClose(int, int); /* SConnect.c */ -int SConnect(int, const struct sockaddr_in *const, int); +int SConnect(int, const struct sockaddr *const, int); /* SConnectByName.c */ int SConnectByName(int, const char *const, const int); @@ -232,7 +232,7 @@ int SRecv(int, char *const, size_t, int, int, int); /* SRecvfrom.c */ -int SRecvfrom(int, char *const, size_t, int, struct sockaddr_in *const, int); +int SRecvfrom(int, char *const, size_t, int, struct sockaddr *const, int); /* SRecvmsg.c */ int SRecvmsg(int, void *const, int, int); @@ -248,8 +248,8 @@ int SSend(int, char *, size_t, int, int); /* SSendto.c */ -int SSendto(int, const char *const, size_t, int, const struct sockaddr_in *const, int); -int Sendto(int, const char *const, size_t, const struct sockaddr_in *const); +int SSendto(int, const char *const, size_t, int, const struct sockaddr *const, int); +int Sendto(int, const char *const, size_t, const struct sockaddr *const); /* SSendtoByName.c */ int SSendtoByName(int, const char *const, size_t, int, const char *const, int); @@ -280,8 +280,8 @@ unsigned int ServiceNameToPortNumber(const char *const s, const int proto); int ServicePortNumberToName(unsigned short port, char *const dst, const size_t dsize, const int proto); void InetNtoA(char *dst, struct in_addr *ia, size_t siz); -int AddrStrToAddr(const char *const, struct sockaddr_in *const, const int); -char *AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr_in * const saddrp, int dns, const char *fmt); +int AddrStrToAddr(const char *const, struct sockaddr *const, const int); +char *AddrToAddrStr(char *const dst, size_t dsize, struct sockaddr * const saddrp, int dns, const char *fmt); /* SError.c */ const char *SError(int e); Index: ncftp3/sio/syshdrs.h diff -u ncftp3/sio/syshdrs.h:1.1.1.7 ncftp3/sio/syshdrs.h:1.8 --- ncftp3/sio/syshdrs.h:1.1.1.7 Thu Jan 8 19:51:17 2004 +++ ncftp3/sio/syshdrs.h Thu Jan 8 20:09:34 2004 @@ -19,6 +19,9 @@ # define WINVER 0x0400 # define _WIN32_WINNT 0x0400 # include /* includes if _WIN32_WINNT >= 0x400 */ +#ifdef ENABLE_IPV6 +# include +#endif /* ENABLE_IPV6 */ # include # include # include Index: ncftp3/vis/syshdrs.h diff -u ncftp3/vis/syshdrs.h:1.1.1.8 ncftp3/vis/syshdrs.h:1.5 --- ncftp3/vis/syshdrs.h:1.1.1.8 Thu Jan 8 19:51:11 2004 +++ ncftp3/vis/syshdrs.h Thu Jan 8 20:09:34 2004 @@ -94,6 +94,9 @@ #include #include #include +#ifndef HAVE_GETADDRINFO +# include "addrinfo.h" +#endif #ifdef HAVE_LOCALE_H # include