From dfd98c8a16d53dff0d1bdca29bcddc6571054129 Mon Sep 17 00:00:00 2001 From: christos Date: Sat, 6 Nov 2004 23:53:21 +0000 Subject: Import bind-9.3.0 --- dist/bind/lib/bind/Makefile.in | 4 +- dist/bind/lib/bind/api | 2 +- dist/bind/lib/bind/configure | 159 ++++-- dist/bind/lib/bind/configure.in | 7 +- dist/bind/lib/bind/include/arpa/nameser_compat.h | 6 +- dist/bind/lib/bind/include/resolv.h | 5 +- dist/bind/lib/bind/irs/dns_ho.c | 56 +-- dist/bind/lib/bind/irs/dns_nw.c | 11 +- dist/bind/lib/bind/irs/gen_gr.c | 76 +-- dist/bind/lib/bind/irs/getaddrinfo.c | 12 +- dist/bind/lib/bind/irs/gethostent_r.c | 10 +- dist/bind/lib/bind/irs/getnameinfo.c | 4 +- dist/bind/lib/bind/irs/hesiod.c | 37 +- dist/bind/lib/bind/nameser/ns_name.c | 30 +- dist/bind/lib/bind/nameser/ns_print.c | 9 +- dist/bind/lib/bind/port/aix32/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/aix4/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/aux3/include/sys/cdefs.h | 4 +- dist/bind/lib/bind/port/cygwin/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/hpux/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/hpux10/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/hpux9/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/irix/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/lynxos/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/mpe/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/next/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/qnx/include/sys/cdefs.h | 5 +- dist/bind/lib/bind/port/sco42/include/sys/cdefs.h | 6 +- .../bind/lib/bind/port/solaris/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port/sunos/include/sys/cdefs.h | 6 +- .../lib/bind/port/unixware20/include/sys/cdefs.h | 6 +- .../lib/bind/port/unixware212/include/sys/cdefs.h | 6 +- dist/bind/lib/bind/port_after.h.in | 1 + dist/bind/lib/bind/resolv/res_debug.c | 8 +- dist/bind/lib/bind/resolv/res_mkupdate.c | 14 +- dist/bind/lib/bind/resolv/res_send.c | 9 +- dist/bind/lib/bind9/Makefile.in | 4 +- dist/bind/lib/bind9/api | 2 +- dist/bind/lib/bind9/check.c | 232 +++++---- dist/bind/lib/bind9/getaddresses.c | 67 ++- dist/bind/lib/dns/Makefile.in | 6 +- dist/bind/lib/dns/adb.c | 8 +- dist/bind/lib/dns/api | 2 +- dist/bind/lib/dns/byaddr.c | 5 +- dist/bind/lib/dns/dispatch.c | 129 +++-- dist/bind/lib/dns/dnssec.c | 6 +- dist/bind/lib/dns/include/dns/db.h | 14 +- dist/bind/lib/dns/include/dns/name.h | 13 +- dist/bind/lib/dns/include/dns/result.h | 7 +- dist/bind/lib/dns/include/dns/validator.h | 6 +- dist/bind/lib/dns/journal.c | 21 +- dist/bind/lib/dns/master.c | 7 +- dist/bind/lib/dns/masterdump.c | 17 +- dist/bind/lib/dns/message.c | 19 +- dist/bind/lib/dns/name.c | 21 +- dist/bind/lib/dns/rbtdb.c | 192 +++++-- dist/bind/lib/dns/rdata/generic/rrsig_46.c | 8 +- dist/bind/lib/dns/resolver.c | 199 +++++--- dist/bind/lib/dns/result.c | 7 +- dist/bind/lib/dns/sdb.c | 8 +- dist/bind/lib/dns/sec/dst/dst_api.c | 31 +- dist/bind/lib/dns/sec/dst/dst_result.c | 5 +- dist/bind/lib/dns/sec/dst/include/dst/dst.h | 6 +- dist/bind/lib/dns/sec/dst/include/dst/result.h | 7 +- dist/bind/lib/dns/time.c | 5 +- dist/bind/lib/dns/tkey.c | 14 +- dist/bind/lib/dns/validator.c | 280 ++++++++++- dist/bind/lib/dns/zone.c | 62 ++- dist/bind/lib/isc/Makefile.in | 4 +- dist/bind/lib/isc/api | 2 +- dist/bind/lib/isc/include/isc/result.h | 7 +- dist/bind/lib/isc/inet_ntop.c | 5 +- dist/bind/lib/isc/lex.c | 5 +- dist/bind/lib/isc/log.c | 27 +- dist/bind/lib/isc/netaddr.c | 7 +- dist/bind/lib/isc/result.c | 9 +- dist/bind/lib/isc/sockaddr.c | 12 +- dist/bind/lib/isc/unix/Makefile.in | 5 +- dist/bind/lib/isc/unix/ifiter_ioctl.c | 39 +- dist/bind/lib/isc/unix/interfaceiter.c | 10 +- dist/bind/lib/isc/unix/socket.c | 10 +- dist/bind/lib/isc/win32/socket.c | 437 ++++++++-------- dist/bind/lib/isccc/Makefile.in | 4 +- dist/bind/lib/isccc/api | 2 +- dist/bind/lib/isccc/cc.c | 5 +- dist/bind/lib/isccfg/Makefile.in | 4 +- dist/bind/lib/isccfg/api | 2 +- dist/bind/lib/isccfg/namedconf.c | 29 +- dist/bind/lib/isccfg/parser.c | 10 +- dist/bind/lib/lwres/Makefile.in | 8 +- dist/bind/lib/lwres/api | 2 +- dist/bind/lib/lwres/include/lwres/platform.h.in | 12 +- dist/bind/lib/lwres/lwinetntop.c | 5 +- dist/bind/lib/lwres/man/lwres.html | 156 +++--- dist/bind/lib/lwres/man/lwres_buffer.html | 270 ++++------ dist/bind/lib/lwres/man/lwres_config.html | 86 ++-- dist/bind/lib/lwres/man/lwres_context.html | 210 +++----- dist/bind/lib/lwres/man/lwres_gabn.html | 144 +++--- dist/bind/lib/lwres/man/lwres_gai_strerror.html | 60 ++- dist/bind/lib/lwres/man/lwres_getaddrinfo.html | 230 ++++----- dist/bind/lib/lwres/man/lwres_gethostent.html | 380 +++++++------- dist/bind/lib/lwres/man/lwres_getipnode.html | 166 +++--- dist/bind/lib/lwres/man/lwres_getnameinfo.html | 98 ++-- dist/bind/lib/lwres/man/lwres_getrrsetbyname.html | 148 +++--- dist/bind/lib/lwres/man/lwres_gnba.html | 120 +++-- dist/bind/lib/lwres/man/lwres_hstrerror.html | 50 +- dist/bind/lib/lwres/man/lwres_inetntop.html | 62 +-- dist/bind/lib/lwres/man/lwres_noop.html | 142 +++--- dist/bind/lib/lwres/man/lwres_packet.html | 120 ++--- dist/bind/lib/lwres/man/lwres_resutil.html | 166 +++--- dist/bind/lib/lwres/print.c | 555 +++++++++++++++++++++ dist/bind/lib/lwres/print_p.h | 88 ++++ dist/bind/lib/tests/Makefile.in | 4 +- dist/bind/lib/tests/include/tests/t_api.h | 5 +- dist/bind/lib/tests/t_api.c | 8 +- 115 files changed, 3517 insertions(+), 2382 deletions(-) create mode 100644 dist/bind/lib/lwres/print.c create mode 100644 dist/bind/lib/lwres/print_p.h (limited to 'dist/bind/lib') diff --git a/dist/bind/lib/bind/Makefile.in b/dist/bind/lib/bind/Makefile.in index 5ce2fa32c18..8d39bc5a02c 100644 --- a/dist/bind/lib/bind/Makefile.in +++ b/dist/bind/lib/bind/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.12.2.5.2.4 2004/03/06 08:13:21 marka Exp +# Id: Makefile.in,v 1.12.2.5.2.5 2004/07/20 07:01:56 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -100,7 +100,7 @@ libbind.@SA@: ${OBJS} libbind.la: ${OBJS} ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} -o libbind.la -rpath ${libdir} \ + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libbind.la -rpath ${libdir} \ -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ ${OBJS} ${LIBS} diff --git a/dist/bind/lib/bind/api b/dist/bind/lib/bind/api index c4b9059729e..3a72afa2cde 100644 --- a/dist/bind/lib/bind/api +++ b/dist/bind/lib/bind/api @@ -1,3 +1,3 @@ LIBINTERFACE = 3 -LIBREVISION = 2 +LIBREVISION = 7 LIBAGE = 0 diff --git a/dist/bind/lib/bind/configure b/dist/bind/lib/bind/configure index dd7cddb6f34..54c6c1097b2 100644 --- a/dist/bind/lib/bind/configure +++ b/dist/bind/lib/bind/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 1.83.2.5.2.1 . +# From configure.in Revision: 1.83.2.5.2.3 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # @@ -464,7 +464,7 @@ ac_includes_default="\ # include #endif" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE RANLIB ac_ct_RANLIB INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA STD_CINCLUDES STD_CDEFINES STD_CWARNINGS CCOPT AR ARFLAGS LN ETAGS PERL CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP ISC_PLATFORM_NEEDSYSSELECTH WANT_IRS_GR WANT_IRS_GR_OBJS WANT_IRS_PW WANT_IRS_PW_OBJS WANT_IRS_NIS WANT_IRS_NIS_OBJS WANT_IRS_NISGR_OBJS WANT_IRS_NISPW_OBJS WANT_IRS_DBPW_OBJS ALWAYS_DEFINES DO_PTHREADS WANT_IRS_THREADSGR_OBJS WANT_IRS_THREADSPW_OBJS WANT_IRS_THREADS_OBJS ISC_THREAD_DIR DAEMON_OBJS NEED_DAEMON STRSEP_OBJS NEED_STRSEP NEED_STRERROR MKDEPCC MKDEPCFLAGS MKDEPPROG IRIX_DNSSEC_WARNINGS_HACK purify_path PURIFY LN_S ECHO ac_ct_AR STRIP ac_ct_STRIP CXX CXXFLAGS ac_ct_CXX CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL O A SA LIBTOOL_MKDEP_SED LIBTOOL_MODE_COMPILE LIBTOOL_MODE_INSTALL LIBTOOL_MODE_LINK HAS_INET6_STRUCTS ISC_PLATFORM_NEEDNETINETIN6H ISC_PLATFORM_NEEDNETINET6IN6H HAS_IN_ADDR6 NEED_IN6ADDR_ANY ISC_PLATFORM_HAVEIN6PKTINFO ISC_PLATFORM_FIXIN6ISADDR ISC_IPV6_H ISC_IPV6_O ISC_ISCIPV6_O ISC_IPV6_C HAVE_SIN6_SCOPE_ID HAVE_SOCKADDR_STORAGE ISC_PLATFORM_NEEDNTOP ISC_PLATFORM_NEEDPTON ISC_PLATFORM_NEEDATON HAVE_SA_LEN HAVE_MINIMUM_IFREQ BSD_COMP SOLARIS_BITTYPES USE_FIONBIO_IOCTL PORT_DIR PORT_INCLUDE ISC_PLATFORM_MSGHDRFLAVOR ISC_PLATFORM_NEEDPORTT ISC_LWRES_ENDHOSTENTINT ISC_LWRES_SETNETENTINT ISC_LWRES_ENDNETENTINT ISC_LWRES_GETHOSTBYADDRVOID ISC_LWRES_NEEDHERRNO ISC_LWRES_GETIPNODEPROTO ISC_LWRES_GETADDRINFOPROTO ISC_LWRES_GETNAMEINFOPROTO NEED_PSELECT NEED_GETTIMEOFDAY HAVE_STRNDUP ISC_PLATFORM_NEEDSTRSEP ISC_PLATFORM_NEEDVSNPRINTF ISC_EXTRA_OBJS ISC_EXTRA_SRCS USE_SYSERROR_LIST ISC_PLATFORM_QUADFORMAT ISC_SOCKLEN_T GETGROUPLIST_ARGS NET_R_ARGS NET_R_BAD NET_R_COPY NET_R_COPY_ARGS NET_R_OK NET_R_SETANSWER NET_R_RETURN GETNETBYADDR_ADDR_T NETENT_DATA NET_R_ENT_ARGS NET_R_SET_RESULT NET_R_SET_RETURN NET_R_END_RESULT NET_R_END_RETURN GROUP_R_ARGS GROUP_R_BAD GROUP_R_OK GROUP_R_RETURN GROUP_R_END_RESULT GROUP_R_END_RETURN GROUP_R_ENT_ARGS GROUP_R_SET_RESULT GROUP_R_SET_RETURN HOST_R_ARGS HOST_R_BAD HOST_R_COPY HOST_R_COPY_ARGS HOST_R_ERRNO HOST_R_OK HOST_R_RETURN HOST_R_SETANSWER HOSTENT_DATA HOST_R_END_RESULT HOST_R_END_RETURN HOST_R_ENT_ARGS HOST_R_SET_RESULT HOST_R_SET_RETURN SETPWENT_VOID SETGRENT_VOID NGR_R_ARGS NGR_R_BAD NGR_R_COPY NGR_R_COPY_ARGS NGR_R_OK NGR_R_RETURN NGR_R_PRIVATE NGR_R_END_RESULT NGR_R_END_RETURN NGR_R_ENT_ARGS NGR_R_SET_RESULT NGR_R_SET_RETURN PROTO_R_ARGS PROTO_R_BAD PROTO_R_COPY PROTO_R_COPY_ARGS PROTO_R_OK PROTO_R_SETANSWER PROTO_R_RETURN PROTO_R_END_RESULT PROTO_R_END_RETURN PROTO_R_ENT_ARGS PROTO_R_SET_RESULT PROTO_R_SET_RETURN PASS_R_ARGS PASS_R_BAD PASS_R_COPY PASS_R_COPY_ARGS PASS_R_OK PASS_R_RETURN PASS_R_END_RESULT PASS_R_END_RETURN PASS_R_ENT_ARGS PASS_R_SET_RESULT PASS_R_SET_RETURN SERV_R_ARGS SERV_R_BAD SERV_R_COPY SERV_R_COPY_ARGS SERV_R_OK SERV_R_SETANSWER SERV_R_RETURN SERV_R_END_RESULT SERV_R_END_RETURN SERV_R_ENT_ARGS SERV_R_SET_RESULT SERV_R_SET_RETURN SETNETGRENT_ARGS INNETGR_ARGS ISC_PLATFORM_BRACEPTHREADONCEINIT BIND9_TOP_BUILDDIR BIND9_VERSION LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE RANLIB ac_ct_RANLIB INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA STD_CINCLUDES STD_CDEFINES STD_CWARNINGS CCOPT AR ARFLAGS LN ETAGS PERL CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP ISC_PLATFORM_NEEDSYSSELECTH WANT_IRS_GR WANT_IRS_GR_OBJS WANT_IRS_PW WANT_IRS_PW_OBJS WANT_IRS_NIS WANT_IRS_NIS_OBJS WANT_IRS_NISGR_OBJS WANT_IRS_NISPW_OBJS WANT_IRS_DBPW_OBJS ALWAYS_DEFINES DO_PTHREADS WANT_IRS_THREADSGR_OBJS WANT_IRS_THREADSPW_OBJS WANT_IRS_THREADS_OBJS USE_IFNAMELINKID ISC_THREAD_DIR DAEMON_OBJS NEED_DAEMON STRSEP_OBJS NEED_STRSEP NEED_STRERROR MKDEPCC MKDEPCFLAGS MKDEPPROG IRIX_DNSSEC_WARNINGS_HACK purify_path PURIFY LN_S ECHO ac_ct_AR STRIP ac_ct_STRIP CXX CXXFLAGS ac_ct_CXX CXXCPP F77 FFLAGS ac_ct_F77 LIBTOOL O A SA LIBTOOL_MKDEP_SED LIBTOOL_MODE_COMPILE LIBTOOL_MODE_INSTALL LIBTOOL_MODE_LINK HAS_INET6_STRUCTS ISC_PLATFORM_NEEDNETINETIN6H ISC_PLATFORM_NEEDNETINET6IN6H HAS_IN_ADDR6 NEED_IN6ADDR_ANY ISC_PLATFORM_HAVEIN6PKTINFO ISC_PLATFORM_FIXIN6ISADDR ISC_IPV6_H ISC_IPV6_O ISC_ISCIPV6_O ISC_IPV6_C HAVE_SIN6_SCOPE_ID HAVE_SOCKADDR_STORAGE ISC_PLATFORM_NEEDNTOP ISC_PLATFORM_NEEDPTON ISC_PLATFORM_NEEDATON HAVE_SA_LEN HAVE_MINIMUM_IFREQ BSD_COMP SOLARIS_BITTYPES USE_FIONBIO_IOCTL PORT_DIR PORT_INCLUDE ISC_PLATFORM_MSGHDRFLAVOR ISC_PLATFORM_NEEDPORTT ISC_LWRES_ENDHOSTENTINT ISC_LWRES_SETNETENTINT ISC_LWRES_ENDNETENTINT ISC_LWRES_GETHOSTBYADDRVOID ISC_LWRES_NEEDHERRNO ISC_LWRES_GETIPNODEPROTO ISC_LWRES_GETADDRINFOPROTO ISC_LWRES_GETNAMEINFOPROTO NEED_PSELECT NEED_GETTIMEOFDAY HAVE_STRNDUP ISC_PLATFORM_NEEDSTRSEP ISC_PLATFORM_NEEDVSNPRINTF ISC_EXTRA_OBJS ISC_EXTRA_SRCS USE_SYSERROR_LIST ISC_PLATFORM_QUADFORMAT ISC_SOCKLEN_T GETGROUPLIST_ARGS NET_R_ARGS NET_R_BAD NET_R_COPY NET_R_COPY_ARGS NET_R_OK NET_R_SETANSWER NET_R_RETURN GETNETBYADDR_ADDR_T NETENT_DATA NET_R_ENT_ARGS NET_R_SET_RESULT NET_R_SET_RETURN NET_R_END_RESULT NET_R_END_RETURN GROUP_R_ARGS GROUP_R_BAD GROUP_R_OK GROUP_R_RETURN GROUP_R_END_RESULT GROUP_R_END_RETURN GROUP_R_ENT_ARGS GROUP_R_SET_RESULT GROUP_R_SET_RETURN HOST_R_ARGS HOST_R_BAD HOST_R_COPY HOST_R_COPY_ARGS HOST_R_ERRNO HOST_R_OK HOST_R_RETURN HOST_R_SETANSWER HOSTENT_DATA HOST_R_END_RESULT HOST_R_END_RETURN HOST_R_ENT_ARGS HOST_R_SET_RESULT HOST_R_SET_RETURN SETPWENT_VOID SETGRENT_VOID NGR_R_ARGS NGR_R_BAD NGR_R_COPY NGR_R_COPY_ARGS NGR_R_OK NGR_R_RETURN NGR_R_PRIVATE NGR_R_END_RESULT NGR_R_END_RETURN NGR_R_ENT_ARGS NGR_R_SET_RESULT NGR_R_SET_RETURN PROTO_R_ARGS PROTO_R_BAD PROTO_R_COPY PROTO_R_COPY_ARGS PROTO_R_OK PROTO_R_SETANSWER PROTO_R_RETURN PROTO_R_END_RESULT PROTO_R_END_RETURN PROTO_R_ENT_ARGS PROTO_R_SET_RESULT PROTO_R_SET_RETURN PASS_R_ARGS PASS_R_BAD PASS_R_COPY PASS_R_COPY_ARGS PASS_R_OK PASS_R_RETURN PASS_R_END_RESULT PASS_R_END_RETURN PASS_R_ENT_ARGS PASS_R_SET_RESULT PASS_R_SET_RETURN SERV_R_ARGS SERV_R_BAD SERV_R_COPY SERV_R_COPY_ARGS SERV_R_OK SERV_R_SETANSWER SERV_R_RETURN SERV_R_END_RESULT SERV_R_END_RETURN SERV_R_ENT_ARGS SERV_R_SET_RESULT SERV_R_SET_RETURN SETNETGRENT_ARGS INNETGR_ARGS ISC_PLATFORM_BRACEPTHREADONCEINIT BIND9_TOP_BUILDDIR BIND9_VERSION LIBOBJS LTLIBOBJS' ac_subst_files='BIND9_INCLUDES BIND9_MAKE_RULES LIBBIND_API' # Initialize some variables set by options. @@ -5716,6 +5716,104 @@ fi +echo "$as_me:$LINENO: checking for if_nametoindex" >&5 +echo $ECHO_N "checking for if_nametoindex... $ECHO_C" >&6 +if test "${ac_cv_func_if_nametoindex+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define if_nametoindex to an innocuous variant, in case declares if_nametoindex. + For example, HP-UX 11i declares gettimeofday. */ +#define if_nametoindex innocuous_if_nametoindex + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char if_nametoindex (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef if_nametoindex + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char if_nametoindex (); +/* 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_if_nametoindex) || defined (__stub___if_nametoindex) +choke me +#else +char (*f) () = if_nametoindex; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != if_nametoindex; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_if_nametoindex=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_func_if_nametoindex=no +fi +rm -f conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_func_if_nametoindex" >&5 +echo "${ECHO_T}$ac_cv_func_if_nametoindex" >&6 +if test $ac_cv_func_if_nametoindex = yes; then + USE_IFNAMELINKID="#define USE_IFNAMELINKID 1" +else + USE_IFNAMELINKID="#undef USE_IFNAMELINKID" +fi + + + ISC_THREAD_DIR=$thread_dir @@ -7197,7 +7295,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 7200 "configure"' > conftest.$ac_ext + echo '#line 7298 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8187,7 +8285,7 @@ fi # Provide some information about the compiler. -echo "$as_me:8190:" \ +echo "$as_me:8288:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -9225,11 +9323,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9228: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9326: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9232: \$? = $ac_status" >&5 + echo "$as_me:9330: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -9458,11 +9556,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9461: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9559: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9465: \$? = $ac_status" >&5 + echo "$as_me:9563: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -9518,11 +9616,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9521: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9619: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9525: \$? = $ac_status" >&5 + echo "$as_me:9623: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11702,7 +11800,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:14084: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13990: \$? = $ac_status" >&5 + echo "$as_me:14088: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -14043,11 +14141,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:14046: $lt_compile\"" >&5) + (eval echo "\"\$as_me:14144: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:14050: \$? = $ac_status" >&5 + echo "$as_me:14148: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15404,7 +15502,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:16430: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:16336: \$? = $ac_status" >&5 + echo "$as_me:16434: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -16389,11 +16487,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:16392: $lt_compile\"" >&5) + (eval echo "\"\$as_me:16490: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:16396: \$? = $ac_status" >&5 + echo "$as_me:16494: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -18427,11 +18525,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18430: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18528: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:18434: \$? = $ac_status" >&5 + echo "$as_me:18532: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -18660,11 +18758,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18663: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18761: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:18667: \$? = $ac_status" >&5 + echo "$as_me:18765: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -18720,11 +18818,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:18723: $lt_compile\"" >&5) + (eval echo "\"\$as_me:18821: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:18727: \$? = $ac_status" >&5 + echo "$as_me:18825: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -20904,7 +21002,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <action != RESTGT_IGNORE) { + const char *nibsuff = res_get_nibblesuffix(pvt->res); qp = q->qname; for (n = IN6ADDRSZ - 1; n >= 0; n--) { i = SPRINTF((qp, "%x.%x.", uaddr[n] & 0xf, (uaddr[n] >> 4) & 0xf)); - if (i < 0) + if (i != 4) abort(); qp += i; } -#ifdef HAVE_STRLCAT - strlcat(q->qname, res_get_nibblesuffix(pvt->res), - sizeof(q->qname)); -#else - strcpy(qp, res_get_nibblesuffix(pvt->res)); -#endif + if (strlen(q->qname) + strlen(nibsuff) + 1 > + sizeof q->qname) { + errno = ENAMETOOLONG; + RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); + hp = NULL; + goto cleanup; + } + strcpy(qp, nibsuff); /* (checked) */ } if (q2->action != RESTGT_IGNORE) { + const char *nibsuff2 = res_get_nibblesuffix2(pvt->res); qp = q2->qname; for (n = IN6ADDRSZ - 1; n >= 0; n--) { i = SPRINTF((qp, "%x.%x.", uaddr[n] & 0xf, (uaddr[n] >> 4) & 0xf)); - if (i < 0) + if (i != 4) abort(); qp += i; } -#ifdef HAVE_STRLCAT - strlcat(q->qname, res_get_nibblesuffix2(pvt->res), - sizeof(q->qname)); -#else - strcpy(qp, res_get_nibblesuffix2(pvt->res)); -#endif + if (strlen(q2->qname) + strlen(nibsuff2) + 1 > + sizeof q2->qname) { + errno = ENAMETOOLONG; + RES_SET_H_ERRNO(pvt->res, NETDB_INTERNAL); + hp = NULL; + goto cleanup; + } + strcpy(qp, nibsuff2); /* (checked) */ } break; default: @@ -822,11 +828,7 @@ gethostans(struct irs_ho *this, had_error++; continue; } -#ifdef HAVE_STRLCPY - strlcpy(bp, tbuf, ep - bp); -#else - strcpy(bp, tbuf); -#endif + strcpy(bp, tbuf); /* (checked) */ pvt->host.h_name = bp; hname = bp; bp += n; @@ -858,11 +860,7 @@ gethostans(struct irs_ho *this, had_error++; continue; } -#ifdef HAVE_STRLCPY - strlcpy(bp, tbuf, ep - bp); -#else - strcpy(bp, tbuf); -#endif + strcpy(bp, tbuf); /* (checked) */ tname = bp; bp += n; continue; @@ -998,11 +996,7 @@ gethostans(struct irs_ho *this, n = strlen(qname) + 1; /* for the \0 */ if (n > (ep - bp) || n >= MAXHOSTNAMELEN) goto no_recovery; -#ifdef HAVE_STRLCPY - strlcpy(bp, qname, ep - bp); -#else - strcpy(bp, qname); -#endif + strcpy(bp, qname); /* (checked) */ pvt->host.h_name = bp; bp += n; } diff --git a/dist/bind/lib/bind/irs/dns_nw.c b/dist/bind/lib/bind/irs/dns_nw.c index 51d775121a5..38513776d41 100644 --- a/dist/bind/lib/bind/irs/dns_nw.c +++ b/dist/bind/lib/bind/irs/dns_nw.c @@ -1,4 +1,4 @@ -/* $NetBSD: dns_nw.c,v 1.1.1.1 2004/05/17 23:44:42 christos Exp $ */ +/* $NetBSD: dns_nw.c,v 1.1.1.2 2004/11/06 23:55:26 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "Id: dns_nw.c,v 1.3.2.4.4.2 2004/03/17 00:29:48 marka Exp"; +static const char rcsid[] = "Id: dns_nw.c,v 1.3.2.4.4.3 2004/05/17 07:48:56 marka Exp"; #endif /* LIBC_SCCS and not lint */ /* Imports. */ @@ -351,12 +351,7 @@ get1101answer(struct irs_nw *this, RES_SET_H_ERRNO(pvt->res, NO_RECOVERY); return (NULL); } -#ifdef HAVE_STRLCPY - strlcpy(bp, name, ep - bp); - pvt->net.n_name = bp; -#else - pvt->net.n_name = strcpy(bp, name); -#endif + pvt->net.n_name = strcpy(bp, name); /* (checked) */ bp += n; } break; diff --git a/dist/bind/lib/bind/irs/gen_gr.c b/dist/bind/lib/bind/irs/gen_gr.c index 0499e8e8ea4..91a305d2fb9 100644 --- a/dist/bind/lib/bind/irs/gen_gr.c +++ b/dist/bind/lib/bind/irs/gen_gr.c @@ -1,4 +1,4 @@ -/* $NetBSD: gen_gr.c,v 1.1.1.1 2004/05/17 23:44:42 christos Exp $ */ +/* $NetBSD: gen_gr.c,v 1.1.1.2 2004/11/06 23:55:26 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,7 @@ */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "Id: gen_gr.c,v 1.4.2.1.4.1 2004/03/09 08:33:35 marka Exp"; +static const char rcsid[] = "Id: gen_gr.c,v 1.4.2.1.4.2 2004/05/17 07:48:56 marka Exp"; #endif /* Imports */ @@ -85,7 +85,7 @@ static void gr_res_set(struct irs_gr *, struct __res_state *, void (*)(void *)); -static void grmerge(struct irs_gr *gr, const struct group *src, +static int grmerge(struct irs_gr *gr, const struct group *src, int preserve); static int countvec(char **vec); @@ -94,6 +94,10 @@ static int countnew(char **old, char **new); static size_t sizenew(char **old, char **new); static int newgid(int, gid_t *, gid_t); +/* Macros */ + +#define FREE_IF(x) do { if ((x) != NULL) { free(x); (x) = NULL; } } while (0) + /* Public */ struct irs_gr * @@ -173,7 +177,8 @@ gr_byname(struct irs_gr *this, const char *name) { gr = rule->inst->gr; tval = (*gr->byname)(gr, name); if (tval) { - grmerge(this, tval, dirty++); + if (!grmerge(this, tval, dirty++)) + return (NULL); if (!(rule->flags & IRS_MERGE)) break; } else { @@ -199,7 +204,8 @@ gr_bygid(struct irs_gr *this, gid_t gid) { gr = rule->inst->gr; tval = (*gr->bygid)(gr, gid); if (tval) { - grmerge(this, tval, dirty++); + if (!grmerge(this, tval, dirty++)) + return (NULL); if (!(rule->flags & IRS_MERGE)) break; } else { @@ -323,7 +329,7 @@ gr_res_set(struct irs_gr *this, struct __res_state *res, /* Private. */ -static void +static int grmerge(struct irs_gr *this, const struct group *src, int preserve) { struct pvt *pvt = (struct pvt *)this->private; char *cp, **m, **p, *oldmembuf, *ep; @@ -334,9 +340,9 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) { pvt->group.gr_gid = src->gr_gid; if (pvt->nmemb < 1) { m = malloc(sizeof *m); - if (!m) { + if (m == NULL) { /* No harm done, no work done. */ - return; + return (0); } pvt->group.gr_mem = m; pvt->nmemb = 1; @@ -353,9 +359,9 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) { n = ndst + nnew + 1; if ((size_t)n > pvt->nmemb) { m = realloc(pvt->group.gr_mem, n * sizeof *m); - if (!m) { + if (m == NULL) { /* No harm done, no work done. */ - return; + return (0); } pvt->group.gr_mem = m; pvt->nmemb = n; @@ -373,13 +379,13 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) { } if (n == 0) { /* No work to do. */ - return; + return (1); } used = preserve ? pvt->membufsize : 0; cp = malloc(used + n); - if (!cp) { + if (cp == NULL) { /* No harm done, no work done. */ - return; + return (0); } ep = cp + used + n; if (used != 0) @@ -403,12 +409,13 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) { if (isnew(pvt->group.gr_mem, *m)) { *p++ = cp; *p = NULL; -#ifdef HAVE_STRLCPY - strlcpy(cp, *m, ep - cp); -#else - strcpy(cp, *m); -#endif - cp += strlen(cp) + 1; + n = strlen(*m) + 1; + if (n > ep - cp) { + FREE_IF(oldmembuf); + return (0); + } + strcpy(cp, *m); /* (checked) */ + cp += n; } if (preserve) { pvt->group.gr_name = pvt->membuf + @@ -417,23 +424,26 @@ grmerge(struct irs_gr *this, const struct group *src, int preserve) { (pvt->group.gr_passwd - oldmembuf); } else { pvt->group.gr_name = cp; -#ifdef HAVE_STRLCPY - strlcpy(cp, src->gr_name, ep - cp); -#else - strcpy(cp, src->gr_name); -#endif - cp += strlen(src->gr_name) + 1; + n = strlen(src->gr_name) + 1; + if (n > ep - cp) { + FREE_IF(oldmembuf); + return (0); + } + strcpy(cp, src->gr_name); /* (checked) */ + cp += n; + pvt->group.gr_passwd = cp; -#ifdef HAVE_STRLCPY - strlcpy(cp, src->gr_passwd, ep - cp); -#else - strcpy(cp, src->gr_passwd); -#endif - cp += strlen(src->gr_passwd) + 1; + n = strlen(src->gr_passwd) + 1; + if (n > ep - cp) { + FREE_IF(oldmembuf); + return (0); + } + strcpy(cp, src->gr_passwd); /* (checked) */ + cp += n; } - if (oldmembuf != NULL) - free(oldmembuf); + FREE_IF(oldmembuf); INSIST(cp >= pvt->membuf && cp <= &pvt->membuf[pvt->membufsize]); + return (1); } static int diff --git a/dist/bind/lib/bind/irs/getaddrinfo.c b/dist/bind/lib/bind/irs/getaddrinfo.c index e4bb2ae8fba..bb80ca63ec2 100644 --- a/dist/bind/lib/bind/irs/getaddrinfo.c +++ b/dist/bind/lib/bind/irs/getaddrinfo.c @@ -1,4 +1,4 @@ -/* $NetBSD: getaddrinfo.c,v 1.1.1.1 2004/05/17 23:44:42 christos Exp $ */ +/* $NetBSD: getaddrinfo.c,v 1.1.1.2 2004/11/06 23:55:26 christos Exp $ */ /* $KAME: getaddrinfo.c,v 1.14 2001/01/06 09:41:15 jinmei Exp $ */ @@ -939,11 +939,7 @@ copy_ai(pai) free(ai); return NULL; } -#ifdef HAVE_STRLCPY - strlcpy(ai->ai_canonname, pai->ai_canonname, l); -#else - strncpy(ai->ai_canonname, pai->ai_canonname, l); -#endif + strcpy(ai->ai_canonname, pai->ai_canonname); /* (checked) */ } else { /* just to make sure */ ai->ai_canonname = NULL; @@ -1098,7 +1094,8 @@ ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, return (0); #ifdef USE_IFNAMELINKID - if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) { + if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) || + IN6_IS_ADDR_MC_NODELOCAL(a6)) { /* * Using interface names as link indices can be allowed * only when we can assume a one-to-one mappings between @@ -1106,6 +1103,7 @@ ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, */ scopeid = if_nametoindex(scope); if (scopeid == 0) + goto trynumeric; *scopeidp = scopeid; return (1); } diff --git a/dist/bind/lib/bind/irs/gethostent_r.c b/dist/bind/lib/bind/irs/gethostent_r.c index 70fd6e8cc09..1985eb4842c 100644 --- a/dist/bind/lib/bind/irs/gethostent_r.c +++ b/dist/bind/lib/bind/irs/gethostent_r.c @@ -1,4 +1,4 @@ -/* $NetBSD: gethostent_r.c,v 1.1.1.1 2004/05/17 23:44:42 christos Exp $ */ +/* $NetBSD: gethostent_r.c,v 1.1.1.2 2004/11/06 23:55:26 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "Id: gethostent_r.c,v 1.4.206.2 2004/04/22 03:32:06 marka Exp"; +static const char rcsid[] = "Id: gethostent_r.c,v 1.4.206.3 2004/09/01 02:03:07 marka Exp"; #endif /* LIBC_SCCS and not lint */ #include @@ -49,7 +49,7 @@ gethostbyname_r(const char *name, struct hostent *hptr, HOST_R_ARGS) { HOST_R_ERRNO; #ifdef HOST_R_SETANSWER - if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) == 0) + if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0) *answerp = NULL; else *answerp = hptr; @@ -74,7 +74,7 @@ gethostbyaddr_r(const char *addr, int len, int type, HOST_R_ERRNO; #ifdef HOST_R_SETANSWER - if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) == 0) + if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0) *answerp = NULL; else *answerp = hptr; @@ -104,7 +104,7 @@ gethostent_r(struct hostent *hptr, HOST_R_ARGS) { HOST_R_ERRNO; #ifdef HOST_R_SETANSWER - if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) == 0) + if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0) *answerp = NULL; else *answerp = hptr; diff --git a/dist/bind/lib/bind/irs/getnameinfo.c b/dist/bind/lib/bind/irs/getnameinfo.c index 757d3802ad4..4a51774e48e 100644 --- a/dist/bind/lib/bind/irs/getnameinfo.c +++ b/dist/bind/lib/bind/irs/getnameinfo.c @@ -1,4 +1,4 @@ -/* $NetBSD: getnameinfo.c,v 1.1.1.1 2004/05/17 23:44:43 christos Exp $ */ +/* $NetBSD: getnameinfo.c,v 1.1.1.2 2004/11/06 23:55:27 christos Exp $ */ /* * Issues to be discussed: @@ -156,7 +156,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) switch (sa->sa_family) { case AF_INET: - if (ntohl(*(const u_long *)addr) >> IN_CLASSA_NSHIFT == 0) + if (ntohl(*(const u_int32_t *)addr) >> IN_CLASSA_NSHIFT == 0) flags |= NI_NUMERICHOST; break; case AF_INET6: diff --git a/dist/bind/lib/bind/irs/hesiod.c b/dist/bind/lib/bind/irs/hesiod.c index 672d5efda59..ef540e04ad4 100644 --- a/dist/bind/lib/bind/irs/hesiod.c +++ b/dist/bind/lib/bind/irs/hesiod.c @@ -1,7 +1,7 @@ -/* $NetBSD: hesiod.c,v 1.1.1.1 2004/05/17 23:44:43 christos Exp $ */ +/* $NetBSD: hesiod.c,v 1.1.1.2 2004/11/06 23:55:27 christos Exp $ */ #if defined(LIBC_SCCS) && !defined(lint) -static const char rcsid[] = "Id: hesiod.c,v 1.1.2.1.4.2 2004/03/17 01:49:41 marka Exp"; +static const char rcsid[] = "Id: hesiod.c,v 1.1.2.1.4.3 2004/05/17 07:48:56 marka Exp"; #endif /* @@ -94,19 +94,14 @@ hesiod_init(void **context) { /* * Use compiled in defaults. */ - ctx->LHS = malloc(strlen(DEF_LHS)+1); - ctx->RHS = malloc(strlen(DEF_RHS)+1); - if (ctx->LHS == 0 || ctx->RHS == 0) { + ctx->LHS = malloc(strlen(DEF_LHS) + 1); + ctx->RHS = malloc(strlen(DEF_RHS) + 1); + if (ctx->LHS == NULL || ctx->RHS == NULL) { errno = ENOMEM; goto cleanup; } -#ifdef HAVE_STRLCPY - strlcpy(ctx->LHS, DEF_LHS, strlen(DEF_LHS) + 1); - strlcpy(ctx->RHS, DEF_RHS, strlen(DEF_RHS) + 1); -#else - strcpy(ctx->LHS, DEF_LHS); - strcpy(ctx->RHS, DEF_RHS); -#endif + strcpy(ctx->LHS, DEF_LHS); /* (checked) */ + strcpy(ctx->RHS, DEF_RHS); /* (checked) */ #else goto cleanup; #endif @@ -125,22 +120,10 @@ hesiod_init(void **context) { goto cleanup; } if (cp[0] == '.') { -#ifdef HAVE_STRLCPY - strlcpy(ctx->RHS, cp, RHSlen); -#else - strcpy(ctx->RHS, cp); -#endif + strcpy(ctx->RHS, cp); /* (checked) */ } else { -#ifdef HAVE_STRLCPY - strlcpy(ctx->RHS, ".", RHSlen); -#else - strcpy(ctx->RHS, "."); -#endif -#ifdef HAVE_STRLCAT - strlcat(ctx->RHS, cp, RHSlen); -#else - strcat(ctx->RHS, cp); -#endif + strcpy(ctx->RHS, "."); /* (checked) */ + strcat(ctx->RHS, cp); /* (checked) */ } } diff --git a/dist/bind/lib/bind/nameser/ns_name.c b/dist/bind/lib/bind/nameser/ns_name.c index fc86a33bed7..1a9dcb20740 100644 --- a/dist/bind/lib/bind/nameser/ns_name.c +++ b/dist/bind/lib/bind/nameser/ns_name.c @@ -1,4 +1,4 @@ -/* $NetBSD: ns_name.c,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: ns_name.c,v 1.1.1.2 2004/11/06 23:55:32 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,7 @@ */ #ifndef lint -static const char rcsid[] = "Id: ns_name.c,v 1.3.2.4.4.1 2004/03/09 08:33:44 marka Exp"; +static const char rcsid[] = "Id: ns_name.c,v 1.3.2.4.4.2 2004/05/04 03:27:47 marka Exp"; #endif #include "port_before.h" @@ -77,9 +77,11 @@ static int dn_find(const u_char *, const u_char *, const u_char * const *, const u_char * const *); static int encode_bitsring(const char **, const char *, - char **, char **, const char *); + unsigned char **, unsigned char **, + unsigned const char *); static int labellen(const u_char *); -static int decode_bitstring(const char **, char *, const char *); +static int decode_bitstring(const unsigned char **, + char *, const char *); /* Public. */ @@ -134,7 +136,7 @@ ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) errno = EINVAL; return(-1); } - if ((m = decode_bitstring((const char **)&cp, dn, eom)) < 0) + if ((m = decode_bitstring(&cp, dn, eom)) < 0) { errno = EMSGSIZE; return(-1); @@ -214,11 +216,8 @@ ns_name_pton(const char *src, u_char *dst, size_t dstsiz) errno = EINVAL; /* ??? */ return(-1); } - if ((e = encode_bitsring(&src, - cp + 2, - (char **)&label, - (char **)&bp, - (const char *)eom)) + if ((e = encode_bitsring(&src, cp + 2, + &label, &bp, eom)) != 0) { errno = e; return(-1); @@ -790,9 +789,9 @@ dn_find(const u_char *domain, const u_char *msg, } static int -decode_bitstring(const char **cpp, char *dn, const char *eom) +decode_bitstring(const unsigned char **cpp, char *dn, const char *eom) { - const char *cp = *cpp; + const unsigned char *cp = *cpp; char *beg = dn, tc; int b, blen, plen, i; @@ -838,12 +837,13 @@ decode_bitstring(const char **cpp, char *dn, const char *eom) } static int -encode_bitsring(const char **bp, const char *end, char **labelp, - char ** dst, const char *eom) +encode_bitsring(const char **bp, const char *end, unsigned char **labelp, + unsigned char ** dst, unsigned const char *eom) { int afterslash = 0; const char *cp = *bp; - char *tp, c; + unsigned char *tp; + char c; const char *beg_blen; char *end_blen = NULL; int value = 0, count = 0, tbcount = 0, blen = 0; diff --git a/dist/bind/lib/bind/nameser/ns_print.c b/dist/bind/lib/bind/nameser/ns_print.c index 5b49672e91c..6bf0c3ae3de 100644 --- a/dist/bind/lib/bind/nameser/ns_print.c +++ b/dist/bind/lib/bind/nameser/ns_print.c @@ -1,4 +1,4 @@ -/* $NetBSD: ns_print.c,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: ns_print.c,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,7 @@ */ #ifndef lint -static const char rcsid[] = "Id: ns_print.c,v 1.3.2.1.4.4 2004/03/17 01:13:36 marka Exp"; +static const char rcsid[] = "Id: ns_print.c,v 1.3.2.1.4.5 2004/07/28 20:16:45 marka Exp"; #endif /* Import. */ @@ -147,8 +147,6 @@ ns_sprintrrf(const u_char *msg, size_t msglen, addlen(x, &buf, &buflen); len = SPRINTF((tmp, " %s %s", p_class(class), p_type(type))); T(addstr(tmp, len, &buf, &buflen)); - if (rdlen == 0U) - return (buf - obuf); T(spaced = addtab(x + len, 16, spaced, &buf, &buflen)); /* @@ -709,7 +707,8 @@ ns_sprintrrf(const u_char *msg, size_t msglen, int n, m; char *p; - len = SPRINTF((tmp, "\\# %u (\t; %s", edata - rdata, comment)); + len = SPRINTF((tmp, "\\# %u%s\t; %s", edata - rdata, + rdlen != 0 ? " (" : "", comment)); T(addstr(tmp, len, &buf, &buflen)); while (rdata < edata) { p = tmp; diff --git a/dist/bind/lib/bind/port/aix32/include/sys/cdefs.h b/dist/bind/lib/bind/port/aix32/include/sys/cdefs.h index 5c43a903201..cd84342a093 100644 --- a/dist/bind/lib/bind/port/aix32/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/aix32/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/04/11 01:30:12 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:36 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/aix4/include/sys/cdefs.h b/dist/bind/lib/bind/port/aix4/include/sys/cdefs.h index 9e440940c95..efe7982b9c7 100644 --- a/dist/bind/lib/bind/port/aix4/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/aix4/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/10 04:23:15 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:37 marka Exp */ #ifndef _CDEFS_H_ @@ -132,7 +132,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/aux3/include/sys/cdefs.h b/dist/bind/lib/bind/port/aux3/include/sys/cdefs.h index 2cb1e61817b..bbc6d00afbb 100644 --- a/dist/bind/lib/bind/port/aux3/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/aux3/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * Copyright (c) 1991, 1993 @@ -116,7 +116,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/cygwin/include/sys/cdefs.h b/dist/bind/lib/bind/port/cygwin/include/sys/cdefs.h index 7f4ecdfa1cd..e70d6bd055f 100644 --- a/dist/bind/lib/bind/port/cygwin/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/cygwin/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1.150.1 2003/10/21 05:21:08 marka Exp + * Id: cdefs.h,v 1.1.150.2 2004/07/19 05:53:39 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/hpux/include/sys/cdefs.h b/dist/bind/lib/bind/port/hpux/include/sys/cdefs.h index 83f716670af..1e8539e162e 100644 --- a/dist/bind/lib/bind/port/hpux/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/hpux/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/04/09 09:17:16 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:40 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/hpux10/include/sys/cdefs.h b/dist/bind/lib/bind/port/hpux10/include/sys/cdefs.h index c46c6179023..1e8539e162e 100644 --- a/dist/bind/lib/bind/port/hpux10/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/hpux10/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:25:49 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:40 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/hpux9/include/sys/cdefs.h b/dist/bind/lib/bind/port/hpux9/include/sys/cdefs.h index 0246e7afbd8..62a512fca6f 100644 --- a/dist/bind/lib/bind/port/hpux9/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/hpux9/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:25:50 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:41 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/irix/include/sys/cdefs.h b/dist/bind/lib/bind/port/irix/include/sys/cdefs.h index 0246e7afbd8..3c4a167cdba 100644 --- a/dist/bind/lib/bind/port/irix/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/irix/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:25:50 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:42 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/lynxos/include/sys/cdefs.h b/dist/bind/lib/bind/port/lynxos/include/sys/cdefs.h index 981f8b41285..5464e896f6f 100644 --- a/dist/bind/lib/bind/port/lynxos/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/lynxos/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:25:51 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:43 marka Exp */ #ifndef _CDEFS_H_ @@ -131,7 +131,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/mpe/include/sys/cdefs.h b/dist/bind/lib/bind/port/mpe/include/sys/cdefs.h index 30da532ffa8..fd549ad23b9 100644 --- a/dist/bind/lib/bind/port/mpe/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/mpe/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:25:51 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:44 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/next/include/sys/cdefs.h b/dist/bind/lib/bind/port/next/include/sys/cdefs.h index 1a5c2f3b6ff..be59bb24b0a 100644 --- a/dist/bind/lib/bind/port/next/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/next/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:47 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:25:55 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:48 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/qnx/include/sys/cdefs.h b/dist/bind/lib/bind/port/qnx/include/sys/cdefs.h index 484dddf65e4..2675c203d7e 100644 --- a/dist/bind/lib/bind/port/qnx/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/qnx/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:46 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * Copyright (c) 1991, 1993 @@ -108,8 +108,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || \ - (__GNUC__ == 2 && __GNUC_MINOR__ < 5) +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/sco42/include/sys/cdefs.h b/dist/bind/lib/bind/port/sco42/include/sys/cdefs.h index 8fc7547e3d2..c94c9d1f126 100644 --- a/dist/bind/lib/bind/port/sco42/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/sco42/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:47 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:25:57 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:50 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/solaris/include/sys/cdefs.h b/dist/bind/lib/bind/port/solaris/include/sys/cdefs.h index b4272bc13e8..c94c9d1f126 100644 --- a/dist/bind/lib/bind/port/solaris/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/solaris/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:47 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/04/02 06:29:20 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:50 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/sunos/include/sys/cdefs.h b/dist/bind/lib/bind/port/sunos/include/sys/cdefs.h index 5550957e0d4..8a268cb23b1 100644 --- a/dist/bind/lib/bind/port/sunos/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/sunos/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:47 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:25:58 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:51 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/unixware20/include/sys/cdefs.h b/dist/bind/lib/bind/port/unixware20/include/sys/cdefs.h index 678bd9f8bba..38672bd4561 100644 --- a/dist/bind/lib/bind/port/unixware20/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/unixware20/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:47 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:26:00 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:52 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port/unixware212/include/sys/cdefs.h b/dist/bind/lib/bind/port/unixware212/include/sys/cdefs.h index 44a1704cdfe..5aa04f6ac2f 100644 --- a/dist/bind/lib/bind/port/unixware212/include/sys/cdefs.h +++ b/dist/bind/lib/bind/port/unixware212/include/sys/cdefs.h @@ -1,4 +1,4 @@ -/* $NetBSD: cdefs.h,v 1.1.1.1 2004/05/17 23:44:47 christos Exp $ */ +/* $NetBSD: cdefs.h,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * ++Copyright++ 1991, 1993 @@ -57,7 +57,7 @@ /* * @(#)cdefs.h 8.1 (Berkeley) 6/2/93 - * Id: cdefs.h,v 1.1 2001/05/17 06:26:01 marka Exp + * Id: cdefs.h,v 1.1.206.1 2004/07/19 05:53:53 marka Exp */ #ifndef _CDEFS_H_ @@ -129,7 +129,7 @@ * these work for GNU C++ (modulo a slight glitch in the C++ grammar * in the distribution version of 2.5.5). */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5 +#if !defined(__GNUC__) || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ #if defined(__GNUC__) && !defined(__STRICT_ANSI__) #define __dead __volatile diff --git a/dist/bind/lib/bind/port_after.h.in b/dist/bind/lib/bind/port_after.h.in index 9095982ec8f..6d5f4dca667 100644 --- a/dist/bind/lib/bind/port_after.h.in +++ b/dist/bind/lib/bind/port_after.h.in @@ -26,6 +26,7 @@ @USE_SYSERROR_LIST@ @INNETGR_ARGS@ @SETNETGRENT_ARGS@ +@USE_IFNAMELINKID@ /* XXX sunos and cygwin needs O_NDELAY */ #define PORT_NONBLOCK O_NONBLOCK diff --git a/dist/bind/lib/bind/resolv/res_debug.c b/dist/bind/lib/bind/resolv/res_debug.c index 91a1b001a53..cc4e18d7f6a 100644 --- a/dist/bind/lib/bind/resolv/res_debug.c +++ b/dist/bind/lib/bind/resolv/res_debug.c @@ -1,4 +1,4 @@ -/* $NetBSD: res_debug.c,v 1.1.1.1 2004/05/17 23:44:47 christos Exp $ */ +/* $NetBSD: res_debug.c,v 1.1.1.2 2004/11/06 23:55:33 christos Exp $ */ /* * Copyright (c) 1985 @@ -97,7 +97,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "Id: res_debug.c,v 1.3.2.5.4.4 2004/04/13 06:53:20 marka Exp"; +static const char rcsid[] = "Id: res_debug.c,v 1.3.2.5.4.5 2004/07/28 20:16:46 marka Exp"; #endif /* LIBC_SCCS and not lint */ #include "port_before.h" @@ -551,7 +551,7 @@ p_type(int type) { result = sym_ntos(__p_type_syms, type, &success); if (success) return (result); - if (type < 0 || type > 0xfff) + if (type < 0 || type > 0xffff) return ("BADTYPE"); sprintf(typebuf, "TYPE%d", type); return (typebuf); @@ -587,7 +587,7 @@ p_class(int class) { result = sym_ntos(__p_class_syms, class, &success); if (success) return (result); - if (class < 0 || class > 0xfff) + if (class < 0 || class > 0xffff) return ("BADCLASS"); sprintf(classbuf, "CLASS%d", class); return (classbuf); diff --git a/dist/bind/lib/bind/resolv/res_mkupdate.c b/dist/bind/lib/bind/resolv/res_mkupdate.c index 926925e7606..bf7174caca9 100644 --- a/dist/bind/lib/bind/resolv/res_mkupdate.c +++ b/dist/bind/lib/bind/resolv/res_mkupdate.c @@ -1,4 +1,4 @@ -/* $NetBSD: res_mkupdate.c,v 1.1.1.1 2004/05/17 23:44:47 christos Exp $ */ +/* $NetBSD: res_mkupdate.c,v 1.1.1.2 2004/11/06 23:55:34 christos Exp $ */ /* * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") @@ -23,7 +23,7 @@ */ #if !defined(lint) && !defined(SABER) -static const char rcsid[] = "Id: res_mkupdate.c,v 1.1.2.1.4.2 2004/03/16 12:34:19 marka Exp"; +static const char rcsid[] = "Id: res_mkupdate.c,v 1.1.2.1.4.3 2004/06/03 04:44:48 marka Exp"; #endif /* not lint */ #include "port_before.h" @@ -352,13 +352,13 @@ res_nmkupdate(res_state statp, ns_updrec *rrecp_in, u_char *buf, int buflen) { bm[i] = 0; while (getword_str(buf2, sizeof buf2, &startp, endp)) { - if ((n1 = res_servicenumber(buf2)) <= 0) + if ((n = res_servicenumber(buf2)) <= 0) return (-1); - if (n1 < MAXPORT) { - bm[n1/8] |= (0x80>>(n1%8)); - if (n1 > maxbm) - maxbm = n1; + if (n < MAXPORT) { + bm[n/8] |= (0x80>>(n%8)); + if ((unsigned)n > maxbm) + maxbm = n; } else return (-1); } diff --git a/dist/bind/lib/bind/resolv/res_send.c b/dist/bind/lib/bind/resolv/res_send.c index f9a2b309fe0..fb2e447b693 100644 --- a/dist/bind/lib/bind/resolv/res_send.c +++ b/dist/bind/lib/bind/resolv/res_send.c @@ -1,4 +1,4 @@ -/* $NetBSD: res_send.c,v 1.1.1.1 2004/05/17 23:44:48 christos Exp $ */ +/* $NetBSD: res_send.c,v 1.1.1.2 2004/11/06 23:55:34 christos Exp $ */ /* * Copyright (c) 1985, 1989, 1993 @@ -72,7 +72,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "Id: res_send.c,v 1.5.2.2.4.3 2004/04/12 06:54:59 marka Exp"; +static const char rcsid[] = "Id: res_send.c,v 1.5.2.2.4.5 2004/08/10 02:19:56 marka Exp"; #endif /* LIBC_SCCS and not lint */ /* @@ -174,7 +174,8 @@ res_ourserver_p(const res_state statp, const struct sockaddr *sa) { if (srv6->sin6_family == in6p->sin6_family && srv6->sin6_port == in6p->sin6_port && #ifdef HAVE_SIN6_SCOPE_ID - srv6->sin6_scope_id == in6p->sin6_scope_id && + (srv6->sin6_scope_id == 0 || + srv6->sin6_scope_id == in6p->sin6_scope_id) && #endif (IN6_IS_ADDR_UNSPECIFIED(&srv6->sin6_addr) || IN6_ARE_ADDR_EQUAL(&srv6->sin6_addr, &in6p->sin6_addr))) @@ -658,7 +659,7 @@ send_vc(res_state statp, len = INT16SZ; while ((n = read(statp->_vcsock, (char *)cp, (int)len)) > 0) { cp += n; - if ((len -= n) <= 0) + if ((len -= n) == 0) break; } if (n <= 0) { diff --git a/dist/bind/lib/bind9/Makefile.in b/dist/bind/lib/bind9/Makefile.in index a179b1e5713..368f06a5a7f 100644 --- a/dist/bind/lib/bind9/Makefile.in +++ b/dist/bind/lib/bind9/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.2.200.5 2004/03/08 09:04:26 marka Exp +# Id: Makefile.in,v 1.2.200.6 2004/07/20 07:01:57 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -59,7 +59,7 @@ libbind9.@SA@: ${OBJS} libbind9.la: ${OBJS} ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} -o libbind9.la -rpath ${libdir} \ + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libbind9.la -rpath ${libdir} \ -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ ${OBJS} ${LIBS} diff --git a/dist/bind/lib/bind9/api b/dist/bind/lib/bind9/api index 06977fcb711..dbaaf58cca8 100644 --- a/dist/bind/lib/bind9/api +++ b/dist/bind/lib/bind9/api @@ -1,3 +1,3 @@ LIBINTERFACE = 0 -LIBREVISION = 1 +LIBREVISION = 4 LIBAGE = 0 diff --git a/dist/bind/lib/bind9/check.c b/dist/bind/lib/bind9/check.c index 4e70b5f0797..53c79b3468f 100644 --- a/dist/bind/lib/bind9/check.c +++ b/dist/bind/lib/bind9/check.c @@ -1,4 +1,4 @@ -/* $NetBSD: check.c,v 1.1.1.1 2004/05/17 23:44:48 christos Exp $ */ +/* $NetBSD: check.c,v 1.1.1.2 2004/11/06 23:55:34 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: check.c,v 1.37.6.25 2004/04/15 23:56:28 marka Exp */ +/* Id: check.c,v 1.37.6.28 2004/07/29 00:08:08 marka Exp */ #include @@ -281,6 +281,39 @@ disabled_algorithms(cfg_obj_t *disabled, isc_log_t *logctx) { return (result); } +static isc_result_t +nameexist(cfg_obj_t *obj, const char *name, int value, isc_symtab_t *symtab, + const char *fmt, isc_log_t *logctx, isc_mem_t *mctx) +{ + char *key; + const char *file; + unsigned int line; + isc_result_t result; + isc_symvalue_t symvalue; + + key = isc_mem_strdup(mctx, name); + if (key == NULL) + return (ISC_R_NOMEMORY); + symvalue.as_pointer = obj; + result = isc_symtab_define(symtab, key, value, symvalue, + isc_symexists_reject); + if (result == ISC_R_EXISTS) { + RUNTIME_CHECK(isc_symtab_lookup(symtab, key, value, + &symvalue) == ISC_R_SUCCESS); + file = cfg_obj_file(symvalue.as_pointer); + line = cfg_obj_line(symvalue.as_pointer); + + if (file == NULL) + file = ""; + cfg_obj_log(obj, logctx, ISC_LOG_ERROR, fmt, key, file, line); + isc_mem_free(mctx, key); + result = ISC_R_EXISTS; + } else if (result != ISC_R_SUCCESS) { + isc_mem_free(mctx, key); + } + return (result); +} + static isc_result_t mustbesecure(cfg_obj_t *secure, isc_symtab_t *symtab, isc_log_t *logctx, isc_mem_t *mctx) @@ -292,9 +325,6 @@ mustbesecure(cfg_obj_t *secure, isc_symtab_t *symtab, isc_log_t *logctx, dns_name_t *name; isc_buffer_t b; isc_result_t result = ISC_R_SUCCESS; - isc_result_t tresult; - isc_symvalue_t symvalue; - char *key; dns_fixedname_init(&fixed); name = dns_fixedname_name(&fixed); @@ -302,42 +332,16 @@ mustbesecure(cfg_obj_t *secure, isc_symtab_t *symtab, isc_log_t *logctx, str = cfg_obj_asstring(obj); isc_buffer_init(&b, str, strlen(str)); isc_buffer_add(&b, strlen(str)); - tresult = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL); - if (tresult != ISC_R_SUCCESS) { + result = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL); + if (result != ISC_R_SUCCESS) { cfg_obj_log(obj, logctx, ISC_LOG_ERROR, "bad domain name '%s'", str); - result = tresult; } else { - dns_name_format(name, namebuf, sizeof(namebuf)); - key = isc_mem_strdup(mctx, namebuf); - if (key == NULL) - return (ISC_R_NOMEMORY); - symvalue.as_pointer = secure; - tresult = isc_symtab_define(symtab, key, 1, symvalue, - isc_symexists_reject); - if (tresult == ISC_R_EXISTS) { - const char *file; - unsigned int line; - - RUNTIME_CHECK(isc_symtab_lookup(symtab, key, 1, - &symvalue) == ISC_R_SUCCESS); - isc_mem_free(mctx, key); - file = cfg_obj_file(symvalue.as_pointer); - line = cfg_obj_line(symvalue.as_pointer); - - if (file == NULL) - file = ""; - - cfg_obj_log(secure, logctx, ISC_LOG_ERROR, - "dnssec-must-be-secure '%s': already " - "exists previous definition: %s:%u", - namebuf, file, line); - result = tresult; - } else if (tresult != ISC_R_SUCCESS) { - isc_mem_free(mctx, key); - result = tresult; - } + result = nameexist(secure, namebuf, 1, symtab, + "dnssec-must-be-secure '%s': already " + "exists previous definition: %s:%u", + logctx, mctx); } return (result); } @@ -355,6 +359,7 @@ check_options(cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx) { unsigned int i; cfg_obj_t *obj = NULL; cfg_listelt_t *element; + isc_symtab_t *symtab = NULL; static intervaltable intervals[] = { { "cleaning-interval", 60, 28 * 24 * 60 }, /* 28 days */ @@ -460,21 +465,70 @@ check_options(cfg_obj_t *options, isc_log_t *logctx, isc_mem_t *mctx) { obj = NULL; (void)cfg_map_get(options, "dnssec-lookaside", &obj); if (obj != NULL) { - dns_fixedname_t fixedname; - const char *dlv; - isc_buffer_t b; - - dlv = cfg_obj_asstring(obj); - dns_fixedname_init(&fixedname); - isc_buffer_init(&b, dlv, strlen(dlv)); - isc_buffer_add(&b, strlen(dlv)); - tresult = dns_name_fromtext(dns_fixedname_name(&fixedname), &b, - dns_rootname, ISC_TRUE, NULL); - if (tresult != ISC_R_SUCCESS) { - cfg_obj_log(obj, logctx, ISC_LOG_ERROR, - "bad domain name '%s'", dlv); + tresult = isc_symtab_create(mctx, 100, freekey, mctx, + ISC_TRUE, &symtab); + if (tresult != ISC_R_SUCCESS) result = tresult; + for (element = cfg_list_first(obj); + element != NULL; + element = cfg_list_next(element)) + { + dns_fixedname_t fixedname; + dns_name_t *name; + const char *dlv; + isc_buffer_t b; + + obj = cfg_listelt_value(element); + + dlv = cfg_obj_asstring(cfg_tuple_get(obj, "domain")); + dns_fixedname_init(&fixedname); + name = dns_fixedname_name(&fixedname); + isc_buffer_init(&b, dlv, strlen(dlv)); + isc_buffer_add(&b, strlen(dlv)); + tresult = dns_name_fromtext(name, &b, dns_rootname, + ISC_TRUE, NULL); + if (tresult != ISC_R_SUCCESS) { + cfg_obj_log(obj, logctx, ISC_LOG_ERROR, + "bad domain name '%s'", dlv); + result = tresult; + } + if (symtab != NULL) { + tresult = nameexist(obj, dlv, 1, symtab, + "dnssec-lookaside '%s': " + "already exists previous " + "definition: %s:%u", + logctx, mctx); + if (tresult != ISC_R_SUCCESS && + result == ISC_R_SUCCESS) + result = tresult; + } + /* + * XXXMPA to be removed when multiple lookaside + * namespaces are supported. + */ + if (!dns_name_equal(dns_rootname, name)) { + cfg_obj_log(obj, logctx, ISC_LOG_ERROR, + "dnssec-lookaside '%s': " + "non-root not yet supported", dlv); + if (result == ISC_R_SUCCESS) + result = ISC_R_FAILURE; + } + dlv = cfg_obj_asstring(cfg_tuple_get(obj, + "trust-anchor")); + dns_fixedname_init(&fixedname); + isc_buffer_init(&b, dlv, strlen(dlv)); + isc_buffer_add(&b, strlen(dlv)); + tresult = dns_name_fromtext(name, &b, dns_rootname, + ISC_TRUE, NULL); + if (tresult != ISC_R_SUCCESS) { + cfg_obj_log(obj, logctx, ISC_LOG_ERROR, + "bad domain name '%s'", dlv); + if (result == ISC_R_SUCCESS) + result = tresult; + } } + if (symtab != NULL) + isc_symtab_destroy(&symtab); } /* @@ -645,7 +699,6 @@ check_zoneconf(cfg_obj_t *zconfig, cfg_obj_t *config, isc_symtab_t *symtab, unsigned int ztype; cfg_obj_t *zoptions; cfg_obj_t *obj = NULL; - isc_symvalue_t symvalue; isc_result_t result = ISC_R_SUCCESS; isc_result_t tresult; unsigned int i; @@ -760,48 +813,22 @@ check_zoneconf(cfg_obj_t *zconfig, cfg_obj_t *config, isc_symtab_t *symtab, dns_fixedname_init(&fixedname); isc_buffer_init(&b, zname, strlen(zname)); isc_buffer_add(&b, strlen(zname)); - result = dns_name_fromtext(dns_fixedname_name(&fixedname), &b, + tresult = dns_name_fromtext(dns_fixedname_name(&fixedname), &b, dns_rootname, ISC_TRUE, NULL); if (result != ISC_R_SUCCESS) { cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR, "zone '%s': is not a valid name", zname); - result = ISC_R_FAILURE; + tresult = ISC_R_FAILURE; } else { char namebuf[DNS_NAME_FORMATSIZE]; - char *key; dns_name_format(dns_fixedname_name(&fixedname), namebuf, sizeof(namebuf)); - key = isc_mem_strdup(mctx, namebuf); - if (key == NULL) - return (ISC_R_NOMEMORY); - symvalue.as_pointer = zconfig; - tresult = isc_symtab_define(symtab, key, - ztype == HINTZONE ? 1 : 2, - symvalue, isc_symexists_reject); - if (tresult == ISC_R_EXISTS) { - const char *file; - unsigned int line; - - RUNTIME_CHECK(isc_symtab_lookup(symtab, key, - ztype == HINTZONE ? 1 : 2, - &symvalue) == ISC_R_SUCCESS); - isc_mem_free(mctx, key); - file = cfg_obj_file(symvalue.as_pointer); - line = cfg_obj_line(symvalue.as_pointer); - - if (file == NULL) - file = ""; - cfg_obj_log(zconfig, logctx, ISC_LOG_ERROR, - "zone '%s': already exists " - "previous definition: %s:%u", - zname, file, line); - result = ISC_R_FAILURE; - } else if (tresult != ISC_R_SUCCESS) { - isc_mem_free(mctx, key); - - return (tresult); - } + tresult = nameexist(zconfig, namebuf, ztype == HINTZONE ? 1 : 2, + symtab, "zone '%s': already exists " + "previous definition: %s:%u", logctx, mctx); + if (tresult != ISC_R_SUCCESS) + result = tresult; } /* @@ -1177,6 +1204,7 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) { cfg_listelt_t *velement; isc_result_t result = ISC_R_SUCCESS; isc_result_t tresult; + isc_symtab_t *symtab = NULL; static const char *builtin[] = { "localhost", "localnets", "any", "none"}; @@ -1218,6 +1246,9 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) { } } + tresult = isc_symtab_create(mctx, 100, NULL, NULL, ISC_TRUE, &symtab); + if (tresult != ISC_R_SUCCESS) + result = tresult; for (velement = cfg_list_first(views); velement != NULL; velement = cfg_list_next(velement)) @@ -1228,6 +1259,8 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) { cfg_obj_t *vclassobj = cfg_tuple_get(view, "class"); dns_rdataclass_t vclass = dns_rdataclass_in; isc_result_t tresult = ISC_R_SUCCESS; + const char *key = cfg_obj_asstring(vname); + isc_symvalue_t symvalue; if (cfg_obj_isstring(vclassobj)) { isc_textregion_t r; @@ -1240,12 +1273,43 @@ bind9_check_namedconf(cfg_obj_t *config, isc_log_t *logctx, isc_mem_t *mctx) { "view '%s': invalid class %s", cfg_obj_asstring(vname), r.base); } + if (tresult == ISC_R_SUCCESS && symtab != NULL) { + symvalue.as_pointer = view; + tresult = isc_symtab_define(symtab, key, vclass, + symvalue, + isc_symexists_reject); + if (tresult == ISC_R_EXISTS) { + const char *file; + unsigned int line; + RUNTIME_CHECK(isc_symtab_lookup(symtab, key, + vclass, &symvalue) == ISC_R_SUCCESS); + file = cfg_obj_file(symvalue.as_pointer); + line = cfg_obj_line(symvalue.as_pointer); + cfg_obj_log(view, logctx, ISC_LOG_ERROR, + "view '%s': already exists " + "previous definition: %s:%u", + key, file, line); + result = tresult; + } else if (result != ISC_R_SUCCESS) { + result = tresult; + } else if ((strcasecmp(key, "_bind") == 0 && + vclass == dns_rdataclass_ch) || + (strcasecmp(key, "_default") == 0 && + vclass == dns_rdataclass_in)) { + cfg_obj_log(view, logctx, ISC_LOG_ERROR, + "attempt to redefine builtin view " + "'%s'", key); + result = ISC_R_EXISTS; + } + } if (tresult == ISC_R_SUCCESS) tresult = check_viewconf(config, voptions, vclass, logctx, mctx); if (tresult != ISC_R_SUCCESS) result = ISC_R_FAILURE; } + if (symtab != NULL) + isc_symtab_destroy(&symtab); if (views != NULL && options != NULL) { obj = NULL; diff --git a/dist/bind/lib/bind9/getaddresses.c b/dist/bind/lib/bind9/getaddresses.c index 2b379b102f5..58745eb4d7e 100644 --- a/dist/bind/lib/bind9/getaddresses.c +++ b/dist/bind/lib/bind9/getaddresses.c @@ -1,4 +1,4 @@ -/* $NetBSD: getaddresses.c,v 1.1.1.1 2004/05/17 23:44:48 christos Exp $ */ +/* $NetBSD: getaddresses.c,v 1.1.1.2 2004/11/06 23:55:34 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: getaddresses.c,v 1.13.126.4 2004/03/08 09:04:27 marka Exp */ +/* Id: getaddresses.c,v 1.13.126.5 2004/05/15 03:46:12 jinmei Exp */ #include #include @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -69,19 +70,67 @@ bind9_getaddresses(const char *hostname, in_port_t port, have_ipv4 = (isc_net_probeipv4() == ISC_R_SUCCESS); have_ipv6 = (isc_net_probeipv6() == ISC_R_SUCCESS); - if (inet_pton(AF_INET6, hostname, &in6) == 1) { - if (!have_ipv6) - return (ISC_R_FAMILYNOSUPPORT); - isc_sockaddr_fromin6(&addrs[0], &in6, port); - *addrcount = 1; - return (ISC_R_SUCCESS); - } else if (inet_pton(AF_INET, hostname, &in4) == 1) { + /* + * Try IPv4, then IPv6. In order to handle the extended format + * for IPv6 scoped addresses (address%scope_ID), we'll use a local + * working buffer of 128 bytes. The length is an ad-hoc value, but + * should be enough for this purpose; the buffer can contain a string + * of at least 80 bytes for scope_ID in addition to any IPv6 numeric + * addresses (up to 46 bytes), the delimiter character and the + * terminating NULL character. + */ + if (inet_pton(AF_INET, hostname, &in4) == 1) { if (have_ipv4) isc_sockaddr_fromin(&addrs[0], &in4, port); else isc_sockaddr_v6fromin(&addrs[0], &in4, port); *addrcount = 1; return (ISC_R_SUCCESS); + } else if (strlen(hostname) <= 127) { + char tmpbuf[128], *d; + isc_uint32_t zone = 0; + + strcpy(tmpbuf, hostname); + d = strchr(tmpbuf, '%'); + if (d != NULL) + *d = '\0'; + + if (inet_pton(AF_INET6, tmpbuf, &in6) == 1) { + isc_netaddr_t na; + + if (!have_ipv6) + return (ISC_R_FAMILYNOSUPPORT); + + if (d != NULL) { +#ifdef ISC_PLATFORM_HAVESCOPEID + isc_result_t result; + + result = isc_netscope_pton(AF_INET6, d + 1, + &in6, &zone); + + if (result != ISC_R_SUCCESS) + return (result); +#else + /* + * The extended format is specified while the + * system does not provide the ability to use + * it. Throw an explicit error instead of + * ignoring the specified value. + */ + return (ISC_R_BADADDRESSFORM); +#endif + } + + isc_netaddr_fromin6(&na, &in6); + isc_netaddr_setzone(&na, zone); + isc_sockaddr_fromnetaddr(&addrs[0], + (const isc_netaddr_t *)&na, + port); + + *addrcount = 1; + return (ISC_R_SUCCESS); + + } } #ifdef USE_GETADDRINFO memset(&hints, 0, sizeof(hints)); diff --git a/dist/bind/lib/dns/Makefile.in b/dist/bind/lib/dns/Makefile.in index 15996afc583..eb1fd61f172 100644 --- a/dist/bind/lib/dns/Makefile.in +++ b/dist/bind/lib/dns/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.126.2.3.2.14 2004/04/15 00:34:52 marka Exp +# Id: Makefile.in,v 1.126.2.3.2.15 2004/07/20 07:01:57 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -107,7 +107,7 @@ libdns.@SA@: ${OBJS} libdns.la: ${OBJS} ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} -o libdns.la -rpath ${libdir} \ + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libdns.la -rpath ${libdir} \ -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ ${OBJS} ${ISCLIBS} @DNS_CRYPTO_LIBS@ ${LIBS} @@ -151,7 +151,7 @@ code.h: gen ./gen -s ${srcdir} > code.h gen: gen.c - ${CC} ${ALL_CFLAGS} -o $@ ${srcdir}/gen.c ${LIBS} + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o $@ ${srcdir}/gen.c ${LIBS} rbtdb64.@O@: rbtdb.c diff --git a/dist/bind/lib/dns/adb.c b/dist/bind/lib/dns/adb.c index 0272a008f23..192e0c3f170 100644 --- a/dist/bind/lib/dns/adb.c +++ b/dist/bind/lib/dns/adb.c @@ -1,4 +1,4 @@ -/* $NetBSD: adb.c,v 1.1.1.1 2004/05/17 23:44:49 christos Exp $ */ +/* $NetBSD: adb.c,v 1.1.1.2 2004/11/06 23:55:35 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: adb.c,v 1.181.2.11.2.17 2004/03/10 02:55:57 marka Exp */ +/* Id: adb.c,v 1.181.2.11.2.19 2004/09/01 05:19:57 marka Exp */ /* * Implementation notes @@ -1009,6 +1009,8 @@ set_target(dns_adb_t *adb, dns_name_t *name, dns_name_t *fname, dns_fixedname_init(&fixed2); new_target = dns_fixedname_name(&fixed2); dns_name_split(name, nlabels, prefix, NULL); + result = dns_name_concatenate(prefix, &dname.dname, new_target, + NULL); dns_rdata_freestruct(&dname); if (result != ISC_R_SUCCESS) return (result); @@ -1581,7 +1583,7 @@ find_name_and_lock(dns_adb_t *adb, dns_name_t *name, dns_adbname_t *adbname; int bucket; - bucket = dns_fullname_hash(name, ISC_FALSE) % NBUCKETS; + bucket = dns_name_fullhash(name, ISC_FALSE) % NBUCKETS; if (*bucketp == DNS_ADB_INVALIDBUCKET) { LOCK(&adb->namelocks[bucket]); diff --git a/dist/bind/lib/dns/api b/dist/bind/lib/dns/api index a8be9070823..444e0c5cd0c 100644 --- a/dist/bind/lib/dns/api +++ b/dist/bind/lib/dns/api @@ -1,3 +1,3 @@ -LIBINTERFACE = 14 +LIBINTERFACE = 20 LIBREVISION = 0 LIBAGE = 0 diff --git a/dist/bind/lib/dns/byaddr.c b/dist/bind/lib/dns/byaddr.c index 1cfdc079098..f2183f852a0 100644 --- a/dist/bind/lib/dns/byaddr.c +++ b/dist/bind/lib/dns/byaddr.c @@ -1,4 +1,4 @@ -/* $NetBSD: byaddr.c,v 1.1.1.1 2004/05/17 23:44:48 christos Exp $ */ +/* $NetBSD: byaddr.c,v 1.1.1.2 2004/11/06 23:55:34 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,12 +17,13 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: byaddr.c,v 1.29.2.1.2.7 2004/03/09 05:21:08 marka Exp */ +/* Id: byaddr.c,v 1.29.2.1.2.8 2004/08/28 06:25:18 marka Exp */ #include #include #include +#include #include /* Required for HP/UX (and others?) */ #include #include diff --git a/dist/bind/lib/dns/dispatch.c b/dist/bind/lib/dns/dispatch.c index e9d05054697..cd600f90bd3 100644 --- a/dist/bind/lib/dns/dispatch.c +++ b/dist/bind/lib/dns/dispatch.c @@ -1,4 +1,4 @@ -/* $NetBSD: dispatch.c,v 1.1.1.1 2004/05/17 23:44:49 christos Exp $ */ +/* $NetBSD: dispatch.c,v 1.1.1.2 2004/11/06 23:55:36 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: dispatch.c,v 1.101.2.6.2.7 2004/04/15 02:10:39 marka Exp */ +/* Id: dispatch.c,v 1.101.2.6.2.10 2004/09/01 04:27:41 marka Exp */ #include @@ -157,14 +157,14 @@ static isc_boolean_t destroy_disp_ok(dns_dispatch_t *); static void destroy_disp(isc_task_t *task, isc_event_t *event); static void udp_recv(isc_task_t *, isc_event_t *); static void tcp_recv(isc_task_t *, isc_event_t *); -static inline void startrecv(dns_dispatch_t *); +static void startrecv(dns_dispatch_t *); static dns_messageid_t dns_randomid(dns_qid_t *); static isc_uint32_t dns_hash(dns_qid_t *, isc_sockaddr_t *, dns_messageid_t); static void free_buffer(dns_dispatch_t *disp, void *buf, unsigned int len); static void *allocate_udp_buffer(dns_dispatch_t *disp); static inline void free_event(dns_dispatch_t *disp, dns_dispatchevent_t *ev); static inline dns_dispatchevent_t *allocate_event(dns_dispatch_t *disp); -static void do_cancel(dns_dispatch_t *disp, dns_dispentry_t *resp); +static void do_cancel(dns_dispatch_t *disp); static dns_dispentry_t *linear_first(dns_qid_t *disp); static dns_dispentry_t *linear_next(dns_qid_t *disp, dns_dispentry_t *resp); @@ -629,26 +629,25 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in) { /* query */ free_buffer(disp, ev->region.base, ev->region.length); goto restart; - } else { - /* response */ - bucket = dns_hash(qid, &ev->address, id); - LOCK(&qid->lock); - resp = bucket_search(qid, &ev->address, id, bucket); - UNLOCK(&qid->lock); - dispatch_log(disp, LVL(90), - "search for response in bucket %d: %s", - bucket, (resp == NULL ? "not found" : "found")); - - if (resp == NULL) { - free_buffer(disp, ev->region.base, ev->region.length); - goto restart; - } - queue_response = resp->item_out; - rev = allocate_event(resp->disp); - if (rev == NULL) { - free_buffer(disp, ev->region.base, ev->region.length); - goto restart; - } + } + + /* response */ + bucket = dns_hash(qid, &ev->address, id); + LOCK(&qid->lock); + resp = bucket_search(qid, &ev->address, id, bucket); + dispatch_log(disp, LVL(90), + "search for response in bucket %d: %s", + bucket, (resp == NULL ? "not found" : "found")); + + if (resp == NULL) { + free_buffer(disp, ev->region.base, ev->region.length); + goto unlock; + } + queue_response = resp->item_out; + rev = allocate_event(resp->disp); + if (rev == NULL) { + free_buffer(disp, ev->region.base, ev->region.length); + goto unlock; } /* @@ -676,6 +675,8 @@ udp_recv(isc_task_t *task, isc_event_t *ev_in) { resp->item_out = ISC_TRUE; isc_task_send(resp->task, ISC_EVENT_PTR(&rev)); } + unlock: + UNLOCK(&qid->lock); /* * Restart recv() to get the next packet. @@ -748,7 +749,7 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in) { case ISC_R_EOF: dispatch_log(disp, LVL(90), "shutting down on EOF"); - do_cancel(disp, NULL); + do_cancel(disp); break; case ISC_R_CONNECTIONRESET: @@ -762,7 +763,7 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in) { dispatch_log(disp, level, "shutting down due to TCP " "receive error: %s: %s", buf, isc_result_totext(tcpmsg->result)); - do_cancel(disp, NULL); + do_cancel(disp); break; } @@ -818,26 +819,25 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in) { * Query. */ goto restart; - } else { - /* - * Response. - */ - bucket = dns_hash(qid, &tcpmsg->address, id); - LOCK(&qid->lock); - resp = bucket_search(qid, &tcpmsg->address, id, bucket); - UNLOCK(&qid->lock); - dispatch_log(disp, LVL(90), - "search for response in bucket %d: %s", - bucket, (resp == NULL ? "not found" : "found")); - - if (resp == NULL) - goto restart; - queue_response = resp->item_out; - rev = allocate_event(disp); - if (rev == NULL) - goto restart; } + /* + * Response. + */ + bucket = dns_hash(qid, &tcpmsg->address, id); + LOCK(&qid->lock); + resp = bucket_search(qid, &tcpmsg->address, id, bucket); + dispatch_log(disp, LVL(90), + "search for response in bucket %d: %s", + bucket, (resp == NULL ? "not found" : "found")); + + if (resp == NULL) + goto unlock; + queue_response = resp->item_out; + rev = allocate_event(disp); + if (rev == NULL) + goto unlock; + /* * At this point, rev contains the event we want to fill in, and * resp contains the information on the place to send it to. @@ -860,6 +860,8 @@ tcp_recv(isc_task_t *task, isc_event_t *ev_in) { resp->item_out = ISC_TRUE; isc_task_send(resp->task, ISC_EVENT_PTR(&rev)); } + unlock: + UNLOCK(&qid->lock); /* * Restart recv() to get the next packet. @@ -907,7 +909,7 @@ startrecv(dns_dispatch_t *disp) { free_buffer(disp, region.base, region.length); disp->shutdown_why = res; disp->shutting_down = 1; - do_cancel(disp, NULL); + do_cancel(disp); return; } INSIST(disp->recv_pending == 0); @@ -920,7 +922,7 @@ startrecv(dns_dispatch_t *disp) { if (res != ISC_R_SUCCESS) { disp->shutdown_why = res; disp->shutting_down = 1; - do_cancel(disp, NULL); + do_cancel(disp); return; } INSIST(disp->recv_pending == 0); @@ -1296,7 +1298,7 @@ local_addr_match(dns_dispatch_t *disp, isc_sockaddr_t *addr) { if (result != ISC_R_SUCCESS) return (ISC_FALSE); - return (isc_sockaddr_equal(&disp->local, &sockaddr)); + return (isc_sockaddr_equal(&sockaddr, addr)); } /* @@ -2020,7 +2022,7 @@ dns_dispatch_removeresponse(dns_dispentry_t **resp, res->magic = 0; isc_mempool_put(disp->mgr->rpool, res); if (disp->shutting_down == 1) - do_cancel(disp, NULL); + do_cancel(disp); else startrecv(disp); @@ -2031,8 +2033,9 @@ dns_dispatch_removeresponse(dns_dispentry_t **resp, } static void -do_cancel(dns_dispatch_t *disp, dns_dispentry_t *resp) { +do_cancel(dns_dispatch_t *disp) { dns_dispatchevent_t *ev; + dns_dispentry_t *resp; dns_qid_t *qid; if (disp->shutdown_out == 1) @@ -2043,28 +2046,16 @@ do_cancel(dns_dispatch_t *disp, dns_dispentry_t *resp) { /* * Search for the first response handler without packets outstanding. */ - if (resp == NULL) { - LOCK(&qid->lock); - resp = linear_first(qid); - if (resp == NULL) { - /* no first item? */ - UNLOCK(&qid->lock); - return; - } - do { - if (resp->item_out == ISC_FALSE) - break; - - resp = linear_next(qid, resp); - } while (resp != NULL); - UNLOCK(&qid->lock); - } - + LOCK(&qid->lock); + for (resp = linear_first(qid); + resp != NULL && resp->item_out != ISC_FALSE; + /* Empty. */) + resp = linear_next(qid, resp); /* * No one to send the cancel event to, so nothing to do. */ if (resp == NULL) - return; + goto unlock; /* * Send the shutdown failsafe event to this resp. @@ -2081,6 +2072,8 @@ do_cancel(dns_dispatch_t *disp, dns_dispentry_t *resp) { ev, resp->task); resp->item_out = ISC_TRUE; isc_task_send(resp->task, ISC_EVENT_PTR(&ev)); + unlock: + UNLOCK(&qid->lock); } isc_socket_t * @@ -2116,7 +2109,7 @@ dns_dispatch_cancel(dns_dispatch_t *disp) { disp->shutdown_why = ISC_R_CANCELED; disp->shutting_down = 1; - do_cancel(disp, NULL); + do_cancel(disp); UNLOCK(&disp->lock); diff --git a/dist/bind/lib/dns/dnssec.c b/dist/bind/lib/dns/dnssec.c index 51f85529fe8..4787f308974 100644 --- a/dist/bind/lib/dns/dnssec.c +++ b/dist/bind/lib/dns/dnssec.c @@ -1,4 +1,4 @@ -/* $NetBSD: dnssec.c,v 1.1.1.1 2004/05/17 23:44:50 christos Exp $ */ +/* $NetBSD: dnssec.c,v 1.1.1.2 2004/11/06 23:55:36 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,7 @@ */ /* - * Id: dnssec.c,v 1.69.2.5.2.6 2004/03/08 21:06:26 marka Exp + * Id: dnssec.c,v 1.69.2.5.2.7 2004/06/11 00:30:54 marka Exp */ @@ -136,6 +136,8 @@ dns_dnssec_keyfromrdata(dns_name_t *name, dns_rdata_t *rdata, isc_mem_t *mctx, INSIST(mctx != NULL); INSIST(key != NULL); INSIST(*key == NULL); + REQUIRE(rdata->type == dns_rdatatype_key || + rdata->type == dns_rdatatype_dnskey); dns_rdata_toregion(rdata, &r); isc_buffer_init(&b, r.base, r.length); diff --git a/dist/bind/lib/dns/include/dns/db.h b/dist/bind/lib/dns/include/dns/db.h index 58e78ffb09c..c2ca6510acb 100644 --- a/dist/bind/lib/dns/include/dns/db.h +++ b/dist/bind/lib/dns/include/dns/db.h @@ -1,4 +1,4 @@ -/* $NetBSD: db.h,v 1.1.1.1 2004/05/17 23:44:57 christos Exp $ */ +/* $NetBSD: db.h,v 1.1.1.2 2004/11/06 23:55:44 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: db.h,v 1.67.12.7 2004/03/08 09:04:35 marka Exp */ +/* Id: db.h,v 1.67.12.8 2004/05/14 05:06:41 marka Exp */ #ifndef DNS_DB_H #define DNS_DB_H 1 @@ -190,6 +190,7 @@ struct dns_db { #define DNS_DBFIND_PENDINGOK 0x08 #define DNS_DBFIND_NOEXACT 0x10 #define DNS_DBFIND_FORCENSEC 0x20 +#define DNS_DBFIND_COVERINGNSEC 0x40 /* * Options that can be specified for dns_db_addrdataset(). @@ -649,6 +650,12 @@ dns_db_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, * is only necessary when querying a database that was not secure * when created. * + * If the DNS_DBFIND_COVERINGNSEC option is set, then look for a + * NSEC record that potentially covers 'name' if a answer cannot + * be found. Note the returned NSEC needs to be checked to ensure + * that it is correct. This only affects answers returned from the + * cache. + * * To respond to a query for SIG records, the caller should create a * rdataset iterator and extract the signatures from each rdataset. * @@ -772,6 +779,9 @@ dns_db_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, * DNS_R_EMPTYNAME The name exists but there is * no data at the name. * + * DNS_R_COVERINGNSEC The returned data is a NSEC + * that potentially covers 'name'. + * * Error results: * * ISC_R_NOMEMORY diff --git a/dist/bind/lib/dns/include/dns/name.h b/dist/bind/lib/dns/include/dns/name.h index a3aa4e93b69..7370f151227 100644 --- a/dist/bind/lib/dns/include/dns/name.h +++ b/dist/bind/lib/dns/include/dns/name.h @@ -1,4 +1,4 @@ -/* $NetBSD: name.h,v 1.1.1.1 2004/05/17 23:44:58 christos Exp $ */ +/* $NetBSD: name.h,v 1.1.1.2 2004/11/06 23:55:45 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: name.h,v 1.95.2.3.2.8 2004/03/16 12:57:17 marka Exp */ +/* Id: name.h,v 1.95.2.3.2.11 2004/09/01 05:19:59 marka Exp */ #ifndef DNS_NAME_H #define DNS_NAME_H 1 @@ -314,7 +314,7 @@ dns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive); */ unsigned int -dns_fullname_hash(dns_name_t *name, isc_boolean_t case_sensitive); +dns_name_fullhash(dns_name_t *name, isc_boolean_t case_sensitive); /* * Provide a hash value for 'name'. Unlike dns_name_hash(), this function * always takes into account of the entire name to calculate the hash value. @@ -575,6 +575,9 @@ dns_name_getlabelsequence(const dns_name_t *source, unsigned int first, * Notes: * Numbering starts at 0. * + * Given "rc.vix.com.", the label 0 is "rc", and label 3 is the + * root label. + * * 'target' refers to the same memory as 'source', so 'source' * must not be changed while 'target' is still in use. * @@ -1216,7 +1219,7 @@ do { \ do { \ (r)->base = (n)->ndata; \ (r)->length = (n)->length; \ -} while (0); +} while (0) #define DNS_NAME_SPLIT(n, l, p, s) \ do { \ @@ -1228,7 +1231,7 @@ do { \ dns_name_getlabelsequence(_n, 0, _n->labels - _l, _p); \ if (_s != NULL) \ dns_name_getlabelsequence(_n, _n->labels - _l, _l, _s); \ -} while (0); +} while (0) #ifdef DNS_NAME_USEINLINE diff --git a/dist/bind/lib/dns/include/dns/result.h b/dist/bind/lib/dns/include/dns/result.h index d2fc5c76b58..bf98b76e610 100644 --- a/dist/bind/lib/dns/include/dns/result.h +++ b/dist/bind/lib/dns/include/dns/result.h @@ -1,4 +1,4 @@ -/* $NetBSD: result.h,v 1.1.1.1 2004/05/17 23:44:58 christos Exp $ */ +/* $NetBSD: result.h,v 1.1.1.2 2004/11/06 23:55:45 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: result.h,v 1.81.2.7.2.12 2004/04/15 23:56:32 marka Exp */ +/* Id: result.h,v 1.81.2.7.2.13 2004/05/14 05:06:41 marka Exp */ #ifndef DNS_RESULT_H #define DNS_RESULT_H 1 @@ -144,8 +144,9 @@ #define DNS_R_DYNAMIC (ISC_RESULTCLASS_DNS + 98) #define DNS_R_UNKNOWNCOMMAND (ISC_RESULTCLASS_DNS + 99) #define DNS_R_MUSTBESECURE (ISC_RESULTCLASS_DNS + 100) +#define DNS_R_COVERINGNSEC (ISC_RESULTCLASS_DNS + 101) -#define DNS_R_NRESULTS 101 /* Number of results */ +#define DNS_R_NRESULTS 102 /* Number of results */ /* * DNS wire format rcodes. diff --git a/dist/bind/lib/dns/include/dns/validator.h b/dist/bind/lib/dns/include/dns/validator.h index 578222d3cbe..98ca73586c8 100644 --- a/dist/bind/lib/dns/include/dns/validator.h +++ b/dist/bind/lib/dns/include/dns/validator.h @@ -1,4 +1,4 @@ -/* $NetBSD: validator.h,v 1.1.1.1 2004/05/17 23:44:58 christos Exp $ */ +/* $NetBSD: validator.h,v 1.1.1.2 2004/11/06 23:55:45 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: validator.h,v 1.18.12.6 2004/04/15 23:56:33 marka Exp */ +/* Id: validator.h,v 1.18.12.7 2004/05/14 05:06:41 marka Exp */ #ifndef DNS_VALIDATOR_H #define DNS_VALIDATOR_H 1 @@ -123,6 +123,8 @@ struct dns_validator { dns_fixedname_t wild; ISC_LINK(dns_validator_t) link; dns_rdataset_t * dlv; + dns_fixedname_t dlvsep; + isc_boolean_t havedlvsep; isc_boolean_t mustbesecure; }; diff --git a/dist/bind/lib/dns/journal.c b/dist/bind/lib/dns/journal.c index 42a331c07c7..7433e39e7f1 100644 --- a/dist/bind/lib/dns/journal.c +++ b/dist/bind/lib/dns/journal.c @@ -1,4 +1,4 @@ -/* $NetBSD: journal.c,v 1.1.1.1 2004/05/17 23:44:50 christos Exp $ */ +/* $NetBSD: journal.c,v 1.1.1.2 2004/11/06 23:55:37 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: journal.c,v 1.77.2.1.10.6 2004/03/08 09:04:30 marka Exp */ +/* Id: journal.c,v 1.77.2.1.10.8 2004/05/14 05:27:47 marka Exp */ #include @@ -1824,10 +1824,16 @@ dns_db_diff(isc_mem_t *mctx, dns_fixedname_init(&fixname[0]); dns_fixedname_init(&fixname[1]); - CHECK(dns_journal_open(mctx, journal_filename, ISC_TRUE, &journal)); + result = dns_journal_open(mctx, journal_filename, ISC_TRUE, &journal); + if (result != ISC_R_SUCCESS) + return (result); - CHECK(dns_db_createiterator(db[0], ISC_FALSE, &dbit[0])); - CHECK(dns_db_createiterator(db[1], ISC_FALSE, &dbit[1])); + result = dns_db_createiterator(db[0], ISC_FALSE, &dbit[0]); + if (result != ISC_R_SUCCESS) + goto cleanup_journal; + result = dns_db_createiterator(db[1], ISC_FALSE, &dbit[1]); + if (result != ISC_R_SUCCESS) + goto cleanup_interator0; itresult[0] = dns_dbiterator_first(dbit[0]); itresult[1] = dns_dbiterator_first(dbit[1]); @@ -1900,8 +1906,10 @@ dns_db_diff(isc_mem_t *mctx, failure: dns_diff_clear(&resultdiff); - dns_dbiterator_destroy(&dbit[0]); dns_dbiterator_destroy(&dbit[1]); + cleanup_interator0: + dns_dbiterator_destroy(&dbit[0]); + cleanup_journal: dns_journal_destroy(&journal); return (result); } @@ -2117,6 +2125,7 @@ index_to_disk(dns_journal_t *j) { } INSIST(p == j->rawindex + rawbytes); + CHECK(journal_seek(j, sizeof(journal_rawheader_t))); CHECK(journal_write(j, j->rawindex, rawbytes)); } failure: diff --git a/dist/bind/lib/dns/master.c b/dist/bind/lib/dns/master.c index 50b796512c5..43a6d2f64ec 100644 --- a/dist/bind/lib/dns/master.c +++ b/dist/bind/lib/dns/master.c @@ -1,4 +1,4 @@ -/* $NetBSD: master.c,v 1.1.1.1 2004/05/17 23:44:51 christos Exp $ */ +/* $NetBSD: master.c,v 1.1.1.2 2004/11/06 23:55:37 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: master.c,v 1.122.2.8.2.13 2004/03/08 02:07:53 marka Exp */ +/* Id: master.c,v 1.122.2.8.2.14 2004/05/05 01:32:16 marka Exp */ #include @@ -1647,7 +1647,8 @@ load(dns_loadctx_t *lctx) { } - if (type == dns_rdatatype_rrsig) + if (type == dns_rdatatype_rrsig || + type == dns_rdatatype_sig) covers = dns_rdata_covers(&rdata[rdcount]); else covers = 0; diff --git a/dist/bind/lib/dns/masterdump.c b/dist/bind/lib/dns/masterdump.c index ab3cf3d2e28..f3457bbda06 100644 --- a/dist/bind/lib/dns/masterdump.c +++ b/dist/bind/lib/dns/masterdump.c @@ -1,4 +1,4 @@ -/* $NetBSD: masterdump.c,v 1.1.1.1 2004/05/17 23:44:49 christos Exp $ */ +/* $NetBSD: masterdump.c,v 1.1.1.2 2004/11/06 23:55:35 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: masterdump.c,v 1.56.2.5.2.10 2004/03/08 09:04:30 marka Exp */ +/* Id: masterdump.c,v 1.56.2.5.2.12 2004/08/28 06:25:19 marka Exp */ #include @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -981,6 +982,7 @@ closeandrename(FILE *f, isc_result_t result, const char *temp, const char *file) static void dump_quantum(isc_task_t *task, isc_event_t *event) { isc_result_t result; + isc_result_t tresult; dns_dumpctx_t *dctx; REQUIRE(event != NULL); @@ -996,11 +998,12 @@ dump_quantum(isc_task_t *task, isc_event_t *event) { return; } - if (dctx->file != NULL) - result = closeandrename(dctx->f, result, - dctx->tmpfile, dctx->file); - if (dctx->version != NULL) - dns_db_closeversion(dctx->db, &dctx->version, ISC_FALSE); + if (dctx->file != NULL) { + tresult = closeandrename(dctx->f, result, + dctx->tmpfile, dctx->file); + if (tresult != ISC_R_SUCCESS && result == ISC_R_SUCCESS) + result = tresult; + } (dctx->done)(dctx->done_arg, result); isc_event_free(&event); dns_dumpctx_detach(&dctx); diff --git a/dist/bind/lib/dns/message.c b/dist/bind/lib/dns/message.c index 693930d1863..30be78789fe 100644 --- a/dist/bind/lib/dns/message.c +++ b/dist/bind/lib/dns/message.c @@ -1,4 +1,4 @@ -/* $NetBSD: message.c,v 1.1.1.1 2004/05/17 23:44:51 christos Exp $ */ +/* $NetBSD: message.c,v 1.1.1.2 2004/11/06 23:55:38 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: message.c,v 1.194.2.10.2.16 2004/03/10 00:48:49 marka Exp */ +/* Id: message.c,v 1.194.2.10.2.17 2004/05/05 01:32:16 marka Exp */ /*** *** Imports @@ -1290,18 +1290,16 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, if (result != ISC_R_SUCCESS) goto cleanup; rdata->rdclass = rdclass; + issigzero = ISC_FALSE; if (rdtype == dns_rdatatype_rrsig && rdata->flags == 0) { covers = dns_rdata_covers(rdata); if (covers == 0) DO_FORMERR; - } else - covers = 0; - - issigzero = ISC_FALSE; - if (rdtype == dns_rdatatype_sig /* SIG(0) */ && - rdata->flags == 0) { - if (dns_rdata_covers(rdata) == 0) { + } else if (rdtype == dns_rdatatype_sig /* SIG(0) */ && + rdata->flags == 0) { + covers = dns_rdata_covers(rdata); + if (covers == 0) { if (sectionid != DNS_SECTION_ADDITIONAL || count != msg->counts[sectionid] - 1) DO_FORMERR; @@ -1310,7 +1308,8 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, skip_type_search = ISC_TRUE; issigzero = ISC_TRUE; } - } + } else + covers = 0; /* * If we are doing a dynamic update or this is a meta-type, diff --git a/dist/bind/lib/dns/name.c b/dist/bind/lib/dns/name.c index 8f6261e96f1..dac5874e8f4 100644 --- a/dist/bind/lib/dns/name.c +++ b/dist/bind/lib/dns/name.c @@ -1,4 +1,4 @@ -/* $NetBSD: name.c,v 1.1.1.1 2004/05/17 23:44:51 christos Exp $ */ +/* $NetBSD: name.c,v 1.1.1.2 2004/11/06 23:55:38 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: name.c,v 1.127.2.7.2.10 2004/04/19 21:55:38 marka Exp */ +/* Id: name.c,v 1.127.2.7.2.11 2004/09/01 05:19:59 marka Exp */ #include @@ -181,6 +181,9 @@ static dns_name_t wild = /* XXXDCL make const? */ LIBDNS_EXTERNAL_DATA dns_name_t *dns_wildcardname = &wild; +unsigned int +dns_fullname_hash(dns_name_t *name, isc_boolean_t case_sensitive); + static void set_offsets(const dns_name_t *name, unsigned char *offsets, dns_name_t *set_name); @@ -432,7 +435,7 @@ dns_name_hash(dns_name_t *name, isc_boolean_t case_sensitive) { } unsigned int -dns_fullname_hash(dns_name_t *name, isc_boolean_t case_sensitive) { +dns_name_fullhash(dns_name_t *name, isc_boolean_t case_sensitive) { /* * Provide a hash value for 'name'. */ @@ -445,6 +448,18 @@ dns_fullname_hash(dns_name_t *name, isc_boolean_t case_sensitive) { name->length, case_sensitive)); } +unsigned int +dns_fullname_hash(dns_name_t *name, isc_boolean_t case_sensitive) { + /* + * This function was deprecated due to the breakage of the name space + * convention. We only keep this internally to provide binary backward + * compatibility. + */ + REQUIRE(VALID_NAME(name)); + + return (dns_name_fullhash(name, case_sensitive)); +} + unsigned int dns_name_hashbylabel(dns_name_t *name, isc_boolean_t case_sensitive) { unsigned char *offsets; diff --git a/dist/bind/lib/dns/rbtdb.c b/dist/bind/lib/dns/rbtdb.c index 87e9f72f227..181af9195c7 100644 --- a/dist/bind/lib/dns/rbtdb.c +++ b/dist/bind/lib/dns/rbtdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: rbtdb.c,v 1.1.1.1 2004/05/17 23:44:52 christos Exp $ */ +/* $NetBSD: rbtdb.c,v 1.1.1.2 2004/11/06 23:55:39 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: rbtdb.c,v 1.168.2.11.2.12 2004/03/08 02:07:55 marka Exp */ +/* Id: rbtdb.c,v 1.168.2.11.2.16 2004/05/23 11:07:23 marka Exp */ /* * Principal Author: Bob Halley @@ -844,8 +844,7 @@ clean_zone_node(dns_rbtdb_t *rbtdb, dns_rbtnode_t *node, /* * If this is a NONEXISTENT rdataset, we can delete it. */ - if ((current->attributes & RDATASET_ATTR_NONEXISTENT) - != 0) { + if (NONEXISTENT(current)) { if (top_prev != NULL) top_prev->next = current->next; else @@ -1064,9 +1063,13 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { * isn't being used by anyone, we can clean * it up. */ - if (rbtdb->current_version->references == 0) + if (rbtdb->current_version->references == 0) { cleanup_version = rbtdb->current_version; + APPENDLIST(version->changed_list, + cleanup_version->changed_list, + link); + } /* * Become the current version. */ @@ -1079,6 +1082,7 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { * We're rolling back this transaction. */ cleanup_list = version->changed_list; + ISC_LIST_INIT(version->changed_list); rollback = ISC_TRUE; cleanup_version = version; rbtdb->future_version = NULL; @@ -1099,6 +1103,7 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { if (least_greater == NULL) least_greater = rbtdb->current_version; + INSIST(version->serial < least_greater->serial); /* * Is this the least open version? */ @@ -1119,16 +1124,19 @@ closeversion(dns_db_t *db, dns_dbversion_t **versionp, isc_boolean_t commit) { version->changed_list, link); } - } + } else if (version->serial == rbtdb->least_serial) + INSIST(EMPTY(version->changed_list)); UNLINK(rbtdb->open_versions, version, link); } } least_serial = rbtdb->least_serial; UNLOCK(&rbtdb->lock); - if (cleanup_version != NULL) + if (cleanup_version != NULL) { + INSIST(EMPTY(cleanup_version->changed_list)); isc_mem_put(rbtdb->common.mctx, cleanup_version, sizeof(*cleanup_version)); + } if (!EMPTY(cleanup_list)) { for (changed = HEAD(cleanup_list); @@ -1933,8 +1941,7 @@ find_closest_nsec(rbtdb_search_t *search, dns_dbnode_t **nodep, * Is this a "this rdataset doesn't * exist" record? */ - if ((header->attributes & - RDATASET_ATTR_NONEXISTENT) != 0) + if (NONEXISTENT(header)) header = NULL; break; } else @@ -2206,8 +2213,7 @@ zone_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, * Is this a "this rdataset doesn't * exist" record? */ - if ((header->attributes & - RDATASET_ATTR_NONEXISTENT) != 0) + if (NONEXISTENT(header)) header = NULL; break; } else @@ -2660,8 +2666,7 @@ find_deepest_zonecut(rbtdb_search_t *search, dns_rbtnode_t *node, node->dirty = 1; header_prev = header; } - } else if ((header->attributes & - RDATASET_ATTR_NONEXISTENT) == 0) { + } else if (EXISTS(header)) { /* * We've found an extant rdataset. See if * we're interested in it. @@ -2737,6 +2742,104 @@ find_deepest_zonecut(rbtdb_search_t *search, dns_rbtnode_t *node, return (result); } +static isc_result_t +find_coveringnsec(rbtdb_search_t *search, dns_dbnode_t **nodep, + isc_stdtime_t now, dns_name_t *foundname, + dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset) +{ + dns_rbtnode_t *node; + rdatasetheader_t *header, *header_next, *header_prev; + rdatasetheader_t *found, *foundsig; + isc_boolean_t empty_node; + isc_result_t result; + dns_fixedname_t fname, forigin; + dns_name_t *name, *origin; + rbtdb_rdatatype_t matchtype, sigmatchtype, nsectype; + + matchtype = RBTDB_RDATATYPE_VALUE(dns_rdatatype_nsec, 0); + nsectype = RBTDB_RDATATYPE_VALUE(0, dns_rdatatype_nsec); + sigmatchtype = RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, + dns_rdatatype_nsec); + + do { + node = NULL; + dns_fixedname_init(&fname); + name = dns_fixedname_name(&fname); + dns_fixedname_init(&forigin); + origin = dns_fixedname_name(&forigin); + result = dns_rbtnodechain_current(&search->chain, name, + origin, &node); + if (result != ISC_R_SUCCESS) + return (result); + LOCK(&(search->rbtdb->node_locks[node->locknum].lock)); + found = NULL; + foundsig = NULL; + empty_node = ISC_TRUE; + header_prev = NULL; + for (header = node->data; + header != NULL; + header = header_next) { + header_next = header->next; + if (header->ttl <= now) { + /* + * This rdataset is stale. If no one else is + * using the node, we can clean it up right + * now, otherwise we mark it as stale, and the + * node as dirty, so it will get cleaned up + * later. + */ + if (node->references == 0) { + INSIST(header->down == NULL); + if (header_prev != NULL) + header_prev->next = + header->next; + else + node->data = header->next; + free_rdataset(search->rbtdb->common.mctx, + header); + } else { + header->attributes |= + RDATASET_ATTR_STALE; + node->dirty = 1; + header_prev = header; + } + continue; + } + if (NONEXISTENT(header) || NXDOMAIN(header)) { + header_prev = header; + continue; + } + empty_node = ISC_FALSE; + if (header->type == matchtype) + found = header; + else if (header->type == sigmatchtype) + foundsig = header; + header_prev = header; + } + if (found != NULL) { + result = dns_name_concatenate(name, origin, + foundname, NULL); + if (result != ISC_R_SUCCESS) + goto unlock_node; + bind_rdataset(search->rbtdb, node, found, + now, rdataset); + if (foundsig != NULL) + bind_rdataset(search->rbtdb, node, foundsig, + now, sigrdataset); + new_reference(search->rbtdb, node); + *nodep = node; + result = DNS_R_COVERINGNSEC; + } else if (!empty_node) { + result = ISC_R_NOTFOUND; + }else + result = dns_rbtnodechain_prev(&search->chain, NULL, + NULL); + unlock_node: + UNLOCK(&(search->rbtdb->node_locks[node->locknum].lock)); + } while (empty_node && result == ISC_R_SUCCESS); + return (result); +} + static isc_result_t cache_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, dns_rdatatype_t type, unsigned int options, isc_stdtime_t now, @@ -2752,7 +2855,7 @@ cache_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, rdatasetheader_t *header, *header_prev, *header_next; rdatasetheader_t *found, *nsheader; rdatasetheader_t *foundsig, *nssig, *cnamesig; - rbtdb_rdatatype_t sigtype, nsecype; + rbtdb_rdatatype_t sigtype, nsectype; UNUSED(version); @@ -2787,6 +2890,13 @@ cache_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, cache_zonecut_callback, &search); if (result == DNS_R_PARTIALMATCH) { + if ((search.options & DNS_DBFIND_COVERINGNSEC) != 0) { + result = find_coveringnsec(&search, nodep, now, + foundname, rdataset, + sigrdataset); + if (result == DNS_R_COVERINGNSEC) + goto tree_exit; + } if (search.zonecut != NULL) { result = setup_delegation(&search, nodep, foundname, rdataset, sigrdataset); @@ -2820,7 +2930,7 @@ cache_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, found = NULL; foundsig = NULL; sigtype = RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, type); - nsecype = RBTDB_RDATATYPE_VALUE(0, type); + nsectype = RBTDB_RDATATYPE_VALUE(0, type); nsheader = NULL; nssig = NULL; cnamesig = NULL; @@ -2848,8 +2958,7 @@ cache_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, node->dirty = 1; header_prev = header; } - } else if ((header->attributes & RDATASET_ATTR_NONEXISTENT) - == 0) { + } else if (EXISTS(header)) { /* * We now know that there is at least one active * non-stale rdataset at this node. @@ -2891,7 +3000,7 @@ cache_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, */ foundsig = header; } else if (header->type == RBTDB_RDATATYPE_NCACHEANY || - header->type == nsecype) { + header->type == nsectype) { /* * We've found a negative cache entry. */ @@ -3116,8 +3225,7 @@ cache_findzonecut(dns_db_t *db, dns_name_t *name, unsigned int options, node->dirty = 1; header_prev = header; } - } else if ((header->attributes & RDATASET_ATTR_NONEXISTENT) - == 0) { + } else if (EXISTS(header)) { /* * If we found a type we were looking for, remember * it. @@ -3180,6 +3288,7 @@ attachnode(dns_db_t *db, dns_dbnode_t *source, dns_dbnode_t **targetp) { dns_rbtnode_t *node = (dns_rbtnode_t *)source; REQUIRE(VALID_RBTDB(rbtdb)); + REQUIRE(targetp != NULL && *targetp == NULL); LOCK(&rbtdb->node_locks[node->locknum].lock); INSIST(node->references > 0); @@ -3450,8 +3559,7 @@ zone_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, * Is this a "this rdataset doesn't * exist" record? */ - if ((header->attributes & - RDATASET_ATTR_NONEXISTENT) != 0) + if (NONEXISTENT(header)) header = NULL; break; } else @@ -3501,7 +3609,7 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db; dns_rbtnode_t *rbtnode = (dns_rbtnode_t *)node; rdatasetheader_t *header, *header_next, *found, *foundsig; - rbtdb_rdatatype_t matchtype, sigmatchtype, nsecype; + rbtdb_rdatatype_t matchtype, sigmatchtype, nsectype; isc_result_t result; REQUIRE(VALID_RBTDB(rbtdb)); @@ -3519,7 +3627,7 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, found = NULL; foundsig = NULL; matchtype = RBTDB_RDATATYPE_VALUE(type, covers); - nsecype = RBTDB_RDATATYPE_VALUE(0, type); + nsectype = RBTDB_RDATATYPE_VALUE(0, type); if (covers == 0) sigmatchtype = RBTDB_RDATATYPE_VALUE(dns_rdatatype_rrsig, type); else @@ -3536,12 +3644,11 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, */ header->attributes |= RDATASET_ATTR_STALE; rbtnode->dirty = 1; - } else if ((header->attributes & RDATASET_ATTR_NONEXISTENT) == - 0) { + } else if (EXISTS(header)) { if (header->type == matchtype) found = header; else if (header->type == RBTDB_RDATATYPE_NCACHEANY || - header->type == nsecype) + header->type == nsectype) found = header; else if (header->type == sigmatchtype) foundsig = header; @@ -3671,10 +3778,13 @@ cname_and_other_data(dns_rbtnode_t *node, rbtdb_serial_t serial) { * or RRSIG CNAME. */ rdtype = RBTDB_RDATATYPE_BASE(header->type); - if (rdtype == dns_rdatatype_rrsig) + if (rdtype == dns_rdatatype_rrsig || + rdtype == dns_rdatatype_sig) rdtype = RBTDB_RDATATYPE_EXT(header->type); if (rdtype != dns_rdatatype_nsec && rdtype != dns_rdatatype_dnskey && + rdtype != dns_rdatatype_nxt && + rdtype != dns_rdatatype_key && rdtype != dns_rdatatype_cname) { /* * We've found a type that isn't @@ -3718,7 +3828,7 @@ add(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion, isc_boolean_t header_nx; isc_boolean_t newheader_nx; isc_boolean_t merge; - dns_rdatatype_t nsecype, rdtype, covers; + dns_rdatatype_t nsectype, rdtype, covers; dns_trust_t trust; /* @@ -3756,7 +3866,7 @@ add(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion, newheader_nx = NONEXISTENT(newheader) ? ISC_TRUE : ISC_FALSE; topheader_prev = NULL; - nsecype = 0; + nsectype = 0; if (rbtversion == NULL && !newheader_nx) { rdtype = RBTDB_RDATATYPE_BASE(newheader->type); if (rdtype == 0) { @@ -3783,7 +3893,7 @@ add(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion, rbtnode->dirty = 1; goto find_header; } - nsecype = RBTDB_RDATATYPE_VALUE(covers, 0); + nsectype = RBTDB_RDATATYPE_VALUE(covers, 0); } else { /* * We're adding something that isn't a @@ -3823,7 +3933,7 @@ add(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion, topheader = NULL; goto find_header; } - nsecype = RBTDB_RDATATYPE_VALUE(0, rdtype); + nsectype = RBTDB_RDATATYPE_VALUE(0, rdtype); } } @@ -3831,7 +3941,7 @@ add(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion, topheader != NULL; topheader = topheader->next) { if (topheader->type == newheader->type || - topheader->type == nsecype) + topheader->type == nsectype) break; topheader_prev = topheader; } @@ -4092,8 +4202,10 @@ addnoqname(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader, RUNTIME_CHECK(result == ISC_R_SUCCESS); noqname = isc_mem_get(mctx, sizeof(*noqname)); - if (noqname == NULL) - return (ISC_R_NOMEMORY); + if (noqname == NULL) { + result = ISC_R_NOMEMORY; + goto cleanup; + } dns_name_init(&noqname->name, NULL); noqname->nsec = NULL; noqname->nsecsig = NULL; @@ -4114,6 +4226,8 @@ addnoqname(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader, return (ISC_R_SUCCESS); cleanup: + dns_rdataset_disassociate(&nsec); + dns_rdataset_disassociate(&nsecsig); free_noqname(mctx, &noqname); return(result); } @@ -4956,7 +5070,7 @@ static void rdataset_clone(dns_rdataset_t *source, dns_rdataset_t *target) { dns_db_t *db = source->private1; dns_dbnode_t *node = source->private2; - dns_dbnode_t *cloned_node; + dns_dbnode_t *cloned_node = NULL; attachnode(db, node, &cloned_node); *target = *source; @@ -4987,9 +5101,8 @@ rdataset_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name, dns_dbnode_t *cloned_node; struct noqname *noqname = rdataset->private6; + cloned_node = NULL; attachnode(db, node, &cloned_node); - attachnode(db, node, &cloned_node); - nsec->methods = &rdataset_methods; nsec->rdclass = db->rdclass; nsec->type = dns_rdatatype_nsec; @@ -5003,6 +5116,8 @@ rdataset_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name, nsec->private5 = NULL; nsec->private6 = NULL; + cloned_node = NULL; + attachnode(db, node, &cloned_node); nsecsig->methods = &rdataset_methods; nsecsig->rdclass = db->rdclass; nsecsig->type = dns_rdatatype_rrsig; @@ -5021,7 +5136,6 @@ rdataset_getnoqname(dns_rdataset_t *rdataset, dns_name_t *name, return (ISC_R_SUCCESS); } - /* * Rdataset Iterator Methods */ diff --git a/dist/bind/lib/dns/rdata/generic/rrsig_46.c b/dist/bind/lib/dns/rdata/generic/rrsig_46.c index 3089a64f38b..887bec85d5a 100644 --- a/dist/bind/lib/dns/rdata/generic/rrsig_46.c +++ b/dist/bind/lib/dns/rdata/generic/rrsig_46.c @@ -1,4 +1,4 @@ -/* $NetBSD: rrsig_46.c,v 1.1.1.1 2004/05/17 23:45:00 christos Exp $ */ +/* $NetBSD: rrsig_46.c,v 1.1.1.2 2004/11/06 23:55:47 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: rrsig_46.c,v 1.4.2.2 2004/03/16 12:38:14 marka Exp */ +/* Id: rrsig_46.c,v 1.4.2.3 2004/06/24 00:58:06 marka Exp */ /* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */ @@ -156,8 +156,8 @@ totext_rrsig(ARGS_TOTEXT) { if (dns_rdatatype_isknown(covered) && covered != 0) { RETERR(dns_rdatatype_totext(covered, target)); } else { - char buf[sizeof("65535")]; - sprintf(buf, "%u", covered); + char buf[sizeof("TYPE65535")]; + sprintf(buf, "TYPE%u", covered); RETERR(str_totext(buf, target)); } RETERR(str_totext(" ", target)); diff --git a/dist/bind/lib/dns/resolver.c b/dist/bind/lib/dns/resolver.c index 4b953db42f1..ee58adf8d24 100644 --- a/dist/bind/lib/dns/resolver.c +++ b/dist/bind/lib/dns/resolver.c @@ -1,4 +1,4 @@ -/* $NetBSD: resolver.c,v 1.1.1.1 2004/05/17 23:44:54 christos Exp $ */ +/* $NetBSD: resolver.c,v 1.1.1.2 2004/11/06 23:55:41 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,10 +17,11 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: resolver.c,v 1.218.2.18.4.36 2004/04/19 23:41:33 marka Exp */ +/* Id: resolver.c,v 1.218.2.18.4.43 2004/08/28 06:25:19 marka Exp */ #include +#include #include #include #include @@ -67,25 +68,28 @@ DNS_LOGCATEGORY_RESOLVER, \ DNS_LOGMODULE_RESOLVER, \ ISC_LOG_DEBUG(3), \ - "fctx %p: %s", fctx, (m)) + "fctx %p(%s'): %s", fctx, fctx->info, (m)) #define FCTXTRACE2(m1, m2) \ isc_log_write(dns_lctx, \ DNS_LOGCATEGORY_RESOLVER, \ DNS_LOGMODULE_RESOLVER, \ ISC_LOG_DEBUG(3), \ - "fctx %p: %s %s", fctx, (m1), (m2)) + "fctx %p(%s): %s %s", \ + fctx, fctx->info, (m1), (m2)) #define FTRACE(m) isc_log_write(dns_lctx, \ DNS_LOGCATEGORY_RESOLVER, \ DNS_LOGMODULE_RESOLVER, \ ISC_LOG_DEBUG(3), \ - "fetch %p (fctx %p): %s", \ - fetch, fetch->private, (m)) + "fetch %p (fctx %p(%s)): %s", \ + fetch, fetch->private, \ + fetch->private->info, (m)) #define QTRACE(m) isc_log_write(dns_lctx, \ DNS_LOGCATEGORY_RESOLVER, \ DNS_LOGMODULE_RESOLVER, \ ISC_LOG_DEBUG(3), \ - "resquery %p (fctx %p): %s", \ - query, query->fctx, (m)) + "resquery %p (fctx %p(%s)): %s", \ + query, query->fctx, \ + query->fctx->info, (m)) #else #define RTRACE(m) #define RRTRACE(r, m) @@ -154,6 +158,7 @@ struct fetchctx { dns_rdatatype_t type; unsigned int options; unsigned int bucketnum; + char * info; /* Locked by appropriate bucket lock. */ fetchstate state; isc_boolean_t want_shutdown; @@ -1123,6 +1128,8 @@ resquery_send(resquery_t *query) { &secure_domain); if (result != ISC_R_SUCCESS) secure_domain = ISC_FALSE; + if (res->view->dlv != NULL) + secure_domain = ISC_TRUE; if (secure_domain) fctx->qmessage->flags |= DNS_MESSAGEFLAG_CD; } else @@ -1817,8 +1824,23 @@ fctx_getaddresses(fetchctx_t *fctx) { sa = ISC_LIST_HEAD(fctx->forwarders); if (sa == NULL) { dns_forwarders_t *forwarders = NULL; - result = dns_fwdtable_find(fctx->res->view->fwdtable, - &fctx->name, &forwarders); + dns_name_t *name = &fctx->name; + dns_name_t suffix; + unsigned int labels; + + /* + * DS records are found in the parent server. + * Strip label to get the correct forwarder (if any). + */ + if (fctx->type == dns_rdatatype_ds && + dns_name_countlabels(name) > 1) { + dns_name_init(&suffix, NULL); + labels = dns_name_countlabels(name); + dns_name_getlabelsequence(name, 1, labels - 1, &suffix); + name = &suffix; + } + result = dns_fwdtable_find(fctx->res->view->fwdtable, name, + &forwarders); if (result == ISC_R_SUCCESS) { sa = ISC_LIST_HEAD(forwarders->addrs); fctx->fwdpolicy = forwarders->fwdpolicy; @@ -2055,7 +2077,7 @@ possibly_mark(fetchctx_t *fctx, dns_adbaddrinfo_t *addr) static inline dns_adbaddrinfo_t * fctx_nextaddress(fetchctx_t *fctx) { - dns_adbfind_t *find; + dns_adbfind_t *find, *start; dns_adbaddrinfo_t *addrinfo; dns_adbaddrinfo_t *faddrinfo; @@ -2098,23 +2120,26 @@ fctx_nextaddress(fetchctx_t *fctx) { * Find the first unmarked addrinfo. */ addrinfo = NULL; - while (find != fctx->find) { - for (addrinfo = ISC_LIST_HEAD(find->list); - addrinfo != NULL; - addrinfo = ISC_LIST_NEXT(addrinfo, publink)) { - if (!UNMARKED(addrinfo)) - continue; - possibly_mark(fctx, addrinfo); - if (UNMARKED(addrinfo)) { - addrinfo->flags |= FCTX_ADDRINFO_MARK; - break; + if (find != NULL) { + start = find; + do { + for (addrinfo = ISC_LIST_HEAD(find->list); + addrinfo != NULL; + addrinfo = ISC_LIST_NEXT(addrinfo, publink)) { + if (!UNMARKED(addrinfo)) + continue; + possibly_mark(fctx, addrinfo); + if (UNMARKED(addrinfo)) { + addrinfo->flags |= FCTX_ADDRINFO_MARK; + break; + } } - } - if (addrinfo != NULL) - break; - find = ISC_LIST_NEXT(find, publink); - if (find != fctx->find && find == NULL) - find = ISC_LIST_HEAD(fctx->finds); + if (addrinfo != NULL) + break; + find = ISC_LIST_NEXT(find, publink); + if (find == NULL) + find = ISC_LIST_HEAD(fctx->finds); + } while (find != start); } fctx->find = find; @@ -2140,23 +2165,26 @@ fctx_nextaddress(fetchctx_t *fctx) { * Find the first unmarked addrinfo. */ addrinfo = NULL; - while (find != fctx->altfind) { - for (addrinfo = ISC_LIST_HEAD(find->list); - addrinfo != NULL; - addrinfo = ISC_LIST_NEXT(addrinfo, publink)) { - if (!UNMARKED(addrinfo)) - continue; - possibly_mark(fctx, addrinfo); - if (UNMARKED(addrinfo)) { - addrinfo->flags |= FCTX_ADDRINFO_MARK; - break; + if (find != NULL) { + start = find; + do { + for (addrinfo = ISC_LIST_HEAD(find->list); + addrinfo != NULL; + addrinfo = ISC_LIST_NEXT(addrinfo, publink)) { + if (!UNMARKED(addrinfo)) + continue; + possibly_mark(fctx, addrinfo); + if (UNMARKED(addrinfo)) { + addrinfo->flags |= FCTX_ADDRINFO_MARK; + break; + } } - } - if (addrinfo != NULL) - break; - find = ISC_LIST_NEXT(find, publink); - if (find != fctx->altfind && find == NULL) - find = ISC_LIST_HEAD(fctx->altfinds); + if (addrinfo != NULL) + break; + find = ISC_LIST_NEXT(find, publink); + if (find == NULL) + find = ISC_LIST_HEAD(fctx->altfinds); + } while (find != start); } faddrinfo = addrinfo; @@ -2289,6 +2317,7 @@ fctx_destroy(fetchctx_t *fctx) { dns_name_free(&fctx->name, res->mctx); dns_db_detach(&fctx->cache); dns_adb_detach(&fctx->adb); + isc_mem_free(res->mctx, fctx->info); isc_mem_put(res->mctx, fctx, sizeof(*fctx)); LOCK(&res->nlock); @@ -2577,6 +2606,9 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, isc_interval_t interval; dns_fixedname_t qdomain; unsigned int findoptions = 0; + char buf[DNS_NAME_FORMATSIZE + DNS_RDATATYPE_FORMATSIZE]; + char typebuf[DNS_RDATATYPE_FORMATSIZE]; + dns_name_t suffix; /* * Caller must be holding the lock for bucket number 'bucketnum'. @@ -2586,11 +2618,18 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, fctx = isc_mem_get(res->mctx, sizeof(*fctx)); if (fctx == NULL) return (ISC_R_NOMEMORY); + dns_name_format(name, buf, sizeof(buf)); + dns_rdatatype_format(type, typebuf, sizeof(typebuf)); + strcat(buf, "/"); /* checked */ + strcat(buf, typebuf); /* checked */ + fctx->info = isc_mem_strdup(res->mctx, buf); + if (fctx->info == NULL) + goto cleanup_fetch; FCTXTRACE("create"); dns_name_init(&fctx->name, NULL); result = dns_name_dup(name, res->mctx, &fctx->name); if (result != ISC_R_SUCCESS) - goto cleanup_fetch; + goto cleanup_info; dns_name_init(&fctx->domain, NULL); dns_rdataset_init(&fctx->nameservers); @@ -2629,8 +2668,21 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, if (domain == NULL) { dns_forwarders_t *forwarders = NULL; - result = dns_fwdtable_find(fctx->res->view->fwdtable, - &fctx->name, &forwarders); + unsigned int labels; + + /* + * DS records are found in the parent server. + * Strip label to get the correct forwarder (if any). + */ + if (fctx->type == dns_rdatatype_ds && + dns_name_countlabels(name) > 1) { + dns_name_init(&suffix, NULL); + labels = dns_name_countlabels(name); + dns_name_getlabelsequence(name, 1, labels - 1, &suffix); + name = &suffix; + } + result = dns_fwdtable_find(fctx->res->view->fwdtable, name, + &forwarders); if (result == ISC_R_SUCCESS) fctx->fwdpolicy = forwarders->fwdpolicy; @@ -2763,6 +2815,9 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, cleanup_name: dns_name_free(&fctx->name, res->mctx); + cleanup_info: + isc_mem_free(res->mctx, fctx->info); + cleanup_fetch: isc_mem_put(res->mctx, fctx, sizeof(*fctx)); @@ -3093,7 +3148,6 @@ validated(isc_task_t *task, isc_event_t *event) { ardataset, &eresult); if (result != ISC_R_SUCCESS) goto noanswer_response; - goto answer_response; } @@ -3154,8 +3208,9 @@ validated(isc_task_t *task, isc_event_t *event) { goto cleanup_event; } + answer_response: /* - * Cache any NS records that happened to be validate. + * Cache any NS/NSEC records that happened to be validated. */ result = dns_message_firstname(fctx->rmessage, DNS_SECTION_AUTHORITY); while (result == ISC_R_SUCCESS) { @@ -3165,14 +3220,15 @@ validated(isc_task_t *task, isc_event_t *event) { for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL; rdataset = ISC_LIST_NEXT(rdataset, link)) { - if (rdataset->type != dns_rdatatype_ns || + if ((rdataset->type != dns_rdatatype_ns && + rdataset->type != dns_rdatatype_nsec) || rdataset->trust != dns_trust_secure) continue; for (sigrdataset = ISC_LIST_HEAD(name->list); sigrdataset != NULL; sigrdataset = ISC_LIST_NEXT(sigrdataset, link)) { if (sigrdataset->type != dns_rdatatype_rrsig || - sigrdataset->covers != dns_rdatatype_ns) + sigrdataset->covers != rdataset->type) continue; break; } @@ -3199,7 +3255,6 @@ validated(isc_task_t *task, isc_event_t *event) { result = ISC_R_SUCCESS; - answer_response: /* * Respond with an answer, positive or negative, * as opposed to an error. 'node' must be non-NULL. @@ -3264,6 +3319,9 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) { if (result != ISC_R_SUCCESS) return (result); + if (res->view->dlv != NULL) + secure_domain = ISC_TRUE; + if ((fctx->options & DNS_FETCHOPT_NOVALIDATE) != 0) need_validation = ISC_FALSE; else @@ -3688,6 +3746,9 @@ ncache_message(fetchctx_t *fctx, dns_rdatatype_t covers, isc_stdtime_t now) { if (result != ISC_R_SUCCESS) return (result); + if (res->view->dlv != NULL) + secure_domain = ISC_TRUE; + if ((fctx->options & DNS_FETCHOPT_NOVALIDATE) != 0) need_validation = ISC_FALSE; else @@ -4693,6 +4754,9 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) { isc_boolean_t bucket_empty = ISC_FALSE; isc_boolean_t locked = ISC_FALSE; unsigned int bucketnum; + dns_rdataset_t nameservers; + dns_fixedname_t fixed; + dns_name_t *domain; REQUIRE(event->ev_type == DNS_EVENT_FETCHDONE); fevent = (dns_fetchevent_t *)event; @@ -4708,15 +4772,17 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) { if (fevent->db != NULL) dns_db_detach(&fevent->db); - dns_resolver_destroyfetch(&fctx->nsfetch); + dns_rdataset_init(&nameservers); bucketnum = fctx->bucketnum; - if (fevent->result == ISC_R_CANCELED) + if (fevent->result == ISC_R_CANCELED) { + dns_resolver_destroyfetch(&fctx->nsfetch); fctx_done(fctx, ISC_R_CANCELED); - else if (fevent->result == ISC_R_SUCCESS) { + } else if (fevent->result == ISC_R_SUCCESS) { FCTXTRACE("resuming DS lookup"); + dns_resolver_destroyfetch(&fctx->nsfetch); if (dns_rdataset_isassociated(&fctx->nameservers)) dns_rdataset_disassociate(&fctx->nameservers); dns_rdataset_clone(fevent->rdataset, &fctx->nameservers); @@ -4735,22 +4801,29 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) { } else { unsigned int n; + /* + * Retrieve state from fctx->nsfetch before we destroy it. + */ + dns_fixedname_init(&fixed); + domain = dns_fixedname_name(&fixed); + dns_name_copy(&fctx->nsfetch->private->domain, domain, NULL); + dns_rdataset_clone(&fctx->nsfetch->private->nameservers, + &nameservers); + dns_resolver_destroyfetch(&fctx->nsfetch); + if (dns_name_equal(&fctx->nsname, domain)) { + fctx_done(fctx, DNS_R_SERVFAIL); + goto cleanup; + } n = dns_name_countlabels(&fctx->nsname); dns_name_getlabelsequence(&fctx->nsname, 1, n - 1, &fctx->nsname); - if (dns_name_equal(&fctx->nsname, &fctx->domain)) { - fctx_done(fctx, DNS_R_SERVFAIL); - goto cleanup; - } if (dns_rdataset_isassociated(fevent->rdataset)) dns_rdataset_disassociate(fevent->rdataset); FCTXTRACE("continuing to look for parent's NS records"); result = dns_resolver_createfetch(fctx->res, &fctx->nsname, - dns_rdatatype_ns, - &fctx->domain, - &fctx->nameservers, NULL, - 0, task, + dns_rdatatype_ns, domain, + &nameservers, NULL, 0, task, resume_dslookup, fctx, &fctx->nsrrset, NULL, &fctx->nsfetch); @@ -4764,6 +4837,8 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) { } cleanup: + if (dns_rdataset_isassociated(&nameservers)) + dns_rdataset_disassociate(&nameservers); if (dns_rdataset_isassociated(fevent->rdataset)) dns_rdataset_disassociate(fevent->rdataset); INSIST(fevent->sigrdataset == NULL); diff --git a/dist/bind/lib/dns/result.c b/dist/bind/lib/dns/result.c index 09163c77492..f4b2ecdb8e9 100644 --- a/dist/bind/lib/dns/result.c +++ b/dist/bind/lib/dns/result.c @@ -1,4 +1,4 @@ -/* $NetBSD: result.c,v 1.1.1.1 2004/05/17 23:44:54 christos Exp $ */ +/* $NetBSD: result.c,v 1.1.1.2 2004/11/06 23:55:41 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: result.c,v 1.90.2.9.2.12 2004/04/15 23:56:30 marka Exp */ +/* Id: result.c,v 1.90.2.9.2.13 2004/05/14 05:06:39 marka Exp */ #include @@ -152,7 +152,8 @@ static const char *text[DNS_R_NRESULTS] = { "dynamic zone", /* 98 DNS_R_DYNAMIC */ "unknown command", /* 99 DNS_R_UNKNOWNCOMMAND */ - "must-be-secure" /* 100 DNS_R_MUSTBESECURE */ + "must-be-secure", /* 100 DNS_R_MUSTBESECURE */ + "covering NSEC record returned" /* 101 DNS_R_COVERINGNSEC */ }; static const char *rcode_text[DNS_R_NRCODERESULTS] = { diff --git a/dist/bind/lib/dns/sdb.c b/dist/bind/lib/dns/sdb.c index 97a429bcfde..34c04ba8cba 100644 --- a/dist/bind/lib/dns/sdb.c +++ b/dist/bind/lib/dns/sdb.c @@ -1,4 +1,4 @@ -/* $NetBSD: sdb.c,v 1.1.1.1 2004/05/17 23:44:54 christos Exp $ */ +/* $NetBSD: sdb.c,v 1.1.1.2 2004/11/06 23:55:42 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: sdb.c,v 1.35.12.7 2004/03/08 21:06:27 marka Exp */ +/* Id: sdb.c,v 1.35.12.8 2004/07/22 04:01:58 marka Exp */ #include @@ -631,10 +631,10 @@ attachversion(dns_db_t *db, dns_dbversion_t *source, dns_dbversion_t **targetp) { REQUIRE(source != NULL && source == (void *) &dummy); + REQUIRE(targetp != NULL && *targetp == NULL); UNUSED(db); - UNUSED(source); - UNUSED(targetp); + *targetp = source; return; } diff --git a/dist/bind/lib/dns/sec/dst/dst_api.c b/dist/bind/lib/dns/sec/dst/dst_api.c index d8f11f5c9d2..9321870a205 100644 --- a/dist/bind/lib/dns/sec/dst/dst_api.c +++ b/dist/bind/lib/dns/sec/dst/dst_api.c @@ -1,4 +1,4 @@ -/* $NetBSD: dst_api.c,v 1.1.1.1 2004/05/17 23:45:00 christos Exp $ */ +/* $NetBSD: dst_api.c,v 1.1.1.2 2004/11/06 23:55:47 christos Exp $ */ /* * Portions Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -20,7 +20,7 @@ /* * Principal Author: Brian Wellington - * Id: dst_api.c,v 1.88.2.3.2.12 2004/03/16 05:50:22 marka Exp + * Id: dst_api.c,v 1.88.2.3.2.15 2004/06/16 01:05:01 marka Exp */ #include @@ -72,6 +72,7 @@ static dst_key_t * get_key_struct(dns_name_t *name, dns_rdataclass_t rdclass, isc_mem_t *mctx); static isc_result_t read_public_key(const char *filename, + int type, isc_mem_t *mctx, dst_key_t **keyp); static isc_result_t write_public_key(const dst_key_t *key, int type, @@ -147,9 +148,11 @@ dst_lib_init(isc_mem_t *mctx, isc_entropy_t *ectx, unsigned int eflags) { RETERR(dst__openssl_init()); RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_RSAMD5])); RETERR(dst__opensslrsa_init(&dst_t_func[DST_ALG_RSASHA1])); +#ifdef HAVE_OPENSSL_DSA RETERR(dst__openssldsa_init(&dst_t_func[DST_ALG_DSA])); - RETERR(dst__openssldh_init(&dst_t_func[DST_ALG_DH])); #endif + RETERR(dst__openssldh_init(&dst_t_func[DST_ALG_DH])); +#endif /* OPENSSL */ #ifdef GSSAPI RETERR(dst__gssapi_init(&dst_t_func[DST_ALG_GSSAPI])); #endif @@ -391,7 +394,7 @@ dst_key_fromnamedfile(const char *filename, int type, isc_mem_t *mctx, REQUIRE(mctx != NULL); REQUIRE(keyp != NULL && *keyp == NULL); - result = read_public_key(filename, mctx, &pubkey); + result = read_public_key(filename, type, mctx, &pubkey); if (result != ISC_R_SUCCESS) return (result); @@ -825,7 +828,9 @@ get_key_struct(dns_name_t *name, unsigned int alg, * Reads a public key from disk */ static isc_result_t -read_public_key(const char *filename, isc_mem_t *mctx, dst_key_t **keyp) { +read_public_key(const char *filename, int type, + isc_mem_t *mctx, dst_key_t **keyp) +{ u_char rdatabuf[DST_KEY_MAXSIZE]; isc_buffer_t b; dns_fixedname_t name; @@ -840,7 +845,7 @@ read_public_key(const char *filename, isc_mem_t *mctx, dst_key_t **keyp) { isc_lexspecials_t specials; isc_uint32_t ttl; isc_result_t result; - dns_rdatatype_t type; + dns_rdatatype_t keytype; newfilenamelen = strlen(filename) + 5; newfilename = isc_mem_get(mctx, newfilenamelen); @@ -913,14 +918,20 @@ read_public_key(const char *filename, isc_mem_t *mctx, dst_key_t **keyp) { BADTOKEN(); if (strcasecmp(DST_AS_STR(token), "DNSKEY") == 0) - type = dns_rdatatype_dnskey; + keytype = dns_rdatatype_dnskey; else if (strcasecmp(DST_AS_STR(token), "KEY") == 0) - type = dns_rdatatype_key; /* SIG(0) */ + keytype = dns_rdatatype_key; /* SIG(0), TKEY */ else BADTOKEN(); + if (((type & DST_TYPE_KEY) != 0 && keytype != dns_rdatatype_key) || + ((type & DST_TYPE_KEY) == 0 && keytype != dns_rdatatype_dnskey)) { + ret = DST_R_BADKEYTYPE; + goto cleanup; + } + isc_buffer_init(&b, rdatabuf, sizeof(rdatabuf)); - ret = dns_rdata_fromtext(&rdata, rdclass, type, lex, NULL, + ret = dns_rdata_fromtext(&rdata, rdclass, keytype, lex, NULL, ISC_FALSE, mctx, &b, NULL); if (ret != ISC_R_SUCCESS) goto cleanup; @@ -1138,10 +1149,12 @@ algorithm_status(unsigned int alg) { if (dst_algorithm_supported(alg)) return (ISC_R_SUCCESS); +#ifndef OPENSSL if (alg == DST_ALG_RSAMD5 || alg == DST_ALG_RSASHA1 || alg == DST_ALG_DSA || alg == DST_ALG_DH || alg == DST_ALG_HMACMD5) return (DST_R_NOCRYPTO); +#endif return (DST_R_UNSUPPORTEDALG); } diff --git a/dist/bind/lib/dns/sec/dst/dst_result.c b/dist/bind/lib/dns/sec/dst/dst_result.c index 18a8fd21efe..27a1460215a 100644 --- a/dist/bind/lib/dns/sec/dst/dst_result.c +++ b/dist/bind/lib/dns/sec/dst/dst_result.c @@ -1,4 +1,4 @@ -/* $NetBSD: dst_result.c,v 1.1.1.1 2004/05/17 23:45:00 christos Exp $ */ +/* $NetBSD: dst_result.c,v 1.1.1.2 2004/11/06 23:55:47 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -19,7 +19,7 @@ /* * Principal Author: Brian Wellington - * Id: dst_result.c,v 1.18.2.1.8.1 2004/03/06 08:14:21 marka Exp + * Id: dst_result.c,v 1.18.2.1.8.2 2004/06/11 00:30:55 marka Exp */ #include @@ -51,6 +51,7 @@ static const char *text[DST_R_NRESULTS] = { "not a key that can compute a secret", /* 17 */ "failure computing a shared secret", /* 18 */ "no randomness available", /* 19 */ + "bad key type" /* 20 */ }; #define DST_RESULT_RESULTSET 2 diff --git a/dist/bind/lib/dns/sec/dst/include/dst/dst.h b/dist/bind/lib/dns/sec/dst/include/dst/dst.h index 7c4cc965da3..87392da810b 100644 --- a/dist/bind/lib/dns/sec/dst/include/dst/dst.h +++ b/dist/bind/lib/dns/sec/dst/include/dst/dst.h @@ -1,4 +1,4 @@ -/* $NetBSD: dst.h,v 1.1.1.1 2004/05/17 23:45:01 christos Exp $ */ +/* $NetBSD: dst.h,v 1.1.1.2 2004/11/06 23:55:48 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: dst.h,v 1.42.2.1.8.5 2004/03/10 02:55:59 marka Exp */ +/* Id: dst.h,v 1.42.2.1.8.6 2004/06/11 00:31:01 marka Exp */ #ifndef DST_DST_H #define DST_DST_H 1 @@ -220,6 +220,7 @@ dst_key_fromfile(dns_name_t *name, dns_keytag_t id, unsigned int alg, int type, * "id" is a valid key tag identifier. * "alg" is a supported key algorithm. * "type" is DST_TYPE_PUBLIC, DST_TYPE_PRIVATE, or the bitwise union. + * DST_TYPE_KEY look for a KEY record otherwise DNSKEY * "mctx" is a valid memory context. * "keyp" is not NULL and "*keyp" is NULL. * @@ -242,6 +243,7 @@ dst_key_fromnamedfile(const char *filename, int type, isc_mem_t *mctx, * Requires: * "filename" is not NULL * "type" is DST_TYPE_PUBLIC, DST_TYPE_PRIVATE, or the bitwise union + * DST_TYPE_KEY look for a KEY record otherwise DNSKEY * "mctx" is a valid memory context * "keyp" is not NULL and "*keyp" is NULL. * diff --git a/dist/bind/lib/dns/sec/dst/include/dst/result.h b/dist/bind/lib/dns/sec/dst/include/dst/result.h index 36bd3cd9f96..73d5d1d9e49 100644 --- a/dist/bind/lib/dns/sec/dst/include/dst/result.h +++ b/dist/bind/lib/dns/sec/dst/include/dst/result.h @@ -1,4 +1,4 @@ -/* $NetBSD: result.h,v 1.1.1.1 2004/05/17 23:45:01 christos Exp $ */ +/* $NetBSD: result.h,v 1.1.1.2 2004/11/06 23:55:48 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: result.h,v 1.20.206.1 2004/03/06 08:14:25 marka Exp */ +/* Id: result.h,v 1.20.206.2 2004/06/11 00:31:01 marka Exp */ #ifndef DST_RESULT_H #define DST_RESULT_H 1 @@ -53,8 +53,9 @@ #define DST_R_KEYCANNOTCOMPUTESECRET (ISC_RESULTCLASS_DST + 17) #define DST_R_COMPUTESECRETFAILURE (ISC_RESULTCLASS_DST + 18) #define DST_R_NORANDOMNESS (ISC_RESULTCLASS_DST + 19) +#define DST_R_BADKEYTYPE (ISC_RESULTCLASS_DST + 20) -#define DST_R_NRESULTS 20 /* Number of results */ +#define DST_R_NRESULTS 21 /* Number of results */ ISC_LANG_BEGINDECLS diff --git a/dist/bind/lib/dns/time.c b/dist/bind/lib/dns/time.c index 7e1d13f343d..e216aeb41d9 100644 --- a/dist/bind/lib/dns/time.c +++ b/dist/bind/lib/dns/time.c @@ -1,4 +1,4 @@ -/* $NetBSD: time.c,v 1.1.1.1 2004/05/17 23:44:55 christos Exp $ */ +/* $NetBSD: time.c,v 1.1.1.2 2004/11/06 23:55:42 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: time.c,v 1.18.2.4.2.7 2004/03/11 04:23:00 marka Exp */ +/* Id: time.c,v 1.18.2.4.2.8 2004/08/28 06:25:20 marka Exp */ #include @@ -25,6 +25,7 @@ #include /* Required for HP/UX (and others?) */ #include +#include #include #include #include diff --git a/dist/bind/lib/dns/tkey.c b/dist/bind/lib/dns/tkey.c index d03b2fa5338..4648741e1ac 100644 --- a/dist/bind/lib/dns/tkey.c +++ b/dist/bind/lib/dns/tkey.c @@ -1,4 +1,4 @@ -/* $NetBSD: tkey.c,v 1.1.1.1 2004/05/17 23:44:55 christos Exp $ */ +/* $NetBSD: tkey.c,v 1.1.1.2 2004/11/06 23:55:42 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,7 @@ */ /* - * Id: tkey.c,v 1.71.2.1.10.4 2004/03/08 02:07:58 marka Exp + * Id: tkey.c,v 1.71.2.1.10.5 2004/06/11 00:30:54 marka Exp */ #include @@ -287,7 +287,7 @@ process_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name, keyname = NULL; dns_message_currentname(msg, DNS_SECTION_ADDITIONAL, &keyname); keyset = NULL; - result = dns_message_findtype(keyname, dns_rdatatype_dnskey, 0, + result = dns_message_findtype(keyname, dns_rdatatype_key, 0, &keyset); if (result != ISC_R_SUCCESS) continue; @@ -335,7 +335,7 @@ process_dhtkey(dns_message_t *msg, dns_name_t *signer, dns_name_t *name, RETERR(dst_key_todns(tctx->dhkey, &ourkeybuf)); isc_buffer_usedregion(&ourkeybuf, &ourkeyr); dns_rdata_fromregion(&ourkeyrdata, dns_rdataclass_any, - dns_rdatatype_dnskey, &ourkeyr); + dns_rdatatype_key, &ourkeyr); dns_name_init(&ourname, NULL); dns_name_clone(dst_key_name(tctx->dhkey), &ourname); @@ -879,7 +879,7 @@ dns_tkey_builddhquery(dns_message_t *msg, dst_key_t *key, dns_name_t *name, RETERR(dst_key_todns(key, dynbuf)); isc_buffer_usedregion(dynbuf, &r); dns_rdata_fromregion(rdata, dns_rdataclass_any, - dns_rdatatype_dnskey, &r); + dns_rdatatype_key, &r); dns_message_takebuffer(msg, &dynbuf); dns_name_init(&keyname, NULL); @@ -1051,7 +1051,7 @@ dns_tkey_processdhresponse(dns_message_t *qmsg, dns_message_t *rmsg, ourkeyname = NULL; ourkeyset = NULL; RETERR(dns_message_findname(rmsg, DNS_SECTION_ANSWER, &keyname, - dns_rdatatype_dnskey, 0, &ourkeyname, + dns_rdatatype_key, 0, &ourkeyname, &ourkeyset)); result = dns_message_firstname(rmsg, DNS_SECTION_ANSWER); @@ -1062,7 +1062,7 @@ dns_tkey_processdhresponse(dns_message_t *qmsg, dns_message_t *rmsg, if (dns_name_equal(theirkeyname, ourkeyname)) goto next; theirkeyset = NULL; - result = dns_message_findtype(theirkeyname, dns_rdatatype_dnskey, + result = dns_message_findtype(theirkeyname, dns_rdatatype_key, 0, &theirkeyset); if (result == ISC_R_SUCCESS) { RETERR(dns_rdataset_first(theirkeyset)); diff --git a/dist/bind/lib/dns/validator.c b/dist/bind/lib/dns/validator.c index f5ae6f87430..cbba995a3c9 100644 --- a/dist/bind/lib/dns/validator.c +++ b/dist/bind/lib/dns/validator.c @@ -1,4 +1,4 @@ -/* $NetBSD: validator.c,v 1.1.1.1 2004/05/17 23:44:53 christos Exp $ */ +/* $NetBSD: validator.c,v 1.1.1.2 2004/11/06 23:55:40 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: validator.c,v 1.91.2.5.8.10 2004/04/15 23:56:30 marka Exp */ +/* Id: validator.c,v 1.91.2.5.8.12 2004/06/11 01:17:36 marka Exp */ #include @@ -55,6 +55,7 @@ #define VALATTR_INSECURITY 0x0010 #define VALATTR_DLV 0x0020 #define VALATTR_DLVTRIED 0x0040 +#define VALATTR_DLVSEPTRIED 0x0080 #define VALATTR_NEEDNOQNAME 0x0100 #define VALATTR_NEEDNOWILDCARD 0x0200 @@ -70,6 +71,7 @@ #define NEEDNOWILDCARD(val) ((val->attributes & VALATTR_NEEDNOWILDCARD) != 0) #define DLV(val) ((val->attributes & VALATTR_DLV) != 0) #define DLVTRIED(val) ((val->attributes & VALATTR_DLVTRIED) != 0) +#define DLVSEPTRIED(val) ((val->attributes & VALATTR_DLVSEPTRIED) != 0) #define SHUTDOWN(v) (((v)->attributes & VALATTR_SHUTDOWN) != 0) @@ -109,6 +111,9 @@ validator_logcreate(dns_validator_t *val, static isc_result_t dlv_validatezonekey(dns_validator_t *val); +static isc_result_t +finddlvsep(dns_validator_t *val, isc_boolean_t resume); + static void validator_done(dns_validator_t *val, isc_result_t result) { isc_task_t *task; @@ -737,6 +742,16 @@ negauthvalidated(isc_task_t *task, isc_event_t *event) { static inline isc_result_t view_find(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type) { + dns_fixedname_t fixedname; + dns_name_t *foundname; + dns_rdata_nsec_t nsec; + dns_rdata_t rdata = DNS_RDATA_INIT; + isc_result_t result; + unsigned int options; + char buf1[DNS_NAME_FORMATSIZE]; + char buf2[DNS_NAME_FORMATSIZE]; + char buf3[DNS_NAME_FORMATSIZE]; + if (dns_rdataset_isassociated(&val->frdataset)) dns_rdataset_disassociate(&val->frdataset); if (dns_rdataset_isassociated(&val->fsigrdataset)) @@ -744,9 +759,106 @@ view_find(dns_validator_t *val, dns_name_t *name, dns_rdatatype_t type) { if (val->view->zonetable == NULL) return (ISC_R_CANCELED); - return (dns_view_simplefind(val->view, name, type, 0, - DNS_DBFIND_PENDINGOK, ISC_FALSE, - &val->frdataset, &val->fsigrdataset)); + + options = DNS_DBFIND_PENDINGOK; + if (type == dns_rdatatype_dlv) + options |= DNS_DBFIND_COVERINGNSEC; + dns_fixedname_init(&fixedname); + foundname = dns_fixedname_name(&fixedname); + result = dns_view_find(val->view, name, type, 0, options, + ISC_FALSE, NULL, NULL, foundname, + &val->frdataset, &val->fsigrdataset); + if (result == DNS_R_NXDOMAIN) { + if (dns_rdataset_isassociated(&val->frdataset)) + dns_rdataset_disassociate(&val->frdataset); + if (dns_rdataset_isassociated(&val->fsigrdataset)) + dns_rdataset_disassociate(&val->fsigrdataset); + } else if (result == DNS_R_COVERINGNSEC) { + validator_log(val, ISC_LOG_DEBUG(3), "DNS_R_COVERINGNSEC"); + /* + * Check if the returned NSEC covers the name. + */ + INSIST(type == dns_rdatatype_dlv); + if (val->frdataset.trust != dns_trust_secure) { + validator_log(val, ISC_LOG_DEBUG(3), + "covering nsec: trust %u", + val->frdataset.trust); + goto notfound; + } + result = dns_rdataset_first(&val->frdataset); + if (result != ISC_R_SUCCESS) + goto notfound; + dns_rdataset_current(&val->frdataset, &rdata); + if (dns_nsec_typepresent(&rdata, dns_rdatatype_ns) && + !dns_nsec_typepresent(&rdata, dns_rdatatype_soa)) { + /* Parent NSEC record. */ + if (dns_name_issubdomain(name, foundname)) { + validator_log(val, ISC_LOG_DEBUG(3), + "covering nsec: for parent"); + goto notfound; + } + } + result = dns_rdata_tostruct(&rdata, &nsec, NULL); + if (result != ISC_R_SUCCESS) + goto notfound; + if (dns_name_compare(foundname, &nsec.next) >= 0) { + /* End of zone chain. */ + if (!dns_name_issubdomain(name, &nsec.next)) { + /* + * XXXMPA We could look for a parent NSEC + * at nsec.next and if found retest with + * this NSEC. + */ + dns_rdata_freestruct(&nsec); + validator_log(val, ISC_LOG_DEBUG(3), + "covering nsec: not in zone"); + goto notfound; + } + } else if (dns_name_compare(name, &nsec.next) >= 0) { + /* + * XXXMPA We could check if this NSEC is at a zone + * apex and if the qname is not below it and look for + * a parent NSEC with the same name. This requires + * that we can cache both NSEC records which we + * currently don't support. + */ + dns_rdata_freestruct(&nsec); + validator_log(val, ISC_LOG_DEBUG(3), + "covering nsec: not in range"); + goto notfound; + } + if (isc_log_wouldlog(dns_lctx,ISC_LOG_DEBUG(3))) { + dns_name_format(name, buf1, sizeof buf1); + dns_name_format(foundname, buf2, sizeof buf2); + dns_name_format(&nsec.next, buf3, sizeof buf3); + validator_log(val, ISC_LOG_DEBUG(3), + "covering nsec found: '%s' '%s' '%s'", + buf1, buf2, buf3); + } + if (dns_rdataset_isassociated(&val->frdataset)) + dns_rdataset_disassociate(&val->frdataset); + if (dns_rdataset_isassociated(&val->fsigrdataset)) + dns_rdataset_disassociate(&val->fsigrdataset); + dns_rdata_freestruct(&nsec); + result = DNS_R_NCACHENXDOMAIN; + } else if (result != ISC_R_SUCCESS && + result != DNS_R_GLUE && + result != DNS_R_HINT && + result != DNS_R_NCACHENXDOMAIN && + result != DNS_R_NCACHENXRRSET && + result != DNS_R_NXRRSET && + result != DNS_R_HINTNXRRSET && + result != ISC_R_NOTFOUND) { + goto notfound; + } + return (result); + + notfound: + if (dns_rdataset_isassociated(&val->frdataset)) + dns_rdataset_disassociate(&val->frdataset); + if (dns_rdataset_isassociated(&val->fsigrdataset)) + dns_rdataset_disassociate(&val->fsigrdataset); + return (ISC_R_NOTFOUND); } static inline isc_boolean_t @@ -1483,7 +1595,7 @@ dlv_validatezonekey(dns_validator_t *val) { } if (result != ISC_R_SUCCESS) { validator_log(val, ISC_LOG_DEBUG(3), - "no KEY matching DLV"); + "no DNSKEY matching DLV"); continue; } @@ -1518,7 +1630,8 @@ dlv_validatezonekey(dns_validator_t *val) { dns_rdataset_disassociate(&trdataset); if (result == ISC_R_SUCCESS) break; - validator_log(val, ISC_LOG_DEBUG(3), "no SIG matching DLV key"); + validator_log(val, ISC_LOG_DEBUG(3), + "no RRSIG matching DLV key"); } if (result == ISC_R_SUCCESS) { val->event->rdataset->trust = dns_trust_secure; @@ -1767,7 +1880,7 @@ validatezonekey(dns_validator_t *val) { } if (result != ISC_R_SUCCESS) { validator_log(val, ISC_LOG_DEBUG(3), - "no KEY matching DS"); + "no DNSKEY matching DS"); continue; } @@ -1802,7 +1915,8 @@ validatezonekey(dns_validator_t *val) { dns_rdataset_disassociate(&trdataset); if (result == ISC_R_SUCCESS) break; - validator_log(val, ISC_LOG_DEBUG(3), "no SIG matching DS key"); + validator_log(val, ISC_LOG_DEBUG(3), + "no RRSIG matching DS key"); } if (result == ISC_R_SUCCESS) { event->rdataset->trust = dns_trust_secure; @@ -1982,8 +2096,8 @@ nsecvalidate(dns_validator_t *val, isc_boolean_t resume) { * would lead to a query for the zone key, which * would return a negative answer, which would contain * an SOA and an NSEC signed by the missing key, which - * would trigger another query for the KEY (since the - * first one is still in progress), and go into an + * would trigger another query for the DNSKEY (since + * the first one is still in progress), and go into an * infinite loop. Avoid that. */ if (val->event->type == dns_rdatatype_dnskey && @@ -2099,9 +2213,127 @@ check_ds_algorithm(dns_validator_t *val, dns_name_t *name, return (ISC_FALSE); } +static void +dlv_fetched2(isc_task_t *task, isc_event_t *event) { + dns_fetchevent_t *devent; + dns_validator_t *val; + isc_boolean_t want_destroy; + isc_result_t eresult; + isc_result_t result; + + UNUSED(task); + INSIST(event->ev_type == DNS_EVENT_FETCHDONE); + devent = (dns_fetchevent_t *)event; + val = devent->ev_arg; + eresult = devent->result; + + isc_event_free(&event); + dns_resolver_destroyfetch(&val->fetch); + + INSIST(val->event != NULL); + validator_log(val, ISC_LOG_DEBUG(3), "in dlv_fetched2: %s", + dns_result_totext(eresult)); + + LOCK(&val->lock); + if (eresult == ISC_R_SUCCESS) { + val->havedlvsep = ISC_TRUE; + result = proveunsecure(val, ISC_FALSE); + if (result != DNS_R_WAIT) + validator_done(val, result); + } else if (eresult == DNS_R_NXRRSET || + eresult == DNS_R_NXDOMAIN || + eresult == DNS_R_NCACHENXRRSET || + eresult == DNS_R_NCACHENXDOMAIN) { + result = finddlvsep(val, ISC_TRUE); + if (result == ISC_R_SUCCESS) { + result = proveunsecure(val, ISC_FALSE); + if (result != DNS_R_WAIT) + validator_done(val, result); + } else if (result == ISC_R_NOTFOUND) { + validator_done(val, ISC_R_SUCCESS); + } else if (result != DNS_R_WAIT) + validator_done(val, result); + } + want_destroy = exit_check(val); + UNLOCK(&val->lock); + if (want_destroy) + destroy(val); +} + +static isc_result_t +finddlvsep(dns_validator_t *val, isc_boolean_t resume) { + dns_fixedname_t dlvfixed; + dns_name_t *dlvname; + dns_name_t *dlvsep; + dns_name_t noroot; + isc_result_t result; + unsigned int labels; + + if (!resume) { + dns_fixedname_init(&val->dlvsep); + dlvsep = dns_fixedname_name(&val->dlvsep); + dns_name_copy(val->event->name, dlvsep, NULL); + val->attributes |= VALATTR_DLVSEPTRIED; + } else { + dlvsep = dns_fixedname_name(&val->dlvsep); + labels = dns_name_countlabels(dlvsep); + dns_name_getlabelsequence(dlvsep, 1, labels - 1, dlvsep); + } + dns_name_init(&noroot, NULL); + dns_fixedname_init(&dlvfixed); + dlvname = dns_fixedname_name(&dlvfixed); + labels = dns_name_countlabels(dlvsep); + dns_name_getlabelsequence(dlvsep, 0, labels - 1, &noroot); + result = dns_name_concatenate(&noroot, val->view->dlv, dlvname, NULL); + while (result == ISC_R_NOSPACE) { + labels = dns_name_countlabels(dlvsep); + dns_name_getlabelsequence(dlvsep, 1, labels - 1, dlvsep); + dns_name_getlabelsequence(dlvsep, 0, labels - 2, &noroot); + result = dns_name_concatenate(&noroot, val->view->dlv, + dlvname, NULL); + } + if (result != ISC_R_SUCCESS) { + validator_log(val, ISC_LOG_DEBUG(2), "DLV concatenate failed"); + return (DNS_R_NOVALIDSIG); + } + + while (dns_name_countlabels(dlvname) > + dns_name_countlabels(val->view->dlv)) + { + result = view_find(val, dlvname, dns_rdatatype_dlv); + if (result == ISC_R_SUCCESS) { + if (val->frdataset.trust < dns_trust_secure) + return (DNS_R_NOVALIDSIG); + val->havedlvsep = ISC_TRUE; + return (ISC_R_SUCCESS); + } + if (result == ISC_R_NOTFOUND) { + result = create_fetch(val, dlvname, dns_rdatatype_dlv, + dlv_fetched2, "finddlvsep"); + if (result != ISC_R_SUCCESS) + return (result); + return (DNS_R_WAIT); + } + if (result != DNS_R_NXRRSET && + result != DNS_R_NXDOMAIN && + result != DNS_R_NCACHENXRRSET && + result != DNS_R_NCACHENXDOMAIN) + return (result); + /* + * Strip first labels from both dlvsep and dlvname. + */ + labels = dns_name_countlabels(dlvsep); + dns_name_getlabelsequence(dlvsep, 1, labels - 1, dlvsep); + labels = dns_name_countlabels(dlvname); + dns_name_getlabelsequence(dlvname, 1, labels - 1, dlvname); + } + return (ISC_R_NOTFOUND); +} + static isc_result_t proveunsecure(dns_validator_t *val, isc_boolean_t resume) { isc_result_t result; + isc_result_t tresult; dns_fixedname_t secroot; dns_name_t *tname; @@ -2112,11 +2344,30 @@ proveunsecure(dns_validator_t *val, isc_boolean_t resume) { /* * If the name is not under a security root, it must be insecure. */ - if (result == ISC_R_NOTFOUND) - return (ISC_R_SUCCESS); + if (val->view->dlv != NULL && !DLVSEPTRIED(val) && + !dns_name_issubdomain(val->event->name, val->view->dlv)) { + tresult = finddlvsep(val, ISC_FALSE); + if (tresult != ISC_R_NOTFOUND && tresult != ISC_R_SUCCESS) { + validator_log(val, ISC_LOG_DEBUG(3), + "finddlvsep returned: %s", + dns_result_totext(tresult)); + return (tresult); + } + } - else if (result != ISC_R_SUCCESS) + if (result == ISC_R_NOTFOUND) { + if (!val->havedlvsep) + return (ISC_R_SUCCESS); + dns_name_copy(dns_fixedname_name(&val->dlvsep), + dns_fixedname_name(&secroot), NULL); + } else if (result != ISC_R_SUCCESS) return (result); + else if (val->havedlvsep && + dns_name_issubdomain(dns_fixedname_name(&val->dlvsep), + dns_fixedname_name(&secroot))) { + dns_name_copy(dns_fixedname_name(&val->dlvsep), + dns_fixedname_name(&secroot), NULL); + } if (!resume) { val->labels = @@ -2429,6 +2680,7 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type, val->nsecset = NULL; val->soaname = NULL; val->seensig = ISC_FALSE; + val->havedlvsep = ISC_FALSE; val->mustbesecure = dns_resolver_getmustbesecure(view->resolver, name); dns_rdataset_init(&val->frdataset); dns_rdataset_init(&val->fsigrdataset); diff --git a/dist/bind/lib/dns/zone.c b/dist/bind/lib/dns/zone.c index 9c94dc4ce9c..9e18270455b 100644 --- a/dist/bind/lib/dns/zone.c +++ b/dist/bind/lib/dns/zone.c @@ -1,4 +1,4 @@ -/* $NetBSD: zone.c,v 1.1.1.1 2004/05/17 23:44:56 christos Exp $ */ +/* $NetBSD: zone.c,v 1.1.1.2 2004/11/06 23:55:43 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: zone.c,v 1.333.2.23.2.45 2004/04/29 01:45:23 marka Exp */ +/* Id: zone.c,v 1.333.2.23.2.50 2004/08/28 05:53:37 marka Exp */ #include @@ -2351,8 +2351,10 @@ dump_done(void *arg, isc_result_t result) { tresult = dns_db_getsoaserial(db, version, &serial); if (tresult == ISC_R_SUCCESS) { - tresult = dns_journal_compact(zone->mctx, zone->journal, - serial, zone->journalsize); + tresult = dns_journal_compact(zone->mctx, + zone->journal, + serial, + zone->journalsize); switch (tresult) { case ISC_R_SUCCESS: case ISC_R_NOSPACE: @@ -3620,7 +3622,12 @@ refresh_callback(isc_task_t *task, isc_event_t *event) { dns_message_destroy(&msg); } else if (isc_serial_eq(soa.serial, zone->serial)) { if (zone->masterfile != NULL) { - result = isc_file_settime(zone->masterfile, &now); + result = ISC_R_FAILURE; + if (zone->journal != NULL) + result = isc_file_settime(zone->journal, &now); + if (result != ISC_R_SUCCESS) + result = isc_file_settime(zone->masterfile, + &now); /* Someone removed the file from underneath us! */ if (result == ISC_R_FILENOTFOUND) { LOCK_ZONE(zone); @@ -3988,6 +3995,8 @@ soa_query(isc_task_t *task, isc_event_t *event) { return; skip_master: + if (key != NULL) + dns_tsigkey_detach(&key); zone->curmaster++; if (zone->curmaster < zone->masterscnt) goto again; @@ -4251,14 +4260,17 @@ zone_shutdown(isc_task_t *task, isc_event_t *event) { if (zone->readio != NULL) zonemgr_cancelio(zone->readio); - if (zone->writeio != NULL) - zonemgr_cancelio(zone->writeio); - if (zone->lctx != NULL) dns_loadctx_cancel(zone->lctx); - if (zone->dctx != NULL) - dns_dumpctx_cancel(zone->dctx); + if (!DNS_ZONE_FLAG(zone, DNS_ZONEFLG_FLUSH) || + !DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DUMPING)) { + if (zone->writeio != NULL) + zonemgr_cancelio(zone->writeio); + + if (zone->dctx != NULL) + dns_dumpctx_cancel(zone->dctx); + } notify_cancel(zone); @@ -5166,9 +5178,8 @@ notify_done(isc_task_t *task, isc_event_t *event) { * the soa if we see a formerr and had sent a SOA. */ isc_event_free(&event); - if ((result == ISC_R_TIMEDOUT || - (message != NULL && message->rcode == dns_rcode_formerr && - (notify->flags & DNS_NOTIFY_NOSOA) == 0))) { + if (message != NULL && message->rcode == dns_rcode_formerr && + (notify->flags & DNS_NOTIFY_NOSOA) == 0) { notify->flags |= DNS_NOTIFY_NOSOA; dns_request_destroy(¬ify->request); result = notify_send_queue(notify); @@ -5226,6 +5237,31 @@ zone_replacedb(dns_zone_t *zone, dns_db_t *db, isc_boolean_t dump) { goto fail; if (dump) zone_needdump(zone, DNS_DUMP_DELAY); + else if (zone->journalsize != -1) { + isc_uint32_t serial; + + result = dns_db_getsoaserial(db, ver, &serial); + if (result == ISC_R_SUCCESS) { + result = dns_journal_compact(zone->mctx, + zone->journal, + serial, + zone->journalsize); + switch (result) { + case ISC_R_SUCCESS: + case ISC_R_NOSPACE: + case ISC_R_NOTFOUND: + dns_zone_log(zone, ISC_LOG_DEBUG(3), + "dns_journal_compact: %s", + dns_result_totext(result)); + break; + default: + dns_zone_log(zone, ISC_LOG_ERROR, + "dns_journal_compact failed: %s", + dns_result_totext(result)); + break; + } + } + } } else { if (dump && zone->masterfile != NULL) { isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, diff --git a/dist/bind/lib/isc/Makefile.in b/dist/bind/lib/isc/Makefile.in index 0c0c65df60c..c7bb871674d 100644 --- a/dist/bind/lib/isc/Makefile.in +++ b/dist/bind/lib/isc/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.71.2.2.2.7 2004/03/08 09:04:48 marka Exp +# Id: Makefile.in,v 1.71.2.2.2.8 2004/07/20 07:01:58 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -94,7 +94,7 @@ libisc.@SA@: ${OBJS} libisc.la: ${OBJS} ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} -o libisc.la -rpath ${libdir} \ + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisc.la -rpath ${libdir} \ -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ ${OBJS} ${LIBS} diff --git a/dist/bind/lib/isc/api b/dist/bind/lib/isc/api index 75a502768ef..9d7fc51c828 100644 --- a/dist/bind/lib/isc/api +++ b/dist/bind/lib/isc/api @@ -1,3 +1,3 @@ LIBINTERFACE = 10 -LIBREVISION = 0 +LIBREVISION = 4 LIBAGE = 1 diff --git a/dist/bind/lib/isc/include/isc/result.h b/dist/bind/lib/isc/include/isc/result.h index 431c57e643e..33e4ef70309 100644 --- a/dist/bind/lib/isc/include/isc/result.h +++ b/dist/bind/lib/isc/include/isc/result.h @@ -1,4 +1,4 @@ -/* $NetBSD: result.h,v 1.1.1.1 2004/05/17 23:45:04 christos Exp $ */ +/* $NetBSD: result.h,v 1.1.1.2 2004/11/06 23:55:51 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: result.h,v 1.57.2.2.8.4 2004/03/08 09:04:53 marka Exp */ +/* Id: result.h,v 1.57.2.2.8.5 2004/05/15 03:46:13 jinmei Exp */ #ifndef ISC_RESULT_H #define ISC_RESULT_H 1 @@ -84,11 +84,12 @@ #define ISC_R_BADNUMBER 56 /* not a valid number */ #define ISC_R_DISABLED 57 /* disabled */ #define ISC_R_MAXSIZE 58 /* max size */ +#define ISC_R_BADADDRESSFORM 59 /* invalid address format */ /* * Not a result code: the number of results. */ -#define ISC_R_NRESULTS 59 +#define ISC_R_NRESULTS 60 ISC_LANG_BEGINDECLS diff --git a/dist/bind/lib/isc/inet_ntop.c b/dist/bind/lib/isc/inet_ntop.c index af350d36992..85f3d5eb000 100644 --- a/dist/bind/lib/isc/inet_ntop.c +++ b/dist/bind/lib/isc/inet_ntop.c @@ -1,4 +1,4 @@ -/* $NetBSD: inet_ntop.c,v 1.1.1.1 2004/05/17 23:45:02 christos Exp $ */ +/* $NetBSD: inet_ntop.c,v 1.1.1.2 2004/11/06 23:55:49 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -19,7 +19,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char rcsid[] = - "Id: inet_ntop.c,v 1.12.12.3 2004/03/08 09:04:49 marka Exp"; + "Id: inet_ntop.c,v 1.12.12.4 2004/08/28 06:25:21 marka Exp"; #endif /* LIBC_SCCS and not lint */ #include @@ -29,6 +29,7 @@ static char rcsid[] = #include #include +#include #define NS_INT16SZ 2 #define NS_IN6ADDRSZ 16 diff --git a/dist/bind/lib/isc/lex.c b/dist/bind/lib/isc/lex.c index 2d9072c39e1..53f5d21ffda 100644 --- a/dist/bind/lib/isc/lex.c +++ b/dist/bind/lib/isc/lex.c @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.1.1.1 2004/05/17 23:45:02 christos Exp $ */ +/* $NetBSD: lex.c,v 1.1.1.2 2004/11/06 23:55:49 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: lex.c,v 1.66.2.6.2.7 2004/03/06 08:14:31 marka Exp */ +/* Id: lex.c,v 1.66.2.6.2.8 2004/08/28 06:25:21 marka Exp */ #include @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include diff --git a/dist/bind/lib/isc/log.c b/dist/bind/lib/isc/log.c index 9192bac76f0..777532810c1 100644 --- a/dist/bind/lib/isc/log.c +++ b/dist/bind/lib/isc/log.c @@ -1,4 +1,4 @@ -/* $NetBSD: log.c,v 1.1.1.1 2004/05/17 23:45:02 christos Exp $ */ +/* $NetBSD: log.c,v 1.1.1.2 2004/11/06 23:55:49 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: log.c,v 1.70.2.8.2.10 2004/04/10 04:31:40 marka Exp */ +/* Id: log.c,v 1.70.2.8.2.12 2004/06/11 00:35:38 marka Exp */ /* Principal Authors: DCL */ @@ -1142,6 +1142,10 @@ greatest_version(isc_logchannel_t *channel, int *greatestp) { unsigned int basenamelen; isc_dir_t dir; isc_result_t result; + char sep = '/'; +#ifdef _WIN32 + char *basename2; +#endif REQUIRE(channel->type == ISC_LOG_TOFILE); @@ -1149,7 +1153,15 @@ greatest_version(isc_logchannel_t *channel, int *greatestp) { * It is safe to DE_CONST the file.name because it was copied * with isc_mem_strdup in isc_log_createchannel. */ - basename = strrchr(FILE_NAME(channel), '/'); + basename = strrchr(FILE_NAME(channel), sep); +#ifdef _WIN32 + basename2 = strrchr(FILE_NAME(channel), '\\'); + if ((basename != NULL && basename2 != NULL && basename2 > basename) || + (basename == NULL && basename2 != NULL)) { + basename = basename2; + sep = '\\'; + } +#endif if (basename != NULL) { *basename++ = '\0'; dirname = FILE_NAME(channel); @@ -1166,7 +1178,7 @@ greatest_version(isc_logchannel_t *channel, int *greatestp) { * Replace the file separator if it was taken out. */ if (basename != FILE_NAME(channel)) - *(basename - 1) = '/'; + *(basename - 1) = sep; /* * Return if the directory open failed. @@ -1319,8 +1331,11 @@ isc_log_open(isc_logchannel_t *channel) { if (stat(path, &statbuf) == 0) { regular_file = S_ISREG(statbuf.st_mode) ? ISC_TRUE : ISC_FALSE; /* XXXDCL if not regular_file complain? */ - roll = ISC_TF(regular_file && FILE_MAXSIZE(channel) > 0 && - statbuf.st_size >= FILE_MAXSIZE(channel)); + if ((FILE_MAXSIZE(channel) == 0 && + FILE_VERSIONS(channel) != ISC_LOG_ROLLNEVER) || + (FILE_MAXSIZE(channel) > 0 && + statbuf.st_size >= FILE_MAXSIZE(channel))) + roll = regular_file; } else if (errno == ENOENT) regular_file = ISC_TRUE; else diff --git a/dist/bind/lib/isc/netaddr.c b/dist/bind/lib/isc/netaddr.c index f19890d1166..9d318f0676a 100644 --- a/dist/bind/lib/isc/netaddr.c +++ b/dist/bind/lib/isc/netaddr.c @@ -1,4 +1,4 @@ -/* $NetBSD: netaddr.c,v 1.1.1.1 2004/05/17 23:45:02 christos Exp $ */ +/* $NetBSD: netaddr.c,v 1.1.1.2 2004/11/06 23:55:49 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: netaddr.c,v 1.18.12.8 2004/03/08 09:04:49 marka Exp */ +/* Id: netaddr.c,v 1.18.12.9 2004/05/15 03:46:12 jinmei Exp */ #include @@ -49,7 +49,8 @@ isc_netaddr_equal(const isc_netaddr_t *a, const isc_netaddr_t *b) { break; case AF_INET6: if (memcmp(&a->type.in6, &b->type.in6, - sizeof(a->type.in6)) != 0) + sizeof(a->type.in6)) != 0 || + a->zone != b->zone) return (ISC_FALSE); break; default: diff --git a/dist/bind/lib/isc/result.c b/dist/bind/lib/isc/result.c index dc9c17af9b8..18127be04ce 100644 --- a/dist/bind/lib/isc/result.c +++ b/dist/bind/lib/isc/result.c @@ -1,4 +1,4 @@ -/* $NetBSD: result.c,v 1.1.1.1 2004/05/17 23:45:03 christos Exp $ */ +/* $NetBSD: result.c,v 1.1.1.2 2004/11/06 23:55:50 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: result.c,v 1.56.2.2.8.5 2004/03/08 09:04:50 marka Exp */ +/* Id: result.c,v 1.56.2.2.8.7 2004/06/11 00:31:01 marka Exp */ #include @@ -98,7 +98,8 @@ static const char *text[ISC_R_NRESULTS] = { "soft quota reached", /* 55 */ "not a valid number", /* 56 */ "disabled", /* 57 */ - "max size" /* 58 */ + "max size", /* 58 */ + "invalid address format" /* 59 */ }; #define ISC_RESULT_RESULTSET 2 @@ -126,7 +127,7 @@ register_table(unsigned int base, unsigned int nresults, const char **text, if (table == NULL) return (ISC_R_NOMEMORY); table->base = base; - table->last = base + nresults; + table->last = base + nresults - 1; table->text = text; table->msgcat = msgcat; table->set = set; diff --git a/dist/bind/lib/isc/sockaddr.c b/dist/bind/lib/isc/sockaddr.c index b34e261749f..66ee4cabc12 100644 --- a/dist/bind/lib/isc/sockaddr.c +++ b/dist/bind/lib/isc/sockaddr.c @@ -1,4 +1,4 @@ -/* $NetBSD: sockaddr.c,v 1.1.1.1 2004/05/17 23:45:02 christos Exp $ */ +/* $NetBSD: sockaddr.c,v 1.1.1.2 2004/11/06 23:55:50 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: sockaddr.c,v 1.48.2.1.2.9 2004/03/08 09:04:50 marka Exp */ +/* Id: sockaddr.c,v 1.48.2.1.2.10 2004/05/15 03:46:12 jinmei Exp */ #include @@ -59,6 +59,10 @@ isc_sockaddr_equal(const isc_sockaddr_t *a, const isc_sockaddr_t *b) { if (memcmp(&a->type.sin6.sin6_addr, &b->type.sin6.sin6_addr, sizeof(a->type.sin6.sin6_addr)) != 0) return (ISC_FALSE); +#ifdef ISC_PLATFORM_HAVESCOPEID + if (a->type.sin6.sin6_scope_id != b->type.sin6.sin6_scope_id) + return (ISC_FALSE); +#endif if (a->type.sin6.sin6_port != b->type.sin6.sin6_port) return (ISC_FALSE); break; @@ -88,6 +92,10 @@ isc_sockaddr_eqaddr(const isc_sockaddr_t *a, const isc_sockaddr_t *b) { if (memcmp(&a->type.sin6.sin6_addr, &b->type.sin6.sin6_addr, sizeof(a->type.sin6.sin6_addr)) != 0) return (ISC_FALSE); +#ifdef ISC_PLATFORM_HAVESCOPEID + if (a->type.sin6.sin6_scope_id != b->type.sin6.sin6_scope_id) + return (ISC_FALSE); +#endif break; default: if (memcmp(&a->type, &b->type, a->length) != 0) diff --git a/dist/bind/lib/isc/unix/Makefile.in b/dist/bind/lib/isc/unix/Makefile.in index 84eaa8cfc9e..d0c6c4b6c2a 100644 --- a/dist/bind/lib/isc/unix/Makefile.in +++ b/dist/bind/lib/isc/unix/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.35.2.1.10.1 2004/03/06 08:14:57 marka Exp +# Id: Makefile.in,v 1.35.2.1.10.2 2004/06/22 02:48:36 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -46,3 +46,6 @@ SUBDIRS = include TARGETS = ${OBJS} @BIND9_MAKE_RULES@ + +interfaceiter.@O@: interfaceiter.c ifiter_ioctl.c ifiter_sysctl.c ifiter_getifaddrs.c + diff --git a/dist/bind/lib/isc/unix/ifiter_ioctl.c b/dist/bind/lib/isc/unix/ifiter_ioctl.c index 2f4c958b0bc..6ef96fbb387 100644 --- a/dist/bind/lib/isc/unix/ifiter_ioctl.c +++ b/dist/bind/lib/isc/unix/ifiter_ioctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: ifiter_ioctl.c,v 1.1.1.1 2004/05/17 23:45:05 christos Exp $ */ +/* $NetBSD: ifiter_ioctl.c,v 1.1.1.2 2004/11/06 23:55:52 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: ifiter_ioctl.c,v 1.19.2.5.2.10 2004/04/15 07:03:50 marka Exp */ +/* Id: ifiter_ioctl.c,v 1.19.2.5.2.14 2004/06/22 04:40:23 marka Exp */ /* * Obtain the list of network interfaces using the SIOCGLIFCONF ioctl. @@ -52,7 +52,7 @@ #define VALID_IFITER(t) ISC_MAGIC_VALID(t, IFITER_MAGIC) #define ISC_IF_INET6_SZ \ - sizeof("00000000000000000000000000000001 01 80 10 80 lo\n") + sizeof("00000000000000000000000000000001 01 80 10 80 XXXXXXloXXXXXXXX\n") struct isc_interfaceiter { unsigned int magic; /* Magic number. */ @@ -102,6 +102,16 @@ struct isc_interfaceiter { #define IFCONF_BUFSIZE_INITIAL 4096 #define IFCONF_BUFSIZE_MAX 1048576 +#ifdef __linux +#ifndef IF_NAMESIZE +# ifdef IFNAMSIZ +# define IF_NAMESIZE IFNAMSIZ +# else +# define IF_NAMESIZE 16 +# endif +#endif +#endif + static isc_result_t getbuf4(isc_interfaceiter_t *iter) { char strbuf[ISC_STRERRORSIZE]; @@ -446,15 +456,28 @@ linux_if_inet6_current(isc_interfaceiter_t *iter) { if (iter->valid != ISC_R_SUCCESS) return (iter->valid); - if (iter->proc == NULL) + if (iter->proc == NULL) { + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_INTERFACE, ISC_LOG_ERROR, + "/proc/net/if_inet6:iter->proc == NULL"); return (ISC_R_FAILURE); + } res = sscanf(iter->entry, "%32[a-f0-9] %x %x %x %x %16s\n", address, &ifindex, &prefix, &flag3, &flag4, name); - if (res != 6) + if (res != 6) { + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_INTERFACE, ISC_LOG_ERROR, + "/proc/net/if_inet6:sscanf() -> %d (expected 6)", + res); return (ISC_R_FAILURE); - if (strlen(address) != 32) + } + if (strlen(address) != 32) { + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_INTERFACE, ISC_LOG_ERROR, + "/proc/net/if_inet6:strlen(%s) != 32", address); return (ISC_R_FAILURE); + } for (i = 0; i < 16; i++) { unsigned char byte; static const char hex[] = "0123456789abcdef"; @@ -945,7 +968,7 @@ internal_next(isc_interfaceiter_t *iter) { #endif #ifdef HAVE_TRUCLUSTER if (!iter->clua_done) { - clua_result = clua_getaliasaddress(&intr->clua_sa, + clua_result = clua_getaliasaddress(&iter->clua_sa, &iter->clua_context); if (clua_result != CLUA_SUCCESS) iter->clua_done = ISC_TRUE; @@ -985,7 +1008,7 @@ void internal_first(isc_interfaceiter_t *iter) { #endif #ifdef HAVE_TRUCLUSTER iter->clua_context = 0; - clua_result = clua_getaliasaddress(&intr->clua_sa, + clua_result = clua_getaliasaddress(&iter->clua_sa, &iter->clua_context); iter->clua_done = ISC_TF(clua_result != CLUA_SUCCESS); #endif diff --git a/dist/bind/lib/isc/unix/interfaceiter.c b/dist/bind/lib/isc/unix/interfaceiter.c index a8427bfeaff..db8ec2ed0d5 100644 --- a/dist/bind/lib/isc/unix/interfaceiter.c +++ b/dist/bind/lib/isc/unix/interfaceiter.c @@ -1,4 +1,4 @@ -/* $NetBSD: interfaceiter.c,v 1.1.1.1 2004/05/17 23:45:05 christos Exp $ */ +/* $NetBSD: interfaceiter.c,v 1.1.1.2 2004/11/06 23:55:52 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: interfaceiter.c,v 1.22.2.1.10.12 2004/04/20 06:46:53 marka Exp */ +/* Id: interfaceiter.c,v 1.22.2.1.10.14 2004/08/28 06:25:22 marka Exp */ #include @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,11 @@ get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src, { struct sockaddr_in6 *sa6; +#if !defined(ISC_PLATFORM_HAVEIFNAMETOINDEX) || \ + !defined(ISC_PLATFORM_HAVESCOPEID) + UNUSED(ifname); +#endif + /* clear any remaining value for safety */ memset(dst, 0, sizeof(*dst)); diff --git a/dist/bind/lib/isc/unix/socket.c b/dist/bind/lib/isc/unix/socket.c index a75a4b2d69d..c5ff6c293b8 100644 --- a/dist/bind/lib/isc/unix/socket.c +++ b/dist/bind/lib/isc/unix/socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: socket.c,v 1.1.1.1 2004/05/17 23:45:06 christos Exp $ */ +/* $NetBSD: socket.c,v 1.1.1.2 2004/11/06 23:55:53 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: socket.c,v 1.207.2.19.2.11 2004/04/19 03:05:22 marka Exp */ +/* Id: socket.c,v 1.207.2.19.2.13 2004/07/01 04:51:15 marka Exp */ #include @@ -2861,7 +2861,11 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) { UNLOCK(&sock->lock); return (ISC_R_FAMILYMISMATCH); } - if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, + /* + * Only set SO_REUSEADDR when we want a specific port. + */ + if (isc_sockaddr_getport(sockaddr) != (in_port_t)0 && + setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) < 0) { UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d) %s", sock->fd, diff --git a/dist/bind/lib/isc/win32/socket.c b/dist/bind/lib/isc/win32/socket.c index d8ed9e78bef..980f11ad7f5 100644 --- a/dist/bind/lib/isc/win32/socket.c +++ b/dist/bind/lib/isc/win32/socket.c @@ -1,4 +1,4 @@ -/* $NetBSD: socket.c,v 1.1.1.1 2004/05/17 23:45:07 christos Exp $ */ +/* $NetBSD: socket.c,v 1.1.1.2 2004/11/06 23:55:58 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: socket.c,v 1.5.2.13.2.8 2004/03/06 08:15:10 marka Exp */ +/* Id: socket.c,v 1.5.2.13.2.13 2004/09/01 04:32:18 marka Exp */ /* This code has been rewritten to take advantage of Windows Sockets * I/O Completion Ports and Events. I/O Completion Ports is ONLY @@ -241,8 +241,10 @@ struct isc_socket { listener : 1, /* listener socket */ connected : 1, connecting : 1, /* connect pending */ - bound : 1; /* bound to local addr */ - + bound : 1, /* bound to local addr */ + pending_free: 1; + unsigned int pending_recv; + unsigned int pending_send; }; /* @@ -348,11 +350,8 @@ static isc_threadresult_t WINAPI SocketIoThread(LPVOID ThreadContext); static void free_socket(isc_socket_t **); enum { - SOCKET_CANCEL, - SOCKET_SHUTDOWN, SOCKET_RECV, SOCKET_SEND, - SOCK_ACCEPT }; enum { @@ -360,9 +359,6 @@ enum { EVENT_DELETE }; -#define SOCK_DEAD(s) ((s)->references == 0) - - #if defined(ISC_SOCKET_DEBUG) /* * This is used to dump the contents of the sock structure @@ -456,7 +452,7 @@ iocompletionport_createthreads(int total_threads, isc_socketmgr_t *manager) { * We need at least one */ for (i = 0; i < total_threads; i++) { - manager->hIOCPThreads[i] = CreateThread( NULL, 0, SocketIoThread, + manager->hIOCPThreads[i] = CreateThread(NULL, 0, SocketIoThread, manager, 0, &manager->dwIOCPThreadIds[i]); if(manager->hIOCPThreads[i] == NULL) { @@ -523,7 +519,8 @@ iocompletionport_exit(isc_socketmgr_t *manager) { } /* - * Add sockets in here and pass the sock data in as part of the information needed + * Add sockets in here and pass the sock data in as part of the + * information needed. */ void iocompletionport_update(isc_socket_t *sock) { @@ -654,9 +651,10 @@ socket_eventlist_add(event_change_t *evchange, sock_event_list *evlist, sock->evthread_id = GetCurrentThreadId(); return (ISC_TRUE); } + /* - * Note that the eventLock is locked before calling this function - * All Events and associated sockes are closed here + * Note that the eventLock is locked before calling this function. + * All Events and associated sockets are closed here. */ isc_boolean_t socket_eventlist_delete(event_change_t *evchange, sock_event_list *evlist) { @@ -666,7 +664,7 @@ socket_eventlist_delete(event_change_t *evchange, sock_event_list *evlist) { REQUIRE(evchange != NULL); /* Make sure this is the right thread from which to delete the event */ - if(evchange->evthread_id != GetCurrentThreadId()) + if (evchange->evthread_id != GetCurrentThreadId()) return (ISC_FALSE); REQUIRE(evlist != NULL); @@ -680,6 +678,7 @@ socket_eventlist_delete(event_change_t *evchange, sock_event_list *evlist) { break; } } + /* Actual event start at 1 */ if (iEvent < 1) return (ISC_FALSE); @@ -688,6 +687,7 @@ socket_eventlist_delete(event_change_t *evchange, sock_event_list *evlist) { evlist->aEventList[i] = evlist->aEventList[i + 1]; evlist->aSockList[i] = evlist->aSockList[i + 1]; } + evlist->aEventList[evlist->max_event - 1] = 0; evlist->aSockList[evlist->max_event - 1] = NULL; @@ -700,6 +700,7 @@ socket_eventlist_delete(event_change_t *evchange, sock_event_list *evlist) { return (ISC_TRUE); } + /* * Get the event changes off of the list and apply the * requested changes. The manager lock is taken out at @@ -724,15 +725,20 @@ process_eventlist(sock_event_list *evlist, isc_socketmgr_t *manager) { LOCK(&manager->lock); - /* First the deletes */ + /* + * First the deletes. + */ evchange = ISC_LIST_HEAD(manager->event_updates); while (evchange != NULL) { next = ISC_LIST_NEXT(evchange, link); del = ISC_FALSE; - if(evchange->action == EVENT_DELETE) { + if (evchange->action == EVENT_DELETE) { del = socket_eventlist_delete(evchange, evlist); - /* Delete only if this thread's socket list was updated */ + /* + * Delete only if this thread's socket list was + * updated. + */ if (del) { ISC_LIST_DEQUEUE(manager->event_updates, evchange, link); @@ -742,15 +748,21 @@ process_eventlist(sock_event_list *evlist, isc_socketmgr_t *manager) { } evchange = next; } - /* Now the adds */ + + /* + * Now the adds. + */ evchange = ISC_LIST_HEAD(manager->event_updates); while (evchange != NULL) { next = ISC_LIST_NEXT(evchange, link); del = ISC_FALSE; - if(evchange->action == EVENT_ADD) { + if (evchange->action == EVENT_ADD) { del = socket_eventlist_add(evchange, evlist, manager); - /* Delete only if this thread's socket list was updated */ + /* + * Delete only if this thread's socket list was + * updated. + */ if (del) { ISC_LIST_DEQUEUE(manager->event_updates, evchange, link); @@ -763,13 +775,15 @@ process_eventlist(sock_event_list *evlist, isc_socketmgr_t *manager) { UNLOCK(&manager->lock); return (ISC_R_SUCCESS); } + /* * Add the event list changes to the queue and notify the * event loop */ static void notify_eventlist(isc_socket_t *sock, isc_socketmgr_t *manager, - unsigned int action) { + unsigned int action) +{ event_change_t *evchange; @@ -795,6 +809,7 @@ notify_eventlist(isc_socket_t *sock, isc_socketmgr_t *manager, else WSASetEvent(manager->prime_alert); } + /* * Note that the socket is already locked before calling this function */ @@ -832,6 +847,7 @@ socket_event_add(isc_socket_t *sock, long type) { notify_eventlist(sock, sock->manager, EVENT_ADD); return (ISC_R_SUCCESS); } + /* * Note that the socket is not locked before calling this function */ @@ -849,8 +865,8 @@ socket_event_delete(isc_socket_t *sock) { sock->hAlert = NULL; sock->evthread_id = 0; } - } + /* * Routine to cleanup and then close the socket. * Only close the socket here if it is NOT associated @@ -874,6 +890,7 @@ socket_close(isc_socket_t *sock) { } } + /* * Initialize socket services */ @@ -895,7 +912,8 @@ BOOL InitSockets() { int internal_sendmsg(isc_socket_t *sock, IoCompletionInfo *lpo, - struct msghdr *messagehdr, int flags, int *Error) { + struct msghdr *messagehdr, int flags, int *Error) +{ int Result; DWORD BytesSent; DWORD Flags = flags; @@ -920,19 +938,20 @@ internal_sendmsg(isc_socket_t *sock, IoCompletionInfo *lpo, *Error = WSAGetLastError(); switch (*Error) { + case WSA_IO_INCOMPLETE : + case WSA_WAIT_IO_COMPLETION : + case WSA_IO_PENDING : + sock->pending_send++; + case NO_ERROR : + break; - case NO_ERROR : - case WSA_IO_INCOMPLETE : - case WSA_WAIT_IO_COMPLETION : - case WSA_IO_PENDING : - break; - - default : - return (-1); - break; - } - } - if(lpo != NULL) + default : + return (-1); + break; + } + } else + sock->pending_send++; + if (lpo != NULL) return (0); else return (total_sent); @@ -940,7 +959,8 @@ internal_sendmsg(isc_socket_t *sock, IoCompletionInfo *lpo, int internal_recvmsg(isc_socket_t *sock, IoCompletionInfo *lpo, - struct msghdr *messagehdr, int flags, int *Error) { + struct msghdr *messagehdr, int flags, int *Error) +{ DWORD Flags = 0; DWORD NumBytes = 0; int total_bytes = 0; @@ -948,14 +968,14 @@ internal_recvmsg(isc_socket_t *sock, IoCompletionInfo *lpo, *Error = 0; Result = WSARecvFrom((SOCKET) sock->fd, - messagehdr->msg_iov, - messagehdr->msg_iovlen, - &NumBytes, - &Flags, - messagehdr->msg_name, - (int *)&(messagehdr->msg_namelen), - (LPOVERLAPPED) lpo, - NULL); + messagehdr->msg_iov, + messagehdr->msg_iovlen, + &NumBytes, + &Flags, + messagehdr->msg_name, + (int *)&(messagehdr->msg_namelen), + (LPOVERLAPPED) lpo, + NULL); total_bytes = (int) NumBytes; @@ -965,31 +985,32 @@ internal_recvmsg(isc_socket_t *sock, IoCompletionInfo *lpo, *Error = WSAGetLastError(); switch (*Error) { + case WSA_IO_INCOMPLETE: + case WSA_WAIT_IO_COMPLETION: + case WSA_IO_PENDING: + sock->pending_recv++; + case NO_ERROR: + break; - case NO_ERROR : - case WSA_IO_INCOMPLETE : - case WSA_WAIT_IO_COMPLETION : - case WSA_IO_PENDING : - break; + default : + return (-1); + break; + } + } else + sock->pending_recv++; - default : - return (-1); - break; - } - } /* Return the flags received in header */ messagehdr->msg_flags = Flags; - if(lpo != NULL) + if (lpo != NULL) return (-1); else return (total_bytes); - } static void -manager_log(isc_socketmgr_t *sockmgr, - isc_logcategory_t *category, isc_logmodule_t *module, int level, - const char *fmt, ...) { +manager_log(isc_socketmgr_t *sockmgr, isc_logcategory_t *category, + isc_logmodule_t *module, int level, const char *fmt, ...) +{ char msgbuf[2048]; va_list ap; @@ -1009,11 +1030,13 @@ socket_log(isc_socket_t *sock, isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, int level, isc_msgcat_t *msgcat, int msgset, int message, const char *fmt, ...) ISC_FORMAT_PRINTF(9, 10); + static void socket_log(isc_socket_t *sock, isc_sockaddr_t *address, isc_logcategory_t *category, isc_logmodule_t *module, int level, isc_msgcat_t *msgcat, int msgset, int message, - const char *fmt, ...) { + const char *fmt, ...) +{ char msgbuf[2048]; char peerbuf[256]; va_list ap; @@ -1060,6 +1083,7 @@ make_nonblock(SOCKET fd) { return (ISC_R_SUCCESS); } + /* * Windows 2000 systems incorrectly cause UDP sockets using WASRecvFrom * to not work correctly, returning a WSACONNRESET error when a WSASendTo @@ -1109,7 +1133,8 @@ connection_reset_fix(SOCKET fd) { static void build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *msg, char *cmsg, - WSABUF *iov, size_t *write_countp) { + WSABUF *iov, size_t *write_countp) +{ unsigned int iovcount; isc_buffer_t *buffer; isc_region_t used; @@ -1196,7 +1221,8 @@ build_msghdr_send(isc_socket_t *sock, isc_socketevent_t *dev, static void build_msghdr_recv(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *msg, char *cmsg, - WSABUF *iov, size_t *read_countp) { + WSABUF *iov, size_t *read_countp) +{ unsigned int iovcount; isc_buffer_t *buffer; isc_region_t available; @@ -1226,10 +1252,10 @@ build_msghdr_recv(isc_socket_t *sock, isc_socketevent_t *dev, iov[0].len = read_count; iovcount = 1; } else { - /* - * Multibuffer I/O. - * Skip empty buffers. - */ + /* + * Multibuffer I/O. + * Skip empty buffers. + */ while (buffer != NULL) { REQUIRE(ISC_BUFFER_VALID(buffer)); if (isc_buffer_availablelength(buffer) != 0) @@ -1268,7 +1294,8 @@ build_msghdr_recv(isc_socket_t *sock, isc_socketevent_t *dev, static void set_dev_address(isc_sockaddr_t *address, isc_socket_t *sock, - isc_socketevent_t *dev) { + isc_socketevent_t *dev) +{ if (sock->type == isc_sockettype_udp) { if (address != NULL) dev->address = *address; @@ -1282,14 +1309,14 @@ set_dev_address(isc_sockaddr_t *address, isc_socket_t *sock, static isc_socketevent_t * allocate_socketevent(isc_socket_t *sock, isc_eventtype_t eventtype, - isc_taskaction_t action, const void *arg) { + isc_taskaction_t action, const void *arg) +{ isc_socketevent_t *ev; ev = (isc_socketevent_t *)isc_event_allocate(sock->manager->mctx, sock, eventtype, action, arg, sizeof(*ev)); - if (ev == NULL) return (NULL); @@ -1326,7 +1353,8 @@ dump_msg(struct msghdr *msg, isc_socket_t *sock) { static int completeio_recv(isc_socket_t *sock, isc_socketevent_t *dev, - struct msghdr *messagehdr, int cc, int recv_errno) { + struct msghdr *messagehdr, int cc, int recv_errno) +{ size_t actual_count; isc_buffer_t *buffer; @@ -1444,31 +1472,27 @@ completeio_recv(isc_socket_t *sock, isc_socketevent_t *dev, dev->result = ISC_R_SUCCESS; return (DOIO_SUCCESS); } + static int startio_recv(isc_socket_t *sock, isc_socketevent_t *dev, int *nbytes, - BOOL bwait, int *recv_errno) { + int *recv_errno) +{ char *cmsg = NULL; char strbuf[ISC_STRERRORSIZE]; IoCompletionInfo *lpo; int status; - struct msghdr messagehdr; struct msghdr *msghdr; - if (!bwait) { - lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle, - HEAP_ZERO_MEMORY, sizeof(IoCompletionInfo)); - lpo->request_type = SOCKET_RECV; - lpo->dev = dev; - msghdr = &lpo->messagehdr; - } else { /* Wait for recv to complete */ - lpo = NULL; - msghdr = &messagehdr; - } - sock->references++; + lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle, + HEAP_ZERO_MEMORY, + sizeof(IoCompletionInfo)); + lpo->request_type = SOCKET_RECV; + lpo->dev = dev; + msghdr = &lpo->messagehdr; memset(msghdr, 0, sizeof(struct msghdr)); build_msghdr_recv(sock, dev, msghdr, cmsg, sock->iov, - &(sock->totalBytes)); + &(sock->totalBytes)); #if defined(ISC_SOCKET_DEBUG) dump_msg(msghdr, sock); @@ -1487,13 +1511,12 @@ startio_recv(isc_socket_t *sock, isc_socketevent_t *dev, int *nbytes, socket_log(sock, NULL, IOEVENT, isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_DOIORECV, - "startio_recv: recvmsg(%d) %d bytes, err %d/%s", + "startio_recv: recvmsg(%d) %d bytes, " + "err %d/%s", sock->fd, *nbytes, *recv_errno, strbuf); } - status = completeio_recv(sock, dev, msghdr, *nbytes, *recv_errno); - if(status != DOIO_SOFT) { - sock->references--; - } + status = completeio_recv(sock, dev, msghdr, + *nbytes, *recv_errno); goto done; } dev->result = ISC_R_SUCCESS; @@ -1501,6 +1524,7 @@ startio_recv(isc_socket_t *sock, isc_socketevent_t *dev, int *nbytes, done: return (status); } + /* * Returns: * DOIO_SUCCESS The operation succeeded. dev->result contains @@ -1515,8 +1539,9 @@ done: * No other return values are possible. */ static int -completeio_send(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *messagehdr, int cc, - int send_errno) { +completeio_send(isc_socket_t *sock, isc_socketevent_t *dev, + struct msghdr *messagehdr, int cc, int send_errno) +{ char addrbuf[ISC_SOCKADDR_FORMATSIZE]; char strbuf[ISC_STRERRORSIZE]; @@ -1594,28 +1619,24 @@ completeio_send(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *messa dev->result = ISC_R_SUCCESS; return (DOIO_SUCCESS); } + static int startio_send(isc_socket_t *sock, isc_socketevent_t *dev, int *nbytes, - BOOL bwait, int *send_errno) { + int *send_errno) +{ char *cmsg = NULL; char strbuf[ISC_STRERRORSIZE]; IoCompletionInfo *lpo; int status; - struct msghdr messagehdr; struct msghdr *msghdr; - if (!bwait) { - lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle, - HEAP_ZERO_MEMORY, sizeof(IoCompletionInfo)); - lpo->request_type = SOCKET_SEND; - lpo->dev = dev; - msghdr = &lpo->messagehdr; - } else { /* Wait for send to complete */ - lpo = NULL; - msghdr = &messagehdr; - } + lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle, + HEAP_ZERO_MEMORY, + sizeof(IoCompletionInfo)); + lpo->request_type = SOCKET_SEND; + lpo->dev = dev; + msghdr = &lpo->messagehdr; memset(msghdr, 0, sizeof(struct msghdr)); - sock->references++; build_msghdr_send(sock, dev, msghdr, cmsg, sock->iov, &(sock->totalBytes)); @@ -1633,13 +1654,12 @@ startio_send(isc_socket_t *sock, isc_socketevent_t *dev, int *nbytes, socket_log(sock, NULL, IOEVENT, isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_INTERNALSEND, - "startio_send: internal_sendmsg(%d) %d bytes, err %d/%s", + "startio_send: internal_sendmsg(%d) %d " + "bytes, err %d/%s", sock->fd, *nbytes, *send_errno, strbuf); } - status = completeio_send(sock, dev, msghdr, *nbytes, *send_errno); - if(status != DOIO_SOFT) { - sock->references--; - } + status = completeio_send(sock, dev, msghdr, + *nbytes, *send_errno); goto done; } dev->result = ISC_R_SUCCESS; @@ -1647,6 +1667,7 @@ startio_send(isc_socket_t *sock, isc_socketevent_t *dev, int *nbytes, done: return (status); } + /* * Kill. * @@ -1657,6 +1678,7 @@ static void destroy_socket(isc_socket_t **sockp) { isc_socket_t *sock = *sockp; isc_socketmgr_t *manager = sock->manager; + isc_boolean_t dofree = ISC_TRUE; REQUIRE(sock != NULL); @@ -1670,15 +1692,14 @@ destroy_socket(isc_socket_t **sockp) { LOCK(&manager->lock); - /* - * No one has this socket open and the socket doesn't have to be - * locked. The socket_close function makes sure that if needed - * the event_wait loop removes any associated event from the list - * of events being waited on. - */ + LOCK(&sock->lock); socket_close(sock); - + if (sock->pending_recv != 0 || sock->pending_send != 0) { + dofree = ISC_FALSE; + sock->pending_free = 1; + } ISC_LIST_UNLINK(manager->socklist, sock, link); + UNLOCK(&sock->lock); if (ISC_LIST_EMPTY(manager->socklist)) SIGNAL(&manager->shutdown_ok); @@ -1686,10 +1707,10 @@ destroy_socket(isc_socket_t **sockp) { /* * XXX should reset manager->maxfd here */ - UNLOCK(&manager->lock); - free_socket(sockp); + if (dofree) + free_socket(sockp); } static isc_result_t @@ -1723,6 +1744,9 @@ allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type, sock->connect_ev = NULL; sock->pending_accept = 0; sock->pending_close = 0; + sock->pending_recv = 0; + sock->pending_send = 0; + sock->pending_free = 0; sock->iocp = 0; sock->listener = 0; sock->connected = 0; @@ -1824,11 +1848,13 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, switch (type) { case isc_sockettype_udp: sock->fd = socket(pf, SOCK_DGRAM, IPPROTO_UDP); - result = connection_reset_fix(sock->fd); - if (result != ISC_R_SUCCESS) { - closesocket(sock->fd); - free_socket(&sock); - return (result); + if (sock->fd != INVALID_SOCKET) { + result = connection_reset_fix(sock->fd); + if (result != ISC_R_SUCCESS) { + closesocket(sock->fd); + free_socket(&sock); + return (result); + } } break; case isc_sockettype_tcp: @@ -1894,7 +1920,7 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type, if ((pf == AF_INET6) && (setsockopt(sock->fd, IPPROTO_IPV6, IPV6_PKTINFO, (void *)&on, sizeof(on)) < 0)) { - isc__strerror(WSAGetLaastError(), strbuf, sizeof(strbuf)); + isc__strerror(WSAGetLastError(), strbuf, sizeof(strbuf)); UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d, IPV6_PKTINFO) %s: %s", sock->fd, @@ -2068,14 +2094,6 @@ internal_accept(isc_socket_t *sock, int accept_errno) { INSIST(sock->pending_accept == 1); sock->pending_accept = 0; - INSIST(sock->references > 0); - sock->references--; /* the internal event is done with this socket */ - if (sock->references == 0) { - UNLOCK(&sock->lock); - destroy_socket(&sock); - return; - } - /* * Check any possible error status from the event notification here. * Note that we don't take any action since it was only @@ -2286,18 +2304,6 @@ internal_connect(isc_socket_t *sock, int connect_errno) { LOCK(&sock->lock); - /* - * When the internal event was sent the reference count was bumped - * to keep the socket around for us. Decrement the count here. - */ - INSIST(sock->references > 0); - sock->references--; - if (sock->references == 0) { - UNLOCK(&sock->lock); - destroy_socket(&sock); - return; - } - /* * Has this event been canceled? */ @@ -2368,7 +2374,9 @@ internal_connect(isc_socket_t *sock, int connect_errno) { } static void -internal_recv(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *messagehdr, int nbytes, int recv_errno) { +internal_recv(isc_socket_t *sock, isc_socketevent_t *dev, + struct msghdr *messagehdr, int nbytes, int recv_errno) +{ isc_socketevent_t *ldev; int io_state; int cc; @@ -2380,14 +2388,8 @@ internal_recv(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *message isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_INTERNALRECV, "internal_recv: task got socket event %p", dev); - INSIST(sock->references > 0); - sock->references--; /* the internal event is done with this socket */ - if (sock->references == 0) { - UNLOCK(&sock->lock); - destroy_socket(&sock); - return; - } - + INSIST(sock->pending_recv > 0); + sock->pending_recv--; /* If the event is no longer in the list we can just return */ ldev = ISC_LIST_HEAD(sock->recv_list); while (ldev != NULL && ldev != dev) { @@ -2400,34 +2402,36 @@ internal_recv(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *message * Try to do as much I/O as possible on this socket. There are no * limits here, currently. */ - switch (completeio_recv(sock, dev, messagehdr, nbytes, recv_errno)) { - case DOIO_SOFT: - cc = 0; - recv_errno = 0; - io_state = startio_recv(sock, dev, &cc, FALSE, &recv_errno); - goto done; + switch (completeio_recv(sock, dev, messagehdr, nbytes, recv_errno)) { + case DOIO_SOFT: + cc = 0; + recv_errno = 0; + io_state = startio_recv(sock, dev, &cc, &recv_errno); + goto done; - case DOIO_EOF: - /* - * read of 0 means the remote end was closed. - * Run through the event queue and dispatch all - * the events with an EOF result code. - */ - dev->result = ISC_R_EOF; - send_recvdone_event(sock, &dev); - goto done; + case DOIO_EOF: + /* + * read of 0 means the remote end was closed. + * Run through the event queue and dispatch all + * the events with an EOF result code. + */ + dev->result = ISC_R_EOF; + send_recvdone_event(sock, &dev); + goto done; - case DOIO_SUCCESS: - case DOIO_HARD: - send_recvdone_event(sock, &dev); - break; - } + case DOIO_SUCCESS: + case DOIO_HARD: + send_recvdone_event(sock, &dev); + break; + } done: UNLOCK(&sock->lock); } static void -internal_send(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *messagehdr, int nbytes, int send_errno) { +internal_send(isc_socket_t *sock, isc_socketevent_t *dev, + struct msghdr *messagehdr, int nbytes, int send_errno) +{ isc_socketevent_t *ldev; int io_state; int cc; @@ -2442,13 +2446,8 @@ internal_send(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *message isc_msgcat, ISC_MSGSET_SOCKET, ISC_MSG_INTERNALSEND, "internal_send: task got socket event %p", dev); - INSIST(sock->references > 0); - sock->references--; /* the internal event is done with this socket */ - if (sock->references == 0) { - UNLOCK(&sock->lock); - destroy_socket(&sock); - return; - } + INSIST(sock->pending_send > 0); + sock->pending_send--; /* If the event is no longer in the list we can just return */ ldev = ISC_LIST_HEAD(sock->send_list); @@ -2465,7 +2464,7 @@ internal_send(isc_socket_t *sock, isc_socketevent_t *dev, struct msghdr *message case DOIO_SOFT: cc = 0; send_errno = 0; - io_state = startio_send(sock, dev, &cc, FALSE, &send_errno); + io_state = startio_send(sock, dev, &cc, &send_errno); goto done; case DOIO_HARD: @@ -2489,8 +2488,6 @@ SocketIoThread(LPVOID ThreadContext) { isc_socketmgr_t *manager = ThreadContext; BOOL bSuccess = FALSE; DWORD nbytes; - DWORD tbytes; - DWORD tflags; IoCompletionInfo *lpo = NULL; isc_socket_t *sock = NULL; int request; @@ -2506,7 +2503,9 @@ SocketIoThread(LPVOID ThreadContext) { * preempt normal recv packet processing, but not * higher than the timer sync thread. */ - if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL)) { + if (!SetThreadPriority(GetCurrentThread(), + THREAD_PRIORITY_ABOVE_NORMAL)) + { errval = GetLastError(); isc__strerror(errval, strbuf, sizeof(strbuf)); FATAL_ERROR(__FILE__, __LINE__, @@ -2516,33 +2515,53 @@ SocketIoThread(LPVOID ThreadContext) { strbuf); } - /* * Loop forever waiting on I/O Completions and then processing them */ - while(TRUE) { + while (TRUE) { bSuccess = GetQueuedCompletionStatus ( manager->hIoCompletionPort, &nbytes, (LPDWORD) &sock, (LPOVERLAPPED *)&lpo, - INFINITE - ); - if(lpo == NULL ) { + INFINITE); + if (lpo == NULL) { /* * Received request to exit */ break; } errstatus = 0; - if(!bSuccess) { + if (!bSuccess) { + isc_boolean_t dofree = ISC_FALSE; + REQUIRE(VALID_SOCKET(sock)); /* - * I/O Failure - * Find out why + * Was this the socket closed under us? */ - WSAGetOverlappedResult(sock->fd, (LPWSAOVERLAPPED) &lpo, - &tbytes, FALSE, &tflags); - dev = lpo->dev; + errstatus = WSAGetLastError(); + if (nbytes == 0 && errstatus == WSA_OPERATION_ABORTED) { + LOCK(&sock->lock); + switch (lpo->request_type) { + case SOCKET_RECV: + INSIST(sock->pending_recv > 0); + sock->pending_recv--; + break; + case SOCKET_SEND: + INSIST(sock->pending_send > 0); + sock->pending_send--; + break; + } + if (sock->pending_recv == 0 && + sock->pending_send == 0 && + sock->pending_free) + dofree = ISC_TRUE; + UNLOCK(&sock->lock); + if (dofree) + free_socket(&sock); + if (lpo != NULL) + HeapFree(hHeapHandle, 0, lpo); + continue; + } } request = lpo->request_type; @@ -2550,20 +2569,17 @@ SocketIoThread(LPVOID ThreadContext) { messagehdr = &lpo->messagehdr; switch (request) { - case SOCKET_CANCEL: - break; case SOCKET_RECV: internal_recv(sock, dev, messagehdr, nbytes, errstatus); break; case SOCKET_SEND: internal_send(sock, dev, messagehdr, nbytes, errstatus); break; - default: - break; /* Unknown: Just ignore it */ } if (lpo != NULL) HeapFree(hHeapHandle, 0, lpo); } + /* * Exit Completion Port Thread */ @@ -2572,6 +2588,7 @@ SocketIoThread(LPVOID ThreadContext) { ISC_MSG_EXITING, "SocketIoThread exiting")); return ((isc_threadresult_t)0); } + /* * This is the thread that will loop forever, waiting for an event to * happen. @@ -2633,7 +2650,6 @@ event_wait(void *uap) { } while (cc < 0 && !manager->bShutdown && manager->event_written == 0); - if (manager->bShutdown) break; @@ -2692,11 +2708,9 @@ event_wait(void *uap) { if (wsock->listener == 1 && wsock->pending_accept == 0) { wsock->pending_accept = 1; - wsock->references++; internal_accept(wsock, event_errno); } else { - wsock->references++; internal_connect(wsock, event_errno); } } @@ -2708,6 +2722,7 @@ event_wait(void *uap) { return ((isc_threadresult_t)0); } + /* * Create a new socket manager. */ @@ -2863,7 +2878,8 @@ isc_socketmgr_destroy(isc_socketmgr_t **managerp) { static isc_result_t socket_recv(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, - unsigned int flags) { + unsigned int flags) +{ int io_state; int cc = 0; isc_task_t *ntask = NULL; @@ -2874,7 +2890,7 @@ socket_recv(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, LOCK(&sock->lock); iocompletionport_update(sock); - io_state = startio_recv(sock, dev, &cc, FALSE, &recv_errno); + io_state = startio_recv(sock, dev, &cc, &recv_errno); switch (io_state) { case DOIO_SOFT: @@ -3052,7 +3068,7 @@ socket_send(isc_socket_t *sock, isc_socketevent_t *dev, isc_task_t *task, LOCK(&sock->lock); have_lock = ISC_TRUE; iocompletionport_update(sock); - io_state = startio_send(sock, dev, &cc, FALSE, &send_errno); + io_state = startio_send(sock, dev, &cc, &send_errno); switch (io_state) { case DOIO_SOFT: @@ -3211,7 +3227,11 @@ isc_socket_bind(isc_socket_t *sock, isc_sockaddr_t *sockaddr) { UNLOCK(&sock->lock); return (ISC_R_FAMILYMISMATCH); } - if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, + /* + * Only set SO_REUSEADDR when we want a specific port. + */ + if (isc_sockaddr_getport(sockaddr) != (in_port_t)0 && + setsockopt(sock->fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on)) < 0) { UNEXPECTED_ERROR(__FILE__, __LINE__, "setsockopt(%d) %s", sock->fd, @@ -3645,7 +3665,6 @@ isc_socket_cancel(isc_socket_t *sock, isc_task_t *task, unsigned int how) { isc_task_t *current_task; dev = ISC_LIST_HEAD(sock->accept_list); - socket_event_delete(sock); while (dev != NULL) { current_task = dev->ev_sender; diff --git a/dist/bind/lib/isccc/Makefile.in b/dist/bind/lib/isccc/Makefile.in index 2bee902664e..bab86d43523 100644 --- a/dist/bind/lib/isccc/Makefile.in +++ b/dist/bind/lib/isccc/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.2.12.4 2004/03/06 08:15:18 marka Exp +# Id: Makefile.in,v 1.2.12.5 2004/07/20 07:01:58 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -69,7 +69,7 @@ libisccc.@SA@: ${OBJS} libisccc.la: ${OBJS} ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} -o libisccc.la -rpath ${libdir} \ + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisccc.la -rpath ${libdir} \ -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ ${OBJS} ${LIBS} ${ISCLIBS} diff --git a/dist/bind/lib/isccc/api b/dist/bind/lib/isccc/api index 8cf13ed487b..4f115e73f2d 100644 --- a/dist/bind/lib/isccc/api +++ b/dist/bind/lib/isccc/api @@ -1,3 +1,3 @@ LIBINTERFACE = 2 -LIBREVISION = 0 +LIBREVISION = 1 LIBAGE = 2 diff --git a/dist/bind/lib/isccc/cc.c b/dist/bind/lib/isccc/cc.c index 993db6bafcb..0bde13bf8a1 100644 --- a/dist/bind/lib/isccc/cc.c +++ b/dist/bind/lib/isccc/cc.c @@ -1,4 +1,4 @@ -/* $NetBSD: cc.c,v 1.1.1.1 2004/05/17 23:45:08 christos Exp $ */ +/* $NetBSD: cc.c,v 1.1.1.2 2004/11/06 23:55:59 christos Exp $ */ /* * Portions Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -18,7 +18,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* Id: cc.c,v 1.4.2.3.2.4 2004/03/06 08:15:19 marka Exp */ +/* Id: cc.c,v 1.4.2.3.2.5 2004/08/28 06:25:23 marka Exp */ #include @@ -28,6 +28,7 @@ #include #include +#include #include #include diff --git a/dist/bind/lib/isccfg/Makefile.in b/dist/bind/lib/isccfg/Makefile.in index 80fb0d7891c..61c38b07de7 100644 --- a/dist/bind/lib/isccfg/Makefile.in +++ b/dist/bind/lib/isccfg/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.6.12.7 2004/03/09 05:21:09 marka Exp +# Id: Makefile.in,v 1.6.12.8 2004/07/20 07:01:58 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -66,7 +66,7 @@ libisccfg.@SA@: ${OBJS} libisccfg.la: ${OBJS} ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} -o libisccfg.la -rpath ${libdir} \ + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libisccfg.la -rpath ${libdir} \ -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ ${OBJS} ${LIBS} ${DNSLIBS} ${ISCCCLIBS} ${ISCLIBS} diff --git a/dist/bind/lib/isccfg/api b/dist/bind/lib/isccfg/api index 7f2166bec3a..7c378e6ef95 100644 --- a/dist/bind/lib/isccfg/api +++ b/dist/bind/lib/isccfg/api @@ -1,3 +1,3 @@ LIBINTERFACE = 1 -LIBREVISION = 2 +LIBREVISION = 4 LIBAGE = 0 diff --git a/dist/bind/lib/isccfg/namedconf.c b/dist/bind/lib/isccfg/namedconf.c index ba1c21a8634..8e0a7624170 100644 --- a/dist/bind/lib/isccfg/namedconf.c +++ b/dist/bind/lib/isccfg/namedconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: namedconf.c,v 1.1.1.1 2004/05/17 23:45:09 christos Exp $ */ +/* $NetBSD: namedconf.c,v 1.1.1.2 2004/11/06 23:55:59 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: namedconf.c,v 1.21.44.27 2004/04/15 23:56:34 marka Exp */ +/* Id: namedconf.c,v 1.21.44.28 2004/06/04 02:33:01 marka Exp */ #include @@ -660,6 +660,28 @@ static cfg_type_t cfg_type_mustbesecure = { &cfg_rep_tuple, mustbesecure_fields }; +/* + * dnssec-lookaside + */ + +static keyword_type_t trustanchor_kw = { "trust-anchor", &cfg_type_astring }; + +static cfg_type_t cfg_type_trustanchor = { + "trust-anchor", parse_keyvalue, print_keyvalue, doc_keyvalue, + &cfg_rep_string, &trustanchor_kw +}; + +static cfg_tuplefielddef_t lookaside_fields[] = { + { "domain", &cfg_type_astring, 0 }, + { "trust-anchor", &cfg_type_trustanchor, 0 }, + { NULL, NULL, 0 } +}; + +static cfg_type_t cfg_type_lookaside = { + "lookaside", cfg_parse_tuple, cfg_print_tuple, cfg_doc_tuple, + &cfg_rep_tuple, lookaside_fields +}; + /* * Clauses that can be found within the 'view' statement, * with defaults in the 'options' statement. @@ -705,7 +727,7 @@ view_clauses[] = { { "disable-algorithms", &cfg_type_disablealgorithm, CFG_CLAUSEFLAG_MULTI }, { "dnssec-enable", &cfg_type_boolean, 0 }, - { "dnssec-lookaside", &cfg_type_astring, 0 }, + { "dnssec-lookaside", &cfg_type_lookaside, CFG_CLAUSEFLAG_MULTI }, { "dnssec-must-be-secure", &cfg_type_mustbesecure, CFG_CLAUSEFLAG_MULTI }, { NULL, NULL, 0 } @@ -1203,6 +1225,7 @@ controls_clauses[] = { CFG_CLAUSEFLAG_MULTI|CFG_CLAUSEFLAG_NOTIMP }, { NULL, NULL, 0 } }; + static cfg_clausedef_t * controls_clausesets[] = { controls_clauses, diff --git a/dist/bind/lib/isccfg/parser.c b/dist/bind/lib/isccfg/parser.c index 8ad5956eb78..698f8c202f9 100644 --- a/dist/bind/lib/isccfg/parser.c +++ b/dist/bind/lib/isccfg/parser.c @@ -1,4 +1,4 @@ -/* $NetBSD: parser.c,v 1.1.1.1 2004/05/17 23:45:09 christos Exp $ */ +/* $NetBSD: parser.c,v 1.1.1.2 2004/11/06 23:56:00 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: parser.c,v 1.70.2.20.2.17 2004/03/16 12:38:15 marka Exp */ +/* Id: parser.c,v 1.70.2.20.2.18 2004/05/15 03:46:13 jinmei Exp */ #include @@ -1673,7 +1673,7 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) { } if ((flags & CFG_ADDR_V6OK) != 0 && strlen(s) <= 127U) { - char buf[128]; + char buf[128]; /* see lib/bind9/getaddresses.c */ char *d; /* zone delimiter */ isc_uint32_t zone = 0; /* scope zone ID */ @@ -1684,6 +1684,7 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) { if (inet_pton(AF_INET6, buf, &in6a) == 1) { if (d != NULL) { +#ifdef ISC_PLATFORM_HAVESCOPEID isc_result_t result; result = isc_netscope_pton(AF_INET6, @@ -1692,6 +1693,9 @@ token_addr(cfg_parser_t *pctx, unsigned int flags, isc_netaddr_t *na) { &zone); if (result != ISC_R_SUCCESS) return (result); +#else + return (ISC_R_BADADDRESSFORM); +#endif } isc_netaddr_fromin6(na, &in6a); diff --git a/dist/bind/lib/lwres/Makefile.in b/dist/bind/lib/lwres/Makefile.in index 1dc36718b9d..a74bb8e099c 100644 --- a/dist/bind/lib/lwres/Makefile.in +++ b/dist/bind/lib/lwres/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.25.12.4 2004/03/08 09:05:09 marka Exp +# Id: Makefile.in,v 1.25.12.6 2004/08/28 06:25:23 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -35,14 +35,14 @@ OBJS = context.@O@ gai_strerror.@O@ getaddrinfo.@O@ gethost.@O@ \ getipnode.@O@ getnameinfo.@O@ getrrset.@O@ herror.@O@ \ lwbuffer.@O@ lwconfig.@O@ lwpacket.@O@ lwresutil.@O@ \ lwres_gabn.@O@ lwres_gnba.@O@ lwres_grbn.@O@ lwres_noop.@O@ \ - lwinetaton.@O@ lwinetpton.@O@ lwinetntop.@O@ + lwinetaton.@O@ lwinetpton.@O@ lwinetntop.@O@ print.@O@ # Alphabetically SRCS = context.c gai_strerror.c getaddrinfo.c gethost.c \ getipnode.c getnameinfo.c getrrset.c herror.c \ lwbuffer.c lwconfig.c lwpacket.c lwresutil.c \ lwres_gabn.c lwres_gnba.c lwres_grbn.c lwres_noop.c \ - lwinetaton.c lwinetpton.c lwinetntop.c + lwinetaton.c lwinetpton.c lwinetntop.c print.c LIBS = @LIBS@ @@ -65,7 +65,7 @@ liblwres.@SA@: ${OBJS} version.@O@ liblwres.la: ${OBJS} version.@O@ ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} -o liblwres.la -rpath ${libdir} \ + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o liblwres.la -rpath ${libdir} \ -version-info ${LIBINTERFACE}:${LIBREVISION}:${LIBAGE} \ ${OBJS} version.@O@ ${LIBS} diff --git a/dist/bind/lib/lwres/api b/dist/bind/lib/lwres/api index 44e7ba41c0a..1da8b023146 100644 --- a/dist/bind/lib/lwres/api +++ b/dist/bind/lib/lwres/api @@ -1,3 +1,3 @@ LIBINTERFACE = 3 -LIBREVISION = 0 +LIBREVISION = 1 LIBAGE = 2 diff --git a/dist/bind/lib/lwres/include/lwres/platform.h.in b/dist/bind/lib/lwres/include/lwres/platform.h.in index 7357836b657..ed9f9679837 100644 --- a/dist/bind/lib/lwres/include/lwres/platform.h.in +++ b/dist/bind/lib/lwres/include/lwres/platform.h.in @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: platform.h.in,v 1.12.2.1.10.1 2004/03/06 08:15:36 marka Exp */ +/* Id: platform.h.in,v 1.12.2.1.10.2 2004/08/28 06:25:26 marka Exp */ #ifndef LWRES_PLATFORM_H #define LWRES_PLATFORM_H 1 @@ -78,6 +78,16 @@ */ @LWRES_PLATFORM_USEDECLSPEC@ +/* + * Defined this system needs vsnprintf() and snprintf(). + */ +@LWRES_PLATFORM_NEEDVSNPRINTF@ + +/* + * If this system need a modern sprintf() that returns (int) not (char*). + */ +@LWRES_PLATFORM_NEEDSPRINTF@ + #ifndef LWRES_PLATFORM_USEDECLSPEC #define LIBLWRES_EXTERNAL_DATA #else diff --git a/dist/bind/lib/lwres/lwinetntop.c b/dist/bind/lib/lwres/lwinetntop.c index a3f5071708b..4b0c0740d97 100644 --- a/dist/bind/lib/lwres/lwinetntop.c +++ b/dist/bind/lib/lwres/lwinetntop.c @@ -1,4 +1,4 @@ -/* $NetBSD: lwinetntop.c,v 1.1.1.1 2004/05/17 23:45:10 christos Exp $ */ +/* $NetBSD: lwinetntop.c,v 1.1.1.2 2004/11/06 23:56:00 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -19,7 +19,7 @@ #if defined(LIBC_SCCS) && !defined(lint) static char rcsid[] = - "Id: lwinetntop.c,v 1.9.12.2 2004/03/06 08:15:32 marka Exp"; + "Id: lwinetntop.c,v 1.9.12.3 2004/08/28 06:25:24 marka Exp"; #endif /* LIBC_SCCS and not lint */ #include @@ -29,6 +29,7 @@ static char rcsid[] = #include #include +#include "print_p.h" #define NS_INT16SZ 2 #define NS_IN6ADDRSZ 16 diff --git a/dist/bind/lib/lwres/man/lwres.html b/dist/bind/lib/lwres/man/lwres.html index e300bf3e50b..7981017d2d5 100644 --- a/dist/bind/lib/lwres/man/lwres.html +++ b/dist/bind/lib/lwres/man/lwres.html @@ -15,16 +15,16 @@ - PERFORMANCE OF THIS SOFTWARE. --> - + + lwres

lwres

lwres
Synopsis

#include <lwres/lwres.h>

The lwresd library implements multiple name service APIs. The standard -gethostbyname()gethostbyname(), -gethostbyaddr()gethostbyaddr(), -gethostbyname_r()gethostbyname_r(), -gethostbyaddr_r()gethostbyaddr_r(), -getaddrinfo()getaddrinfo(), -getipnodebyname()getipnodebyname(), and -getipnodebyaddr()getipnodebyaddr() functions are all supported. To allow the lwres library to coexist with system libraries that define functions of the same name, the library defines these functions with names prefixed by -lwres_lwres_. To define the standard names, applications must include the header file @@ -142,23 +142,23 @@ CLASS="FILENAME" > which contains macro definitions mapping the standard function names into -lwres_lwres_ prefixed ones. Operating system vendors who integrate the lwres library into their base distributions should rename the functions in the library proper so that the renaming macros are not needed.

The library also provides a native API consisting of the functions -lwres_getaddrsbyname()lwres_getaddrsbyname() and -lwres_getnamebyaddr()lwres_getnamebyaddr(). These may be called by applications that require more detailed control over the lookup process than the standard functions @@ -167,9 +167,9 @@ provide.

In addition to these name service independent address lookup functions, the library implements a new, experimental API for looking up arbitrary DNS resource records, using the -lwres_getaddrsbyname()lwres_getaddrsbyname() function.

lwres_packet_t, -called pktpkt below.

(2) Set (2) Set pkt.recvlengthpkt.recvlength to the maximum length we will accept. This is done so the receiver of our packets knows how large our receive buffer is. The "default" is a constant in lwres.h: : LWRES_RECVLENGTH = 4096LWRES_RECVLENGTH = 4096.

(3) Set (3) Set pkt.serialpkt.serial to a unique serial number. This value is echoed back to the application by the remote server.

(4) Set (4) Set pkt.pktflagspkt.pktflags. Usually this is set to 0.

(5) Set (5) Set pkt.resultpkt.result to 0.

(6) Call (6) Call lwres_*request_render()lwres_*request_render(), or marshall in the data using the primitives -such as lwres_packet_render()lwres_packet_render() and storing the packet data.

(7) Transmit the resulting buffer.

(8) Call (8) Call lwres_*response_parse()lwres_*response_parse() to parse any packets received.

lwres_packet_t is used -in both the _parse() and _parse() and _render()_render() calls, with only a few modifications made to the packet header's contents between uses. This method is recommended as it keeps the serial, opcode, and other fields correct.

(1) When a packet is received, call (1) When a packet is received, call lwres_*request_parse()lwres_*request_parse() to unmarshall it. This returns a lwres_packet_t (also called (also called pktpkt, below) as well as a data specific type, such as

(2) Process the request in the data specific type.

(3) Set the (3) Set the pkt.resultpkt.result, -pkt.recvlengthpkt.recvlength as above. All other fields can -be left untouched since they were filled in by the *_parse()*_parse() call -above. If using lwres_*response_render()lwres_*response_render(), -pkt.pktflagspkt.pktflags will be set up -properly. Otherwise, the LWRES_LWPACKETFLAG_RESPONSELWRES_LWPACKETFLAG_RESPONSE bit should be set.

(4) Call the data specific rendering function, such as -lwres_gabnresponse_render()lwres_gabnresponse_render().

(5) Send the resulting packet to the client.

- + + lwres_buffer

lwres_buffer

lwres_buffer
Synopsis

#include <lwres/lwbuffer.h>
These functions provide bounds checked access to a region of memory where data is being read or written. They are based on, and similar to, the -isc_buffer_isc_buffer_ functions in the ISC library.

lwres_buffer_init()lwres_buffer_init() initializes the lwres_buffer_t -*b*b and assocates it with the memory region of size -lengthlength bytes starting at location -base.base.

lwres_buffer_invalidate()lwres_buffer_invalidate() marks the buffer -*b*b as invalid. Invalidating a buffer after use is not required, but makes it possible to catch its possible accidental use.

The functions -lwres_buffer_add()lwres_buffer_add() and -lwres_buffer_subtract()lwres_buffer_subtract() respectively increase and decrease the used space in buffer -*b*b by -nn bytes. -lwres_buffer_add()lwres_buffer_add() checks for buffer overflow and -lwres_buffer_subtract()lwres_buffer_subtract() checks for underflow. These functions do not allocate or deallocate memory. They just change the value of -usedused.

A buffer is re-initialised by -lwres_buffer_clear()lwres_buffer_clear(). The function sets -usedused , -currentcurrent and -activeactive to zero.

lwres_buffer_firstlwres_buffer_first makes the consumed region of buffer -*p*p empty by setting -currentcurrent to zero (the start of the buffer).

lwres_buffer_forward()lwres_buffer_forward() increases the consumed region of buffer -*b*b by -nn bytes, checking for overflow. Similarly, -lwres_buffer_back()lwres_buffer_back() decreases buffer -bb's consumed region by -nn bytes and checks for underflow.

lwres_buffer_getuint8()lwres_buffer_getuint8() reads an unsigned 8-bit integer from -*b*b and returns it. -lwres_buffer_putuint8()lwres_buffer_putuint8() writes the unsigned 8-bit integer -valval to buffer -*b*b.

lwres_buffer_getuint16()lwres_buffer_getuint16() and -lwres_buffer_getuint32()lwres_buffer_getuint32() are identical to -lwres_buffer_putuint8()lwres_buffer_putuint8() except that they respectively read an unsigned 16-bit or 32-bit integer in network byte order from -bb. Similarly, -lwres_buffer_putuint16()lwres_buffer_putuint16() and -lwres_buffer_putuint32()lwres_buffer_putuint32() writes the unsigned 16-bit or 32-bit integer -valval to buffer -bb, in network byte order.

Arbitrary amounts of data are read or written from a lightweight resolver buffer with -lwres_buffer_getmem()lwres_buffer_getmem() and -lwres_buffer_putmem()lwres_buffer_putmem() respectively. -lwres_buffer_putmem()lwres_buffer_putmem() copies -lengthlength bytes of memory at -basebase to -bb. Conversely, -lwres_buffer_getmem()lwres_buffer_getmem() copies -lengthlength bytes of memory from -bb to -basebase.

- + + lwres_config

lwres_config

lwres_config
Synopsis

#include <lwres/lwres.h>

DESCRIPTION

lwres_conf_init()lwres_conf_init() creates an empty lwres_conf_t structure for lightweight resolver context -ctxctx.

lwres_conf_clear()lwres_conf_clear() frees up all the internal memory used by that @@ -142,30 +140,24 @@ CLASS="TYPE" >lwres_conf_t structure in resolver context -ctxctx.

lwres_conf_parse()lwres_conf_parse() opens the file -filenamefilename and parses it to initialise the resolver context -ctxctx's structure.

lwres_conf_print()lwres_conf_print() prints the lwres_conf_t structure for resolver context -ctxctx to the FILE -fpfp.

RETURN VALUES

lwres_conf_parse()lwres_conf_parse() returns LWRES_R_SUCCESS if it successfully read and parsed -filenamefilename. It returns LWRES_R_FAILURE if -filenamefilename could not be opened or contained incorrect resolver statements.

lwres_conf_print()lwres_conf_print() returns - + + lwres_context

lwres_context

lwres_context
Synopsis

#include <lwres/lwres.h>

DESCRIPTION

lwres_context_create()lwres_context_create() creates a lwres_context_t is returned through -contextpcontextp, a pointer to a @@ -174,33 +172,25 @@ CLASS="TYPE" >

When the lightweight resolver needs to perform dynamic memory allocation, it will call -malloc_functionmalloc_function to allocate memory and -free_functionfree_function to free it. If -malloc_functionmalloc_function and -free_functionfree_function are NULL, memory is allocated using @@ -215,48 +205,36 @@ CLASS="REFENTRYTITLE" >. It is not permitted to have a NULL -malloc_functionmalloc_function and a non-NULL -free_functionfree_function or vice versa. -argarg is passed as the first parameter to the memory allocation functions. If -malloc_functionmalloc_function and -free_functionfree_function are NULL, -argarg is unused and should be passed as NULL.

and returned via -*contextp*contextp.

lwres_context_destroy()lwres_context_destroy() destroys a , closing its socket. -contextpcontextp is a pointer to a pointer to the context that is to be destroyed. The pointer will be set to NULL when the context has been destroyed.

The context holds a serial number that is used to identify resolver request packets and associate responses with the corresponding requests. This serial number is controlled using -lwres_context_initserial()lwres_context_initserial() and -lwres_context_nextserial()lwres_context_nextserial(). -lwres_context_initserial()lwres_context_initserial() sets the serial number for context -*ctx*ctx to -serialserial. -lwres_context_nextserial()lwres_context_nextserial() increments the serial number and returns the previous value.

Memory for a lightweight resolver context is allocated and freed using -lwres_context_allocmem()lwres_context_allocmem() and -lwres_context_freemem()lwres_context_freemem(). These use whatever allocations were defined when the context was created with -lwres_context_create()lwres_context_create(). -lwres_context_allocmem()lwres_context_allocmem() allocates -lenlen bytes of memory and if successful returns a pointer to the allocated storage. -lwres_context_freemem()lwres_context_freemem() frees -lenlen bytes of space starting at location -memmem.

lwres_context_sendrecv()lwres_context_sendrecv() performs I/O for the context -ctxctx. Data are read and written from the context's socket. It writes data from -sendbasesendbase — typically a lightweight resolver query packet — and waits for a reply which is copied to the receive buffer at -recvbaserecvbase. The number of bytes that were written to this receive buffer is returned in -*recvd_len*recvd_len.

RETURN VALUES

lwres_context_create()lwres_context_create() returns

Successful calls to the memory allocator -lwres_context_allocmem()lwres_context_allocmem() return a pointer to the start of the allocated space. It returns NULL if memory could not be allocated.

LWRES_R_SUCCESS is returned when -lwres_context_sendrecv()lwres_context_sendrecv() completes successfully. LWRES_R_TIMEOUT is returned if -lwres_context_sendrecv()lwres_context_sendrecv() times out waiting for a response.

- + + lwres_gabn

lwres_gabn

lwres_gabn
Synopsis

#include <lwres/lwres.h>

lwres_gabnrequest_render()lwres_gabnrequest_render() uses resolver context -ctxctx to convert getaddrbyname request structure -reqreq to canonical format. The packet header structure -pktpkt is initialised and transferred to buffer -bb. The contents of -*req*req are then appended to the buffer in canonical format. -lwres_gabnresponse_render()lwres_gabnresponse_render() performs the same task, except it converts a getaddrbyname response structure to the lightweight resolver's canonical format.

lwres_gabnrequest_parse()lwres_gabnrequest_parse() uses context -ctxctx to convert the contents of packet -pktpkt to a structure. Buffer -bb provides space to be used for storing this structure. When the function succeeds, the resulting @@ -270,21 +254,19 @@ CLASS="TYPE" >lwres_gabnrequest_t is made available through -*structp*structp. -lwres_gabnresponse_parse()lwres_gabnresponse_parse() offers the same semantics as -lwres_gabnrequest_parse()lwres_gabnrequest_parse() except it yields a structure.

lwres_gabnresponse_free()lwres_gabnresponse_free() and -lwres_gabnrequest_free()lwres_gabnrequest_free() release the memory in resolver context -ctxctx that was allocated to the lwres_gabnrequest_t structures referenced via -structpstructp. Any memory associated with ancillary buffers and strings for those @@ -339,22 +317,22 @@ NAME="AEN93" >RETURN VALUES

The getaddrbyname opcode functions -lwres_gabnrequest_render()lwres_gabnrequest_render(), -lwres_gabnresponse_render()lwres_gabnresponse_render() -lwres_gabnrequest_parse()lwres_gabnrequest_parse() and -lwres_gabnresponse_parse()lwres_gabnresponse_parse() all return LWRES_R_UNEXPECTEDEND is returned if the available space in the buffer -bb is too small to accommodate the packet header or the lwres_gabnresponse_t structures. -lwres_gabnrequest_parse()lwres_gabnrequest_parse() and -lwres_gabnresponse_parse()lwres_gabnresponse_parse() will return LWRES_R_FAILURE if -pktflagspktflags in the packet header structure - + + lwres_gai_strerror

lwres_gai_strerror

lwres_gai_strerror
Synopsis

#include <lwres/netdb.h>

DESCRIPTION

lwres_gai_strerror()lwres_gai_strerror() returns an error message corresponding to an error code returned by -getaddrinfo()getaddrinfo(). The following error codes and their meaning are defined in

invalid value for -ai_flagsai_flags

ai_familyai_family not supported

servname not supported for servname not supported for ai_socktypeai_socktype

ai_socktypeai_socktype not supported

invalid error code is returned if -ecodeecode is out of range.

ai_flagsai_flags, -ai_familyai_family and -ai_socktypeai_socktype are elements of the struct addrinfo used by -lwres_getaddrinfo()lwres_getaddrinfo().

- + + lwres_getaddrinfo

lwres_getaddrinfo

lwres_getaddrinfo
Synopsis

#include <lwres/netdb.h>

DESCRIPTION

lwres_getaddrinfo()lwres_getaddrinfo() is used to get a list of IP addresses and port numbers for host -hostnamehostname and service -servnameservname. The function is the lightweight resolver's implementation of -getaddrinfo()getaddrinfo() as defined in RFC2133. -hostnamehostname and -servnameservname are pointers to null-terminated strings or @@ -156,19 +148,15 @@ CLASS="TYPE" >NULL. -hostnamehostname is either a host name or a numeric host address string: a dotted decimal IPv4 address or an IPv6 address. -servnameservname is either a decimal port number or a service name as listed in /etc/services.

hintshints is an optional pointer to a *hints*hints:

ai_familyai_family

The protocol family that should be used. When -ai_familyai_family is set to

ai_socktypeai_socktype

— that is wanted. When -ai_socktypeai_socktype is zero the caller will accept any socket type.

ai_protocolai_protocol

indicates which transport protocol is wanted: IPPROTO_UDP or IPPROTO_TCP. If -ai_protocolai_protocol is zero the caller will accept any protocol.

ai_flagsai_flags

AI_CANONNAME bit is set, a successful call to -lwres_getaddrinfo()lwres_getaddrinfo() will return a null-terminated string containing the canonical name of the specified hostname in -ai_canonnameai_canonname of the first

When -ai_flagsai_flags does not set the hostnamehostname is a AI_PASSIVE is not set in -ai_flagsai_flags.

If -ai_flagsai_flags is set to AI_NUMERICHOST it indicates that -hostnamehostname should be treated as a numeric string defining an IPv4 or IPv6 address and no name resolution should be attempted.

struct addrinfo passed -via hintshints must be zero.

A A hintshints of NULLstruct addrinfo initialized to zero -with ai_familyai_familyset to -PF_UNSPECPF_UNSPEC.

After a successful call to -lwres_getaddrinfo()lwres_getaddrinfo(), -*res*res is a pointer to a linked list of one or more in this list cn be processed by following the -ai_nextai_next pointer, until a pointer is encountered. The three members -ai_familyai_family, -ai_socktypeai_socktype, and -ai_protocolai_protocol in each returned @@ -525,43 +499,41 @@ CLASS="TYPE" >addrinfo structure in the list, the -ai_addrai_addr member points to a filled-in socket address structure of length -ai_addrlenai_addrlen.

All of the information returned by -lwres_getaddrinfo()lwres_getaddrinfo() is dynamically allocated: the addrinfo structures, and the socket address structures and canonical host name strings pointed to by the -addrinfoaddrinfostructures. Memory allocated for the dynamically allocated structures created by a successful call to -lwres_getaddrinfo()lwres_getaddrinfo() is released by -lwres_freeaddrinfo()lwres_freeaddrinfo(). -aiai is a pointer to a struct addrinfo created by a call to -lwres_getaddrinfo()lwres_getaddrinfo().

RETURN VALUES

lwres_getaddrinfo()lwres_getaddrinfo() returns zero on success or one of the error codes listed in if an error occurs. If both -hostnamehostname and -servnameservname are NULL -lwres_getaddrinfo()lwres_getaddrinfo() returns - + + lwres_gethostent

lwres_gethostent

lwres_gethostent
Synopsis

#include <lwres/netdb.h>
h_nameh_name

The official (canonical) name of the host.

h_aliasesh_aliases

A NULL-terminated array of alternate names (nicknames) for the host.

h_addrtypeh_addrtype

.

h_lengthh_length

The length of the address in bytes.

h_addr_listh_addr_list

For backward compatibility with very old software, -h_addrh_addr is the first address in -h_addr_list.h_addr_list.

lwres_gethostent()lwres_gethostent(), -lwres_sethostent()lwres_sethostent(), -lwres_endhostent()lwres_endhostent(), -lwres_gethostent_r()lwres_gethostent_r(), -lwres_sethostent_r()lwres_sethostent_r() and -lwres_endhostent_r()lwres_endhostent_r() provide iteration over the known host entries on systems that provide such functionality through facilities like @@ -311,33 +311,29 @@ or NIS. The lightweight resolver does not currently implement these functions; it only provides them as stub functions that always return failure.

lwres_gethostbyname()lwres_gethostbyname() and -lwres_gethostbyname2()lwres_gethostbyname2() look up the hostname -namename. -lwres_gethostbyname()lwres_gethostbyname() always looks for an IPv4 -address while lwres_gethostbyname2()lwres_gethostbyname2() looks for an -address of protocol family afaf: either NULL is returned if the lookups by -lwres_gethostbyname()lwres_gethostbyname() or -lwres_gethostbyname2()lwres_gethostbyname2() fail.

Reverse lookups of addresses are performed by -lwres_gethostbyaddr()lwres_gethostbyaddr(). -addraddr is an address of length -lenlen bytes and protocol family -typetype — PF_INETPF_INET6. -lwres_gethostbyname_r()lwres_gethostbyname_r() is a thread-safe function for forward lookups. If an error occurs, an error code is returned in -*error*error. -resbufresbuf is a pointer to a struct hostent which is initialised by a successful call to -lwres_gethostbyname_r()lwres_gethostbyname_r() . -bufbuf is a buffer of length -lenlen bytes which is used to store the -h_name, h_name, h_aliasesh_aliases, and -h_addr_listh_addr_list elements of the struct hostent returned in returned in resbufresbuf. -Successful calls to lwres_gethostbyname_r()lwres_gethostbyname_r() -return resbufresbuf, which is a pointer to the struct hostent it created.

lwres_gethostbyaddr_r()lwres_gethostbyaddr_r() is a thread-safe function -that performs a reverse lookup of address addraddr -which is lenlen bytes long and is of protocol -family typetype — PF_INETPF_INET6. If an error occurs, the error code is returned -in *error*error. The other function parameters are -identical to those in lwres_gethostbyname_r()lwres_gethostbyname_r(). -resbufresbuf is a pointer to a struct hostent which is initialised by a successful call to -lwres_gethostbyaddr_r()lwres_gethostbyaddr_r(). -bufbuf is a buffer of length -lenlen bytes which is used to store the -h_name, h_name, h_aliasesh_aliases, and -h_addr_listh_addr_list elements of the struct hostent returned in returned in resbufresbuf. Successful -calls to lwres_gethostbyaddr_r()lwres_gethostbyaddr_r() return -resbufresbuf, which is a pointer to the -struct hostent()struct hostent() it created.

RETURN VALUES

The functions -lwres_gethostbyname()lwres_gethostbyname(), -lwres_gethostbyname2()lwres_gethostbyname2(), -lwres_gethostbyaddr()lwres_gethostbyaddr(), and -lwres_gethostent()lwres_gethostent() return NULL to indicate an error. In this case the global variable

HOST_NOT_FOUNDHOST_NOT_FOUND

The host or address was not found.

TRY_AGAINTRY_AGAIN

NO_RECOVERYNO_RECOVERY

A non-recoverable error occurred.

NO_DATANO_DATA

translates these error codes to suitable error messages.

lwres_gethostent()lwres_gethostent() and -lwres_gethostent_r()lwres_gethostent_r() always return NULL.

Successful calls to Successful calls to lwres_gethostbyname_r()lwres_gethostbyname_r() and -lwres_gethostbyaddr_r()lwres_gethostbyaddr_r() return -resbufresbuf, a pointer to the struct @@ -698,40 +656,36 @@ hostentNULL if the lookups fail or if if the lookups fail or if bufbuf was too small to hold the list of addresses and names referenced by -the h_name, h_name, h_aliasesh_aliases, and -h_addr_listh_addr_list elements of the struct hostent. If . If bufbuf was too small, both -lwres_gethostbyname_r()lwres_gethostbyname_r() and -lwres_gethostbyaddr_r()lwres_gethostbyaddr_r() set the global variable

BUGS

lwres_gethostbyname()lwres_gethostbyname(), -lwres_gethostbyname2()lwres_gethostbyname2(), -lwres_gethostbyaddr()lwres_gethostbyaddr() and -lwres_endhostent()lwres_endhostent() are not thread safe; they return pointers to static data and provide error codes through a global variable. Thread-safe versions for name and address lookup are provided by -lwres_gethostbyname_r()lwres_gethostbyname_r(), and -lwres_gethostbyaddr_r()lwres_gethostbyaddr_r() respectively.

- + + lwres_getipnode

lwres_getipnode

lwres_getipnode
Synopsis

#include <lwres/netdb.h>
h_nameh_name

The official (canonical) name of the host.

h_aliasesh_aliases

A NULL-terminated array of alternate names (nicknames) for the host.

h_addrtypeh_addrtype

.

h_lengthh_length

The length of the address in bytes.

h_addr_listh_addr_list

lwres_getipnodebyname()lwres_getipnodebyname() looks up addresses of protocol family -afaf for the hostname -namename. The -flagsflags parameter contains ORed flag bits to specify the types of addresses that are searched @@ -231,44 +225,40 @@ The flag bits are: CLASS="VARIABLELIST" >

AI_V4MAPPEDAI_V4MAPPED

This is used with an -afaf of AF_INET6, and causes IPv4 addresses to be returned as IPv4-mapped IPv6 addresses.

AI_ALLAI_ALL

This is used with an -afaf of AF_INET6, and causes all known addresses (IPv6 and IPv4) to be returned. If AI_V4MAPPED is also set, the IPv4 addresses are return as mapped IPv6 addresses.

AI_ADDRCONFIGAI_ADDRCONFIG

AI_DEFAULTAI_DEFAULT

This default sets the -AI_V4MAPPEDAI_V4MAPPED and -AI_ADDRCONFIGAI_ADDRCONFIG flag bits.

lwres_getipnodebyaddr()lwres_getipnodebyaddr() performs a reverse lookup of address -srcsrc which is -lenlen bytes long. -afaf denotes the protocol family, typically PF_INET6.

lwres_freehostent()lwres_freehostent() releases all the memory associated with the @@ -347,27 +331,25 @@ CLASS="TYPE" >struct hostent pointer -hehe. Any memory allocated for the -h_nameh_name, -h_addr_listh_addr_list and -h_aliasesh_aliases is freed, as is the memory for the RETURN VALUES

If an error occurs, -lwres_getipnodebyname()lwres_getipnodebyname() and -lwres_getipnodebyaddr()lwres_getipnodebyaddr() set -*error_num*error_num to an appropriate error code and the function returns a

HOST_NOT_FOUNDHOST_NOT_FOUND

No such host is known.

NO_ADDRESSNO_ADDRESS

TRY_AGAINTRY_AGAIN

NO_RECOVERYNO_RECOVERY

- + + lwres_getnameinfo

lwres_getnameinfo

lwres_getnameinfo
Synopsis

#include <lwres/netdb.h>
getnameinfo(3) function defined in RFC2133. -lwres_getnameinfo()lwres_getnameinfo() returns the hostname for the struct sockaddr sasa which is -salensalen bytes long. The hostname is of length -hostlenhostlen and is returned via -*host.*host. The maximum length of the hostname is -1025 bytes: NI_MAXHOSTNI_MAXHOST.

The name of the service associated with the port number in -sa is returned in sa is returned in *serv.*serv. -It is servlenservlen bytes long. The maximum length -of the service name is NI_MAXSERVNI_MAXSERV - 32 bytes.

The The flagsflags argument sets the following bits:

NI_NOFQDNNI_NOFQDN

NI_NUMERICHOSTNI_NUMERICHOST

NI_NAMEREQDNI_NAMEREQD

NI_NUMERICSERVNI_NUMERICSERV

The service name is returned as a digit string representing the port number.

NI_DGRAMNI_DGRAM

RETURN VALUES

lwres_getnameinfo()lwres_getnameinfo() returns 0 on success or a non-zero error code if an error occurs.

- + + lwres_getrrsetbyname

lwres_getrrsetbyname

lwres_getrrsetbyname
Synopsis

#include <lwres/netdb.h>

DESCRIPTION

lwres_getrrsetbyname()lwres_getrrsetbyname() gets a set of resource records associated with a -hostnamehostname, -classclass, and -typetype. -hostnamehostname is a pointer a to null-terminated string. The -flagsflags field is currently unused and must be zero.

After a successful call to -lwres_getrrsetbyname()lwres_getrrsetbyname(), -*res*res is a pointer to an rri_rdclassrri_rdclass and -rri_rdtyperri_rdtype are copied from the parameters. -rri_ttlrri_ttl and -rri_namerri_name are properties of the obtained rrset. The resource records contained in -rri_rdatasrri_rdatas and -rri_sigsrri_sigs are in uncompressed DNS wire format. Properties of the rdataset are represented in the -rri_flagsrri_flags bitfield. If the RRSET_VALIDATED bit is set, the data has been DNSSEC validated and the signatures verified.

All of the information returned by -lwres_getrrsetbyname()lwres_getrrsetbyname() is dynamically allocated: the -rrsetinforrsetinfo and -rdatainfordatainfo structures, and the canonical host name strings pointed to by the -rrsetinforrsetinfostructure. Memory allocated for the dynamically allocated structures created by a successful call to -lwres_getrrsetbyname()lwres_getrrsetbyname() is released by -lwres_freerrset()lwres_freerrset(). -rrsetrrset is a pointer to a struct rrset created by a call to -lwres_getrrsetbyname()lwres_getrrsetbyname().

RETURN VALUES

lwres_getrrsetbyname()lwres_getrrsetbyname() returns zero on success, and one of the following error codes if an error occurred: @@ -296,54 +282,54 @@ codes if an error occurred: CLASS="VARIABLELIST" >

ERRSET_NONAMEERRSET_NONAME

the name does not exist

ERRSET_NODATAERRSET_NODATA

the name exists, but does not have data of the desired type

ERRSET_NOMEMORYERRSET_NOMEMORY

memory could not be allocated

ERRSET_INVALERRSET_INVAL

a parameter is invalid

ERRSET_FAILERRSET_FAIL

other failure

- + + lwres_gnba

lwres_gnba

lwres_gnba
Synopsis

#include <lwres/lwres.h>

lwres_gnbarequest_render()lwres_gnbarequest_render() uses resolver context -ctxctx to convert getnamebyaddr request structure -reqreq to canonical format. The packet header structure -pktpkt is initialised and transferred to buffer -bb. The contents of -*req*req are then appended to the buffer in canonical format. -lwres_gnbaresponse_render()lwres_gnbaresponse_render() performs the same task, except it converts a getnamebyaddr response structure to the lightweight resolver's canonical format.

lwres_gnbarequest_parse()lwres_gnbarequest_parse() uses context -ctxctx to convert the contents of packet -pktpkt to a structure. Buffer -bb provides space to be used for storing this structure. When the function succeeds, the resulting @@ -246,18 +246,18 @@ CLASS="TYPE" >lwres_gnbarequest_t is made available through -*structp*structp. -lwres_gnbaresponse_parse()lwres_gnbaresponse_parse() offers the same semantics as -lwres_gnbarequest_parse()lwres_gnbarequest_parse() except it yields a structure.

lwres_gnbaresponse_free()lwres_gnbaresponse_free() and -lwres_gnbarequest_free()lwres_gnbarequest_free() release the memory in resolver context -ctxctx that was allocated to the lwres_gnbarequest_t structures referenced via -structpstructp. Any memory associated with ancillary buffers and strings for those structures is also discarded.

RETURN VALUES

The getnamebyaddr opcode functions -lwres_gnbarequest_render()lwres_gnbarequest_render(), -lwres_gnbaresponse_render()lwres_gnbaresponse_render() -lwres_gnbarequest_parse()lwres_gnbarequest_parse() and -lwres_gnbaresponse_parse()lwres_gnbaresponse_parse() all return LWRES_R_UNEXPECTEDEND is returned if the available space in the buffer -bb is too small to accommodate the packet header or the lwres_gnbaresponse_t structures. -lwres_gnbarequest_parse()lwres_gnbarequest_parse() and -lwres_gnbaresponse_parse()lwres_gnbaresponse_parse() will return LWRES_R_FAILURE if -pktflagspktflags in the packet header structure - + + lwres_hstrerror

lwres_hstrerror

lwres_hstrerror
Synopsis

#include <lwres/netdb.h>

DESCRIPTION

lwres_herror()lwres_herror() prints the string -ss on stderr followed by the string -generated by lwres_hstrerror()lwres_hstrerror() for the error code -stored in the global variable lwres_h_errnolwres_h_errno.

lwres_hstrerror()lwres_hstrerror() returns an appropriate string -for the error code gievn by errerr. The values of the error codes and messages are as follows: @@ -205,14 +201,14 @@ NAME="AEN65" CLASS="ERRORNAME" >Unknown resolver error is returned by -lwres_hstrerror()lwres_hstrerror() when the value of -lwres_h_errnolwres_h_errno is not a valid error code.

- + + lwres_inetntop

lwres_inetntop

lwres_inetntop
Synopsis

#include <lwres/net.h>

DESCRIPTION

lwres_net_ntop()lwres_net_ntop() converts an IP address of -protocol family afaf — IPv4 or IPv6 — -at location srcsrc from network format to its conventional representation as a string. For IPv4 addresses, that string would be a dotted-decimal. An IPv6 address would be represented in colon notation as described in RFC1884.

The generated string is copied to The generated string is copied to dstdst provided -sizesize indicates it is long enough to store the ASCII representation of the address.

RETURN VALUES

If successful, the function returns If successful, the function returns dstdst: a pointer to a string containing the presentation format of the -address. lwres_net_ntop()lwres_net_ntop() returns NULL and sets the global variable -errnoerrno to EAFNOSUPPORT if -the protocol family given in afaf is not supported.

- + + lwres_noop

lwres_noop

lwres_noop
Synopsis

#include <lwres/lwres.h>

lwres_nooprequest_render()lwres_nooprequest_render() uses resolver -context ctxctx to convert no-op request structure -reqreq to canonical format. The packet header -structure pktpkt is initialised and transferred to -buffer bb. The contents of -*req*req are then appended to the buffer in -canonical format. lwres_noopresponse_render()lwres_noopresponse_render() performs the same task, except it converts a no-op response structure to the lightweight resolver's canonical format.

lwres_nooprequest_parse()lwres_nooprequest_parse() uses context -ctxctx to convert the contents of packet -pktpkt to a lwres_nooprequest_t -structure. Buffer bb provides space to be used for storing this structure. When the function succeeds, the resulting lwres_nooprequest_t is made available through -*structp*structp. -lwres_noopresponse_parse()lwres_noopresponse_parse() offers the same -semantics as lwres_nooprequest_parse()lwres_nooprequest_parse() except it yields a lwres_noopresponse_t structure.

lwres_noopresponse_free()lwres_noopresponse_free() and -lwres_nooprequest_free()lwres_nooprequest_free() release the memory in -resolver context ctxctx that was allocated to the lwres_nooprequest_t -structures referenced via structpstructp.

RETURN VALUES

The no-op opcode functions -lwres_nooprequest_render()lwres_nooprequest_render(), -lwres_noopresponse_render()lwres_noopresponse_render() -lwres_nooprequest_parse()lwres_nooprequest_parse() and -lwres_noopresponse_parse()lwres_noopresponse_parse() all return LWRES_R_UNEXPECTEDEND is returned if the available space in the buffer -bb is too small to accommodate the packet header or the lwres_noopresponse_t structures. -lwres_nooprequest_parse()lwres_nooprequest_parse() and -lwres_noopresponse_parse()lwres_noopresponse_parse() will return LWRES_R_FAILURE if -pktflagspktflags in the packet header structure - + + lwres_packet

lwres_packet

lwres_packet
Synopsis

#include <lwres/lwpacket.h>
lengthlength

versionversion

pktflagspktflags

serialserial

opcodeopcode

resultresult

recvlengthrecvlength

authtypeauthtype

authlenauthlen

NOOPNOOP

GETADDRSBYNAMEGETADDRSBYNAME

GETNAMEBYADDRGETNAMEBYADDR

lwres_lwpacket_renderheader()lwres_lwpacket_renderheader() transfers the contents of lightweight resolver packet structure lwres_lwpacket_t *pkt*pkt in network byte order to the lightweight resolver buffer, -*b*b.

lwres_lwpacket_parseheader()lwres_lwpacket_parseheader() performs the converse operation. It transfers data in network byte order from -buffer *b*b to resolver packet -*pkt*pkt. The contents of the buffer -bb should correspond to a RETURN VALUES

Successful calls to -lwres_lwpacket_renderheader()lwres_lwpacket_renderheader() and -lwres_lwpacket_parseheader()lwres_lwpacket_parseheader() return LWRES_R_SUCCESS. If there is insufficient -space to copy data between the buffer *b*b and -lightweight resolver packet *pkt*pkt both functions return - + + lwres_resutil

lwres_resutil

lwres_resutil
Synopsis

#include <lwres/lwres.h>

DESCRIPTION

lwres_string_parse()lwres_string_parse() retrieves a DNS-encoded string starting the current pointer of lightweight resolver buffer -b: i.e. b: i.e. b->currentb->current. When the function returns, the address of the first byte of the -encoded string is returned via *c*c and the -length of that string is given by *len*len. The buffer's current pointer is advanced to point at the character following the string length, the encoded string, and the trailing @@ -140,45 +134,43 @@ CLASS="TYPE" >NULL character.

lwres_addr_parse()lwres_addr_parse() extracts an address from the -buffer bb. The buffer's current pointer -b->currentb->current is presumed to point at an encoded address: the address preceded by a 32-bit protocol family identifier and a 16-bit length field. The encoded address is copied to -addr->addressaddr->address and -addr->lengthaddr->length indicates the size in bytes of -the address that was copied. b->currentb->current is advanced to point at the next byte of available data in the buffer following the encoded address.

lwres_getaddrsbyname()lwres_getaddrsbyname() and -lwres_getnamebyaddr()lwres_getnamebyaddr() use the

The lightweight resolver uses -lwres_getaddrsbyname()lwres_getaddrsbyname() to perform foward lookups. -Hostname namename is looked up using the resolver -context ctxctx for memory allocation. -addrtypesaddrtypes is a bitmask indicating which type of addresses are to be looked up. Current values for this bitmask are LWRES_ADDRTYPE_V6 for IPv6 addresses. Results of the -lookup are returned in *structp*structp.

lwres_getnamebyaddr()lwres_getnamebyaddr() performs reverse lookups. -Resolver context ctxctx is used for memory allocation. The address type is indicated by -addrtypeaddrtype: LWRES_ADDRTYPE_V4LWRES_ADDRTYPE_V6. The address to be looked up is given -by addraddr and its length is -addrlenaddrlen bytes. The result of the function call -is made available through *structp*structp.

RETURN VALUES

Successful calls to -lwres_string_parse()lwres_string_parse() and -lwres_addr_parse()lwres_addr_parse() return

lwres_getaddrsbyname()lwres_getaddrsbyname() returns LWRES_R_NOTFOUND if the hostname -namename could not be found.

LWRES_R_SUCCESS is returned by a successful call to -lwres_getnamebyaddr()lwres_getnamebyaddr().

Both -lwres_getaddrsbyname()lwres_getaddrsbyname() and -lwres_getnamebyaddr()lwres_getnamebyaddr() return + +#include +#include /* for sprintf */ + +#define LWRES__PRINT_SOURCE /* Used to get the lwres_print_* prototypes. */ + +#include + +#include "assert_p.h" +#include "print_p.h" + +int +lwres__print_sprintf(char *str, const char *format, ...) { + va_list ap; + + va_start(ap, format); + vsprintf(str, format, ap); + va_end(ap); + return (strlen(str)); +} + +/* + * Return length of string that would have been written if not truncated. + */ + +int +lwres__print_snprintf(char *str, size_t size, const char *format, ...) { + va_list ap; + int ret; + + va_start(ap, format); + ret = vsnprintf(str, size, format, ap); + va_end(ap); + return (ret); + +} + +/* + * Return length of string that would have been written if not truncated. + */ + +int +lwres__print_vsnprintf(char *str, size_t size, const char *format, va_list ap) { + int h; + int l; + int q; + int alt; + int zero; + int left; + int plus; + int space; + int neg; + long long tmpi; + unsigned long long tmpui; + unsigned long width; + unsigned long precision; + unsigned int length; + char buf[1024]; + char c; + void *v; + char *save = str; + const char *cp; + const char *head; + int count = 0; + int pad; + int zeropad; + int dot; + double dbl; +#ifdef HAVE_LONG_DOUBLE + long double ldbl; +#endif + char fmt[32]; + + INSIST(str != NULL); + INSIST(format != NULL); + + while (*format != '\0') { + if (*format != '%') { + if (size > 1) { + *str++ = *format; + size--; + } + count++; + format++; + continue; + } + format++; + + /* + * Reset flags. + */ + dot = neg = space = plus = left = zero = alt = h = l = q = 0; + width = precision = 0; + head = ""; + length = pad = zeropad = 0; + + do { + if (*format == '#') { + alt = 1; + format++; + } else if (*format == '-') { + left = 1; + zero = 0; + format++; + } else if (*format == ' ') { + if (!plus) + space = 1; + format++; + } else if (*format == '+') { + plus = 1; + space = 0; + format++; + } else if (*format == '0') { + if (!left) + zero = 1; + format++; + } else + break; + } while (1); + + /* + * Width. + */ + if (*format == '*') { + width = va_arg(ap, int); + format++; + } else if (isdigit((unsigned char)*format)) { + char *e; + width = strtoul(format, &e, 10); + format = e; + } + + /* + * Precision. + */ + if (*format == '.') { + format++; + dot = 1; + if (*format == '*') { + precision = va_arg(ap, int); + format++; + } else if (isdigit((unsigned char)*format)) { + char *e; + precision = strtoul(format, &e, 10); + format = e; + } + } + + switch (*format) { + case '\0': + continue; + case '%': + if (size > 1) { + *str++ = *format; + size--; + } + count++; + break; + case 'q': + q = 1; + format++; + goto doint; + case 'h': + h = 1; + format++; + goto doint; + case 'l': + l = 1; + format++; + if (*format == 'l') { + q = 1; + format++; + } + goto doint; + case 'n': + case 'i': + case 'd': + case 'o': + case 'u': + case 'x': + case 'X': + doint: + if (precision != 0) + zero = 0; + switch (*format) { + case 'n': + if (h) { + short int *p; + p = va_arg(ap, short *); + REQUIRE(p != NULL); + *p = str - save; + } else if (l) { + long int *p; + p = va_arg(ap, long *); + REQUIRE(p != NULL); + *p = str - save; + } else { + int *p; + p = va_arg(ap, int *); + REQUIRE(p != NULL); + *p = str - save; + } + break; + case 'i': + case 'd': + if (q) + tmpi = va_arg(ap, long long int); + else if (l) + tmpi = va_arg(ap, long int); + else + tmpi = va_arg(ap, int); + if (tmpi < 0) { + head = "-"; + tmpui = -tmpi; + } else { + if (plus) + head = "+"; + else if (space) + head = " "; + else + head = ""; + tmpui = tmpi; + } + sprintf(buf, "%llu", + tmpui); + goto printint; + case 'o': + if (q) + tmpui = va_arg(ap, + unsigned long long int); + else if (l) + tmpui = va_arg(ap, long int); + else + tmpui = va_arg(ap, int); + sprintf(buf, + alt ? "%#llo" : "%llo", tmpui); + goto printint; + case 'u': + if (q) + tmpui = va_arg(ap, + unsigned long long int); + else if (l) + tmpui = va_arg(ap, unsigned long int); + else + tmpui = va_arg(ap, unsigned int); + sprintf(buf, "%llu", tmpui); + goto printint; + case 'x': + if (q) + tmpui = va_arg(ap, + unsigned long long int); + else if (l) + tmpui = va_arg(ap, unsigned long int); + else + tmpui = va_arg(ap, unsigned int); + if (alt) { + head = "0x"; + if (precision > 2) + precision -= 2; + } + sprintf(buf, "%llx", tmpui); + goto printint; + case 'X': + if (q) + tmpui = va_arg(ap, + unsigned long long int); + else if (l) + tmpui = va_arg(ap, unsigned long int); + else + tmpui = va_arg(ap, unsigned int); + if (alt) { + head = "0X"; + if (precision > 2) + precision -= 2; + } + sprintf(buf, "%llX", tmpui); + goto printint; + printint: + if (precision != 0 || width != 0) { + length = strlen(buf); + if (length < precision) + zeropad = precision - length; + else if (length < width && zero) + zeropad = width - length; + if (width != 0) { + pad = width - length - + zeropad - strlen(head); + if (pad < 0) + pad = 0; + } + } + count += strlen(head) + strlen(buf) + pad + + zeropad; + if (!left) { + while (pad > 0 && size > 1) { + *str++ = ' '; + size--; + pad--; + } + } + cp = head; + while (*cp != '\0' && size > 1) { + *str++ = *cp++; + size--; + } + while (zeropad > 0 && size > 1) { + *str++ = '0'; + size--; + zeropad--; + } + cp = buf; + while (*cp != '\0' && size > 1) { + *str++ = *cp++; + size--; + } + while (pad > 0 && size > 1) { + *str++ = ' '; + size--; + pad--; + } + break; + default: + break; + } + break; + case 's': + cp = va_arg(ap, char *); + REQUIRE(cp != NULL); + + if (precision != 0) { + /* + * cp need not be NULL terminated. + */ + const char *tp; + unsigned long n; + + n = precision; + tp = cp; + while (n != 0 && *tp != '\0') + n--, tp++; + length = precision - n; + } else { + length = strlen(cp); + } + if (width != 0) { + pad = width - length; + if (pad < 0) + pad = 0; + } + count += pad + length; + if (!left) + while (pad > 0 && size > 1) { + *str++ = ' '; + size--; + pad--; + } + if (precision != 0) + while (precision > 0 && *cp != '\0' && + size > 1) { + *str++ = *cp++; + size--; + precision--; + } + else + while (*cp != '\0' && size > 1) { + *str++ = *cp++; + size--; + } + while (pad > 0 && size > 1) { + *str++ = ' '; + size--; + pad--; + } + break; + case 'c': + c = va_arg(ap, int); + if (width > 0) { + count += width; + width--; + if (left) { + *str++ = c; + size--; + } + while (width-- > 0 && size > 1) { + *str++ = ' '; + size--; + } + if (!left && size > 1) { + *str++ = c; + size--; + } + } else { + count++; + if (size > 1) { + *str++ = c; + size--; + } + } + break; + case 'p': + v = va_arg(ap, void *); + sprintf(buf, "%p", v); + length = strlen(buf); + if (precision > length) + zeropad = precision - length; + if (width > 0) { + pad = width - length - zeropad; + if (pad < 0) + pad = 0; + } + count += length + pad + zeropad; + if (!left) + while (pad > 0 && size > 1) { + *str++ = ' '; + size--; + pad--; + } + cp = buf; + if (zeropad > 0 && buf[0] == '0' && + (buf[1] == 'x' || buf[1] == 'X')) { + if (size > 1) { + *str++ = *cp++; + size--; + } + if (size > 1) { + *str++ = *cp++; + size--; + } + while (zeropad > 0 && size > 1) { + *str++ = '0'; + size--; + zeropad--; + } + } + while (*cp != '\0' && size > 1) { + *str++ = *cp++; + size--; + } + while (pad > 0 && size > 1) { + *str++ = ' '; + size--; + pad--; + } + break; + case 'D': /*deprecated*/ + INSIST("use %ld instead of %D" == NULL); + case 'O': /*deprecated*/ + INSIST("use %lo instead of %O" == NULL); + case 'U': /*deprecated*/ + INSIST("use %lu instead of %U" == NULL); + + case 'L': +#ifdef HAVE_LONG_DOUBLE + l = 1; +#else + INSIST("long doubles are not supported" == NULL); +#endif + /*FALLTHROUGH*/ + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + if (!dot) + precision = 6; + /* + * IEEE floating point. + * MIN 2.2250738585072014E-308 + * MAX 1.7976931348623157E+308 + * VAX floating point has a smaller range than IEEE. + * + * precisions > 324 don't make much sense. + * if we cap the precision at 512 we will not + * overflow buf. + */ + if (precision > 512) + precision = 512; + sprintf(fmt, "%%%s%s.%lu%s%c", alt ? "#" : "", + plus ? "+" : space ? " " : "", + precision, l ? "L" : "", *format); + switch (*format) { + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': +#ifdef HAVE_LONG_DOUBLE + if (l) { + ldbl = va_arg(ap, long double); + sprintf(buf, fmt, ldbl); + } else +#endif + { + dbl = va_arg(ap, double); + sprintf(buf, fmt, dbl); + } + length = strlen(buf); + if (width > 0) { + pad = width - length; + if (pad < 0) + pad = 0; + } + count += length + pad; + if (!left) + while (pad > 0 && size > 1) { + *str++ = ' '; + size--; + pad--; + } + cp = buf; + while (*cp != ' ' && size > 1) { + *str++ = *cp++; + size--; + } + while (pad > 0 && size > 1) { + *str++ = ' '; + size--; + pad--; + } + break; + default: + continue; + } + break; + default: + continue; + } + format++; + } + if (size > 0) + *str = '\0'; + return (count); +} diff --git a/dist/bind/lib/lwres/print_p.h b/dist/bind/lib/lwres/print_p.h new file mode 100644 index 00000000000..d43b72034e6 --- /dev/null +++ b/dist/bind/lib/lwres/print_p.h @@ -0,0 +1,88 @@ +/* $NetBSD: print_p.h,v 1.1.1.1 2004/11/06 23:56:01 christos Exp $ */ + +/* + * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 1999-2001, 2003 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, + * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* Id: print_p.h,v 1.2.4.1 2004/08/28 06:25:25 marka Exp */ + +#ifndef LWRES_PRINT_P_H +#define LWRES_PRINT_P_H 1 + +/*** + *** Imports + ***/ + +#include +#include + +/* + * This block allows lib/lwres/print.c to be cleanly compiled even if + * the platform does not need it. The standard Makefile will still + * not compile print.c or archive print.o, so this is just to make test + * compilation ("make print.o") easier. + */ +#if !defined(LWRES_PLATFORM_NEEDVSNPRINTF) && defined(LWRES__PRINT_SOURCE) +#define LWRES_PLATFORM_NEEDVSNPRINTF +#endif + +#if !defined(LWRES_PLATFORM_NEEDSPRINTF) && defined(LWRES__PRINT_SOURCE) +#define LWRES_PLATFORM_NEEDSPRINTF +#endif + +/*** + *** Macros. + ***/ + +#ifdef __GNUC__ +#define LWRES_FORMAT_PRINTF(fmt, args) \ + __attribute__((__format__(__printf__, fmt, args))) +#else +#define LWRES_FORMAT_PRINTF(fmt, args) +#endif + +/*** + *** Functions + ***/ + +#ifdef LWRES_PLATFORM_NEEDVSNPRINTF +#include +#include +#endif + +LWRES_LANG_BEGINDECLS + +#ifdef LWRES_PLATFORM_NEEDVSNPRINTF +int +lwres__print_vsnprintf(char *str, size_t size, const char *format, va_list ap) + LWRES_FORMAT_PRINTF(3, 0); +#define vsnprintf lwres__print_vsnprintf + +int +lwres__print_snprintf(char *str, size_t size, const char *format, ...) + LWRES_FORMAT_PRINTF(3, 4); +#define snprintf lwres__print_snprintf +#endif /* LWRES_PLATFORM_NEEDVSNPRINTF */ + +#ifdef LWRES_PLATFORM_NEEDSPRINTF +int +lwres__print_sprintf(char *str, const char *format, ...) LWRES_FORMAT_PRINTF(2, 3); +#define sprintf lwres__print_sprintf +#endif + +LWRES_LANG_ENDDECLS + +#endif /* LWRES_PRINT_P_H */ diff --git a/dist/bind/lib/tests/Makefile.in b/dist/bind/lib/tests/Makefile.in index e8d8b96824f..0a17d0e77e5 100644 --- a/dist/bind/lib/tests/Makefile.in +++ b/dist/bind/lib/tests/Makefile.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# Id: Makefile.in,v 1.14.12.6 2004/03/06 08:15:46 marka Exp +# Id: Makefile.in,v 1.14.12.7 2004/07/20 07:01:59 marka Exp srcdir = @srcdir@ VPATH = @srcdir@ @@ -46,7 +46,7 @@ libt_api.@SA@: ${OBJS} libt_api.la: ${OBJS} ${LIBTOOL_MODE_LINK} \ - ${CC} ${ALL_CFLAGS} -o libt_api.la -rpath ${libdir} \ + ${CC} ${ALL_CFLAGS} ${LDFLAGS} -o libt_api.la -rpath ${libdir} \ ${OBJS} ${ISCLIBS} ${LIBS} -allow-undefined timestamp: libt_api.@A@ diff --git a/dist/bind/lib/tests/include/tests/t_api.h b/dist/bind/lib/tests/include/tests/t_api.h index d6c28352266..7b8f1004703 100644 --- a/dist/bind/lib/tests/include/tests/t_api.h +++ b/dist/bind/lib/tests/include/tests/t_api.h @@ -1,4 +1,4 @@ -/* $NetBSD: t_api.h,v 1.1.1.1 2004/05/17 23:45:12 christos Exp $ */ +/* $NetBSD: t_api.h,v 1.1.1.2 2004/11/06 23:56:02 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: t_api.h,v 1.14.206.1 2004/03/06 08:15:47 marka Exp */ +/* Id: t_api.h,v 1.14.206.2 2004/06/21 06:58:02 marka Exp */ #ifndef TESTS_T_API_H #define TESTS_T_API_H 1 @@ -39,6 +39,7 @@ #define T_UNRESOLVED 0x3 #define T_UNSUPPORTED 0x4 #define T_UNTESTED 0x5 +#define T_THREADONLY 0x6 /* * diff --git a/dist/bind/lib/tests/t_api.c b/dist/bind/lib/tests/t_api.c index 1401f655cd5..ac1ff43933d 100644 --- a/dist/bind/lib/tests/t_api.c +++ b/dist/bind/lib/tests/t_api.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_api.c,v 1.1.1.1 2004/05/17 23:45:12 christos Exp $ */ +/* $NetBSD: t_api.c,v 1.1.1.2 2004/11/06 23:56:02 christos Exp $ */ /* * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") @@ -17,7 +17,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* Id: t_api.c,v 1.48.2.1.2.4 2004/03/08 09:05:13 marka Exp */ +/* Id: t_api.c,v 1.48.2.1.2.6 2004/08/28 06:25:27 marka Exp */ #include @@ -35,6 +35,7 @@ #include #include +#include #include #include @@ -392,6 +393,9 @@ t_result(int result) { case T_UNTESTED: p = "UNTESTED"; break; + case T_THREADONLY: + p = "THREADONLY"; + break; default: p = "UNKNOWN"; break; -- cgit