Compare commits

...

1 Commits

Author SHA1 Message Date
cvs2git
c04a3d879c This commit was manufactured by cvs2git to create tag 'v9_0_0a2'. 1999-09-08 18:25:35 +00:00
864 changed files with 0 additions and 236556 deletions

View File

@@ -1,6 +0,0 @@
Makefile
config.log
config.h
config.cache
config.status
libtool

View File

@@ -1,50 +0,0 @@
# Copyright (C) 1998, 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM 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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
@BIND9_VERSION@
SUBDIRS = make lib bin
TARGETS =
DISTFILES = Makefile.in README \
acconfig.h aclocal.m4 config.h.in configure.in \
config.sub config.guess install-sh configure \
ltconfig ltmain.sh \
bin lib make \
version
@BIND9_MAKE_RULES@
distclean::
rm -f config.cache config.h config.log config.status libtool TAGS
cleandir: distclean
kit: kitclean
mkdir bind-${VERSION}
@(cd bind-${VERSION}; for i in ${DISTFILES}; do ln -s ../$$i $$i; done)
gtar -c -v -z -h --exclude '*CVS*' -f bind-${VERSION}.tar.gz \
bind-${VERSION}
rm -rf bind-${VERSION}
kitclean: distclean
rm -rf bind-${VERSION}
tags:
rm -f TAGS
find lib bin -name "*.[ch]" -print | etags -

78
README
View File

@@ -1,78 +0,0 @@
Code Drop 3 Status Update
Work since the last code drop has focused on both the libraries and
the server. Some of the highlights are:
Libraries
IPv6 sockets.
DNSSEC security core, TSIG.
Shared libraries can now be generated.
Internationalization message catalog support. (Much of the
code has yet to be converted to use catalogs.)
Server
Most of the temporary code in the server has been replaced
with the real thing. One exception is config file processing,
which has not yet been integrated.
Basic AXFR, IXFR, and dynamic update support.
The server now listens on IPv6 sockets, if the system
supports them.
The IPv6 reverse lookup scheme (bitstring labels and DNAME)
is supported by the server. A6 chain following remains
to be implemented.
DNSSEC NXT records are returned in negative responses
for secure zones.
Resolver
The skeleton of the resolver is in the kit. This
shows how the resolver is going to work, but the
resolver is not yet functional. This will be the
prime focus of work in the near future.
Building
We've had successful builds and tests on the following systems
BSDI 3.1
Digital UNIX 4.0D
HP-UX 11
NetBSD
Red Hat Linux 6.0
SGI IRIX 6.5
Solaris 2.6
To build, just
./configure
make
Do not run 'make install'. Shared libraries will be built if "--with-libtool"
is added to the "configure" command.
Building with gcc is not supported, unless gcc is the vendor's usual
compiler (e.g. the various BSD systems, Linux).
bin/named Note
The configuration code in bin/named does not represent the final
architecture. The config file processing code in lib/dns/config will be
used by the server in the future. The server is still running on port
5544.
API Note
All APIs are subject to change in future code drops. We expect the
existing library interfaces in the code drop to be quite stable,
however, and unless we've specifically indicated that an interface is
temporary, we don't expect significant changes in future releases.

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
/* define on DEC OSF to enable 4.4BSD style sa_len support */
#undef _SOCKADDR_LEN
/* define if your system needs pthread_init() before using pthreads */
#undef NEED_PTHREAD_INIT
/* define if your system has sigwait() */
#undef HAVE_SIGWAIT
/* define on Solaris to get sigwait() to work using pthreads semantics */
#undef _POSIX_PTHREAD_SEMANTICS
/* define if LinuxThreads is in use */
#undef HAVE_LINUXTHREADS
/* define if catgets() is available */
#undef HAVE_CATGETS
/* define if you have the NET_RT_IFLIST sysctl variable. */
#undef HAVE_IFLIST_SYSCTL
/* define if you need to #define _XPG4_2 before including sys/socket.h */
#undef NEED_XPG4_2_BEFORE_SOCKET_H
/* define if you need to #define _XOPEN_SOURCE_ENTENDED before including
* sys/socket.h
*/
#undef NEED_XSE_BEFORE_SOCKET_H

427
aclocal.m4 vendored
View File

@@ -1,427 +0,0 @@
## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
## Copyright (C) 1996-1999 Free Software Foundation, Inc.
## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
## As a special exception to the GNU General Public License, if you
## distribute this file as part of a program that contains a
## configuration script generated by Autoconf, you may include it under
## the same distribution terms that you use for the rest of that program.
# serial 40 AC_PROG_LIBTOOL
AC_DEFUN(AC_PROG_LIBTOOL,
[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
# Save cache, so that ltconfig can load it
AC_CACHE_SAVE
# Actually configure libtool. ac_aux_dir is where install-sh is found.
CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
|| AC_MSG_ERROR([libtool configure failed])
# Reload cache, that may have been modified by ltconfig
AC_CACHE_LOAD
# This can be used to rebuild libtool when needed
LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
# Always use our own libtool.
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
AC_SUBST(LIBTOOL)dnl
# Redirect the config.log output again, so that the ltconfig log is not
# clobbered by the next message.
exec 5>>./config.log
])
AC_DEFUN(AC_LIBTOOL_SETUP,
[AC_PREREQ(2.13)dnl
AC_REQUIRE([AC_ENABLE_SHARED])dnl
AC_REQUIRE([AC_ENABLE_STATIC])dnl
AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
AC_REQUIRE([AC_PROG_RANLIB])dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_LD])dnl
AC_REQUIRE([AC_PROG_NM])dnl
AC_REQUIRE([AC_PROG_LN_S])dnl
dnl
# Check for any special flags to pass to ltconfig.
libtool_flags="--cache-file=$cache_file"
test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
[libtool_flags="$libtool_flags --enable-dlopen"])
ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
[libtool_flags="$libtool_flags --enable-win32-dll"])
AC_ARG_ENABLE(libtool-lock,
[ --disable-libtool-lock avoid locking (might break parallel builds)])
test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
# Some flags need to be propagated to the compiler or linker for good
# libtool support.
case "$host" in
*-*-irix6*)
# Find out which ABI we are using.
echo '[#]line __oline__ "configure"' > conftest.$ac_ext
if AC_TRY_EVAL(ac_compile); then
case "`/usr/bin/file conftest.o`" in
*32-bit*)
LD="${LD-ld} -32"
;;
*N32*)
LD="${LD-ld} -n32"
;;
*64-bit*)
LD="${LD-ld} -64"
;;
esac
fi
rm -rf conftest*
;;
*-*-sco3.2v5*)
# On SCO OpenServer 5, we need -belf to get full-featured binaries.
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -belf"
AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
[AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
if test x"$lt_cv_cc_needs_belf" != x"yes"; then
# this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
CFLAGS="$SAVE_CFLAGS"
fi
;;
ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
[*-*-cygwin* | *-*-mingw*)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
;;
])
esac
])
# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
# AC_ENABLE_SHARED - implement the --enable-shared flag
# Usage: AC_ENABLE_SHARED[(DEFAULT)]
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
# `yes'.
AC_DEFUN(AC_ENABLE_SHARED, [dnl
define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
AC_ARG_ENABLE(shared,
changequote(<<, >>)dnl
<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
changequote([, ])dnl
[p=${PACKAGE-default}
case "$enableval" in
yes) enable_shared=yes ;;
no) enable_shared=no ;;
*)
enable_shared=no
# Look at the argument we got. We use all the common list separators.
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
for pkg in $enableval; do
if test "X$pkg" = "X$p"; then
enable_shared=yes
fi
done
IFS="$ac_save_ifs"
;;
esac],
enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
])
# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_ENABLE_SHARED(no)])
# AC_ENABLE_STATIC - implement the --enable-static flag
# Usage: AC_ENABLE_STATIC[(DEFAULT)]
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
# `yes'.
AC_DEFUN(AC_ENABLE_STATIC, [dnl
define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
AC_ARG_ENABLE(static,
changequote(<<, >>)dnl
<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
changequote([, ])dnl
[p=${PACKAGE-default}
case "$enableval" in
yes) enable_static=yes ;;
no) enable_static=no ;;
*)
enable_static=no
# Look at the argument we got. We use all the common list separators.
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
for pkg in $enableval; do
if test "X$pkg" = "X$p"; then
enable_static=yes
fi
done
IFS="$ac_save_ifs"
;;
esac],
enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
])
# AC_DISABLE_STATIC - set the default static flag to --disable-static
AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_ENABLE_STATIC(no)])
# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to
# `yes'.
AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
AC_ARG_ENABLE(fast-install,
changequote(<<, >>)dnl
<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
changequote([, ])dnl
[p=${PACKAGE-default}
case "$enableval" in
yes) enable_fast_install=yes ;;
no) enable_fast_install=no ;;
*)
enable_fast_install=no
# Look at the argument we got. We use all the common list separators.
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
for pkg in $enableval; do
if test "X$pkg" = "X$p"; then
enable_fast_install=yes
fi
done
IFS="$ac_save_ifs"
;;
esac],
enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
])
# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_ENABLE_FAST_INSTALL(no)])
# AC_PROG_LD - find the path to the GNU or non-GNU linker
AC_DEFUN(AC_PROG_LD,
[AC_ARG_WITH(gnu-ld,
[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
AC_REQUIRE([AC_CANONICAL_BUILD])dnl
ac_prog=ld
if test "$ac_cv_prog_gcc" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by GCC])
ac_prog=`($CC -print-prog-name=ld) 2>&5`
case "$ac_prog" in
# Accept absolute paths.
changequote(,)dnl
[\\/]* | [A-Za-z]:[\\/]*)
re_direlt='/[^/][^/]*/\.\./'
changequote([,])dnl
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(ac_cv_path_LD,
[if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH; do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
ac_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
test "$with_gnu_ld" != no && break
else
test "$with_gnu_ld" != yes && break
fi
fi
done
IFS="$ac_save_ifs"
else
ac_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$ac_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
AC_SUBST(LD)
AC_PROG_LD_GNU
])
AC_DEFUN(AC_PROG_LD_GNU,
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
ac_cv_prog_gnu_ld=yes
else
ac_cv_prog_gnu_ld=no
fi])
])
# AC_PROG_NM - find the path to a BSD-compatible name lister
AC_DEFUN(AC_PROG_NM,
[AC_MSG_CHECKING([for BSD-compatible nm])
AC_CACHE_VAL(ac_cv_path_NM,
[if test -n "$NM"; then
# Let the user override the test.
ac_cv_path_NM="$NM"
else
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
test -z "$ac_dir" && ac_dir=.
if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
# Check to see if the nm accepts a BSD-compat flag.
# Adding the `sed 1q' prevents false positives on HP-UX, which says:
# nm: unknown option "B" ignored
if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
ac_cv_path_NM="$ac_dir/nm -B"
break
elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
ac_cv_path_NM="$ac_dir/nm -p"
break
else
ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
continue # so that we can try to find one that supports BSD flags
fi
fi
done
IFS="$ac_save_ifs"
test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
fi])
NM="$ac_cv_path_NM"
AC_MSG_RESULT([$NM])
AC_SUBST(NM)
])
# AC_CHECK_LIBM - check for math library
AC_DEFUN(AC_CHECK_LIBM,
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
LIBM=
case "$host" in
*-*-beos* | *-*-cygwin*)
# These system don't have libm
;;
*-ncr-sysv4.3*)
AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
;;
*)
AC_CHECK_LIB(m, main, LIBM="-lm")
;;
esac
])
# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
# the libltdl convenience library, adds --enable-ltdl-convenience to
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
# to be `${top_builddir}/libltdl'. Make sure you start DIR with
# '${top_builddir}/' (note the single quotes!) if your package is not
# flat, and, if you're not using automake, define top_builddir as
# appropriate in the Makefiles.
AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
case "$enable_ltdl_convenience" in
no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
"") enable_ltdl_convenience=yes
ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
esac
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
])
# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
# the libltdl installable library, and adds --enable-ltdl-install to
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
# to be `${top_builddir}/libltdl'. Make sure you start DIR with
# '${top_builddir}/' (note the single quotes!) if your package is not
# flat, and, if you're not using automake, define top_builddir as
# appropriate in the Makefiles.
# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_CHECK_LIB(ltdl, main,
[test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
[if test x"$enable_ltdl_install" = xno; then
AC_MSG_WARN([libltdl not installed, but installation disabled])
else
enable_ltdl_install=yes
fi
])
if test x"$enable_ltdl_install" = x"yes"; then
ac_configure_args="$ac_configure_args --enable-ltdl-install"
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
else
ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
LIBLTDL="-lltdl"
INCLTDL=
fi
])
dnl old names
AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
dnl This is just to silence aclocal about the macro not being used
ifelse([AC_DISABLE_FAST_INSTALL])dnl

View File

@@ -1 +0,0 @@
Makefile

View File

@@ -1,23 +0,0 @@
# Copyright (C) 1998, 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM 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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
SUBDIRS = named tests
TARGETS =
@BIND9_MAKE_RULES@

View File

@@ -1,452 +0,0 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <isc/types.h>
#include <isc/assertions.h>
#include <isc/buffer.h>
#include <isc/error.h>
#include <isc/mem.h>
#include <isc/stdtime.h>
#include <dns/types.h>
#include <dns/name.h>
#include <dns/fixedname.h>
#include <dns/db.h>
#include <dns/dbiterator.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/result.h>
#include <dns/dnssec.h>
#include <dns/keyvalues.h>
#include <dst/dst.h>
#define MAXKEYS 10
#define is_zone_key(key) ((dst_key_flags(key) & DNS_KEYFLAG_OWNERMASK) \
== DNS_KEYOWNER_ZONE)
static isc_mem_t *mctx = NULL;
static inline void
fatal(char *message) {
fprintf(stderr, "%s\n", message);
exit(1);
}
static inline void
check_result(isc_result_t result, char *message) {
if (result != ISC_R_SUCCESS) {
fprintf(stderr, "%s: %s\n", message,
isc_result_totext(result));
exit(1);
}
}
static void
set_bit(unsigned char *array, unsigned int index, unsigned int bit) {
unsigned int byte, shift, mask;
byte = array[index / 8];
shift = 7 - (index % 8);
mask = 1 << shift;
if (bit)
array[index / 8] |= mask;
else
array[index / 8] &= (~mask & 0xFF);
}
/*
* XXXRTH Something like this will become a library function.
*/
static void
build_nxt(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
dns_name_t *target)
{
isc_result_t result;
dns_rdata_t rdata;
dns_rdataset_t rdataset;
dns_rdatalist_t rdatalist;
isc_region_t r;
unsigned char data[256 + 16];
unsigned char *nxt_bits;
unsigned int max_type;
dns_rdatasetiter_t *rdsiter;
memset(data, 0, sizeof data);
dns_name_toregion(target, &r);
memcpy(data, r.base, r.length);
r.base = data;
nxt_bits = r.base + r.length;
set_bit(nxt_bits, dns_rdatatype_nxt, 1);
max_type = dns_rdatatype_nxt;
dns_rdataset_init(&rdataset);
rdsiter = NULL;
result = dns_db_allrdatasets(db, node, version, 0, &rdsiter);
check_result(result, "dns_db_allrdatasets()");
result = dns_rdatasetiter_first(rdsiter);
while (result == ISC_R_SUCCESS) {
dns_rdatasetiter_current(rdsiter, &rdataset);
if (rdataset.type > 127)
fatal("rdataset type too large");
if (rdataset.type != dns_rdatatype_nxt) {
if (rdataset.type > max_type)
max_type = rdataset.type;
set_bit(nxt_bits, rdataset.type, 1);
}
dns_rdataset_disassociate(&rdataset);
result = dns_rdatasetiter_next(rdsiter);
}
if (result != DNS_R_NOMORE)
fatal("rdataset iteration failed");
dns_rdatasetiter_destroy(&rdsiter);
dns_rdata_init(&rdata);
r.length += (max_type / 8);
if (max_type % 8 != 0)
r.length++;
dns_rdata_fromregion(&rdata, dns_rdataclass_in,
dns_rdatatype_nxt,
&r);
rdatalist.rdclass = dns_rdataclass_in;
rdatalist.type = dns_rdatatype_nxt;
rdatalist.covers = 0;
rdatalist.ttl = 3600; /* XXXRTH */
ISC_LIST_INIT(rdatalist.rdata);
ISC_LIST_APPEND(rdatalist.rdata, &rdata, link);
result = dns_rdatalist_tordataset(&rdatalist, &rdataset);
check_result(result, "dns_rdatalist_tordataset");
result = dns_db_addrdataset(db, node, version, 0, &rdataset,
ISC_FALSE, NULL);
if (result == DNS_R_UNCHANGED)
result = ISC_R_SUCCESS;
check_result(result, "dns_db_addrdataset");
dns_rdataset_disassociate(&rdataset);
}
static void
generate_sig(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node,
dns_name_t *name, dst_key_t **keys, int nkeys)
{
isc_result_t result;
dns_rdata_t rdata, rdatas[MAXKEYS];
dns_rdataset_t rdataset, sigrdataset;
dns_rdatalist_t sigrdatalist;
isc_region_t data[MAXKEYS];
dns_rdatasetiter_t *rdsiter;
isc_buffer_t buffer;
isc_stdtime_t now, later;
unsigned char array[MAXKEYS][1024];
int i;
dns_rdataset_init(&rdataset);
rdsiter = NULL;
result = dns_db_allrdatasets(db, node, version, 0, &rdsiter);
check_result(result, "dns_db_allrdatasets()");
result = dns_rdatasetiter_first(rdsiter);
while (result == ISC_R_SUCCESS) {
dns_rdatasetiter_current(rdsiter, &rdataset);
if (rdataset.type > 127)
fatal("rdataset type too large");
if (rdataset.type == dns_rdatatype_sig ||
(rdataset.type == dns_rdatatype_key &&
dns_name_compare(name, dns_db_origin(db)) == 0))
{
dns_rdataset_disassociate(&rdataset);
result = dns_rdatasetiter_next(rdsiter);
continue;
}
if (rdataset.type == dns_rdatatype_nxt) {
unsigned char *nxt_bits;
dns_name_t nxtname;
isc_region_t r, r2;
result = dns_rdataset_first(&rdataset);
check_result(result, "dns_rdataset_first()");
dns_rdataset_current(&rdataset, &rdata);
dns_rdata_toregion(&rdata, &r);
dns_name_init(&nxtname, NULL);
dns_name_fromregion(&nxtname, &r);
dns_name_toregion(&nxtname, &r2);
nxt_bits = r.base + r2.length;
set_bit(nxt_bits, dns_rdatatype_sig, 1);
}
isc_stdtime_get(&now);
later = 100000 + now;
ISC_LIST_INIT(sigrdatalist.rdata);
for (i = 0; i < nkeys; i++) {
data[i].base = array[i];
data[i].length = sizeof(array[i]);
memset(data[i].base, 0, data[i].length);
dns_rdata_init(&rdatas[i]);
isc_buffer_init(&buffer, data[i].base, data[i].length,
ISC_BUFFERTYPE_BINARY);
result = dns_dnssec_sign(name, &rdataset, keys[i],
&now, &later,
mctx, &buffer, &rdatas[i]);
check_result(result, "dns_dnssec_sign()");
result = dns_dnssec_verify(name, &rdataset, keys[i],
mctx, &rdatas[i]);
check_result(result, "dns_dnssec_verify()");
ISC_LIST_APPEND(sigrdatalist.rdata, &rdatas[i], link);
}
sigrdatalist.rdclass = rdataset.rdclass;
sigrdatalist.type = dns_rdatatype_sig;
sigrdatalist.covers = rdataset.type;
sigrdatalist.ttl = rdataset.ttl;
dns_rdataset_init(&sigrdataset);
result = dns_rdatalist_tordataset(&sigrdatalist, &sigrdataset);
check_result(result, "dns_rdatalist_tordataset");
result = dns_db_addrdataset(db, node, version, 0, &sigrdataset,
ISC_FALSE, NULL);
if (result == DNS_R_UNCHANGED)
result = ISC_R_SUCCESS;
check_result(result, "dns_db_addrdataset");
dns_rdataset_disassociate(&sigrdataset);
dns_rdataset_disassociate(&rdataset);
result = dns_rdatasetiter_next(rdsiter);
}
if (result != DNS_R_NOMORE)
fatal("rdataset iteration failed");
dns_rdatasetiter_destroy(&rdsiter);
}
static void
find_keys(dns_db_t *db, dns_dbnode_t *node, dns_name_t *name,
dst_key_t **keys, int *nkeys)
{
dns_rdataset_t rdataset;
dns_rdata_t rdata;
isc_result_t result;
dst_key_t *pubkey;
int count = 0;
*nkeys = 0;
dns_rdataset_init(&rdataset);
result = dns_db_findrdataset(db, node, NULL, dns_rdatatype_key, 0, 0,
&rdataset, NULL);
check_result(result, "dns_db_findrdataset()");
result = dns_rdataset_first(&rdataset);
check_result(result, "dns_rdataset_first()");
while (result == ISC_R_SUCCESS && count < MAXKEYS) {
pubkey = NULL;
dns_rdataset_current(&rdataset, &rdata);
result = dns_dnssec_keyfromrdata(name, &rdata, mctx, &pubkey);
check_result(result, "dns_dnssec_keyfromrdata()");
if (!is_zone_key(pubkey)) {
dst_key_free(pubkey);
continue;
}
result = dst_key_fromfile(dst_key_name(pubkey),
dst_key_id(pubkey),
dst_key_alg(pubkey),
DST_TYPE_PRIVATE,
mctx, &keys[count++]);
check_result(result, "dst_key_fromfile()");
dst_key_free(pubkey);
result = dns_rdataset_next(&rdataset);
}
dns_rdataset_disassociate(&rdataset);
if (count == 0)
check_result(ISC_R_FAILURE, "no key found");
*nkeys = count;
}
static inline isc_boolean_t
active_node(dns_db_t *db, dns_dbversion_t *version, dns_dbnode_t *node) {
dns_rdatasetiter_t *rdsiter;
isc_boolean_t active = ISC_FALSE;
isc_result_t result;
dns_rdataset_t rdataset;
dns_rdataset_init(&rdataset);
rdsiter = NULL;
result = dns_db_allrdatasets(db, node, version, 0, &rdsiter);
check_result(result, "dns_db_allrdatasets()");
result = dns_rdatasetiter_first(rdsiter);
while (result == ISC_R_SUCCESS) {
dns_rdatasetiter_current(rdsiter, &rdataset);
if (rdataset.type != dns_rdatatype_nxt)
active = ISC_TRUE;
dns_rdataset_disassociate(&rdataset);
if (!active)
result = dns_rdatasetiter_next(rdsiter);
else
result = DNS_R_NOMORE;
}
if (result != DNS_R_NOMORE)
fatal("rdataset iteration failed");
dns_rdatasetiter_destroy(&rdsiter);
if (!active) {
/*
* Make sure there is no NXT record for this node.
*/
result = dns_db_deleterdataset(db, node, version,
dns_rdatatype_nxt);
if (result == DNS_R_UNCHANGED)
result = ISC_R_SUCCESS;
check_result(result, "dns_db_deleterdataset");
}
return (active);
}
static inline isc_result_t
next_active(dns_db_t *db, dns_dbversion_t *version, dns_dbiterator_t *dbiter,
dns_name_t *name, dns_dbnode_t **nodep)
{
isc_result_t result;
isc_boolean_t active;
do {
active = ISC_FALSE;
result = dns_dbiterator_current(dbiter, nodep, name);
if (result == ISC_R_SUCCESS) {
active = active_node(db, version, *nodep);
if (!active) {
dns_db_detachnode(db, nodep);
result = dns_dbiterator_next(dbiter);
}
}
} while (result == ISC_R_SUCCESS && !active);
return (result);
}
static void
sign(char *filename) {
isc_result_t result;
dns_db_t *db;
dns_dbversion_t *wversion;
dns_dbnode_t *node, *nextnode, *curnode;
char *origintext;
dns_fixedname_t fname, fnextname;
dns_name_t *name, *nextname, *target, curname;
isc_buffer_t b;
size_t len;
dns_dbiterator_t *dbiter;
char newfilename[1024];
dst_key_t *keys[MAXKEYS];
unsigned char curdata[1024];
isc_buffer_t curbuf;
int nkeys = 0, i;
dns_fixedname_init(&fname);
name = dns_fixedname_name(&fname);
dns_fixedname_init(&fnextname);
nextname = dns_fixedname_name(&fnextname);
origintext = strrchr(filename, '/');
if (origintext == NULL)
origintext = filename;
else
origintext++; /* Skip '/'. */
len = strlen(origintext);
isc_buffer_init(&b, origintext, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&b, len);
result = dns_name_fromtext(name, &b, dns_rootname, ISC_FALSE, NULL);
check_result(result, "dns_name_fromtext()");
db = NULL;
result = dns_db_create(mctx, "rbt", name, ISC_FALSE,
dns_rdataclass_in, 0, NULL, &db);
check_result(result, "dns_db_create()");
result = dns_db_load(db, filename);
check_result(result, "dns_db_load()");
node = NULL;
result = dns_db_findnode(db, name, ISC_FALSE, &node);
check_result(result, "dns_db_findnode()");
find_keys(db, node, name, keys, &nkeys);
dns_db_detachnode(db, &node);
wversion = NULL;
result = dns_db_newversion(db, &wversion);
check_result(result, "dns_db_newversion()");
dbiter = NULL;
result = dns_db_createiterator(db, ISC_FALSE, &dbiter);
check_result(result, "dns_db_createiterator()");
result = dns_dbiterator_first(dbiter);
node = NULL;
result = next_active(db, wversion, dbiter, name, &node);
while (result == ISC_R_SUCCESS) {
nextnode = NULL;
curnode = NULL;
dns_name_init(&curname, NULL);
isc_buffer_init(&curbuf, curdata, sizeof(curdata),
ISC_BUFFERTYPE_BINARY);
dns_name_setbuffer(&curname, &curbuf);
dns_dbiterator_current(dbiter, &curnode, &curname);
result = dns_dbiterator_next(dbiter);
if (result == ISC_R_SUCCESS)
result = next_active(db, wversion, dbiter, nextname,
&nextnode);
if (result == ISC_R_SUCCESS)
target = nextname;
else if (result == DNS_R_NOMORE)
target = dns_db_origin(db);
else {
target = NULL; /* Make compiler happy. */
fatal("db iteration failed");
}
build_nxt(db, wversion, node, target);
generate_sig(db, wversion, node, &curname, keys, nkeys);
dns_name_invalidate(&curname);
dns_db_detachnode(db, &node);
dns_db_detachnode(db, &curnode);
node = nextnode;
}
if (result != DNS_R_NOMORE)
fatal("db iteration failed");
dns_dbiterator_destroy(&dbiter);
/*
* XXXRTH For now, we don't increment the SOA serial.
*/
dns_db_closeversion(db, &wversion, ISC_TRUE);
len = strlen(filename);
if (len + 4 + 1 > sizeof newfilename)
fatal("filename too long");
sprintf(newfilename, "%s.new", filename);
result = dns_db_dump(db, NULL, newfilename);
check_result(result, "dns_db_dump");
dns_db_detach(&db);
for (i = 0; i < nkeys; i++)
dst_key_free(keys[i]);
}
int
main(int argc, char *argv[]) {
int i;
isc_result_t result;
dns_result_register();
result = isc_mem_create(0, 0, &mctx);
check_result(result, "isc_mem_create()");
argc--;
argv++;
for (i = 0; i < argc; i++)
sign(argv[i]);
isc_mem_stats(mctx, stdout);
isc_mem_destroy(&mctx);
return (0);
}

View File

@@ -1,10 +0,0 @@
Makefile
.libs
*.la
*.lo
named
parser.c
parser_p.h
confparser.c
confparser_p.h
lexer.c

View File

@@ -1,62 +0,0 @@
# Copyright (C) 1998, 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM 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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
@BIND9_VERSION@
CINCLUDES = -I../../lib/isc/unix/include \
-I${srcdir}/../../lib/isc/unix/include \
-I${srcdir}/../../lib/isc/pthreads/include \
-I${srcdir}/../../lib/isc/include \
-I../../lib/dns/include \
-I${srcdir}/../../lib/dns/include \
-I${srcdir}/../../lib/dns/sec/dst/include \
-I${srcdir}/include \
-I${srcdir}/../..
CDEFINES =
CWARNINGS =
DEPLIBS = ../../lib/dns/libdns.@A@ \
../../lib/isc/libisc.@A@
LIBS = ${DEPLIBS} \
@LIBS@
TARGETS = named
OBJS = client.o interfacemgr.o main.o query.o server.o \
update.o xfrin.o xfrout.o
SRCS = client.c interfacemgr.c main.c query.c server.c \
update.c xfrin.c xfrout.c
@BIND9_MAKE_RULES@
main.o: main.c
${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" -c $<
printmsg.o: ${srcdir}/../tests/printmsg.c
${CC} -c -o printmsg.o ${ALL_CFLAGS} -I${srcdir}/../tests \
${srcdir}/../tests/printmsg.c
named: ${OBJS} ${DEPLIBS}
${LIBTOOL} ${CC} -o $@ ${OBJS} ${LIBS}
clean distclean::
rm -f ${TARGETS}

View File

@@ -1,962 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <isc/assertions.h>
#include <isc/mem.h>
#include <isc/mutex.h>
#include <isc/result.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <dns/dispatch.h>
#include <dns/events.h>
#include <dns/message.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/view.h>
#include <named/client.h>
#include <named/query.h>
#include <named/update.h>
#include <named/xfrin.h>
#include <named/globals.h>
#include "../../isc/util.h" /* XXX */
#define NS_CLIENT_TRACE
#ifdef NS_CLIENT_TRACE
#include <stdio.h>
#define CTRACE(m) printf("client %p: %s\n", client, (m))
#define MTRACE(m) printf("clientmgr %p: %s\n", manager, (m))
#else
#define CTRACE(m)
#define MTRACE(m)
#endif
#define TCP_CLIENT(c) (((c)->attributes & NS_CLIENTATTR_TCP) != 0)
#define SEND_BUFFER_SIZE 2048
struct ns_clientmgr {
/* Unlocked. */
unsigned int magic;
isc_mem_t * mctx;
isc_taskmgr_t * taskmgr;
isc_timermgr_t * timermgr;
isc_mutex_t lock;
/* Locked by lock. */
isc_boolean_t exiting;
unsigned int nclients;
ISC_LIST(ns_client_t) clients;
};
#define MANAGER_MAGIC 0x4E53436DU /* NSCm */
#define VALID_MANAGER(m) ((m) != NULL && \
(m)->magic == MANAGER_MAGIC)
static void clientmgr_destroy(ns_clientmgr_t *manager);
/***
*** Client
***/
/*
* Important note!
*
* All client state changes, other than that from idle to listening, occur
* as a result of events. This guarantees serialization and avoids the
* need for locking.
*
* If a routine is ever created that allows someone other than the client's
* task to change the client, then the client will have to be locked.
*/
static inline void
client_free(ns_client_t *client) {
dns_dispatchevent_t **deventp;
CTRACE("free");
ns_query_free(client);
isc_mempool_destroy(&client->sendbufs);
dns_message_destroy(&client->message);
isc_timer_detach(&client->timer);
if (client->dispentry != NULL) {
if (client->dispevent != NULL)
deventp = &client->dispevent;
else
deventp = NULL;
dns_dispatch_removerequest(client->dispatch,
&client->dispentry,
deventp);
}
if (client->dispatch != NULL)
dns_dispatch_detach(&client->dispatch);
if (client->tcplistener != NULL)
isc_socket_detach(&client->tcplistener);
if (client->tcpsocket != NULL) {
if (client->state == ns_clientstate_reading)
dns_tcpmsg_cancelread(&client->tcpmsg);
dns_tcpmsg_invalidate(&client->tcpmsg);
isc_socket_detach(&client->tcpsocket);
}
isc_task_detach(&client->task);
client->magic = 0;
isc_mem_put(client->mctx, client, sizeof *client);
}
static void
client_destroy(ns_client_t *client) {
ns_clientmgr_t *manager;
isc_boolean_t need_clientmgr_destroy = ISC_FALSE;
REQUIRE(NS_CLIENT_VALID(client));
CTRACE("destroy");
manager = client->manager;
LOCK(&manager->lock);
INSIST(manager->nclients > 0);
manager->nclients--;
if (manager->nclients == 0 && manager->exiting)
need_clientmgr_destroy = ISC_TRUE;
ISC_LIST_UNLINK(manager->clients, client, link);
UNLOCK(&manager->lock);
client_free(client);
if (need_clientmgr_destroy)
clientmgr_destroy(manager);
}
static void
client_shutdown(isc_task_t *task, isc_event_t *event) {
ns_client_t *client;
REQUIRE(event != NULL);
REQUIRE(event->type == ISC_TASKEVENT_SHUTDOWN);
client = event->arg;
REQUIRE(NS_CLIENT_VALID(client));
REQUIRE(task == client->task);
CTRACE("shutdown");
client_destroy(client);
isc_event_free(&event);
}
static void client_read(ns_client_t *client);
static void client_accept(ns_client_t *client);
void
ns_client_next(ns_client_t *client, isc_result_t result) {
REQUIRE(NS_CLIENT_VALID(client));
REQUIRE(client->state == ns_clientstate_listening ||
client->state == ns_clientstate_working);
CTRACE("next");
if (client->next != NULL) {
(client->next)(client, result);
client->next = NULL;
}
/*
* XXXRTH If result != ISC_R_SUCCESS:
* Log result if there is interest in doing so.
*/
if (client->view != NULL)
dns_view_detach(&client->view);
if (client->opt != NULL)
client->opt = NULL;
dns_message_reset(client->message, DNS_MESSAGE_INTENTPARSE);
if (client->dispevent != NULL) {
dns_dispatch_freeevent(client->dispatch, client->dispentry,
&client->dispevent);
client->state = ns_clientstate_listening;
} else if (TCP_CLIENT(client)) {
if (result == ISC_R_SUCCESS)
client_read(client);
else {
if (client->tcpsocket != NULL) {
dns_tcpmsg_invalidate(&client->tcpmsg);
isc_socket_detach(&client->tcpsocket);
}
client_accept(client);
}
}
}
static void
client_senddone(isc_task_t *task, isc_event_t *event) {
ns_client_t *client;
isc_socketevent_t *sevent = (isc_socketevent_t *)event;
REQUIRE(sevent != NULL);
REQUIRE(sevent->type == ISC_SOCKEVENT_SENDDONE);
client = sevent->arg;
REQUIRE(NS_CLIENT_VALID(client));
REQUIRE(task == client->task);
CTRACE("senddone");
INSIST(client->nsends > 0);
client->nsends--;
isc_mempool_put(client->sendbufs, sevent->region.base);
isc_event_free(&event);
/*
* If all of its sendbufs buffers were busy, the client might be
* waiting for one to become available.
*/
if (client->state == ns_clientstate_waiting) {
client->state = ns_clientstate_working;
ns_client_send(client);
return;
}
/* XXXRTH need to add exit draining mode. */
}
void
ns_client_send(ns_client_t *client) {
isc_result_t result;
unsigned char *data;
isc_buffer_t buffer;
isc_buffer_t tcpbuffer;
isc_region_t r;
isc_socket_t *socket;
isc_sockaddr_t *address;
unsigned int bufsize = 512;
REQUIRE(NS_CLIENT_VALID(client));
CTRACE("send");
data = isc_mempool_get(client->sendbufs);
if (data == NULL) {
CTRACE("no buffers available");
if (client->nsends > 0) {
/*
* We couldn't get memory, but there is at least one
* send outstanding. We arrange to be restarted when a
* send completes.
*/
CTRACE("waiting");
INSIST(client->state == ns_clientstate_working);
client->state = ns_clientstate_waiting;
} else
ns_client_next(client, ISC_R_NOMEMORY);
return;
}
/*
* XXXRTH The following doesn't deal with TSIGs, TCP buffer resizing,
* or ENDS1 more data packets.
*/
if (TCP_CLIENT(client)) {
/*
* XXXRTH "tcpbuffer" is a hack to get things working.
*/
isc_buffer_init(&tcpbuffer, data, SEND_BUFFER_SIZE,
ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&buffer, data + 2, SEND_BUFFER_SIZE - 2,
ISC_BUFFERTYPE_BINARY);
} else {
if (client->opt != NULL) {
if (client->opt->rdclass < SEND_BUFFER_SIZE)
bufsize = client->opt->rdclass;
else
bufsize = SEND_BUFFER_SIZE;
}
isc_buffer_init(&buffer, data, bufsize, ISC_BUFFERTYPE_BINARY);
}
result = dns_message_renderbegin(client->message, &buffer);
if (result != ISC_R_SUCCESS)
goto done;
if (client->opt != NULL) {
result = dns_message_setopt(client->message, client->opt);
if (result != ISC_R_SUCCESS)
goto done;
}
result = dns_message_rendersection(client->message,
DNS_SECTION_QUESTION, 0, 0);
if (result != ISC_R_SUCCESS)
goto done;
result = dns_message_rendersection(client->message,
DNS_SECTION_ANSWER, 0, 0);
if (result == ISC_R_NOSPACE) {
client->message->flags |= DNS_MESSAGEFLAG_TC;
goto renderend;
}
if (result != ISC_R_SUCCESS)
goto done;
result = dns_message_rendersection(client->message,
DNS_SECTION_AUTHORITY, 0, 0);
if (result == ISC_R_NOSPACE) {
client->message->flags |= DNS_MESSAGEFLAG_TC;
goto renderend;
}
if (result != ISC_R_SUCCESS)
goto done;
result = dns_message_rendersection(client->message,
DNS_SECTION_ADDITIONAL, 0, 0);
if (result != ISC_R_SUCCESS && result != ISC_R_NOSPACE)
goto done;
renderend:
result = dns_message_renderend(client->message);
if (result != ISC_R_SUCCESS)
goto done;
if (TCP_CLIENT(client)) {
socket = client->tcpsocket;
address = NULL;
isc_buffer_used(&buffer, &r);
isc_buffer_putuint16(&tcpbuffer, (isc_uint16_t)r.length);
isc_buffer_add(&tcpbuffer, r.length);
isc_buffer_used(&tcpbuffer, &r);
} else {
socket = dns_dispatch_getsocket(client->dispatch);
address = &client->dispevent->addr;
isc_buffer_used(&buffer, &r);
}
CTRACE("sendto");
result = isc_socket_sendto(socket, &r, client->task, client_senddone,
client, address);
if (result == ISC_R_SUCCESS)
client->nsends++;
done:
if (result != ISC_R_SUCCESS)
isc_mempool_put(client->sendbufs, data);
ns_client_next(client, result);
}
void
ns_client_error(ns_client_t *client, isc_result_t result) {
dns_rcode_t rcode;
dns_message_t *message;
REQUIRE(NS_CLIENT_VALID(client));
CTRACE("error");
message = client->message;
rcode = dns_result_torcode(result);
/*
* message may be an in-progress reply that we had trouble
* with, in which case QR will be set. We need to clear QR before
* calling dns_message_reply() to avoid triggering an assertion.
*/
message->flags &= ~DNS_MESSAGEFLAG_QR;
result = dns_message_reply(message, ISC_TRUE);
if (result != ISC_R_SUCCESS) {
/*
* It could be that we've got a query with a good header,
* but a bad question section, so we try again with
* want_question_section set to ISC_FALSE.
*/
result = dns_message_reply(message, ISC_FALSE);
if (result != ISC_R_SUCCESS) {
/*
* There's no hope of replying to this request.
*
* XXXRTH Mark this client to that if it is a
* TCP session, the session will be closed.
*/
ns_client_next(client, result);
return;
}
}
message->rcode = rcode;
ns_client_send(client);
}
static inline isc_result_t
client_addopt(ns_client_t *client) {
dns_rdataset_t *rdataset;
dns_rdatalist_t *rdatalist;
dns_rdata_t *rdata;
isc_result_t result;
REQUIRE(client->opt == NULL); /* XXXRTH free old. */
rdataset = NULL;
result = dns_message_gettemprdataset(client->message, &rdataset);
if (result != ISC_R_SUCCESS)
return (result);
dns_rdataset_init(rdataset);
rdatalist = NULL;
result = dns_message_gettemprdatalist(client->message, &rdatalist);
if (result != ISC_R_SUCCESS)
return (result);
rdata = NULL;
result = dns_message_gettemprdata(client->message, &rdata);
if (result != ISC_R_SUCCESS)
return (result);
rdatalist->type = dns_rdatatype_opt;
rdatalist->covers = 0;
/*
* Set Maximum UDP buffer size.
*/
rdatalist->rdclass = SEND_BUFFER_SIZE;
/*
* Set EXTENDED-RCODE, VERSION, and Z to 0.
*/
rdatalist->ttl = 0;
/*
* No ENDS options.
*/
rdata->data = NULL;
rdata->length = 0;
ISC_LIST_INIT(rdatalist->rdata);
ISC_LIST_APPEND(rdatalist->rdata, rdata, link);
dns_rdatalist_tordataset(rdatalist, rdataset);
client->opt = rdataset;
return (ISC_R_SUCCESS);
}
static void
client_request(isc_task_t *task, isc_event_t *event) {
ns_client_t *client;
dns_dispatchevent_t *devent;
isc_result_t result;
isc_buffer_t *buffer;
dns_view_t *view;
dns_rdataset_t *opt;
REQUIRE(event != NULL);
client = event->arg;
REQUIRE(NS_CLIENT_VALID(client));
REQUIRE(task == client->task);
if (event->type == DNS_EVENT_DISPATCH) {
devent = (dns_dispatchevent_t *)event;
REQUIRE(client->dispentry != NULL);
client->dispevent = devent;
buffer = &devent->buffer;
result = devent->result;
} else {
REQUIRE(event->type == DNS_EVENT_TCPMSG);
REQUIRE(event->sender == &client->tcpmsg);
buffer = &client->tcpmsg.buffer;
result = client->tcpmsg.result;
}
CTRACE("request");
client->state = ns_clientstate_working;
if (isc_stdtime_get(&client->requesttime) != ISC_R_SUCCESS)
client->requesttime = 0;
if (result != ISC_R_SUCCESS) {
if (TCP_CLIENT(client))
ns_client_next(client, result);
else
isc_task_shutdown(client->task);
return;
}
result = dns_message_parse(client->message, buffer, ISC_FALSE);
if (result != ISC_R_SUCCESS) {
ns_client_error(client, result);
return;
}
INSIST((client->message->flags & DNS_MESSAGEFLAG_QR) == 0);
/*
* Deal with EDNS.
*/
opt = dns_message_getopt(client->message);
if (opt != NULL) {
unsigned int version;
/*
* Create an OPT for our reply.
*/
result = client_addopt(client);
if (result != ISC_R_SUCCESS) {
ns_client_error(client, result);
return;
}
/*
* Do we understand this version of ENDS?
*
* XXXRTH need library support for this!
*/
version = (opt->ttl & 0x00FF0000) >> 16;
if (version != 0) {
ns_client_error(client, DNS_R_BADVERS);
return;
}
}
/*
* XXXRTH View list management code will be moving to its own module
* soon.
*/
RWLOCK(&ns_g_viewlock, isc_rwlocktype_read);
for (view = ISC_LIST_HEAD(ns_g_viewlist);
view != NULL;
view = ISC_LIST_NEXT(view, link)) {
/*
* XXXRTH View matching will become more powerful later.
*/
if (client->message->rdclass == view->rdclass) {
dns_view_attach(view, &client->view);
break;
}
}
RWUNLOCK(&ns_g_viewlock, isc_rwlocktype_read);
if (view == NULL) {
CTRACE("no view");
ns_client_error(client, DNS_R_REFUSED);
return;
}
/*
* Dispatch the request.
*/
switch (client->message->opcode) {
case dns_opcode_query:
CTRACE("query");
ns_query_start(client);
break;
case dns_opcode_update:
CTRACE("update");
ns_update_start(client);
break;
case dns_opcode_notify:
CTRACE("notify");
xfrin_test(); /* XXX for testing only */
ns_client_next(client, DNS_R_SUCCESS);
break;
case dns_opcode_iquery:
CTRACE("iquery");
ns_client_error(client, DNS_R_REFUSED);
default:
CTRACE("unknown opcode");
ns_client_error(client, DNS_R_NOTIMP);
}
}
static void
client_timeout(isc_task_t *task, isc_event_t *event) {
ns_client_t *client;
REQUIRE(event != NULL);
REQUIRE(event->type == ISC_TIMEREVENT_LIFE ||
event->type == ISC_TIMEREVENT_IDLE);
client = event->arg;
REQUIRE(NS_CLIENT_VALID(client));
REQUIRE(task == client->task);
REQUIRE(client->timer != NULL);
CTRACE("timeout");
isc_event_free(&event);
ns_client_next(client, ISC_R_TIMEDOUT);
}
static isc_result_t
client_create(ns_clientmgr_t *manager, ns_clienttype_t type,
ns_client_t **clientp)
{
ns_client_t *client;
isc_result_t result;
/*
* Caller must be holding the manager lock.
*
* Note: creating a client does not add the client to the manager's
* client list. The caller is responsible for that.
*/
REQUIRE(clientp != NULL && *clientp == NULL);
client = isc_mem_get(manager->mctx, sizeof *client);
if (client == NULL)
return (ISC_R_NOMEMORY);
client->task = NULL;
result = isc_task_create(manager->taskmgr, manager->mctx, 0,
&client->task);
if (result != ISC_R_SUCCESS)
goto cleanup_client;
result = isc_task_onshutdown(client->task, client_shutdown, client);
if (result != ISC_R_SUCCESS)
goto cleanup_task;
client->timer = NULL;
result = isc_timer_create(manager->timermgr, isc_timertype_inactive,
NULL, NULL, client->task, client_timeout,
client, &client->timer);
if (result != ISC_R_SUCCESS)
goto cleanup_task;
client->message = NULL;
result = dns_message_create(manager->mctx, DNS_MESSAGE_INTENTPARSE,
&client->message);
if (result != ISC_R_SUCCESS)
goto cleanup_timer;
/* XXXRTH Hardwired constants */
client->sendbufs = NULL;
result = isc_mempool_create(manager->mctx, SEND_BUFFER_SIZE,
&client->sendbufs);
if (result != ISC_R_SUCCESS)
goto cleanup_message;
isc_mempool_setfreemax(client->sendbufs, 3);
isc_mempool_setmaxalloc(client->sendbufs, 3);
client->magic = NS_CLIENT_MAGIC;
client->mctx = manager->mctx;
client->manager = manager;
client->type = type;
client->state = ns_clientstate_idle;
client->attributes = 0;
client->view = NULL;
client->dispatch = NULL;
client->dispentry = NULL;
client->dispevent = NULL;
client->tcplistener = NULL;
client->tcpsocket = NULL;
client->nsends = 0;
client->opt = NULL;
client->next = NULL;
ISC_LINK_INIT(client, link);
/*
* We call the init routines for the various kinds of client here,
* after we have created an otherwise valid client, because some
* of them call routines that REQUIRE(NS_CLIENT_VALID(client)).
*/
result = ns_query_init(client);
if (result != ISC_R_SUCCESS)
goto cleanup_sendbufs;
CTRACE("create");
*clientp = client;
return (ISC_R_SUCCESS);
cleanup_sendbufs:
isc_mempool_destroy(&client->sendbufs);
client->magic = 0;
cleanup_message:
dns_message_destroy(&client->message);
cleanup_timer:
isc_timer_detach(&client->timer);
cleanup_task:
isc_task_detach(&client->task);
cleanup_client:
isc_mem_put(manager->mctx, client, sizeof *client);
return (result);
}
static void
client_read(ns_client_t *client) {
isc_result_t result;
CTRACE("read");
result = dns_tcpmsg_readmessage(&client->tcpmsg, client->task,
client_request, client);
if (result != ISC_R_SUCCESS)
ns_client_next(client, result);
client->state = ns_clientstate_reading;
}
static void
client_newconn(isc_task_t *task, isc_event_t *event) {
ns_client_t *client = event->arg;
isc_socket_newconnev_t *nevent = (isc_socket_newconnev_t *)event;
REQUIRE(event->type == ISC_SOCKEVENT_NEWCONN);
REQUIRE(NS_CLIENT_VALID(client));
REQUIRE(client->task == task);
CTRACE("newconn");
if (nevent->result == ISC_R_SUCCESS) {
client->tcpsocket = nevent->newsocket;
dns_tcpmsg_init(client->mctx, client->tcpsocket,
&client->tcpmsg);
client_read(client);
} else {
/*
* XXXRTH What should we do? We're trying to accept but
* it didn't work. If we just give up, then TCP
* service may eventually stop.
*
* For now, we just go idle.
*
* Going idle is probably the right thing if the
* I/O was canceled.
*/
client->state = ns_clientstate_idle;
}
isc_event_free(&event);
}
static void
client_accept(ns_client_t *client) {
isc_result_t result;
CTRACE("accept");
result = isc_socket_accept(client->tcplistener, client->task,
client_newconn, client);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_socket_accept() failed: %s",
isc_result_totext(result));
/*
* XXXRTH What should we do? We're trying to accept but
* it didn't work. If we just give up, then TCP
* service may eventually stop.
*
* For now, we just go idle.
*/
client->state = ns_clientstate_idle;
return;
}
}
/***
*** Client Manager
***/
static void
clientmgr_destroy(ns_clientmgr_t *manager) {
REQUIRE(manager->nclients == 0);
REQUIRE(ISC_LIST_EMPTY(manager->clients));
MTRACE("clientmgr_destroy");
manager->magic = 0;
isc_mem_put(manager->mctx, manager, sizeof *manager);
}
isc_result_t
ns_clientmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, ns_clientmgr_t **managerp)
{
ns_clientmgr_t *manager;
isc_result_t result;
manager = isc_mem_get(mctx, sizeof *manager);
if (manager == NULL)
return (ISC_R_NOMEMORY);
result = isc_mutex_init(&manager->lock);
if (result != ISC_R_SUCCESS)
goto cleanup_manager;
manager->mctx = mctx;
manager->taskmgr = taskmgr;
manager->timermgr = timermgr;
manager->exiting = ISC_FALSE;
manager->nclients = 0;
ISC_LIST_INIT(manager->clients);
manager->magic = MANAGER_MAGIC;
MTRACE("create");
*managerp = manager;
return (ISC_R_SUCCESS);
cleanup_manager:
isc_mem_put(manager->mctx, manager, sizeof *manager);
return (result);
}
void
ns_clientmgr_destroy(ns_clientmgr_t **managerp) {
ns_clientmgr_t *manager;
ns_client_t *client;
isc_boolean_t need_destroy = ISC_FALSE;
REQUIRE(managerp != NULL);
manager = *managerp;
REQUIRE(VALID_MANAGER(manager));
MTRACE("destroy");
LOCK(&manager->lock);
manager->exiting = ISC_TRUE;
for (client = ISC_LIST_HEAD(manager->clients);
client != NULL;
client = ISC_LIST_NEXT(client, link))
isc_task_shutdown(client->task);
if (ISC_LIST_EMPTY(manager->clients))
need_destroy = ISC_TRUE;
UNLOCK(&manager->lock);
if (need_destroy)
clientmgr_destroy(manager);
*managerp = NULL;
}
isc_result_t
ns_clientmgr_addtodispatch(ns_clientmgr_t *manager, unsigned int n,
dns_dispatch_t *dispatch)
{
isc_result_t result = ISC_R_SUCCESS;
unsigned int i;
ns_client_t *client;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(n > 0);
MTRACE("addtodispatch");
/*
* We MUST lock the manager lock for the entire client creation
* process. If we didn't do this, then a client could get a
* shutdown event and disappear out from under us.
*/
LOCK(&manager->lock);
for (i = 0; i < n; i++) {
client = NULL;
result = client_create(manager, ns_clienttype_basic,
&client);
if (result != ISC_R_SUCCESS)
break;
client->state = ns_clientstate_listening;
dns_dispatch_attach(dispatch, &client->dispatch);
result = dns_dispatch_addrequest(dispatch, client->task,
client_request,
client, &client->dispentry);
if (result != ISC_R_SUCCESS) {
client_free(client);
break;
}
manager->nclients++;
ISC_LIST_APPEND(manager->clients, client, link);
}
if (i != 0) {
/*
* We managed to create at least one client, so we
* declare victory.
*/
result = ISC_R_SUCCESS;
}
UNLOCK(&manager->lock);
return (result);
}
isc_result_t
ns_clientmgr_accepttcp(ns_clientmgr_t *manager, isc_socket_t *socket,
unsigned int n)
{
isc_result_t result = ISC_R_SUCCESS;
unsigned int i;
ns_client_t *client;
REQUIRE(VALID_MANAGER(manager));
REQUIRE(n > 0);
MTRACE("accepttcp");
/*
* XXXRTH
*
* This does not represent the planned method for TCP support,
* because we are dedicating a few clients to servicing TCP requests
* instead of allocating TCP clients from a pool and applying quotas.
*
* All this will be fixed later, but this code will allow parts of
* the server that need TCP support, e.g. IXFR and AXFR, to progress.
*/
/*
* We MUST lock the manager lock for the entire client creation
* process. If we didn't do this, then a client could get a
* shutdown event and disappear out from under us.
*/
LOCK(&manager->lock);
for (i = 0; i < n; i++) {
client = NULL;
result = client_create(manager, ns_clienttype_tcp, &client);
if (result != ISC_R_SUCCESS)
break;
client->state = ns_clientstate_listening;
client->attributes |= NS_CLIENTATTR_TCP;
isc_socket_attach(socket, &client->tcplistener);
client_accept(client);
manager->nclients++;
ISC_LIST_APPEND(manager->clients, client, link);
}
if (i != 0) {
/*
* We managed to create at least one client, so we
* declare victory.
*/
result = ISC_R_SUCCESS;
}
UNLOCK(&manager->lock);
return (result);
}

View File

@@ -1,113 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_CLIENT_H
#define NS_CLIENT_H 1
#include <isc/types.h>
#include <isc/stdtime.h>
#include <isc/buffer.h>
#include <dns/types.h>
#include <dns/tcpmsg.h>
#include <named/types.h>
#include <named/query.h>
typedef enum ns_clienttype {
ns_clienttype_basic = 0,
ns_clienttype_recursive,
ns_clienttype_axfr,
ns_clienttype_ixfr,
ns_clienttype_tcp
} ns_clienttype_t;
typedef enum {
ns_clientstate_idle = 0,
ns_clientstate_listening,
ns_clientstate_reading,
ns_clientstate_working,
ns_clientstate_waiting
} ns_clientstate_t;
struct ns_client {
unsigned int magic;
isc_mem_t * mctx;
ns_clientmgr_t * manager;
ns_clienttype_t type;
ns_clientstate_t state;
unsigned int attributes;
isc_task_t * task;
dns_view_t * view;
dns_dispatch_t * dispatch;
dns_dispentry_t * dispentry;
dns_dispatchevent_t * dispevent;
isc_socket_t * tcplistener;
isc_socket_t * tcpsocket;
dns_tcpmsg_t tcpmsg;
isc_timer_t * timer;
dns_message_t * message;
unsigned int nsends;
isc_mempool_t * sendbufs;
dns_rdataset_t * opt;
void (*next)(ns_client_t *, isc_result_t);
ns_query_t query;
isc_stdtime_t requesttime;
ISC_LINK(struct ns_client) link;
};
#define NS_CLIENT_MAGIC 0x4E534363U /* NSCc */
#define NS_CLIENT_VALID(c) ((c) != NULL && \
(c)->magic == NS_CLIENT_MAGIC)
#define NS_CLIENTATTR_TCP 0x01
/*
* Note! These ns_client_ routines MUST be called ONLY from the client's
* task in order to ensure synchronization.
*/
void
ns_client_error(ns_client_t *client, isc_result_t result);
void
ns_client_next(ns_client_t *client, isc_result_t result);
void
ns_client_send(ns_client_t *client);
void
ns_client_destroy(ns_client_t *client);
isc_result_t
ns_client_newnamebuf(ns_client_t *client);
isc_result_t
ns_clientmgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_timermgr_t *timermgr, ns_clientmgr_t **managerp);
void
ns_clientmgr_destroy(ns_clientmgr_t **managerp);
isc_result_t
ns_clientmgr_addtodispatch(ns_clientmgr_t *manager, unsigned int n,
dns_dispatch_t *dispatch);
isc_result_t
ns_clientmgr_accepttcp(ns_clientmgr_t *manager, isc_socket_t *socket,
unsigned int n);
#endif /* NS_CLIENT_H */

View File

@@ -1,62 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_GLOBALS_H
#define NS_GLOBALS_H 1
#include <isc/types.h>
#include <isc/rwlock.h>
#include <dns/types.h>
#include <named/types.h>
#include <named/interfacemgr.h>
#undef EXTERN
#undef INIT
#ifdef NS_MAIN
#define EXTERN
#define INIT(v) = (v)
#else
#define EXTERN extern
#define INIT(v)
#endif
EXTERN isc_mem_t * ns_g_mctx INIT(NULL);
EXTERN unsigned int ns_g_cpus INIT(1);
EXTERN isc_taskmgr_t * ns_g_taskmgr INIT(NULL);
/*
* XXXRTH We're going to want multiple timer managers eventually. One
* for really short timers, another for client timers, and one
* for zone timers.
*/
EXTERN isc_timermgr_t * ns_g_timermgr INIT(NULL);
EXTERN isc_socketmgr_t * ns_g_socketmgr INIT(NULL);
EXTERN ns_interfacemgr_t * ns_g_interfacemgr INIT(NULL);
EXTERN ns_clientmgr_t * ns_g_clientmgr INIT(NULL);
EXTERN char * ns_g_version INIT(VERSION);
EXTERN dns_viewlist_t ns_g_viewlist;
EXTERN isc_rwlock_t ns_g_viewlock;
/* XXXRTH These are temporary. */
EXTERN ns_dbinfolist_t ns_g_dbs;
#undef EXTERN
#undef INIT
#endif /* NS_GLOBALS_H */

View File

@@ -1,92 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_INTERFACEMGR_H
#define NS_INTERFACEMGR_H 1
/*****
***** Module Info
*****/
/*
* Interface manager
*
* The interface manager monitors the operating system's list
* of network interfaces, creating and destroying listeners
* as needed.
*
* Reliability:
* No impact expected.
*
* Resources:
*
* Security:
* The server will only be able to bind to the DNS port on
* newly discovered interfaces if it is running as root.
*
* Standards:
* The API for scanning varies greatly among operating systems.
* This module attempts to hide the differences.
*/
/***
*** Imports
***/
#include <isc/types.h>
#include <isc/result.h>
#include <isc/mem.h>
#include <isc/socket.h>
#include <dns/result.h>
/***
*** Types
***/
typedef struct ns_interfacemgr ns_interfacemgr_t;
/***
*** Functions
***/
isc_result_t
ns_interfacemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_socketmgr_t *socketmgr, ns_clientmgr_t *clientmgr,
ns_interfacemgr_t **mgrp);
void
ns_interfacemgr_scan(ns_interfacemgr_t *mgr);
/*
* Scan the operatings system's list of network interfaces
* and create listeners when new interfaces are discovered.
* Shut down the sockets for interfaces that go away.
*
* XXX should honor the listen-on directive in named.conf.
*
* This should be called once on server startup and then
* periodically according to the 'interface-interval' option
* in named.conf.
*/
void
ns_interfacemgr_destroy(ns_interfacemgr_t **mgrp);
/*
* Destroy the interface manager.
*/
#endif /* NS_INTERFACEMGR_H */

View File

@@ -1,63 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_QUERY_H
#define NS_QUERY_H 1
#include <isc/types.h>
#include <isc/buffer.h>
#include <dns/types.h>
#include <dns/a6.h>
#include <named/types.h>
typedef struct ns_dbversion {
dns_db_t *db;
dns_dbversion_t *version;
ISC_LINK(struct ns_dbversion) link;
} ns_dbversion_t;
struct ns_query {
unsigned int attributes;
dns_name_t * qname;
dns_name_t * origqname;
unsigned int dboptions;
dns_db_t * gluedb;
dns_a6context_t a6ctx;
isc_bufferlist_t namebufs;
ISC_LIST(dns_name_t) tmpnames;
ISC_LIST(dns_rdataset_t) tmprdatasets;
ISC_LIST(ns_dbversion_t) activeversions;
ISC_LIST(ns_dbversion_t) freeversions;
};
#define NS_QUERYATTR_RECURSIONOK 0x01
#define NS_QUERYATTR_CACHEOK 0x02
#define NS_QUERYATTR_PARTIALANSWER 0x04
#define NS_QUERYATTR_NAMEBUFUSED 0x08
isc_result_t
ns_query_init(ns_client_t *client);
void
ns_query_free(ns_client_t *client);
void
ns_query_start(ns_client_t *client);
#endif /* NS_QUERY_H */

View File

@@ -1,25 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_SERVER_H
#define NS_SERVER_H 1
#include <isc/types.h>
isc_result_t ns_server_init(void);
#endif /* NS_SERVER_H */

View File

@@ -1,51 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_TYPES_H
#define NS_TYPES_H 1
#include <isc/list.h>
#include <dns/types.h>
typedef struct ns_client ns_client_t;
typedef struct ns_clientmgr ns_clientmgr_t;
typedef struct ns_query ns_query_t;
/*
* XXXRTH This stuff is temporary. As soon as we have zone and config
* support, it will go away.
*/
typedef struct ns_dbinfo {
char * path;
char * origin;
char * master; /* Dotted quad, or NULL */
isc_boolean_t iscache;
isc_boolean_t isslave;
dns_view_t * view;
dns_db_t * db;
ISC_LINK(struct ns_dbinfo) link;
} ns_dbinfo_t;
typedef ISC_LIST(ns_dbinfo_t) ns_dbinfolist_t;
/*
* XXXRTH End of temporary stuff.
*/
#endif /* NS_TYPES_H */

View File

@@ -1,47 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_UPDATE_H
#define NS_UPDATE_H 1
/*****
***** Module Info
*****/
/*
* RFC2136 Dynamic Update
*/
/***
*** Imports
***/
#include <isc/types.h>
#include <dns/types.h>
#include <dns/result.h>
/***
*** Types.
***/
/***
*** Functions
***/
void ns_update_start(ns_client_t *client);
#endif /* NS_UPDATE_H */

View File

@@ -1,39 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_XFRIN_H
#define NS_XFRIN_H 1
/*****
***** Module Info
*****/
/*
* Incoming zone transfers (AXFR + IXFR).
*/
#include <dns/types.h>
/***
*** Functions
***/
/* XXX for testing only */
void xfrin_test(void);
#endif /* NS_XFRIN_H */

View File

@@ -1,35 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#ifndef NS_XFROUT_H
#define NS_XFROUT_H 1
/*****
***** Module Info
*****/
/*
* Outgoing zone transfers (AXFR + IXFR).
*/
/***
*** Functions
***/
void ns_xfr_start(ns_client_t *client, dns_rdatatype_t xfrtype);
#endif /* NS_XFROUT_H */

View File

@@ -1,448 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/mem.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/types.h>
#include <isc/net.h>
#include <isc/interfaceiter.h>
#include <dns/dispatch.h>
#include <named/client.h>
#include <named/globals.h>
#include <named/interfacemgr.h>
typedef struct ns_interface ns_interface_t;
#define IFMGR_MAGIC 0x49464D47U /* IFMG. */
#define VALID_IFMGR(t) ((t) != NULL && (t)->magic == IFMGR_MAGIC)
struct ns_interfacemgr {
unsigned int magic; /* Magic number. */
isc_mem_t * mctx; /* Memory context. */
isc_taskmgr_t * taskmgr; /* Task manager. */
isc_socketmgr_t * socketmgr; /* Socket manager. */
ns_clientmgr_t * clientmgr; /* Client manager. */
unsigned int generation; /* Current generation no. */
ISC_LIST(ns_interface_t) interfaces; /* List of interfaces. */
};
#define IFACE_MAGIC 0x493A2D29U /* I:-). */
#define VALID_IFACE(t) ((t) != NULL && (t)->magic == IFACE_MAGIC)
struct ns_interface {
unsigned int magic; /* Magic number. */
ns_interfacemgr_t * mgr; /* Interface manager. */
unsigned int generation; /* Generation number. */
isc_sockaddr_t addr; /* Address and port. */
isc_socket_t * udpsocket; /* UDP socket. */
dns_dispatch_t * udpdispatch; /* UDP dispatcher. */
isc_socket_t * tcpsocket; /* TCP socket. */
isc_task_t * task;
ISC_LINK(ns_interface_t) link;
};
isc_result_t
ns_interfacemgr_create(isc_mem_t *mctx, isc_taskmgr_t *taskmgr,
isc_socketmgr_t *socketmgr, ns_clientmgr_t *clientmgr,
ns_interfacemgr_t **mgrp)
{
ns_interfacemgr_t *mgr;
REQUIRE(mctx != NULL);
REQUIRE(mgrp != NULL);
REQUIRE(*mgrp == NULL);
mgr = isc_mem_get(mctx, sizeof(*mgr));
if (mgr == NULL)
return (DNS_R_NOMEMORY);
mgr->mctx = mctx;
mgr->taskmgr = taskmgr;
mgr->socketmgr = socketmgr;
mgr->clientmgr = clientmgr;
mgr->generation = 1;
ISC_LIST_INIT(mgr->interfaces);
mgr->magic = IFMGR_MAGIC;
*mgrp = mgr;
return (DNS_R_SUCCESS);
}
static dns_result_t
ns_interface_create(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr,
isc_boolean_t udp_only, ns_interface_t **ifpret) {
ns_interface_t *ifp;
isc_result_t result;
REQUIRE(VALID_IFMGR(mgr));
ifp = isc_mem_get(mgr->mctx, sizeof(*ifp));
if (ifp == NULL)
return (DNS_R_NOMEMORY);
ifp->mgr = mgr;
ifp->generation = mgr->generation;
ifp->addr = *addr;
/*
* Create a task.
*/
ifp->task = NULL;
result = isc_task_create(mgr->taskmgr, mgr->mctx, 0, &ifp->task);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_task_create() failed: %s",
isc_result_totext(result));
goto task_create_failure;
}
result = isc_task_allowdone(ifp->task, ISC_FALSE);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_task_allowdone() failed: %s",
isc_result_totext(result));
goto task_create_failure;
}
/*
* Open a UDP socket.
*/
ifp->udpsocket = NULL;
result = isc_socket_create(mgr->socketmgr,
isc_sockaddr_pf(addr),
isc_sockettype_udp,
&ifp->udpsocket);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"creating UDP socket: %s",
isc_result_totext(result));
goto udp_socket_failure;
}
result = isc_socket_bind(ifp->udpsocket, &ifp->addr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"binding UDP socket: %s",
isc_result_totext(result));
goto udp_bind_failure;
}
/*
* XXXRTH hardwired constants. We're going to need to determine if
* this UDP socket will be shared with the resolver, and if so, we
* need to set the hashsize to be be something bigger than 4.
*/
ifp->udpdispatch = NULL;
result = dns_dispatch_create(mgr->mctx, ifp->udpsocket, ifp->task,
4096, 50, 50, 4, &ifp->udpdispatch);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"UDP dns_dispatch_create(): %s",
isc_result_totext(result));
goto udp_dispatch_failure;
}
result = ns_clientmgr_addtodispatch(mgr->clientmgr, ns_g_cpus,
ifp->udpdispatch);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"UDP ns_clientmgr_addtodispatch(): %s",
isc_result_totext(result));
goto addtodispatch_failure;
}
ifp->tcpsocket = NULL;
if (!udp_only) {
/*
* Open a TCP socket.
*/
result = isc_socket_create(mgr->socketmgr,
isc_sockaddr_pf(addr),
isc_sockettype_tcp,
&ifp->tcpsocket);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"creating TCP socket: %s",
isc_result_totext(result));
goto tcp_socket_failure;
}
result = isc_socket_bind(ifp->tcpsocket, &ifp->addr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"binding TCP socket: %s",
isc_result_totext(result));
goto tcp_bind_failure;
}
result = isc_socket_listen(ifp->tcpsocket, 0);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"listen TCP socket: %s",
isc_result_totext(result));
goto tcp_listen_failure;
}
result = ns_clientmgr_accepttcp(mgr->clientmgr, ifp->tcpsocket,
ns_g_cpus);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"TCP ns_clientmgr_accepttcp(): %s",
isc_result_totext(result));
goto accepttcp_failure;
}
}
ISC_LIST_APPEND(mgr->interfaces, ifp, link);
ifp->magic = IFACE_MAGIC;
*ifpret = ifp;
return (DNS_R_SUCCESS);
accepttcp_failure:
tcp_listen_failure:
tcp_bind_failure:
isc_socket_detach(&ifp->tcpsocket);
tcp_socket_failure:
/*
* XXXRTH We don't currently have a way to easily stop dispatch
* service, so we return currently return DNS_R_SUCCESS (the UDP
* stuff will work even if TCP creation failed). This will be fixed
* later.
*/
return (DNS_R_SUCCESS);
addtodispatch_failure:
dns_dispatch_detach(&ifp->udpdispatch);
udp_dispatch_failure:
udp_bind_failure:
isc_socket_detach(&ifp->udpsocket);
udp_socket_failure:
isc_task_detach(&ifp->task);
task_create_failure:
ifp->magic = 0;
isc_mem_put(mgr->mctx, ifp, sizeof(*ifp));
return (DNS_R_UNEXPECTED);
}
static dns_result_t
ns_interface_destroy(ns_interface_t **ifpret) {
ns_interface_t *ifp;
REQUIRE(ifpret != NULL);
REQUIRE(VALID_IFACE(*ifpret));
ifp = *ifpret;
ISC_LIST_UNLINK(ifp->mgr->interfaces, ifp, link);
dns_dispatch_detach(&ifp->udpdispatch);
isc_socket_detach(&ifp->udpsocket);
if (ifp->tcpsocket != NULL) {
isc_socket_cancel(ifp->tcpsocket, NULL, ISC_SOCKCANCEL_ALL);
isc_socket_detach(&ifp->tcpsocket);
}
isc_task_detach(&ifp->task);
ifp->magic = 0;
isc_mem_put(ifp->mgr->mctx, ifp, sizeof(*ifp));
*ifpret = NULL;
return (DNS_R_SUCCESS);
}
/*
* Search the interface list for an interface whose address and port
* both match those of 'addr'. Return a pointer to it, or NULL if not found.
*/
static ns_interface_t *
find_matching_interface(ns_interfacemgr_t *mgr, isc_sockaddr_t *addr) {
ns_interface_t *ifp;
for (ifp = ISC_LIST_HEAD(mgr->interfaces); ifp != NULL;
ifp = ISC_LIST_NEXT(ifp, link)) {
if (isc_sockaddr_equal(&ifp->addr, addr))
break;
}
return (ifp);
}
/*
* Remove any interfaces whose generation number is not the current one.
*/
static void
purge_old_interfaces(ns_interfacemgr_t *mgr) {
ns_interface_t *ifp, *next;
for (ifp = ISC_LIST_HEAD(mgr->interfaces); ifp != NULL; ifp = next) {
INSIST(VALID_IFACE(ifp));
next = ISC_LIST_NEXT(ifp, link);
if (ifp->generation != mgr->generation) {
dns_result_t result = ns_interface_destroy(&ifp);
RUNTIME_CHECK(result == DNS_R_SUCCESS);
}
}
}
static void
do_ipv4(ns_interfacemgr_t *mgr, isc_boolean_t udp_only) {
isc_interfaceiter_t *iter = NULL;
isc_result_t result;
result = isc_interfaceiter_create(mgr->mctx, &iter);
if (result != ISC_R_SUCCESS)
return;
result = isc_interfaceiter_first(iter);
while (result == ISC_R_SUCCESS) {
ns_interface_t *ifp;
unsigned int listen_port = 5544; /* XXX from configuration */
isc_interface_t interface;
isc_sockaddr_t listen_addr;
/*
* XXX insert code to match against named.conf
* "listen-on" statements here. Also build list of
* local addresses and local networks.
*/
result = isc_interfaceiter_current(iter, &interface);
if (result != ISC_R_SUCCESS)
break;
isc_sockaddr_fromin(&listen_addr,
&interface.address.type.in,
listen_port);
ifp = find_matching_interface(mgr, &listen_addr);
if (ifp != NULL) {
ifp->generation = mgr->generation;
} else {
char buf[128];
const char *addrstr;
addrstr = inet_ntop(listen_addr.type.sin.sin_family,
&listen_addr.type.sin.sin_addr,
buf, sizeof(buf));
if (addrstr == NULL)
addrstr = "(bad address)";
printf("IPv4: listening on %s (%s port %u)\n",
interface.name, addrstr,
ntohs(listen_addr.type.sin.sin_port));
result = ns_interface_create(mgr, &listen_addr,
udp_only, &ifp);
if (result != DNS_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"IPv4: listening on interface %s"
" failed; interface ignored",
interface.name);
}
}
result = isc_interfaceiter_next(iter);
}
if (result != ISC_R_NOMORE)
UNEXPECTED_ERROR(__FILE__, __LINE__,
"IPv4: interface iteration failed: %s",
isc_result_totext(result));
isc_interfaceiter_destroy(&iter);
}
static void
do_ipv6(ns_interfacemgr_t *mgr) {
isc_result_t result;
ns_interface_t *ifp;
unsigned int listen_port = 5544; /* XXX from configuration */
isc_sockaddr_t listen_addr;
struct in6_addr in6a;
in6a = in6addr_any;
isc_sockaddr_fromin6(&listen_addr, &in6a, listen_port);
ifp = find_matching_interface(mgr, &listen_addr);
if (ifp != NULL) {
ifp->generation = mgr->generation;
} else {
printf("IPv6: listening (port %u)\n", listen_port);
result = ns_interface_create(mgr, &listen_addr, ISC_FALSE,
&ifp);
if (result != DNS_R_SUCCESS)
UNEXPECTED_ERROR(__FILE__, __LINE__,
"IPv6: listening failed");
}
}
void
ns_interfacemgr_scan(ns_interfacemgr_t *mgr) {
isc_boolean_t udp_only = ISC_FALSE;
REQUIRE(VALID_IFMGR(mgr));
mgr->generation++; /* Increment the generation count. */
if (isc_net_probeipv6() == ISC_R_SUCCESS) {
do_ipv6(mgr);
udp_only = ISC_TRUE;
} else
printf("IPv6: not available\n");
if (isc_net_probeipv4() == ISC_R_SUCCESS)
do_ipv4(mgr, udp_only);
else
printf("IPv4: not available\n");
/*
* Now go through the interface list and delete anything that
* does not have the current generation number. This is
* how we catch interfaces that go away or change their
* addresses.
*/
purge_old_interfaces(mgr);
if (ISC_LIST_EMPTY(mgr->interfaces)) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"warning: not listening on any interfaces");
/* Continue anyway. */
}
}
void
ns_interfacemgr_destroy(ns_interfacemgr_t **mgrp)
{
ns_interfacemgr_t *mgr;
REQUIRE(mgrp != NULL);
mgr = *mgrp;
REQUIRE(VALID_IFMGR(mgr));
/*
* Destroy all interfaces. By incrementing the generation count,
* we make purge_old_interfaces() consider all interfaces "old"
* and destroy all of them.
*/
mgr->generation++;
purge_old_interfaces(mgr);
INSIST(ISC_LIST_EMPTY(mgr->interfaces));
mgr->magic = 0;
isc_mem_put(mgr->mctx, mgr, sizeof *mgr);
*mgrp = NULL;
}

View File

@@ -1,304 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <string.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h> /* XXXRTH Naughty. Needed for getopt(). */
#include <isc/app.h>
#include <isc/error.h>
#include <isc/boolean.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <dns/dbtable.h>
#include <dns/tsig.h>
#include <dns/result.h>
#include <dst/result.h>
#define NS_MAIN 1
#include <named/globals.h>
#include <named/client.h>
#include <named/interfacemgr.h>
#include <named/server.h>
static isc_boolean_t want_stats = ISC_FALSE;
static void
early_fatal(char *format, ...) {
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
fprintf(stderr, "\n");
exit(1);
}
static void
usage(void) {
fprintf(stderr,
"usage: named [[-c cachefile] ...] [[-z zonefile] ...]\n");
fprintf(stderr,
" [-s] [-N number of cpus]\n");
}
static void
parse_command_line(int argc, char *argv[]) {
char *argtext, *mastertext, *origintext;
int ch;
ns_dbinfo_t *dbi;
/*+ XXXRTH we need a veneered getopt() */
while ((ch = getopt(argc, argv, "c:N:sz:")) != -1) {
switch (ch) {
case 'c':
/* XXXRTH temporary syntax */
dbi = isc_mem_get(ns_g_mctx, sizeof *dbi);
if (dbi == NULL)
early_fatal("creating cache info failed");
dbi->path = isc_mem_strdup(ns_g_mctx, optarg);
if (dbi->path == NULL)
early_fatal("out of memory");
dbi->origin = isc_mem_strdup(ns_g_mctx, ".");
if (dbi->origin == NULL)
early_fatal("out of memory");
dbi->master = NULL;
dbi->iscache = ISC_TRUE;
dbi->isslave = ISC_FALSE;
dbi->view = NULL;
dbi->db = NULL;
ISC_LINK_INIT(dbi, link);
ISC_LIST_APPEND(ns_g_dbs, dbi, link);
break;
case 'N':
ns_g_cpus = atoi(optarg);
if (ns_g_cpus == 0)
ns_g_cpus = 1;
break;
case 's':
/* XXXRTH temporary syntax */
want_stats = ISC_TRUE;
break;
case 'z':
/* XXXRTH temporary syntax */
dbi = isc_mem_get(ns_g_mctx, sizeof *dbi);
if (dbi == NULL)
early_fatal("creating zone info failed");
argtext = isc_mem_strdup(ns_g_mctx, optarg);
if (argtext == NULL)
early_fatal("out of memory");
mastertext = strrchr(argtext, '@');
if (mastertext == NULL) {
dbi->master = NULL;
dbi->isslave = ISC_FALSE;
} else {
*mastertext++ = '\0';
dbi->master = isc_mem_strdup(ns_g_mctx,
mastertext);
if (dbi->master == NULL)
early_fatal("out of memory");
RUNTIME_CHECK(dbi->master != NULL);
dbi->isslave = ISC_TRUE;
}
origintext = strrchr(argtext, '/');
if (origintext == NULL)
origintext = argtext;
else
origintext++; /* Skip '/'. */
dbi->path = isc_mem_strdup(ns_g_mctx, argtext);
if (dbi->path == NULL)
early_fatal("out of memory");
dbi->origin = isc_mem_strdup(ns_g_mctx, origintext);
if (dbi->origin == NULL)
early_fatal("out of memory");
dbi->view = NULL;
dbi->db = NULL;
dbi->iscache = ISC_FALSE;
isc_mem_free(ns_g_mctx, argtext);
ISC_LINK_INIT(dbi, link);
ISC_LIST_APPEND(ns_g_dbs, dbi, link);
break;
case '?':
usage();
early_fatal("unknown command line argument");
break;
default:
early_fatal("getopt() returned %d", ch);
}
}
argc -= optind;
argv += optind;
if (argc > 1) {
usage();
early_fatal("extra command line arguments");
}
}
static isc_result_t
create_managers() {
isc_result_t result;
result = isc_taskmgr_create(ns_g_mctx, ns_g_cpus, 0, &ns_g_taskmgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_taskmgr_create() failed: %s\n",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
result = isc_timermgr_create(ns_g_mctx, &ns_g_timermgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_timermgr_create() failed: %s\n",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
result = isc_socketmgr_create(ns_g_mctx, &ns_g_socketmgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"isc_socketmgr_create() failed: %s\n",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
result = ns_clientmgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
&ns_g_clientmgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_clientmgr_create() failed: %s\n",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
result = ns_interfacemgr_create(ns_g_mctx, ns_g_taskmgr,
ns_g_socketmgr, ns_g_clientmgr,
&ns_g_interfacemgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_interfacemgr_create() failed: %s\n",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
return (ISC_R_SUCCESS);
}
static void
destroy_managers(void) {
/*
* The interface manager owns tasks, so we have to destroy it before
* we destroy the task manager.
*/
ns_interfacemgr_destroy(&ns_g_interfacemgr);
/*
* isc_taskmgr_destroy() will block until all tasks have exited,
*/
isc_taskmgr_destroy(&ns_g_taskmgr);
isc_timermgr_destroy(&ns_g_timermgr);
isc_socketmgr_destroy(&ns_g_socketmgr);
ns_clientmgr_destroy(&ns_g_clientmgr);
}
static void
setup() {
isc_result_t result;
ISC_LIST_INIT(ns_g_viewlist);
result = isc_rwlock_init(&ns_g_viewlock, 0, 0);
if (result != ISC_R_SUCCESS)
early_fatal("isc_rwlock_init() failed: %s",
isc_result_totext(result));
result = create_managers();
if (result != ISC_R_SUCCESS)
early_fatal("create_managers() failed: %s",
isc_result_totext(result));
result = ns_server_init();
if (result != ISC_R_SUCCESS)
early_fatal("ns_server_init() failed: %s",
isc_result_totext(result));
result = dns_tsig_init(ns_g_mctx);
if (result != ISC_R_SUCCESS)
early_fatal("dns_tsig_init() failed: %s",
isc_result_totext(result));
}
static void
cleanup() {
destroy_managers();
dns_tsig_destroy();
#if 0
isc_rwlock_destroy(&ns_g_viewlock);
#endif
}
int
main(int argc, char *argv[]) {
isc_result_t result;
result = isc_app_start();
if (result != ISC_R_SUCCESS)
early_fatal("isc_app_start() failed: %s",
isc_result_totext(result));
result = isc_mem_create(0, 0, &ns_g_mctx);
if (result != ISC_R_SUCCESS)
early_fatal("isc_mem_create() failed: %s",
isc_result_totext(result));
dns_result_register();
dst_result_register();
parse_command_line(argc, argv);
setup();
/*
* Start things running and then wait for a shutdown request.
*/
result = isc_app_run();
if (result != ISC_R_SUCCESS)
UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_app_run(): %s",
isc_result_totext(result));
cleanup();
if (want_stats)
isc_mem_stats(ns_g_mctx, stdout);
isc_mem_destroy(&ns_g_mctx);
isc_app_finish();
return (0);
}

View File

@@ -1,9 +0,0 @@
options {
directory "/var/named";
};
zone "vix.com" {
type master;
file "whatever";
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,382 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/rwlock.h>
#include <isc/mem.h>
#include <isc/task.h>
#include <isc/thread.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/timer.h>
#include <isc/app.h>
#include <dns/types.h>
#include <dns/result.h>
#include <dns/master.h>
#include <dns/name.h>
#include <dns/fixedname.h>
#include <dns/rdata.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/compress.h>
#include <dns/db.h>
#include <dns/dbtable.h>
#include <dns/message.h>
#include <dns/journal.h>
#include <dns/view.h>
#include <named/types.h>
#include <named/globals.h>
#include <named/server.h>
#include <named/xfrin.h>
#include "../../isc/util.h" /* XXXRTH */
static isc_task_t * server_task;
static dns_db_t * version_db;
static dns_view_t * version_view;
static dns_result_t
load(ns_dbinfo_t *dbi, char *view_name) {
dns_fixedname_t forigin;
dns_name_t *origin;
dns_result_t result;
isc_buffer_t source;
size_t len;
dns_view_t *view;
/*
* XXXRTH View list code will move to its own module soon.
*/
RWLOCK(&ns_g_viewlock, isc_rwlocktype_read);
for (view = ISC_LIST_HEAD(ns_g_viewlist);
view != NULL;
view = ISC_LIST_NEXT(view, link)) {
if (strcasecmp(view_name, view->name) == 0) {
dns_view_attach(view, &dbi->view);
break;
}
}
RWUNLOCK(&ns_g_viewlock, isc_rwlocktype_read);
if (view == NULL)
return (DNS_R_NOTFOUND);
len = strlen(dbi->origin);
isc_buffer_init(&source, dbi->origin, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, len);
dns_fixedname_init(&forigin);
origin = dns_fixedname_name(&forigin);
result = dns_name_fromtext(origin, &source, dns_rootname, ISC_FALSE,
NULL);
if (result != DNS_R_SUCCESS)
goto view_detach;
result = dns_db_create(ns_g_mctx, "rbt", origin, dbi->iscache,
view->rdclass, 0, NULL, &dbi->db);
if (result != DNS_R_SUCCESS)
goto view_detach;
printf("loading %s (%s)\n", dbi->path, dbi->origin);
result = dns_db_load(dbi->db, dbi->path);
if (result != DNS_R_SUCCESS) {
if (dbi->isslave) {
/* Ignore the error, just leave dbi->db == NULL. */
dns_db_detach(&dbi->db);
return (DNS_R_SUCCESS);
} else {
goto db_detach;
}
}
printf("loaded\n");
printf("journal rollforward\n");
result = dns_journal_rollforward(ns_g_mctx, dbi->db, "journal");
if (result != DNS_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_rollforward(): %s",
dns_result_totext(result));
/* Continue anyway... */
}
if (dbi->iscache) {
/*
* XXXRTH We must ensure that this is safe, since the
* field is not covered by the view's lock.
*
* We're OK for now, but we'll have to be careful
* when we start processing the config file.
*/
INSIST(view->cachedb == NULL);
dns_db_attach(dbi->db, &view->cachedb);
} else if (dns_dbtable_add(view->dbtable, dbi->db) != DNS_R_SUCCESS)
goto db_detach;
return (DNS_R_SUCCESS);
db_detach:
dns_db_detach(&dbi->db);
view_detach:
dns_view_detach(&dbi->view);
return (result);
}
static isc_result_t
load_version(void) {
dns_fixedname_t forigin;
dns_name_t *origin;
dns_result_t result, eresult;
isc_buffer_t source;
size_t len;
int soacount, nscount;
dns_rdatacallbacks_t callbacks;
dns_view_t *view;
char version_text[1024];
sprintf(version_text, "version 0 CHAOS TXT \"%s\"\n", ns_g_version);
/*
* XXXRTH View list code will move to its own module soon.
*/
RWLOCK(&ns_g_viewlock, isc_rwlocktype_read);
for (view = ISC_LIST_HEAD(ns_g_viewlist);
view != NULL;
view = ISC_LIST_NEXT(view, link)) {
if (strcasecmp(view->name, "default/CHAOS") == 0) {
version_view = NULL;
dns_view_attach(view, &version_view);
break;
}
}
RWUNLOCK(&ns_g_viewlock, isc_rwlocktype_read);
if (view == NULL)
return (DNS_R_NOTFOUND);
len = strlen("bind.");
isc_buffer_init(&source, "bind.", len, ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, len);
dns_fixedname_init(&forigin);
origin = dns_fixedname_name(&forigin);
result = dns_name_fromtext(origin, &source, dns_rootname, ISC_FALSE,
NULL);
if (result != DNS_R_SUCCESS)
goto view_detach;
version_db = NULL;
result = dns_db_create(ns_g_mctx, "rbt", origin, ISC_FALSE,
view->rdclass, 0, NULL, &version_db);
if (result != DNS_R_SUCCESS)
goto view_detach;
dns_rdatacallbacks_init(&callbacks);
len = strlen(version_text);
isc_buffer_init(&source, version_text, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, len);
result = dns_db_beginload(version_db, &callbacks.add, &callbacks.add_private);
if (result != DNS_R_SUCCESS)
return (result);
result = dns_master_loadbuffer(&source, &version_db->origin, &version_db->origin,
version_db->rdclass, ISC_FALSE, &soacount,
&nscount, &callbacks, version_db->mctx);
eresult = dns_db_endload(version_db, &callbacks.add_private);
if (result == ISC_R_SUCCESS)
result = eresult;
if (result != ISC_R_SUCCESS)
goto db_detach;
if (dns_dbtable_add(version_view->dbtable, version_db) != DNS_R_SUCCESS)
goto db_detach;
return (DNS_R_SUCCESS);
db_detach:
dns_db_detach(&version_db);
view_detach:
dns_view_detach(&version_view);
return (result);
}
static isc_result_t
load_all(void) {
isc_result_t result = ISC_R_SUCCESS;
ns_dbinfo_t *dbi;
result = load_version();
if (result != ISC_R_SUCCESS)
return (result);
for (dbi = ISC_LIST_HEAD(ns_g_dbs);
dbi != NULL;
dbi = ISC_LIST_NEXT(dbi, link)) {
result = load(dbi, "default/IN");
if (result != ISC_R_SUCCESS)
break;
}
return (result);
}
static void
unload_all(void) {
ns_dbinfo_t *dbi, *dbi_next;
for (dbi = ISC_LIST_HEAD(ns_g_dbs); dbi != NULL; dbi = dbi_next) {
dbi_next = ISC_LIST_NEXT(dbi, link);
if (dbi->view != NULL) {
INSIST(dbi->db != NULL);
if (dns_db_iszone(dbi->db))
dns_dbtable_remove(dbi->view->dbtable,
dbi->db);
dns_db_detach(&dbi->db);
dns_view_detach(&dbi->view);
}
isc_mem_free(ns_g_mctx, dbi->path);
isc_mem_free(ns_g_mctx, dbi->origin);
if (dbi->master != NULL)
isc_mem_free(ns_g_mctx, dbi->master);
ISC_LIST_UNLINK(ns_g_dbs, dbi, link);
isc_mem_put(ns_g_mctx, dbi, sizeof *dbi);
}
if (version_view != NULL) {
INSIST(version_db != NULL);
dns_dbtable_remove(version_view->dbtable, version_db);
dns_db_detach(&version_db);
dns_view_detach(&version_view);
}
}
static void
load_configuration(void) {
isc_result_t result;
/*
* XXXRTH loading code below is temporary; it
* will be replaced by proper config file processing.
*/
result = load_all();
if (result != ISC_R_SUCCESS) {
/* XXXRTH */
printf("load_all(): %s\n", isc_result_totext(result));
}
ns_interfacemgr_scan(ns_g_interfacemgr);
xfrin_test();
}
static void
run_server(isc_task_t *task, isc_event_t *event) {
(void)task;
printf("server running\n");
load_configuration();
isc_event_free(&event);
}
static void
shutdown_server(isc_task_t *task, isc_event_t *event) {
dns_view_t *view, *view_next;
(void)task;
printf("server shutting down\n");
RWLOCK(&ns_g_viewlock, isc_rwlocktype_write);
unload_all();
for (view = ISC_LIST_HEAD(ns_g_viewlist);
view != NULL;
view = view_next) {
view_next = ISC_LIST_NEXT(view, link);
ISC_LIST_UNLINK(ns_g_viewlist, view, link);
dns_view_detach(&view);
}
ISC_LIST_INIT(ns_g_viewlist);
RWUNLOCK(&ns_g_viewlock, isc_rwlocktype_write);
isc_task_detach(&server_task);
isc_event_free(&event);
}
isc_result_t
ns_server_init(void) {
isc_result_t result;
dns_view_t *view, *view_next;
/*
* XXXRTH The view management code here will probably move to its
* own module when we start using the config file.
*/
view = NULL;
result = dns_view_create(ns_g_mctx, dns_rdataclass_in, "default/IN",
NULL, NULL, &view);
if (result != ISC_R_SUCCESS)
goto cleanup_views;
ISC_LIST_APPEND(ns_g_viewlist, view, link);
view = NULL;
result = dns_view_create(ns_g_mctx, dns_rdataclass_ch, "default/CHAOS",
NULL, NULL, &view);
if (result != ISC_R_SUCCESS)
goto cleanup_views;
ISC_LIST_APPEND(ns_g_viewlist, view, link);
result = isc_task_create(ns_g_taskmgr, ns_g_mctx, 0, &server_task);
if (result != ISC_R_SUCCESS)
goto cleanup_views;
result = isc_task_onshutdown(server_task, shutdown_server, NULL);
if (result != ISC_R_SUCCESS)
goto cleanup_task;
result = isc_app_onrun(ns_g_mctx, server_task, run_server, NULL);
if (result != ISC_R_SUCCESS)
goto cleanup_task;
return (ISC_R_SUCCESS);
cleanup_task:
isc_task_detach(&server_task);
cleanup_views:
for (view = ISC_LIST_HEAD(ns_g_viewlist);
view != NULL;
view = view_next) {
view_next = ISC_LIST_NEXT(view, link);
ISC_LIST_UNLINK(ns_g_viewlist, view, link);
dns_view_detach(&view);
}
return (result);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,29 +0,0 @@
Makefile
.libs
*.la
*.lo
name_test
rwlock_test
mem_test
sock_test
sym_test
lex_test
task_test
shutdown_test
timer_test
wire_test
rdata_test
master_test
rbt_test
db_test
compress_test
t_journal
mempool_test
res_test
dispatch_test
dispatch_tcp_test
sdig
nxtify
serial_test
signer
zone_test

View File

@@ -1,185 +0,0 @@
# Copyright (C) 1998, 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM 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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
CINCLUDES = -I../../lib/isc/unix/include \
-I${srcdir}/../../lib/isc/unix/include \
-I${srcdir}/../../lib/isc/pthreads/include \
-I${srcdir}/../../lib/isc/include \
-I../../lib/dns/include \
-I${srcdir}/../../lib/dns/include \
-I${srcdir}/../../lib/dns/sec/dst/include
CDEFINES =
CWARNINGS =
DNSLIBS = ../../lib/dns/libdns.@A@
ISCLIBS = ../../lib/isc/libisc.@A@
DNSDEPLIBS = ../../lib/dns/libdns.@A@
ISCDEPLIBS = ../../lib/isc/libisc.@A@
LIBS = @LIBS@
SUBDIRS = master names rbt tasks db timers mem dst
TARGETS = sdig \
nxtify \
signer \
res_test \
lex_test \
name_test \
sock_test \
sym_test \
task_test \
shutdown_test \
timer_test \
rbt_test \
rdata_test \
rwlock_test \
wire_test \
master_test \
db_test \
compress_test \
mempool_test \
dispatch_test \
dispatch_tcp_test \
serial_test \
zone_test
SRCS = sdig.c \
nxtify.c \
signer.c \
res_test.c \
lex_test.c \
name_test.c \
sock_test.c \
sym_test.c \
task_test.c \
shutdown_test.c \
timer_test.c \
rbt_test.c \
rdata_test.c \
rwlock_test.c \
wire_test.c \
master_test.c \
db_test.c \
compress_test.c \
mempool_test.c \
dispatch_test.c \
dispatch_tcp_test.c \
printmsg.c \
serial_test.c \
zone_test.c
@BIND9_MAKE_RULES@
sdig: sdig.o printmsg.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ sdig.o printmsg.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
nxtify: nxtify.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ nxtify.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
signer: signer.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ signer.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
res_test: res_test.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ res_test.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
lex_test: lex_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ lex_test.o \
${ISCLIBS} ${LIBS}
name_test: name_test.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ name_test.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
sock_test: sock_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ sock_test.o \
${ISCLIBS} ${LIBS}
sym_test: sym_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ sym_test.o \
${ISCLIBS} ${LIBS}
task_test: task_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ task_test.o \
${ISCLIBS} ${LIBS}
shutdown_test: shutdown_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ shutdown_test.o \
${ISCLIBS} ${LIBS}
timer_test: timer_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ timer_test.o \
${ISCLIBS} ${LIBS}
rbt_test: rbt_test.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ rbt_test.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
rdata_test: rdata_test.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ rdata_test.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
rwlock_test: rwlock_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ rwlock_test.o \
${ISCLIBS} ${LIBS}
wire_test: wire_test.o printmsg.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ wire_test.o printmsg.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
master_test: master_test.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ master_test.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
db_test: db_test.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ db_test.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
compress_test: compress_test.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ compress_test.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
mempool_test: mempool_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ mempool_test.o \
${ISCLIBS} ${LIBS}
serial_test: serial_test.o ${ISCDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ serial_test.o \
${ISCLIBS} ${LIBS}
zone_test: zone_test.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ zone_test.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
dispatch_test: dispatch_test.o printmsg.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ dispatch_test.o printmsg.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
dispatch_tcp_test: dispatch_tcp_test.o printmsg.o ${ISCDEPLIBS} ${DNSDEPLIBS}
${LIBTOOL} ${CC} ${CFLAGS} -o $@ dispatch_tcp_test.o printmsg.o \
${DNSLIBS} ${ISCLIBS} ${LIBS}
clean distclean::
rm -f ${TARGETS}
rm -f t_journal

View File

@@ -1,209 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <dns/compress.h>
#include <dns/name.h>
unsigned char plain1[] = "\003yyy\003foo";
unsigned char plain2[] = "\003bar\003yyy\003foo";
unsigned char plain3[] = "\003xxx\003bar\003foo";
unsigned char plain[] =
"\003yyy\003foo\0\003bar\003yyy\003foo\0\003bar\003yyy\003foo\0\003xxx\003bar\003foo";
/* result concatenate (plain1, plain2, plain2, plain3) */
unsigned char bit1[] = "\101\010b";
unsigned char bit2[] = "\101\014b\260";
unsigned char bit3[] = "\101\020b\264";
unsigned char bit[] = "\101\010b\0\101\014b\260\0\101\014b\260\0\101\020b\264";
int raw = 0;
int verbose = 0;
void test(unsigned int, dns_name_t *, dns_name_t *, dns_name_t *,
unsigned char *, unsigned int);
int
main(int argc, char *argv[]) {
dns_name_t name1;
dns_name_t name2;
dns_name_t name3;
isc_region_t region;
int c;
while ((c = getopt(argc, argv, "rv")) != -1) {
switch (c) {
case 'r':
raw++;
break;
case 'v':
verbose++;
break;
}
}
dns_name_init(&name1, NULL);
region.base = plain1;
region.length = sizeof plain1;
dns_name_fromregion(&name1, &region);
dns_name_init(&name2, NULL);
region.base = plain2;
region.length = sizeof plain2;
dns_name_fromregion(&name2, &region);
dns_name_init(&name3, NULL);
region.base = plain3;
region.length = sizeof plain3;
dns_name_fromregion(&name3, &region);
test(DNS_COMPRESS_NONE, &name1, &name2, &name3, plain, sizeof plain);
test(DNS_COMPRESS_GLOBAL14, &name1, &name2, &name3, plain,
sizeof plain);
test(DNS_COMPRESS_GLOBAL, &name1, &name2, &name3, plain, sizeof plain);
test(DNS_COMPRESS_LOCAL, &name1, &name2, &name3, plain, sizeof plain);
test(DNS_COMPRESS_ALL, &name1, &name2, &name3, plain, sizeof plain);
dns_name_init(&name1, NULL);
region.base = bit1;
region.length = sizeof bit1;
dns_name_fromregion(&name1, &region);
dns_name_init(&name2, NULL);
region.base = bit2;
region.length = sizeof bit2;
dns_name_fromregion(&name2, &region);
dns_name_init(&name3, NULL);
region.base = bit3;
region.length = sizeof bit3;
dns_name_fromregion(&name3, &region);
test(DNS_COMPRESS_NONE, &name1, &name2, &name3, bit, sizeof bit);
test(DNS_COMPRESS_GLOBAL14, &name1, &name2, &name3, bit, sizeof bit);
test(DNS_COMPRESS_GLOBAL, &name1, &name2, &name3, bit, sizeof bit);
test(DNS_COMPRESS_LOCAL, &name1, &name2, &name3, bit, sizeof bit);
test(DNS_COMPRESS_ALL, &name1, &name2, &name3, bit, sizeof bit);
exit(0);
}
void
test(unsigned int allowed, dns_name_t *name1, dns_name_t *name2,
dns_name_t *name3, unsigned char *result, unsigned int length)
{
isc_mem_t *mctx = NULL;
dns_compress_t cctx;
dns_decompress_t dctx;
isc_buffer_t source;
isc_buffer_t target;
dns_name_t name;
unsigned char buf1[1024];
unsigned char buf2[1024];
if (verbose) {
char *s;
switch (allowed) {
case DNS_COMPRESS_NONE: s = "DNS_COMPRESS_NONE"; break;
case DNS_COMPRESS_GLOBAL14: s = "DNS_COMPRESS_GLOBAL14"; break;
case DNS_COMPRESS_GLOBAL16: s = "DNS_COMPRESS_GLOBAL16"; break;
case DNS_COMPRESS_GLOBAL: s = "DNS_COMPRESS_GLOBAL"; break;
case DNS_COMPRESS_LOCAL: s = "DNS_COMPRESS_LOCAL"; break;
case DNS_COMPRESS_ALL: s = "DNS_COMPRESS_ALL"; break;
default: s = "UNKOWN"; break;
}
fprintf(stdout, "Allowed = %s\n", s);
}
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
isc_buffer_init(&source, buf1, sizeof buf1, ISC_BUFFERTYPE_BINARY);
RUNTIME_CHECK(dns_compress_init(&cctx, -1, mctx) == DNS_R_SUCCESS);
RUNTIME_CHECK(dns_name_towire(name1, &cctx, &source) == DNS_R_SUCCESS);
RUNTIME_CHECK(dns_compress_localinit(&cctx, name1, &source) ==
DNS_R_SUCCESS);
dns_compress_setmethods(&cctx, allowed);
RUNTIME_CHECK(dns_name_towire(name2, &cctx, &source) == DNS_R_SUCCESS);
RUNTIME_CHECK(dns_name_towire(name2, &cctx, &source) == DNS_R_SUCCESS);
RUNTIME_CHECK(dns_name_towire(name3, &cctx, &source) == DNS_R_SUCCESS);
dns_compress_localinvalidate(&cctx);
dns_compress_rollback(&cctx, 0); /* testing only */
dns_compress_invalidate(&cctx);
if (raw) {
unsigned int i;
for (i = 0 ; i < source.used ; /* */ ) {
fprintf(stdout, "%02x",
((unsigned char *)source.base)[i]);
if ((++i % 20) == 0)
fputs("\n", stdout);
else
if (i == source.used)
fputs("\n", stdout);
else
fputs(" ", stdout);
}
}
isc_buffer_setactive(&source, source.used);
isc_buffer_init(&target, buf2, sizeof buf2, ISC_BUFFERTYPE_BINARY);
dns_decompress_init(&dctx, -1, ISC_TRUE);
dns_name_init(&name, NULL);
RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE,
&target) == DNS_R_SUCCESS);
dns_decompress_setmethods(&dctx, allowed);
dns_decompress_localinit(&dctx, &name, &source);
RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE,
&target) == DNS_R_SUCCESS);
RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE,
&target) == DNS_R_SUCCESS);
RUNTIME_CHECK(dns_name_fromwire(&name, &source, &dctx, ISC_FALSE,
&target) == DNS_R_SUCCESS);
dns_decompress_localinvalidate(&dctx);
dns_decompress_invalidate(&dctx);
if (raw) {
unsigned int i;
for (i = 0 ; i < target.used ; /* */ ) {
fprintf(stdout, "%02x",
((unsigned char *)target.base)[i]);
if ((++i % 20) == 0)
fputs("\n", stdout);
else
if (i == target.used)
fputs("\n", stdout);
else
fputs(" ", stdout);
}
fputs("\n", stdout);
fflush(stdout);
}
RUNTIME_CHECK(target.used == length);
RUNTIME_CHECK(memcmp(target.base, result, target.used) == 0);
isc_mem_destroy(&mctx);
}

View File

@@ -1,3 +0,0 @@
Makefile
t_db
.libs

View File

@@ -1,48 +0,0 @@
# Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM 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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
CINCLUDES = -I${srcdir}/../../../lib/isc/unix/include \
-I${srcdir}/../../../lib/isc/pthreads/include \
-I${srcdir}/../../../lib/isc/include \
-I${srcdir}/../../../lib/dns/include \
-I${srcdir}/../../../lib/tests/include
CDEFINES =
CWARNINGS =
LIBS = ../../../lib/dns/libdns.@A@ \
../../../lib/isc/libisc.@A@ \
../../../lib/tests/libt_api.a \
@LIBS@
TARGETS = t_db
@BIND9_MAKE_RULES@
t_db: t_db.o
${LIBTOOL} ${CC} -o $@ t_db.o ${LIBS}
test:
-@./t_db -c @top_srcdir@/t_config -a >> ../t_journal 2>&1
testhelp:
@./t_db -h
clean distclean::
rm -f ${TARGETS}

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,9 +0,0 @@
#
# test data for dns_db_class
#
# format:
# filename class
#
#
dns_db_class_1.data in
# dns_db_class_1.data any

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_closeversion test 1
#
# format:
# filename type origin class cache new_name new_type existing_name existing_type
#
dns_db_closeversion_1.data rbt vix.com. in zone a.b.c.vix.com. A a.vix.com. NS

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_closeversion test 2
#
# format:
# filename type origin class cache new_name new_type existing_name existing_type
#
dns_db_closeversion_1.data rbt vix.com. in zone a.b.c.vix.com. A a.vix.com. NS

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a.b.c.vix.com. a 1.2.3.4
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_currentversion
#
# format:
# filename findname findtype
#
dns_db_currentversion.data rbt vix.com. IN zone a.b.c.vix.com. A

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_expirenode
#
# format:
# filename type origin class existing_name existing_type
#
dns_db_expirenode.data rbt vix.com. in a.vix.com. 10000 0 DNS_R_NOTFOUND

View File

@@ -1,12 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4
a.b.c in ns b

View File

@@ -1,10 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a.b.c in NS ns1.vix.com.
a.b.c in A 1.2.3.4

View File

@@ -1,8 +0,0 @@
#
# test data for dns_db_find expiration time handling
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_10.data rbt vix.com. in cache a.b.c.vix.com. NS 0 1010 DNS_R_NOTFOUND
dns_db_find_10.data rbt vix.com. in cache a.b.c.vix.com. NS 0 0 DNS_R_SUCCESS

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_find best match
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_1.data rbt vix.com. in zone a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION

View File

@@ -1,9 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
fx in ns a.fx.vix.com.
a.fx in a 1.2.3.4

View File

@@ -1,8 +0,0 @@
#
# test data for dns_db_find DNS_R_GLUE
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_2.data rbt vix.com. in zone a.fx.vix.com. A DNS_DBFIND_GLUEOK 0 DNS_R_GLUE
dns_db_find_2.data rbt vix.com. in zone a.fx.vix.com. NS DNS_DBFIND_GLUEOK 0 DNS_R_GLUE

View File

@@ -1,10 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a.b.c in ns b
a.a.b.c in a 10.0.0.1
b in a 10.0.0.2

View File

@@ -1,9 +0,0 @@
#
# test data for dns_db_find DNS_R_DELAGATION
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_3.data rbt vix.com. in zone a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION
dns_db_find_3.data rbt vix.com. in zone a.a.b.c.vix.com. NS DNS_DB_GLUEOK 0 DNS_R_DELEGATION
dns_db_find_3.data rbt vix.com. in zone a.a.b.c.vix.com. A DNS_DB_GLUEOK 0 DNS_R_DELEGATION

View File

@@ -1,9 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a.b.c in ns b
b.a.b.c in a 10.0.0.2

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_find DNS_R_ZONECUT
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_4.data rbt vix.com. in zone a.b.c.vix.com. ANY 0 0 DNS_R_ZONECUT

View File

@@ -1,10 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a.b.c. in DNAME x.y.z.
a.x.y.z. in A 1.2.3.4

View File

@@ -1,8 +0,0 @@
#
# test data for dns_db_find DNS_R_DNAME
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_5.data rbt vix.com. in zone x.a.b.c. ANY 0 0 DNS_R_DNAME
dns_db_find_5.data rbt vix.com. in zone a.a.b.c. ANY 0 0 DNS_R_DNAME

View File

@@ -1,10 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
exploder in CNAME mx
mx in A 1.2.3.4

View File

@@ -1,8 +0,0 @@
#
# test data for dns_db_find DNS_R_CNAME
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_6.data rbt vix.com. in zone exploder.vix.com. A 0 0 DNS_R_CNAME
dns_db_find_6.data rbt vix.com. in zone exploder.vix.com. ANY 0 0 DNS_R_CNAME

View File

@@ -1,13 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a.b.c.d in A 1.2.3.4
a.b.c. in A 1.2.3.4
a.b in A 1.2.3.4
a in NS ns1.vix.com.

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_find DNS_R_NXDOMAIN
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_7.data rbt vix.com. in zone a.b.c.vix.com. ANY 0 0 DNS_R_NXDOMAIN

View File

@@ -1,13 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a.b.c.d in A 1.2.3.4
a.b.c in A 1.2.3.4
a.b in A 1.2.3.4
a in NS ns1.vix.com.

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_find DNS_R_NXRDATASET
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_8.data rbt vix.com. in zone a.b.c.vix.com. NS 0 0 DNS_R_NXRDATASET

View File

@@ -1,14 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a.b.c.d in NS ns1.vix.com.
a.b.c in A 1.2.3.4
a.b in NS ns1.vix.com.
a in NS ns1.vix.com.
a.b.c. in NS ns1.vix.com.

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_find DNS_R_NOTFOUND
#
# format:
# dbfile dbtype dborigin dbclass dbcache findname findtype findopts findtime expected_results
#
dns_db_find_9.data rbt vix.com. in cache a.b.c.vix.com. NS 0 0 DNS_R_NOTFOUND

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,9 +0,0 @@
#
# test data for dns_db_findnode, case DNS_R_SUCCESS
#
# format:
# filename type origin class cache existingname rdatatype
#
dns_db_findnode_1.data rbt vix.com. in zone a.vix.com. NS DNS_R_SUCCESS
dns_db_findnode_1.data rbt vix.com. in zone b.vix.com. A DNS_R_SUCCESS
dns_db_findnode_1.data rbt vix.com. in zone c.vix.com. A DNS_R_NOTFOUND

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_findnode 2
#
# format:
# filename type origin class cache newname
#
dns_db_findnode_2.data rbt vix.com. in zone a.b.c.vix.com.

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_iscache test 1
#
# format:
# filename db_type origin class
#
dns_db_iscache_1.data rbt . in

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_iscache test 1
#
# format:
# filename db_type origin class
#
dns_db_iscache_2.data rbt . in

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_iszone test 1
#
# format:
# filename db_type origin class
#
dns_db_iszone_1.data rbt . in

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_iszone test 2
#
# format:
# filename db_type origin class
#
dns_db_iszone_2.data rbt . in

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_load
#
# format:
# filename type origin cache class findname expected_result
#
dns_db_load_1.data rbt . zone in DNS_R_SUCCESS a. A DNS_R_DELEGATION

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,7 +0,0 @@
#
# test data for dns_db_newversion
#
# format:
# filename type origin class cache newname newtype
#
dns_db_newversion.data rbt vix.com. in zone a.b.c.vix.com. A

View File

@@ -1,11 +0,0 @@
$TTL 1000
@ in soa localhost. postmaster.localhost. (
1993050801 ;serial
3600 ;refresh
1800 ;retry
604800 ;expiration
3600 ) ;minimum
a in ns ns.vix.com.
a in ns ns2.vix.com.
a in ns ns3.vix.com.
b in a 1.2.3.4

View File

@@ -1,8 +0,0 @@
#
# test data for dns_db_origin
#
# format:
# filename origin
#
dns_db_origin_1.data .
dns_db_origin_1.data vix.com.

File diff suppressed because it is too large Load Diff

View File

@@ -1,908 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
/*
* Principal Author: Bob Halley
*/
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h> /* XXX Naughty. */
#include <unistd.h> /* XXX Naughty. */
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/boolean.h>
#include <isc/region.h>
#include <isc/list.h>
#include <isc/result.h>
#include <dns/types.h>
#include <dns/result.h>
#include <dns/name.h>
#include <dns/fixedname.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdatasetiter.h>
#include <dns/compress.h>
#include <dns/db.h>
#include <dns/dbiterator.h>
#include <dns/dbtable.h>
#define MAXHOLD 100
#define MAXVERSIONS 100
typedef struct dbinfo {
dns_db_t * db;
dns_dbversion_t * version;
dns_dbversion_t * wversion;
dns_dbversion_t * rversions[MAXVERSIONS];
int rcount;
dns_dbnode_t * hold_nodes[MAXHOLD];
int hold_count;
dns_dbiterator_t * dbiterator;
dns_dbversion_t * iversion;
int pause_every;
isc_boolean_t ascending;
ISC_LINK(struct dbinfo) link;
} dbinfo;
static isc_mem_t * mctx = NULL;
static char dbtype[128];
static dns_dbtable_t * dbtable;
static ISC_LIST(dbinfo) dbs;
static dbinfo * cache_dbi = NULL;
static int pause_every = 0;
static isc_boolean_t ascending = ISC_TRUE;
static void
print_result(char *message, isc_result_t result) {
size_t len;
if (message == NULL) {
len = 0;
message = "";
}
len = strlen(message);
printf("%s%sresult %08x: %s\n", message, (len == 0) ? "" : " ", result,
isc_result_totext(result));
}
static void
print_rdataset(dns_name_t *name, dns_rdataset_t *rdataset) {
isc_buffer_t text;
char t[1000];
isc_result_t result;
isc_region_t r;
isc_buffer_init(&text, t, sizeof t, ISC_BUFFERTYPE_TEXT);
result = dns_rdataset_totext(rdataset, name, ISC_FALSE, ISC_FALSE,
&text);
isc_buffer_used(&text, &r);
if (result == DNS_R_SUCCESS)
printf("%.*s", (int)r.length, (char *)r.base);
else
print_result("", result);
}
static void
print_rdatasets(dns_name_t *name, dns_rdatasetiter_t *rdsiter) {
isc_result_t result;
dns_rdataset_t rdataset;
dns_rdataset_init(&rdataset);
result = dns_rdatasetiter_first(rdsiter);
while (result == DNS_R_SUCCESS) {
dns_rdatasetiter_current(rdsiter, &rdataset);
print_rdataset(name, &rdataset);
dns_rdataset_disassociate(&rdataset);
result = dns_rdatasetiter_next(rdsiter);
}
if (result != DNS_R_NOMORE)
print_result("", result);
}
static dbinfo *
select_db(char *origintext) {
dns_fixedname_t forigin;
dns_name_t *origin;
isc_buffer_t source;
size_t len;
dbinfo *dbi;
isc_result_t result;
if (strcasecmp(origintext, "cache") == 0) {
if (cache_dbi == NULL)
printf("the cache does not exist\n");
return (cache_dbi);
}
len = strlen(origintext);
isc_buffer_init(&source, origintext, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, len);
dns_fixedname_init(&forigin);
origin = dns_fixedname_name(&forigin);
result = dns_name_fromtext(origin, &source, dns_rootname, ISC_FALSE,
NULL);
if (result != DNS_R_SUCCESS) {
print_result("bad name", result);
return (NULL);
}
for (dbi = ISC_LIST_HEAD(dbs);
dbi != NULL;
dbi = ISC_LIST_NEXT(dbi, link)) {
if (dns_name_compare(dns_db_origin(dbi->db), origin) == 0)
break;
}
return (dbi);
}
static void
list(dbinfo *dbi, char *seektext) {
dns_fixedname_t fname;
dns_name_t *name;
dns_dbnode_t *node;
dns_rdatasetiter_t *rdsiter;
isc_result_t result;
int i;
size_t len;
dns_fixedname_t fseekname;
dns_name_t *seekname;
isc_buffer_t source;
dns_fixedname_init(&fname);
name = dns_fixedname_name(&fname);
if (dbi->dbiterator == NULL) {
INSIST(dbi->iversion == NULL);
if (dns_db_iszone(dbi->db)) {
if (dbi->version != NULL)
dns_db_attachversion(dbi->db, dbi->version,
&dbi->iversion);
else
dns_db_currentversion(dbi->db, &dbi->iversion);
}
result = dns_db_createiterator(dbi->db, ISC_FALSE,
&dbi->dbiterator);
if (result == DNS_R_SUCCESS) {
if (seektext != NULL) {
len = strlen(seektext);
isc_buffer_init(&source, seektext, len,
ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, len);
dns_fixedname_init(&fseekname);
seekname = dns_fixedname_name(&fseekname);
result = dns_name_fromtext(seekname, &source,
dns_db_origin(
dbi->db),
ISC_FALSE,
NULL);
if (result == ISC_R_SUCCESS)
result = dns_dbiterator_seek(
dbi->dbiterator,
seekname);
} else if (dbi->ascending)
result = dns_dbiterator_first(dbi->dbiterator);
else
result = dns_dbiterator_last(dbi->dbiterator);
}
} else
result = DNS_R_SUCCESS;
node = NULL;
rdsiter = NULL;
i = 0;
while (result == DNS_R_SUCCESS) {
result = dns_dbiterator_current(dbi->dbiterator, &node, name);
if (result != DNS_R_SUCCESS && result != DNS_R_NEWORIGIN)
break;
result = dns_db_allrdatasets(dbi->db, node, dbi->iversion, 0,
&rdsiter);
if (result != DNS_R_SUCCESS) {
dns_db_detachnode(dbi->db, &node);
break;
}
print_rdatasets(name, rdsiter);
dns_rdatasetiter_destroy(&rdsiter);
dns_db_detachnode(dbi->db, &node);
if (dbi->ascending)
result = dns_dbiterator_next(dbi->dbiterator);
else
result = dns_dbiterator_prev(dbi->dbiterator);
i++;
if (result == DNS_R_SUCCESS && i == dbi->pause_every) {
printf("[more...]\n");
result = dns_dbiterator_pause(dbi->dbiterator);
if (result == DNS_R_SUCCESS)
return;
}
}
if (result != DNS_R_NOMORE)
print_result("", result);
dns_dbiterator_destroy(&dbi->dbiterator);
if (dbi->iversion != NULL)
dns_db_closeversion(dbi->db, &dbi->iversion, ISC_FALSE);
}
static isc_result_t
load(char *filename, char *origintext, isc_boolean_t cache) {
dns_fixedname_t forigin;
dns_name_t *origin;
isc_result_t result;
isc_buffer_t source;
size_t len;
dbinfo *dbi;
unsigned int i;
dbi = isc_mem_get(mctx, sizeof *dbi);
if (dbi == NULL)
return (DNS_R_NOMEMORY);
dbi->db = NULL;
dbi->version = NULL;
dbi->wversion = NULL;
for (i = 0; i < MAXVERSIONS; i++)
dbi->rversions[i] = NULL;
dbi->hold_count = 0;
for (i = 0; i < MAXHOLD; i++)
dbi->hold_nodes[i] = NULL;
dbi->dbiterator = NULL;
dbi->iversion = NULL;
dbi->pause_every = pause_every;
dbi->ascending = ascending;
len = strlen(origintext);
isc_buffer_init(&source, origintext, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, len);
dns_fixedname_init(&forigin);
origin = dns_fixedname_name(&forigin);
result = dns_name_fromtext(origin, &source, dns_rootname, ISC_FALSE,
NULL);
if (result != DNS_R_SUCCESS)
return (result);
result = dns_db_create(mctx, dbtype, origin, cache, dns_rdataclass_in,
0, NULL, &dbi->db);
if (result != DNS_R_SUCCESS) {
isc_mem_put(mctx, dbi, sizeof *dbi);
return (result);
}
printf("loading %s (%s)\n", filename, origintext);
result = dns_db_load(dbi->db, filename);
if (result != DNS_R_SUCCESS) {
dns_db_detach(&dbi->db);
isc_mem_put(mctx, dbi, sizeof *dbi);
return (result);
}
printf("loaded\n");
if (cache) {
INSIST(cache_dbi == NULL);
dns_dbtable_adddefault(dbtable, dbi->db);
cache_dbi = dbi;
} else {
if (dns_dbtable_add(dbtable, dbi->db) != DNS_R_SUCCESS) {
dns_db_detach(&dbi->db);
isc_mem_put(mctx, dbi, sizeof *dbi);
return (result);
}
}
ISC_LIST_APPEND(dbs, dbi, link);
return (DNS_R_SUCCESS);
}
static void
unload_all(void) {
dbinfo *dbi, *dbi_next;
for (dbi = ISC_LIST_HEAD(dbs); dbi != NULL; dbi = dbi_next) {
dbi_next = ISC_LIST_NEXT(dbi, link);
if (dns_db_iszone(dbi->db))
dns_dbtable_remove(dbtable, dbi->db);
else {
INSIST(dbi == cache_dbi);
dns_dbtable_removedefault(dbtable);
cache_dbi = NULL;
}
dns_db_detach(&dbi->db);
ISC_LIST_UNLINK(dbs, dbi, link);
isc_mem_put(mctx, dbi, sizeof *dbi);
}
}
#define DBI_CHECK(dbi) \
if ((dbi) == NULL) { \
printf("You must first select a database with !DB\n"); \
continue; \
}
int
main(int argc, char *argv[]) {
dns_db_t *db;
dns_dbnode_t *node;
isc_result_t result;
dns_name_t name;
dns_offsets_t offsets;
size_t len;
isc_buffer_t source, target;
char s[1000];
char b[255];
dns_rdataset_t rdataset, sigrdataset;
int ch;
dns_rdatatype_t type = 1;
isc_boolean_t printnode = ISC_FALSE;
isc_boolean_t addmode = ISC_FALSE;
isc_boolean_t delmode = ISC_FALSE;
isc_boolean_t holdmode = ISC_FALSE;
isc_boolean_t verbose = ISC_FALSE;
isc_boolean_t done = ISC_FALSE;
isc_boolean_t quiet = ISC_FALSE;
isc_boolean_t time_lookups = ISC_FALSE;
isc_boolean_t found_as;
int i, v;
dns_rdatasetiter_t *rdsiter;
char t1[256];
char t2[256];
isc_buffer_t tb1, tb2;
isc_region_t r1, r2;
dns_fixedname_t foundname;
dns_name_t *fname;
unsigned int options = 0;
struct timeval start, finish;
char *origintext;
dbinfo *dbi;
dns_dbversion_t *version;
dns_name_t *origin;
size_t memory_quota = 0;
dns_trust_t trust = 0;
dns_result_register();
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(dns_dbtable_create(mctx, dns_rdataclass_in, &dbtable) ==
DNS_R_SUCCESS);
strcpy(dbtype, "rbt");
while ((ch = getopt(argc, argv, "c:d:t:z:P:Q:gpqvT")) != -1) {
switch (ch) {
case 'c':
result = load(optarg, ".", ISC_TRUE);
if (result != DNS_R_SUCCESS)
printf("cache load(%s) %08x: %s\n",
optarg, result,
isc_result_totext(result));
break;
case 'd':
strcpy(dbtype, optarg);
break;
case 'g':
options |= (DNS_DBFIND_GLUEOK|DNS_DBFIND_VALIDATEGLUE);
break;
case 'q':
quiet = ISC_TRUE;
verbose = ISC_FALSE;
break;
case 'p':
printnode = ISC_TRUE;
break;
case 'P':
pause_every = atoi(optarg);
break;
case 'Q':
memory_quota = atoi(optarg);
isc_mem_setquota(mctx, memory_quota);
break;
case 't':
type = atoi(optarg);
break;
case 'T':
time_lookups = ISC_TRUE;
break;
case 'v':
verbose = ISC_TRUE;
break;
case 'z':
origintext = strrchr(optarg, '/');
if (origintext == NULL)
origintext = optarg;
else
origintext++; /* Skip '/'. */
result = load(optarg, origintext, ISC_FALSE);
if (result != DNS_R_SUCCESS)
printf("zone load(%s) %08x: %s\n",
optarg, result,
isc_result_totext(result));
break;
}
}
argc -= optind;
argv += optind;
if (argc != 0)
printf("ignoring trailing arguments\n");
/*
* Some final initialization...
*/
dns_fixedname_init(&foundname);
fname = dns_fixedname_name(&foundname);
dbi = NULL;
origin = dns_rootname;
version = NULL;
if (time_lookups) {
/* Naughty */
(void)gettimeofday(&start, NULL);
}
while (!done) {
if (!quiet)
printf("\n");
if (fgets(s, sizeof s, stdin) == NULL) {
done = ISC_TRUE;
continue;
}
len = strlen(s);
if (len > 0 && s[len - 1] == '\n') {
s[len - 1] = '\0';
len--;
}
if (verbose && dbi != NULL) {
if (dbi->wversion != NULL)
printf("future version (%p)\n", dbi->wversion);
for (i = 0; i < dbi->rcount; i++)
if (dbi->rversions[i] != NULL)
printf("open version %d (%p)\n", i,
dbi->rversions[i]);
}
dns_name_init(&name, offsets);
if (strcmp(s, "!R") == 0) {
DBI_CHECK(dbi);
if (dbi->rcount == MAXVERSIONS) {
printf("too many open versions\n");
continue;
}
dns_db_currentversion(dbi->db,
&dbi->rversions[dbi->rcount]);
printf("opened version %d\n", dbi->rcount);
dbi->version = dbi->rversions[dbi->rcount];
version = dbi->version;
dbi->rcount++;
continue;
} else if (strcmp(s, "!W") == 0) {
DBI_CHECK(dbi);
if (dbi->wversion != NULL) {
printf("using existing future version\n");
dbi->version = dbi->wversion;
version = dbi->version;
continue;
}
result = dns_db_newversion(dbi->db, &dbi->wversion);
if (result != DNS_R_SUCCESS)
print_result("", result);
else
printf("newversion\n");
dbi->version = dbi->wversion;
version = dbi->version;
continue;
} else if (strcmp(s, "!C") == 0) {
DBI_CHECK(dbi);
addmode = ISC_FALSE;
delmode = ISC_FALSE;
if (dbi->version == NULL)
continue;
if (dbi->version == dbi->wversion) {
printf("closing future version\n");
dbi->wversion = NULL;
} else {
for (i = 0; i < dbi->rcount; i++) {
if (dbi->version ==
dbi->rversions[i]) {
dbi->rversions[i] = NULL;
printf("closing open version %d\n",
i);
break;
}
}
}
dns_db_closeversion(dbi->db, &dbi->version, ISC_TRUE);
version = NULL;
continue;
} else if (strcmp(s, "!X") == 0) {
DBI_CHECK(dbi);
addmode = ISC_FALSE;
delmode = ISC_FALSE;
if (dbi->version == NULL)
continue;
if (dbi->version == dbi->wversion) {
printf("aborting future version\n");
dbi->wversion = NULL;
} else {
for (i = 0; i < dbi->rcount; i++) {
if (dbi->version ==
dbi->rversions[i]) {
dbi->rversions[i] = NULL;
printf("closing open version %d\n",
i);
break;
}
}
}
dns_db_closeversion(dbi->db, &dbi->version, ISC_FALSE);
version = NULL;
continue;
} else if (strcmp(s, "!A") == 0) {
DBI_CHECK(dbi);
delmode = ISC_FALSE;
if (addmode)
addmode = ISC_FALSE;
else
addmode = ISC_TRUE;
printf("addmode = %s\n", addmode ? "TRUE" : "FALSE");
continue;
} else if (strcmp(s, "!D") == 0) {
DBI_CHECK(dbi);
addmode = ISC_FALSE;
if (delmode)
delmode = ISC_FALSE;
else
delmode = ISC_TRUE;
printf("delmode = %s\n", delmode ? "TRUE" : "FALSE");
continue;
} else if (strcmp(s, "!H") == 0) {
DBI_CHECK(dbi);
if (holdmode)
holdmode = ISC_FALSE;
else
holdmode = ISC_TRUE;
printf("holdmode = %s\n", holdmode ? "TRUE" : "FALSE");
continue;
} else if (strcmp(s, "!HR") == 0) {
DBI_CHECK(dbi);
for (i = 0; i < dbi->hold_count; i++)
dns_db_detachnode(dbi->db,
&dbi->hold_nodes[i]);
dbi->hold_count = 0;
holdmode = ISC_FALSE;
printf("held nodes have been detached\n");
continue;
} else if (strcmp(s, "!VC") == 0) {
DBI_CHECK(dbi);
printf("switching to current version\n");
dbi->version = NULL;
version = NULL;
continue;
} else if (strstr(s, "!V") == s) {
DBI_CHECK(dbi);
v = atoi(&s[2]);
if (v >= dbi->rcount) {
printf("unknown open version %d\n", v);
continue;
} else if (dbi->rversions[v] == NULL) {
printf("version %d is not open\n", v);
continue;
}
printf("switching to open version %d\n", v);
dbi->version = dbi->rversions[v];
version = dbi->version;
continue;
} else if (strstr(s, "!TR") == s) {
trust = (unsigned int)atoi(&s[3]);
printf("trust level is now %u\n", (unsigned int)trust);
continue;
} else if (strstr(s, "!T") == s) {
type = (unsigned int)atoi(&s[2]);
printf("now searching for type %u\n", type);
continue;
} else if (strcmp(s, "!G") == 0) {
if ((options & DNS_DBFIND_GLUEOK) != 0)
options &= ~DNS_DBFIND_GLUEOK;
else
options |= DNS_DBFIND_GLUEOK;
printf("glue ok = %s\n",
((options & DNS_DBFIND_GLUEOK) != 0) ?
"TRUE" : "FALSE");
continue;
} else if (strcmp(s, "!GV") == 0) {
if ((options & DNS_DBFIND_VALIDATEGLUE) != 0)
options &= ~DNS_DBFIND_VALIDATEGLUE;
else
options |= DNS_DBFIND_VALIDATEGLUE;
printf("validate glue = %s\n",
((options & DNS_DBFIND_VALIDATEGLUE) != 0) ?
"TRUE" : "FALSE");
continue;
} else if (strcmp(s, "!WC") == 0) {
if ((options & DNS_DBFIND_NOWILD) != 0)
options &= ~DNS_DBFIND_NOWILD;
else
options |= DNS_DBFIND_NOWILD;
printf("wildcard matching = %s\n",
((options & DNS_DBFIND_NOWILD) == 0) ?
"TRUE" : "FALSE");
continue;
} else if (strstr(s, "!LS ") == s) {
DBI_CHECK(dbi);
list(dbi, &s[4]);
continue;
} else if (strcmp(s, "!LS") == 0) {
DBI_CHECK(dbi);
list(dbi, NULL);
continue;
} else if (strstr(s, "!DU ") == s) {
DBI_CHECK(dbi);
result = dns_db_dump(dbi->db, dbi->version, s+4);
if (result != DNS_R_SUCCESS) {
printf("\n");
print_result("", result);
}
continue;
} else if (strcmp(s, "!PN") == 0) {
if (printnode)
printnode = ISC_FALSE;
else
printnode = ISC_TRUE;
printf("printnode = %s\n",
printnode ? "TRUE" : "FALSE");
continue;
} else if (strstr(s, "!P") == s) {
DBI_CHECK(dbi);
v = atoi(&s[2]);
dbi->pause_every = v;
continue;
} else if (strcmp(s, "!+") == 0) {
DBI_CHECK(dbi);
dbi->ascending = ISC_TRUE;
continue;
} else if (strcmp(s, "!-") == 0) {
DBI_CHECK(dbi);
dbi->ascending = ISC_FALSE;
continue;
} else if (strcmp(s, "!DB") == 0) {
dbi = NULL;
origin = dns_rootname;
version = NULL;
printf("now searching all databases\n");
continue;
} else if (strncmp(s, "!DB ", 4) == 0) {
dbi = select_db(s+4);
if (dbi != NULL) {
db = dbi->db;
origin = dns_db_origin(dbi->db);
version = dbi->version;
addmode = ISC_FALSE;
delmode = ISC_FALSE;
holdmode = ISC_FALSE;
} else {
db = NULL;
version = NULL;
origin = dns_rootname;
printf("database not found; "
"now searching all databases\n");
}
continue;
}
isc_buffer_init(&source, s, len, ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, len);
isc_buffer_init(&target, b, sizeof b, ISC_BUFFERTYPE_BINARY);
result = dns_name_fromtext(&name, &source, origin,
ISC_FALSE, &target);
if (result != DNS_R_SUCCESS) {
print_result("bad name: ", result);
continue;
}
if (dbi == NULL) {
db = NULL;
result = dns_dbtable_find(dbtable, &name, &db);
if (result != DNS_R_SUCCESS &&
result != DNS_R_PARTIALMATCH) {
if (!quiet) {
printf("\n");
print_result("", result);
}
continue;
}
isc_buffer_init(&tb1, t1, sizeof t1,
ISC_BUFFERTYPE_TEXT);
result = dns_name_totext(dns_db_origin(db), ISC_FALSE,
&tb1);
if (result != DNS_R_SUCCESS) {
printf("\n");
print_result("", result);
dns_db_detach(&db);
continue;
}
isc_buffer_used(&tb1, &r1);
printf("\ndatabase = %.*s (%s)\n",
(int)r1.length, r1.base,
(dns_db_iszone(db)) ? "zone" : "cache");
}
node = NULL;
dns_rdataset_init(&rdataset);
dns_rdataset_init(&sigrdataset);
result = dns_db_find(db, &name, version, type, options, 0,
&node, fname, &rdataset, &sigrdataset);
if (!quiet) {
if (dbi != NULL)
printf("\n");
print_result("", result);
}
found_as = ISC_FALSE;
switch (result) {
case DNS_R_SUCCESS:
case DNS_R_GLUE:
case DNS_R_CNAME:
case DNS_R_ZONECUT:
break;
case DNS_R_DNAME:
case DNS_R_DELEGATION:
found_as = ISC_TRUE;
break;
case DNS_R_NXRDATASET:
if (dns_rdataset_isassociated(&rdataset))
break;
if (dbi != NULL) {
if (holdmode) {
RUNTIME_CHECK(dbi->hold_count <
MAXHOLD);
dbi->hold_nodes[dbi->hold_count++] =
node;
node = NULL;
} else
dns_db_detachnode(db, &node);
} else {
dns_db_detachnode(db, &node);
dns_db_detach(&db);
}
continue;
case DNS_R_NXDOMAIN:
if (dns_rdataset_isassociated(&rdataset))
break;
/* FALLTHROUGH */
default:
if (dbi == NULL)
dns_db_detach(&db);
if (quiet)
print_result("", result);
continue;
}
if (found_as && !quiet) {
isc_buffer_init(&tb1, t1, sizeof t1,
ISC_BUFFERTYPE_TEXT);
isc_buffer_init(&tb2, t2, sizeof t2,
ISC_BUFFERTYPE_TEXT);
result = dns_name_totext(&name, ISC_FALSE, &tb1);
if (result != DNS_R_SUCCESS) {
print_result("", result);
dns_db_detachnode(db, &node);
if (dbi == NULL)
dns_db_detach(&db);
continue;
}
result = dns_name_totext(fname, ISC_FALSE, &tb2);
if (result != DNS_R_SUCCESS) {
print_result("", result);
dns_db_detachnode(db, &node);
if (dbi == NULL)
dns_db_detach(&db);
continue;
}
isc_buffer_used(&tb1, &r1);
isc_buffer_used(&tb2, &r2);
printf("found %.*s as %.*s\n",
(int)r1.length, r1.base,
(int)r2.length, r2.base);
}
if (printnode)
dns_db_printnode(db, node, stdout);
if (!found_as && type == dns_rdatatype_any) {
rdsiter = NULL;
result = dns_db_allrdatasets(db, node, version, 0,
&rdsiter);
if (result == DNS_R_SUCCESS) {
if (!quiet)
print_rdatasets(fname, rdsiter);
dns_rdatasetiter_destroy(&rdsiter);
} else
print_result("", result);
} else {
if (!quiet)
print_rdataset(fname, &rdataset);
if (dns_rdataset_isassociated(&sigrdataset)) {
if (!quiet)
print_rdataset(fname, &sigrdataset);
dns_rdataset_disassociate(&sigrdataset);
}
if (dbi != NULL && addmode && !found_as) {
rdataset.ttl++;
rdataset.trust = trust;
result = dns_db_addrdataset(db, node, version,
0, &rdataset,
dns_db_iszone(db),
NULL);
if (result != DNS_R_SUCCESS)
print_result("", result);
if (printnode)
dns_db_printnode(db, node, stdout);
} else if (dbi != NULL && delmode && !found_as) {
result = dns_db_deleterdataset(db, node,
version, type);
if (result != DNS_R_SUCCESS)
print_result("", result);
if (printnode)
dns_db_printnode(db, node, stdout);
}
dns_rdataset_disassociate(&rdataset);
}
if (dbi != NULL) {
if (holdmode) {
RUNTIME_CHECK(dbi->hold_count < MAXHOLD);
dbi->hold_nodes[dbi->hold_count++] = node;
node = NULL;
} else
dns_db_detachnode(db, &node);
} else {
dns_db_detachnode(db, &node);
dns_db_detach(&db);
}
}
if (time_lookups) {
struct timeval interval;
/* Naughty */
(void)gettimeofday(&finish, NULL);
if (start.tv_usec > finish.tv_usec) {
finish.tv_sec--;
interval.tv_usec = 1000000 -
start.tv_usec + finish.tv_usec;
} else
interval.tv_usec = finish.tv_usec - start.tv_usec;
interval.tv_sec = finish.tv_sec - start.tv_sec;
printf("elapsed time: %lu.%06lu seconds\n",
(unsigned long)interval.tv_sec,
(unsigned long)interval.tv_usec);
}
unload_all();
dns_dbtable_detach(&dbtable);
if (!quiet)
isc_mem_stats(mctx, stdout);
return (0);
}

View File

@@ -1,417 +0,0 @@
/*
* Copyright (C) 1998, 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <isc/app.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/mem.h>
#include <isc/task.h>
#include <isc/thread.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/timer.h>
#include <dns/dispatch.h>
#include <dns/message.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "printmsg.h"
isc_mem_t *mctx;
isc_taskmgr_t *manager;
isc_socketmgr_t *socketmgr;
dns_dispatch_t *disp;
isc_task_t *t0, *t1, *t2;
isc_buffer_t render;
unsigned char render_buffer[1024];
dns_rdataset_t rdataset;
dns_rdatalist_t rdatalist;
void my_accept(isc_task_t *, isc_event_t *);
void got_request(isc_task_t *, isc_event_t *);
void got_response(isc_task_t *, isc_event_t *);
void start_response(void);
static inline void CHECKRESULT(dns_result_t, char *);
void send_done(isc_task_t *, isc_event_t *);
void hex_dump(isc_buffer_t *);
void
hex_dump(isc_buffer_t *b)
{
unsigned int len;
isc_region_t r;
isc_buffer_remaining(b, &r);
printf("Buffer %p (%p, %d): used region base %p, length %d",
b, b->base, b->length, r.base, r.length);
for (len = 0 ; len < r.length ; len++) {
if (len % 16 == 0)
printf("\n");
printf("%02x ", r.base[len]);
}
printf("\n");
}
static inline void
CHECKRESULT(dns_result_t result, char *msg)
{
if (result != DNS_R_SUCCESS) {
printf("%s: %s\n", msg, isc_result_totext(result));
exit(1);
}
}
void
my_accept(isc_task_t *task, isc_event_t *ev_in)
{
isc_socket_newconnev_t *ev = (isc_socket_newconnev_t *)ev_in;
dns_dispentry_t *resp;
if (ev->result != ISC_R_SUCCESS) {
isc_event_free(&ev_in);
isc_app_shutdown();
}
/*
* Create a dispatch context
*/
disp = NULL;
RUNTIME_CHECK(dns_dispatch_create(mctx, ev->newsocket, task,
512, 6, 1024, 4, &disp)
== ISC_R_SUCCESS);
resp = NULL;
RUNTIME_CHECK(dns_dispatch_addrequest(disp, task, got_request, NULL,
&resp)
== ISC_R_SUCCESS);
isc_socket_detach(&ev->newsocket);
isc_event_free(&ev_in);
}
void
send_done(isc_task_t *task, isc_event_t *ev_in)
{
isc_socketevent_t *ev = (isc_socketevent_t *)ev_in;
dns_dispentry_t *resp = (dns_dispentry_t *)ev_in->arg;
(void)task;
if (ev->result == ISC_R_SUCCESS) {
printf("Send done (SUCCESS)\n");
isc_event_free(&ev_in);
return;
}
CHECKRESULT(ev->result, "send_done got event");
isc_event_free(&ev_in);
printf("--- removing response (FAILURE)\n");
dns_dispatch_removeresponse(disp, &resp, NULL);
isc_app_shutdown();
}
void
start_response(void)
{
dns_dispentry_t *resp;
dns_messageid_t id;
isc_sockaddr_t from;
dns_message_t *msg;
isc_result_t result;
dns_name_t name;
unsigned char namebuf[255];
isc_buffer_t target;
isc_buffer_t source;
isc_region_t region;
#define QUESTION "flame.org."
isc_buffer_init(&source, QUESTION, strlen(QUESTION),
ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, strlen(QUESTION));
isc_buffer_setactive(&source, strlen(QUESTION));
isc_buffer_init(&target, namebuf, sizeof(namebuf),
ISC_BUFFERTYPE_BINARY);
dns_name_init(&name, NULL);
result = dns_name_fromtext(&name, &source, dns_rootname, ISC_FALSE,
&target);
CHECKRESULT(result, "dns_name_fromtext()");
memset(&from, 0, sizeof(from));
from.length = sizeof(struct sockaddr_in);
#ifdef ISC_NET_HAVESALEN
from.type.sa.sa_len = sizeof(struct sockaddr_in);
#endif
from.type.sin.sin_port = htons(53);
from.type.sa.sa_family = AF_INET;
RUNTIME_CHECK(inet_aton("204.152.184.97",
&from.type.sin.sin_addr) == 1);
msg = NULL;
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &msg);
CHECKRESULT(result, "dns_message_create()");
dns_message_addname(msg, &name, DNS_SECTION_QUESTION);
rdatalist.rdclass = dns_rdataclass_in;
rdatalist.type = dns_rdatatype_a;
rdatalist.ttl = 0;
ISC_LIST_INIT(rdatalist.rdata);
dns_rdataset_init(&rdataset);
result = dns_rdatalist_tordataset(&rdatalist, &rdataset);
CHECKRESULT(result, "dns_rdatalist_tordataset()");
ISC_LIST_APPEND(name.list, &rdataset, link);
result = printmessage(msg);
CHECKRESULT(result, "printmessage()");
isc_buffer_init(&render, render_buffer, sizeof(render_buffer),
ISC_BUFFERTYPE_BINARY);
result = dns_message_renderbegin(msg, &render);
CHECKRESULT(result, "dns_message_renderbegin()");
rdataset.attributes |= DNS_RDATASETATTR_QUESTION;
result = dns_message_rendersection(msg, DNS_SECTION_QUESTION, 0, 0);
CHECKRESULT(result, "dns_message_rendersection(QUESTION)");
result = dns_message_rendersection(msg, DNS_SECTION_ANSWER, 0, 0);
CHECKRESULT(result, "dns_message_rendersection(ANSWER)");
result = dns_message_rendersection(msg, DNS_SECTION_ADDITIONAL, 0, 0);
CHECKRESULT(result, "dns_message_rendersection(ADDITIONAL)");
result = dns_message_rendersection(msg, DNS_SECTION_AUTHORITY, 0, 0);
CHECKRESULT(result, "dns_message_rendersection(AUTHORITY)");
printf("--- adding response\n");
resp = NULL;
result = dns_dispatch_addresponse(disp, &from, t2, got_response, NULL,
&id, &resp);
CHECKRESULT(result, "dns_dispatch_addresponse");
printf("Assigned MessageID %d\n", id);
msg->opcode = dns_opcode_query;
msg->rcode = dns_rcode_noerror;
msg->flags = DNS_MESSAGEFLAG_RD;
msg->id = id;
result = dns_message_renderend(msg);
CHECKRESULT(result, "dns_message_renderend");
dns_message_destroy(&msg);
isc_buffer_used(&render, &region);
result = isc_socket_sendto(dns_dispatch_getsocket(disp), &region,
t2, send_done, resp, &from);
CHECKRESULT(result, "isc_socket_sendto()");
}
void
got_response(isc_task_t *task, isc_event_t *ev_in)
{
dns_dispatchevent_t *ev = (dns_dispatchevent_t *)ev_in;
dns_dispentry_t *resp = ev->sender;
dns_message_t *msg;
isc_result_t result;
(void)task;
printf("App: Got response (id %d). Result: %s\n",
ev->id, isc_result_totext(ev->result));
msg = NULL;
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
CHECKRESULT(result, "dns_message_create() failed");
result = dns_message_parse(msg, &ev->buffer, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse() failed");
result = printmessage(msg);
CHECKRESULT(result, "printmessage() failed");
dns_message_destroy(&msg);
printf("--- removing response\n");
dns_dispatch_removeresponse(disp, &resp, &ev);
isc_app_shutdown();
}
void
got_request(isc_task_t *task, isc_event_t *ev_in)
{
dns_dispatchevent_t *ev = (dns_dispatchevent_t *)ev_in;
dns_dispentry_t *resp = ev->sender;
static int cnt = 0;
dns_message_t *msg;
dns_result_t result;
printf("App: Got request. Result: %s\n",
isc_result_totext(ev->result));
if (ev->result != DNS_R_SUCCESS) {
printf("Got error, terminating application\n");
dns_dispatch_removerequest(disp, &resp, &ev);
dns_dispatch_detach(&disp);
isc_app_shutdown();
return;
}
hex_dump(&ev->buffer);
msg = NULL;
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
CHECKRESULT(result, "dns_message_create() failed");
result = dns_message_parse(msg, &ev->buffer, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse() failed");
result = printmessage(msg);
CHECKRESULT(result, "printmessage() failed");
dns_message_destroy(&msg);
sleep (1);
printf("App: Ready.\n");
cnt++;
switch (cnt) {
case 6:
printf("--- removing request\n");
dns_dispatch_removerequest(disp, &resp, &ev);
dns_dispatch_detach(&disp);
isc_app_shutdown();
break;
case 3:
printf("--- removing request\n");
dns_dispatch_removerequest(disp, &resp, &ev);
printf("--- adding request\n");
RUNTIME_CHECK(dns_dispatch_addrequest(disp, task, got_request,
NULL, &resp)
== DNS_R_SUCCESS);
break;
default:
dns_dispatch_freeevent(disp, resp, &ev);
break;
}
}
int
main(int argc, char *argv[])
{
isc_socket_t *s0;
isc_sockaddr_t sockaddr;
(void)argc;
(void)argv;
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
/*
* EVERYTHING needs a memory context.
*/
mctx = NULL;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
dns_result_register();
/*
* The task manager is independent (other than memory context)
*/
manager = NULL;
RUNTIME_CHECK(isc_taskmgr_create(mctx, 5, 0, &manager) ==
ISC_R_SUCCESS);
t0 = NULL;
RUNTIME_CHECK(isc_task_create(manager, NULL, 0, &t0) == ISC_R_SUCCESS);
t1 = NULL;
RUNTIME_CHECK(isc_task_create(manager, NULL, 0, &t1) == ISC_R_SUCCESS);
t2 = NULL;
RUNTIME_CHECK(isc_task_create(manager, NULL, 0, &t2) == ISC_R_SUCCESS);
socketmgr = NULL;
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
/*
* Open up a random socket. Who cares where.
*/
s0 = NULL;
memset(&sockaddr, 0, sizeof(sockaddr));
sockaddr.type.sin.sin_family = AF_INET;
sockaddr.type.sin.sin_port = htons(5555);
sockaddr.length = sizeof (struct sockaddr_in);
RUNTIME_CHECK(isc_socket_create(socketmgr, PF_INET,
isc_sockettype_tcp, &s0) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_bind(s0, &sockaddr) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_listen(s0, 0) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_accept(s0, t1, my_accept, NULL)
== ISC_R_SUCCESS);
isc_app_run();
isc_socket_detach(&s0);
fprintf(stderr, "Destroying socket manager\n");
isc_socketmgr_destroy(&socketmgr);
isc_task_shutdown(t0);
isc_task_detach(&t0);
isc_task_shutdown(t1);
isc_task_detach(&t1);
isc_task_shutdown(t2);
isc_task_detach(&t2);
fprintf(stderr, "Destroying task manager\n");
isc_taskmgr_destroy(&manager);
isc_mem_stats(mctx, stderr);
isc_mem_destroy(&mctx);
isc_app_finish();
return (0);
}

View File

@@ -1,452 +0,0 @@
/*
* Copyright (C) 1998, 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <isc/app.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/mem.h>
#include <isc/mutex.h>
#include <isc/task.h>
#include <isc/thread.h>
#include <isc/result.h>
#include <isc/socket.h>
#include <isc/timer.h>
#include <dns/dispatch.h>
#include <dns/message.h>
#include <dns/rdatalist.h>
#include <dns/rdataset.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "printmsg.h"
typedef struct {
int count;
isc_buffer_t render;
unsigned char render_buffer[1024];
dns_rdataset_t rdataset;
dns_rdatalist_t rdatalist;
dns_dispentry_t *resp;
} clictx_t;
isc_mem_t *mctx;
isc_taskmgr_t *manager;
isc_socketmgr_t *socketmgr;
dns_dispatch_t *disp;
isc_task_t *t0, *t1, *t2;
clictx_t clients[16]; /* lots of things might want to use this */
unsigned int client_count = 0;
isc_mutex_t client_lock;
void got_request(isc_task_t *, isc_event_t *);
void got_response(isc_task_t *, isc_event_t *);
void start_response(clictx_t *, char *, isc_task_t *);
static inline void CHECKRESULT(dns_result_t, char *);
void send_done(isc_task_t *, isc_event_t *);
void hex_dump(isc_buffer_t *);
void
hex_dump(isc_buffer_t *b)
{
unsigned int len;
isc_region_t r;
isc_buffer_remaining(b, &r);
printf("Buffer %p: used region base %p, length %d",
b, r.base, r.length);
for (len = 0 ; len < r.length ; len++) {
if (len % 16 == 0)
printf("\n");
printf("%02x ", r.base[len]);
}
printf("\n");
}
static inline void
CHECKRESULT(dns_result_t result, char *msg)
{
if (result != DNS_R_SUCCESS) {
printf("%s: %s\n", msg, isc_result_totext(result));
exit(1);
}
}
void
send_done(isc_task_t *task, isc_event_t *ev_in)
{
isc_socketevent_t *ev = (isc_socketevent_t *)ev_in;
clictx_t *cli = (clictx_t *)ev_in->arg;
(void)task;
if (ev->result == ISC_R_SUCCESS) {
printf("Send done (SUCCESS)\n");
isc_event_free(&ev_in);
return;
}
CHECKRESULT(ev->result, "send_done got event");
isc_event_free(&ev_in);
printf("--- removing response (FAILURE)\n");
dns_dispatch_removeresponse(disp, &cli->resp, NULL);
isc_app_shutdown();
}
void
start_response(clictx_t *cli, char *query, isc_task_t *task)
{
dns_messageid_t id;
isc_sockaddr_t from;
dns_message_t *msg;
isc_result_t result;
dns_name_t name;
unsigned char namebuf[255];
isc_buffer_t target;
isc_buffer_t source;
isc_region_t region;
isc_buffer_init(&source, query, strlen(query), ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&source, strlen(query));
isc_buffer_setactive(&source, strlen(query));
isc_buffer_init(&target, namebuf, sizeof(namebuf),
ISC_BUFFERTYPE_BINARY);
dns_name_init(&name, NULL);
result = dns_name_fromtext(&name, &source, dns_rootname, ISC_FALSE,
&target);
CHECKRESULT(result, "dns_name_fromtext()");
memset(&from, 0, sizeof(from));
from.length = sizeof(struct sockaddr_in);
#ifdef ISC_NET_HAVESALEN
from.type.sa.sa_len = sizeof(struct sockaddr_in);
#endif
from.type.sin.sin_port = htons(53);
from.type.sa.sa_family = AF_INET;
RUNTIME_CHECK(inet_aton("204.152.184.97",
&from.type.sin.sin_addr) == 1);
msg = NULL;
result = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &msg);
CHECKRESULT(result, "dns_message_create()");
dns_message_addname(msg, &name, DNS_SECTION_QUESTION);
cli->rdatalist.rdclass = dns_rdataclass_in;
cli->rdatalist.type = dns_rdatatype_a;
cli->rdatalist.ttl = 0;
ISC_LIST_INIT(cli->rdatalist.rdata);
dns_rdataset_init(&cli->rdataset);
result = dns_rdatalist_tordataset(&cli->rdatalist, &cli->rdataset);
CHECKRESULT(result, "dns_rdatalist_tordataset()");
ISC_LIST_APPEND(name.list, &cli->rdataset, link);
result = printmessage(msg);
CHECKRESULT(result, "printmessage()");
isc_buffer_init(&cli->render, cli->render_buffer,
sizeof(cli->render_buffer), ISC_BUFFERTYPE_BINARY);
result = dns_message_renderbegin(msg, &cli->render);
CHECKRESULT(result, "dns_message_renderbegin()");
cli->rdataset.attributes |= DNS_RDATASETATTR_QUESTION;
result = dns_message_rendersection(msg, DNS_SECTION_QUESTION, 0, 0);
CHECKRESULT(result, "dns_message_rendersection(QUESTION)");
result = dns_message_rendersection(msg, DNS_SECTION_ANSWER, 0, 0);
CHECKRESULT(result, "dns_message_rendersection(ANSWER)");
result = dns_message_rendersection(msg, DNS_SECTION_ADDITIONAL, 0, 0);
CHECKRESULT(result, "dns_message_rendersection(ADDITIONAL)");
result = dns_message_rendersection(msg, DNS_SECTION_AUTHORITY, 0, 0);
CHECKRESULT(result, "dns_message_rendersection(AUTHORITY)");
printf("--- adding response\n");
RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS);
client_count++;
RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS);
cli->resp = NULL;
result = dns_dispatch_addresponse(disp, &from, task, got_response,
cli, &id, &cli->resp);
CHECKRESULT(result, "dns_dispatch_addresponse");
printf("Assigned MessageID %d\n", id);
msg->opcode = dns_opcode_query;
msg->rcode = dns_rcode_noerror;
msg->flags = DNS_MESSAGEFLAG_RD;
msg->id = id;
result = dns_message_renderend(msg);
CHECKRESULT(result, "dns_message_renderend");
dns_message_destroy(&msg);
isc_buffer_used(&cli->render, &region);
result = isc_socket_sendto(dns_dispatch_getsocket(disp), &region,
task, send_done, cli->resp, &from);
CHECKRESULT(result, "isc_socket_sendto()");
}
void
got_response(isc_task_t *task, isc_event_t *ev_in)
{
dns_dispatchevent_t *ev = (dns_dispatchevent_t *)ev_in;
dns_dispentry_t *resp = ev->sender;
dns_message_t *msg;
isc_result_t result;
unsigned int cnt;
(void)task;
printf("App: Got response (id %d). Result: %s\n",
ev->id, isc_result_totext(ev->result));
if (ev->result != ISC_R_SUCCESS) {
printf("--- ERROR, shutting down response slot\n");
printf("--- shutting down dispatcher\n");
dns_dispatch_cancel(disp);
printf("--- removing response\n");
dns_dispatch_removeresponse(disp, &resp, &ev);
RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS);
INSIST(client_count > 0);
client_count--;
cnt = client_count;
RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS);
if (cnt == 0)
isc_app_shutdown();
return;
}
msg = NULL;
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
CHECKRESULT(result, "dns_message_create() failed");
result = dns_message_parse(msg, &ev->buffer, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse() failed");
result = printmessage(msg);
CHECKRESULT(result, "printmessage() failed");
dns_message_destroy(&msg);
printf("--- shutting down dispatcher\n");
dns_dispatch_cancel(disp);
printf("--- removing response\n");
dns_dispatch_removeresponse(disp, &resp, &ev);
RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS);
INSIST(client_count > 0);
client_count--;
cnt = client_count;
RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS);
if (cnt == 0)
isc_app_shutdown();
}
void
got_request(isc_task_t *task, isc_event_t *ev_in)
{
dns_dispatchevent_t *ev = (dns_dispatchevent_t *)ev_in;
clictx_t *cli = (clictx_t *)ev_in->arg;
dns_message_t *msg;
dns_result_t result;
unsigned int cnt;
printf("App: Got request. Result: %s\n",
isc_result_totext(ev->result));
if (ev->result != DNS_R_SUCCESS) {
RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS);
printf("Got error, terminating CLIENT %p resp %p\n",
cli, cli->resp);
dns_dispatch_removerequest(disp, &cli->resp, &ev);
INSIST(client_count > 0);
client_count--;
cnt = client_count;
printf("CLIENT %p ENDING, %d remain\n", cli, client_count);
RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS);
if (cnt == 0)
isc_app_shutdown();
return;
}
hex_dump(&ev->buffer);
msg = NULL;
result = dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
CHECKRESULT(result, "dns_message_create() failed");
result = dns_message_parse(msg, &ev->buffer, ISC_FALSE);
CHECKRESULT(result, "dns_message_parse() failed");
result = printmessage(msg);
CHECKRESULT(result, "printmessage() failed");
dns_message_destroy(&msg);
sleep (1);
cli->count++;
printf("App: Client %p ready, count == %d.\n", cli, cli->count);
switch (cli->count) {
case 4:
printf("--- starting DNS lookup\n");
dns_dispatch_freeevent(disp, cli->resp, &ev);
start_response(&clients[3], "flame.org", task);
start_response(&clients[4], "vix.com", task);
start_response(&clients[5], "isc.org", task);
break;
case 2:
printf("--- removing request\n");
dns_dispatch_removerequest(disp, &cli->resp, &ev);
printf("--- adding request\n");
RUNTIME_CHECK(dns_dispatch_addrequest(disp, task, got_request,
cli, &cli->resp)
== DNS_R_SUCCESS);
break;
default:
dns_dispatch_freeevent(disp, cli->resp, &ev);
break;
}
}
int
main(int argc, char *argv[])
{
isc_socket_t *s0;
isc_sockaddr_t sockaddr;
unsigned int i;
(void)argc;
(void)argv;
RUNTIME_CHECK(isc_app_start() == ISC_R_SUCCESS);
/*
* EVERYTHING needs a memory context.
*/
mctx = NULL;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
dns_result_register();
/*
* The task manager is independent (other than memory context)
*/
manager = NULL;
RUNTIME_CHECK(isc_taskmgr_create(mctx, 5, 0, &manager) ==
ISC_R_SUCCESS);
t0 = NULL;
RUNTIME_CHECK(isc_task_create(manager, NULL, 0, &t0) == ISC_R_SUCCESS);
t1 = NULL;
RUNTIME_CHECK(isc_task_create(manager, NULL, 0, &t1) == ISC_R_SUCCESS);
t2 = NULL;
RUNTIME_CHECK(isc_task_create(manager, NULL, 0, &t2) == ISC_R_SUCCESS);
socketmgr = NULL;
RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS);
/*
* Open up a random socket. Who cares where.
*/
s0 = NULL;
memset(&sockaddr, 0, sizeof(sockaddr));
sockaddr.type.sin.sin_family = AF_INET;
sockaddr.type.sin.sin_port = htons(5555);
sockaddr.length = sizeof (struct sockaddr_in);
RUNTIME_CHECK(isc_socket_create(socketmgr, PF_INET,
isc_sockettype_udp, &s0) ==
ISC_R_SUCCESS);
RUNTIME_CHECK(isc_socket_bind(s0, &sockaddr) == ISC_R_SUCCESS);
/*
* Create a dispatch context
*/
disp = NULL;
RUNTIME_CHECK(dns_dispatch_create(mctx, s0, t0, 512, 6, 1024,
4, &disp) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_mutex_init(&client_lock) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_mutex_lock(&client_lock) == ISC_R_SUCCESS);
for (i = 0 ; i < 2 ; i++) {
clients[i].count = 0;
clients[i].resp = NULL;
RUNTIME_CHECK(dns_dispatch_addrequest(disp, t1, got_request,
&clients[i],
&clients[i].resp)
== ISC_R_SUCCESS);
client_count++;
}
RUNTIME_CHECK(isc_mutex_unlock(&client_lock) == ISC_R_SUCCESS);
isc_app_run();
fprintf(stderr, "canceling dispatcher\n");
dns_dispatch_cancel(disp);
fprintf(stderr, "detaching from socket\n");
isc_socket_detach(&s0);
fprintf(stderr, "detaching from dispatcher\n");
dns_dispatch_detach(&disp);
fprintf(stderr, "Destroying socket manager\n");
isc_socketmgr_destroy(&socketmgr);
isc_task_shutdown(t0);
isc_task_detach(&t0);
isc_task_shutdown(t1);
isc_task_detach(&t1);
isc_task_shutdown(t2);
isc_task_detach(&t2);
fprintf(stderr, "Destroying task manager\n");
isc_taskmgr_destroy(&manager);
isc_mem_stats(mctx, stderr);
isc_mem_destroy(&mctx);
isc_app_finish();
return (0);
}

View File

@@ -1,4 +0,0 @@
Makefile
dst_test
t_dst
.libs

View File

@@ -1 +0,0 @@
test. IN KEY 49152 2 1

View File

@@ -1 +0,0 @@
test. IN KEY 257 3 1 AQPQjwSpaVzxIgRCpiUoozUQKGh2oX8NIFKDOvtxK+tn536OZg2cROKTlgGEHXJK9YHfW/6nzQULTVpb63P+SQMmjCCidb8IYyhItixRztVeJQ==

View File

@@ -1,10 +0,0 @@
Private-key-format: v1.2
Algorithm: 1 (RSA)
Modulus: 0I8EqWlc8SIEQqYlKKM1EChodqF/DSBSgzr7cSvrZ+d+jmYNnETik5YBhB1ySvWB31v+p80FC01aW+tz/kkDJowgonW/CGMoSLYsUc7VXiU=
PublicExponent: Aw==
PrivateExponent: iwoDG5uTS2wC1xluGxd4tXBFpGuqCMA3AidSS3Kc7++ptEQJEtiXC9kfCJMvZhGfQLaujft2OgrmkcuDVtPIbQWEENhyJhb4Lk82kFXbfus=
Prime1: /rSKuzcZY7R5cY2YWD4CiBNyj9WJMq1wWmBnb9+5M08nTl5E9NW5qQ==
Prime2: 0Z5shXQYd16E2Gs6e5WxtO0Oqlly2KkSqXohwTQWDWTb8Pw0WTZmHQ==
Exponent1: qc2x0iS7l82mS7O65X6sWrehtTkGIcj1kZWaSpUmIjTE3umDTePRGw==
Exponent2: i77zA6K6+j8DOvIm/Q52eJ4JxuZMkHC3G6bBK3gOs5iSoKgi5iREEw==
Coefficient: 3+wYZB0SJad7z2EsjzgbSlg6CawoaOvrROGSbwSiW5DCsMFROudOTw==

View File

@@ -1 +0,0 @@
test. IN KEY 49152 2 3

View File

@@ -1 +0,0 @@
test. IN KEY 16641 3 3 ANp1//lqDlEfTavcFI+cyudNfgEz73V/K7fSDvkA0eDYcGg/kSvEjAEO/oLWCERltkuC55ZcM/mSv17WF1d/wR6kww/pLI9eXwkjftAYqs5sNxk+mbEGl6zwve9wq5z7IoTY5/J4l7XLCKftg/wGvrzXQhggIkRvEh3myhxd+ouILcpfvTIthWlTKiH59tSJpmgmiSMTE7nDYaf10iVRWN6DMSprgejiH05/fpmyZAt44tyAh4m1wXS5u4tam1PXDJYJozn7EfQ8e2weIv1yC+t6PHSx

View File

@@ -1,7 +0,0 @@
Private-key-format: v1.2
Algorithm: 3 (DSA)
Prime(p): 73V/K7fSDvkA0eDYcGg/kSvEjAEO/oLWCERltkuC55ZcM/mSv17WF1d/wR6kww/pLI9eXwkjftAYqs5sNxk+mQ==
Subprime(q): 2nX/+WoOUR9Nq9wUj5zK501+ATM=
Base(g): sQaXrPC973CrnPsihNjn8niXtcsIp+2D/Aa+vNdCGCAiRG8SHebKHF36i4gtyl+9Mi2FaVMqIfn21ImmaCaJIw==
Private_value(x): Nky4tvIwg6xlcyeHXr4k2DEZg0E=
Public_value(y): ExO5w2Gn9dIlUVjegzEqa4Ho4h9Of36ZsmQLeOLcgIeJtcF0ubuLWptT1wyWCaM5+xH0PHtsHiL9cgvrejx0sQ==

View File

@@ -1,54 +0,0 @@
# Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM 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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
CINCLUDES = -I${srcdir}/../../../lib/isc/unix/include \
-I${srcdir}/../../../lib/isc/pthreads/include \
-I${srcdir}/../../../lib/isc/include \
-I${srcdir}/../../../lib/dns/include \
-I${srcdir}/../../../lib/dns/sec/dst/include \
-I${srcdir}/../../../lib/tests/include
CDEFINES =
CWARNINGS =
DEPLIBS = ../../../lib/dns/libdns.@A@ \
../../../lib/isc/libisc.@A@
LIBS = ${DEPLIBS} \
@LIBS@
TLIB = ../../../lib/tests/libt_api.a
TARGETS = dst_test t_dst
SRCS = dst_test.c t_dst.c
@BIND9_MAKE_RULES@
dst_test: dst_test.o
${LIBTOOL} ${CC} -o $@ dst_test.o ${LIBS}
t_dst: t_dst.o ${DEPLIBS} ${TLIB}
${LIBTOOL} ${CC} -o $@ t_dst.o ${LIBS} ${TLIB}
test:
-@ ./t_dst -a
clean distclean::
rm -f ${TARGETS}

View File

@@ -1,138 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> /* XXX */
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/boolean.h>
#include <isc/region.h>
#include <isc/mem.h>
#include <dst/dst.h>
#include <dst/result.h>
char *current, *tmp = "/tmp";
static void
use(dst_key_t *key) {
dst_result_t ret;
char *data = "This is some data";
unsigned char sig[512];
isc_buffer_t databuf, sigbuf;
isc_region_t datareg, sigreg;
isc_buffer_init(&sigbuf, sig, sizeof(sig), ISC_BUFFERTYPE_BINARY);
/* Advance 1 byte for fun */
isc_buffer_add(&sigbuf, 1);
isc_buffer_init(&databuf, data, strlen(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&databuf, strlen(data));
isc_buffer_used(&databuf, &datareg);
ret = dst_sign(DST_SIGMODE_ALL, key, NULL, &datareg, &sigbuf);
printf("sign(%d) returned: %s\n", dst_key_alg(key),
dst_result_totext(ret));
isc_buffer_forward(&sigbuf, 1);
isc_buffer_remaining(&sigbuf, &sigreg);
ret = dst_verify(DST_SIGMODE_ALL, key, NULL, &datareg, &sigreg);
printf("verify(%d) returned: %s\n", dst_key_alg(key),
dst_result_totext(ret));
}
static void
io(char *name, int id, int alg, int type, isc_mem_t *mctx) {
dst_key_t *key;
dst_result_t ret;
chdir(current);
ret = dst_key_fromfile(name, id, alg, type, mctx, &key);
printf("read(%d) returned: %s\n", alg, dst_result_totext(ret));
if (ret != 0)
return;
chdir(tmp);
ret = dst_key_tofile(key, type);
printf("write(%d) returned: %s\n", alg, dst_result_totext(ret));
if (ret != 0)
return;
use(key);
dst_key_free(key);
}
static void
generate(int alg, isc_mem_t *mctx) {
dst_result_t ret;
dst_key_t *key;
ret = dst_key_generate("test.", alg, 512, 0, 0, 0, mctx, &key);
printf("generate(%d) returned: %s\n", alg, dst_result_totext(ret));
use(key);
dst_key_free(key);
}
static void
get_random() {
unsigned char data[25];
isc_buffer_t databuf;
dst_result_t ret;
unsigned int i;
isc_buffer_init(&databuf, data, sizeof data, ISC_BUFFERTYPE_BINARY);
ret = dst_random(sizeof(data), &databuf);
printf("random() returned: %s\n", dst_result_totext(ret));
for (i = 0; i < sizeof data; i++)
printf("%02x ", data[i]);
printf("\n");
}
int
main() {
isc_mem_t *mctx = NULL;
isc_mem_create(0, 0, &mctx);
current = isc_mem_get(mctx, 256);
getcwd(current, 256);
io("test.", 6204, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx);
io("test.", 54622, DST_ALG_RSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx);
io("test.", 0, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx);
io("test.", 0, DST_ALG_RSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC, mctx);
generate(DST_ALG_RSA, mctx);
generate(DST_ALG_DSA, mctx);
generate(DST_ALG_HMACMD5, mctx);
get_random();
isc_mem_put(mctx, current, 256);
/* isc_mem_stats(mctx, stdout);*/
isc_mem_destroy(&mctx);
exit(0);
}

View File

@@ -1,297 +0,0 @@
/*
* Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <ctype.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h> /* XXX */
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/boolean.h>
#include <isc/region.h>
#include <isc/mem.h>
#include <dst/dst.h>
#include <dst/result.h>
#include <tests/t_api.h>
static void t1(void);
/*
* adapted from the original dst_test.c program
*/
static void
cleandir(char *path) {
DIR *dirp;
struct dirent *pe;
char fullname[PATH_MAX + 1];
dirp = opendir(path);
if (dirp == NULL) {
t_info("opendir(%s) failed %d\n", path, opendir);
return;
}
while ((pe = readdir(dirp)) != NULL) {
if (! strcmp(pe->d_name, "."))
continue;
if (! strcmp(pe->d_name, ".."))
continue;
strcpy(fullname, path);
strcat(fullname, "/");
strcat(fullname, pe->d_name);
if (remove(fullname)) {
t_info("remove(%s) failed %d\n", fullname, errno);
}
}
(void) closedir(dirp);
if (rmdir(path)) {
t_info("rmdir(%s) failed %d\n", path, errno);
}
return;
}
static void
use(dst_key_t *key, dst_result_t exp_result, int *nfails) {
dst_result_t ret;
char *data = "This is some data";
unsigned char sig[512];
isc_buffer_t databuf, sigbuf;
isc_region_t datareg, sigreg;
isc_buffer_init(&sigbuf, sig, sizeof(sig), ISC_BUFFERTYPE_BINARY);
isc_buffer_init(&databuf, data, strlen(data), ISC_BUFFERTYPE_TEXT);
isc_buffer_add(&databuf, strlen(data));
isc_buffer_used(&databuf, &datareg);
ret = dst_sign(DST_SIGMODE_ALL, key, NULL, &datareg, &sigbuf);
if (ret != exp_result) {
t_info("dst_sign(%d) returned (%s) expected (%s)\n",
dst_key_alg(key), dst_result_totext(ret),
dst_result_totext(exp_result));
++*nfails;
return;
}
isc_buffer_remaining(&sigbuf, &sigreg);
ret = dst_verify(DST_SIGMODE_ALL, key, NULL, &datareg, &sigreg);
if (ret != exp_result) {
t_info("dst_verify(%d) returned (%s) expected (%s)\n",
dst_key_alg(key), dst_result_totext(ret),
dst_result_totext(exp_result));
++*nfails;
}
}
static void
io(char *name, int id, int alg, int type, isc_mem_t *mctx, dst_result_t exp_result,
int *nfails, int *nprobs) {
dst_key_t *key;
dst_result_t ret;
int rval;
char current[PATH_MAX + 1];
char tmp[PATH_MAX + 1];
char *p;
p = getcwd(current, PATH_MAX);;
if (p == NULL) {
t_info("getcwd failed %d\n", errno);
++*nprobs;
return;
}
ret = dst_key_fromfile(name, id, alg, type, mctx, &key);
if (ret != DST_R_SUCCESS) {
t_info("dst_key_fromfile(%d) returned: %s\n", alg, dst_result_totext(ret));
++*nfails;
return;
}
p = tmpnam(tmp);
if (p == NULL) {
t_info("tmpnam failed %d\n", errno);
++*nprobs;
return;
}
rval = mkdir(tmp, S_IRWXU | S_IRWXG );
if (rval != 0) {
t_info("mkdir failed %d\n", errno);
++*nprobs;
return;
}
if (chdir(tmp)) {
t_info("chdir failed %d\n", errno);
(void) rmdir(tmp);
++*nprobs;
return;
}
ret = dst_key_tofile(key, type);
if (ret != 0) {
t_info("dst_key_tofile(%d) returned: %s\n", alg, dst_result_totext(ret));
(void) chdir(current);
++*nfails;
return;
}
use(key, exp_result, nfails);
if (chdir(current)) {
t_info("chdir failed %d\n", errno);
++*nprobs;
return;
}
cleandir(tmp);
dst_key_free(key);
}
static void
generate(int alg, isc_mem_t *mctx, int *nfails) {
dst_result_t ret;
dst_key_t *key;
ret = dst_key_generate("test.", alg, 512, 0, 0, 0, mctx, &key);
if (ret != DST_R_SUCCESS) {
t_info("dst_key_generate(%d) returned: %s\n", alg, dst_result_totext(ret));
++*nfails;
return;
}
use(key, DST_R_SUCCESS, nfails);
dst_key_free(key);
}
#define DBUFSIZ 25
static void
get_random(int *nfails) {
unsigned char data1[DBUFSIZ];
unsigned char data2[DBUFSIZ];
isc_buffer_t databuf1;
isc_buffer_t databuf2;
dst_result_t ret;
unsigned int i;
isc_buffer_init(&databuf1, data1, sizeof(data1), ISC_BUFFERTYPE_BINARY);
ret = dst_random(sizeof(data1), &databuf1);
if (ret != DST_R_SUCCESS) {
t_info("random() returned: %s\n", dst_result_totext(ret));
++*nfails;
return;
}
isc_buffer_init(&databuf2, data2, sizeof(data2), ISC_BUFFERTYPE_BINARY);
ret = dst_random(sizeof(data2), &databuf2);
if (ret != DST_R_SUCCESS) {
t_info("random() returned: %s\n", dst_result_totext(ret));
++*nfails;
return;
}
/* weak test, but better than nought */
if (memcmp(data1, data2, DBUFSIZ) == 0) {
t_info("data not random\n");
++*nfails;
}
if (T_debug) {
for (i = 0; i < sizeof(data1); i++)
t_info("data1[%d]: %02x ", i, data1[i]);
for (i = 0; i < sizeof(data2); i++)
t_info("data2[%d]: %02x ", i, data2[i]);
}
}
static char *a1 =
"the dst module provides the capability to "
"generate, store and retrieve public and private keys, "
"sign and verify data using the RSA, DSA and MD5 algorithms, "
"and generate random number sequences.";
static void
t1() {
isc_mem_t *mctx;
int nfails;
int nprobs;
int result;
isc_result_t isc_result;
t_assert("dst", 1, T_REQUIRED, a1);
nfails = 0;
nprobs = 0;
mctx = NULL;
isc_result = isc_mem_create(0, 0, &mctx);
if (isc_result != ISC_R_SUCCESS) {
t_info("isc_mem_create failed %d\n", isc_result_totext(isc_result));
t_result(T_UNRESOLVED);
return;
}
t_info("testing use of stored keys\n");
io("test.", 6204, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
mctx, DST_R_SUCCESS, &nfails, &nprobs);
io("test.", 54622, DST_ALG_RSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
mctx, DST_R_SUCCESS, &nfails, &nprobs);
io("test.", 0, DST_ALG_DSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
mctx, DST_R_NULLKEY, &nfails, &nprobs);
io("test.", 0, DST_ALG_RSA, DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
mctx, DST_R_NULLKEY, &nfails, &nprobs);
t_info("testing use of generated keys\n");
generate(DST_ALG_RSA, mctx, &nfails);
generate(DST_ALG_DSA, mctx, &nfails);
generate(DST_ALG_HMACMD5, mctx, &nfails);
t_info("testing random number sequence generation\n");
get_random(&nfails);
isc_mem_destroy(&mctx);
result = T_UNRESOLVED;
if ((nfails == 0) && (nprobs == 0))
result = T_PASS;
else if (nfails)
result = T_FAIL;
t_result(result);
}
testspec_t T_testlist[] = {
{ t1, "basic dst module verification" },
{ NULL, NULL }
};

View File

@@ -1,161 +0,0 @@
/*
* Copyright (C) 1998, 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM 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.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <isc/assertions.h>
#include <isc/error.h>
#include <isc/lex.h>
isc_mem_t *mctx;
isc_lex_t *lex;
isc_lexspecials_t specials;
static void
print_token(isc_token_t *tokenp, FILE *stream) {
switch (tokenp->type) {
case isc_tokentype_unknown:
fprintf(stream, "UNKNOWN");
break;
case isc_tokentype_string:
fprintf(stream, "STRING %.*s",
(int)tokenp->value.as_region.length,
tokenp->value.as_region.base);
break;
case isc_tokentype_number:
fprintf(stream, "NUMBER %lu", tokenp->value.as_ulong);
break;
case isc_tokentype_qstring:
fprintf(stream, "QSTRING \"%.*s\"",
(int)tokenp->value.as_region.length,
tokenp->value.as_region.base);
break;
case isc_tokentype_eol:
fprintf(stream, "EOL");
break;
case isc_tokentype_eof:
fprintf(stream, "EOF");
break;
case isc_tokentype_initialws:
fprintf(stream, "INITIALWS");
break;
case isc_tokentype_special:
fprintf(stream, "SPECIAL %c", tokenp->value.as_char);
break;
case isc_tokentype_nomore:
fprintf(stream, "NOMORE");
break;
default:
FATAL_ERROR(__FILE__, __LINE__, "Unexpected type %d",
tokenp->type);
}
}
int
main(int argc, char *argv[]) {
isc_token_t token;
isc_result_t result;
int quiet = 0;
int c;
int masterfile = 1;
int stats = 0;
unsigned int options = 0;
int done = 0;
while ((c = getopt(argc, argv, "qmcs")) != -1) {
switch (c) {
case 'q':
quiet = 1;
break;
case 'm':
masterfile = 1;
break;
case 'c':
masterfile = 0;
break;
case 's':
stats = 1;
break;
}
}
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_lex_create(mctx, 256, &lex) == ISC_R_SUCCESS);
if (masterfile) {
/* Set up to lex DNS master file. */
specials['('] = 1;
specials[')'] = 1;
specials['"'] = 1;
isc_lex_setspecials(lex, specials);
options = ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE |
ISC_LEXOPT_EOF |
ISC_LEXOPT_QSTRING | ISC_LEXOPT_NOMORE;
isc_lex_setcomments(lex, ISC_LEXCOMMENT_DNSMASTERFILE);
} else {
/* Set up to lex DNS config file. */
specials['{'] = 1;
specials['}'] = 1;
specials[';'] = 1;
specials['/'] = 1;
specials['"'] = 1;
specials['!'] = 1;
specials['*'] = 1;
isc_lex_setspecials(lex, specials);
options = ISC_LEXOPT_EOF |
ISC_LEXOPT_QSTRING |
ISC_LEXOPT_NUMBER | ISC_LEXOPT_NOMORE;
isc_lex_setcomments(lex, (ISC_LEXCOMMENT_C|
ISC_LEXCOMMENT_CPLUSPLUS|
ISC_LEXCOMMENT_SHELL));
}
RUNTIME_CHECK(isc_lex_openstream(lex, stdin) == ISC_R_SUCCESS);
while ((result = isc_lex_gettoken(lex, options, &token)) ==
ISC_R_SUCCESS && !done) {
if (!quiet) {
char *name = isc_lex_getsourcename(lex);
print_token(&token, stdout);
printf(" line = %d file = %s\n",
isc_lex_getsourceline(lex),
(name == NULL) ? "<none>" : name);
}
if (token.type == isc_tokentype_eof)
isc_lex_close(lex);
if (token.type == isc_tokentype_nomore)
done = 1;
}
if (result != ISC_R_SUCCESS)
printf("Result: %s\n", isc_result_totext(result));
isc_lex_close(lex);
isc_lex_destroy(&lex);
if (!quiet && stats)
isc_mem_stats(mctx, stdout);
isc_mem_destroy(&mctx);
return (0);
}

View File

@@ -1,5 +0,0 @@
Makefile
.libs
*.la
*.lo
t_master

View File

@@ -1,51 +0,0 @@
# Copyright (C) 1999 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 INTERNET SOFTWARE CONSORTIUM DISCLAIMS
# ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
# CONSORTIUM 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.
srcdir = @srcdir@
VPATH = @srcdir@
top_srcdir = @top_srcdir@
CINCLUDES = -I${srcdir}/../../../lib/isc/unix/include \
-I${srcdir}/../../../lib/isc/pthreads/include \
-I${srcdir}/../../../lib/isc/include \
-I${srcdir}/../../../lib/dns/include \
-I${srcdir}/../../../lib/tests/include
CDEFINES =
CWARNINGS =
# Note that we do not want to use libtool for libt_api.a
LIBS = ../../../lib/dns/libdns.@A@ \
../../../lib/isc/libisc.@A@ \
../../../lib/tests/libt_api.a \
@LIBS@
TARGETS = t_master
SRCS = t_master.c
@BIND9_MAKE_RULES@
t_master: t_master.o
${LIBTOOL} ${CC} -o $@ t_master.o ${LIBS}
test:
-@ ./t_master -c @top_srcdir@/t_config -a >> ../t_journal 2>&1
testhelp:
@./t_master -h
clean distclean::
rm -f ${TARGETS}

View File

@@ -1,12 +0,0 @@
#
# test data for dns_master_load test 1
#
# format is:
# masterfile origin class expected_result
# where
# masterfile name is the name of a file containing master data
# origin is the origin
# class is the zone's class
# expected_result is a text representation of a dns_result_t
#
master1.data test in DNS_R_SUCCESS

View File

@@ -1,12 +0,0 @@
#
# test data for dns_master_load test 2
#
# format is:
# masterfile origin class expected_result
# where
# masterfile name is the name of a file containing master data
# origin is the origin
# class is the zone's class
# expected_result is a text representation of a dns_result_t
#
master2.data test in DNS_R_UNEXPECTEDEND

Some files were not shown because too many files have changed in this diff Show More