summaryrefslogtreecommitdiffstats
path: root/contrib/unbound
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2014-07-29 20:57:38 +0000
committerdes <des@FreeBSD.org>2014-07-29 20:57:38 +0000
commitfe6d9379787eb938c503444ce243caa89cc7b08c (patch)
tree5cc01e837e3c2f3dfb21ef0136ca69be1f957059 /contrib/unbound
parent1f52ac9340be3979c9bf100fe65c551bcd870cc6 (diff)
downloadFreeBSD-src-fe6d9379787eb938c503444ce243caa89cc7b08c.zip
FreeBSD-src-fe6d9379787eb938c503444ce243caa89cc7b08c.tar.gz
MFH (r266114, r266138): upgrade to latest ldns and unbound
MFH (r266139-r266143, r266145, r266149, r266150): fix props MFH (r266179, r266180, r266193, r266238, r266777): misc cleanup MFH (r266863): create and use /var/unbound/conf.d MFH (r268839): import unblock-lan-zones patch from upstream MFH (r268840): fix reverse lookups on private networks MFH (r268883): avoid spamming source tree during build PR: 190739 (for r268883)
Diffstat (limited to 'contrib/unbound')
-rw-r--r--contrib/unbound/LICENSE20
-rw-r--r--contrib/unbound/Makefile.in812
-rw-r--r--contrib/unbound/acx_nlnetlabs.m442
-rw-r--r--contrib/unbound/acx_pthread.m4280
-rw-r--r--contrib/unbound/ax_pthread.m4317
-rw-r--r--contrib/unbound/compat/snprintf.c1770
-rw-r--r--contrib/unbound/compat/strlcat.c73
-rw-r--r--contrib/unbound/config.h61
-rw-r--r--contrib/unbound/config.h.in53
-rwxr-xr-xcontrib/unbound/configure762
-rw-r--r--contrib/unbound/configure.ac186
-rw-r--r--contrib/unbound/daemon/acl_list.c24
-rw-r--r--contrib/unbound/daemon/acl_list.h24
-rw-r--r--contrib/unbound/daemon/cachedump.c298
-rw-r--r--contrib/unbound/daemon/cachedump.h20
-rw-r--r--contrib/unbound/daemon/daemon.c100
-rw-r--r--contrib/unbound/daemon/daemon.h27
-rw-r--r--contrib/unbound/daemon/remote.c209
-rw-r--r--contrib/unbound/daemon/remote.h20
-rw-r--r--contrib/unbound/daemon/stats.c39
-rw-r--r--contrib/unbound/daemon/stats.h24
-rw-r--r--contrib/unbound/daemon/unbound.c32
-rw-r--r--contrib/unbound/daemon/worker.c302
-rw-r--r--contrib/unbound/daemon/worker.h20
-rw-r--r--contrib/unbound/doc/Changelog311
-rw-r--r--contrib/unbound/doc/FEATURES1
-rw-r--r--contrib/unbound/doc/LICENSE20
-rw-r--r--contrib/unbound/doc/README11
-rw-r--r--contrib/unbound/doc/example.conf.in62
-rw-r--r--contrib/unbound/doc/libunbound.39
-rw-r--r--contrib/unbound/doc/libunbound.3.in9
-rw-r--r--contrib/unbound/doc/unbound-anchor.82
-rw-r--r--contrib/unbound/doc/unbound-anchor.8.in2
-rw-r--r--contrib/unbound/doc/unbound-checkconf.82
-rw-r--r--contrib/unbound/doc/unbound-checkconf.8.in2
-rw-r--r--contrib/unbound/doc/unbound-control.812
-rw-r--r--contrib/unbound/doc/unbound-control.8.in12
-rw-r--r--contrib/unbound/doc/unbound-host.12
-rw-r--r--contrib/unbound/doc/unbound.84
-rw-r--r--contrib/unbound/doc/unbound.8.in4
-rw-r--r--contrib/unbound/doc/unbound.conf.549
-rw-r--r--contrib/unbound/doc/unbound.conf.5.in49
-rwxr-xr-xcontrib/unbound/freebsd-configure.sh13
-rw-r--r--contrib/unbound/iterator/iter_delegpt.c53
-rw-r--r--contrib/unbound/iterator/iter_delegpt.h50
-rw-r--r--contrib/unbound/iterator/iter_donotq.c20
-rw-r--r--contrib/unbound/iterator/iter_donotq.h20
-rw-r--r--contrib/unbound/iterator/iter_fwd.c78
-rw-r--r--contrib/unbound/iterator/iter_fwd.h30
-rw-r--r--contrib/unbound/iterator/iter_hints.c147
-rw-r--r--contrib/unbound/iterator/iter_hints.h20
-rw-r--r--contrib/unbound/iterator/iter_priv.c95
-rw-r--r--contrib/unbound/iterator/iter_priv.h26
-rw-r--r--contrib/unbound/iterator/iter_resptype.c23
-rw-r--r--contrib/unbound/iterator/iter_resptype.h20
-rw-r--r--contrib/unbound/iterator/iter_scrub.c75
-rw-r--r--contrib/unbound/iterator/iter_scrub.h24
-rw-r--r--contrib/unbound/iterator/iter_utils.c69
-rw-r--r--contrib/unbound/iterator/iter_utils.h30
-rw-r--r--contrib/unbound/iterator/iterator.c107
-rw-r--r--contrib/unbound/iterator/iterator.h20
-rw-r--r--contrib/unbound/ldns/keyraw.c368
-rw-r--r--contrib/unbound/ldns/keyraw.h112
-rw-r--r--contrib/unbound/ldns/parse.c470
-rw-r--r--contrib/unbound/ldns/parse.h184
-rw-r--r--contrib/unbound/ldns/parseutil.c726
-rw-r--r--contrib/unbound/ldns/parseutil.h148
-rw-r--r--contrib/unbound/ldns/pkthdr.h158
-rw-r--r--contrib/unbound/ldns/rrdef.c738
-rw-r--r--contrib/unbound/ldns/rrdef.h503
-rw-r--r--contrib/unbound/ldns/sbuffer.c178
-rw-r--r--contrib/unbound/ldns/sbuffer.h706
-rw-r--r--contrib/unbound/ldns/str2wire.c2001
-rw-r--r--contrib/unbound/ldns/str2wire.h541
-rw-r--r--contrib/unbound/ldns/wire2str.c1967
-rw-r--r--contrib/unbound/ldns/wire2str.h984
-rw-r--r--contrib/unbound/libunbound/context.c81
-rw-r--r--contrib/unbound/libunbound/context.h33
-rw-r--r--contrib/unbound/libunbound/libunbound.c221
-rw-r--r--contrib/unbound/libunbound/libworker.c208
-rw-r--r--contrib/unbound/libunbound/libworker.h49
-rw-r--r--contrib/unbound/libunbound/ubsyms.def3
-rw-r--r--contrib/unbound/libunbound/unbound-event.h135
-rw-r--r--contrib/unbound/libunbound/unbound.h38
-rw-r--r--contrib/unbound/libunbound/worker.h9
-rw-r--r--contrib/unbound/services/cache/dns.c63
-rw-r--r--contrib/unbound/services/cache/dns.h28
-rw-r--r--contrib/unbound/services/cache/infra.c44
-rw-r--r--contrib/unbound/services/cache/infra.h38
-rw-r--r--contrib/unbound/services/cache/rrset.c33
-rw-r--r--contrib/unbound/services/cache/rrset.h30
-rw-r--r--contrib/unbound/services/listen_dnsport.c147
-rw-r--r--contrib/unbound/services/listen_dnsport.h40
-rw-r--r--contrib/unbound/services/localzone.c343
-rw-r--r--contrib/unbound/services/localzone.h29
-rw-r--r--contrib/unbound/services/mesh.c73
-rw-r--r--contrib/unbound/services/mesh.h35
-rw-r--r--contrib/unbound/services/modstack.c20
-rw-r--r--contrib/unbound/services/modstack.h20
-rw-r--r--contrib/unbound/services/outbound_list.c20
-rw-r--r--contrib/unbound/services/outbound_list.h20
-rw-r--r--contrib/unbound/services/outside_network.c266
-rw-r--r--contrib/unbound/services/outside_network.h42
-rw-r--r--contrib/unbound/smallapp/unbound-anchor.c43
-rw-r--r--contrib/unbound/smallapp/unbound-checkconf.c29
-rwxr-xr-xcontrib/unbound/smallapp/unbound-control-setup.sh20
-rwxr-xr-xcontrib/unbound/smallapp/unbound-control-setup.sh.in20
-rw-r--r--contrib/unbound/smallapp/unbound-control.c22
-rw-r--r--contrib/unbound/smallapp/unbound-host.c94
-rw-r--r--contrib/unbound/smallapp/worker_cb.c31
-rw-r--r--contrib/unbound/util/alloc.c26
-rw-r--r--contrib/unbound/util/alloc.h38
-rw-r--r--contrib/unbound/util/config_file.c132
-rw-r--r--contrib/unbound/util/config_file.h33
-rw-r--r--contrib/unbound/util/configlexer.c3536
-rw-r--r--contrib/unbound/util/configlexer.lex136
-rw-r--r--contrib/unbound/util/configparser.c2330
-rw-r--r--contrib/unbound/util/configparser.h138
-rw-r--r--contrib/unbound/util/configparser.y68
-rw-r--r--contrib/unbound/util/data/dname.c95
-rw-r--r--contrib/unbound/util/data/dname.h37
-rw-r--r--contrib/unbound/util/data/msgencode.c294
-rw-r--r--contrib/unbound/util/data/msgencode.h31
-rw-r--r--contrib/unbound/util/data/msgparse.c271
-rw-r--r--contrib/unbound/util/data/msgparse.h40
-rw-r--r--contrib/unbound/util/data/msgreply.c128
-rw-r--r--contrib/unbound/util/data/msgreply.h41
-rw-r--r--contrib/unbound/util/data/packed_rrset.c229
-rw-r--r--contrib/unbound/util/data/packed_rrset.h80
-rw-r--r--contrib/unbound/util/fptr_wlist.c22
-rw-r--r--contrib/unbound/util/fptr_wlist.h20
-rw-r--r--contrib/unbound/util/iana_ports.inc26
-rw-r--r--contrib/unbound/util/locks.c20
-rw-r--r--contrib/unbound/util/locks.h20
-rw-r--r--contrib/unbound/util/log.c32
-rw-r--r--contrib/unbound/util/log.h28
-rw-r--r--contrib/unbound/util/mini_event.c24
-rw-r--r--contrib/unbound/util/mini_event.h24
-rw-r--r--contrib/unbound/util/module.c20
-rw-r--r--contrib/unbound/util/module.h139
-rw-r--r--contrib/unbound/util/net_help.c41
-rw-r--r--contrib/unbound/util/net_help.h20
-rw-r--r--contrib/unbound/util/netevent.c229
-rw-r--r--contrib/unbound/util/netevent.h47
-rw-r--r--contrib/unbound/util/random.c21
-rw-r--r--contrib/unbound/util/random.h20
-rw-r--r--contrib/unbound/util/rbtree.c20
-rw-r--r--contrib/unbound/util/rbtree.h20
-rw-r--r--contrib/unbound/util/regional.c20
-rw-r--r--contrib/unbound/util/regional.h20
-rw-r--r--contrib/unbound/util/rtt.c20
-rw-r--r--contrib/unbound/util/rtt.h20
-rw-r--r--contrib/unbound/util/storage/dnstree.c20
-rw-r--r--contrib/unbound/util/storage/dnstree.h20
-rw-r--r--contrib/unbound/util/storage/lookup3.c26
-rw-r--r--contrib/unbound/util/storage/lookup3.h20
-rw-r--r--contrib/unbound/util/storage/lruhash.c20
-rw-r--r--contrib/unbound/util/storage/lruhash.h20
-rw-r--r--contrib/unbound/util/storage/slabhash.c20
-rw-r--r--contrib/unbound/util/storage/slabhash.h20
-rw-r--r--contrib/unbound/util/timehist.c21
-rw-r--r--contrib/unbound/util/timehist.h20
-rw-r--r--contrib/unbound/util/tube.c22
-rw-r--r--contrib/unbound/util/tube.h20
-rw-r--r--contrib/unbound/util/winsock_event.c42
-rw-r--r--contrib/unbound/util/winsock_event.h24
-rw-r--r--contrib/unbound/validator/autotrust.c896
-rw-r--r--contrib/unbound/validator/autotrust.h33
-rw-r--r--contrib/unbound/validator/val_anchor.c241
-rw-r--r--contrib/unbound/validator/val_anchor.h23
-rw-r--r--contrib/unbound/validator/val_kcache.c22
-rw-r--r--contrib/unbound/validator/val_kcache.h22
-rw-r--r--contrib/unbound/validator/val_kentry.c35
-rw-r--r--contrib/unbound/validator/val_kentry.h32
-rw-r--r--contrib/unbound/validator/val_neg.c42
-rw-r--r--contrib/unbound/validator/val_neg.h25
-rw-r--r--contrib/unbound/validator/val_nsec.c23
-rw-r--r--contrib/unbound/validator/val_nsec.h22
-rw-r--r--contrib/unbound/validator/val_nsec3.c123
-rw-r--r--contrib/unbound/validator/val_nsec3.h34
-rw-r--r--contrib/unbound/validator/val_secalgo.c78
-rw-r--r--contrib/unbound/validator/val_secalgo.h23
-rw-r--r--contrib/unbound/validator/val_sigcrypt.c166
-rw-r--r--contrib/unbound/validator/val_sigcrypt.h36
-rw-r--r--contrib/unbound/validator/val_utils.c28
-rw-r--r--contrib/unbound/validator/val_utils.h20
-rw-r--r--contrib/unbound/validator/validator.c65
-rw-r--r--contrib/unbound/validator/validator.h20
188 files changed, 17701 insertions, 12288 deletions
diff --git a/contrib/unbound/LICENSE b/contrib/unbound/LICENSE
index c248049..1859c09 100644
--- a/contrib/unbound/LICENSE
+++ b/contrib/unbound/LICENSE
@@ -18,13 +18,13 @@ be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/contrib/unbound/Makefile.in b/contrib/unbound/Makefile.in
index 0064341..27defa6 100644
--- a/contrib/unbound/Makefile.in
+++ b/contrib/unbound/Makefile.in
@@ -16,7 +16,6 @@ datadir=@datadir@
includedir=@includedir@
doxygen=@doxygen@
libtool=@libtool@
-ldnsdir=@ldnsdir@
staticexe=@staticexe@
EXEEXT=@EXEEXT@
configfile=@ub_conf_file@
@@ -30,7 +29,13 @@ PYTHONMOD_INSTALL=@PYTHONMOD_INSTALL@
PYTHONMOD_UNINSTALL=@PYTHONMOD_UNINSTALL@
PYUNBOUND_INSTALL=@PYUNBOUND_INSTALL@
PYUNBOUND_UNINSTALL=@PYUNBOUND_UNINSTALL@
+UNBOUND_EVENT_INSTALL=@UNBOUND_EVENT_INSTALL@
+UNBOUND_EVENT_UNINSTALL=@UNBOUND_EVENT_UNINSTALL@
+UNBOUND_VERSION_MAJOR=@UNBOUND_VERSION_MAJOR@
+UNBOUND_VERSION_MINOR=@UNBOUND_VERSION_MINOR@
+UNBOUND_VERSION_MICRO=@UNBOUND_VERSION_MICRO@
ALLTARGET=@ALLTARGET@
+INSTALLTARGET=@INSTALLTARGET@
# _unbound.la if pyunbound enabled.
PYUNBOUND_TARGET=@PYUNBOUND_TARGET@
@@ -61,7 +66,7 @@ EXTRALINK=@EXTRALINK@
WINDRES=@WINDRES@
LINT=splint
-LINTFLAGS=+quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned -Du_char=uint8_t -preproc -Drlimit=rlimit64 -D__gnuc_va_list=va_list
+LINTFLAGS=+quiet -weak -warnposix -unrecog -Din_addr_t=uint32_t -Du_int=unsigned -Du_char=uint8_t -preproc -Drlimit=rlimit64 -D__gnuc_va_list=va_list -formatcode
#-Dglob64=glob -Dglobfree64=globfree
# compat with openssl linux edition.
LINTFLAGS+="-DBN_ULONG=unsigned long" -Dkrb5_int32=int "-Dkrb5_ui_4=unsigned int" -DPQ_64BIT=uint64_t -DRC4_INT=unsigned -fixedformalarray -D"ENGINE=unsigned" -D"RSA=unsigned" -D"DSA=unsigned" -D"EVP_PKEY=unsigned" -D"EVP_MD=unsigned" -D"SSL=unsigned" -D"SSL_CTX=unsigned" -D"X509=unsigned" -D"RC4_KEY=unsigned" -D"EVP_MD_CTX=unsigned" -D"ECDSA_SIG=DSA_SIG"
@@ -69,8 +74,8 @@ LINTFLAGS+="-DBN_ULONG=unsigned long" -Dkrb5_int32=int "-Dkrb5_ui_4=unsigned int
LINTFLAGS+=@NETBSD_LINTFLAGS@
# compat with OpenBSD
LINTFLAGS+="-Dsigset_t=long"
-# FreeBSD8
-LINTFLAGS+="-D__uint16_t=uint16_t"
+# FreeBSD
+LINTFLAGS+="-D__uint16_t=uint16_t" "-DEVP_PKEY_ASN1_METHOD=int"
INSTALL=$(srcdir)/install-sh
@@ -118,80 +123,83 @@ outside_network.lo
COMMON_OBJ_ALL_SYMBOLS=@COMMON_OBJ_ALL_SYMBOLS@
COMPAT_SRC=compat/ctime_r.c compat/fake-rfc2553.c compat/gmtime_r.c \
compat/inet_aton.c compat/inet_ntop.c compat/inet_pton.c compat/malloc.c \
-compat/memcmp.c compat/memmove.c compat/snprintf.c compat/strlcpy.c \
-compat/strptime.c
+compat/memcmp.c compat/memmove.c compat/snprintf.c compat/strlcat.c \
+compat/strlcpy.c compat/strptime.c
COMPAT_OBJ=$(LIBOBJS:.o=.lo)
COMPAT_OBJ_WITHOUT_CTIME=$(LIBOBJ_WITHOUT_CTIME:.o=.lo)
+SLDNS_SRC=ldns/keyraw.c ldns/sbuffer.c ldns/wire2str.c ldns/parse.c \
+ldns/parseutil.c ldns/rrdef.c ldns/str2wire.c
+SLDNS_OBJ=keyraw.lo sbuffer.lo wire2str.lo parse.lo parseutil.lo rrdef.lo \
+str2wire.lo
UNITTEST_SRC=testcode/unitanchor.c testcode/unitdname.c \
testcode/unitlruhash.c testcode/unitmain.c testcode/unitmsgparse.c \
testcode/unitneg.c testcode/unitregional.c testcode/unitslabhash.c \
-testcode/unitverify.c testcode/readhex.c testcode/ldns-testpkts.c
+testcode/unitverify.c testcode/readhex.c testcode/testpkts.c testcode/unitldns.c
UNITTEST_OBJ=unitanchor.lo unitdname.lo unitlruhash.lo unitmain.lo \
unitmsgparse.lo unitneg.lo unitregional.lo unitslabhash.lo unitverify.lo \
-readhex.lo ldns-testpkts.lo
-UNITTEST_OBJ_LINK=$(UNITTEST_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ)
+readhex.lo testpkts.lo unitldns.lo
+UNITTEST_OBJ_LINK=$(UNITTEST_OBJ) worker_cb.lo $(COMMON_OBJ) $(SLDNS_OBJ) \
+$(COMPAT_OBJ)
DAEMON_SRC=daemon/acl_list.c daemon/cachedump.c daemon/daemon.c \
daemon/remote.c daemon/stats.c daemon/unbound.c daemon/worker.c @WIN_DAEMON_SRC@
DAEMON_OBJ=acl_list.lo cachedump.lo daemon.lo remote.lo stats.lo unbound.lo \
worker.lo @WIN_DAEMON_OBJ@
-DAEMON_OBJ_LINK=$(DAEMON_OBJ) $(COMMON_OBJ_ALL_SYMBOLS) \
+DAEMON_OBJ_LINK=$(DAEMON_OBJ) $(COMMON_OBJ_ALL_SYMBOLS) $(SLDNS_OBJ) \
$(COMPAT_OBJ) @WIN_DAEMON_OBJ_LINK@
CHECKCONF_SRC=smallapp/unbound-checkconf.c smallapp/worker_cb.c
CHECKCONF_OBJ=unbound-checkconf.lo worker_cb.lo
-CHECKCONF_OBJ_LINK=$(CHECKCONF_OBJ) $(COMMON_OBJ_ALL_SYMBOLS) \
+CHECKCONF_OBJ_LINK=$(CHECKCONF_OBJ) $(COMMON_OBJ_ALL_SYMBOLS) $(SLDNS_OBJ) \
$(COMPAT_OBJ) @WIN_CHECKCONF_OBJ_LINK@
CONTROL_SRC=smallapp/unbound-control.c
CONTROL_OBJ=unbound-control.lo
CONTROL_OBJ_LINK=$(CONTROL_OBJ) worker_cb.lo $(COMMON_OBJ_ALL_SYMBOLS) \
-$(COMPAT_OBJ) @WIN_CONTROL_OBJ_LINK@
+$(SLDNS_OBJ) $(COMPAT_OBJ) @WIN_CONTROL_OBJ_LINK@
HOST_SRC=smallapp/unbound-host.c
HOST_OBJ=unbound-host.lo
-HOST_OBJ_LINK=$(HOST_OBJ) $(COMPAT_OBJ_WITHOUT_CTIME) @WIN_HOST_OBJ_LINK@
+HOST_OBJ_LINK=$(HOST_OBJ) $(SLDNS_OBJ) $(COMPAT_OBJ_WITHOUT_CTIME) @WIN_HOST_OBJ_LINK@
UBANCHOR_SRC=smallapp/unbound-anchor.c
UBANCHOR_OBJ=unbound-anchor.lo
UBANCHOR_OBJ_LINK=$(UBANCHOR_OBJ) \
$(COMPAT_OBJ_WITHOUT_CTIME) @WIN_UBANCHOR_OBJ_LINK@
-TESTBOUND_SRC=testcode/testbound.c testcode/ldns-testpkts.c \
+TESTBOUND_SRC=testcode/testbound.c testcode/testpkts.c \
daemon/worker.c daemon/acl_list.c daemon/daemon.c daemon/stats.c \
testcode/replay.c testcode/fake_event.c
TESTBOUND_OBJ=testbound.lo replay.lo fake_event.lo
-TESTBOUND_OBJ_LINK=$(TESTBOUND_OBJ) ldns-testpkts.lo worker.lo acl_list.lo \
-daemon.lo stats.lo $(COMMON_OBJ_WITHOUT_NETCALL) $(COMPAT_OBJ)
+TESTBOUND_OBJ_LINK=$(TESTBOUND_OBJ) testpkts.lo worker.lo acl_list.lo \
+daemon.lo stats.lo $(COMMON_OBJ_WITHOUT_NETCALL) $(SLDNS_OBJ) $(COMPAT_OBJ)
LOCKVERIFY_SRC=testcode/lock_verify.c
LOCKVERIFY_OBJ=lock_verify.lo
-LOCKVERIFY_OBJ_LINK=$(LOCKVERIFY_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ)
+LOCKVERIFY_OBJ_LINK=$(LOCKVERIFY_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ) \
+$(SLDNS_OBJ)
PETAL_SRC=testcode/petal.c
PETAL_OBJ=petal.lo
PETAL_OBJ_LINK=$(PETAL_OBJ) $(COMPAT_OBJ_WITHOUT_CTIME)
PKTVIEW_SRC=testcode/pktview.c testcode/readhex.c
PKTVIEW_OBJ=pktview.lo
PKTVIEW_OBJ_LINK=$(PKTVIEW_OBJ) worker_cb.lo readhex.lo $(COMMON_OBJ) \
-$(COMPAT_OBJ)
-SIGNIT_SRC=testcode/signit.c
-SIGNIT_OBJ=signit.lo
-SIGNIT_OBJ_LINK=$(SIGNIT_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ)
+$(COMPAT_OBJ) $(SLDNS_OBJ)
MEMSTATS_SRC=testcode/memstats.c
MEMSTATS_OBJ=memstats.lo
-MEMSTATS_OBJ_LINK=$(MEMSTATS_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ)
+MEMSTATS_OBJ_LINK=$(MEMSTATS_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ) \
+$(SLDNS_OBJ)
ASYNCLOOK_SRC=testcode/asynclook.c
ASYNCLOOK_OBJ=asynclook.lo
ASYNCLOOK_OBJ_LINK=$(ASYNCLOOK_OBJ) log.lo locks.lo $(COMPAT_OBJ)
STREAMTCP_SRC=testcode/streamtcp.c
STREAMTCP_OBJ=streamtcp.lo
-STREAMTCP_OBJ_LINK=$(STREAMTCP_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ)
+STREAMTCP_OBJ_LINK=$(STREAMTCP_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ) \
+$(SLDNS_OBJ)
PERF_SRC=testcode/perf.c
PERF_OBJ=perf.lo
-PERF_OBJ_LINK=$(PERF_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ)
+PERF_OBJ_LINK=$(PERF_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ) $(SLDNS_OBJ)
DELAYER_SRC=testcode/delayer.c
DELAYER_OBJ=delayer.lo
-DELAYER_OBJ_LINK=$(DELAYER_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ)
-HARVEST_SRC=testcode/harvest.c
-HARVEST_OBJ=harvest.lo
-HARVEST_OBJ_LINK=$(HARVEST_OBJ) $(COMPAT_OBJ_WITHOUT_CTIME)
+DELAYER_OBJ_LINK=$(DELAYER_OBJ) worker_cb.lo $(COMMON_OBJ) $(COMPAT_OBJ) \
+$(SLDNS_OBJ)
LIBUNBOUND_SRC=libunbound/context.c libunbound/libunbound.c \
libunbound/libworker.c
LIBUNBOUND_OBJ=context.lo libunbound.lo libworker.lo
-LIBUNBOUND_OBJ_LINK=$(LIBUNBOUND_OBJ) $(COMMON_OBJ) $(COMPAT_OBJ)
+LIBUNBOUND_OBJ_LINK=$(LIBUNBOUND_OBJ) $(COMMON_OBJ) $(SLDNS_OBJ) $(COMPAT_OBJ)
# win apps or "" if not on windows
WINAPPS=@WINAPPS@
@@ -211,19 +219,19 @@ RSRC_OBJ=rsrc_svcinst.o rsrc_svcuninst.o rsrc_anchorupd.o rsrc_unbound.o \
rsrc_unbound_checkconf.o
ALL_SRC=$(COMMON_SRC) $(UNITTEST_SRC) $(DAEMON_SRC) \
- $(TESTBOUND_SRC) $(LOCKVERIFY_SRC) $(PKTVIEW_SRC) $(SIGNIT_SRC) \
+ $(TESTBOUND_SRC) $(LOCKVERIFY_SRC) $(PKTVIEW_SRC) \
$(MEMSTATS_SRC) $(CHECKCONF_SRC) $(LIBUNBOUND_SRC) $(HOST_SRC) \
$(ASYNCLOOK_SRC) $(STREAMTCP_SRC) $(PERF_SRC) $(DELAYER_SRC) \
- $(HARVEST_SRC) $(CONTROL_SRC) $(UBANCHOR_SRC) $(PETAL_SRC) \
+ $(CONTROL_SRC) $(UBANCHOR_SRC) $(PETAL_SRC) \
$(PYTHONMOD_SRC) $(PYUNBOUND_SRC) $(WIN_DAEMON_THE_SRC)\
- $(SVCINST_SRC) $(SVCUNINST_SRC) $(ANCHORUPD_SRC)
+ $(SVCINST_SRC) $(SVCUNINST_SRC) $(ANCHORUPD_SRC) $(SLDNS_SRC)
ALL_OBJ=$(COMMON_OBJ) $(UNITTEST_OBJ) $(DAEMON_OBJ) \
- $(TESTBOUND_OBJ) $(LOCKVERIFY_OBJ) $(PKTVIEW_OBJ) $(SIGNIT_OBJ) \
+ $(TESTBOUND_OBJ) $(LOCKVERIFY_OBJ) $(PKTVIEW_OBJ) \
$(MEMSTATS_OBJ) $(CHECKCONF_OBJ) $(LIBUNBOUND_OBJ) $(HOST_OBJ) \
$(ASYNCLOOK_OBJ) $(STREAMTCP_OBJ) $(PERF_OBJ) $(DELAYER_OBJ) \
- $(HARVEST_OBJ) $(CONTROL_OBJ) $(UBANCHOR_OBJ) $(PETAL_OBJ) \
+ $(CONTROL_OBJ) $(UBANCHOR_OBJ) $(PETAL_OBJ) \
$(COMPAT_OBJ) $(PYUNBOUND_OBJ) \
- $(SVCINST_OBJ) $(SVCUNINST_OBJ) $(ANCHORUPD_OBJ)
+ $(SVCINST_OBJ) $(SVCUNINST_OBJ) $(ANCHORUPD_OBJ) $(SLDNS_OBJ)
COMPILE=$(LIBTOOL) --tag=CC --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS)
LINK=$(LIBTOOL) --tag=CC --mode=link $(CC) $(staticexe) $(RUNTIME_PATH) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
@@ -257,9 +265,9 @@ rsrc_unbound_anchor.o: $(srcdir)/winrc/rsrc_unbound_anchor.rc config.h
rsrc_unbound_control.o: $(srcdir)/winrc/rsrc_unbound_control.rc config.h
rsrc_unbound_checkconf.o: $(srcdir)/winrc/rsrc_unbound_checkconf.rc config.h
-TEST_BIN=asynclook$(EXEEXT) delayer$(EXEEXT) harvest$(EXEEXT) \
+TEST_BIN=asynclook$(EXEEXT) delayer$(EXEEXT) \
lock-verify$(EXEEXT) memstats$(EXEEXT) perf$(EXEEXT) \
- petal$(EXEEXT) pktview$(EXEEXT) signit$(EXEEXT) streamtcp$(EXEEXT) \
+ petal$(EXEEXT) pktview$(EXEEXT) streamtcp$(EXEEXT) \
testbound$(EXEEXT) unittest$(EXEEXT)
tests: all $(TEST_BIN)
@@ -275,7 +283,7 @@ test: unittest$(EXEEXT) testbound$(EXEEXT)
longtest: tests
if test -x "`which bash`"; then bash testcode/do-tests.sh; else sh testcode/do-tests.sh; fi
-lib: libunbound.la
+lib: libunbound.la unbound.h
libunbound.la: $(LIBUNBOUND_OBJ_LINK)
$(LINK_LIB) $(UBSYMS) -o $@ $(LIBUNBOUND_OBJ_LINK) -rpath $(libdir) -lssl $(LIBS)
@@ -319,9 +327,6 @@ petal$(EXEEXT): $(PETAL_OBJ_LINK)
pktview$(EXEEXT): $(PKTVIEW_OBJ_LINK)
$(LINK) -o $@ $(PKTVIEW_OBJ_LINK) -lssl $(LIBS)
-signit$(EXEEXT): $(SIGNIT_OBJ_LINK)
- $(LINK) -o $@ $(SIGNIT_OBJ_LINK) -lssl $(LIBS)
-
memstats$(EXEEXT): $(MEMSTATS_OBJ_LINK)
$(LINK) -o $@ $(MEMSTATS_OBJ_LINK) -lssl $(LIBS)
@@ -337,18 +342,16 @@ perf$(EXEEXT): $(PERF_OBJ_LINK)
delayer$(EXEEXT): $(DELAYER_OBJ_LINK)
$(LINK) -o $@ $(DELAYER_OBJ_LINK) -lssl $(LIBS)
-harvest$(EXEEXT): $(HARVEST_OBJ_LINK) libunbound.la
- $(LINK) -o $@ $(HARVEST_OBJ_LINK) $(LIBS) -L. -L.libs -lunbound
+signit$(EXEEXT): testcode/signit.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ testcode/signit.c $(LDFLAGS) -lldns -lssl $(LIBS)
+
+unbound.h: $(srcdir)/libunbound/unbound.h
+ sed -e 's/@''UNBOUND_VERSION_MAJOR@/$(UNBOUND_VERSION_MAJOR)/' -e 's/@''UNBOUND_VERSION_MINOR@/$(UNBOUND_VERSION_MINOR)/' -e 's/@''UNBOUND_VERSION_MICRO@/$(UNBOUND_VERSION_MICRO)/' < $(srcdir)/libunbound/unbound.h > $@
unbound-control-setup: $(srcdir)/smallapp/unbound-control-setup.sh
sed -e 's:^DESTDIR=.*$$:DESTDIR=$(UNBOUND_RUN_DIR):' < $(srcdir)/smallapp/unbound-control-setup.sh > $@
-chmod +x $@
-#testcode/ldns-testpkts.c: $(ldnsdir)/examples/ldns-testpkts.c \
-# $(ldnsdir)/examples/ldns-testpkts.h
-# cp $(ldnsdir)/examples/ldns-testpkts.c testcode/ldns-testpkts.c
-# cp $(ldnsdir)/examples/ldns-testpkts.h testcode/ldns-testpkts.h
-
# Python Module
pythonmod.lo pythonmod.o: $(srcdir)/pythonmod/pythonmod.c config.h \
pythonmod/interface.h \
@@ -367,8 +370,8 @@ pythonmod/interface.h: $(srcdir)/pythonmod/interface.i config.h
$(SWIG) $(CPPFLAGS) -o $@ -python $(srcdir)/pythonmod/interface.i
libunbound_wrap.lo libunbound_wrap.o: libunbound/python/libunbound_wrap.c \
- $(srcdir)/libunbound/unbound.h
-libunbound/python/libunbound_wrap.c: $(srcdir)/libunbound/python/libunbound.i $(srcdir)/libunbound/unbound.h
+ unbound.h
+libunbound/python/libunbound_wrap.c: $(srcdir)/libunbound/python/libunbound.i unbound.h
@-if test ! -d libunbound/python; then $(INSTALL) -d libunbound/python; fi
$(SWIG) -python -o $@ $(CPPFLAGS) $(srcdir)/libunbound/python/libunbound.i
@@ -391,7 +394,7 @@ util/configparser.c util/configparser.h: $(srcdir)/util/configparser.y
clean:
rm -f *.o *.d *.lo *~ tags
- rm -f unbound$(EXEEXT) unbound-checkconf$(EXEEXT) unbound-host$(EXEEXT) unbound-control$(EXEEXT) unbound-anchor$(EXEEXT) unbound-control-setup libunbound.la
+ rm -f unbound$(EXEEXT) unbound-checkconf$(EXEEXT) unbound-host$(EXEEXT) unbound-control$(EXEEXT) unbound-anchor$(EXEEXT) unbound-control-setup libunbound.la unbound.h
rm -f $(ALL_SRC:.c=.lint)
rm -f _unbound.la libunbound/python/libunbound_wrap.c libunbound/python/unbound.py pythonmod/interface.h pythonmod/unboundmodule.py
rm -rf autom4te.cache .libs build doc/html doc/xml
@@ -406,7 +409,7 @@ realclean: clean
.SUFFIXES: .lint
.c.lint:
- $(LINT) $(LINTFLAGS) -I. -I$(srcdir) -I$(ldnsdir)/include $<
+ $(LINT) $(LINTFLAGS) -I. -I$(srcdir) $<
touch $@
util/configparser.lint util/configlexer.lint pythonmod/pythonmod.lint libunbound/python/libunbound_wrap.lint:
@@ -449,15 +452,38 @@ pyunbound-install:
$(LIBTOOL) --mode=install cp _unbound.la $(DESTDIR)$(PYTHON_SITE_PKG)
$(LIBTOOL) --mode=finish $(DESTDIR)$(PYTHON_SITE_PKG)
-install: all $(PYTHONMOD_INSTALL) $(PYUNBOUND_INSTALL)
+unbound-event-install:
+ $(INSTALL) -m 755 -d $(DESTDIR)$(includedir)
+ $(LIBTOOL) --mode=install cp $(srcdir)/libunbound/unbound-event.h $(DESTDIR)$(includedir)/unbound-event.h
+
+install: $(INSTALLTARGET)
+
+install-lib: lib $(UNBOUND_EVENT_INSTALL)
+ $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
+ $(INSTALL) -m 755 -d $(DESTDIR)$(includedir)
+ $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)
+ $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man3
+ $(INSTALL) -c -m 644 doc/libunbound.3 $(DESTDIR)$(mandir)/man3
+ for mpage in ub_ctx ub_result ub_ctx_create ub_ctx_delete \
+ ub_ctx_set_option ub_ctx_get_option ub_ctx_config ub_ctx_set_fwd \
+ ub_ctx_resolvconf ub_ctx_hosts ub_ctx_add_ta ub_ctx_add_ta_file \
+ ub_ctx_trustedkeys ub_ctx_debugout ub_ctx_debuglevel ub_ctx_async \
+ ub_poll ub_wait ub_fd ub_process ub_resolve ub_resolve_async ub_cancel \
+ ub_resolve_free ub_strerror ub_ctx_print_local_zones ub_ctx_zone_add \
+ ub_ctx_zone_remove ub_ctx_data_add ub_ctx_data_remove; \
+ do \
+ echo ".so man3/libunbound.3" > $(DESTDIR)$(mandir)/man3/$$mpage.3 ; \
+ done
+ $(LIBTOOL) --mode=install cp unbound.h $(DESTDIR)$(includedir)/unbound.h
+ $(LIBTOOL) --mode=install cp libunbound.la $(DESTDIR)$(libdir)
+ $(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
+
+install-all: all $(PYTHONMOD_INSTALL) $(PYUNBOUND_INSTALL) $(UNBOUND_EVENT_INSTALL) install-lib
$(INSTALL) -m 755 -d $(DESTDIR)$(sbindir)
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man8
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man5
- $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man3
$(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
- $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
- $(INSTALL) -m 755 -d $(DESTDIR)$(includedir)
$(LIBTOOL) --mode=install cp unbound$(EXEEXT) $(DESTDIR)$(sbindir)/unbound$(EXEEXT)
$(LIBTOOL) --mode=install cp unbound-checkconf$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-checkconf$(EXEEXT)
$(LIBTOOL) --mode=install cp unbound-control$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-control$(EXEEXT)
@@ -466,25 +492,12 @@ install: all $(PYTHONMOD_INSTALL) $(PYUNBOUND_INSTALL)
$(INSTALL) -c -m 644 doc/unbound.8 $(DESTDIR)$(mandir)/man8
$(INSTALL) -c -m 644 doc/unbound-checkconf.8 $(DESTDIR)$(mandir)/man8
$(INSTALL) -c -m 644 doc/unbound-control.8 $(DESTDIR)$(mandir)/man8
+ $(INSTALL) -c -m 644 doc/unbound-control.8 $(DESTDIR)$(mandir)/man8/unbound-control-setup.8
$(INSTALL) -c -m 644 doc/unbound-anchor.8 $(DESTDIR)$(mandir)/man8
$(INSTALL) -c -m 644 doc/unbound.conf.5 $(DESTDIR)$(mandir)/man5
$(INSTALL) -c -m 644 $(srcdir)/doc/unbound-host.1 $(DESTDIR)$(mandir)/man1
- $(INSTALL) -c -m 644 doc/libunbound.3 $(DESTDIR)$(mandir)/man3
- for mpage in ub_ctx ub_result ub_ctx_create ub_ctx_delete \
- ub_ctx_set_option ub_ctx_get_option ub_ctx_config ub_ctx_set_fwd \
- ub_ctx_resolvconf ub_ctx_hosts ub_ctx_add_ta ub_ctx_add_ta_file \
- ub_ctx_trustedkeys ub_ctx_debugout ub_ctx_debuglevel ub_ctx_async \
- ub_poll ub_wait ub_fd ub_process ub_resolve ub_resolve_async ub_cancel \
- ub_resolve_free ub_strerror ub_ctx_print_local_zones ub_ctx_zone_add \
- ub_ctx_zone_remove ub_ctx_data_add ub_ctx_data_remove; \
- do \
- echo ".so man3/libunbound.3" > $(DESTDIR)$(mandir)/man3/$$mpage.3 ; \
- done
$(INSTALL) -c -m 755 unbound-control-setup $(DESTDIR)$(sbindir)/unbound-control-setup
if test ! -e $(DESTDIR)$(configfile); then $(INSTALL) -d `dirname $(DESTDIR)$(configfile)`; $(INSTALL) -c -m 644 doc/example.conf $(DESTDIR)$(configfile); fi
- $(LIBTOOL) --mode=install cp $(srcdir)/libunbound/unbound.h $(DESTDIR)$(includedir)/unbound.h
- $(LIBTOOL) --mode=install cp libunbound.la $(DESTDIR)$(libdir)
- $(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
pythonmod-uninstall:
rm -f -- $(DESTDIR)$(PYTHON_SITE_PKG)/unboundmodule.py
@@ -493,9 +506,12 @@ pyunbound-uninstall:
rm -f -- $(DESTDIR)$(PYTHON_SITE_PKG)/unbound.py
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(PYTHON_SITE_PKG)/_unbound.la
-uninstall: $(PYTHONMOD_UNINSTALL) $(PYUNBOUND_UNINSTALL)
+unbound-event-uninstall:
+ rm -f -- $(DESTDIR)$(includedir)/unbound-event.h
+
+uninstall: $(PYTHONMOD_UNINSTALL) $(PYUNBOUND_UNINSTALL) $(UNBOUND_EVENT_UNINSTALL)
rm -f -- $(DESTDIR)$(sbindir)/unbound$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-checkconf$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-host$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-control$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-anchor$(EXEEXT) $(DESTDIR)$(sbindir)/unbound-control-setup
- rm -f -- $(DESTDIR)$(mandir)/man8/unbound.8 $(DESTDIR)$(mandir)/man8/unbound-checkconf.8 $(DESTDIR)$(mandir)/man5/unbound.conf.5 $(DESTDIR)$(mandir)/man8/unbound-control.8 $(DESTDIR)$(mandir)/man8/unbound-anchor.8
+ rm -f -- $(DESTDIR)$(mandir)/man8/unbound.8 $(DESTDIR)$(mandir)/man8/unbound-checkconf.8 $(DESTDIR)$(mandir)/man5/unbound.conf.5 $(DESTDIR)$(mandir)/man8/unbound-control.8 $(DESTDIR)$(mandir)/man8/unbound-anchor.8 $(DESTDIR)$(mandir)/man8/unbound-control-setup.8
rm -f -- $(DESTDIR)$(mandir)/man1/unbound-host.1 $(DESTDIR)$(mandir)/man3/libunbound.3
for mpage in ub_ctx ub_result ub_ctx_create ub_ctx_delete \
ub_ctx_set_option ub_ctx_get_option ub_ctx_config ub_ctx_set_fwd \
@@ -556,655 +572,3 @@ depend:
rm -f $(DEPEND_TMP) $(DEPEND_TMP2)
# Dependencies
-dns.lo dns.o: $(srcdir)/services/cache/dns.c config.h $(srcdir)/iterator/iter_delegpt.h $(srcdir)/util/log.h \
- $(srcdir)/validator/val_nsec.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/services/cache/dns.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/module.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/net_help.h \
- $(srcdir)/util/regional.h $(srcdir)/util/config_file.h
-infra.lo infra.o: $(srcdir)/services/cache/infra.c config.h \
- $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/rtt.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/config_file.h $(srcdir)/iterator/iterator.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgparse.h \
-
-rrset.lo rrset.o: $(srcdir)/services/cache/rrset.c config.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/config_file.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/regional.h $(srcdir)/util/alloc.h
-dname.lo dname.o: $(srcdir)/util/data/dname.c config.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/storage/lookup3.h
-msgencode.lo msgencode.o: $(srcdir)/util/data/msgencode.c config.h \
- $(srcdir)/util/data/msgencode.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/regional.h $(srcdir)/util/net_help.h
-msgparse.lo msgparse.o: $(srcdir)/util/data/msgparse.c config.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/regional.h
-msgreply.lo msgreply.o: $(srcdir)/util/data/msgreply.c config.h \
- $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/storage/lookup3.h $(srcdir)/util/alloc.h $(srcdir)/util/netevent.h $(srcdir)/util/net_help.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/regional.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/data/msgencode.h
-packed_rrset.lo packed_rrset.o: $(srcdir)/util/data/packed_rrset.c config.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/alloc.h $(srcdir)/util/regional.h \
- $(srcdir)/util/net_help.h
-iterator.lo iterator.o: $(srcdir)/iterator/iterator.c config.h \
- $(srcdir)/iterator/iterator.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgparse.h $(srcdir)/iterator/iter_utils.h $(srcdir)/iterator/iter_resptype.h \
- $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h \
- $(srcdir)/iterator/iter_fwd.h $(srcdir)/iterator/iter_donotq.h $(srcdir)/iterator/iter_delegpt.h \
- $(srcdir)/iterator/iter_scrub.h $(srcdir)/iterator/iter_priv.h $(srcdir)/validator/val_neg.h \
- $(srcdir)/services/cache/dns.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/util/netevent.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/regional.h $(srcdir)/util/data/dname.h $(srcdir)/util/data/msgencode.h \
- $(srcdir)/util/fptr_wlist.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/services/modstack.h \
- $(srcdir)/util/config_file.h
-iter_delegpt.lo iter_delegpt.o: $(srcdir)/iterator/iter_delegpt.c config.h $(srcdir)/iterator/iter_delegpt.h \
- $(srcdir)/util/log.h \
- $(srcdir)/services/cache/dns.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/regional.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/net_help.h
-iter_donotq.lo iter_donotq.o: $(srcdir)/iterator/iter_donotq.c config.h $(srcdir)/iterator/iter_donotq.h \
- $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/util/regional.h $(srcdir)/util/log.h \
- $(srcdir)/util/config_file.h \
- $(srcdir)/util/net_help.h
-iter_fwd.lo iter_fwd.o: $(srcdir)/iterator/iter_fwd.c config.h \
- $(srcdir)/iterator/iter_fwd.h \
- $(srcdir)/util/rbtree.h $(srcdir)/iterator/iter_delegpt.h $(srcdir)/util/log.h $(srcdir)/util/config_file.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h
-iter_hints.lo iter_hints.o: $(srcdir)/iterator/iter_hints.c config.h \
- $(srcdir)/iterator/iter_hints.h \
- $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/iterator/iter_delegpt.h $(srcdir)/util/log.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h
-iter_priv.lo iter_priv.o: $(srcdir)/iterator/iter_priv.c config.h \
- $(srcdir)/iterator/iter_priv.h \
- $(srcdir)/util/rbtree.h \
- $(srcdir)/util/regional.h $(srcdir)/util/log.h $(srcdir)/util/config_file.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/net_help.h \
- $(srcdir)/util/storage/dnstree.h
-iter_resptype.lo iter_resptype.o: $(srcdir)/iterator/iter_resptype.c config.h \
- $(srcdir)/iterator/iter_resptype.h $(srcdir)/iterator/iter_delegpt.h $(srcdir)/util/log.h \
- $(srcdir)/services/cache/dns.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/net_help.h \
- $(srcdir)/util/data/dname.h
-iter_scrub.lo iter_scrub.o: $(srcdir)/iterator/iter_scrub.c config.h $(srcdir)/iterator/iter_scrub.h \
- $(srcdir)/iterator/iterator.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/iterator/iter_priv.h $(srcdir)/util/rbtree.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/util/net_help.h $(srcdir)/util/regional.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/data/dname.h $(srcdir)/util/alloc.h
-iter_utils.lo iter_utils.o: $(srcdir)/iterator/iter_utils.c config.h $(srcdir)/iterator/iter_utils.h \
- $(srcdir)/iterator/iter_resptype.h \
- $(srcdir)/iterator/iterator.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h \
- $(srcdir)/iterator/iter_fwd.h $(srcdir)/iterator/iter_donotq.h $(srcdir)/iterator/iter_delegpt.h \
- $(srcdir)/iterator/iter_priv.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
- $(srcdir)/services/cache/dns.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/config_file.h $(srcdir)/util/regional.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/random.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/netevent.h $(srcdir)/util/tube.h \
- $(srcdir)/services/mesh.h $(srcdir)/services/modstack.h $(srcdir)/validator/val_anchor.h \
- $(srcdir)/validator/val_kcache.h $(srcdir)/validator/val_kentry.h $(srcdir)/validator/val_utils.h
-listen_dnsport.lo listen_dnsport.o: $(srcdir)/services/listen_dnsport.c config.h \
- $(srcdir)/services/listen_dnsport.h $(srcdir)/util/netevent.h \
- $(srcdir)/services/outside_network.h $(srcdir)/util/rbtree.h $(srcdir)/util/log.h $(srcdir)/util/config_file.h \
- $(srcdir)/util/net_help.h
-localzone.lo localzone.o: $(srcdir)/services/localzone.c config.h \
- $(srcdir)/services/localzone.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/regional.h $(srcdir)/util/config_file.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgencode.h $(srcdir)/util/net_help.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/msgparse.h
-mesh.lo mesh.o: $(srcdir)/services/mesh.c config.h \
- $(srcdir)/services/mesh.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util/netevent.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/services/modstack.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/services/cache/dns.h $(srcdir)/util/net_help.h \
- $(srcdir)/util/regional.h $(srcdir)/util/data/msgencode.h $(srcdir)/util/timehist.h $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/tube.h $(srcdir)/util/alloc.h $(srcdir)/util/config_file.h
-modstack.lo modstack.o: $(srcdir)/services/modstack.c config.h $(srcdir)/services/modstack.h \
- $(srcdir)/util/module.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/netevent.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \
- $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h $(srcdir)/validator/validator.h \
- $(srcdir)/validator/val_utils.h
-outbound_list.lo outbound_list.o: $(srcdir)/services/outbound_list.c config.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/services/outside_network.h $(srcdir)/util/rbtree.h \
- $(srcdir)/util/netevent.h \
-
-outside_network.lo outside_network.o: $(srcdir)/services/outside_network.c config.h \
- $(srcdir)/services/outside_network.h $(srcdir)/util/rbtree.h $(srcdir)/util/netevent.h \
- $(srcdir)/services/listen_dnsport.h $(srcdir)/services/cache/infra.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/rtt.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgencode.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/net_help.h $(srcdir)/util/random.h $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/module.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/services/modstack.h \
-
-alloc.lo alloc.o: $(srcdir)/util/alloc.c config.h $(srcdir)/util/alloc.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/regional.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/netevent.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/tube.h \
- $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h
-config_file.lo config_file.o: $(srcdir)/util/config_file.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/configyyrename.h $(srcdir)/util/config_file.h util/configparser.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/regional.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/netevent.h $(srcdir)/util/tube.h \
- $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/iana_ports.inc
-configlexer.lo configlexer.o: util/configlexer.c config.h $(srcdir)/util/configyyrename.h \
- $(srcdir)/util/config_file.h util/configparser.h
-configparser.lo configparser.o: util/configparser.c config.h $(srcdir)/util/configyyrename.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h $(srcdir)/util/log.h \
-
-fptr_wlist.lo fptr_wlist.o: $(srcdir)/util/fptr_wlist.c config.h $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/netevent.h \
- $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/tube.h \
- $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/util/mini_event.h \
- $(srcdir)/daemon/worker.h $(srcdir)/util/alloc.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h \
- $(srcdir)/daemon/remote.h \
- $(srcdir)/services/outside_network.h $(srcdir)/services/localzone.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \
- $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h $(srcdir)/iterator/iter_fwd.h \
- $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h $(srcdir)/validator/val_anchor.h \
- $(srcdir)/validator/val_nsec3.h $(srcdir)/validator/val_sigcrypt.h $(srcdir)/validator/val_kentry.h \
- $(srcdir)/validator/val_neg.h $(srcdir)/validator/autotrust.h $(srcdir)/util/storage/dnstree.h \
- $(srcdir)/libunbound/libworker.h $(srcdir)/libunbound/context.h $(srcdir)/libunbound/unbound.h \
- $(srcdir)/util/config_file.h
-locks.lo locks.o: $(srcdir)/util/locks.c config.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
-
-log.lo log.o: $(srcdir)/util/log.c config.h $(srcdir)/util/log.h \
- $(srcdir)/util/locks.h
-mini_event.lo mini_event.o: $(srcdir)/util/mini_event.c config.h
-module.lo module.o: $(srcdir)/util/module.c config.h $(srcdir)/util/module.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
-
-netevent.lo netevent.o: $(srcdir)/util/netevent.c config.h \
- $(srcdir)/util/netevent.h \
- $(srcdir)/util/log.h $(srcdir)/util/net_help.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \
- $(srcdir)/services/modstack.h \
-
-net_help.lo net_help.o: $(srcdir)/util/net_help.c config.h \
- $(srcdir)/util/net_help.h \
- $(srcdir)/util/log.h $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h $(srcdir)/util/regional.h \
-
-random.lo random.o: $(srcdir)/util/random.c config.h $(srcdir)/util/random.h $(srcdir)/util/log.h \
-
-rbtree.lo rbtree.o: $(srcdir)/util/rbtree.c config.h $(srcdir)/util/log.h \
- $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/netevent.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/tube.h \
- $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h
-regional.lo regional.o: $(srcdir)/util/regional.c config.h $(srcdir)/util/log.h \
- $(srcdir)/util/regional.h
-rtt.lo rtt.o: $(srcdir)/util/rtt.c config.h $(srcdir)/util/rtt.h
-dnstree.lo dnstree.o: $(srcdir)/util/storage/dnstree.c config.h $(srcdir)/util/storage/dnstree.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/net_help.h
-lookup3.lo lookup3.o: $(srcdir)/util/storage/lookup3.c config.h $(srcdir)/util/storage/lookup3.h
-lruhash.lo lruhash.o: $(srcdir)/util/storage/lruhash.c config.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/netevent.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/tube.h \
- $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h
-slabhash.lo slabhash.o: $(srcdir)/util/storage/slabhash.c config.h $(srcdir)/util/storage/slabhash.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
-
-timehist.lo timehist.o: $(srcdir)/util/timehist.c config.h $(srcdir)/util/timehist.h $(srcdir)/util/log.h \
-
-tube.lo tube.o: $(srcdir)/util/tube.c config.h $(srcdir)/util/tube.h $(srcdir)/util/log.h \
- $(srcdir)/util/net_help.h \
- $(srcdir)/util/netevent.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/services/mesh.h \
- $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h
-winsock_event.lo winsock_event.o: $(srcdir)/util/winsock_event.c config.h
-autotrust.lo autotrust.o: $(srcdir)/validator/autotrust.c config.h \
- $(srcdir)/validator/autotrust.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/validator/val_anchor.h $(srcdir)/validator/val_utils.h \
- $(srcdir)/validator/val_sigcrypt.h $(srcdir)/util/data/dname.h $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/net_help.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/regional.h $(srcdir)/util/random.h $(srcdir)/services/mesh.h \
- $(srcdir)/util/netevent.h $(srcdir)/services/modstack.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/validator/val_kcache.h
-val_anchor.lo val_anchor.o: $(srcdir)/validator/val_anchor.c config.h \
- $(srcdir)/validator/val_anchor.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/validator/val_sigcrypt.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/validator/autotrust.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/net_help.h $(srcdir)/util/config_file.h
-validator.lo validator.o: $(srcdir)/validator/validator.c config.h \
- $(srcdir)/validator/validator.h \
- $(srcdir)/util/module.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/validator/val_utils.h $(srcdir)/validator/val_anchor.h $(srcdir)/util/rbtree.h \
- $(srcdir)/validator/val_kcache.h $(srcdir)/util/storage/slabhash.h $(srcdir)/validator/val_kentry.h \
- $(srcdir)/validator/val_nsec.h $(srcdir)/validator/val_nsec3.h $(srcdir)/validator/val_neg.h \
- $(srcdir)/validator/val_sigcrypt.h $(srcdir)/validator/autotrust.h $(srcdir)/services/cache/dns.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/net_help.h $(srcdir)/util/regional.h $(srcdir)/util/config_file.h \
- $(srcdir)/util/fptr_wlist.h $(srcdir)/util/netevent.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h \
- $(srcdir)/services/modstack.h
-val_kcache.lo val_kcache.o: $(srcdir)/validator/val_kcache.c config.h $(srcdir)/validator/val_kcache.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/validator/val_kentry.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/data/dname.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
-
-val_kentry.lo val_kentry.o: $(srcdir)/validator/val_kentry.c config.h \
- $(srcdir)/validator/val_kentry.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/regional.h $(srcdir)/util/net_help.h
-val_neg.lo val_neg.o: $(srcdir)/validator/val_neg.c config.h \
- $(srcdir)/validator/val_neg.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/rbtree.h \
- $(srcdir)/validator/val_nsec.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/validator/val_nsec3.h \
- $(srcdir)/validator/val_utils.h $(srcdir)/util/data/dname.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/config_file.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/dns.h
-val_nsec3.lo val_nsec3.o: $(srcdir)/validator/val_nsec3.c config.h \
- $(srcdir)/validator/val_nsec3.h $(srcdir)/util/rbtree.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/validator/validator.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/validator/val_utils.h \
- $(srcdir)/validator/val_kentry.h $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h \
- $(srcdir)/util/regional.h $(srcdir)/util/net_help.h $(srcdir)/util/data/dname.h $(srcdir)/validator/val_nsec.h
-val_nsec.lo val_nsec.o: $(srcdir)/validator/val_nsec.c config.h \
- $(srcdir)/validator/val_nsec.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/validator/val_utils.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/module.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h
-val_secalgo.lo val_secalgo.o: $(srcdir)/validator/val_secalgo.c config.h \
- $(srcdir)/validator/val_secalgo.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
-
-val_sigcrypt.lo val_sigcrypt.o: $(srcdir)/validator/val_sigcrypt.c config.h \
- $(srcdir)/validator/val_sigcrypt.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/validator/val_secalgo.h $(srcdir)/validator/validator.h $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h $(srcdir)/validator/val_utils.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/rbtree.h $(srcdir)/util/net_help.h $(srcdir)/util/regional.h \
-
-val_utils.lo val_utils.o: $(srcdir)/validator/val_utils.c config.h $(srcdir)/validator/val_utils.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/validator/validator.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/validator/val_kentry.h \
- $(srcdir)/validator/val_sigcrypt.h $(srcdir)/validator/val_anchor.h $(srcdir)/util/rbtree.h \
- $(srcdir)/validator/val_nsec.h $(srcdir)/validator/val_neg.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/dns.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/regional.h
-checklocks.lo checklocks.o: $(srcdir)/testcode/checklocks.c config.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/testcode/checklocks.h
-unitanchor.lo unitanchor.o: $(srcdir)/testcode/unitanchor.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/testcode/unitmain.h $(srcdir)/validator/val_anchor.h $(srcdir)/util/rbtree.h
-unitdname.lo unitdname.o: $(srcdir)/testcode/unitdname.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/testcode/unitmain.h $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h
-unitlruhash.lo unitlruhash.o: $(srcdir)/testcode/unitlruhash.c config.h $(srcdir)/testcode/unitmain.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/storage/slabhash.h
-unitmain.lo unitmain.o: $(srcdir)/testcode/unitmain.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/testcode/unitmain.h $(srcdir)/util/alloc.h $(srcdir)/util/locks.h $(srcdir)/util/net_help.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/rtt.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/random.h
-unitmsgparse.lo unitmsgparse.o: $(srcdir)/testcode/unitmsgparse.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/testcode/unitmain.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/dname.h $(srcdir)/util/alloc.h $(srcdir)/util/regional.h \
- $(srcdir)/util/net_help.h $(srcdir)/testcode/readhex.h
-unitneg.lo unitneg.o: $(srcdir)/testcode/unitneg.c config.h $(srcdir)/util/log.h \
- $(srcdir)/util/net_help.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/data/dname.h \
- $(srcdir)/testcode/unitmain.h $(srcdir)/validator/val_neg.h $(srcdir)/util/rbtree.h
-unitregional.lo unitregional.o: $(srcdir)/testcode/unitregional.c config.h $(srcdir)/testcode/unitmain.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/regional.h
-unitslabhash.lo unitslabhash.o: $(srcdir)/testcode/unitslabhash.c config.h $(srcdir)/testcode/unitmain.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h
-unitverify.lo unitverify.o: $(srcdir)/testcode/unitverify.c config.h $(srcdir)/util/log.h \
- $(srcdir)/testcode/unitmain.h \
- $(srcdir)/validator/val_sigcrypt.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h \
- $(srcdir)/validator/val_secalgo.h \
- $(srcdir)/validator/val_nsec.h $(srcdir)/validator/val_nsec3.h $(srcdir)/util/rbtree.h \
- $(srcdir)/validator/validator.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/validator/val_utils.h $(srcdir)/testcode/ldns-testpkts.h \
- $(srcdir)/util/data/dname.h \
- $(srcdir)/util/regional.h $(srcdir)/util/alloc.h $(srcdir)/util/net_help.h $(srcdir)/util/config_file.h
-readhex.lo readhex.o: $(srcdir)/testcode/readhex.c config.h $(srcdir)/testcode/readhex.h \
- $(srcdir)/util/log.h
-ldns-testpkts.lo ldns-testpkts.o: $(srcdir)/testcode/ldns-testpkts.c config.h \
- $(srcdir)/testcode/ldns-testpkts.h
-acl_list.lo acl_list.o: $(srcdir)/daemon/acl_list.c config.h $(srcdir)/daemon/acl_list.h \
- $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/util/regional.h $(srcdir)/util/log.h \
- $(srcdir)/util/config_file.h \
- $(srcdir)/util/net_help.h
-cachedump.lo cachedump.o: $(srcdir)/daemon/cachedump.c config.h \
- $(srcdir)/daemon/cachedump.h \
- $(srcdir)/daemon/remote.h $(srcdir)/daemon/worker.h $(srcdir)/util/netevent.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/daemon/stats.h \
- $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/dns.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/util/regional.h $(srcdir)/util/net_help.h $(srcdir)/util/data/dname.h \
- $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h $(srcdir)/iterator/iter_delegpt.h \
- $(srcdir)/iterator/iter_utils.h $(srcdir)/iterator/iter_resptype.h $(srcdir)/iterator/iter_fwd.h \
- $(srcdir)/util/rbtree.h $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h
-daemon.lo daemon.o: $(srcdir)/daemon/daemon.c config.h \
- $(srcdir)/daemon/daemon.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h $(srcdir)/daemon/worker.h \
- $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/daemon/stats.h \
- $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/daemon/remote.h $(srcdir)/daemon/acl_list.h \
- $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/util/config_file.h \
- $(srcdir)/util/storage/lookup3.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/listen_dnsport.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
- $(srcdir)/services/localzone.h $(srcdir)/util/random.h $(srcdir)/util/tube.h $(srcdir)/util/net_help.h
-remote.lo remote.o: $(srcdir)/daemon/remote.c config.h \
- $(srcdir)/daemon/remote.h \
- $(srcdir)/daemon/worker.h $(srcdir)/util/netevent.h $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/alloc.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h $(srcdir)/daemon/stats.h $(srcdir)/util/timehist.h $(srcdir)/util/module.h \
- $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h $(srcdir)/daemon/cachedump.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h $(srcdir)/services/listen_dnsport.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h $(srcdir)/services/localzone.h \
- $(srcdir)/util/fptr_wlist.h $(srcdir)/util/tube.h $(srcdir)/util/data/dname.h $(srcdir)/validator/validator.h \
- $(srcdir)/validator/val_utils.h $(srcdir)/validator/val_kcache.h $(srcdir)/validator/val_kentry.h \
- $(srcdir)/validator/val_anchor.h $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h \
- $(srcdir)/iterator/iter_fwd.h $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h \
- $(srcdir)/iterator/iter_delegpt.h $(srcdir)/services/outside_network.h
-stats.lo stats.o: $(srcdir)/daemon/stats.c config.h \
- $(srcdir)/daemon/stats.h \
- $(srcdir)/util/timehist.h $(srcdir)/daemon/worker.h $(srcdir)/util/netevent.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/module.h \
- $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \
- $(srcdir)/services/outside_network.h $(srcdir)/util/config_file.h $(srcdir)/util/tube.h \
- $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h
-unbound.lo unbound.o: $(srcdir)/daemon/unbound.c config.h $(srcdir)/util/log.h \
- $(srcdir)/daemon/daemon.h \
- $(srcdir)/util/locks.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h $(srcdir)/daemon/remote.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/storage/slabhash.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/services/listen_dnsport.h $(srcdir)/util/netevent.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/module.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/net_help.h
-worker.lo worker.o: $(srcdir)/daemon/worker.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/random.h $(srcdir)/daemon/worker.h $(srcdir)/util/netevent.h \
- $(srcdir)/util/locks.h $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/daemon/stats.h \
- $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h \
- $(srcdir)/daemon/remote.h \
- $(srcdir)/daemon/acl_list.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/regional.h $(srcdir)/util/storage/slabhash.h \
- $(srcdir)/services/listen_dnsport.h $(srcdir)/services/outside_network.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/services/cache/rrset.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/services/cache/dns.h $(srcdir)/services/mesh.h $(srcdir)/services/localzone.h \
- $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/dname.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/tube.h \
- $(srcdir)/iterator/iter_fwd.h $(srcdir)/iterator/iter_hints.h $(srcdir)/validator/autotrust.h \
- $(srcdir)/validator/val_anchor.h
-testbound.lo testbound.o: $(srcdir)/testcode/testbound.c config.h $(srcdir)/testcode/ldns-testpkts.h \
- $(srcdir)/testcode/replay.h \
- $(srcdir)/util/netevent.h $(srcdir)/util/rbtree.h $(srcdir)/testcode/fake_event.h $(srcdir)/daemon/remote.h \
- $(srcdir)/util/config_file.h $(srcdir)/daemon/unbound.c $(srcdir)/util/log.h $(srcdir)/daemon/daemon.h \
- $(srcdir)/util/locks.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h $(srcdir)/util/storage/slabhash.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/services/listen_dnsport.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/module.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/net_help.h
-ldns-testpkts.lo ldns-testpkts.o: $(srcdir)/testcode/ldns-testpkts.c config.h \
- $(srcdir)/testcode/ldns-testpkts.h
-worker.lo worker.o: $(srcdir)/daemon/worker.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/random.h $(srcdir)/daemon/worker.h $(srcdir)/util/netevent.h \
- $(srcdir)/util/locks.h $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/daemon/stats.h \
- $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h \
- $(srcdir)/daemon/remote.h \
- $(srcdir)/daemon/acl_list.h $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/regional.h $(srcdir)/util/storage/slabhash.h \
- $(srcdir)/services/listen_dnsport.h $(srcdir)/services/outside_network.h \
- $(srcdir)/services/outbound_list.h $(srcdir)/services/cache/rrset.h $(srcdir)/services/cache/infra.h \
- $(srcdir)/util/rtt.h $(srcdir)/services/cache/dns.h $(srcdir)/services/mesh.h $(srcdir)/services/localzone.h \
- $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/dname.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/tube.h \
- $(srcdir)/iterator/iter_fwd.h $(srcdir)/iterator/iter_hints.h $(srcdir)/validator/autotrust.h \
- $(srcdir)/validator/val_anchor.h
-acl_list.lo acl_list.o: $(srcdir)/daemon/acl_list.c config.h $(srcdir)/daemon/acl_list.h \
- $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/util/regional.h $(srcdir)/util/log.h \
- $(srcdir)/util/config_file.h \
- $(srcdir)/util/net_help.h
-daemon.lo daemon.o: $(srcdir)/daemon/daemon.c config.h \
- $(srcdir)/daemon/daemon.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/util/alloc.h $(srcdir)/services/modstack.h $(srcdir)/daemon/worker.h \
- $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/daemon/stats.h \
- $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/daemon/remote.h $(srcdir)/daemon/acl_list.h \
- $(srcdir)/util/storage/dnstree.h $(srcdir)/util/rbtree.h $(srcdir)/util/config_file.h \
- $(srcdir)/util/storage/lookup3.h $(srcdir)/util/storage/slabhash.h $(srcdir)/services/listen_dnsport.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
- $(srcdir)/services/localzone.h $(srcdir)/util/random.h $(srcdir)/util/tube.h $(srcdir)/util/net_help.h
-stats.lo stats.o: $(srcdir)/daemon/stats.c config.h \
- $(srcdir)/daemon/stats.h \
- $(srcdir)/util/timehist.h $(srcdir)/daemon/worker.h $(srcdir)/util/netevent.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/alloc.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/module.h \
- $(srcdir)/daemon/daemon.h $(srcdir)/services/modstack.h $(srcdir)/services/mesh.h $(srcdir)/util/rbtree.h \
- $(srcdir)/services/outside_network.h $(srcdir)/util/config_file.h $(srcdir)/util/tube.h \
- $(srcdir)/util/net_help.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h
-replay.lo replay.o: $(srcdir)/testcode/replay.c config.h $(srcdir)/util/log.h \
- $(srcdir)/util/net_help.h \
- $(srcdir)/util/config_file.h $(srcdir)/testcode/replay.h $(srcdir)/util/netevent.h \
- $(srcdir)/testcode/ldns-testpkts.h \
- $(srcdir)/util/rbtree.h \
- $(srcdir)/testcode/fake_event.h
-fake_event.lo fake_event.o: $(srcdir)/testcode/fake_event.c config.h $(srcdir)/testcode/fake_event.h \
- $(srcdir)/util/netevent.h \
- $(srcdir)/util/net_help.h \
- $(srcdir)/util/log.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/dname.h \
- $(srcdir)/util/config_file.h $(srcdir)/services/listen_dnsport.h $(srcdir)/services/outside_network.h \
- $(srcdir)/util/rbtree.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h $(srcdir)/testcode/replay.h \
- $(srcdir)/testcode/ldns-testpkts.h \
- $(srcdir)/util/fptr_wlist.h \
- $(srcdir)/util/module.h $(srcdir)/util/tube.h $(srcdir)/services/mesh.h $(srcdir)/services/modstack.h
-lock_verify.lo lock_verify.o: $(srcdir)/testcode/lock_verify.c config.h $(srcdir)/util/log.h \
- $(srcdir)/util/rbtree.h \
- $(srcdir)/util/locks.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/netevent.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/tube.h \
- $(srcdir)/services/mesh.h $(srcdir)/services/modstack.h
-pktview.lo pktview.o: $(srcdir)/testcode/pktview.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/data/msgparse.h $(srcdir)/testcode/unitmain.h $(srcdir)/testcode/readhex.h
-readhex.lo readhex.o: $(srcdir)/testcode/readhex.c config.h $(srcdir)/testcode/readhex.h \
- $(srcdir)/util/log.h
-signit.lo signit.o: $(srcdir)/testcode/signit.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/net_help.h
-memstats.lo memstats.o: $(srcdir)/testcode/memstats.c config.h $(srcdir)/util/log.h \
- $(srcdir)/util/rbtree.h \
- $(srcdir)/util/locks.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/netevent.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/tube.h \
- $(srcdir)/services/mesh.h $(srcdir)/services/modstack.h
-unbound-checkconf.lo unbound-checkconf.o: $(srcdir)/smallapp/unbound-checkconf.c config.h $(srcdir)/util/log.h \
- $(srcdir)/util/config_file.h \
- $(srcdir)/util/module.h $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/net_help.h \
- $(srcdir)/util/regional.h $(srcdir)/iterator/iterator.h $(srcdir)/services/outbound_list.h \
- $(srcdir)/iterator/iter_fwd.h $(srcdir)/util/rbtree.h $(srcdir)/iterator/iter_hints.h \
- $(srcdir)/util/storage/dnstree.h $(srcdir)/validator/validator.h $(srcdir)/validator/val_utils.h \
- $(srcdir)/services/localzone.h
-worker_cb.lo worker_cb.o: $(srcdir)/smallapp/worker_cb.c config.h $(srcdir)/util/log.h \
- $(srcdir)/services/mesh.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util/netevent.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h \
- $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/services/modstack.h
-context.lo context.o: $(srcdir)/libunbound/context.c config.h $(srcdir)/libunbound/context.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/alloc.h \
- $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/libunbound/unbound.h \
- $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/config_file.h \
- $(srcdir)/util/net_help.h $(srcdir)/services/localzone.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h
-libunbound.lo libunbound.o: $(srcdir)/libunbound/libunbound.c $(srcdir)/libunbound/unbound.h config.h \
- $(srcdir)/libunbound/context.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/alloc.h \
- $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/libunbound/libworker.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/module.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/regional.h $(srcdir)/util/random.h $(srcdir)/util/net_help.h $(srcdir)/util/tube.h \
- $(srcdir)/services/localzone.h $(srcdir)/services/cache/infra.h $(srcdir)/util/rtt.h \
- $(srcdir)/services/cache/rrset.h $(srcdir)/util/storage/slabhash.h
-libworker.lo libworker.o: $(srcdir)/libunbound/libworker.c config.h \
- $(srcdir)/libunbound/libworker.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/storage/lruhash.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h $(srcdir)/libunbound/context.h $(srcdir)/util/alloc.h $(srcdir)/util/rbtree.h \
- $(srcdir)/services/modstack.h $(srcdir)/libunbound/unbound.h $(srcdir)/services/outside_network.h \
- $(srcdir)/util/netevent.h $(srcdir)/services/mesh.h $(srcdir)/util/data/msgparse.h $(srcdir)/util/module.h \
- $(srcdir)/util/data/msgreply.h $(srcdir)/services/localzone.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/services/outbound_list.h $(srcdir)/util/regional.h \
- $(srcdir)/util/random.h $(srcdir)/util/config_file.h $(srcdir)/util/storage/lookup3.h $(srcdir)/util/net_help.h \
- $(srcdir)/util/data/dname.h $(srcdir)/util/data/msgencode.h $(srcdir)/util/tube.h $(srcdir)/iterator/iter_fwd.h \
- $(srcdir)/iterator/iter_hints.h $(srcdir)/util/storage/dnstree.h
-unbound-host.lo unbound-host.o: $(srcdir)/smallapp/unbound-host.c config.h $(srcdir)/libunbound/unbound.h \
-
-asynclook.lo asynclook.o: $(srcdir)/testcode/asynclook.c config.h $(srcdir)/libunbound/unbound.h \
- $(srcdir)/libunbound/context.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/alloc.h \
- $(srcdir)/util/rbtree.h $(srcdir)/services/modstack.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/storage/lruhash.h \
-
-streamtcp.lo streamtcp.o: $(srcdir)/testcode/streamtcp.c config.h \
- $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/data/msgreply.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/dname.h \
-
-perf.lo perf.o: $(srcdir)/testcode/perf.c config.h \
- $(srcdir)/util/log.h $(srcdir)/util/locks.h \
- $(srcdir)/util/net_help.h $(srcdir)/util/data/msgencode.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/data/packed_rrset.h $(srcdir)/util/data/msgparse.h
-delayer.lo delayer.o: $(srcdir)/testcode/delayer.c config.h $(srcdir)/util/net_help.h $(srcdir)/util/log.h \
- $(srcdir)/util/config_file.h
-harvest.lo harvest.o: $(srcdir)/testcode/harvest.c config.h \
- $(srcdir)/libunbound/unbound.h
-unbound-control.lo unbound-control.o: $(srcdir)/smallapp/unbound-control.c config.h \
- $(srcdir)/util/log.h \
- $(srcdir)/util/config_file.h \
- $(srcdir)/util/locks.h $(srcdir)/util/net_help.h
-unbound-anchor.lo unbound-anchor.o: $(srcdir)/smallapp/unbound-anchor.c config.h $(srcdir)/libunbound/unbound.h \
-
-petal.lo petal.o: $(srcdir)/testcode/petal.c config.h \
-
-pythonmod_utils.lo pythonmod_utils.o: $(srcdir)/pythonmod/pythonmod_utils.c config.h $(srcdir)/util/module.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/util/netevent.h \
- $(srcdir)/util/net_help.h $(srcdir)/services/cache/dns.h $(srcdir)/services/cache/rrset.h \
- $(srcdir)/util/storage/slabhash.h $(srcdir)/util/regional.h
-win_svc.lo win_svc.o: $(srcdir)/winrc/win_svc.c config.h $(srcdir)/winrc/win_svc.h $(srcdir)/winrc/w_inst.h \
- $(srcdir)/daemon/daemon.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
- $(srcdir)/util/alloc.h \
- $(srcdir)/services/modstack.h $(srcdir)/daemon/worker.h $(srcdir)/util/netevent.h $(srcdir)/util/data/msgreply.h \
- $(srcdir)/util/storage/lruhash.h $(srcdir)/util/data/packed_rrset.h \
- $(srcdir)/util/data/msgparse.h \
- $(srcdir)/daemon/stats.h \
- $(srcdir)/util/timehist.h $(srcdir)/util/module.h $(srcdir)/daemon/remote.h \
- $(srcdir)/util/config_file.h $(srcdir)/util/winsock_event.h
-w_inst.lo w_inst.o: $(srcdir)/winrc/w_inst.c config.h $(srcdir)/winrc/w_inst.h $(srcdir)/winrc/win_svc.h
-unbound-service-install.lo unbound-service-install.o: $(srcdir)/winrc/unbound-service-install.c config.h \
- $(srcdir)/winrc/w_inst.h
-unbound-service-remove.lo unbound-service-remove.o: $(srcdir)/winrc/unbound-service-remove.c config.h \
- $(srcdir)/winrc/w_inst.h
-anchor-update.lo anchor-update.o: $(srcdir)/winrc/anchor-update.c config.h \
- $(srcdir)/libunbound/unbound.h
-ctime_r.lo ctime_r.o: $(srcdir)/compat/ctime_r.c config.h $(srcdir)/util/locks.h $(srcdir)/util/log.h \
-
-fake-rfc2553.lo fake-rfc2553.o: $(srcdir)/compat/fake-rfc2553.c $(srcdir)/compat/fake-rfc2553.h config.h
-gmtime_r.lo gmtime_r.o: $(srcdir)/compat/gmtime_r.c config.h
-inet_aton.lo inet_aton.o: $(srcdir)/compat/inet_aton.c config.h
-inet_ntop.lo inet_ntop.o: $(srcdir)/compat/inet_ntop.c config.h
-inet_pton.lo inet_pton.o: $(srcdir)/compat/inet_pton.c config.h
-malloc.lo malloc.o: $(srcdir)/compat/malloc.c config.h
-memcmp.lo memcmp.o: $(srcdir)/compat/memcmp.c config.h
-memmove.lo memmove.o: $(srcdir)/compat/memmove.c config.h
-snprintf.lo snprintf.o: $(srcdir)/compat/snprintf.c config.h
-strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c config.h
-strptime.lo strptime.o: $(srcdir)/compat/strptime.c config.h
diff --git a/contrib/unbound/acx_nlnetlabs.m4 b/contrib/unbound/acx_nlnetlabs.m4
index e90c81e..e1cf83a 100644
--- a/contrib/unbound/acx_nlnetlabs.m4
+++ b/contrib/unbound/acx_nlnetlabs.m4
@@ -2,7 +2,12 @@
# Copyright 2009, Wouter Wijngaards, NLnet Labs.
# BSD licensed.
#
-# Version 21
+# Version 26
+# 2013-09-19 FLTO help text improved.
+# 2013-07-18 Enable ACX_CHECK_COMPILER_FLAG to test for -Wstrict-prototypes
+# 2013-06-25 FLTO has --disable-flto option.
+# 2013-05-03 Update W32_SLEEP for newer mingw that links but not defines it.
+# 2013-03-22 Fix ACX_RSRC_VERSION for long version numbers.
# 2012-02-09 Fix AHX_MEMCMP_BROKEN with undef in compat/memcmp.h.
# 2012-01-20 Fix COMPILER_FLAGS_UNBOUND for gcc 4.6.2 assigned-not-used-warns.
# 2011-12-05 Fix getaddrinfowithincludes on windows with fedora16 mingw32-gcc.
@@ -101,7 +106,7 @@ dnl Calculate comma separated windows-resource numbers from package version.
dnl Picks the first three(,0) or four numbers out of the name.
dnl $1: variable for the result
AC_DEFUN([ACX_RSRC_VERSION],
-[$1=[`echo $PACKAGE_VERSION | sed -e 's/^[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\).*$/\1,\2,\3,\4/' -e 's/^[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*$/\1,\2,\3,0/' `]
+[$1=[`echo $PACKAGE_VERSION | sed -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\).*$/\1,\2,\3,\4/' -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9]*$/\1,\2,\3,0/' `]
])
dnl Routine to help check for compiler flags.
@@ -116,7 +121,7 @@ AC_MSG_CHECKING(whether $CC supports -$1)
cache=`echo $1 | sed 'y%.=/+-%___p_%'`
AC_CACHE_VAL(cv_prog_cc_flag_$cache,
[
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -$1 -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -405,19 +410,22 @@ int test() {
dnl Check if CC supports -flto.
dnl in a way that supports clang and suncc (that flag does something else,
dnl but fails to link). It sets it in CFLAGS if it works.
-AC_DEFUN([ACX_CHECK_FLTO],
-[AC_MSG_CHECKING([if $CC supports -flto])
-BAKCFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -flto"
-AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [
- if $CC $CFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then
- CFLAGS="$BAKCFLAGS"
- AC_MSG_RESULT(no)
- else
- AC_MSG_RESULT(yes)
- fi
- rm -f conftest conftest.c conftest.o
-], [CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)])
+AC_DEFUN([ACX_CHECK_FLTO], [
+ AC_ARG_ENABLE([flto], AS_HELP_STRING([--disable-flto], [Disable link-time optimization (gcc specific option)]))
+ AS_IF([test "x$enable_flto" != "xno"], [
+ AC_MSG_CHECKING([if $CC supports -flto])
+ BAKCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -flto"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [
+ if $CC $CFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then
+ CFLAGS="$BAKCFLAGS"
+ AC_MSG_RESULT(no)
+ else
+ AC_MSG_RESULT(yes)
+ fi
+ rm -f conftest conftest.c conftest.o
+ ], [CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)])
+ ])
])
dnl Check the printf-format attribute (if any)
@@ -1208,7 +1216,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result);
dnl provide w32 compat definition for sleep
AC_DEFUN([AHX_CONFIG_W32_SLEEP],
[
-#ifndef HAVE_SLEEP
+#if !defined(HAVE_SLEEP) || defined(HAVE_WINDOWS_H)
#define sleep(x) Sleep((x)*1000) /* on win32 */
#endif /* HAVE_SLEEP */
])
diff --git a/contrib/unbound/acx_pthread.m4 b/contrib/unbound/acx_pthread.m4
deleted file mode 100644
index 7ac8ffd..0000000
--- a/contrib/unbound/acx_pthread.m4
+++ /dev/null
@@ -1,280 +0,0 @@
-##### http://autoconf-archive.cryp.to/acx_pthread.html
-#
-# SYNOPSIS
-#
-# ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
-#
-# DESCRIPTION
-#
-# This macro figures out how to build C programs using POSIX threads.
-# It sets the PTHREAD_LIBS output variable to the threads library and
-# linker flags, and the PTHREAD_CFLAGS output variable to any special
-# C compiler flags that are needed. (The user can also force certain
-# compiler flags/libs to be tested by setting these environment
-# variables.)
-#
-# Also sets PTHREAD_CC to any special C compiler that is needed for
-# multi-threaded programs (defaults to the value of CC otherwise).
-# (This is necessary on AIX to use the special cc_r compiler alias.)
-#
-# NOTE: You are assumed to not only compile your program with these
-# flags, but also link it with them as well. e.g. you should link
-# with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
-# $LIBS
-#
-# If you are only building threads programs, you may wish to use
-# these variables in your default LIBS, CFLAGS, and CC:
-#
-# LIBS="$PTHREAD_LIBS $LIBS"
-# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-# CC="$PTHREAD_CC"
-#
-# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
-# constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
-# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
-#
-# ACTION-IF-FOUND is a list of shell commands to run if a threads
-# library is found, and ACTION-IF-NOT-FOUND is a list of commands to
-# run it if it is not found. If ACTION-IF-FOUND is not specified, the
-# default action will define HAVE_PTHREAD.
-#
-# Please let the authors know if this macro fails on any platform, or
-# if you have any other suggestions or comments. This macro was based
-# on work by SGJ on autoconf scripts for FFTW (http://www.fftw.org/)
-# (with help from M. Frigo), as well as ac_pthread and hb_pthread
-# macros posted by Alejandro Forero Cuervo to the autoconf macro
-# repository. We are also grateful for the helpful feedback of
-# numerous users.
-#
-# LAST MODIFICATION
-#
-# 2006-05-29
-#
-# COPYLEFT
-#
-# Copyright (c) 2006 Steven G. Johnson <stevenj@alum.mit.edu>
-#
-# 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, the respective Autoconf Macro's copyright
-# owner gives unlimited permission to copy, distribute and modify the
-# configure scripts that are the output of Autoconf when processing
-# the Macro. You need not follow the terms of the GNU General Public
-# License when using or distributing such scripts, even though
-# portions of the text of the Macro appear in them. The GNU General
-# Public License (GPL) does govern all other use of the material that
-# constitutes the Autoconf Macro.
-#
-# This special exception to the GPL applies to versions of the
-# Autoconf Macro released by the Autoconf Macro Archive. When you
-# make and distribute a modified version of the Autoconf Macro, you
-# may extend this special exception to the GPL to apply to your
-# modified version as well.
-
-AC_DEFUN([ACX_PTHREAD], [
-AC_REQUIRE([AC_CANONICAL_HOST])
-AC_LANG_SAVE
-AC_LANG_C
-acx_pthread_ok=no
-
-# We used to check for pthread.h first, but this fails if pthread.h
-# requires special compiler flags (e.g. on True64 or Sequent).
-# It gets checked for in the link test anyway.
-
-# First of all, check if the user has set any of the PTHREAD_LIBS,
-# etcetera environment variables, and if threads linking works using
-# them:
-if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
- save_LIBS="$LIBS"
- LIBS="$PTHREAD_LIBS $LIBS"
- AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
- AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
- AC_MSG_RESULT($acx_pthread_ok)
- if test x"$acx_pthread_ok" = xno; then
- PTHREAD_LIBS=""
- PTHREAD_CFLAGS=""
- fi
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
-fi
-
-# We must check for the threads library under a number of different
-# names; the ordering is very important because some systems
-# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
-# libraries is broken (non-POSIX).
-
-# Create a list of thread flags to try. Items starting with a "-" are
-# C compiler flags, and other items are library names, except for "none"
-# which indicates that we try without any flags at all, and "pthread-config"
-# which is a program returning the flags for the Pth emulation library.
-
-acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
-
-# The ordering *is* (sometimes) important. Some notes on the
-# individual items follow:
-
-# pthreads: AIX (must check this before -lpthread)
-# none: in case threads are in libc; should be tried before -Kthread and
-# other compiler flags to prevent continual compiler warnings
-# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
-# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
-# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
-# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
-# -pthreads: Solaris/gcc
-# -mthreads: Mingw32/gcc, Lynx/gcc
-# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
-# doesn't hurt to check since this sometimes defines pthreads too;
-# also defines -D_REENTRANT)
-# ... -mt is also the pthreads flag for HP/aCC
-# pthread: Linux, etcetera
-# --thread-safe: KAI C++
-# pthread-config: use pthread-config program (for GNU Pth library)
-
-case "${host_cpu}-${host_os}" in
- *solaris*)
-
- # On Solaris (at least, for some versions), libc contains stubbed
- # (non-functional) versions of the pthreads routines, so link-based
- # tests will erroneously succeed. (We need to link with -pthreads/-mt/
- # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
- # a function called by this macro, so we could check for that, but
- # who knows whether they'll stub that too in a future libc.) So,
- # we'll just look for -pthreads and -lpthread first:
-
- acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
- ;;
-esac
-
-if test x"$acx_pthread_ok" = xno; then
-for flag in $acx_pthread_flags; do
-
- case $flag in
- none)
- AC_MSG_CHECKING([whether pthreads work without any flags])
- ;;
-
- -*)
- AC_MSG_CHECKING([whether pthreads work with $flag])
- PTHREAD_CFLAGS="$flag"
- ;;
-
- pthread-config)
- AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
- if test x"$acx_pthread_config" = xno; then continue; fi
- PTHREAD_CFLAGS="`pthread-config --cflags`"
- PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
- ;;
-
- *)
- AC_MSG_CHECKING([for the pthreads library -l$flag])
- PTHREAD_LIBS="-l$flag"
- ;;
- esac
-
- save_LIBS="$LIBS"
- save_CFLAGS="$CFLAGS"
- LIBS="$PTHREAD_LIBS $LIBS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-
- # Check for various functions. We must include pthread.h,
- # since some functions may be macros. (On the Sequent, we
- # need a special flag -Kthread to make this header compile.)
- # We check for pthread_join because it is in -lpthread on IRIX
- # while pthread_create is in libc. We check for pthread_attr_init
- # due to DEC craziness with -lpthreads. We check for
- # pthread_cleanup_push because it is one of the few pthread
- # functions on Solaris that doesn't have a non-functional libc stub.
- # We try pthread_create on general principles.
- AC_TRY_LINK([#include <pthread.h>],
- [pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
- [acx_pthread_ok=yes])
-
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
-
- AC_MSG_RESULT($acx_pthread_ok)
- if test "x$acx_pthread_ok" = xyes; then
- break;
- fi
-
- PTHREAD_LIBS=""
- PTHREAD_CFLAGS=""
-done
-fi
-
-# Various other checks:
-if test "x$acx_pthread_ok" = xyes; then
- save_LIBS="$LIBS"
- LIBS="$PTHREAD_LIBS $LIBS"
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
-
- # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
- AC_MSG_CHECKING([for joinable pthread attribute])
- attr_name=unknown
- for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
- AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
- [attr_name=$attr; break])
- done
- AC_MSG_RESULT($attr_name)
- if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
- AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
- [Define to necessary symbol if this constant
- uses a non-standard name on your system.])
- fi
-
- AC_MSG_CHECKING([if more special flags are required for pthreads])
- flag=no
- case "${host_cpu}-${host_os}" in
- *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
- *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
- esac
- AC_MSG_RESULT(${flag})
- if test "x$flag" != xno; then
- PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
- fi
-
- LIBS="$save_LIBS"
- CFLAGS="$save_CFLAGS"
-
- # More AIX lossage: must compile with xlc_r or cc_r
- if test x"$GCC" != xyes; then
- AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
- else
- PTHREAD_CC=$CC
- fi
-else
- PTHREAD_CC="$CC"
-fi
-
-AC_SUBST(PTHREAD_LIBS)
-AC_SUBST(PTHREAD_CFLAGS)
-AC_SUBST(PTHREAD_CC)
-
-# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
-if test x"$acx_pthread_ok" = xyes; then
- ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
- :
-else
- acx_pthread_ok=no
- $2
-fi
-AC_LANG_RESTORE
-])dnl ACX_PTHREAD
diff --git a/contrib/unbound/ax_pthread.m4 b/contrib/unbound/ax_pthread.m4
new file mode 100644
index 0000000..47fe233
--- /dev/null
+++ b/contrib/unbound/ax_pthread.m4
@@ -0,0 +1,317 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_pthread.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+# This macro figures out how to build C programs using POSIX threads. It
+# sets the PTHREAD_LIBS output variable to the threads library and linker
+# flags, and the PTHREAD_CFLAGS output variable to any special C compiler
+# flags that are needed. (The user can also force certain compiler
+# flags/libs to be tested by setting these environment variables.)
+#
+# Also sets PTHREAD_CC to any special C compiler that is needed for
+# multi-threaded programs (defaults to the value of CC otherwise). (This
+# is necessary on AIX to use the special cc_r compiler alias.)
+#
+# NOTE: You are assumed to not only compile your program with these flags,
+# but also link it with them as well. e.g. you should link with
+# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS
+#
+# If you are only building threads programs, you may wish to use these
+# variables in your default LIBS, CFLAGS, and CC:
+#
+# LIBS="$PTHREAD_LIBS $LIBS"
+# CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+# CC="$PTHREAD_CC"
+#
+# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant
+# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name
+# (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+#
+# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the
+# PTHREAD_PRIO_INHERIT symbol is defined when compiling with
+# PTHREAD_CFLAGS.
+#
+# ACTION-IF-FOUND is a list of shell commands to run if a threads library
+# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it
+# is not found. If ACTION-IF-FOUND is not specified, the default action
+# will define HAVE_PTHREAD.
+#
+# Please let the authors know if this macro fails on any platform, or if
+# you have any other suggestions or comments. This macro was based on work
+# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help
+# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by
+# Alejandro Forero Cuervo to the autoconf macro repository. We are also
+# grateful for the helpful feedback of numerous users.
+#
+# Updated for Autoconf 2.68 by Daniel Richard G.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG>
+#
+# 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 3 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, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 20
+
+AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
+AC_DEFUN([AX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_PUSH([C])
+ax_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+ AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes)
+ AC_MSG_RESULT($ax_pthread_ok)
+ if test x"$ax_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case ${host_os} in
+ solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
+ ;;
+
+ darwin*)
+ ax_pthread_flags="-pthread $ax_pthread_flags"
+ ;;
+esac
+
+if test x"$ax_pthread_ok" = xno; then
+for flag in $ax_pthread_flags; do
+
+ case $flag in
+ none)
+ AC_MSG_CHECKING([whether pthreads work without any flags])
+ ;;
+
+ -*)
+ AC_MSG_CHECKING([whether pthreads work with $flag])
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no)
+ if test x"$ax_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
+
+ *)
+ AC_MSG_CHECKING([for the pthreads library -l$flag])
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>
+ static void routine(void *a) { *((int*)a) = 0; }
+ static void *start_routine(void *a) { return a; }],
+ [pthread_t th; pthread_attr_t attr;
+ pthread_create(&th, 0, start_routine, 0);
+ pthread_join(th, 0);
+ pthread_attr_init(&attr);
+ pthread_cleanup_push(routine, 0);
+ pthread_cleanup_pop(0) /* ; */])],
+ [ax_pthread_ok=yes],
+ [])
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ AC_MSG_RESULT($ax_pthread_ok)
+ if test "x$ax_pthread_ok" = xyes; then
+ break;
+ fi
+
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$ax_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ AC_MSG_CHECKING([for joinable pthread attribute])
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>],
+ [int attr = $attr; return attr /* ; */])],
+ [attr_name=$attr; break],
+ [])
+ done
+ AC_MSG_RESULT($attr_name)
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+ AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+ [Define to necessary symbol if this constant
+ uses a non-standard name on your system.])
+ fi
+
+ AC_MSG_CHECKING([if more special flags are required for pthreads])
+ flag=no
+ case ${host_os} in
+ aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
+ osf* | hpux*) flag="-D_REENTRANT";;
+ solaris*)
+ if test "$GCC" = "yes"; then
+ flag="-D_REENTRANT"
+ else
+ flag="-mt -D_REENTRANT"
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT(${flag})
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
+
+ AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT],
+ ax_cv_PTHREAD_PRIO_INHERIT, [
+ AC_LINK_IFELSE([
+ AC_LANG_PROGRAM([[#include <pthread.h>]], [[int i = PTHREAD_PRIO_INHERIT;]])],
+ [ax_cv_PTHREAD_PRIO_INHERIT=yes],
+ [ax_cv_PTHREAD_PRIO_INHERIT=no])
+ ])
+ AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"],
+ AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.]))
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ # More AIX lossage: compile with *_r variant
+ if test "x$GCC" != xyes; then
+ case $host_os in
+ aix*)
+ AS_CASE(["x/$CC"],
+ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
+ [#handle absolute path differently from PATH based program lookup
+ AS_CASE(["x$CC"],
+ [x/*],
+ [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
+ [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
+ ;;
+ esac
+ fi
+fi
+
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$ax_pthread_ok" = xyes; then
+ ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+ :
+else
+ ax_pthread_ok=no
+ $2
+fi
+AC_LANG_POP
+])dnl AX_PTHREAD
diff --git a/contrib/unbound/compat/snprintf.c b/contrib/unbound/compat/snprintf.c
index b736175..0663557 100644
--- a/contrib/unbound/compat/snprintf.c
+++ b/contrib/unbound/compat/snprintf.c
@@ -1,792 +1,1036 @@
-#include <config.h>
-
-#ifndef HAVE_SNPRINTF
+/* snprintf - compatibility implementation of snprintf, vsnprintf
+ *
+ * Copyright (c) 2013, NLnet Labs. All rights reserved.
+ *
+ * This software is open source.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of the NLNET LABS nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "config.h"
+#include <stdio.h>
#include <ctype.h>
-#include <sys/types.h>
+#include <string.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <errno.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
-/* Define this as a fall through, HAVE_STDARG_H is probably already set */
+/* for test */
+/* #define SNPRINTF_TEST 1 */
+#ifdef SNPRINTF_TEST
+#define snprintf my_snprintf
+#define vsnprintf my_vsnprintf
+#endif /* SNPRINTF_TEST */
-#define HAVE_VARARGS_H
+int snprintf(char* str, size_t size, const char* format, ...);
+int vsnprintf(char* str, size_t size, const char* format, va_list arg);
-/**************************************************************
- * Original:
- * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
- * A bombproof version of doprnt (dopr) included.
- * Sigh. This sort of thing is always nasty do deal with. Note that
- * the version here does not include floating point...
- *
- * snprintf() is used instead of sprintf() as it does limit checks
- * for string length. This covers a nasty loophole.
+/**
+ * Very portable snprintf implementation, limited in functionality,
+ * esp. for %[capital] %[nonportable] and so on. Reduced float functionality,
+ * mostly in formatting and range (e+-16), for %f and %g.
*
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
- *
- * More Recently:
- * Brandon Long (blong@fiction.net) 9/15/96 for mutt 0.43
- * This was ugly. It is still ugly. I opted out of floating point
- * numbers, but the formatter understands just about everything
- * from the normal C string format, at least as far as I can tell from
- * the Solaris 2.5 printf(3S) man page.
- *
- * Brandon Long (blong@fiction.net) 10/22/97 for mutt 0.87.1
- * Ok, added some minimal floating point support, which means this
- * probably requires libm on most operating systems. Don't yet
- * support the exponent (e,E) and sigfig (g,G). Also, fmtint()
- * was pretty badly broken, it just wasn't being exercised in ways
- * which showed it, so that's been fixed. Also, formated the code
- * to mutt conventions, and removed dead code left over from the
- * original. Also, there is now a builtin-test, just compile with:
- * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
- * and run snprintf for results.
- *
- * Wouter Wijngaards(wouter@nlnetlabs.nl) 2/09/2010 for unbound.
- * Limited support for %g. Does not do the exponents for the before-dot.
- *
- **************************************************************/
+ * %s, %d, %u, %i, %x, %c, %n and %% are fully supported.
+ * This includes width, precision, flags 0- +, and *(arg for wid,prec).
+ * %f, %g, %m, %p have reduced support, support for wid,prec,flags,*, but
+ * less floating point range, no %e formatting for %g.
+ */
+int snprintf(char* str, size_t size, const char* format, ...)
+{
+ int r;
+ va_list args;
+ va_start(args, format);
+ r = vsnprintf(str, size, format, args);
+ va_end(args);
+ return r;
+}
+/** add padding to string */
+static void
+print_pad(char** at, size_t* left, int* ret, char p, int num)
+{
+ while(num--) {
+ if(*left > 1) {
+ *(*at)++ = p;
+ (*left)--;
+ }
+ (*ret)++;
+ }
+}
-/* varargs declarations: */
+/** get negative symbol, 0 if none */
+static char
+get_negsign(int negative, int plus, int space)
+{
+ if(negative)
+ return '-';
+ if(plus)
+ return '+';
+ if(space)
+ return ' ';
+ return 0;
+}
-#if defined(HAVE_STDARG_H)
-# include <stdarg.h>
-# define HAVE_STDARGS /* let's hope that works everywhere (mj) */
-# define VA_LOCAL_DECL va_list ap
-# define VA_START(f) va_start(ap, f)
-# define VA_SHIFT(v,t) ; /* no-op for ANSI */
-# define VA_END va_end(ap)
-#else
-# if defined(HAVE_VARARGS_H)
-# include <varargs.h>
-# undef HAVE_STDARGS
-# define VA_LOCAL_DECL va_list ap
-# define VA_START(f) va_start(ap) /* f is ignored! */
-# define VA_SHIFT(v,t) v = va_arg(ap,t)
-# define VA_END va_end(ap)
-# else
-/*XX ** NO VARARGS ** XX*/
-# endif
-#endif
+#define PRINT_DEC_BUFSZ 32 /* 20 is enough for 64 bit decimals */
+/** print decimal into buffer, returns length */
+static int
+print_dec(char* buf, int max, unsigned int value)
+{
+ int i = 0;
+ if(value == 0) {
+ if(max > 0) {
+ buf[0] = '0';
+ i = 1;
+ }
+ } else while(value && i < max) {
+ buf[i++] = '0' + value % 10;
+ value /= 10;
+ }
+ return i;
+}
-int snprintf (char *str, size_t count, const char *fmt, ...);
-int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
+/** print long decimal into buffer, returns length */
+static int
+print_dec_l(char* buf, int max, unsigned long value)
+{
+ int i = 0;
+ if(value == 0) {
+ if(max > 0) {
+ buf[0] = '0';
+ i = 1;
+ }
+ } else while(value && i < max) {
+ buf[i++] = '0' + value % 10;
+ value /= 10;
+ }
+ return i;
+}
-static void dopr (char *buffer, size_t maxlen, const char *format,
- va_list args);
-static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
- char *value, int flags, int min, int max);
-static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
- long value, int base, int min, int max, int flags);
-static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- long double fvalue, int min, int max, int flags, int conv);
-static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
+/** print long decimal into buffer, returns length */
+static int
+print_dec_ll(char* buf, int max, unsigned long long value)
+{
+ int i = 0;
+ if(value == 0) {
+ if(max > 0) {
+ buf[0] = '0';
+ i = 1;
+ }
+ } else while(value && i < max) {
+ buf[i++] = '0' + value % 10;
+ value /= 10;
+ }
+ return i;
+}
-int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
+/** print hex into buffer, returns length */
+static int
+print_hex(char* buf, int max, unsigned int value)
{
- str[0] = 0;
- dopr(str, count, fmt, args);
- return(strlen(str));
+ const char* h = "0123456789abcdef";
+ int i = 0;
+ if(value == 0) {
+ if(max > 0) {
+ buf[0] = '0';
+ i = 1;
+ }
+ } else while(value && i < max) {
+ buf[i++] = h[value & 0x0f];
+ value >>= 4;
+ }
+ return i;
}
-/* VARARGS3 */
-#ifdef HAVE_STDARGS
-int snprintf (char *str,size_t count,const char *fmt,...)
+/** print long hex into buffer, returns length */
+static int
+print_hex_l(char* buf, int max, unsigned long value)
+{
+ const char* h = "0123456789abcdef";
+ int i = 0;
+ if(value == 0) {
+ if(max > 0) {
+ buf[0] = '0';
+ i = 1;
+ }
+ } else while(value && i < max) {
+ buf[i++] = h[value & 0x0f];
+ value >>= 4;
+ }
+ return i;
+}
+
+/** print long long hex into buffer, returns length */
+static int
+print_hex_ll(char* buf, int max, unsigned long long value)
+{
+ const char* h = "0123456789abcdef";
+ int i = 0;
+ if(value == 0) {
+ if(max > 0) {
+ buf[0] = '0';
+ i = 1;
+ }
+ } else while(value && i < max) {
+ buf[i++] = h[value & 0x0f];
+ value >>= 4;
+ }
+ return i;
+}
+
+/** copy string into result, reversed */
+static void
+spool_str_rev(char** at, size_t* left, int* ret, const char* buf, int len)
+{
+ int i = len;
+ while(i) {
+ if(*left > 1) {
+ *(*at)++ = buf[--i];
+ (*left)--;
+ } else --i;
+ (*ret)++;
+ }
+}
+
+/** copy string into result */
+static void
+spool_str(char** at, size_t* left, int* ret, const char* buf, int len)
+{
+ int i;
+ for(i=0; i<len; i++) {
+ if(*left > 1) {
+ *(*at)++ = buf[i];
+ (*left)--;
+ }
+ (*ret)++;
+ }
+}
+
+/** print number formatted */
+static void
+print_num(char** at, size_t* left, int* ret, int minw, int precision,
+ int prgiven, int zeropad, int minus, int plus, int space,
+ int zero, int negative, char* buf, int len)
+{
+ int w = len; /* excludes minus sign */
+ char s = get_negsign(negative, plus, space);
+ if(minus) {
+ /* left adjust the number into the field, space padding */
+ /* calc numw = [sign][zeroes][number] */
+ int numw = w;
+ if(precision == 0 && zero) numw = 0;
+ if(numw < precision) numw = precision;
+ if(s) numw++;
+
+ /* sign */
+ if(s) print_pad(at, left, ret, s, 1);
+
+ /* number */
+ if(precision == 0 && zero) {
+ /* "" for the number */
+ } else {
+ if(w < precision)
+ print_pad(at, left, ret, '0', precision - w);
+ spool_str_rev(at, left, ret, buf, len);
+ }
+ /* spaces */
+ if(numw < minw)
+ print_pad(at, left, ret, ' ', minw - numw);
+ } else {
+ /* pad on the left of the number */
+ /* calculate numw has width of [sign][zeroes][number] */
+ int numw = w;
+ if(precision == 0 && zero) numw = 0;
+ if(numw < precision) numw = precision;
+ if(!prgiven && zeropad && numw < minw) numw = minw;
+ else if(s) numw++;
+
+ /* pad with spaces */
+ if(numw < minw)
+ print_pad(at, left, ret, ' ', minw - numw);
+ /* print sign (and one less zeropad if so) */
+ if(s) {
+ print_pad(at, left, ret, s, 1);
+ numw--;
+ }
+ /* pad with zeroes */
+ if(w < numw)
+ print_pad(at, left, ret, '0', numw - w);
+ if(precision == 0 && zero)
+ return;
+ /* print the characters for the value */
+ spool_str_rev(at, left, ret, buf, len);
+ }
+}
+
+/** print %d and %i */
+static void
+print_num_d(char** at, size_t* left, int* ret, int value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = (value < 0);
+ int zero = (value == 0);
+ int len = print_dec(buf, (int)sizeof(buf),
+ (unsigned int)(negative?-value:value));
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %ld and %li */
+static void
+print_num_ld(char** at, size_t* left, int* ret, long value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = (value < 0);
+ int zero = (value == 0);
+ int len = print_dec_l(buf, (int)sizeof(buf),
+ (unsigned long)(negative?-value:value));
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %lld and %lli */
+static void
+print_num_lld(char** at, size_t* left, int* ret, long long value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = (value < 0);
+ int zero = (value == 0);
+ int len = print_dec_ll(buf, (int)sizeof(buf),
+ (unsigned long long)(negative?-value:value));
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %u */
+static void
+print_num_u(char** at, size_t* left, int* ret, unsigned int value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = 0;
+ int zero = (value == 0);
+ int len = print_dec(buf, (int)sizeof(buf), value);
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %lu */
+static void
+print_num_lu(char** at, size_t* left, int* ret, unsigned long value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = 0;
+ int zero = (value == 0);
+ int len = print_dec_l(buf, (int)sizeof(buf), value);
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %llu */
+static void
+print_num_llu(char** at, size_t* left, int* ret, unsigned long long value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = 0;
+ int zero = (value == 0);
+ int len = print_dec_ll(buf, (int)sizeof(buf), value);
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %x */
+static void
+print_num_x(char** at, size_t* left, int* ret, unsigned int value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = 0;
+ int zero = (value == 0);
+ int len = print_hex(buf, (int)sizeof(buf), value);
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %lx */
+static void
+print_num_lx(char** at, size_t* left, int* ret, unsigned long value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = 0;
+ int zero = (value == 0);
+ int len = print_hex_l(buf, (int)sizeof(buf), value);
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %llx */
+static void
+print_num_llx(char** at, size_t* left, int* ret, unsigned long long value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = 0;
+ int zero = (value == 0);
+ int len = print_hex_ll(buf, (int)sizeof(buf), value);
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+/** print %llp */
+static void
+print_num_llp(char** at, size_t* left, int* ret, void* value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_DEC_BUFSZ];
+ int negative = 0;
+ int zero = (value == 0);
+#if defined(UINTPTR_MAX) && defined(UINT32_MAX) && (UINTPTR_MAX == UINT32_MAX)
+ /* avoid warning about upcast on 32bit systems */
+ unsigned long long llvalue = (unsigned long)value;
#else
-int snprintf (va_alist) va_dcl
+ unsigned long long llvalue = (unsigned long long)value;
#endif
+ int len = print_hex_ll(buf, (int)sizeof(buf), llvalue);
+ if(zero) {
+ buf[0]=')';
+ buf[1]='l';
+ buf[2]='i';
+ buf[3]='n';
+ buf[4]='(';
+ len = 5;
+ } else {
+ /* put '0x' in front of the (reversed) buffer result */
+ if(len < PRINT_DEC_BUFSZ)
+ buf[len++] = 'x';
+ if(len < PRINT_DEC_BUFSZ)
+ buf[len++] = '0';
+ }
+ print_num(at, left, ret, minw, precision, prgiven, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
+
+#define PRINT_FLOAT_BUFSZ 64 /* xx.yy with 20.20 about the max */
+/** spool remainder after the decimal point to buffer, in reverse */
+static int
+print_remainder(char* buf, int max, double r, int prec)
{
-#ifndef HAVE_STDARGS
- char *str;
- size_t count;
- char *fmt;
-#endif
- VA_LOCAL_DECL;
-
- VA_START (fmt);
- VA_SHIFT (str, char *);
- VA_SHIFT (count, size_t );
- VA_SHIFT (fmt, char *);
- (void) vsnprintf(str, count, fmt, ap);
- VA_END;
- return(strlen(str));
-}
-
-/*
- * dopr(): poor man's version of doprintf
- */
+ unsigned long long cap = 1;
+ unsigned long long value;
+ int len, i;
+ if(prec > 19) prec = 19; /* max we can do */
+ if(max < prec) return 0;
+ for(i=0; i<prec; i++) {
+ cap *= 10;
+ }
+ r *= (double)cap;
+ value = (unsigned long long)r;
+ /* see if we need to round up */
+ if(((unsigned long long)((r - (double)value)*10.0)) >= 5) {
+ value++;
+ /* that might carry to numbers before the comma, if so,
+ * just ignore that rounding. failure because 64bitprintout */
+ if(value >= cap)
+ value = cap-1;
+ }
+ len = print_dec_ll(buf, max, value);
+ while(len < prec) { /* pad with zeroes, e.g. if 0.0012 */
+ buf[len++] = '0';
+ }
+ if(len < max)
+ buf[len++] = '.';
+ return len;
+}
-/* format read states */
-#define DP_S_DEFAULT 0
-#define DP_S_FLAGS 1
-#define DP_S_MIN 2
-#define DP_S_DOT 3
-#define DP_S_MAX 4
-#define DP_S_MOD 5
-#define DP_S_CONV 6
-#define DP_S_DONE 7
-
-/* format flags - Bits */
-#define DP_F_MINUS 1
-#define DP_F_PLUS 2
-#define DP_F_SPACE 4
-#define DP_F_NUM 8
-#define DP_F_ZERO 16
-#define DP_F_UP 32
-
-/* Conversion Flags */
-#define DP_C_SHORT 1
-#define DP_C_LONG 2
-#define DP_C_LDOUBLE 3
-
-#define char_to_int(p) (p - '0')
-#ifndef MAX
-#define MAX(p,q) ((p >= q) ? p : q)
-#endif
+/** spool floating point to buffer */
+static int
+print_float(char* buf, int max, double value, int prec)
+{
+ /* as xxx.xxx if prec==0, no '.', with prec decimals after . */
+ /* no conversion for NAN and INF, because we do not want to require
+ linking with -lm. */
+ /* Thus, the conversions use 64bit integers to convert the numbers,
+ * which makes 19 digits before and after the decimal point the max */
+ unsigned long long whole = (unsigned long long)value;
+ double remain = value - (double)whole;
+ int len = 0;
+ if(prec != 0)
+ len = print_remainder(buf, max, remain, prec);
+ len += print_dec_ll(buf+len, max-len, whole);
+ return len;
+}
-static void dopr (char *buffer, size_t maxlen, const char *format, va_list args)
-{
- char ch;
- long value;
- long double fvalue;
- char *strvalue;
- int min;
- int max;
- int state;
- int flags;
- int cflags;
- size_t currlen;
-
- state = DP_S_DEFAULT;
- currlen = flags = cflags = min = 0;
- max = -1;
- ch = *format++;
-
- while (state != DP_S_DONE)
- {
- if ((ch == '\0') || (currlen >= maxlen))
- state = DP_S_DONE;
-
- switch(state)
- {
- case DP_S_DEFAULT:
- if (ch == '%')
- state = DP_S_FLAGS;
- else
- dopr_outch (buffer, &currlen, maxlen, ch);
- ch = *format++;
- break;
- case DP_S_FLAGS:
- switch (ch)
- {
- case '-':
- flags |= DP_F_MINUS;
- ch = *format++;
- break;
- case '+':
- flags |= DP_F_PLUS;
- ch = *format++;
- break;
- case ' ':
- flags |= DP_F_SPACE;
- ch = *format++;
- break;
- case '#':
- flags |= DP_F_NUM;
- ch = *format++;
- break;
- case '0':
- flags |= DP_F_ZERO;
- ch = *format++;
- break;
- default:
- state = DP_S_MIN;
- break;
- }
- break;
- case DP_S_MIN:
- if (isdigit(ch))
- {
- min = 10*min + char_to_int (ch);
- ch = *format++;
- }
- else if (ch == '*')
- {
- min = va_arg (args, int);
- ch = *format++;
- state = DP_S_DOT;
- }
- else
- state = DP_S_DOT;
- break;
- case DP_S_DOT:
- if (ch == '.')
- {
- state = DP_S_MAX;
- ch = *format++;
- }
- else
- state = DP_S_MOD;
- break;
- case DP_S_MAX:
- if (isdigit(ch))
- {
- if (max < 0)
- max = 0;
- max = 10*max + char_to_int (ch);
- ch = *format++;
- }
- else if (ch == '*')
- {
- max = va_arg (args, int);
- ch = *format++;
- state = DP_S_MOD;
- }
- else
- state = DP_S_MOD;
- break;
- case DP_S_MOD:
- /* Currently, we don't support Long Long, bummer */
- switch (ch)
- {
- case 'h':
- cflags = DP_C_SHORT;
- ch = *format++;
- break;
- case 'l':
- cflags = DP_C_LONG;
- ch = *format++;
- break;
- case 'L':
- cflags = DP_C_LDOUBLE;
- ch = *format++;
- break;
- default:
- break;
- }
- state = DP_S_CONV;
- break;
- case DP_S_CONV:
- switch (ch)
- {
- case 'd':
- case 'i':
- if (cflags == DP_C_SHORT)
- value = va_arg (args, int);
- else if (cflags == DP_C_LONG)
- value = va_arg (args, long int);
- else
- value = va_arg (args, int);
- fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
- break;
- case 'o':
- flags &= ~DP_F_PLUS;
- if (cflags == DP_C_SHORT)
- value = va_arg (args, unsigned int);
- else if (cflags == DP_C_LONG)
- value = va_arg (args, unsigned long int);
- else
- value = va_arg (args, unsigned int);
- fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
- break;
- case 'u':
- flags &= ~DP_F_PLUS;
- if (cflags == DP_C_SHORT)
- value = va_arg (args, unsigned int);
- else if (cflags == DP_C_LONG)
- value = va_arg (args, unsigned long int);
- else
- value = va_arg (args, unsigned int);
- fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
- break;
- case 'X':
- flags |= DP_F_UP;
- case 'x':
- flags &= ~DP_F_PLUS;
- if (cflags == DP_C_SHORT)
- value = va_arg (args, unsigned int);
- else if (cflags == DP_C_LONG)
- value = va_arg (args, unsigned long int);
- else
- value = va_arg (args, unsigned int);
- fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
- break;
- case 'f':
- if (cflags == DP_C_LDOUBLE)
- fvalue = va_arg (args, long double);
- else
- fvalue = va_arg (args, double);
- /* um, floating point? */
- fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, 'f');
- break;
- case 'E':
- flags |= DP_F_UP;
- case 'e':
- if (cflags == DP_C_LDOUBLE)
- fvalue = va_arg (args, long double);
- else
- fvalue = va_arg (args, double);
- break;
- case 'G':
- flags |= DP_F_UP;
- case 'g':
- if (cflags == DP_C_LDOUBLE)
- fvalue = va_arg (args, long double);
- else
- fvalue = va_arg (args, double);
- fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags, 'g');
- break;
- case 'c':
- dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
- break;
- case 's':
- strvalue = va_arg (args, char *);
- if (max < 0)
- max = maxlen; /* ie, no max */
- fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
- break;
- case 'p':
- strvalue = va_arg (args, void *);
- fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
- break;
- case 'n':
- if (cflags == DP_C_SHORT)
- {
- short int *num;
- num = va_arg (args, short int *);
- *num = currlen;
- }
- else if (cflags == DP_C_LONG)
- {
- long int *num;
- num = va_arg (args, long int *);
- *num = currlen;
- }
- else
- {
- int *num;
- num = va_arg (args, int *);
- *num = currlen;
- }
- break;
- case '%':
- dopr_outch (buffer, &currlen, maxlen, ch);
- break;
- case 'w':
- /* not supported yet, treat as next char */
- ch = *format++;
- break;
- default:
- /* Unknown, skip */
- break;
- }
- ch = *format++;
- state = DP_S_DEFAULT;
- flags = cflags = min = 0;
- max = -1;
- break;
- case DP_S_DONE:
- break;
- default:
- /* hmm? */
- break; /* some picky compilers need this */
- }
- }
- if (currlen < maxlen - 1)
- buffer[currlen] = '\0';
- else
- buffer[maxlen - 1] = '\0';
-}
-
-static void fmtstr (char *buffer, size_t *currlen, size_t maxlen,
- char *value, int flags, int min, int max)
-{
- int padlen, strln; /* amount to pad */
- int cnt = 0;
-
- if (value == 0)
- {
- value = "<NULL>";
- }
-
- for (strln = 0; value[strln]; ++strln); /* strlen */
- padlen = min - strln;
- if (padlen < 0)
- padlen = 0;
- if (flags & DP_F_MINUS)
- padlen = -padlen; /* Left Justify */
-
- while ((padlen > 0) && (cnt < max))
- {
- dopr_outch (buffer, currlen, maxlen, ' ');
- --padlen;
- ++cnt;
- }
- while (*value && (cnt < max))
- {
- dopr_outch (buffer, currlen, maxlen, *value++);
- ++cnt;
- }
- while ((padlen < 0) && (cnt < max))
- {
- dopr_outch (buffer, currlen, maxlen, ' ');
- ++padlen;
- ++cnt;
- }
-}
-
-/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
-
-static void fmtint (char *buffer, size_t *currlen, size_t maxlen,
- long value, int base, int min, int max, int flags)
-{
- int signvalue = 0;
- unsigned long uvalue;
- char convert[20];
- int place = 0;
- int spadlen = 0; /* amount to space pad */
- int zpadlen = 0; /* amount to zero pad */
- int caps = 0;
-
- if (max < 0)
- max = 0;
-
- uvalue = value;
- if( value < 0 ) {
- signvalue = '-';
- uvalue = -value;
- }
- else
- if (flags & DP_F_PLUS) /* Do a sign (+/i) */
- signvalue = '+';
- else
- if (flags & DP_F_SPACE)
- signvalue = ' ';
-
- if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
-
- do {
- convert[place++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")
- [uvalue % (unsigned)base ];
- uvalue = (uvalue / (unsigned)base );
- } while(uvalue && (place < 20));
- if (place == 20) place--;
- convert[place] = 0;
-
- zpadlen = max - place;
- spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
- if (zpadlen < 0) zpadlen = 0;
- if (spadlen < 0) spadlen = 0;
- if (flags & DP_F_ZERO)
- {
- zpadlen = MAX(zpadlen, spadlen);
- spadlen = 0;
- }
- if (flags & DP_F_MINUS)
- spadlen = -spadlen; /* Left Justifty */
-
-#ifdef DEBUG_SNPRINTF
- dprint (1, (debugfile, "zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
- zpadlen, spadlen, min, max, place));
-#endif
+/** print %f */
+static void
+print_num_f(char** at, size_t* left, int* ret, double value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_FLOAT_BUFSZ];
+ int negative = (value < 0);
+ int zero = 0;
+ int len;
+ if(!prgiven) precision = 6;
+ len = print_float(buf, (int)sizeof(buf), negative?-value:value,
+ precision);
+ print_num(at, left, ret, minw, 1, 0, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
- /* Spaces */
- while (spadlen > 0)
- {
- dopr_outch (buffer, currlen, maxlen, ' ');
- --spadlen;
- }
-
- /* Sign */
- if (signvalue)
- dopr_outch (buffer, currlen, maxlen, signvalue);
-
- /* Zeros */
- if (zpadlen > 0)
- {
- while (zpadlen > 0)
- {
- dopr_outch (buffer, currlen, maxlen, '0');
- --zpadlen;
- }
- }
-
- /* Digits */
- while (place > 0)
- dopr_outch (buffer, currlen, maxlen, convert[--place]);
-
- /* Left Justified spaces */
- while (spadlen < 0) {
- dopr_outch (buffer, currlen, maxlen, ' ');
- ++spadlen;
- }
-}
-
-static long double abs_val (long double value)
-{
- long double result = value;
-
- if (value < 0)
- result = -value;
-
- return result;
-}
-
-static long double compat_pow10 (int exp)
-{
- long double result = 1;
-
- while (exp)
- {
- result *= 10;
- exp--;
- }
-
- return result;
-}
-
-static long compat_round (long double value)
-{
- long intpart;
-
- intpart = value;
- value = value - intpart;
- if (value >= 0.5)
- intpart++;
-
- return intpart;
-}
-
-static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
- long double fvalue, int min, int max, int flags, int conv)
-{
- int signvalue = 0;
- long double ufvalue;
- char iconvert[20];
- char fconvert[20];
- int iplace = 0;
- int fplace = 0;
- int padlen = 0; /* amount to pad */
- int zpadlen = 0;
- int caps = 0;
- long intpart;
- long fracpart;
-
- /*
- * AIX manpage says the default is 0, but Solaris says the default
- * is 6, and sprintf on AIX defaults to 6
- */
- if (max < 0)
- max = 6;
-
- ufvalue = abs_val (fvalue);
-
- if (fvalue < 0)
- signvalue = '-';
- else
- if (flags & DP_F_PLUS) /* Do a sign (+/i) */
- signvalue = '+';
- else
- if (flags & DP_F_SPACE)
- signvalue = ' ';
-
-#if 0
- if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
-#endif
+/* rudimentary %g support */
+static int
+print_float_g(char* buf, int max, double value, int prec)
+{
+ unsigned long long whole = (unsigned long long)value;
+ double remain = value - (double)whole;
+ int before = 0;
+ int len = 0;
+
+ /* number of digits before the decimal point */
+ while(whole > 0) {
+ before++;
+ whole /= 10;
+ }
+ whole = (unsigned long long)value;
+
+ if(prec > before && remain != 0.0) {
+ /* see if the last decimals are zero, if so, skip them */
+ len = print_remainder(buf, max, remain, prec-before);
+ while(len > 0 && buf[0]=='0') {
+ memmove(buf, buf+1, --len);
+ }
+ }
+ len += print_dec_ll(buf+len, max-len, whole);
+ return len;
+}
- intpart = ufvalue;
- /*
- * Sorry, we only support 9 digits past the decimal because of our
- * conversion method
- */
- if (max > 9)
- max = 9;
+/** print %g */
+static void
+print_num_g(char** at, size_t* left, int* ret, double value,
+ int minw, int precision, int prgiven, int zeropad, int minus,
+ int plus, int space)
+{
+ char buf[PRINT_FLOAT_BUFSZ];
+ int negative = (value < 0);
+ int zero = 0;
+ int len;
+ if(!prgiven) precision = 6;
+ if(precision == 0) precision = 1;
+ len = print_float_g(buf, (int)sizeof(buf), negative?-value:value,
+ precision);
+ print_num(at, left, ret, minw, 1, 0, zeropad, minus,
+ plus, space, zero, negative, buf, len);
+}
- /* We "cheat" by converting the fractional part to integer by
- * multiplying by a factor of 10
- */
- fracpart = compat_round ((compat_pow10 (max)) * (ufvalue - intpart));
- if (fracpart >= compat_pow10 (max))
- {
- intpart++;
- fracpart -= compat_pow10 (max);
- }
+/** strnlen (compat implementation) */
+static int
+my_strnlen(const char* s, int max)
+{
+ int i;
+ for(i=0; i<max; i++)
+ if(s[i]==0)
+ return i;
+ return max;
+}
-#ifdef DEBUG_SNPRINTF
- dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
-#endif
+/** print %s */
+static void
+print_str(char** at, size_t* left, int* ret, char* s,
+ int minw, int precision, int prgiven, int minus)
+{
+ int w;
+ /* with prec: no more than x characters from this string, stop at 0 */
+ if(prgiven)
+ w = my_strnlen(s, precision);
+ else w = (int)strlen(s); /* up to the nul */
+ if(w < minw && !minus)
+ print_pad(at, left, ret, ' ', minw - w);
+ spool_str(at, left, ret, s, w);
+ if(w < minw && minus)
+ print_pad(at, left, ret, ' ', minw - w);
+}
- /* Convert integer part */
- do {
- iconvert[iplace++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")[intpart % 10];
- intpart = (intpart / 10);
- } while(intpart && (iplace < 20));
- if (iplace == 20) iplace--;
- iconvert[iplace] = 0;
-
- /* Convert fractional part */
- do {
- fconvert[fplace++] =
- (caps? "0123456789ABCDEF":"0123456789abcdef")[fracpart % 10];
- fracpart = (fracpart / 10);
- if(conv == 'g' && fplace == 1 && fconvert[0] == '0') {
- fplace = 0; /* skip trailing zeroes for %g */
- zpadlen ++;
- }
- } while(fracpart && (fplace < 20));
- if (fplace == 20) fplace--;
- fconvert[fplace] = 0;
-
- if(conv == 'f') {
- /* -1 for decimal point, another -1 if we are printing a sign */
- padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
- zpadlen = max - fplace;
- } else if(conv == 'g') {
- /* zpadlen contains number of trailing zeroes removed */
- padlen = min - iplace - (max-zpadlen) - 1 - ((signvalue) ? 1 : 0);
- if(fplace == 0) {
- padlen += 1; /* add the decimal dot suppressed */
- zpadlen = 0;
- } else zpadlen = (max-zpadlen) - fplace;
- }
- if (zpadlen < 0)
- zpadlen = 0;
- if (padlen < 0)
- padlen = 0;
- if (flags & DP_F_MINUS)
- padlen = -padlen; /* Left Justifty */
-
- if ((flags & DP_F_ZERO) && (padlen > 0))
- {
- if (signvalue)
- {
- dopr_outch (buffer, currlen, maxlen, signvalue);
- --padlen;
- signvalue = 0;
- }
- while (padlen > 0)
- {
- dopr_outch (buffer, currlen, maxlen, '0');
- --padlen;
- }
- }
- while (padlen > 0)
- {
- dopr_outch (buffer, currlen, maxlen, ' ');
- --padlen;
- }
- if (signvalue)
- dopr_outch (buffer, currlen, maxlen, signvalue);
-
- while (iplace > 0)
- dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
-
- /* for %g do not output decimal point if no fraction is present */
- if(conv == 'f' || (conv == 'g' && fplace > 0)) {
- /*
- * Decimal point. This should probably use locale to find the correct
- * char to print out.
- */
- dopr_outch (buffer, currlen, maxlen, '.');
- }
-
- while (zpadlen > 0)
- {
- dopr_outch (buffer, currlen, maxlen, '0');
- --zpadlen;
- }
-
- while (fplace > 0)
- dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
-
- while (padlen < 0)
- {
- dopr_outch (buffer, currlen, maxlen, ' ');
- ++padlen;
- }
-}
-
-static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c)
-{
- if (*currlen < maxlen)
- buffer[(*currlen)++] = c;
-}
-
-#ifdef TEST_SNPRINTF
-#ifndef LONG_STRING
-#define LONG_STRING 1024
-#endif
-int main (void)
-{
- char buf1[LONG_STRING];
- char buf2[LONG_STRING];
- char *fp_fmt[] = {
- "%-1.5f",
- "%1.5f",
- "%123.9f",
- "%10.5f",
- "% 10.5f",
- "%+22.9f",
- "%+4.9f",
- "%01.3f",
- "%4f",
- "%3.1f",
- "%3.2f",
- NULL
- };
- double fp_nums[] = { -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
- 0.9996, 1.996, 4.136, 0};
- char *int_fmt[] = {
- "%-1.5d",
- "%1.5d",
- "%123.9d",
- "%5.5d",
- "%10.5d",
- "% 10.5d",
- "%+22.33d",
- "%01.3d",
- "%4d",
- NULL
- };
- long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
- int x, y;
- int fail = 0;
- int num = 0;
-
- printf ("Testing snprintf format codes against system sprintf...\n");
-
- for (x = 0; fp_fmt[x] != NULL ; x++)
- for (y = 0; fp_nums[y] != 0 ; y++)
- {
- snprintf (buf1, sizeof (buf1), fp_fmt[x], fp_nums[y]);
- sprintf (buf2, fp_fmt[x], fp_nums[y]);
- if (strcmp (buf1, buf2))
- {
- printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
- fp_fmt[x], buf1, buf2);
- fail++;
- }
- num++;
- }
-
- for (x = 0; int_fmt[x] != NULL ; x++)
- for (y = 0; int_nums[y] != 0 ; y++)
- {
- snprintf (buf1, sizeof (buf1), int_fmt[x], int_nums[y]);
- sprintf (buf2, int_fmt[x], int_nums[y]);
- if (strcmp (buf1, buf2))
- {
- printf("snprintf doesn't match Format: %s\n\tsnprintf = %s\n\tsprintf = %s\n",
- int_fmt[x], buf1, buf2);
- fail++;
- }
- num++;
- }
- printf ("%d tests failed out of %d.\n", fail, num);
+/** print %c */
+static void
+print_char(char** at, size_t* left, int* ret, int c,
+ int minw, int minus)
+{
+ if(1 < minw && !minus)
+ print_pad(at, left, ret, ' ', minw - 1);
+ print_pad(at, left, ret, c, 1);
+ if(1 < minw && minus)
+ print_pad(at, left, ret, ' ', minw - 1);
+}
+
+
+/**
+ * Print to string.
+ * str: string buffer for result. result will be null terminated.
+ * size: size of the buffer. null is put inside buffer.
+ * format: printf format string.
+ * arg: '...' arguments to print.
+ * returns number of characters. a null is printed after this.
+ * return number of bytes that would have been written
+ * if the buffer had been large enough.
+ *
+ * supported format specifiers:
+ * %s, %u, %d, %x, %i, %f, %g, %c, %p, %n.
+ * length: l, ll (for d, u, x).
+ * precision: 6.6d (for d, u, x)
+ * %f, %g precisions, 0.3f
+ * %20s, '.*s'
+ * and %%.
+ */
+int vsnprintf(char* str, size_t size, const char* format, va_list arg)
+{
+ char* at = str;
+ size_t left = size;
+ int ret = 0;
+ const char* fmt = format;
+ int conv, minw, precision, prgiven, zeropad, minus, plus, space, length;
+ while(*fmt) {
+ /* copy string before % */
+ while(*fmt && *fmt!='%') {
+ if(left > 1) {
+ *at++ = *fmt++;
+ left--;
+ } else fmt++;
+ ret++;
+ }
+
+ /* see if we are at end */
+ if(!*fmt) break;
+
+ /* fetch next argument % designation from format string */
+ fmt++; /* skip the '%' */
+
+ /********************************/
+ /* get the argument designation */
+ /********************************/
+ /* we must do this vararg stuff inside this function for
+ * portability. Hence, get_designation, and print_designation
+ * are not their own functions. */
+
+ /* printout designation:
+ * conversion specifier: x, d, u, s, c, n, m, p
+ * flags: # not supported
+ * 0 zeropad (on the left)
+ * - left adjust (right by default)
+ * ' ' printspace for positive number (in - position).
+ * + alwayssign
+ * fieldwidth: [1-9][0-9]* minimum field width.
+ * if this is * then type int next argument specifies the minwidth.
+ * if this is negative, the - flag is set (with positive width).
+ * precision: period[digits]*, %.2x.
+ * if this is * then type int next argument specifies the precision.
+ * just '.' or negative value means precision=0.
+ * this is mindigits to print for d, i, u, x
+ * this is aftercomma digits for f
+ * this is max number significant digits for g
+ * maxnumber characters to be printed for s
+ * length: 0-none (int), 1-l (long), 2-ll (long long)
+ * notsupported: hh (char), h (short), L (long double), q, j, z, t
+ * Does not support %m$ and *m$ argument designation as array indices.
+ * Does not support %#x
+ *
+ */
+ minw = 0;
+ precision = 1;
+ prgiven = 0;
+ zeropad = 0;
+ minus = 0;
+ plus = 0;
+ space = 0;
+ length = 0;
+
+ /* get flags in any order */
+ for(;;) {
+ if(*fmt == '0')
+ zeropad = 1;
+ else if(*fmt == '-')
+ minus = 1;
+ else if(*fmt == '+')
+ plus = 1;
+ else if(*fmt == ' ')
+ space = 1;
+ else break;
+ fmt++;
+ }
+
+ /* field width */
+ if(*fmt == '*') {
+ fmt++; /* skip char */
+ minw = va_arg(arg, int);
+ if(minw < 0) {
+ minus = 1;
+ minw = -minw;
+ }
+ } else while(*fmt >= '0' && *fmt <= '9') {
+ minw = minw*10 + (*fmt++)-'0';
+ }
+
+ /* precision */
+ if(*fmt == '.') {
+ fmt++; /* skip period */
+ prgiven = 1;
+ precision = 0;
+ if(*fmt == '*') {
+ fmt++; /* skip char */
+ precision = va_arg(arg, int);
+ if(precision < 0)
+ precision = 0;
+ } else while(*fmt >= '0' && *fmt <= '9') {
+ precision = precision*10 + (*fmt++)-'0';
+ }
+ }
+
+ /* length */
+ if(*fmt == 'l') {
+ fmt++; /* skip char */
+ length = 1;
+ if(*fmt == 'l') {
+ fmt++; /* skip char */
+ length = 2;
+ }
+ }
+
+ /* get the conversion */
+ if(!*fmt) conv = 0;
+ else conv = *fmt++;
+
+ /***********************************/
+ /* print that argument designation */
+ /***********************************/
+ switch(conv) {
+ case 'i':
+ case 'd':
+ if(length == 0)
+ print_num_d(&at, &left, &ret, va_arg(arg, int),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ else if(length == 1)
+ print_num_ld(&at, &left, &ret, va_arg(arg, long),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ else if(length == 2)
+ print_num_lld(&at, &left, &ret,
+ va_arg(arg, long long),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ break;
+ case 'u':
+ if(length == 0)
+ print_num_u(&at, &left, &ret,
+ va_arg(arg, unsigned int),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ else if(length == 1)
+ print_num_lu(&at, &left, &ret,
+ va_arg(arg, unsigned long),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ else if(length == 2)
+ print_num_llu(&at, &left, &ret,
+ va_arg(arg, unsigned long long),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ break;
+ case 'x':
+ if(length == 0)
+ print_num_x(&at, &left, &ret,
+ va_arg(arg, unsigned int),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ else if(length == 1)
+ print_num_lx(&at, &left, &ret,
+ va_arg(arg, unsigned long),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ else if(length == 2)
+ print_num_llx(&at, &left, &ret,
+ va_arg(arg, unsigned long long),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ break;
+ case 's':
+ print_str(&at, &left, &ret, va_arg(arg, char*),
+ minw, precision, prgiven, minus);
+ break;
+ case 'c':
+ print_char(&at, &left, &ret, va_arg(arg, int),
+ minw, minus);
+ break;
+ case 'n':
+ *va_arg(arg, int*) = ret;
+ break;
+ case 'm':
+ print_str(&at, &left, &ret, strerror(errno),
+ minw, precision, prgiven, minus);
+ break;
+ case 'p':
+ print_num_llp(&at, &left, &ret, va_arg(arg, void*),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ break;
+ case '%':
+ print_pad(&at, &left, &ret, '%', 1);
+ break;
+ case 'f':
+ print_num_f(&at, &left, &ret, va_arg(arg, double),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ break;
+ case 'g':
+ print_num_g(&at, &left, &ret, va_arg(arg, double),
+ minw, precision, prgiven, zeropad, minus, plus, space);
+ break;
+ /* unknown */
+ default:
+ case 0: break;
+ }
+ }
+
+ /* zero terminate */
+ if(left > 0)
+ *at = 0;
+ return ret;
}
-#endif /* SNPRINTF_TEST */
-#endif /* !HAVE_SNPRINTF */
+#ifdef SNPRINTF_TEST
+
+/** do tests */
+#undef snprintf
+#define DOTEST(bufsz, result, retval, ...) do { \
+ char buf[bufsz]; \
+ printf("now test %s\n", #__VA_ARGS__); \
+ int r=my_snprintf(buf, sizeof(buf), __VA_ARGS__); \
+ if(r != retval || strcmp(buf, result) != 0) { \
+ printf("error test(%s) was \"%s\":%d\n", \
+ ""#bufsz", "#result", "#retval", "#__VA_ARGS__, \
+ buf, r); \
+ exit(1); \
+ } \
+ r=snprintf(buf, sizeof(buf), __VA_ARGS__); \
+ if(r != retval || strcmp(buf, result) != 0) { \
+ printf("error test(%s) differs with system, \"%s\":%d\n", \
+ ""#bufsz", "#result", "#retval", "#__VA_ARGS__, \
+ buf, r); \
+ exit(1); \
+ } \
+ printf("test(\"%s\":%d) passed\n", buf, r); \
+ } while(0);
+
+/** test program */
+int main(void)
+{
+ int x = 0;
+
+ /* bufsize, expectedstring, expectedretval, snprintf arguments */
+ DOTEST(1024, "hello", 5, "hello");
+ DOTEST(1024, "h", 1, "h");
+ /* warning from gcc for format string, but it does work
+ * DOTEST(1024, "", 0, ""); */
+
+ DOTEST(3, "he", 5, "hello");
+ DOTEST(1, "", 7, "%d", 7823089);
+
+ /* test positive numbers */
+ DOTEST(1024, "0", 1, "%d", 0);
+ DOTEST(1024, "1", 1, "%d", 1);
+ DOTEST(1024, "9", 1, "%d", 9);
+ DOTEST(1024, "15", 2, "%d", 15);
+ DOTEST(1024, "ab15cd", 6, "ab%dcd", 15);
+ DOTEST(1024, "167", 3, "%d", 167);
+ DOTEST(1024, "7823089", 7, "%d", 7823089);
+ DOTEST(1024, " 12", 3, "%3d", 12);
+ DOTEST(1024, "012", 3, "%.3d", 12);
+ DOTEST(1024, "012", 3, "%3.3d", 12);
+ DOTEST(1024, "012", 3, "%03d", 12);
+ DOTEST(1024, " 012", 4, "%4.3d", 12);
+ DOTEST(1024, "", 0, "%.0d", 0);
+
+ /* test negative numbers */
+ DOTEST(1024, "-1", 2, "%d", -1);
+ DOTEST(1024, "-12", 3, "%3d", -12);
+ DOTEST(1024, " -2", 3, "%3d", -2);
+ DOTEST(1024, "-012", 4, "%.3d", -12);
+ DOTEST(1024, "-012", 4, "%3.3d", -12);
+ DOTEST(1024, "-012", 4, "%4.3d", -12);
+ DOTEST(1024, " -012", 5, "%5.3d", -12);
+ DOTEST(1024, "-12", 3, "%03d", -12);
+ DOTEST(1024, "-02", 3, "%03d", -2);
+ DOTEST(1024, "-15", 3, "%d", -15);
+ DOTEST(1024, "-7307", 5, "%d", -7307);
+ DOTEST(1024, "-12 ", 5, "%-5d", -12);
+ DOTEST(1024, "-00012", 6, "%-.5d", -12);
+
+ /* test + and space flags */
+ DOTEST(1024, "+12", 3, "%+d", 12);
+ DOTEST(1024, " 12", 3, "% d", 12);
+
+ /* test %u */
+ DOTEST(1024, "12", 2, "%u", 12);
+ DOTEST(1024, "0", 1, "%u", 0);
+ DOTEST(1024, "4294967295", 10, "%u", 0xffffffff);
+
+ /* test %x */
+ DOTEST(1024, "0", 1, "%x", 0);
+ DOTEST(1024, "c", 1, "%x", 12);
+ DOTEST(1024, "12ab34cd", 8, "%x", 0x12ab34cd);
+
+ /* test %llu, %lld */
+ DOTEST(1024, "18446744073709551615", 20, "%llu",
+ (long long)0xffffffffffffffff);
+ DOTEST(1024, "-9223372036854775808", 20, "%lld",
+ (long long)0x8000000000000000);
+ DOTEST(1024, "9223372036854775808", 19, "%llu",
+ (long long)0x8000000000000000);
+
+ /* test %s */
+ DOTEST(1024, "hello", 5, "%s", "hello");
+ DOTEST(1024, " hello", 10, "%10s", "hello");
+ DOTEST(1024, "hello ", 10, "%-10s", "hello");
+ DOTEST(1024, "he", 2, "%.2s", "hello");
+ DOTEST(1024, " he", 4, "%4.2s", "hello");
+ DOTEST(1024, " h", 4, "%4.2s", "h");
+
+ /* test %c */
+ DOTEST(1024, "a", 1, "%c", 'a');
+ /* warning from gcc for format string, but it does work
+ DOTEST(1024, " a", 5, "%5c", 'a');
+ DOTEST(1024, "a", 1, "%.0c", 'a'); */
+
+ /* test %n */
+ DOTEST(1024, "hello", 5, "hello%n", &x);
+ if(x != 5) { printf("the %%n failed\n"); exit(1); }
+
+ /* test %m */
+ errno = 0;
+ DOTEST(1024, "Success", 7, "%m");
+
+ /* test %p */
+ DOTEST(1024, "0x10", 4, "%p", (void*)0x10);
+ DOTEST(1024, "(nil)", 5, "%p", (void*)0x0);
+
+ /* test %% */
+ DOTEST(1024, "%", 1, "%%");
+
+ /* test %f */
+ DOTEST(1024, "0.000000", 8, "%f", 0.0);
+ DOTEST(1024, "0.00", 4, "%.2f", 0.0);
+ /* differs, "-0.00" DOTEST(1024, "0.00", 4, "%.2f", -0.0); */
+ DOTEST(1024, "234.00", 6, "%.2f", 234.005);
+ DOTEST(1024, "8973497.1246", 12, "%.4f", 8973497.12456);
+ DOTEST(1024, "-12.000000", 10, "%f", -12.0);
+ DOTEST(1024, "6", 1, "%.0f", 6.0);
+
+ DOTEST(1024, "6", 1, "%g", 6.0);
+ DOTEST(1024, "6.1", 3, "%g", 6.1);
+ DOTEST(1024, "6.15", 4, "%g", 6.15);
+
+ /* These format strings are from the code of NSD, Unbound, ldns */
+
+ DOTEST(1024, "abcdef", 6, "%s", "abcdef");
+ DOTEST(1024, "005", 3, "%03u", 5);
+ DOTEST(1024, "12345", 5, "%03u", 12345);
+ DOTEST(1024, "5", 1, "%d", 5);
+ DOTEST(1024, "(nil)", 5, "%p", NULL);
+ DOTEST(1024, "12345", 5, "%ld", (long)12345);
+ DOTEST(1024, "12345", 5, "%lu", (long)12345);
+ DOTEST(1024, " 12345", 12, "%12u", (unsigned)12345);
+ DOTEST(1024, "12345", 5, "%u", (unsigned)12345);
+ DOTEST(1024, "12345", 5, "%llu", (unsigned long long)12345);
+ DOTEST(1024, "12345", 5, "%x", 0x12345);
+ DOTEST(1024, "12345", 5, "%llx", (long long)0x12345);
+ DOTEST(1024, "012345", 6, "%6.6d", 12345);
+ DOTEST(1024, "012345", 6, "%6.6u", 12345);
+ DOTEST(1024, "1234.54", 7, "%g", 1234.54);
+ DOTEST(1024, "123456789.54", 12, "%.12g", 123456789.54);
+ DOTEST(1024, "3456789123456.54", 16, "%.16g", 3456789123456.54);
+ /* %24g does not work with 24 digits, not enough accuracy,
+ * the first 16 digits are correct */
+ DOTEST(1024, "12345", 5, "%3.3d", 12345);
+ DOTEST(1024, "000", 3, "%3.3d", 0);
+ DOTEST(1024, "001", 3, "%3.3d", 1);
+ DOTEST(1024, "012", 3, "%3.3d", 12);
+ DOTEST(1024, "-012", 4, "%3.3d", -12);
+ DOTEST(1024, "he", 2, "%.2s", "hello");
+ DOTEST(1024, "helloworld", 10, "%s%s", "hello", "world");
+ DOTEST(1024, "he", 2, "%.*s", 2, "hello");
+ DOTEST(1024, " hello", 7, "%*s", 7, "hello");
+ DOTEST(1024, "hello ", 7, "%*s", -7, "hello");
+ DOTEST(1024, "0", 1, "%c", '0');
+ DOTEST(1024, "A", 1, "%c", 'A');
+ DOTEST(1024, "", 1, "%c", 0);
+ DOTEST(1024, "\010", 1, "%c", 8);
+ DOTEST(1024, "%", 1, "%%");
+ DOTEST(1024, "0a", 2, "%02x", 0x0a);
+ DOTEST(1024, "bd", 2, "%02x", 0xbd);
+ DOTEST(1024, "12", 2, "%02ld", (long)12);
+ DOTEST(1024, "02", 2, "%02ld", (long)2);
+ DOTEST(1024, "02", 2, "%02u", (unsigned)2);
+ DOTEST(1024, "765432", 6, "%05u", (unsigned)765432);
+ DOTEST(1024, "10.234", 6, "%0.3f", 10.23421);
+ DOTEST(1024, "123456.234", 10, "%0.3f", 123456.23421);
+ DOTEST(1024, "123456789.234", 13, "%0.3f", 123456789.23421);
+ DOTEST(1024, "123456.23", 9, "%.2f", 123456.23421);
+ DOTEST(1024, "123456", 6, "%.0f", 123456.23421);
+ DOTEST(1024, "0123", 4, "%.4x", 0x0123);
+ DOTEST(1024, "00000123", 8, "%.8x", 0x0123);
+ DOTEST(1024, "ffeb0cde", 8, "%.8x", 0xffeb0cde);
+ DOTEST(1024, " 987654321", 10, "%10lu", (unsigned long)987654321);
+ DOTEST(1024, " 987654321", 12, "%12lu", (unsigned long)987654321);
+ DOTEST(1024, "987654321", 9, "%i", 987654321);
+ DOTEST(1024, "-87654321", 9, "%i", -87654321);
+ DOTEST(1024, "hello ", 16, "%-16s", "hello");
+ DOTEST(1024, " ", 16, "%-16s", "");
+ DOTEST(1024, "a ", 16, "%-16s", "a");
+ DOTEST(1024, "foobarfoobar ", 16, "%-16s", "foobarfoobar");
+ DOTEST(1024, "foobarfoobarfoobar", 18, "%-16s", "foobarfoobarfoobar");
+
+ /* combined expressions */
+ DOTEST(1024, "foo 1.0 size 512 edns", 21,
+ "foo %s size %d %s%s", "1.0", 512, "", "edns");
+ DOTEST(15, "foo 1.0 size 5", 21,
+ "foo %s size %d %s%s", "1.0", 512, "", "edns");
+ DOTEST(1024, "packet 1203ceff id", 18,
+ "packet %2.2x%2.2x%2.2x%2.2x id", 0x12, 0x03, 0xce, 0xff);
+ DOTEST(1024, "/tmp/testbound_123abcd.tmp", 26, "/tmp/testbound_%u%s%s.tmp", 123, "ab", "cd");
+
+ return 0;
+}
+#endif /* SNPRINTF_TEST */
diff --git a/contrib/unbound/compat/strlcat.c b/contrib/unbound/compat/strlcat.c
new file mode 100644
index 0000000..0bea925
--- /dev/null
+++ b/contrib/unbound/compat/strlcat.c
@@ -0,0 +1,73 @@
+/* compat/strlcat.c */
+
+/*-
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* OPENBSD ORIGINAL: lib/libc/string/strlcat.c */
+
+#include "config.h"
+#ifndef HAVE_STRLCAT
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return(dlen + (s - src)); /* count does not include NUL */
+}
+
+#endif /* !HAVE_STRLCAT */
diff --git a/contrib/unbound/config.h b/contrib/unbound/config.h
index 27af3d6..9c53c13 100644
--- a/contrib/unbound/config.h
+++ b/contrib/unbound/config.h
@@ -62,6 +62,12 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
+/* Define to 1 if you have the `endprotoent' function. */
+#define HAVE_ENDPROTOENT 1
+
+/* Define to 1 if you have the `endservent' function. */
+#define HAVE_ENDSERVENT 1
+
/* Define to 1 if you have the `event_base_free' function. */
/* #undef HAVE_EVENT_BASE_FREE */
@@ -158,15 +164,6 @@
/* Define to 1 if you have the `kill' function. */
#define HAVE_KILL 1
-/* Define to 1 if you have the `ldns_key_EVP_unload_gost' function. */
-/* #undef HAVE_LDNS_KEY_EVP_UNLOAD_GOST */
-
-/* Define to 1 if you have the <ldns/ldns.h> header file. */
-#define HAVE_LDNS_LDNS_H 1
-
-/* Define to 1 if you have the `ldns' library (-lldns). */
-#define HAVE_LIBLDNS 1
-
/* Define to 1 if you have the `localtime_r' function. */
#define HAVE_LOCALTIME_R 1
@@ -212,6 +209,9 @@
/* Define if you have POSIX threads libraries and header files. */
#define HAVE_PTHREAD 1
+/* Have PTHREAD_PRIO_INHERIT. */
+#define HAVE_PTHREAD_PRIO_INHERIT 1
+
/* Define to 1 if the system has the type `pthread_rwlock_t'. */
#define HAVE_PTHREAD_RWLOCK_T 1
@@ -231,7 +231,7 @@
#define HAVE_RECVMSG 1
/* Define to 1 if you have the `sbrk' function. */
-#define HAVE_SBRK 1
+/* #undef HAVE_SBRK */
/* Define to 1 if you have the `sendmsg' function. */
#define HAVE_SENDMSG 1
@@ -299,6 +299,9 @@
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
+/* Define to 1 if you have the `strlcat' function. */
+#define HAVE_STRLCAT 1
+
/* Define to 1 if you have the `strlcpy' function. */
#define HAVE_STRLCPY 1
@@ -428,7 +431,7 @@
#define PACKAGE_NAME "unbound"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "unbound 1.4.20"
+#define PACKAGE_STRING "unbound 1.4.22"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "unbound"
@@ -437,7 +440,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.4.20"
+#define PACKAGE_VERSION "1.4.22"
/* default pidfile location */
#define PIDFILE "/var/unbound/unbound.pid"
@@ -456,7 +459,7 @@
#define ROOT_CERT_FILE "/var/unbound/icannbundle.pem"
/* version number for resource files */
-#define RSRC_PACKAGE_VERSION 1,4,2,0
+#define RSRC_PACKAGE_VERSION 1,4,22,0
/* Directory to chdir to */
#define RUN_DIR "/var/unbound"
@@ -464,6 +467,9 @@
/* Shared data */
#define SHARE_DIR "/var/unbound"
+/* The size of `time_t', as computed by sizeof. */
+#define SIZEOF_TIME_T 8
+
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
@@ -558,6 +564,9 @@
/* Define to 1 if on MINIX. */
/* #undef _MINIX */
+/* Enable for compile on Minix */
+/* #undef _NETBSD_SOURCE */
+
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */
@@ -676,6 +685,12 @@
# define NDEBUG
#endif
+/** Use small-ldns codebase */
+#define USE_SLDNS 1
+#ifdef HAVE_SSL
+# define LDNS_BUILD_CONFIG_HAVE_SSL 1
+#endif
+
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -686,6 +701,10 @@
#include <stddef.h>
#endif
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
@@ -720,6 +739,12 @@
#include <ws2tcpip.h>
#endif
+#ifndef USE_WINSOCK
+#define ARG_LL "%ll"
+#else
+#define ARG_LL "%I64"
+#endif
+
#ifdef HAVE_ATTR_FORMAT
@@ -785,6 +810,12 @@ void *memmove(void *dest, const void *src, size_t n);
#endif
+#ifndef HAVE_STRLCAT
+#define strlcat strlcat_unbound
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+
#ifndef HAVE_STRLCPY
#define strlcpy strlcpy_unbound
size_t strlcpy(char *dst, const char *src, size_t siz);
@@ -797,7 +828,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result);
#endif
-#ifndef HAVE_SLEEP
+#if !defined(HAVE_SLEEP) || defined(HAVE_WINDOWS_H)
#define sleep(x) Sleep((x)*1000) /* on win32 */
#endif /* HAVE_SLEEP */
@@ -863,8 +894,6 @@ char *strptime(const char *s, const char *format, struct tm *tm);
# endif
#endif /* CHECKED_INET6 */
-/* maximum nesting of included files */
-#define MAXINCLUDES 10
#ifndef HAVE_GETADDRINFO
struct sockaddr_storage;
#include "compat/fake-rfc2553.h"
diff --git a/contrib/unbound/config.h.in b/contrib/unbound/config.h.in
index 930b638..630a939 100644
--- a/contrib/unbound/config.h.in
+++ b/contrib/unbound/config.h.in
@@ -61,6 +61,12 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
+/* Define to 1 if you have the `endprotoent' function. */
+#undef HAVE_ENDPROTOENT
+
+/* Define to 1 if you have the `endservent' function. */
+#undef HAVE_ENDSERVENT
+
/* Define to 1 if you have the `event_base_free' function. */
#undef HAVE_EVENT_BASE_FREE
@@ -157,15 +163,6 @@
/* Define to 1 if you have the `kill' function. */
#undef HAVE_KILL
-/* Define to 1 if you have the `ldns_key_EVP_unload_gost' function. */
-#undef HAVE_LDNS_KEY_EVP_UNLOAD_GOST
-
-/* Define to 1 if you have the <ldns/ldns.h> header file. */
-#undef HAVE_LDNS_LDNS_H
-
-/* Define to 1 if you have the `ldns' library (-lldns). */
-#undef HAVE_LIBLDNS
-
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
@@ -211,6 +208,9 @@
/* Define if you have POSIX threads libraries and header files. */
#undef HAVE_PTHREAD
+/* Have PTHREAD_PRIO_INHERIT. */
+#undef HAVE_PTHREAD_PRIO_INHERIT
+
/* Define to 1 if the system has the type `pthread_rwlock_t'. */
#undef HAVE_PTHREAD_RWLOCK_T
@@ -298,6 +298,9 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
+/* Define to 1 if you have the `strlcat' function. */
+#undef HAVE_STRLCAT
+
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
@@ -463,6 +466,9 @@
/* Shared data */
#undef SHARE_DIR
+/* The size of `time_t', as computed by sizeof. */
+#undef SIZEOF_TIME_T
+
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
@@ -557,6 +563,9 @@
/* Define to 1 if on MINIX. */
#undef _MINIX
+/* Enable for compile on Minix */
+#undef _NETBSD_SOURCE
+
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
@@ -675,6 +684,12 @@
# define NDEBUG
#endif
+/** Use small-ldns codebase */
+#define USE_SLDNS 1
+#ifdef HAVE_SSL
+# define LDNS_BUILD_CONFIG_HAVE_SSL 1
+#endif
+
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -685,6 +700,10 @@
#include <stddef.h>
#endif
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
@@ -719,6 +738,12 @@
#include <ws2tcpip.h>
#endif
+#ifndef USE_WINSOCK
+#define ARG_LL "%ll"
+#else
+#define ARG_LL "%I64"
+#endif
+
#ifdef HAVE_ATTR_FORMAT
@@ -784,6 +809,12 @@ void *memmove(void *dest, const void *src, size_t n);
#endif
+#ifndef HAVE_STRLCAT
+#define strlcat strlcat_unbound
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+
#ifndef HAVE_STRLCPY
#define strlcpy strlcpy_unbound
size_t strlcpy(char *dst, const char *src, size_t siz);
@@ -796,7 +827,7 @@ struct tm *gmtime_r(const time_t *timep, struct tm *result);
#endif
-#ifndef HAVE_SLEEP
+#if !defined(HAVE_SLEEP) || defined(HAVE_WINDOWS_H)
#define sleep(x) Sleep((x)*1000) /* on win32 */
#endif /* HAVE_SLEEP */
@@ -862,8 +893,6 @@ char *strptime(const char *s, const char *format, struct tm *tm);
# endif
#endif /* CHECKED_INET6 */
-/* maximum nesting of included files */
-#define MAXINCLUDES 10
#ifndef HAVE_GETADDRINFO
struct sockaddr_storage;
#include "compat/fake-rfc2553.h"
diff --git a/contrib/unbound/configure b/contrib/unbound/configure
index 8d3a181..5672b39 100755
--- a/contrib/unbound/configure
+++ b/contrib/unbound/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for unbound 1.4.20.
+# Generated by GNU Autoconf 2.69 for unbound 1.4.22.
#
# Report bugs to <unbound-bugs@nlnetlabs.nl>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='unbound'
PACKAGE_TARNAME='unbound'
-PACKAGE_VERSION='1.4.20'
-PACKAGE_STRING='unbound 1.4.20'
+PACKAGE_VERSION='1.4.22'
+PACKAGE_STRING='unbound 1.4.22'
PACKAGE_BUGREPORT='unbound-bugs@nlnetlabs.nl'
PACKAGE_URL=''
@@ -632,7 +632,7 @@ ac_includes_default="\
#endif"
ac_subst_vars='LTLIBOBJS
-ldnsdir
+INSTALLTARGET
ALLTARGET
SOURCEFILE
SOURCEDETERMINE
@@ -651,6 +651,8 @@ WINAPPS
WINDRES
CHECKLOCK_OBJ
staticexe
+UNBOUND_EVENT_UNINSTALL
+UNBOUND_EVENT_INSTALL
HAVE_SSL
CONFIG_DATE
NETBSD_LINTFLAGS
@@ -677,7 +679,7 @@ PYTHON_VERSION
PTHREAD_CFLAGS
PTHREAD_LIBS
PTHREAD_CC
-acx_pthread_config
+ax_pthread_config
RUNTIME_PATH
LIBOBJS
OTOOL64
@@ -739,6 +741,9 @@ CC
LIBUNBOUND_AGE
LIBUNBOUND_REVISION
LIBUNBOUND_CURRENT
+UNBOUND_VERSION_MICRO
+UNBOUND_VERSION_MINOR
+UNBOUND_VERSION_MAJOR
target_alias
host_alias
build_alias
@@ -790,6 +795,7 @@ with_rootcert_file
with_username
enable_checking
enable_debug
+enable_flto
enable_shared
enable_static
with_pic
@@ -811,13 +817,13 @@ with_ssl
enable_sha2
enable_gost
enable_ecdsa
+enable_event_api
with_libevent
with_libexpat
enable_static_exe
enable_lock_checks
enable_allsymbols
with_libunbound_only
-with_ldns
'
ac_precious_vars='build_alias
host_alias
@@ -1371,7 +1377,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures unbound 1.4.20 to adapt to many kinds of systems.
+\`configure' configures unbound 1.4.22 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1436,7 +1442,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of unbound 1.4.20:";;
+ short | recursive ) echo "Configuration of unbound 1.4.22:";;
esac
cat <<\_ACEOF
@@ -1446,6 +1452,7 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-checking Enable warnings, asserts, makefile-dependencies
--enable-debug same as enable-checking
+ --disable-flto Disable link-time optimization (gcc specific option)
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
@@ -1464,8 +1471,10 @@ Optional Features:
--disable-sha2 Disable SHA256 and SHA512 RRSIG support
--disable-gost Disable GOST support
--disable-ecdsa Disable ECDSA support
+ --enable-event-api Enable (experimental) libevent-based libunbound API
+ installed to unbound-event.h
--enable-static-exe enable to compile executables statically against
- event, ldns libs, for debug purposes
+ (event) libs, for debug purposes
--enable-lock-checks enable to check lock and unlock calls, for debug
purposes
--enable-allsymbols export all symbols from libunbound and link binaries
@@ -1516,7 +1525,6 @@ Optional Packages:
outgoing port ranges.
--with-libexpat=path specify explicit path for libexpat.
--with-libunbound-only do not build daemon and tool programs
- --with-ldns=PATH specify prefix of path of ldns library to use
Some influential environment variables:
CC C compiler command
@@ -1604,7 +1612,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-unbound configure 1.4.20
+unbound configure 1.4.22
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2024,6 +2032,189 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_type
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if test "$cross_compiling" = yes; then
+ # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_lo=0 ac_mid=0
+ while :; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=$ac_mid; break
+else
+ as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+ if test $ac_lo -le $ac_mid; then
+ ac_lo= ac_hi=
+ break
+ fi
+ as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=-1 ac_mid=-1
+ while :; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_lo=$ac_mid; break
+else
+ as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+ if test $ac_mid -le $ac_hi; then
+ ac_lo= ac_hi=
+ break
+ fi
+ as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ done
+else
+ ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+ as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0;
+return test_array [0];
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_hi=$ac_mid
+else
+ as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+ FILE *f = fopen ("conftest.val", "w");
+ if (! f)
+ return 1;
+ if (($2) < 0)
+ {
+ long int i = longval ();
+ if (i != ($2))
+ return 1;
+ fprintf (f, "%ld", i);
+ }
+ else
+ {
+ unsigned long int i = ulongval ();
+ if (i != ($2))
+ return 1;
+ fprintf (f, "%lu", i);
+ }
+ /* Do not output a trailing newline, as this causes \r\n confusion
+ on some platforms. */
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+ echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+ ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+ fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
+
# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
# ---------------------------------------------
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
@@ -2130,7 +2321,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by unbound $as_me 1.4.20, which was
+It was created by unbound $as_me 1.4.22, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -2478,10 +2669,16 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
ac_compiler_gnu=$ac_cv_c_compiler_gnu
+UNBOUND_VERSION_MAJOR=1
-LIBUNBOUND_CURRENT=3
-LIBUNBOUND_REVISION=5
-LIBUNBOUND_AGE=1
+UNBOUND_VERSION_MINOR=4
+
+UNBOUND_VERSION_MICRO=22
+
+
+LIBUNBOUND_CURRENT=4
+LIBUNBOUND_REVISION=1
+LIBUNBOUND_AGE=2
# 1.0.0 had 0:12:0
# 1.0.1 had 0:13:0
# 1.0.2 had 0:14:0
@@ -2516,7 +2713,8 @@ LIBUNBOUND_AGE=1
# 1.4.17 had 3:2:1
# 1.4.18 had 3:3:1
# 1.4.19 had 3:4:1
-# 1.4.20 had 4:0:2 # adds libunbound.ttl
+# 1.4.20 had 4:0:2 # adds libunbound.ttl # but shipped 3:5:1
+# 1.4.21 had 4:1:2
# Current -- the number of the binary API that we're implementing
# Revision -- which iteration of the implementation of the binary
@@ -3790,6 +3988,11 @@ $as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
+if test "$ac_cv_header_minix_config_h" = "yes"; then
+
+$as_echo "#define _NETBSD_SOURCE 1" >>confdefs.h
+
+fi
case "$prefix" in
NONE)
@@ -3971,7 +4174,7 @@ _ACEOF
$as_echo "#define WINVER 0x0502" >>confdefs.h
-wnvs=`echo $PACKAGE_VERSION | sed -e 's/^[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\).*$/\1,\2,\3,\4/' -e 's/^[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*\([0-9]\)[^0-9]*$/\1,\2,\3,0/' `
+wnvs=`echo $PACKAGE_VERSION | sed -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\).*$/\1,\2,\3,\4/' -e 's/^[^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9][^0-9]*\([0-9][0-9]*\)[^0-9]*$/\1,\2,\3,0/' `
cat >>confdefs.h <<_ACEOF
@@ -4078,7 +4281,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -g -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -4109,7 +4312,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -O2 -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -4699,7 +4902,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -Werror -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -4730,7 +4933,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -Wall -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -4763,7 +4966,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -std=c99 -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -4794,7 +4997,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -xc99 -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -5461,7 +5664,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -W -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -5492,7 +5695,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -Wall -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -5523,7 +5726,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -Wextra -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -5554,7 +5757,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -Wdeclaration-after-statement -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -5584,11 +5787,19 @@ $as_echo "#define UNBOUND_DEBUG /**/" >>confdefs.h
# nothing to do.
;;
esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -flto" >&5
+
+ # Check whether --enable-flto was given.
+if test "${enable_flto+set}" = set; then :
+ enableval=$enable_flto;
+fi
+
+ if test "x$enable_flto" != "xno"; then :
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports -flto" >&5
$as_echo_n "checking if $CC supports -flto... " >&6; }
-BAKCFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -flto"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ BAKCFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -flto"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
@@ -5601,15 +5812,15 @@ main ()
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- if $CC $CFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then
- CFLAGS="$BAKCFLAGS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ if $CC $CFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then
+ CFLAGS="$BAKCFLAGS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- fi
- rm -f conftest conftest.c conftest.o
+ fi
+ rm -f conftest conftest.c conftest.o
else
CFLAGS="$BAKCFLAGS" ; { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
@@ -5618,6 +5829,8 @@ fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
+fi
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
$as_echo_n "checking for inline... " >&6; }
@@ -13793,6 +14006,53 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
fi
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5
+$as_echo_n "checking size of time_t... " >&6; }
+if ${ac_cv_sizeof_time_t+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" "
+$ac_includes_default
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+
+"; then :
+
+else
+ if test "$ac_cv_type_time_t" = yes; then
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "cannot compute sizeof (time_t)
+See \`config.log' for more details" "$LINENO" 5; }
+ else
+ ac_cv_sizeof_time_t=0
+ fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5
+$as_echo "$ac_cv_sizeof_time_t" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_TIME_T $ac_cv_sizeof_time_t
+_ACEOF
+
+
+
# add option to disable the evil rpath
# Check whether --enable-rpath was given.
@@ -15002,14 +15262,13 @@ ub_have_pthreads=no
if test x_$withval != x_no; then
-
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
-acx_pthread_ok=no
+ax_pthread_ok=no
# We used to check for pthread.h first, but this fails if pthread.h
# requires special compiler flags (e.g. on True64 or Sequent).
@@ -15044,13 +15303,13 @@ return pthread_join ();
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- acx_pthread_ok=yes
+ ax_pthread_ok=yes
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5
-$as_echo "$acx_pthread_ok" >&6; }
- if test x"$acx_pthread_ok" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5
+$as_echo "$ax_pthread_ok" >&6; }
+ if test x"$ax_pthread_ok" = xno; then
PTHREAD_LIBS=""
PTHREAD_CFLAGS=""
fi
@@ -15068,7 +15327,7 @@ fi
# which indicates that we try without any flags at all, and "pthread-config"
# which is a program returning the flags for the Pth emulation library.
-acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
# The ordering *is* (sometimes) important. Some notes on the
# individual items follow:
@@ -15090,8 +15349,8 @@ acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -m
# --thread-safe: KAI C++
# pthread-config: use pthread-config program (for GNU Pth library)
-case "${host_cpu}-${host_os}" in
- *solaris*)
+case ${host_os} in
+ solaris*)
# On Solaris (at least, for some versions), libc contains stubbed
# (non-functional) versions of the pthreads routines, so link-based
@@ -15101,12 +15360,16 @@ case "${host_cpu}-${host_os}" in
# who knows whether they'll stub that too in a future libc.) So,
# we'll just look for -pthreads and -lpthread first:
- acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+ ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
+ ;;
+
+ darwin*)
+ ax_pthread_flags="-pthread $ax_pthread_flags"
;;
esac
-if test x"$acx_pthread_ok" = xno; then
-for flag in $acx_pthread_flags; do
+if test x"$ax_pthread_ok" = xno; then
+for flag in $ax_pthread_flags; do
case $flag in
none)
@@ -15120,16 +15383,16 @@ $as_echo_n "checking whether pthreads work with $flag... " >&6; }
PTHREAD_CFLAGS="$flag"
;;
- pthread-config)
- # Extract the first word of "pthread-config", so it can be a program name with args.
+ pthread-config)
+ # Extract the first word of "pthread-config", so it can be a program name with args.
set dummy pthread-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_acx_pthread_config+:} false; then :
+if ${ac_cv_prog_ax_pthread_config+:} false; then :
$as_echo_n "(cached) " >&6
else
- if test -n "$acx_pthread_config"; then
- ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test.
+ if test -n "$ax_pthread_config"; then
+ ac_cv_prog_ax_pthread_config="$ax_pthread_config" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
@@ -15138,7 +15401,7 @@ do
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_acx_pthread_config="yes"
+ ac_cv_prog_ax_pthread_config="yes"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
@@ -15146,23 +15409,23 @@ done
done
IFS=$as_save_IFS
- test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
+ test -z "$ac_cv_prog_ax_pthread_config" && ac_cv_prog_ax_pthread_config="no"
fi
fi
-acx_pthread_config=$ac_cv_prog_acx_pthread_config
-if test -n "$acx_pthread_config"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5
-$as_echo "$acx_pthread_config" >&6; }
+ax_pthread_config=$ac_cv_prog_ax_pthread_config
+if test -n "$ax_pthread_config"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_config" >&5
+$as_echo "$ax_pthread_config" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
- if test x"$acx_pthread_config" = xno; then continue; fi
- PTHREAD_CFLAGS="`pthread-config --cflags`"
- PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
- ;;
+ if test x"$ax_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
*)
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5
@@ -15188,18 +15451,23 @@ $as_echo_n "checking for the pthreads library -l$flag... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <pthread.h>
+ static void routine(void *a) { *((int*)a) = 0; }
+ static void *start_routine(void *a) { return a; }
int
main ()
{
-pthread_t th; pthread_join(th, 0);
- pthread_attr_init(0); pthread_cleanup_push(0, 0);
- pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+pthread_t th; pthread_attr_t attr;
+ pthread_create(&th, 0, start_routine, 0);
+ pthread_join(th, 0);
+ pthread_attr_init(&attr);
+ pthread_cleanup_push(routine, 0);
+ pthread_cleanup_pop(0) /* ; */
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
- acx_pthread_ok=yes
+ ax_pthread_ok=yes
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
@@ -15207,9 +15475,9 @@ rm -f core conftest.err conftest.$ac_objext \
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5
-$as_echo "$acx_pthread_ok" >&6; }
- if test "x$acx_pthread_ok" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5
+$as_echo "$ax_pthread_ok" >&6; }
+ if test "x$ax_pthread_ok" = xyes; then
break;
fi
@@ -15219,24 +15487,24 @@ done
fi
# Various other checks:
-if test "x$acx_pthread_ok" = xyes; then
+if test "x$ax_pthread_ok" = xyes; then
save_LIBS="$LIBS"
LIBS="$PTHREAD_LIBS $LIBS"
save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
# Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5
$as_echo_n "checking for joinable pthread attribute... " >&6; }
- attr_name=unknown
- for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <pthread.h>
int
main ()
{
-int attr=$attr; return attr;
+int attr = $attr; return attr /* ; */
;
return 0;
}
@@ -15246,7 +15514,7 @@ if ac_fn_c_try_link "$LINENO"; then :
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
- done
+ done
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5
$as_echo "$attr_name" >&6; }
if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
@@ -15260,9 +15528,16 @@ _ACEOF
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5
$as_echo_n "checking if more special flags are required for pthreads... " >&6; }
flag=no
- case "${host_cpu}-${host_os}" in
- *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
- *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+ case ${host_os} in
+ aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";;
+ osf* | hpux*) flag="-D_REENTRANT";;
+ solaris*)
+ if test "$GCC" = "yes"; then
+ flag="-D_REENTRANT"
+ else
+ flag="-mt -D_REENTRANT"
+ fi
+ ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5
$as_echo "${flag}" >&6; }
@@ -15270,12 +15545,58 @@ $as_echo "${flag}" >&6; }
PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5
+$as_echo_n "checking for PTHREAD_PRIO_INHERIT... " >&6; }
+if ${ax_cv_PTHREAD_PRIO_INHERIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #include <pthread.h>
+int
+main ()
+{
+int i = PTHREAD_PRIO_INHERIT;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ax_cv_PTHREAD_PRIO_INHERIT=yes
+else
+ ax_cv_PTHREAD_PRIO_INHERIT=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5
+$as_echo "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; }
+ if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"; then :
+
+$as_echo "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h
+
+fi
+
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
- # More AIX lossage: must compile with xlc_r or cc_r
- if test x"$GCC" != xyes; then
- for ac_prog in xlc_r cc_r
+ # More AIX lossage: compile with *_r variant
+ if test "x$GCC" != xyes; then
+ case $host_os in
+ aix*)
+ case "x/$CC" in #(
+ x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6) :
+ #handle absolute path differently from PATH based program lookup
+ case "x$CC" in #(
+ x/*) :
+ if as_fn_executable_p ${CC}_r; then :
+ PTHREAD_CC="${CC}_r"
+fi ;; #(
+ *) :
+ for ac_prog in ${CC}_r
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
@@ -15316,21 +15637,25 @@ fi
test -n "$PTHREAD_CC" && break
done
-test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
-
- else
- PTHREAD_CC=$CC
- fi
-else
- PTHREAD_CC="$CC"
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
+ ;;
+esac ;; #(
+ *) :
+ ;;
+esac
+ ;;
+ esac
+ fi
fi
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
+
# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
-if test x"$acx_pthread_ok" = xyes; then
+if test x"$ax_pthread_ok" = xyes; then
$as_echo "#define HAVE_PTHREAD 1" >>confdefs.h
@@ -15363,7 +15688,7 @@ fi
:
else
- acx_pthread_ok=no
+ ax_pthread_ok=no
fi
ac_ext=c
@@ -15457,7 +15782,7 @@ if eval \${cv_prog_cc_flag_$cache+:} false; then :
$as_echo_n "(cached) " >&6
else
-echo 'void f(){}' >conftest.c
+echo 'void f(void){}' >conftest.c
if test -z "`$CC $CPPFLAGS $CFLAGS -mt -c conftest.c 2>&1`"; then
eval "cv_prog_cc_flag_$cache=yes"
else
@@ -16570,7 +16895,7 @@ else
#include <openssl/evp.h>
#include <openssl/engine.h>
#include <openssl/conf.h>
-/* routine to load gost from ldns */
+/* routine to load gost (from sldns) */
int load_gost_id(void)
{
static int gost_id = 0;
@@ -16760,6 +17085,20 @@ _ACEOF
;;
esac
+# Check whether --enable-event-api was given.
+if test "${enable_event_api+set}" = set; then :
+ enableval=$enable_event_api;
+fi
+
+use_unbound_event="no"
+case "$enable_event_api" in
+ yes)
+ use_unbound_event="yes"
+ ;;
+ *)
+ ;;
+esac
+
# check for libevent
# Check whether --with-libevent was given.
@@ -16777,7 +17116,7 @@ $as_echo_n "checking for libevent... " >&6; }
fi
for dir in $withval; do
thedir="$dir"
- if test -f "$dir/include/event.h"; then
+ if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then
found_libevent="yes"
if test "$thedir" != "/usr"; then
CPPFLAGS="$CPPFLAGS -I$thedir/include"
@@ -16814,8 +17153,18 @@ large outgoing port ranges. " "$LINENO" 5
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: found in $thedir" >&5
$as_echo "found in $thedir" >&6; }
- if test "$thedir" != "/usr" -a "$thedir" != ""; then
- LDFLAGS="$LDFLAGS -L$thedir/lib"
+ if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then
+ LDFLAGS="$LDFLAGS -L$thedir/lib/event2"
+
+ if test "x$enable_rpath" = xyes; then
+ if echo "$thedir/lib/event2" | grep "^/" >/dev/null; then
+ RUNTIME_PATH="$RUNTIME_PATH -R$thedir/lib/event2"
+ fi
+ fi
+
+ else
+ if test "$thedir" != "/usr" -a "$thedir" != ""; then
+ LDFLAGS="$LDFLAGS -L$thedir/lib"
if test "x$enable_rpath" = xyes; then
if echo "$thedir/lib" | grep "^/" >/dev/null; then
@@ -16823,6 +17172,7 @@ $as_echo "found in $thedir" >&6; }
fi
fi
+ fi
fi
fi
# check for library used by libevent after 1.3c
@@ -17090,6 +17440,12 @@ done
if test -n "$BAK_LDFLAGS_SET"; then
LDFLAGS="$BAK_LDFLAGS"
fi
+ if test "$use_unbound_event" = "yes"; then
+ UNBOUND_EVENT_INSTALL=unbound-event-install
+
+ UNBOUND_EVENT_UNINSTALL=unbound-event-uninstall
+
+ fi
else
$as_echo "#define USE_MINI_EVENT 1" >>confdefs.h
@@ -17577,7 +17933,7 @@ if test "$ac_res" != no; then :
fi
-for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex
+for ac_func in tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@@ -17698,6 +18054,20 @@ esac
fi
+ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
+if test "x$ac_cv_func_strlcat" = xyes; then :
+ $as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
+
+else
+ case " $LIBOBJS " in
+ *" strlcat.$ac_objext "* ) ;;
+ *) LIBOBJS="$LIBOBJS strlcat.$ac_objext"
+ ;;
+esac
+
+fi
+
+
ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy"
if test "x$ac_cv_func_strlcpy" = xyes; then :
$as_echo "#define HAVE_STRLCPY 1" >>confdefs.h
@@ -17835,204 +18205,20 @@ rm -f conftest.lo
# see if we want to build the library or everything
ALLTARGET="alltargets"
+INSTALLTARGET="install-all"
# Check whether --with-libunbound-only was given.
if test "${with_libunbound_only+set}" = set; then :
withval=$with_libunbound_only;
if test "$withval" = "yes"; then
ALLTARGET="lib"
+ INSTALLTARGET="install-lib"
fi
fi
-# check this after all other compilation checks, since the linking of the lib
-# may break checks after this.
-
-# Check whether --with-ldns was given.
-if test "${with_ldns+set}" = set; then :
- withval=$with_ldns;
- if test "$withval" != "yes"; then
- if test "$withval" != "/usr" -a "$withval" != ""; then
- CPPFLAGS="-I$withval/include $CPPFLAGS"
- LDFLAGS="-L$withval/lib $LDFLAGS"
-
- if test "x$enable_rpath" = xyes; then
- if echo "$withval/lib" | grep "^/" >/dev/null; then
- RUNTIME_PATH="$RUNTIME_PATH -R$withval/lib"
- fi
- fi
-
- fi
- ldnsdir="$withval"
-
- fi
-
-fi
-
-
-# check if ldns is good enough
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ldns_rr_new in -lldns" >&5
-$as_echo_n "checking for ldns_rr_new in -lldns... " >&6; }
-if ${ac_cv_lib_ldns_ldns_rr_new+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- ac_check_lib_save_LIBS=$LIBS
-LIBS="-lldns $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-/* Override any GCC internal prototype to avoid an error.
- Use char because int might match the return type of a GCC
- builtin and then its argument prototype would still apply. */
-#ifdef __cplusplus
-extern "C"
-#endif
-char ldns_rr_new ();
-int
-main ()
-{
-return ldns_rr_new ();
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- ac_cv_lib_ldns_ldns_rr_new=yes
-else
- ac_cv_lib_ldns_ldns_rr_new=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ldns_ldns_rr_new" >&5
-$as_echo "$ac_cv_lib_ldns_ldns_rr_new" >&6; }
-if test "x$ac_cv_lib_ldns_ldns_rr_new" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBLDNS 1
-_ACEOF
-
- LIBS="-lldns $LIBS"
-
-else
-
- as_fn_error $? "No ldns library found, install the ldns library into system lib dir or use --with-ldns=path to other location. The --with-ldns can point to the make-dir of ldns. Install the package ldns or download source http://www.nlnetlabs.nl/projects/ldns" "$LINENO" 5
-
-fi
-
-ac_fn_c_check_func "$LINENO" "ldns_buffer_copy" "ac_cv_func_ldns_buffer_copy"
-if test "x$ac_cv_func_ldns_buffer_copy" = xyes; then :
-
-fi
-
-if test $USE_NSS = "no"; then
- ac_fn_c_check_func "$LINENO" "ldns_key_buf2rsa_raw" "ac_cv_func_ldns_key_buf2rsa_raw"
-if test "x$ac_cv_func_ldns_key_buf2rsa_raw" = xyes; then :
-
-fi
-
-else
- ac_cv_func_ldns_key_buf2rsa_raw="yes"
-fi
-ac_fn_c_check_func "$LINENO" "ldns_get_random" "ac_cv_func_ldns_get_random"
-if test "x$ac_cv_func_ldns_get_random" = xyes; then :
-
-fi
-
-ac_fn_c_check_func "$LINENO" "ldns_b32_ntop_extended_hex" "ac_cv_func_ldns_b32_ntop_extended_hex"
-if test "x$ac_cv_func_ldns_b32_ntop_extended_hex" = xyes; then :
-
-fi
-
-if test x$use_gost = xyes -a x$USE_NSS = xno; then
- ac_fn_c_check_func "$LINENO" "ldns_key_EVP_load_gost_id" "ac_cv_func_ldns_key_EVP_load_gost_id"
-if test "x$ac_cv_func_ldns_key_EVP_load_gost_id" = xyes; then :
-
-fi
-
- for ac_func in ldns_key_EVP_unload_gost
-do :
- ac_fn_c_check_func "$LINENO" "ldns_key_EVP_unload_gost" "ac_cv_func_ldns_key_EVP_unload_gost"
-if test "x$ac_cv_func_ldns_key_EVP_unload_gost" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LDNS_KEY_EVP_UNLOAD_GOST 1
-_ACEOF
-
-fi
-done
-
-else
- ac_cv_func_ldns_key_EVP_load_gost_id="yes"
-fi
-if test x$use_ecdsa = xyes; then
- ac_fn_c_check_decl "$LINENO" "LDNS_ECDSAP384SHA384" "ac_cv_have_decl_LDNS_ECDSAP384SHA384" "
-$ac_includes_default
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#ifdef HAVE_WS2TCPIP_H
-# include <ws2tcpip.h>
-#endif
-#include <ldns/ldns.h>
-
-"
-if test "x$ac_cv_have_decl_LDNS_ECDSAP384SHA384" = xyes; then :
-
-fi
-
-else
- ac_cv_have_decl_LDNS_ECDSAP384SHA384="yes"
-fi
-for ac_header in ldns/ldns.h
-do :
- ac_fn_c_check_header_compile "$LINENO" "ldns/ldns.h" "ac_cv_header_ldns_ldns_h" "$ac_includes_default
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.h>
-#endif
-
-"
-if test "x$ac_cv_header_ldns_ldns_h" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_LDNS_LDNS_H 1
-_ACEOF
-
-else
-
- as_fn_error $? "No ldns include file found, install the ldns library development files. Install package ldns-dev or ldns-devel or download source http://www.nlnetlabs.nl/projects/ldns" "$LINENO" 5
-
-fi
-
-done
-
-if test $ac_cv_func_ldns_buffer_copy = yes \
- -a $ac_cv_func_ldns_key_buf2rsa_raw = yes \
- -a $ac_cv_func_ldns_get_random = yes \
- -a $ac_cv_header_ldns_ldns_h = yes \
- -a $ac_cv_func_ldns_b32_ntop_extended_hex = yes \
- -a $ac_cv_func_ldns_key_EVP_load_gost_id = yes \
- -a $ac_cv_have_decl_LDNS_ECDSAP384SHA384 = yes; then
- :
-else
- as_fn_error $? "ldns library is not recent, update the ldns library, install it into system lib dir or use --with-ldns=path to other location. The --with-ldns can point to the make-dir of ldns. Package libldns or download source http://www.nlnetlabs.nl/projects/ldns" "$LINENO" 5
-fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: Stripping extension flags..." >&5
@@ -18622,7 +18808,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by unbound $as_me 1.4.20, which was
+This file was extended by unbound $as_me 1.4.22, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -18688,7 +18874,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-unbound config.status 1.4.20
+unbound config.status 1.4.22
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/contrib/unbound/configure.ac b/contrib/unbound/configure.ac
index 180b9d7..5eaab75 100644
--- a/contrib/unbound/configure.ac
+++ b/contrib/unbound/configure.ac
@@ -2,15 +2,22 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
sinclude(acx_nlnetlabs.m4)
-sinclude(acx_pthread.m4)
+sinclude(ax_pthread.m4)
sinclude(acx_python.m4)
sinclude(ac_pkg_swig.m4)
-AC_INIT(unbound, 1.4.20, unbound-bugs@nlnetlabs.nl, unbound)
-
-LIBUNBOUND_CURRENT=3
-LIBUNBOUND_REVISION=5
-LIBUNBOUND_AGE=1
+# must be numbers. ac_defun because of later processing
+m4_define([VERSION_MAJOR],[1])
+m4_define([VERSION_MINOR],[4])
+m4_define([VERSION_MICRO],[22])
+AC_INIT(unbound, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), unbound-bugs@nlnetlabs.nl, unbound)
+AC_SUBST(UNBOUND_VERSION_MAJOR, [VERSION_MAJOR])
+AC_SUBST(UNBOUND_VERSION_MINOR, [VERSION_MINOR])
+AC_SUBST(UNBOUND_VERSION_MICRO, [VERSION_MICRO])
+
+LIBUNBOUND_CURRENT=4
+LIBUNBOUND_REVISION=1
+LIBUNBOUND_AGE=2
# 1.0.0 had 0:12:0
# 1.0.1 had 0:13:0
# 1.0.2 had 0:14:0
@@ -45,7 +52,8 @@ LIBUNBOUND_AGE=1
# 1.4.17 had 3:2:1
# 1.4.18 had 3:3:1
# 1.4.19 had 3:4:1
-# 1.4.20 had 4:0:2 # adds libunbound.ttl
+# 1.4.20 had 4:0:2 # adds libunbound.ttl # but shipped 3:5:1
+# 1.4.21 had 4:1:2
# Current -- the number of the binary API that we're implementing
# Revision -- which iteration of the implementation of the binary
@@ -71,6 +79,9 @@ AC_SUBST(LIBUNBOUND_AGE)
CFLAGS="$CFLAGS"
AC_AIX
+if test "$ac_cv_header_minix_config_h" = "yes"; then
+ AC_DEFINE(_NETBSD_SOURCE,1, [Enable for compile on Minix])
+fi
dnl
dnl By default set prefix to /usr/local
@@ -275,6 +286,20 @@ ACX_TYPE_IN_ADDR_T
ACX_TYPE_IN_PORT_T
ACX_CHECK_MEMCMP_SIGNED
+AC_CHECK_SIZEOF(time_t,,[
+AC_INCLUDES_DEFAULT
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
+])
+
# add option to disable the evil rpath
ACX_ARG_RPATH
AC_SUBST(RUNTIME_PATH)
@@ -371,7 +396,7 @@ AC_ARG_WITH(pthreads, AC_HELP_STRING([--with-pthreads],
[ ],[ withval="yes" ])
ub_have_pthreads=no
if test x_$withval != x_no; then
- ACX_PTHREAD([
+ AX_PTHREAD([
AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.])
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
@@ -579,7 +604,7 @@ AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <openssl/evp.h>
#include <openssl/engine.h>
#include <openssl/conf.h>
-/* routine to load gost from ldns */
+/* routine to load gost (from sldns) */
int load_gost_id(void)
{
static int gost_id = 0;
@@ -707,6 +732,16 @@ case "$enable_ecdsa" in
;;
esac
+AC_ARG_ENABLE(event-api, AC_HELP_STRING([--enable-event-api], [Enable (experimental) libevent-based libunbound API installed to unbound-event.h]))
+use_unbound_event="no"
+case "$enable_event_api" in
+ yes)
+ use_unbound_event="yes"
+ ;;
+ *)
+ ;;
+esac
+
# check for libevent
AC_ARG_WITH(libevent, AC_HELP_STRING([--with-libevent=pathname],
[use libevent (will check /usr/local /opt/local /usr/lib /usr/pkg /usr/sfw /usr or you can specify an explicit path). Slower, but allows use of large outgoing port ranges.]),
@@ -718,7 +753,7 @@ if test x_$withval = x_yes -o x_$withval != x_no; then
fi
for dir in $withval; do
thedir="$dir"
- if test -f "$dir/include/event.h"; then
+ if test -f "$dir/include/event.h" -o -f "$dir/include/event2/event.h"; then
found_libevent="yes"
dnl assume /usr is in default path.
if test "$thedir" != "/usr"; then
@@ -754,10 +789,16 @@ large outgoing port ranges. ])
fi
else
AC_MSG_RESULT(found in $thedir)
- dnl assume /usr is in default path, do not add "".
- if test "$thedir" != "/usr" -a "$thedir" != ""; then
- LDFLAGS="$LDFLAGS -L$thedir/lib"
- ACX_RUNTIME_PATH_ADD([$thedir/lib])
+ dnl if event2 exists and no event lib in dir itself, use subdir
+ if test ! -f $thedir/lib/libevent.a -a ! -f $thedir/lib/libevent.so -a -d "$thedir/lib/event2"; then
+ LDFLAGS="$LDFLAGS -L$thedir/lib/event2"
+ ACX_RUNTIME_PATH_ADD([$thedir/lib/event2])
+ else
+ dnl assume /usr is in default path, do not add "".
+ if test "$thedir" != "/usr" -a "$thedir" != ""; then
+ LDFLAGS="$LDFLAGS -L$thedir/lib"
+ ACX_RUNTIME_PATH_ADD([$thedir/lib])
+ fi
fi
fi
# check for library used by libevent after 1.3c
@@ -781,6 +822,10 @@ large outgoing port ranges. ])
if test -n "$BAK_LDFLAGS_SET"; then
LDFLAGS="$BAK_LDFLAGS"
fi
+ if test "$use_unbound_event" = "yes"; then
+ AC_SUBST(UNBOUND_EVENT_INSTALL, [unbound-event-install])
+ AC_SUBST(UNBOUND_EVENT_UNINSTALL, [unbound-event-uninstall])
+ fi
else
AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
fi
@@ -812,7 +857,7 @@ AC_CHECK_HEADERS([expat.h],,, [AC_INCLUDES_DEFAULT])
AC_SUBST(staticexe)
staticexe=""
AC_ARG_ENABLE(static-exe, AC_HELP_STRING([--enable-static-exe],
- [ enable to compile executables statically against event, ldns libs, for debug purposes ]),
+ [ enable to compile executables statically against (event) libs, for debug purposes ]),
, )
if test x_$enable_static_exe = x_yes; then
staticexe="-static"
@@ -905,7 +950,7 @@ AC_INCLUDES_DEFAULT
#endif
])
AC_SEARCH_LIBS([setusercontext], [util])
-AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex])
+AC_CHECK_FUNCS([tzset sigprocmask fcntl getpwnam getrlimit setrlimit setsid sbrk chroot kill sleep usleep random srandom recvmsg sendmsg writev socketpair glob initgroups strftime localtime_r setusercontext _beginthreadex endservent endprotoent])
AC_CHECK_FUNCS([setresuid],,[AC_CHECK_FUNCS([setreuid])])
AC_CHECK_FUNCS([setresgid],,[AC_CHECK_FUNCS([setregid])])
@@ -917,6 +962,7 @@ AC_REPLACE_FUNCS(inet_aton)
AC_REPLACE_FUNCS(inet_pton)
AC_REPLACE_FUNCS(inet_ntop)
AC_REPLACE_FUNCS(snprintf)
+AC_REPLACE_FUNCS(strlcat)
AC_REPLACE_FUNCS(strlcpy)
AC_REPLACE_FUNCS(memmove)
AC_REPLACE_FUNCS(gmtime_r)
@@ -993,100 +1039,17 @@ AC_SUBST(SOURCEFILE)
# see if we want to build the library or everything
ALLTARGET="alltargets"
+INSTALLTARGET="install-all"
AC_ARG_WITH(libunbound-only, AC_HELP_STRING([--with-libunbound-only],
[do not build daemon and tool programs]),
[
if test "$withval" = "yes"; then
ALLTARGET="lib"
+ INSTALLTARGET="install-lib"
fi
])
AC_SUBST(ALLTARGET)
-
-# check this after all other compilation checks, since the linking of the lib
-# may break checks after this.
-AC_ARG_WITH(ldns, AC_HELP_STRING([--with-ldns=PATH],
- [specify prefix of path of ldns library to use]),
- [
- if test "$withval" != "yes"; then
- if test "$withval" != "/usr" -a "$withval" != ""; then
- CPPFLAGS="-I$withval/include $CPPFLAGS"
- LDFLAGS="-L$withval/lib $LDFLAGS"
- ACX_RUNTIME_PATH_ADD([$withval/lib])
- fi
- ldnsdir="$withval"
- AC_SUBST(ldnsdir)
- fi
-])
-
-# check if ldns is good enough
-AC_CHECK_LIB(ldns, ldns_rr_new,,[
- AC_MSG_ERROR([No ldns library found, install the ldns library into system lib dir or use --with-ldns=path to other location. The --with-ldns can point to the make-dir of ldns. Install the package ldns or download source http://www.nlnetlabs.nl/projects/ldns])
-])
-AC_CHECK_FUNC(ldns_buffer_copy)
-if test $USE_NSS = "no"; then
- AC_CHECK_FUNC(ldns_key_buf2rsa_raw)
-else
- dnl ignore test
- ac_cv_func_ldns_key_buf2rsa_raw="yes"
-fi
-AC_CHECK_FUNC(ldns_get_random)
-AC_CHECK_FUNC(ldns_b32_ntop_extended_hex)
-if test x$use_gost = xyes -a x$USE_NSS = xno; then
- AC_CHECK_FUNC(ldns_key_EVP_load_gost_id)
- AC_CHECK_FUNCS([ldns_key_EVP_unload_gost])
-else
- dnl ignore test
- ac_cv_func_ldns_key_EVP_load_gost_id="yes"
-fi
-if test x$use_ecdsa = xyes; then
- AC_CHECK_DECL([LDNS_ECDSAP384SHA384], [], [], [
-AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_SOCKET_H
-# include <sys/socket.h>
-#endif
-#ifdef HAVE_WS2TCPIP_H
-# include <ws2tcpip.h>
-#endif
-#include <ldns/ldns.h>
- ])
-else
- ac_cv_have_decl_LDNS_ECDSAP384SHA384="yes"
-fi
-AC_CHECK_HEADERS([ldns/ldns.h],,[
- AC_MSG_ERROR([No ldns include file found, install the ldns library development files. Install package ldns-dev or ldns-devel or download source http://www.nlnetlabs.nl/projects/ldns])
- ], [AC_INCLUDES_DEFAULT
-#ifdef HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
-#ifdef HAVE_ARPA_INET_H
-#include <arpa/inet.h>
-#endif
-
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.h>
-#endif
-])
-if test $ac_cv_func_ldns_buffer_copy = yes \
- -a $ac_cv_func_ldns_key_buf2rsa_raw = yes \
- -a $ac_cv_func_ldns_get_random = yes \
- -a $ac_cv_header_ldns_ldns_h = yes \
- -a $ac_cv_func_ldns_b32_ntop_extended_hex = yes \
- -a $ac_cv_func_ldns_key_EVP_load_gost_id = yes \
- -a $ac_cv_have_decl_LDNS_ECDSAP384SHA384 = yes; then
- dnl ldns was found
- :
-else
- AC_MSG_ERROR([ldns library is not recent, update the ldns library, install it into system lib dir or use --with-ldns=path to other location. The --with-ldns can point to the make-dir of ldns. Package libldns or download source http://www.nlnetlabs.nl/projects/ldns])
-fi
+AC_SUBST(INSTALLTARGET)
ACX_STRIP_EXT_FLAGS
LDFLAGS="$LATE_LDFLAGS $LDFLAGS"
@@ -1103,6 +1066,12 @@ dnl includes
# define NDEBUG
#endif
+/** Use small-ldns codebase */
+#define USE_SLDNS 1
+#ifdef HAVE_SSL
+# define LDNS_BUILD_CONFIG_HAVE_SSL 1
+#endif
+
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -1113,6 +1082,10 @@ dnl includes
#include <stddef.h>
#endif
+#ifdef HAVE_STDARG_H
+#include <stdarg.h>
+#endif
+
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
@@ -1146,6 +1119,12 @@ dnl includes
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
+
+#ifndef USE_WINSOCK
+#define ARG_LL "%ll"
+#else
+#define ARG_LL "%I64"
+#endif
]
AHX_CONFIG_FORMAT_ATTRIBUTE
@@ -1157,6 +1136,7 @@ AHX_CONFIG_INET_PTON(unbound)
AHX_CONFIG_INET_NTOP(unbound)
AHX_CONFIG_INET_ATON(unbound)
AHX_CONFIG_MEMMOVE(unbound)
+AHX_CONFIG_STRLCAT(unbound)
AHX_CONFIG_STRLCPY(unbound)
AHX_CONFIG_GMTIME_R(unbound)
AHX_CONFIG_W32_SLEEP
@@ -1193,8 +1173,6 @@ char *strptime(const char *s, const char *format, struct tm *tm);
# endif
#endif /* CHECKED_INET6 */
-/* maximum nesting of included files */
-#define MAXINCLUDES 10
#ifndef HAVE_GETADDRINFO
struct sockaddr_storage;
#include "compat/fake-rfc2553.h"
diff --git a/contrib/unbound/daemon/acl_list.c b/contrib/unbound/daemon/acl_list.c
index 48c8e0f..84d099c 100644
--- a/contrib/unbound/daemon/acl_list.c
+++ b/contrib/unbound/daemon/acl_list.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -103,6 +103,10 @@ acl_list_str_cfg(struct acl_list* acl, const char* str, const char* s2,
control = acl_deny;
else if(strcmp(s2, "refuse") == 0)
control = acl_refuse;
+ else if(strcmp(s2, "deny_non_local") == 0)
+ control = acl_deny_non_local;
+ else if(strcmp(s2, "refuse_non_local") == 0)
+ control = acl_refuse_non_local;
else if(strcmp(s2, "allow_snoop") == 0)
control = acl_allow_snoop;
else {
diff --git a/contrib/unbound/daemon/acl_list.h b/contrib/unbound/daemon/acl_list.h
index 03ac301..2323697 100644
--- a/contrib/unbound/daemon/acl_list.h
+++ b/contrib/unbound/daemon/acl_list.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -55,6 +55,10 @@ enum acl_access {
acl_deny = 0,
/** disallow access, send a polite 'REFUSED' reply */
acl_refuse,
+ /** disallow any access to zones that aren't local, drop it */
+ acl_deny_non_local,
+ /** disallow access to zones that aren't local, 'REFUSED' reply */
+ acl_refuse_non_local,
/** allow full access for recursion (+RD) queries */
acl_allow,
/** allow full access for all queries, recursion and cache snooping */
diff --git a/contrib/unbound/daemon/cachedump.c b/contrib/unbound/daemon/cachedump.c
index 9d941d7..cf5b1a1 100644
--- a/contrib/unbound/daemon/cachedump.c
+++ b/contrib/unbound/daemon/cachedump.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,7 +40,7 @@
* to text format.
*/
#include "config.h"
-#include <ldns/ldns.h>
+#include <openssl/ssl.h>
#include "daemon/cachedump.h"
#include "daemon/remote.h"
#include "daemon/worker.h"
@@ -56,70 +56,25 @@
#include "iterator/iter_utils.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_hints.h"
-
-/** convert to ldns rr */
-static ldns_rr*
-to_rr(struct ub_packed_rrset_key* k, struct packed_rrset_data* d,
- uint32_t now, size_t i, uint16_t type)
-{
- ldns_rr* rr = ldns_rr_new();
- ldns_rdf* rdf;
- ldns_status status;
- size_t pos;
- log_assert(i < d->count + d->rrsig_count);
- if(!rr) {
- return NULL;
- }
- ldns_rr_set_type(rr, type);
- ldns_rr_set_class(rr, ntohs(k->rk.rrset_class));
- if(d->rr_ttl[i] < now)
- ldns_rr_set_ttl(rr, 0);
- else ldns_rr_set_ttl(rr, d->rr_ttl[i] - now);
- pos = 0;
- status = ldns_wire2dname(&rdf, k->rk.dname, k->rk.dname_len, &pos);
- if(status != LDNS_STATUS_OK) {
- /* we drop detailed error in status */
- ldns_rr_free(rr);
- return NULL;
- }
- ldns_rr_set_owner(rr, rdf);
- pos = 0;
- status = ldns_wire2rdf(rr, d->rr_data[i], d->rr_len[i], &pos);
- if(status != LDNS_STATUS_OK) {
- /* we drop detailed error in status */
- ldns_rr_free(rr);
- return NULL;
- }
- return rr;
-}
+#include "ldns/sbuffer.h"
+#include "ldns/wire2str.h"
+#include "ldns/str2wire.h"
/** dump one rrset zonefile line */
static int
-dump_rrset_line(SSL* ssl, struct ub_packed_rrset_key* k,
- struct packed_rrset_data* d, uint32_t now, size_t i, uint16_t type)
+dump_rrset_line(SSL* ssl, struct ub_packed_rrset_key* k, time_t now, size_t i)
{
- char* s;
- ldns_rr* rr = to_rr(k, d, now, i, type);
- if(!rr) {
- return ssl_printf(ssl, "BADRR\n");
- }
- s = ldns_rr2str(rr);
- ldns_rr_free(rr);
- if(!s) {
+ char s[65535];
+ if(!packed_rr_to_string(k, i, now, s, sizeof(s))) {
return ssl_printf(ssl, "BADRR\n");
}
- if(!ssl_printf(ssl, "%s", s)) {
- free(s);
- return 0;
- }
- free(s);
- return 1;
+ return ssl_printf(ssl, "%s", s);
}
/** dump rrset key and data info */
static int
dump_rrset(SSL* ssl, struct ub_packed_rrset_key* k,
- struct packed_rrset_data* d, uint32_t now)
+ struct packed_rrset_data* d, time_t now)
{
size_t i;
/* rd lock held by caller */
@@ -127,29 +82,23 @@ dump_rrset(SSL* ssl, struct ub_packed_rrset_key* k,
if(d->ttl < now) return 1; /* expired */
/* meta line */
- if(!ssl_printf(ssl, ";rrset%s %u %u %u %d %d\n",
+ if(!ssl_printf(ssl, ";rrset%s " ARG_LL "d %u %u %d %d\n",
(k->rk.flags & PACKED_RRSET_NSEC_AT_APEX)?" nsec_apex":"",
- (unsigned)(d->ttl - now),
+ (long long)(d->ttl - now),
(unsigned)d->count, (unsigned)d->rrsig_count,
(int)d->trust, (int)d->security
))
return 0;
- for(i=0; i<d->count; i++) {
- if(!dump_rrset_line(ssl, k, d, now, i, ntohs(k->rk.type)))
+ for(i=0; i<d->count + d->rrsig_count; i++) {
+ if(!dump_rrset_line(ssl, k, now, i))
return 0;
}
- for(i=0; i<d->rrsig_count; i++) {
- if(!dump_rrset_line(ssl, k, d, now, i+d->count,
- LDNS_RR_TYPE_RRSIG))
- return 0;
- }
-
return 1;
}
/** dump lruhash rrset cache */
static int
-dump_rrset_lruhash(SSL* ssl, struct lruhash* h, uint32_t now)
+dump_rrset_lruhash(SSL* ssl, struct lruhash* h, time_t now)
{
struct lruhash_entry* e;
/* lruhash already locked by caller */
@@ -189,20 +138,10 @@ dump_rrset_cache(SSL* ssl, struct worker* worker)
static int
dump_msg_ref(SSL* ssl, struct ub_packed_rrset_key* k)
{
- ldns_rdf* rdf;
- ldns_status status;
- size_t pos;
char* nm, *tp, *cl;
-
- pos = 0;
- status = ldns_wire2dname(&rdf, k->rk.dname, k->rk.dname_len, &pos);
- if(status != LDNS_STATUS_OK) {
- return ssl_printf(ssl, "BADREF\n");
- }
- nm = ldns_rdf2str(rdf);
- ldns_rdf_deep_free(rdf);
- tp = ldns_rr_type2str(ntohs(k->rk.type));
- cl = ldns_rr_class2str(ntohs(k->rk.rrset_class));
+ nm = sldns_wire2str_dname(k->rk.dname, k->rk.dname_len);
+ tp = sldns_wire2str_type(ntohs(k->rk.type));
+ cl = sldns_wire2str_class(ntohs(k->rk.rrset_class));
if(!nm || !cl || !tp) {
free(nm);
free(tp);
@@ -225,25 +164,16 @@ dump_msg_ref(SSL* ssl, struct ub_packed_rrset_key* k)
/** dump message entry */
static int
dump_msg(SSL* ssl, struct query_info* k, struct reply_info* d,
- uint32_t now)
+ time_t now)
{
size_t i;
char* nm, *tp, *cl;
- ldns_rdf* rdf;
- ldns_status status;
- size_t pos;
if(!k || !d) return 1;
if(d->ttl < now) return 1; /* expired */
- pos = 0;
- status = ldns_wire2dname(&rdf, k->qname, k->qname_len, &pos);
- if(status != LDNS_STATUS_OK) {
- return 1; /* skip this entry */
- }
- nm = ldns_rdf2str(rdf);
- ldns_rdf_deep_free(rdf);
- tp = ldns_rr_type2str(k->qtype);
- cl = ldns_rr_class2str(k->qclass);
+ nm = sldns_wire2str_dname(k->qname, k->qname_len);
+ tp = sldns_wire2str_type(k->qtype);
+ cl = sldns_wire2str_class(k->qclass);
if(!nm || !tp || !cl) {
free(nm);
free(tp);
@@ -259,10 +189,10 @@ dump_msg(SSL* ssl, struct query_info* k, struct reply_info* d,
}
/* meta line */
- if(!ssl_printf(ssl, "msg %s %s %s %d %d %u %d %u %u %u\n",
+ if(!ssl_printf(ssl, "msg %s %s %s %d %d " ARG_LL "d %d %u %u %u\n",
nm, cl, tp,
(int)d->flags, (int)d->qdcount,
- (unsigned)(d->ttl-now), (int)d->security,
+ (long long)(d->ttl-now), (int)d->security,
(unsigned)d->an_numrrsets,
(unsigned)d->ns_numrrsets,
(unsigned)d->ar_numrrsets)) {
@@ -369,96 +299,74 @@ dump_cache(SSL* ssl, struct worker* worker)
/** read a line from ssl into buffer */
static int
-ssl_read_buf(SSL* ssl, ldns_buffer* buf)
+ssl_read_buf(SSL* ssl, sldns_buffer* buf)
{
- return ssl_read_line(ssl, (char*)ldns_buffer_begin(buf),
- ldns_buffer_capacity(buf));
+ return ssl_read_line(ssl, (char*)sldns_buffer_begin(buf),
+ sldns_buffer_capacity(buf));
}
/** check fixed text on line */
static int
-read_fixed(SSL* ssl, ldns_buffer* buf, const char* str)
+read_fixed(SSL* ssl, sldns_buffer* buf, const char* str)
{
if(!ssl_read_buf(ssl, buf)) return 0;
- return (strcmp((char*)ldns_buffer_begin(buf), str) == 0);
+ return (strcmp((char*)sldns_buffer_begin(buf), str) == 0);
}
/** load an RR into rrset */
static int
-load_rr(SSL* ssl, ldns_buffer* buf, struct regional* region,
+load_rr(SSL* ssl, sldns_buffer* buf, struct regional* region,
struct ub_packed_rrset_key* rk, struct packed_rrset_data* d,
- unsigned int i, int is_rrsig, int* go_on, uint32_t now)
+ unsigned int i, int is_rrsig, int* go_on, time_t now)
{
- ldns_rr* rr;
- ldns_status status;
+ uint8_t rr[LDNS_RR_BUF_SIZE];
+ size_t rr_len = sizeof(rr), dname_len = 0;
+ int status;
/* read the line */
if(!ssl_read_buf(ssl, buf))
return 0;
- if(strncmp((char*)ldns_buffer_begin(buf), "BADRR\n", 6) == 0) {
+ if(strncmp((char*)sldns_buffer_begin(buf), "BADRR\n", 6) == 0) {
*go_on = 0;
return 1;
}
- status = ldns_rr_new_frm_str(&rr, (char*)ldns_buffer_begin(buf),
- LDNS_DEFAULT_TTL, NULL, NULL);
- if(status != LDNS_STATUS_OK) {
+ status = sldns_str2wire_rr_buf((char*)sldns_buffer_begin(buf), rr,
+ &rr_len, &dname_len, 3600, NULL, 0, NULL, 0);
+ if(status != 0) {
log_warn("error cannot parse rr: %s: %s",
- ldns_get_errorstr_by_id(status),
- (char*)ldns_buffer_begin(buf));
+ sldns_get_errorstr_parse(status),
+ (char*)sldns_buffer_begin(buf));
return 0;
}
- if(is_rrsig && ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG) {
+ if(is_rrsig && sldns_wirerr_get_type(rr, rr_len, dname_len)
+ != LDNS_RR_TYPE_RRSIG) {
log_warn("error expected rrsig but got %s",
- (char*)ldns_buffer_begin(buf));
+ (char*)sldns_buffer_begin(buf));
return 0;
}
/* convert ldns rr into packed_rr */
- d->rr_ttl[i] = ldns_rr_ttl(rr) + now;
- ldns_buffer_clear(buf);
- ldns_buffer_skip(buf, 2);
- status = ldns_rr_rdata2buffer_wire(buf, rr);
- if(status != LDNS_STATUS_OK) {
- log_warn("error cannot rr2wire: %s",
- ldns_get_errorstr_by_id(status));
- ldns_rr_free(rr);
- return 0;
- }
- ldns_buffer_flip(buf);
- ldns_buffer_write_u16_at(buf, 0, ldns_buffer_limit(buf) - 2);
-
- d->rr_len[i] = ldns_buffer_limit(buf);
+ d->rr_ttl[i] = (time_t)sldns_wirerr_get_ttl(rr, rr_len, dname_len) + now;
+ sldns_buffer_clear(buf);
+ d->rr_len[i] = sldns_wirerr_get_rdatalen(rr, rr_len, dname_len)+2;
d->rr_data[i] = (uint8_t*)regional_alloc_init(region,
- ldns_buffer_begin(buf), ldns_buffer_limit(buf));
+ sldns_wirerr_get_rdatawl(rr, rr_len, dname_len), d->rr_len[i]);
if(!d->rr_data[i]) {
- ldns_rr_free(rr);
log_warn("error out of memory");
return 0;
}
/* if first entry, fill the key structure */
if(i==0) {
- rk->rk.type = htons(ldns_rr_get_type(rr));
- rk->rk.rrset_class = htons(ldns_rr_get_class(rr));
- ldns_buffer_clear(buf);
- status = ldns_dname2buffer_wire(buf, ldns_rr_owner(rr));
- if(status != LDNS_STATUS_OK) {
- log_warn("error cannot dname2buffer: %s",
- ldns_get_errorstr_by_id(status));
- ldns_rr_free(rr);
- return 0;
- }
- ldns_buffer_flip(buf);
- rk->rk.dname_len = ldns_buffer_limit(buf);
- rk->rk.dname = regional_alloc_init(region,
- ldns_buffer_begin(buf), ldns_buffer_limit(buf));
+ rk->rk.type = htons(sldns_wirerr_get_type(rr, rr_len, dname_len));
+ rk->rk.rrset_class = htons(sldns_wirerr_get_class(rr, rr_len, dname_len));
+ rk->rk.dname_len = dname_len;
+ rk->rk.dname = regional_alloc_init(region, rr, dname_len);
if(!rk->rk.dname) {
log_warn("error out of memory");
- ldns_rr_free(rr);
return 0;
}
}
- ldns_rr_free(rr);
return 1;
}
@@ -489,7 +397,7 @@ move_into_cache(struct ub_packed_rrset_key* k,
return 0;
}
s = sizeof(*ad) + (sizeof(size_t) + sizeof(uint8_t*) +
- sizeof(uint32_t))* num;
+ sizeof(time_t))* num;
for(i=0; i<num; i++)
s += d->rr_len[i];
ad = (struct packed_rrset_data*)malloc(s);
@@ -505,8 +413,8 @@ move_into_cache(struct ub_packed_rrset_key* k,
p += sizeof(size_t)*num;
memmove(p, &d->rr_data[0], sizeof(uint8_t*)*num);
p += sizeof(uint8_t*)*num;
- memmove(p, &d->rr_ttl[0], sizeof(uint32_t)*num);
- p += sizeof(uint32_t)*num;
+ memmove(p, &d->rr_ttl[0], sizeof(time_t)*num);
+ p += sizeof(time_t)*num;
for(i=0; i<num; i++) {
memmove(p, d->rr_data[i], d->rr_len[i]);
p += d->rr_len[i];
@@ -524,13 +432,14 @@ move_into_cache(struct ub_packed_rrset_key* k,
/** load an rrset entry */
static int
-load_rrset(SSL* ssl, ldns_buffer* buf, struct worker* worker)
+load_rrset(SSL* ssl, sldns_buffer* buf, struct worker* worker)
{
- char* s = (char*)ldns_buffer_begin(buf);
+ char* s = (char*)sldns_buffer_begin(buf);
struct regional* region = worker->scratchpad;
struct ub_packed_rrset_key* rk;
struct packed_rrset_data* d;
- unsigned int ttl, rr_count, rrsig_count, trust, security;
+ unsigned int rr_count, rrsig_count, trust, security;
+ long long ttl;
unsigned int i;
int go_on = 1;
regional_free_all(region);
@@ -552,7 +461,7 @@ load_rrset(SSL* ssl, ldns_buffer* buf, struct worker* worker)
s += 10;
rk->rk.flags |= PACKED_RRSET_NSEC_AT_APEX;
}
- if(sscanf(s, " %u %u %u %u %u", &ttl, &rr_count, &rrsig_count,
+ if(sscanf(s, " " ARG_LL "d %u %u %u %u", &ttl, &rr_count, &rrsig_count,
&trust, &security) != 5) {
log_warn("error bad rrset spec %s", s);
return 0;
@@ -565,12 +474,12 @@ load_rrset(SSL* ssl, ldns_buffer* buf, struct worker* worker)
d->rrsig_count = (size_t)rrsig_count;
d->security = (enum sec_status)security;
d->trust = (enum rrset_trust)trust;
- d->ttl = (uint32_t)ttl + *worker->env.now;
+ d->ttl = (time_t)ttl + *worker->env.now;
d->rr_len = regional_alloc_zero(region,
sizeof(size_t)*(d->count+d->rrsig_count));
d->rr_ttl = regional_alloc_zero(region,
- sizeof(uint32_t)*(d->count+d->rrsig_count));
+ sizeof(time_t)*(d->count+d->rrsig_count));
d->rr_data = regional_alloc_zero(region,
sizeof(uint8_t*)*(d->count+d->rrsig_count));
if(!d->rr_len || !d->rr_ttl || !d->rr_data) {
@@ -605,10 +514,10 @@ load_rrset(SSL* ssl, ldns_buffer* buf, struct worker* worker)
static int
load_rrset_cache(SSL* ssl, struct worker* worker)
{
- ldns_buffer* buf = worker->env.scratch_buffer;
+ sldns_buffer* buf = worker->env.scratch_buffer;
if(!read_fixed(ssl, buf, "START_RRSET_CACHE")) return 0;
while(ssl_read_buf(ssl, buf) &&
- strcmp((char*)ldns_buffer_begin(buf), "END_RRSET_CACHE")!=0) {
+ strcmp((char*)sldns_buffer_begin(buf), "END_RRSET_CACHE")!=0) {
if(!load_rrset(ssl, buf, worker))
return 0;
}
@@ -617,13 +526,13 @@ load_rrset_cache(SSL* ssl, struct worker* worker)
/** read qinfo from next three words */
static char*
-load_qinfo(char* str, struct query_info* qinfo, ldns_buffer* buf,
- struct regional* region)
+load_qinfo(char* str, struct query_info* qinfo, struct regional* region)
{
/* s is part of the buf */
char* s = str;
- ldns_rr* rr;
- ldns_status status;
+ uint8_t rr[LDNS_RR_BUF_SIZE];
+ size_t rr_len = sizeof(rr), dname_len = 0;
+ int status;
/* skip three words */
s = strchr(str, ' ');
@@ -637,26 +546,17 @@ load_qinfo(char* str, struct query_info* qinfo, ldns_buffer* buf,
s++;
/* parse them */
- status = ldns_rr_new_question_frm_str(&rr, str, NULL, NULL);
- if(status != LDNS_STATUS_OK) {
+ status = sldns_str2wire_rr_question_buf(str, rr, &rr_len, &dname_len,
+ NULL, 0, NULL, 0);
+ if(status != 0) {
log_warn("error cannot parse: %s %s",
- ldns_get_errorstr_by_id(status), str);
- return NULL;
- }
- qinfo->qtype = ldns_rr_get_type(rr);
- qinfo->qclass = ldns_rr_get_class(rr);
- ldns_buffer_clear(buf);
- status = ldns_dname2buffer_wire(buf, ldns_rr_owner(rr));
- ldns_rr_free(rr);
- if(status != LDNS_STATUS_OK) {
- log_warn("error cannot dname2wire: %s",
- ldns_get_errorstr_by_id(status));
+ sldns_get_errorstr_parse(status), str);
return NULL;
}
- ldns_buffer_flip(buf);
- qinfo->qname_len = ldns_buffer_limit(buf);
- qinfo->qname = (uint8_t*)regional_alloc_init(region,
- ldns_buffer_begin(buf), ldns_buffer_limit(buf));
+ qinfo->qtype = sldns_wirerr_get_type(rr, rr_len, dname_len);
+ qinfo->qclass = sldns_wirerr_get_class(rr, rr_len, dname_len);
+ qinfo->qname_len = dname_len;
+ qinfo->qname = (uint8_t*)regional_alloc_init(region, rr, dname_len);
if(!qinfo->qname) {
log_warn("error out of memory");
return NULL;
@@ -667,11 +567,11 @@ load_qinfo(char* str, struct query_info* qinfo, ldns_buffer* buf,
/** load a msg rrset reference */
static int
-load_ref(SSL* ssl, ldns_buffer* buf, struct worker* worker,
+load_ref(SSL* ssl, sldns_buffer* buf, struct worker* worker,
struct regional *region, struct ub_packed_rrset_key** rrset,
int* go_on)
{
- char* s = (char*)ldns_buffer_begin(buf);
+ char* s = (char*)sldns_buffer_begin(buf);
struct query_info qinfo;
unsigned int flags;
struct ub_packed_rrset_key* k;
@@ -684,7 +584,7 @@ load_ref(SSL* ssl, ldns_buffer* buf, struct worker* worker,
return 1;
}
- s = load_qinfo(s, &qinfo, buf, region);
+ s = load_qinfo(s, &qinfo, region);
if(!s) {
return 0;
}
@@ -712,13 +612,14 @@ load_ref(SSL* ssl, ldns_buffer* buf, struct worker* worker,
/** load a msg entry */
static int
-load_msg(SSL* ssl, ldns_buffer* buf, struct worker* worker)
+load_msg(SSL* ssl, sldns_buffer* buf, struct worker* worker)
{
struct regional* region = worker->scratchpad;
struct query_info qinf;
struct reply_info rep;
- char* s = (char*)ldns_buffer_begin(buf);
- unsigned int flags, qdcount, ttl, security, an, ns, ar;
+ char* s = (char*)sldns_buffer_begin(buf);
+ unsigned int flags, qdcount, security, an, ns, ar;
+ long long ttl;
size_t i;
int go_on = 1;
@@ -729,20 +630,20 @@ load_msg(SSL* ssl, ldns_buffer* buf, struct worker* worker)
return 0;
}
s += 4;
- s = load_qinfo(s, &qinf, buf, region);
+ s = load_qinfo(s, &qinf, region);
if(!s) {
return 0;
}
/* read remainder of line */
- if(sscanf(s, " %u %u %u %u %u %u %u", &flags, &qdcount, &ttl,
+ if(sscanf(s, " %u %u " ARG_LL "d %u %u %u %u", &flags, &qdcount, &ttl,
&security, &an, &ns, &ar) != 7) {
log_warn("error cannot parse numbers: %s", s);
return 0;
}
rep.flags = (uint16_t)flags;
rep.qdcount = (uint16_t)qdcount;
- rep.ttl = (uint32_t)ttl;
+ rep.ttl = (time_t)ttl;
rep.prefetch_ttl = PREFETCH_TTL_CALC(rep.ttl);
rep.security = (enum sec_status)security;
rep.an_numrrsets = (size_t)an;
@@ -774,10 +675,10 @@ load_msg(SSL* ssl, ldns_buffer* buf, struct worker* worker)
static int
load_msg_cache(SSL* ssl, struct worker* worker)
{
- ldns_buffer* buf = worker->env.scratch_buffer;
+ sldns_buffer* buf = worker->env.scratch_buffer;
if(!read_fixed(ssl, buf, "START_MSG_CACHE")) return 0;
while(ssl_read_buf(ssl, buf) &&
- strcmp((char*)ldns_buffer_begin(buf), "END_MSG_CACHE")!=0) {
+ strcmp((char*)sldns_buffer_begin(buf), "END_MSG_CACHE")!=0) {
if(!load_msg(ssl, buf, worker))
return 0;
}
@@ -800,8 +701,9 @@ print_dp_details(SSL* ssl, struct worker* worker, struct delegpt* dp)
{
char buf[257];
struct delegpt_addr* a;
- int lame, dlame, rlame, rto, edns_vs, to, delay, entry_ttl,
+ int lame, dlame, rlame, rto, edns_vs, to, delay,
tA = 0, tAAAA = 0, tother = 0;
+ long long entry_ttl;
struct rtt_info ri;
uint8_t edns_lame_known;
for(a = dp->target_list; a; a = a->next_target) {
@@ -840,8 +742,8 @@ print_dp_details(SSL* ssl, struct worker* worker, struct delegpt* dp)
return;
continue; /* skip stuff not in infra cache */
}
- if(!ssl_printf(ssl, "%s%s%s%srto %d msec, ttl %d, ping %d "
- "var %d rtt %d, tA %d, tAAAA %d, tother %d",
+ if(!ssl_printf(ssl, "%s%s%s%srto %d msec, ttl " ARG_LL "d, "
+ "ping %d var %d rtt %d, tA %d, tAAAA %d, tother %d",
lame?"LAME ":"", dlame?"NoDNSSEC ":"",
a->lame?"AddrWasParentSide ":"",
rlame?"NoAuthButRecursive ":"", rto, entry_ttl,
diff --git a/contrib/unbound/daemon/cachedump.h b/contrib/unbound/daemon/cachedump.h
index da9804f..0f2feab 100644
--- a/contrib/unbound/daemon/cachedump.h
+++ b/contrib/unbound/daemon/cachedump.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/daemon/daemon.c b/contrib/unbound/daemon/daemon.c
index b91683f..aed22c2 100644
--- a/contrib/unbound/daemon/daemon.c
+++ b/contrib/unbound/daemon/daemon.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -56,12 +56,16 @@
#include <openssl/engine.h>
#endif
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#include <sys/time.h>
+
#ifdef HAVE_NSS
/* nss3 */
#include "nss.h"
#endif
-#include <ldns/ldns.h>
#include "daemon/daemon.h"
#include "daemon/worker.h"
#include "daemon/remote.h"
@@ -80,6 +84,7 @@
#include "util/random.h"
#include "util/tube.h"
#include "util/net_help.h"
+#include "ldns/keyraw.h"
#include <signal.h>
/** How many quit requests happened. */
@@ -203,7 +208,7 @@ daemon_init(void)
OPENSSL_config("unbound");
# endif
# ifdef USE_GOST
- (void)ldns_key_EVP_load_gost_id();
+ (void)sldns_key_EVP_load_gost_id();
# endif
OpenSSL_add_all_algorithms();
# if HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS
@@ -250,9 +255,55 @@ daemon_open_shared_ports(struct daemon* daemon)
{
log_assert(daemon);
if(daemon->cfg->port != daemon->listening_port) {
- listening_ports_free(daemon->ports);
- if(!(daemon->ports=listening_ports_open(daemon->cfg)))
+ size_t i;
+ int reuseport = 0;
+ struct listen_port* p0;
+ /* free and close old ports */
+ if(daemon->ports != NULL) {
+ for(i=0; i<daemon->num_ports; i++)
+ listening_ports_free(daemon->ports[i]);
+ free(daemon->ports);
+ daemon->ports = NULL;
+ }
+ /* see if we want to reuseport */
+#if defined(__linux__) && defined(SO_REUSEPORT)
+ if(daemon->cfg->so_reuseport && daemon->cfg->num_threads > 0)
+ reuseport = 1;
+#endif
+ /* try to use reuseport */
+ p0 = listening_ports_open(daemon->cfg, &reuseport);
+ if(!p0) {
+ listening_ports_free(p0);
return 0;
+ }
+ if(reuseport) {
+ /* reuseport was successful, allocate for it */
+ daemon->num_ports = (size_t)daemon->cfg->num_threads;
+ } else {
+ /* do the normal, singleportslist thing,
+ * reuseport not enabled or did not work */
+ daemon->num_ports = 1;
+ }
+ if(!(daemon->ports = (struct listen_port**)calloc(
+ daemon->num_ports, sizeof(*daemon->ports)))) {
+ listening_ports_free(p0);
+ return 0;
+ }
+ daemon->ports[0] = p0;
+ if(reuseport) {
+ /* continue to use reuseport */
+ for(i=1; i<daemon->num_ports; i++) {
+ if(!(daemon->ports[i]=
+ listening_ports_open(daemon->cfg,
+ &reuseport)) || !reuseport ) {
+ for(i=0; i<daemon->num_ports; i++)
+ listening_ports_free(daemon->ports[i]);
+ free(daemon->ports);
+ daemon->ports = NULL;
+ return 0;
+ }
+ }
+ }
daemon->listening_port = daemon->cfg->port;
}
if(!daemon->cfg->remote_control_enable && daemon->rc_port) {
@@ -389,6 +440,7 @@ static void*
thread_start(void* arg)
{
struct worker* worker = (struct worker*)arg;
+ int port_num = 0;
log_thread_set(&worker->thread_num);
ub_thread_blocksigs();
#ifdef THREADS_DISABLED
@@ -396,7 +448,14 @@ thread_start(void* arg)
tube_close_write(worker->cmd);
close_other_pipes(worker->daemon, worker->thread_num);
#endif
- if(!worker_init(worker, worker->daemon->cfg, worker->daemon->ports, 0))
+#if defined(__linux__) && defined(SO_REUSEPORT)
+ if(worker->daemon->cfg->so_reuseport)
+ port_num = worker->thread_num;
+ else
+ port_num = 0;
+#endif
+ if(!worker_init(worker, worker->daemon->cfg,
+ worker->daemon->ports[port_num], 0))
fatal_exit("Could not initialize thread");
worker_work(worker);
@@ -469,7 +528,7 @@ daemon_fork(struct daemon* daemon)
#if defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP)
/* in libev the first inited base gets signals */
- if(!worker_init(daemon->workers[0], daemon->cfg, daemon->ports, 1))
+ if(!worker_init(daemon->workers[0], daemon->cfg, daemon->ports[0], 1))
fatal_exit("Could not initialize main thread");
#endif
@@ -483,7 +542,7 @@ daemon_fork(struct daemon* daemon)
*/
#if !(defined(HAVE_EV_LOOP) || defined(HAVE_EV_DEFAULT_LOOP))
/* libevent has the last inited base get signals (or any base) */
- if(!worker_init(daemon->workers[0], daemon->cfg, daemon->ports, 1))
+ if(!worker_init(daemon->workers[0], daemon->cfg, daemon->ports[0], 1))
fatal_exit("Could not initialize main thread");
#endif
signal_handling_playback(daemon->workers[0]);
@@ -529,11 +588,14 @@ daemon_cleanup(struct daemon* daemon)
void
daemon_delete(struct daemon* daemon)
{
+ size_t i;
if(!daemon)
return;
modstack_desetup(&daemon->mods, daemon->env);
daemon_remote_delete(daemon->rc);
- listening_ports_free(daemon->ports);
+ for(i = 0; i < daemon->num_ports; i++)
+ listening_ports_free(daemon->ports[i]);
+ free(daemon->ports);
listening_ports_free(daemon->rc_ports);
if(daemon->env) {
slabhash_delete(daemon->env->msg_cache);
@@ -558,7 +620,7 @@ daemon_delete(struct daemon* daemon)
/* libcrypto cleanup */
#ifdef HAVE_SSL
# if defined(USE_GOST) && defined(HAVE_LDNS_KEY_EVP_UNLOAD_GOST)
- ldns_key_EVP_unload_gost();
+ sldns_key_EVP_unload_gost();
# endif
# if HAVE_DECL_SSL_COMP_GET_COMPRESSION_METHODS && HAVE_DECL_SK_SSL_COMP_POP_FREE
# ifndef S_SPLINT_S
diff --git a/contrib/unbound/daemon/daemon.h b/contrib/unbound/daemon/daemon.h
index 8e47ea0..855b0d3 100644
--- a/contrib/unbound/daemon/daemon.h
+++ b/contrib/unbound/daemon/daemon.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -72,8 +72,11 @@ struct daemon {
char* pidfile;
/** port number that has ports opened. */
int listening_port;
- /** listening ports, opened, to be shared by threads */
- struct listen_port* ports;
+ /** array of listening ports, opened. Listening ports per worker,
+ * or just one element[0] shared by the worker threads. */
+ struct listen_port** ports;
+ /** size of ports array */
+ size_t num_ports;
/** port number for remote that has ports opened. */
int rc_port;
/** listening ports for remote control */
diff --git a/contrib/unbound/daemon/remote.c b/contrib/unbound/daemon/remote.c
index ba02d7d..6882e16 100644
--- a/contrib/unbound/daemon/remote.c
+++ b/contrib/unbound/daemon/remote.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -47,7 +47,6 @@
#include <openssl/err.h>
#endif
#include <ctype.h>
-#include <ldns/ldns.h>
#include "daemon/remote.h"
#include "daemon/worker.h"
#include "daemon/daemon.h"
@@ -75,6 +74,10 @@
#include "iterator/iter_delegpt.h"
#include "services/outbound_list.h"
#include "services/outside_network.h"
+#include "ldns/str2wire.h"
+#include "ldns/parseutil.h"
+#include "ldns/wire2str.h"
+#include "ldns/sbuffer.h"
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
@@ -268,7 +271,7 @@ add_open(const char* ip, int nr, struct listen_port** list, int noproto_is_err)
}
/* open fd */
- fd = create_tcp_accept_sock(res, 1, &noproto);
+ fd = create_tcp_accept_sock(res, 1, &noproto, 0);
freeaddrinfo(res);
if(fd == -1 && noproto) {
if(!noproto_is_err)
@@ -629,8 +632,8 @@ print_stats(SSL* ssl, const char* nm, struct stats_info* s)
if(!ssl_printf(ssl, "%s.requestlist.current.user"SQ"%u\n", nm,
(unsigned)s->mesh_num_reply_states)) return 0;
timeval_divide(&avg, &s->mesh_replies_sum_wait, s->mesh_replies_sent);
- if(!ssl_printf(ssl, "%s.recursion.time.avg"SQ"%d.%6.6d\n", nm,
- (int)avg.tv_sec, (int)avg.tv_usec)) return 0;
+ if(!ssl_printf(ssl, "%s.recursion.time.avg"SQ ARG_LL "d.%6.6d\n", nm,
+ (long long)avg.tv_sec, (int)avg.tv_usec)) return 0;
if(!ssl_printf(ssl, "%s.recursion.time.median"SQ"%g\n", nm,
s->mesh_time_median)) return 0;
return 1;
@@ -713,12 +716,12 @@ print_uptime(SSL* ssl, struct worker* worker, int reset)
timeval_subtract(&dt, &now, &worker->daemon->time_last_stat);
if(reset)
worker->daemon->time_last_stat = now;
- if(!ssl_printf(ssl, "time.now"SQ"%d.%6.6d\n",
- (unsigned)now.tv_sec, (unsigned)now.tv_usec)) return 0;
- if(!ssl_printf(ssl, "time.up"SQ"%d.%6.6d\n",
- (unsigned)up.tv_sec, (unsigned)up.tv_usec)) return 0;
- if(!ssl_printf(ssl, "time.elapsed"SQ"%d.%6.6d\n",
- (unsigned)dt.tv_sec, (unsigned)dt.tv_usec)) return 0;
+ if(!ssl_printf(ssl, "time.now"SQ ARG_LL "d.%6.6d\n",
+ (long long)now.tv_sec, (unsigned)now.tv_usec)) return 0;
+ if(!ssl_printf(ssl, "time.up"SQ ARG_LL "d.%6.6d\n",
+ (long long)up.tv_sec, (unsigned)up.tv_usec)) return 0;
+ if(!ssl_printf(ssl, "time.elapsed"SQ ARG_LL "d.%6.6d\n",
+ (long long)dt.tv_sec, (unsigned)dt.tv_usec)) return 0;
return 1;
}
@@ -756,13 +759,13 @@ print_ext(SSL* ssl, struct stats_info* s)
{
int i;
char nm[16];
- const ldns_rr_descriptor* desc;
- const ldns_lookup_table* lt;
+ const sldns_rr_descriptor* desc;
+ const sldns_lookup_table* lt;
/* TYPE */
for(i=0; i<STATS_QTYPE_NUM; i++) {
if(inhibit_zero && s->svr.qtype[i] == 0)
continue;
- desc = ldns_rr_descript((uint16_t)i);
+ desc = sldns_rr_descript((uint16_t)i);
if(desc && desc->_name) {
snprintf(nm, sizeof(nm), "%s", desc->_name);
} else if (i == LDNS_RR_TYPE_IXFR) {
@@ -789,7 +792,7 @@ print_ext(SSL* ssl, struct stats_info* s)
for(i=0; i<STATS_QCLASS_NUM; i++) {
if(inhibit_zero && s->svr.qclass[i] == 0)
continue;
- lt = ldns_lookup_by_id(ldns_rr_classes, i);
+ lt = sldns_lookup_by_id(sldns_rr_classes, i);
if(lt && lt->name) {
snprintf(nm, sizeof(nm), "%s", lt->name);
} else {
@@ -806,7 +809,7 @@ print_ext(SSL* ssl, struct stats_info* s)
for(i=0; i<STATS_OPCODE_NUM; i++) {
if(inhibit_zero && s->svr.qopcode[i] == 0)
continue;
- lt = ldns_lookup_by_id(ldns_opcodes, i);
+ lt = sldns_lookup_by_id(sldns_opcodes, i);
if(lt && lt->name) {
snprintf(nm, sizeof(nm), "%s", lt->name);
} else {
@@ -846,7 +849,7 @@ print_ext(SSL* ssl, struct stats_info* s)
for(i=0; i<STATS_RCODE_NUM; i++) {
if(inhibit_zero && s->svr.ans_rcode[i] == 0)
continue;
- lt = ldns_lookup_by_id(ldns_rcodes, i);
+ lt = sldns_lookup_by_id(sldns_rcodes, i);
if(lt && lt->name) {
snprintf(nm, sizeof(nm), "%s", lt->name);
} else {
@@ -912,17 +915,20 @@ do_stats(SSL* ssl, struct daemon_remote* rc, int reset)
static int
parse_arg_name(SSL* ssl, char* str, uint8_t** res, size_t* len, int* labs)
{
- ldns_rdf* rdf;
+ uint8_t nm[LDNS_MAX_DOMAINLEN+1];
+ size_t nmlen = sizeof(nm);
+ int status;
*res = NULL;
*len = 0;
*labs = 0;
- rdf = ldns_dname_new_frm_str(str);
- if(!rdf) {
- ssl_printf(ssl, "error cannot parse name %s\n", str);
+ status = sldns_str2wire_dname_buf(str, nm, &nmlen);
+ if(status != 0) {
+ ssl_printf(ssl, "error cannot parse name %s at %d: %s\n", str,
+ LDNS_WIREPARSE_OFFSET(status),
+ sldns_get_errorstr_parse(status));
return 0;
}
- *res = memdup(ldns_rdf_data(rdf), ldns_rdf_size(rdf));
- ldns_rdf_deep_free(rdf);
+ *res = memdup(nm, nmlen);
if(!*res) {
ssl_printf(ssl, "error out of memory\n");
return 0;
@@ -975,7 +981,7 @@ do_zone_add(SSL* ssl, struct worker* worker, char* arg)
free(nm);
return;
}
- lock_quick_lock(&worker->daemon->local_zones->lock);
+ lock_rw_wrlock(&worker->daemon->local_zones->lock);
if((z=local_zones_find(worker->daemon->local_zones, nm, nmlen,
nmlabs, LDNS_RR_CLASS_IN))) {
/* already present in tree */
@@ -983,17 +989,17 @@ do_zone_add(SSL* ssl, struct worker* worker, char* arg)
z->type = t; /* update type anyway */
lock_rw_unlock(&z->lock);
free(nm);
- lock_quick_unlock(&worker->daemon->local_zones->lock);
+ lock_rw_unlock(&worker->daemon->local_zones->lock);
send_ok(ssl);
return;
}
if(!local_zones_add_zone(worker->daemon->local_zones, nm, nmlen,
nmlabs, LDNS_RR_CLASS_IN, t)) {
- lock_quick_unlock(&worker->daemon->local_zones->lock);
+ lock_rw_unlock(&worker->daemon->local_zones->lock);
ssl_printf(ssl, "error out of memory\n");
return;
}
- lock_quick_unlock(&worker->daemon->local_zones->lock);
+ lock_rw_unlock(&worker->daemon->local_zones->lock);
send_ok(ssl);
}
@@ -1007,13 +1013,13 @@ do_zone_remove(SSL* ssl, struct worker* worker, char* arg)
struct local_zone* z;
if(!parse_arg_name(ssl, arg, &nm, &nmlen, &nmlabs))
return;
- lock_quick_lock(&worker->daemon->local_zones->lock);
+ lock_rw_wrlock(&worker->daemon->local_zones->lock);
if((z=local_zones_find(worker->daemon->local_zones, nm, nmlen,
nmlabs, LDNS_RR_CLASS_IN))) {
/* present in tree */
local_zones_del_zone(worker->daemon->local_zones, z);
}
- lock_quick_unlock(&worker->daemon->local_zones->lock);
+ lock_rw_unlock(&worker->daemon->local_zones->lock);
free(nm);
send_ok(ssl);
}
@@ -1022,8 +1028,7 @@ do_zone_remove(SSL* ssl, struct worker* worker, char* arg)
static void
do_data_add(SSL* ssl, struct worker* worker, char* arg)
{
- if(!local_zones_add_RR(worker->daemon->local_zones, arg,
- worker->env.scratch_buffer)) {
+ if(!local_zones_add_RR(worker->daemon->local_zones, arg)) {
ssl_printf(ssl,"error in syntax or out of memory, %s\n", arg);
return;
}
@@ -1090,7 +1095,7 @@ do_flush_type(SSL* ssl, struct worker* worker, char* arg)
return;
if(!parse_arg_name(ssl, arg, &nm, &nmlen, &nmlabs))
return;
- t = ldns_get_rr_type_by_name(arg2);
+ t = sldns_get_rr_type_by_name(arg2);
do_cache_remove(worker, nm, nmlen, t, LDNS_RR_CLASS_IN);
free(nm);
@@ -1118,9 +1123,9 @@ struct del_info {
/** labels */
int labs;
/** now */
- uint32_t now;
+ time_t now;
/** time to invalidate to */
- uint32_t expired;
+ time_t expired;
/** number of rrsets removed */
size_t num_rrsets;
/** number of msgs removed */
@@ -1388,9 +1393,9 @@ ssl_print_name_dp(SSL* ssl, const char* str, uint8_t* nm, uint16_t dclass,
struct delegpt_addr* a;
int f = 0;
if(str) { /* print header for forward, stub */
- char* c = ldns_rr_class2str(dclass);
+ char* c = sldns_wire2str_class(dclass);
dname_str(nm, buf);
- if(!ssl_printf(ssl, "%s %s %s: ", buf, c, str)) {
+ if(!ssl_printf(ssl, "%s %s %s: ", buf, (c?c:"CLASS??"), str)) {
free(c);
return 0;
}
@@ -1571,7 +1576,7 @@ do_forward_add(SSL* ssl, struct worker* worker, char* args)
struct delegpt* dp = NULL;
if(!parse_fs_args(ssl, args, &nm, &dp, &insecure, NULL))
return;
- if(insecure) {
+ if(insecure && worker->env.anchors) {
if(!anchors_add_insecure(worker->env.anchors, LDNS_RR_CLASS_IN,
nm)) {
(void)ssl_printf(ssl, "error out of memory\n");
@@ -1598,7 +1603,7 @@ do_forward_remove(SSL* ssl, struct worker* worker, char* args)
uint8_t* nm = NULL;
if(!parse_fs_args(ssl, args, &nm, NULL, &insecure, NULL))
return;
- if(insecure)
+ if(insecure && worker->env.anchors)
anchors_delete_insecure(worker->env.anchors, LDNS_RR_CLASS_IN,
nm);
forwards_delete_zone(fwd, LDNS_RR_CLASS_IN, nm);
@@ -1616,7 +1621,7 @@ do_stub_add(SSL* ssl, struct worker* worker, char* args)
struct delegpt* dp = NULL;
if(!parse_fs_args(ssl, args, &nm, &dp, &insecure, &prime))
return;
- if(insecure) {
+ if(insecure && worker->env.anchors) {
if(!anchors_add_insecure(worker->env.anchors, LDNS_RR_CLASS_IN,
nm)) {
(void)ssl_printf(ssl, "error out of memory\n");
@@ -1626,8 +1631,9 @@ do_stub_add(SSL* ssl, struct worker* worker, char* args)
}
}
if(!forwards_add_stub_hole(fwd, LDNS_RR_CLASS_IN, nm)) {
- if(insecure) anchors_delete_insecure(worker->env.anchors,
- LDNS_RR_CLASS_IN, nm);
+ if(insecure && worker->env.anchors)
+ anchors_delete_insecure(worker->env.anchors,
+ LDNS_RR_CLASS_IN, nm);
(void)ssl_printf(ssl, "error out of memory\n");
delegpt_free_mlc(dp);
free(nm);
@@ -1636,8 +1642,9 @@ do_stub_add(SSL* ssl, struct worker* worker, char* args)
if(!hints_add_stub(worker->env.hints, LDNS_RR_CLASS_IN, dp, !prime)) {
(void)ssl_printf(ssl, "error out of memory\n");
forwards_delete_stub_hole(fwd, LDNS_RR_CLASS_IN, nm);
- if(insecure) anchors_delete_insecure(worker->env.anchors,
- LDNS_RR_CLASS_IN, nm);
+ if(insecure && worker->env.anchors)
+ anchors_delete_insecure(worker->env.anchors,
+ LDNS_RR_CLASS_IN, nm);
free(nm);
return;
}
@@ -1654,7 +1661,7 @@ do_stub_remove(SSL* ssl, struct worker* worker, char* args)
uint8_t* nm = NULL;
if(!parse_fs_args(ssl, args, &nm, NULL, &insecure, NULL))
return;
- if(insecure)
+ if(insecure && worker->env.anchors)
anchors_delete_insecure(worker->env.anchors, LDNS_RR_CLASS_IN,
nm);
forwards_delete_stub_hole(fwd, LDNS_RR_CLASS_IN, nm);
@@ -1663,6 +1670,43 @@ do_stub_remove(SSL* ssl, struct worker* worker, char* args)
send_ok(ssl);
}
+/** do the insecure_add command */
+static void
+do_insecure_add(SSL* ssl, struct worker* worker, char* arg)
+{
+ size_t nmlen;
+ int nmlabs;
+ uint8_t* nm = NULL;
+ if(!parse_arg_name(ssl, arg, &nm, &nmlen, &nmlabs))
+ return;
+ if(worker->env.anchors) {
+ if(!anchors_add_insecure(worker->env.anchors,
+ LDNS_RR_CLASS_IN, nm)) {
+ (void)ssl_printf(ssl, "error out of memory\n");
+ free(nm);
+ return;
+ }
+ }
+ free(nm);
+ send_ok(ssl);
+}
+
+/** do the insecure_remove command */
+static void
+do_insecure_remove(SSL* ssl, struct worker* worker, char* arg)
+{
+ size_t nmlen;
+ int nmlabs;
+ uint8_t* nm = NULL;
+ if(!parse_arg_name(ssl, arg, &nm, &nmlen, &nmlabs))
+ return;
+ if(worker->env.anchors)
+ anchors_delete_insecure(worker->env.anchors,
+ LDNS_RR_CLASS_IN, nm);
+ free(nm);
+ send_ok(ssl);
+}
+
/** do the status command */
static void
do_status(SSL* ssl, struct worker* worker)
@@ -1684,7 +1728,7 @@ do_status(SSL* ssl, struct worker* worker)
if(!ssl_printf(ssl, " ]\n"))
return;
uptime = (time_t)time(NULL) - (time_t)worker->daemon->time_boot.tv_sec;
- if(!ssl_printf(ssl, "uptime: %u seconds\n", (unsigned)uptime))
+ if(!ssl_printf(ssl, "uptime: " ARG_LL "d seconds\n", (long long)uptime))
return;
if(!ssl_printf(ssl, "unbound (pid %d) is running...\n",
(int)getpid()))
@@ -1703,7 +1747,8 @@ get_mesh_age(struct mesh_state* m, char* buf, size_t len,
while(r && r->next)
r = r->next;
timeval_subtract(&d, env->now_tv, &r->start_time);
- snprintf(buf, len, "%d.%6.6d", (int)d.tv_sec, (int)d.tv_usec);
+ snprintf(buf, len, ARG_LL "d.%6.6d",
+ (long long)d.tv_sec, (int)d.tv_usec);
} else {
snprintf(buf, len, "-");
}
@@ -1748,10 +1793,11 @@ get_mesh_status(struct mesh_area* mesh, struct mesh_state* m,
if(m->sub_set.count == 0)
snprintf(buf, len, " (empty_list)");
RBTREE_FOR(sub, struct mesh_state_ref*, &m->sub_set) {
- char* t = ldns_rr_type2str(sub->s->s.qinfo.qtype);
- char* c = ldns_rr_class2str(sub->s->s.qinfo.qclass);
+ char* t = sldns_wire2str_type(sub->s->s.qinfo.qtype);
+ char* c = sldns_wire2str_class(sub->s->s.qinfo.qclass);
dname_str(sub->s->s.qinfo.qname, nm);
- snprintf(buf, len, " %s %s %s", t, c, nm);
+ snprintf(buf, len, " %s %s %s", (t?t:"TYPE??"),
+ (c?c:"CLASS??"), nm);
l = strlen(buf);
buf += l; len -= l;
free(t);
@@ -1780,13 +1826,14 @@ do_dump_requestlist(SSL* ssl, struct worker* worker)
mesh = worker->env.mesh;
if(!mesh) return;
RBTREE_FOR(m, struct mesh_state*, &mesh->all) {
- char* t = ldns_rr_type2str(m->s.qinfo.qtype);
- char* c = ldns_rr_class2str(m->s.qinfo.qclass);
+ char* t = sldns_wire2str_type(m->s.qinfo.qtype);
+ char* c = sldns_wire2str_class(m->s.qinfo.qclass);
dname_str(m->s.qinfo.qname, buf);
get_mesh_age(m, timebuf, sizeof(timebuf), &worker->env);
get_mesh_status(mesh, m, statbuf, sizeof(statbuf));
if(!ssl_printf(ssl, "%3d %4s %2s %s %s %s\n",
- num, t, c, buf, timebuf, statbuf)) {
+ num, (t?t:"TYPE??"), (c?c:"CLASS??"), buf, timebuf,
+ statbuf)) {
free(t);
free(c);
return;
@@ -1804,7 +1851,7 @@ struct infra_arg {
/** the SSL connection */
SSL* ssl;
/** the time now */
- uint32_t now;
+ time_t now;
};
/** callback for every host element in the infra cache */
@@ -1927,7 +1974,7 @@ do_list_local_zones(SSL* ssl, struct worker* worker)
struct local_zones* zones = worker->daemon->local_zones;
struct local_zone* z;
char buf[257];
- lock_quick_lock(&zones->lock);
+ lock_rw_rdlock(&zones->lock);
RBTREE_FOR(z, struct local_zone*, &zones->ztree) {
lock_rw_rdlock(&z->lock);
dname_str(z->name, buf);
@@ -1935,7 +1982,7 @@ do_list_local_zones(SSL* ssl, struct worker* worker)
local_zone_type2str(z->type));
lock_rw_unlock(&z->lock);
}
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
}
/** do the list_local_data command */
@@ -1946,22 +1993,30 @@ do_list_local_data(SSL* ssl, struct worker* worker)
struct local_zone* z;
struct local_data* d;
struct local_rrset* p;
- lock_quick_lock(&zones->lock);
+ char* s = (char*)sldns_buffer_begin(worker->env.scratch_buffer);
+ size_t slen = sldns_buffer_capacity(worker->env.scratch_buffer);
+ lock_rw_rdlock(&zones->lock);
RBTREE_FOR(z, struct local_zone*, &zones->ztree) {
lock_rw_rdlock(&z->lock);
RBTREE_FOR(d, struct local_data*, &z->data) {
for(p = d->rrsets; p; p = p->next) {
- ldns_rr_list* rr = packed_rrset_to_rr_list(
- p->rrset, worker->env.scratch_buffer);
- char* str = ldns_rr_list2str(rr);
- (void)ssl_printf(ssl, "%s", str);
- free(str);
- ldns_rr_list_free(rr);
+ struct packed_rrset_data* d =
+ (struct packed_rrset_data*)p->rrset->entry.data;
+ size_t i;
+ for(i=0; i<d->count + d->rrsig_count; i++) {
+ if(!packed_rr_to_string(p->rrset, i,
+ 0, s, slen)) {
+ if(!ssl_printf(ssl, "BADRR\n"))
+ return;
+ }
+ if(!ssl_printf(ssl, "%s\n", s))
+ return;
+ }
}
}
lock_rw_unlock(&z->lock);
}
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
}
/** tell other processes to execute the command */
@@ -2050,6 +2105,16 @@ execute_cmd(struct daemon_remote* rc, SSL* ssl, char* cmd,
if(rc) distribute_cmd(rc, ssl, cmd);
do_forward_remove(ssl, worker, skipwhite(p+14));
return;
+ } else if(cmdcmp(p, "insecure_add", 12)) {
+ /* must always distribute this cmd */
+ if(rc) distribute_cmd(rc, ssl, cmd);
+ do_insecure_add(ssl, worker, skipwhite(p+12));
+ return;
+ } else if(cmdcmp(p, "insecure_remove", 15)) {
+ /* must always distribute this cmd */
+ if(rc) distribute_cmd(rc, ssl, cmd);
+ do_insecure_remove(ssl, worker, skipwhite(p+15));
+ return;
} else if(cmdcmp(p, "forward", 7)) {
/* must always distribute this cmd */
if(rc) distribute_cmd(rc, ssl, cmd);
diff --git a/contrib/unbound/daemon/remote.h b/contrib/unbound/daemon/remote.h
index 7d922bd..cc670b7 100644
--- a/contrib/unbound/daemon/remote.h
+++ b/contrib/unbound/daemon/remote.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/daemon/stats.c b/contrib/unbound/daemon/stats.c
index 9a1a7d2..57ad1ef 100644
--- a/contrib/unbound/daemon/stats.c
+++ b/contrib/unbound/daemon/stats.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,7 +40,11 @@
* numbers. These 'statistics' may be of interest to the operator.
*/
#include "config.h"
-#include <ldns/wire2host.h>
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#include <sys/time.h>
+#include <sys/types.h>
#include "daemon/stats.h"
#include "daemon/worker.h"
#include "daemon/daemon.h"
@@ -51,6 +55,7 @@
#include "util/timehist.h"
#include "util/net_help.h"
#include "validator/validator.h"
+#include "ldns/sbuffer.h"
/** add timers and the values do not overflow or become negative */
static void
@@ -257,14 +262,14 @@ void server_stats_insquery(struct server_stats* stats, struct comm_point* c,
uint16_t qtype, uint16_t qclass, struct edns_data* edns,
struct comm_reply* repinfo)
{
- uint16_t flags = ldns_buffer_read_u16_at(c->buffer, 2);
+ uint16_t flags = sldns_buffer_read_u16_at(c->buffer, 2);
if(qtype < STATS_QTYPE_NUM)
stats->qtype[qtype]++;
else stats->qtype_big++;
if(qclass < STATS_QCLASS_NUM)
stats->qclass[qclass]++;
else stats->qclass_big++;
- stats->qopcode[ LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) ]++;
+ stats->qopcode[ LDNS_OPCODE_WIRE(sldns_buffer_begin(c->buffer)) ]++;
if(c->type != comm_udp)
stats->qtcp++;
if(repinfo && addr_is_ip6(&repinfo->addr, repinfo->addrlen))
@@ -292,12 +297,12 @@ void server_stats_insquery(struct server_stats* stats, struct comm_point* c,
}
}
-void server_stats_insrcode(struct server_stats* stats, ldns_buffer* buf)
+void server_stats_insrcode(struct server_stats* stats, sldns_buffer* buf)
{
- if(stats->extended && ldns_buffer_limit(buf) != 0) {
- int r = (int)LDNS_RCODE_WIRE( ldns_buffer_begin(buf) );
+ if(stats->extended && sldns_buffer_limit(buf) != 0) {
+ int r = (int)LDNS_RCODE_WIRE( sldns_buffer_begin(buf) );
stats->ans_rcode[r] ++;
- if(r == 0 && LDNS_ANCOUNT( ldns_buffer_begin(buf) ) == 0)
+ if(r == 0 && LDNS_ANCOUNT( sldns_buffer_begin(buf) ) == 0)
stats->ans_rcode_nodata ++;
}
}
diff --git a/contrib/unbound/daemon/stats.h b/contrib/unbound/daemon/stats.h
index c0fc1cc..7c31551 100644
--- a/contrib/unbound/daemon/stats.h
+++ b/contrib/unbound/daemon/stats.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -43,12 +43,12 @@
#ifndef DAEMON_STATS_H
#define DAEMON_STATS_H
#include "util/timehist.h"
-#include <ldns/buffer.h>
struct worker;
struct config_file;
struct comm_point;
struct comm_reply;
struct edns_data;
+struct sldns_buffer;
/** number of qtype that is stored for in array */
#define STATS_QTYPE_NUM 256
@@ -230,6 +230,6 @@ void server_stats_insquery(struct server_stats* stats, struct comm_point* c,
* @param stats: the stats
* @param buf: buffer with rcode. If buffer is length0: not counted.
*/
-void server_stats_insrcode(struct server_stats* stats, ldns_buffer* buf);
+void server_stats_insrcode(struct server_stats* stats, struct sldns_buffer* buf);
#endif /* DAEMON_STATS_H */
diff --git a/contrib/unbound/daemon/unbound.c b/contrib/unbound/daemon/unbound.c
index 6539b9e..716fbce 100644
--- a/contrib/unbound/daemon/unbound.c
+++ b/contrib/unbound/daemon/unbound.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
@@ -67,9 +67,12 @@
#include <grp.h>
#endif
+#ifndef S_SPLINT_S
+/* splint chokes on this system header file */
#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
+#endif /* S_SPLINT_S */
#ifdef HAVE_LOGIN_CAP_H
#include <login_cap.h>
#endif
@@ -165,8 +168,8 @@ static void usage()
#endif
printf("Version %s\n", PACKAGE_VERSION);
get_event_sys(&evnm, &evsys, &evmethod);
- printf("linked libs: %s %s (it uses %s), ldns %s, %s\n",
- evnm, evsys, evmethod, ldns_version(),
+ printf("linked libs: %s %s (it uses %s), %s\n",
+ evnm, evsys, evmethod,
#ifdef HAVE_SSL
SSLeay_version(SSLEAY_VERSION)
#elif defined(HAVE_NSS)
@@ -193,6 +196,7 @@ int replay_var_compare(const void* ATTR_UNUSED(a), const void* ATTR_UNUSED(b))
static void
checkrlimits(struct config_file* cfg)
{
+#ifndef S_SPLINT_S
#ifdef HAVE_GETRLIMIT
/* list has number of ports to listen to, ifs number addresses */
int list = ((cfg->do_udp?1:0) + (cfg->do_tcp?1 +
@@ -283,6 +287,7 @@ checkrlimits(struct config_file* cfg)
#else
(void)cfg;
#endif /* HAVE_GETRLIMIT */
+#endif /* S_SPLINT_S */
}
/** set verbosity, check rlimits, cache settings */
@@ -522,7 +527,7 @@ perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode,
/* setusercontext does initgroups, setuid, setgid, and
* also resource limits from login config, but we
* still call setresuid, setresgid to be sure to set all uid*/
- if(setusercontext(NULL, pwd, uid,
+ if(setusercontext(NULL, pwd, uid, (unsigned)
LOGIN_SETALL & ~LOGIN_SETUSER & ~LOGIN_SETGROUP) != 0)
log_warn("unable to setusercontext %s: %s",
cfg->username, strerror(errno));
@@ -715,6 +720,7 @@ main(int argc, char* argv[])
#endif
log_init(NULL, 0, NULL);
+ log_ident_set(strrchr(argv[0],'/')?strrchr(argv[0],'/')+1:argv[0]);
/* parse the options */
while( (c=getopt(argc, argv, "c:dhvw:")) != -1) {
switch(c) {
diff --git a/contrib/unbound/daemon/worker.c b/contrib/unbound/daemon/worker.c
index 0e5b14d..ccc45f6 100644
--- a/contrib/unbound/daemon/worker.c
+++ b/contrib/unbound/daemon/worker.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,7 +40,6 @@
* pending requests.
*/
#include "config.h"
-#include <ldns/wire2host.h>
#include "util/log.h"
#include "util/net_help.h"
#include "util/random.h"
@@ -72,6 +71,7 @@
#include "validator/val_anchor.h"
#include "libunbound/context.h"
#include "libunbound/libworker.h"
+#include "ldns/sbuffer.h"
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
@@ -181,7 +181,7 @@ worker_mem_report(struct worker* ATTR_UNUSED(worker),
+ sizeof(worker->rndstate)
+ regional_get_mem(worker->scratchpad)
+ sizeof(*worker->env.scratch_buffer)
- + ldns_buffer_capacity(worker->env.scratch_buffer)
+ + sldns_buffer_capacity(worker->env.scratch_buffer)
+ forwards_get_mem(worker->env.fwds)
+ hints_get_mem(worker->env.hints);
if(worker->thread_num == 0)
@@ -243,10 +243,10 @@ worker_handle_reply(struct comm_point* c, void* arg, int error,
return 0;
}
/* sanity check. */
- if(!LDNS_QR_WIRE(ldns_buffer_begin(c->buffer))
- || LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) !=
+ if(!LDNS_QR_WIRE(sldns_buffer_begin(c->buffer))
+ || LDNS_OPCODE_WIRE(sldns_buffer_begin(c->buffer)) !=
LDNS_PACKET_QUERY
- || LDNS_QDCOUNT(ldns_buffer_begin(c->buffer)) > 1) {
+ || LDNS_QDCOUNT(sldns_buffer_begin(c->buffer)) > 1) {
/* error becomes timeout for the module as if this reply
* never arrived. */
mesh_report_reply(worker->env.mesh, &e, reply_info,
@@ -274,10 +274,10 @@ worker_handle_service_reply(struct comm_point* c, void* arg, int error,
return 0;
}
/* sanity check. */
- if(!LDNS_QR_WIRE(ldns_buffer_begin(c->buffer))
- || LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) !=
+ if(!LDNS_QR_WIRE(sldns_buffer_begin(c->buffer))
+ || LDNS_OPCODE_WIRE(sldns_buffer_begin(c->buffer)) !=
LDNS_PACKET_QUERY
- || LDNS_QDCOUNT(ldns_buffer_begin(c->buffer)) > 1) {
+ || LDNS_QDCOUNT(sldns_buffer_begin(c->buffer)) > 1) {
/* error becomes timeout for the module as if this reply
* never arrived. */
verbose(VERB_ALGO, "worker: bad reply handled as timeout");
@@ -297,49 +297,49 @@ worker_handle_service_reply(struct comm_point* c, void* arg, int error,
* @return error code, 0 OK, or -1 discard.
*/
static int
-worker_check_request(ldns_buffer* pkt, struct worker* worker)
+worker_check_request(sldns_buffer* pkt, struct worker* worker)
{
- if(ldns_buffer_limit(pkt) < LDNS_HEADER_SIZE) {
+ if(sldns_buffer_limit(pkt) < LDNS_HEADER_SIZE) {
verbose(VERB_QUERY, "request too short, discarded");
return -1;
}
- if(ldns_buffer_limit(pkt) > NORMAL_UDP_SIZE &&
+ if(sldns_buffer_limit(pkt) > NORMAL_UDP_SIZE &&
worker->daemon->cfg->harden_large_queries) {
verbose(VERB_QUERY, "request too large, discarded");
return -1;
}
- if(LDNS_QR_WIRE(ldns_buffer_begin(pkt))) {
+ if(LDNS_QR_WIRE(sldns_buffer_begin(pkt))) {
verbose(VERB_QUERY, "request has QR bit on, discarded");
return -1;
}
- if(LDNS_TC_WIRE(ldns_buffer_begin(pkt))) {
- LDNS_TC_CLR(ldns_buffer_begin(pkt));
+ if(LDNS_TC_WIRE(sldns_buffer_begin(pkt))) {
+ LDNS_TC_CLR(sldns_buffer_begin(pkt));
verbose(VERB_QUERY, "request bad, has TC bit on");
return LDNS_RCODE_FORMERR;
}
- if(LDNS_OPCODE_WIRE(ldns_buffer_begin(pkt)) != LDNS_PACKET_QUERY) {
+ if(LDNS_OPCODE_WIRE(sldns_buffer_begin(pkt)) != LDNS_PACKET_QUERY) {
verbose(VERB_QUERY, "request unknown opcode %d",
- LDNS_OPCODE_WIRE(ldns_buffer_begin(pkt)));
+ LDNS_OPCODE_WIRE(sldns_buffer_begin(pkt)));
return LDNS_RCODE_NOTIMPL;
}
- if(LDNS_QDCOUNT(ldns_buffer_begin(pkt)) != 1) {
+ if(LDNS_QDCOUNT(sldns_buffer_begin(pkt)) != 1) {
verbose(VERB_QUERY, "request wrong nr qd=%d",
- LDNS_QDCOUNT(ldns_buffer_begin(pkt)));
+ LDNS_QDCOUNT(sldns_buffer_begin(pkt)));
return LDNS_RCODE_FORMERR;
}
- if(LDNS_ANCOUNT(ldns_buffer_begin(pkt)) != 0) {
+ if(LDNS_ANCOUNT(sldns_buffer_begin(pkt)) != 0) {
verbose(VERB_QUERY, "request wrong nr an=%d",
- LDNS_ANCOUNT(ldns_buffer_begin(pkt)));
+ LDNS_ANCOUNT(sldns_buffer_begin(pkt)));
return LDNS_RCODE_FORMERR;
}
- if(LDNS_NSCOUNT(ldns_buffer_begin(pkt)) != 0) {
+ if(LDNS_NSCOUNT(sldns_buffer_begin(pkt)) != 0) {
verbose(VERB_QUERY, "request wrong nr ns=%d",
- LDNS_NSCOUNT(ldns_buffer_begin(pkt)));
+ LDNS_NSCOUNT(sldns_buffer_begin(pkt)));
return LDNS_RCODE_FORMERR;
}
- if(LDNS_ARCOUNT(ldns_buffer_begin(pkt)) > 1) {
+ if(LDNS_ARCOUNT(sldns_buffer_begin(pkt)) > 1) {
verbose(VERB_QUERY, "request wrong nr ar=%d",
- LDNS_ARCOUNT(ldns_buffer_begin(pkt)));
+ LDNS_ARCOUNT(sldns_buffer_begin(pkt)));
return LDNS_RCODE_FORMERR;
}
return 0;
@@ -361,7 +361,7 @@ worker_handle_control_cmd(struct tube* ATTR_UNUSED(tube), uint8_t* msg,
if(len != sizeof(uint32_t)) {
fatal_exit("bad control msg length %d", (int)len);
}
- cmd = ldns_read_uint32(msg);
+ cmd = sldns_read_uint32(msg);
free(msg);
switch(cmd) {
case worker_cmd_quit:
@@ -451,7 +451,7 @@ answer_norec_from_cache(struct worker* worker, struct query_info* qinfo,
*/
uint16_t udpsize = edns->udp_size;
int secure = 0;
- uint32_t timenow = *worker->env.now;
+ time_t timenow = *worker->env.now;
int must_validate = (!(flags&BIT_CD) || worker->env.cfg->ignore_cd)
&& worker->env.need_to_validate;
struct dns_msg *msg = NULL;
@@ -526,7 +526,7 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo,
struct reply_info* rep, uint16_t id, uint16_t flags,
struct comm_reply* repinfo, struct edns_data* edns)
{
- uint32_t timenow = *worker->env.now;
+ time_t timenow = *worker->env.now;
uint16_t udpsize = edns->udp_size;
int secure;
int must_validate = (!(flags&BIT_CD) || worker->env.cfg->ignore_cd)
@@ -616,7 +616,7 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo,
/** Reply to client and perform prefetch to keep cache up to date */
static void
reply_and_prefetch(struct worker* worker, struct query_info* qinfo,
- uint16_t flags, struct comm_reply* repinfo, uint32_t leeway)
+ uint16_t flags, struct comm_reply* repinfo, time_t leeway)
{
/* first send answer to client to keep its latency
* as small as a cachereply */
@@ -638,32 +638,32 @@ reply_and_prefetch(struct worker* worker, struct query_info* qinfo,
* @param edns: edns reply information.
*/
static void
-chaos_replystr(ldns_buffer* pkt, const char* str, struct edns_data* edns)
+chaos_replystr(sldns_buffer* pkt, const char* str, struct edns_data* edns)
{
size_t len = strlen(str);
- unsigned int rd = LDNS_RD_WIRE(ldns_buffer_begin(pkt));
- unsigned int cd = LDNS_CD_WIRE(ldns_buffer_begin(pkt));
+ unsigned int rd = LDNS_RD_WIRE(sldns_buffer_begin(pkt));
+ unsigned int cd = LDNS_CD_WIRE(sldns_buffer_begin(pkt));
if(len>255) len=255; /* cap size of TXT record */
- ldns_buffer_clear(pkt);
- ldns_buffer_skip(pkt, (ssize_t)sizeof(uint16_t)); /* skip id */
- ldns_buffer_write_u16(pkt, (uint16_t)(BIT_QR|BIT_RA));
- if(rd) LDNS_RD_SET(ldns_buffer_begin(pkt));
- if(cd) LDNS_CD_SET(ldns_buffer_begin(pkt));
- ldns_buffer_write_u16(pkt, 1); /* qdcount */
- ldns_buffer_write_u16(pkt, 1); /* ancount */
- ldns_buffer_write_u16(pkt, 0); /* nscount */
- ldns_buffer_write_u16(pkt, 0); /* arcount */
+ sldns_buffer_clear(pkt);
+ sldns_buffer_skip(pkt, (ssize_t)sizeof(uint16_t)); /* skip id */
+ sldns_buffer_write_u16(pkt, (uint16_t)(BIT_QR|BIT_RA));
+ if(rd) LDNS_RD_SET(sldns_buffer_begin(pkt));
+ if(cd) LDNS_CD_SET(sldns_buffer_begin(pkt));
+ sldns_buffer_write_u16(pkt, 1); /* qdcount */
+ sldns_buffer_write_u16(pkt, 1); /* ancount */
+ sldns_buffer_write_u16(pkt, 0); /* nscount */
+ sldns_buffer_write_u16(pkt, 0); /* arcount */
(void)query_dname_len(pkt); /* skip qname */
- ldns_buffer_skip(pkt, (ssize_t)sizeof(uint16_t)); /* skip qtype */
- ldns_buffer_skip(pkt, (ssize_t)sizeof(uint16_t)); /* skip qclass */
- ldns_buffer_write_u16(pkt, 0xc00c); /* compr ptr to query */
- ldns_buffer_write_u16(pkt, LDNS_RR_TYPE_TXT);
- ldns_buffer_write_u16(pkt, LDNS_RR_CLASS_CH);
- ldns_buffer_write_u32(pkt, 0); /* TTL */
- ldns_buffer_write_u16(pkt, sizeof(uint8_t) + len);
- ldns_buffer_write_u8(pkt, len);
- ldns_buffer_write(pkt, str, len);
- ldns_buffer_flip(pkt);
+ sldns_buffer_skip(pkt, (ssize_t)sizeof(uint16_t)); /* skip qtype */
+ sldns_buffer_skip(pkt, (ssize_t)sizeof(uint16_t)); /* skip qclass */
+ sldns_buffer_write_u16(pkt, 0xc00c); /* compr ptr to query */
+ sldns_buffer_write_u16(pkt, LDNS_RR_TYPE_TXT);
+ sldns_buffer_write_u16(pkt, LDNS_RR_CLASS_CH);
+ sldns_buffer_write_u32(pkt, 0); /* TTL */
+ sldns_buffer_write_u16(pkt, sizeof(uint8_t) + len);
+ sldns_buffer_write_u8(pkt, len);
+ sldns_buffer_write(pkt, str, len);
+ sldns_buffer_flip(pkt);
edns->edns_version = EDNS_ADVERTISED_VERSION;
edns->udp_size = EDNS_ADVERTISED_SIZE;
edns->bits &= EDNS_DO;
@@ -680,7 +680,7 @@ chaos_replystr(ldns_buffer* pkt, const char* str, struct edns_data* edns)
*/
static int
answer_chaos(struct worker* w, struct query_info* qinfo,
- struct edns_data* edns, ldns_buffer* pkt)
+ struct edns_data* edns, sldns_buffer* pkt)
{
struct config_file* cfg = w->env.cfg;
if(qinfo->qtype != LDNS_RR_TYPE_ANY && qinfo->qtype != LDNS_RR_TYPE_TXT)
@@ -720,6 +720,52 @@ answer_chaos(struct worker* w, struct query_info* qinfo,
return 0;
}
+static int
+deny_refuse(struct comm_point* c, enum acl_access acl,
+ enum acl_access deny, enum acl_access refuse,
+ struct worker* worker, struct comm_reply* repinfo)
+{
+ if(acl == deny) {
+ comm_point_drop_reply(repinfo);
+ if(worker->stats.extended)
+ worker->stats.unwanted_queries++;
+ return 0;
+ } else if(acl == refuse) {
+ log_addr(VERB_ALGO, "refused query from",
+ &repinfo->addr, repinfo->addrlen);
+ log_buf(VERB_ALGO, "refuse", c->buffer);
+ if(worker->stats.extended)
+ worker->stats.unwanted_queries++;
+ if(worker_check_request(c->buffer, worker) == -1) {
+ comm_point_drop_reply(repinfo);
+ return 0; /* discard this */
+ }
+ sldns_buffer_set_limit(c->buffer, LDNS_HEADER_SIZE);
+ sldns_buffer_write_at(c->buffer, 4,
+ (uint8_t*)"\0\0\0\0\0\0\0\0", 8);
+ LDNS_QR_SET(sldns_buffer_begin(c->buffer));
+ LDNS_RCODE_SET(sldns_buffer_begin(c->buffer),
+ LDNS_RCODE_REFUSED);
+ return 1;
+ }
+
+ return -1;
+}
+
+static int
+deny_refuse_all(struct comm_point* c, enum acl_access acl,
+ struct worker* worker, struct comm_reply* repinfo)
+{
+ return deny_refuse(c, acl, acl_deny, acl_refuse, worker, repinfo);
+}
+
+static int
+deny_refuse_non_local(struct comm_point* c, enum acl_access acl,
+ struct worker* worker, struct comm_reply* repinfo)
+{
+ return deny_refuse(c, acl, acl_deny_non_local, acl_refuse_non_local, worker, repinfo);
+}
+
int
worker_handle_request(struct comm_point* c, void* arg, int error,
struct comm_reply* repinfo)
@@ -739,35 +785,16 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
}
acl = acl_list_lookup(worker->daemon->acl, &repinfo->addr,
repinfo->addrlen);
- if(acl == acl_deny) {
- comm_point_drop_reply(repinfo);
- if(worker->stats.extended)
- worker->stats.unwanted_queries++;
- return 0;
- } else if(acl == acl_refuse) {
- log_addr(VERB_ALGO, "refused query from",
- &repinfo->addr, repinfo->addrlen);
- log_buf(VERB_ALGO, "refuse", c->buffer);
- if(worker->stats.extended)
- worker->stats.unwanted_queries++;
- if(worker_check_request(c->buffer, worker) == -1) {
- comm_point_drop_reply(repinfo);
- return 0; /* discard this */
- }
- ldns_buffer_set_limit(c->buffer, LDNS_HEADER_SIZE);
- ldns_buffer_write_at(c->buffer, 4,
- (uint8_t*)"\0\0\0\0\0\0\0\0", 8);
- LDNS_QR_SET(ldns_buffer_begin(c->buffer));
- LDNS_RCODE_SET(ldns_buffer_begin(c->buffer),
- LDNS_RCODE_REFUSED);
- return 1;
+ if((ret=deny_refuse_all(c, acl, worker, repinfo)) != -1)
+ {
+ return ret;
}
if((ret=worker_check_request(c->buffer, worker)) != 0) {
verbose(VERB_ALGO, "worker check request: bad query.");
log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen);
if(ret != -1) {
- LDNS_QR_SET(ldns_buffer_begin(c->buffer));
- LDNS_RCODE_SET(ldns_buffer_begin(c->buffer), ret);
+ LDNS_QR_SET(sldns_buffer_begin(c->buffer));
+ LDNS_RCODE_SET(sldns_buffer_begin(c->buffer), ret);
return 1;
}
comm_point_drop_reply(repinfo);
@@ -778,9 +805,9 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
if(!query_info_parse(&qinfo, c->buffer)) {
verbose(VERB_ALGO, "worker parse request: formerror.");
log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen);
- ldns_buffer_rewind(c->buffer);
- LDNS_QR_SET(ldns_buffer_begin(c->buffer));
- LDNS_RCODE_SET(ldns_buffer_begin(c->buffer),
+ sldns_buffer_rewind(c->buffer);
+ LDNS_QR_SET(sldns_buffer_begin(c->buffer));
+ LDNS_RCODE_SET(sldns_buffer_begin(c->buffer),
LDNS_RCODE_FORMERR);
server_stats_insrcode(&worker->stats, c->buffer);
return 1;
@@ -794,9 +821,9 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
qinfo.qtype == LDNS_RR_TYPE_IXFR) {
verbose(VERB_ALGO, "worker request: refused zone transfer.");
log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen);
- ldns_buffer_rewind(c->buffer);
- LDNS_QR_SET(ldns_buffer_begin(c->buffer));
- LDNS_RCODE_SET(ldns_buffer_begin(c->buffer),
+ sldns_buffer_rewind(c->buffer);
+ LDNS_QR_SET(sldns_buffer_begin(c->buffer));
+ LDNS_RCODE_SET(sldns_buffer_begin(c->buffer),
LDNS_RCODE_REFUSED);
if(worker->stats.extended) {
worker->stats.qtype[qinfo.qtype]++;
@@ -807,9 +834,9 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
if((ret=parse_edns_from_pkt(c->buffer, &edns)) != 0) {
verbose(VERB_ALGO, "worker parse edns: formerror.");
log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen);
- ldns_buffer_rewind(c->buffer);
- LDNS_QR_SET(ldns_buffer_begin(c->buffer));
- LDNS_RCODE_SET(ldns_buffer_begin(c->buffer), ret);
+ sldns_buffer_rewind(c->buffer);
+ LDNS_QR_SET(sldns_buffer_begin(c->buffer));
+ LDNS_RCODE_SET(sldns_buffer_begin(c->buffer), ret);
server_stats_insrcode(&worker->stats, c->buffer);
return 1;
}
@@ -821,8 +848,8 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
verbose(VERB_ALGO, "query with bad edns version.");
log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen);
error_encode(c->buffer, EDNS_RCODE_BADVERS&0xf, &qinfo,
- *(uint16_t*)(void *)ldns_buffer_begin(c->buffer),
- ldns_buffer_read_u16_at(c->buffer, 2), NULL);
+ *(uint16_t*)(void *)sldns_buffer_begin(c->buffer),
+ sldns_buffer_read_u16_at(c->buffer, 2), NULL);
attach_edns_record(c->buffer, &edns);
return 1;
}
@@ -833,17 +860,25 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen);
edns.udp_size = NORMAL_UDP_SIZE;
}
- if(edns.edns_present && edns.udp_size < LDNS_HEADER_SIZE) {
+ if(edns.udp_size > worker->daemon->cfg->max_udp_size &&
+ c->type == comm_udp) {
+ verbose(VERB_QUERY,
+ "worker request: max UDP reply size modified"
+ " (%d to max-udp-size)", (int)edns.udp_size);
+ log_addr(VERB_CLIENT,"from",&repinfo->addr, repinfo->addrlen);
+ edns.udp_size = worker->daemon->cfg->max_udp_size;
+ }
+ if(edns.udp_size < LDNS_HEADER_SIZE) {
verbose(VERB_ALGO, "worker request: edns is too small.");
log_addr(VERB_CLIENT, "from", &repinfo->addr, repinfo->addrlen);
- LDNS_QR_SET(ldns_buffer_begin(c->buffer));
- LDNS_TC_SET(ldns_buffer_begin(c->buffer));
- LDNS_RCODE_SET(ldns_buffer_begin(c->buffer),
+ LDNS_QR_SET(sldns_buffer_begin(c->buffer));
+ LDNS_TC_SET(sldns_buffer_begin(c->buffer));
+ LDNS_RCODE_SET(sldns_buffer_begin(c->buffer),
LDNS_RCODE_SERVFAIL);
- ldns_buffer_set_position(c->buffer, LDNS_HEADER_SIZE);
- ldns_buffer_write_at(c->buffer, 4,
+ sldns_buffer_set_position(c->buffer, LDNS_HEADER_SIZE);
+ sldns_buffer_write_at(c->buffer, 4,
(uint8_t*)"\0\0\0\0\0\0\0\0", 8);
- ldns_buffer_flip(c->buffer);
+ sldns_buffer_flip(c->buffer);
return 1;
}
if(worker->stats.extended)
@@ -859,22 +894,32 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
if(local_zones_answer(worker->daemon->local_zones, &qinfo, &edns,
c->buffer, worker->scratchpad)) {
regional_free_all(worker->scratchpad);
- if(ldns_buffer_limit(c->buffer) == 0) {
+ if(sldns_buffer_limit(c->buffer) == 0) {
comm_point_drop_reply(repinfo);
return 0;
}
server_stats_insrcode(&worker->stats, c->buffer);
return 1;
}
- if(!(LDNS_RD_WIRE(ldns_buffer_begin(c->buffer))) &&
+
+ /* We've looked in our local zones. If the answer isn't there, we
+ * might need to bail out based on ACLs now. */
+ if((ret=deny_refuse_non_local(c, acl, worker, repinfo)) != -1)
+ {
+ return ret;
+ }
+
+ /* If this request does not have the recursion bit set, verify
+ * ACLs allow the snooping. */
+ if(!(LDNS_RD_WIRE(sldns_buffer_begin(c->buffer))) &&
acl != acl_allow_snoop ) {
- ldns_buffer_set_limit(c->buffer, LDNS_HEADER_SIZE);
- ldns_buffer_write_at(c->buffer, 4,
+ sldns_buffer_set_limit(c->buffer, LDNS_HEADER_SIZE);
+ sldns_buffer_write_at(c->buffer, 4,
(uint8_t*)"\0\0\0\0\0\0\0\0", 8);
- LDNS_QR_SET(ldns_buffer_begin(c->buffer));
- LDNS_RCODE_SET(ldns_buffer_begin(c->buffer),
+ LDNS_QR_SET(sldns_buffer_begin(c->buffer));
+ LDNS_RCODE_SET(sldns_buffer_begin(c->buffer),
LDNS_RCODE_REFUSED);
- ldns_buffer_flip(c->buffer);
+ sldns_buffer_flip(c->buffer);
server_stats_insrcode(&worker->stats, c->buffer);
log_addr(VERB_ALGO, "refused nonrec (cache snoop) query from",
&repinfo->addr, repinfo->addrlen);
@@ -885,17 +930,17 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
/* answer from cache - we have acquired a readlock on it */
if(answer_from_cache(worker, &qinfo,
(struct reply_info*)e->data,
- *(uint16_t*)(void *)ldns_buffer_begin(c->buffer),
- ldns_buffer_read_u16_at(c->buffer, 2), repinfo,
+ *(uint16_t*)(void *)sldns_buffer_begin(c->buffer),
+ sldns_buffer_read_u16_at(c->buffer, 2), repinfo,
&edns)) {
/* prefetch it if the prefetch TTL expired */
if(worker->env.cfg->prefetch && *worker->env.now >=
((struct reply_info*)e->data)->prefetch_ttl) {
- uint32_t leeway = ((struct reply_info*)e->
+ time_t leeway = ((struct reply_info*)e->
data)->ttl - *worker->env.now;
lock_rw_unlock(&e->lock);
reply_and_prefetch(worker, &qinfo,
- ldns_buffer_read_u16_at(c->buffer, 2),
+ sldns_buffer_read_u16_at(c->buffer, 2),
repinfo, leeway);
return 0;
}
@@ -905,17 +950,17 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
verbose(VERB_ALGO, "answer from the cache failed");
lock_rw_unlock(&e->lock);
}
- if(!LDNS_RD_WIRE(ldns_buffer_begin(c->buffer))) {
+ if(!LDNS_RD_WIRE(sldns_buffer_begin(c->buffer))) {
if(answer_norec_from_cache(worker, &qinfo,
- *(uint16_t*)(void *)ldns_buffer_begin(c->buffer),
- ldns_buffer_read_u16_at(c->buffer, 2), repinfo,
+ *(uint16_t*)(void *)sldns_buffer_begin(c->buffer),
+ sldns_buffer_read_u16_at(c->buffer, 2), repinfo,
&edns)) {
return 1;
}
verbose(VERB_ALGO, "answer norec from cache -- "
"need to validate or not primed");
}
- ldns_buffer_rewind(c->buffer);
+ sldns_buffer_rewind(c->buffer);
server_stats_querymiss(&worker->stats, worker);
if(verbosity >= VERB_CLIENT) {
@@ -928,8 +973,8 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
/* grab a work request structure for this new request */
mesh_new_client(worker->env.mesh, &qinfo,
- ldns_buffer_read_u16_at(c->buffer, 2), &edns, repinfo,
- *(uint16_t*)(void *)ldns_buffer_begin(c->buffer));
+ sldns_buffer_read_u16_at(c->buffer, 2),
+ &edns, repinfo, *(uint16_t*)(void *)sldns_buffer_begin(c->buffer));
worker_mem_report(worker, NULL);
return 0;
}
@@ -1113,7 +1158,7 @@ worker_init(struct worker* worker, struct config_file *cfg,
worker->daemon->env->infra_cache, worker->rndstate,
cfg->use_caps_bits_for_id, worker->ports, worker->numports,
cfg->unwanted_threshold, &worker_alloc_cleanup, worker,
- cfg->do_udp, worker->daemon->connect_sslctx);
+ cfg->do_udp, worker->daemon->connect_sslctx, cfg->delay_close);
if(!worker->back) {
log_err("could not create outgoing sockets");
worker_delete(worker);
@@ -1159,7 +1204,7 @@ worker_init(struct worker* worker, struct config_file *cfg,
worker->env.attach_sub = &mesh_attach_sub;
worker->env.kill_sub = &mesh_state_delete;
worker->env.detect_cycle = &mesh_detect_cycle;
- worker->env.scratch_buffer = ldns_buffer_new(cfg->msg_buffer_size);
+ worker->env.scratch_buffer = sldns_buffer_new(cfg->msg_buffer_size);
if(!(worker->env.fwds = forwards_create()) ||
!forwards_apply_cfg(worker->env.fwds, cfg)) {
log_err("Could not set forward zones");
@@ -1222,7 +1267,7 @@ worker_delete(struct worker* worker)
}
outside_network_quit_prepare(worker->back);
mesh_delete(worker->env.mesh);
- ldns_buffer_free(worker->env.scratch_buffer);
+ sldns_buffer_free(worker->env.scratch_buffer);
forwards_delete(worker->env.fwds);
hints_delete(worker->env.hints);
listen_delete(worker->front);
@@ -1336,14 +1381,21 @@ void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
}
void libworker_fg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
- ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
+ sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
char* ATTR_UNUSED(why_bogus))
{
log_assert(0);
}
void libworker_bg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
- ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
+ sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
+ char* ATTR_UNUSED(why_bogus))
+{
+ log_assert(0);
+}
+
+void libworker_event_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
+ sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
char* ATTR_UNUSED(why_bogus))
{
log_assert(0);
diff --git a/contrib/unbound/daemon/worker.h b/contrib/unbound/daemon/worker.h
index f0e8cf0..83503ae 100644
--- a/contrib/unbound/daemon/worker.h
+++ b/contrib/unbound/daemon/worker.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/doc/Changelog b/contrib/unbound/doc/Changelog
index 346f02a..55650ae 100644
--- a/contrib/unbound/doc/Changelog
+++ b/contrib/unbound/doc/Changelog
@@ -1,5 +1,316 @@
+12 March 2014: Wouter
+ - tag 1.4.22
+
+10 March 2014: Wouter
+ - Fix bug#561: contrib/cacti plugin did not report SERVFAIL rcodes
+ because of spelling. Patch from Chris Coates.
+
+27 February 2014: Wouter
+ - tag 1.4.22rc1
+
+21 February 2014: Wouter
+ - iana portlist updated.
+
+20 February 2014: Matthijs
+ - Be lenient when a NSEC NameError response with RCODE=NXDOMAIN is
+ received. This is okay according 4035, but not after revising
+ existence in 4592. NSEC empty non-terminals exist and thus the
+ RCODE should have been NOERROR. If this occurs, and the RRsets
+ are secure, we set the RCODE to NOERROR and the security status
+ of the reponse is also considered secure.
+
+14 February 2014: Wouter
+ - Works on Minix (3.2.1).
+
+11 February 2014: Wouter
+ - Fix parse of #553(NSD) string in sldns, quotes without spaces.
+
+7 February 2014: Wouter
+ - iana portlist updated.
+ - add body to ifstatement if locks disabled.
+ - add TXT string"string" test case to unit test.
+ - Fix #551: License change "Regents" to "Copyright holder", matching
+ the BSD license on opensource.org.
+
+6 February 2014: Wouter
+ - sldns has type HIP.
+ - code documentation on the module interface.
+
+5 February 2014: Wouter
+ - Fix sldns parse tests on osx.
+
+3 February 2014: Wouter
+ - Detect libevent2 install automatically by configure.
+ - Fixup link with lib/event2 subdir.
+ - Fix parse in sldns of quoted parenthesized text strings.
+
+31 January 2014: Wouter
+ - unit test for ldns wire to str and back with zones, root, nlnetlabs
+ and types.sidnlabs.
+ - Fix for hex to string in unknown, atma and nsap.
+ - fixup nss compile (no ldns in it).
+ - fixup warning in unitldns
+ - fixup WKS and rdata type service to print unsigned because strings
+ are not portable; they cannot be read (for sure) on other computers.
+ - fixup type EUI48 and EUI64, type APL and type IPSECKEY in string
+ parse sldns.
+
+30 January 2014: Wouter
+ - delay-close does not act if there are udp-wait queries, so that
+ it does not make a socketdrain DoS easier.
+
+28 January 2014: Wouter
+ - iana portlist updated.
+ - iana portlist test updated so it does not touch the source
+ if there are no changes.
+ - delay-close: msec option that delays closing ports for which
+ the UDP reply has timed out. Keeps the port open, only accepts
+ the correct reply. This correct reply is not used, but the port
+ is open so that no port-denied ICMPs are generated.
+
+27 January 2014: Wouter
+ - reuseport is attempted, then fallback to without on failure.
+
+24 January 2014: Wouter
+ - Change unbound-event.h to use void* buffer, length idiom.
+ - iana portlist updated.
+ - unbound-event.h is installed if you configure --enable-event-api.
+ - speed up unbound (reports say it could be up to 10%), by reducing
+ lock contention on localzones.lock. It is changed to an rwlock.
+ - so-reuseport: yesno option to distribute queries evenly over
+ threads on Linux (Thanks Robert Edmonds).
+ - made lint clean.
+
+21 January 2014: Wouter
+ - Fix #547: no trustanchor written if filesystem full, fclose checked.
+
+17 January 2014: Wouter
+ - Fix isprint() portability in sldns, uses unsigned int.
+ - iana portlist updated.
+
+16 January 2014: Wouter
+ - fix #544: Fixed +i causes segfault when running with module conf
+ "iterator".
+ - Windows port, adjust %lld to %I64d, and warning in win_event.c.
+
+14 January 2014: Wouter
+ - iana portlist updated.
+
+5 Dec 2013: Wouter
+ - Fix bug in cachedump that uses sldns.
+ - update pythonmod for ldns_ to sldns_ name change.
+
+3 Dec 2013: Wouter
+ - Fix sldns to use sldns_ prefix for all ldns_ variables.
+ - Fix windows compile to compile with sldns.
+
+30 Nov 2013: Wouter
+ - Fix sldns to make globals use sldns_ prefix. This fixes
+ linking with libldns that uses global variables ldns_ .
+
+13 Nov 2013: Wouter
+ - Fix bug#537: compile python plugin without ldns library.
+
+12 Nov 2013: Wouter
+ - Fix bug#536: acl_deny_non_local and refuse_non_local added.
+
+5 Nov 2013: Wouter
+ - Patch from Neel Goyal to fix async id assignment if callback
+ is called by libunbound in the mesh attach.
+ - Accept ip-address: as an alternative for interface: for
+ consistency with nsd.conf syntax.
+
+4 Nov 2013: Wouter
+ - Patch from Neel Goyal to fix callback in libunbound.
+
+3 Nov 2013: Wouter
+ - if configured --with-libunbound-only fix make install.
+
+31 Oct 2013: Wouter
+ - Fix #531: Set SO_REUSEADDR so that the wildcard interface and a
+ more specific interface port 53 can be used at the same time, and
+ one of the daemons is unbound.
+ - iana portlist update.
+ - separate ldns into core ldns inside ldns/ subdirectory. No more
+ --with-ldns is needed and unbound does not rely on libldns.
+ - portability fixes for new USE_SLDNS ldns subdir codebase.
+
+22 Oct 2013: Wouter
+ - Patch from Neel Goyal: Add an API call to set an event base on an
+ existing ub_ctx. This basically just destroys the current worker and
+ sets the event base to the current. And fix a deadlock in
+ ub_resolve_event – the cfglock is held when libworker_create is
+ called. This ends up trying to acquire the lock again in
+ context_obtain_alloc in the call chain.
+ - Fix #528: if very high logging (4 or more) segfault on allow_snoop.
+
+26 Sep 2013: Wouter
+ - unbound-event.h is installed if configured --with-libevent. It
+ contains low-level library calls, that use libevent's event_base
+ and an ldns_buffer for the wire return packet to perform async
+ resolution in the client's eventloop.
+
+19 Sep 2013: Wouter
+ - 1.4.21 tag created.
+ - trunk has 1.4.22 number inside it.
+ - iana portlist updated.
+ - acx_nlnetlabs.m4 to 26; improve FLTO help text.
+
+16 Sep 2013: Wouter
+ - Fix#524: max-udp-size not effective to non-EDNS0 queries, from
+ Daisuke HIGASHI.
+
+10 Sep 2013: Wouter
+ - MIN_TTL and MAX_TTL also in time_t.
+ - tag 1.4.21rc1 made again.
+
+26 Aug 2013: Wouter
+ - More fixes for bug#519: for the threaded case test if the bg
+ thread has been killed, on ub_ctx_delete, to avoid hangs.
+
+22 Aug 2013: Wouter
+ - more fixes that I overlooked.
+ - review fixes from Willem.
+
+21 Aug 2013: Wouter
+ - Fix#520: Errors found by static analysis from Tomas Hozza(redhat).
+
+20 Aug 2013: Wouter
+ - Fix for 2038, with time_t instead of uint32_t.
+
+19 Aug 2013: Wouter
+ - Fix#519 ub_ctx_delete may hang in some scenarios (libunbound).
+
+14 Aug 2013: Wouter
+ - Fix uninit variable in fix#516.
+
+8 Aug 2013: Wouter
+ - Fix#516 dnssec lameness detection for answers that are improper.
+
+30 Jun 2013: Wouter
+ - tag 1.4.21rc1
+
+29 Jun 2013: Wouter
+ - Fix#512 memleak in testcode for testbound (if it fails).
+ - Fix#512 NSS returned arrays out of setup function to be statics.
+
+26 Jun 2013: Wouter
+ - max include of 100.000 files (depth and globbed at one time).
+ This is to preserve system memory in bug cases, or endless cases.
+ - iana portlist updated.
+
+19 Jun 2013: Wouter
+ - streamtcp man page, contributed by Tomas Hozza.
+ - iana portlist updated.
+ - libunbound documentation on how to avoid openssl race conditions.
+
+25 Jun 2013: Wouter
+ - Squelch sendto-permission denied errors when the network is
+ not connected, to avoid spamming syslog.
+ - configure --disable-flto option (from Robert Edmonds).
+
+18 Jun 2013: Wouter
+ - Fix for const string literals in C++ for libunbound, from Karel
+ Slany.
+ - iana portlist updated.
+
+17 Jun 2013: Wouter
+ - Fixup manpage syntax.
+
+14 Jun 2013: Wouter
+ - get_option and set_option support for log-time-ascii, python-script
+ val-sig-skew-min and val-sig-skew-max. log-time-ascii takes effect
+ immediately. The others are mostly useful for libunbound users.
+
+13 Jun 2013: Wouter
+ - get_option, set_option, unbound-checkconf -o and libunbound
+ getoption and setoption support cache-min-ttl and cache-max-ttl.
+
+10 Jun 2013: Wouter
+ - Fix#501: forward-first does not recurse, when forward name is ".".
+ - iana portlist update.
+ - Max include depth is unlimited.
+
+27 May 2013: Wouter
+ - Update acx_pthreads.m4 to ax_pthreads.4 (2013-03-29), and apply
+ patch to it to not fail when -Werror is also specified, from the
+ autoconf-archives.
+ - iana portlist update.
+
+21 May 2013: Wouter
+ - Explain bogus and secure flags in libunbound more.
+
+16 May 2013: Wouter
+ - Fix#499 use-after-free in out-of-memory handling code (thanks Jake
+ Montgomery).
+ - Fix#500 use on non-initialised values on socket bind failures.
+
+15 May 2013: Wouter
+ - Fix round-robin doesn't work with some Windows clients (from Ilya
+ Bakulin).
+
+3 May 2013: Wouter
+ - update acx_nlnetlabs.m4 to v23, sleep w32 fix.
+
+26 April 2013: Wouter
+ - add unbound-control insecure_add and insecure_remove for the
+ administration of negative trust anchors.
+
+25 April 2013: Wouter
+ - Implement max-udp-size config option, default 4096 (thanks
+ Daisuke Higashi).
+ - Robust checks on dname validity from rdata for dname compare.
+ - updated iana portlist.
+
+19 April 2013: Wouter
+ - Fixup snprintf return value usage, fixed libunbound_get_option.
+
+18 April 2013: Wouter
+ - fix bug #491: pick program name (0th argument) as syslog identity.
+ - own implementation of compat/snprintf.c.
+
+15 April 2013: Wouter
+ - Fix so that for a configuration line of include: "*.conf" it is not
+ an error if there are no files matching the glob pattern.
+ - unbound-anchor review: BIO_write can return 0 successfully if it
+ has successfully appended a zero length string.
+
+11 April 2013: Wouter
+ - Fix queries leaking up for stubs and forwards, if the configured
+ nameservers all fail to answer.
+
+10 April 2013: Wouter
+ - code improve for minimal responses, small speed increase.
+
+9 April 2013: Wouter
+ - updated iana portlist.
+ - Fix crash in previous private address fixup of 22 March.
+
+28 March 2013: Wouter
+ - Make reverse zones easier by documenting the nodefault statements
+ commented-out in the example config file.
+
+26 March 2013: Wouter
+ - more fixes to lookup3.c endianness detection.
+
+25 March 2013: Wouter
+ - #492: Fix endianness detection, revert to older lookup3.c detection
+ and put new detect lines after previous tests, to avoid regressions
+ but allow new detections to succeed.
+ And add detection for machine/endian.h to it.
+
+22 March 2013: Wouter
+ - Fix resolve of names that use a mix of public and private addresses.
+ - iana portlist update.
+ - Fix makedist for new svn for -d option.
+ - unbound.h header file has UNBOUND_VERSION_MAJOR define.
+ - Fix windows RSRC version for long version numbers.
+
21 March 2013: Wouter
- release 1.4.20
+ - trunk has 1.4.21
+ - committed libunbound version 4:1:2 for binary API updated in 1.4.20
+ - install copy of unbound-control.8 man page for unbound-control-setup
14 March 2013: Wouter
- iana portlist update.
diff --git a/contrib/unbound/doc/FEATURES b/contrib/unbound/doc/FEATURES
index 93ed292..076988e 100644
--- a/contrib/unbound/doc/FEATURES
+++ b/contrib/unbound/doc/FEATURES
@@ -99,4 +99,5 @@ SSHFP type
4701: DHCID
5155: NSEC3, NSEC3PARAM
4408: SPF
+6944: DNSKEY algorithm status
diff --git a/contrib/unbound/doc/LICENSE b/contrib/unbound/doc/LICENSE
index c248049..1859c09 100644
--- a/contrib/unbound/doc/LICENSE
+++ b/contrib/unbound/doc/LICENSE
@@ -18,13 +18,13 @@ be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
-LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGE.
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/contrib/unbound/doc/README b/contrib/unbound/doc/README
index c8c69c1..badc60f 100644
--- a/contrib/unbound/doc/README
+++ b/contrib/unbound/doc/README
@@ -1,4 +1,4 @@
-README for Unbound 1.4.20
+README for Unbound 1.4.22
Copyright 2007 NLnet Labs
http://unbound.net
@@ -10,14 +10,11 @@ This software is under BSD license, see LICENSE for details.
http://unbound.net/svn/
* Uses the following libraries;
- * ldns http://www.nlnetlabs.nl/ldns/ (BSD license)
- (required) can use ldns build directory directly with --with-ldns=path.
* libevent http://www.monkey.org/~provos/libevent/ (BSD license)
(optional) can use builtin alternative instead.
+ * libexpat (for the unbound-anchor helper program) (MIT license)
* Make and install: ./configure; make; make install
- * --with-ldns=/path/to/ldns
- It will dynamically link against it.
* --with-libevent=/path/to/libevent
Can be set to either the system install or the build directory.
--with-libevent=no (default) gives a builtin alternative
@@ -36,8 +33,8 @@ This software is under BSD license, see LICENSE for details.
programming errors, among which buffer overflows. The program exits
with an error if an assertion fails (but the buffer did not overflow).
* --enable-static-exe
- This enables a debug option to statically link, against ldns and
- libevent libraries.
+ This enables a debug option to statically link against the
+ libevent library.
* --enable-lock-checks
This enables a debug option to check lock and unlock calls. It needs
a recent pthreads library to work.
diff --git a/contrib/unbound/doc/example.conf.in b/contrib/unbound/doc/example.conf.in
index aa9a7f7..9e91d1f 100644
--- a/contrib/unbound/doc/example.conf.in
+++ b/contrib/unbound/doc/example.conf.in
@@ -1,7 +1,7 @@
#
# Example configuration file.
#
-# See unbound.conf(5) man page, version 1.4.20.
+# See unbound.conf(5) man page, version 1.4.22.
#
# this is a comment.
@@ -84,11 +84,18 @@ server:
# buffer size for UDP port 53 outgoing (SO_SNDBUF socket option).
# 0 is system default. Use 4m to handle spikes on very busy servers.
# so-sndbuf: 0
+
+ # on Linux(3.9+) use SO_REUSEPORT to distribute queries over threads.
+ # so-reuseport: no
# EDNS reassembly buffer to advertise to UDP peers (the actual buffer
# is set with msg-buffer-size). 1480 can solve fragmentation (timeouts).
# edns-buffer-size: 4096
+ # Maximum UDP response size (not applied to TCP response).
+ # Suggested values are 512 to 4096. Default is 4096. 65536 disables it.
+ # max-udp-size: 4096
+
# buffer size for handling DNS data. No messages larger than this
# size can be sent or received, by UDP or TCP. In bytes.
# msg-buffer-size: 65552
@@ -107,6 +114,9 @@ server:
# if very busy, 50% queries run to completion, 50% get timeout in msec
# jostle-timeout: 200
+
+ # msec to wait before close of port on timeout UDP. 0 disables.
+ # delay-close: 0
# the amount of memory to use for the RRset cache.
# plain value in bytes or you can append k, m or G. default is "4Mb".
@@ -161,6 +171,8 @@ server:
# By default everything is refused, except for localhost.
# Choose deny (drop message), refuse (polite error reply),
# allow (recursive ok), allow_snoop (recursive and nonrecursive ok)
+ # deny_non_local (drop queries unless can be answered from local-data)
+ # refuse_non_local (like deny_non_local but polite error reply).
# access-control: 0.0.0.0/0 refuse
# access-control: 127.0.0.0/8 allow
# access-control: ::0/0 refuse
@@ -425,6 +437,54 @@ server:
# the amount of memory to use for the negative cache (used for DLV).
# plain value in bytes or you can append k, m or G. default is "1Mb".
# neg-cache-size: 1m
+
+ # if unbound is running service for the local host then it is useful
+ # to perform lan-wide lookups to the upstream, and unblock the
+ # long list of local-zones above. If this unbound is a dns server
+ # for a network of computers, disabled is better and stops information
+ # leakage of local lan information.
+ # unblock-lan-zones: no
+
+ # By default, for a number of zones a small default 'nothing here'
+ # reply is built-in. Query traffic is thus blocked. If you
+ # wish to serve such zone you can unblock them by uncommenting one
+ # of the nodefault statements below.
+ # You may also have to use domain-insecure: zone to make DNSSEC work,
+ # unless you have your own trust anchors for this zone.
+ # local-zone: "localhost." nodefault
+ # local-zone: "127.in-addr.arpa." nodefault
+ # local-zone: "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." nodefault
+ # local-zone: "10.in-addr.arpa." nodefault
+ # local-zone: "16.172.in-addr.arpa." nodefault
+ # local-zone: "17.172.in-addr.arpa." nodefault
+ # local-zone: "18.172.in-addr.arpa." nodefault
+ # local-zone: "19.172.in-addr.arpa." nodefault
+ # local-zone: "20.172.in-addr.arpa." nodefault
+ # local-zone: "21.172.in-addr.arpa." nodefault
+ # local-zone: "22.172.in-addr.arpa." nodefault
+ # local-zone: "23.172.in-addr.arpa." nodefault
+ # local-zone: "24.172.in-addr.arpa." nodefault
+ # local-zone: "25.172.in-addr.arpa." nodefault
+ # local-zone: "26.172.in-addr.arpa." nodefault
+ # local-zone: "27.172.in-addr.arpa." nodefault
+ # local-zone: "28.172.in-addr.arpa." nodefault
+ # local-zone: "29.172.in-addr.arpa." nodefault
+ # local-zone: "30.172.in-addr.arpa." nodefault
+ # local-zone: "31.172.in-addr.arpa." nodefault
+ # local-zone: "168.192.in-addr.arpa." nodefault
+ # local-zone: "0.in-addr.arpa." nodefault
+ # local-zone: "254.169.in-addr.arpa." nodefault
+ # local-zone: "2.0.192.in-addr.arpa." nodefault
+ # local-zone: "100.51.198.in-addr.arpa." nodefault
+ # local-zone: "113.0.203.in-addr.arpa." nodefault
+ # local-zone: "255.255.255.255.in-addr.arpa." nodefault
+ # local-zone: "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa." nodefault
+ # local-zone: "d.f.ip6.arpa." nodefault
+ # local-zone: "8.e.f.ip6.arpa." nodefault
+ # local-zone: "9.e.f.ip6.arpa." nodefault
+ # local-zone: "a.e.f.ip6.arpa." nodefault
+ # local-zone: "b.e.f.ip6.arpa." nodefault
+ # local-zone: "8.b.d.0.1.0.0.2.ip6.arpa." nodefault
# a number of locally served zones can be configured.
# local-zone: <zone> <type>
diff --git a/contrib/unbound/doc/libunbound.3 b/contrib/unbound/doc/libunbound.3
index 0f6f0c6..52c0a53 100644
--- a/contrib/unbound/doc/libunbound.3
+++ b/contrib/unbound/doc/libunbound.3
@@ -1,4 +1,4 @@
-.TH "libunbound" "3" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "libunbound" "3" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" libunbound.3 -- unbound library functions manual
.\"
@@ -42,7 +42,7 @@
.B ub_ctx_zone_remove,
.B ub_ctx_data_add,
.B ub_ctx_data_remove
-\- Unbound DNS validating resolver 1.4.20 functions.
+\- Unbound DNS validating resolver 1.4.22 functions.
.SH "SYNOPSIS"
.LP
.B #include <unbound.h>
@@ -171,6 +171,9 @@ by default. Use
and
.B ub_ctx_hosts
to read them.
+Before you call this, use the openssl functions CRYPTO_set_id_callback and
+CRYPTO_set_locking_callback to set up asyncronous operation if you use
+lib openssl (the application calls these functions once for initialisation).
.TP
.B ub_ctx_delete
Delete validation context and free associated resources.
@@ -364,7 +367,7 @@ The result of the DNS resolution and validation is returned as
.fi
.P
If both secure and bogus are false, security was not enabled for the
-domain of the query.
+domain of the query. Else, they are not both true, one of them is true.
.SH "RETURN VALUES"
Many routines return an error code. The value 0 (zero) denotes no error
happened. Other values can be passed to
diff --git a/contrib/unbound/doc/libunbound.3.in b/contrib/unbound/doc/libunbound.3.in
index 0f6f0c6..52c0a53 100644
--- a/contrib/unbound/doc/libunbound.3.in
+++ b/contrib/unbound/doc/libunbound.3.in
@@ -1,4 +1,4 @@
-.TH "libunbound" "3" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "libunbound" "3" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" libunbound.3 -- unbound library functions manual
.\"
@@ -42,7 +42,7 @@
.B ub_ctx_zone_remove,
.B ub_ctx_data_add,
.B ub_ctx_data_remove
-\- Unbound DNS validating resolver 1.4.20 functions.
+\- Unbound DNS validating resolver 1.4.22 functions.
.SH "SYNOPSIS"
.LP
.B #include <unbound.h>
@@ -171,6 +171,9 @@ by default. Use
and
.B ub_ctx_hosts
to read them.
+Before you call this, use the openssl functions CRYPTO_set_id_callback and
+CRYPTO_set_locking_callback to set up asyncronous operation if you use
+lib openssl (the application calls these functions once for initialisation).
.TP
.B ub_ctx_delete
Delete validation context and free associated resources.
@@ -364,7 +367,7 @@ The result of the DNS resolution and validation is returned as
.fi
.P
If both secure and bogus are false, security was not enabled for the
-domain of the query.
+domain of the query. Else, they are not both true, one of them is true.
.SH "RETURN VALUES"
Many routines return an error code. The value 0 (zero) denotes no error
happened. Other values can be passed to
diff --git a/contrib/unbound/doc/unbound-anchor.8 b/contrib/unbound/doc/unbound-anchor.8
index 4c9c6a7..27bb5a6 100644
--- a/contrib/unbound/doc/unbound-anchor.8
+++ b/contrib/unbound/doc/unbound-anchor.8
@@ -1,4 +1,4 @@
-.TH "unbound-anchor" "8" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound-anchor" "8" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound-anchor.8 -- unbound anchor maintenance utility manual
.\"
diff --git a/contrib/unbound/doc/unbound-anchor.8.in b/contrib/unbound/doc/unbound-anchor.8.in
index 0b5e5a0..41b18ed 100644
--- a/contrib/unbound/doc/unbound-anchor.8.in
+++ b/contrib/unbound/doc/unbound-anchor.8.in
@@ -1,4 +1,4 @@
-.TH "unbound-anchor" "8" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound-anchor" "8" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound-anchor.8 -- unbound anchor maintenance utility manual
.\"
diff --git a/contrib/unbound/doc/unbound-checkconf.8 b/contrib/unbound/doc/unbound-checkconf.8
index 768bda5..2ed6124 100644
--- a/contrib/unbound/doc/unbound-checkconf.8
+++ b/contrib/unbound/doc/unbound-checkconf.8
@@ -1,4 +1,4 @@
-.TH "unbound-checkconf" "8" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound-checkconf" "8" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound-checkconf.8 -- unbound configuration checker manual
.\"
diff --git a/contrib/unbound/doc/unbound-checkconf.8.in b/contrib/unbound/doc/unbound-checkconf.8.in
index 4ae174f..69e0b4f 100644
--- a/contrib/unbound/doc/unbound-checkconf.8.in
+++ b/contrib/unbound/doc/unbound-checkconf.8.in
@@ -1,4 +1,4 @@
-.TH "unbound-checkconf" "8" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound-checkconf" "8" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound-checkconf.8 -- unbound configuration checker manual
.\"
diff --git a/contrib/unbound/doc/unbound-control.8 b/contrib/unbound/doc/unbound-control.8
index 5b3559d..4f1a1cf 100644
--- a/contrib/unbound/doc/unbound-control.8
+++ b/contrib/unbound/doc/unbound-control.8
@@ -1,4 +1,4 @@
-.TH "unbound-control" "8" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound-control" "8" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound-control.8 -- unbound remote control manual
.\"
@@ -170,7 +170,7 @@ harden\-glue, harden\-dnssec\-stripped, harden\-below\-nxdomain,
harden\-referral\-path, prefetch, prefetch\-key, log\-queries,
hide\-identity, hide\-version, identity, version, val\-log\-level,
val\-log\-squelch, ignore\-cd\-flag, add\-holddown, del\-holddown,
-keep\-missing, tcp\-upstream, ssl\-upstream.
+keep\-missing, tcp\-upstream, ssl\-upstream, max\-udp\-size.
.TP
.B get_option \fIopt
Get the value of the option. Give the option name without a trailing ':'.
@@ -196,6 +196,14 @@ List the local zones in use. These are printed one per line with zone type.
.B list_local_data
List the local data RRs in use. The resource records are printed.
.TP
+.B insecure_add \fIzone
+Add a \fBdomain\-insecure\fR for the given zone, like the statement in unbound.conf.
+Adds to the running unbound without affecting the cache contents (which may
+still be bogus, use \fBflush_zone\fR to remove it), does not affect the config file.
+.TP
+.B insecure_remove \fIzone
+Removes domain\-insecure for the given zone.
+.TP
.B forward_add \fR[\fI+i\fR] \fIzone addr ...
Add a new forward zone to running unbound. With +i option also adds a
\fIdomain\-insecure\fR for the zone (so it can resolve insecurely if you have
diff --git a/contrib/unbound/doc/unbound-control.8.in b/contrib/unbound/doc/unbound-control.8.in
index 669e81d..e57231c 100644
--- a/contrib/unbound/doc/unbound-control.8.in
+++ b/contrib/unbound/doc/unbound-control.8.in
@@ -1,4 +1,4 @@
-.TH "unbound-control" "8" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound-control" "8" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound-control.8 -- unbound remote control manual
.\"
@@ -170,7 +170,7 @@ harden\-glue, harden\-dnssec\-stripped, harden\-below\-nxdomain,
harden\-referral\-path, prefetch, prefetch\-key, log\-queries,
hide\-identity, hide\-version, identity, version, val\-log\-level,
val\-log\-squelch, ignore\-cd\-flag, add\-holddown, del\-holddown,
-keep\-missing, tcp\-upstream, ssl\-upstream.
+keep\-missing, tcp\-upstream, ssl\-upstream, max\-udp\-size.
.TP
.B get_option \fIopt
Get the value of the option. Give the option name without a trailing ':'.
@@ -196,6 +196,14 @@ List the local zones in use. These are printed one per line with zone type.
.B list_local_data
List the local data RRs in use. The resource records are printed.
.TP
+.B insecure_add \fIzone
+Add a \fBdomain\-insecure\fR for the given zone, like the statement in unbound.conf.
+Adds to the running unbound without affecting the cache contents (which may
+still be bogus, use \fBflush_zone\fR to remove it), does not affect the config file.
+.TP
+.B insecure_remove \fIzone
+Removes domain\-insecure for the given zone.
+.TP
.B forward_add \fR[\fI+i\fR] \fIzone addr ...
Add a new forward zone to running unbound. With +i option also adds a
\fIdomain\-insecure\fR for the zone (so it can resolve insecurely if you have
diff --git a/contrib/unbound/doc/unbound-host.1 b/contrib/unbound/doc/unbound-host.1
index 4957705..1c8c42d 100644
--- a/contrib/unbound/doc/unbound-host.1
+++ b/contrib/unbound/doc/unbound-host.1
@@ -1,4 +1,4 @@
-.TH "unbound\-host" "1" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound\-host" "1" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound-host.1 -- unbound DNS lookup utility
.\"
diff --git a/contrib/unbound/doc/unbound.8 b/contrib/unbound/doc/unbound.8
index 09fcc6a..9c04538 100644
--- a/contrib/unbound/doc/unbound.8
+++ b/contrib/unbound/doc/unbound.8
@@ -1,4 +1,4 @@
-.TH "unbound" "8" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound" "8" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound.8 -- unbound manual
.\"
@@ -10,7 +10,7 @@
.SH "NAME"
.LP
.B unbound
-\- Unbound DNS validating resolver 1.4.20.
+\- Unbound DNS validating resolver 1.4.22.
.SH "SYNOPSIS"
.LP
.B unbound
diff --git a/contrib/unbound/doc/unbound.8.in b/contrib/unbound/doc/unbound.8.in
index 5d84d9a..fd67e71 100644
--- a/contrib/unbound/doc/unbound.8.in
+++ b/contrib/unbound/doc/unbound.8.in
@@ -1,4 +1,4 @@
-.TH "unbound" "8" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound" "8" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound.8 -- unbound manual
.\"
@@ -10,7 +10,7 @@
.SH "NAME"
.LP
.B unbound
-\- Unbound DNS validating resolver 1.4.20.
+\- Unbound DNS validating resolver 1.4.22.
.SH "SYNOPSIS"
.LP
.B unbound
diff --git a/contrib/unbound/doc/unbound.conf.5 b/contrib/unbound/doc/unbound.conf.5
index 1b399a4..a106733 100644
--- a/contrib/unbound/doc/unbound.conf.5
+++ b/contrib/unbound/doc/unbound.conf.5
@@ -1,4 +1,4 @@
-.TH "unbound.conf" "5" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound.conf" "5" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound.conf.5 -- unbound.conf manual
.\"
@@ -122,6 +122,9 @@ A port number can be specified with @port (without spaces between
interface and port number), if not specified the default port (from
\fBport\fR) is used.
.TP
+.B ip\-address: \fI<ip address[@port]>
+Same as interface: (for easy of compatibility with nsd.conf).
+.TP
.B interface\-automatic: \fI<yes or no>
Detect source interface on UDP queries and copy them to replies. This
feature is experimental, and needs support in your OS for particular socket
@@ -183,6 +186,11 @@ stringent path MTU problems, but is seen as extreme, since the amount
of TCP fallback generated is excessive (probably also for this resolver,
consider tuning the outgoing tcp number).
.TP
+.B max\-udp\-size: \fI<number>
+Maximum UDP response size (not applied to TCP response). 65536 disables the
+udp response size maximum, and uses the choice from the client, always.
+Suggested values are 512 to 4096. Default is 4096.
+.TP
.B msg\-buffer\-size: \fI<number>
Number of bytes size of the message buffers. Default is 65552 bytes, enough
for 64 Kb packets, the maximum DNS message size. No message larger than this
@@ -220,6 +228,15 @@ The qps for short queries can be about (numqueriesperthread / 2)
/ (jostletimeout in whole seconds) qps per thread, about (1024/2)*5 = 2560
qps by default.
.TP
+.B delay\-close: \fI<msec>
+Extra delay for timeouted UDP ports before they are closed, in msec.
+Default is 0, and that disables it. This prevents very delayed answer
+packets from the upstream (recursive) servers from bouncing against
+closed ports and setting off all sort of close-port counters, with
+eg. 1500 msec. When timeouts happen you need extra sockets, it checks
+the ID and remote IP of packets, and unwanted packets are added to the
+unwanted packet counter.
+.TP
.B so\-rcvbuf: \fI<number>
If not 0, then set the SO_RCVBUF socket option to get more buffer
space on UDP port 53 incoming queries. So that short spikes on busy
@@ -242,6 +259,15 @@ linux unbound needs root permission to bypass the limit, or the admin
can use sysctl net.core.wmem_max. On BSD, Solaris changes are similar
to so\-rcvbuf.
.TP
+.B so\-reuseport: \fI<yes or no>
+If yes, then open dedicated listening sockets for incoming queries for each
+thread and try to set the SO_REUSEPORT socket option on each socket. May
+distribute incoming queries to threads more evenly. Default is no. Only
+supported on Linux >= 3.9. You can enable it (on any platform and kernel),
+it then attempts to open the port and passes the option if it was available
+at compile time, if that works it is used, if it fails, it continues
+silently (unless verbosity 3) without the option.
+.TP
.B rrset\-cache\-size: \fI<number>
Number of bytes size of the RRset cache. Default is 4 megabytes.
A plain number is in bytes, append 'k', 'm' or 'g' for kilobytes, megabytes
@@ -326,7 +352,7 @@ a daemon. Default is yes.
.B access\-control: \fI<IP netblock> <action>
The netblock is given as an IP4 or IP6 address with /size appended for a
classless network block. The action can be \fIdeny\fR, \fIrefuse\fR,
-\fIallow\fR or \fIallow_snoop\fR.
+\fIallow\fR, \fIallow_snoop\fR, \fIdeny_non_local\fR or \fIrefuse_non_local\fR.
.IP
The action \fIdeny\fR stops queries from hosts from that netblock.
.IP
@@ -355,6 +381,12 @@ By default only localhost is \fIallow\fRed, the rest is \fIrefuse\fRd.
The default is \fIrefuse\fRd, because that is protocol\-friendly. The DNS
protocol is not designed to handle dropped packets due to policy, and
dropping may result in (possibly excessive) retried queries.
+.IP
+The deny_non_local and refuse_non_local settings are for hosts that are
+only allowed to query for the authoritative local\-data, they are not
+allowed full recursion but only the static data. With deny_non_local,
+messages that are disallowed are dropped, with refuse_non_local they
+receive error code REFUSED.
.TP
.B chroot: \fI<directory>
If chroot is enabled, you should pass the configfile (from the
@@ -492,7 +524,7 @@ unsigned to badly signed often. If turned off you run the risk of a
downgrade attack that disables security for a zone. Default is on.
.TP
.B harden\-below\-nxdomain: \fI<yes or no>
-From draft-vixie-dnsext-resimprove, returns nxdomain to queries for a name
+From draft\-vixie\-dnsext\-resimprove, returns nxdomain to queries for a name
below another name that is already known to be nxdomain. DNSSEC mandates
noerror for empty nonterminals, hence this is possible. Very old software
might return nxdomain for empty nonterminals (that usually happen for reverse
@@ -746,6 +778,17 @@ Number of bytes size of the aggressive negative cache. Default is 1 megabyte.
A plain number is in bytes, append 'k', 'm' or 'g' for kilobytes, megabytes
or gigabytes (1024*1024 bytes in a megabyte).
.TP
+.B unblock\-lan\-zones: \fI<yesno>
+Default is disabled. If enabled, then for private address space,
+the reverse lookups are no longer filtered. This allows unbound when
+running as dns service on a host where it provides service for that host,
+to put out all of the queries for the 'lan' upstream. When enabled,
+only localhost, 127.0.0.1 reverse and ::1 reverse zones are configured
+with default local zones. Disable the option when unbound is running
+as a (DHCP-) DNS network resolver for a group of machines, where such
+lookups should be filtered (RFC compliance), this also stops potential
+data leakage about the local network to the upstream DNS servers.
+.TP
.B local\-zone: \fI<zone> <type>
Configure a local zone. The type determines the answer to give if
there is no match from local\-data. The types are deny, refuse, static,
diff --git a/contrib/unbound/doc/unbound.conf.5.in b/contrib/unbound/doc/unbound.conf.5.in
index 6dd0216..aadd0da 100644
--- a/contrib/unbound/doc/unbound.conf.5.in
+++ b/contrib/unbound/doc/unbound.conf.5.in
@@ -1,4 +1,4 @@
-.TH "unbound.conf" "5" "Mar 21, 2013" "NLnet Labs" "unbound 1.4.20"
+.TH "unbound.conf" "5" "Mar 12, 2014" "NLnet Labs" "unbound 1.4.22"
.\"
.\" unbound.conf.5 -- unbound.conf manual
.\"
@@ -122,6 +122,9 @@ A port number can be specified with @port (without spaces between
interface and port number), if not specified the default port (from
\fBport\fR) is used.
.TP
+.B ip\-address: \fI<ip address[@port]>
+Same as interface: (for easy of compatibility with nsd.conf).
+.TP
.B interface\-automatic: \fI<yes or no>
Detect source interface on UDP queries and copy them to replies. This
feature is experimental, and needs support in your OS for particular socket
@@ -183,6 +186,11 @@ stringent path MTU problems, but is seen as extreme, since the amount
of TCP fallback generated is excessive (probably also for this resolver,
consider tuning the outgoing tcp number).
.TP
+.B max\-udp\-size: \fI<number>
+Maximum UDP response size (not applied to TCP response). 65536 disables the
+udp response size maximum, and uses the choice from the client, always.
+Suggested values are 512 to 4096. Default is 4096.
+.TP
.B msg\-buffer\-size: \fI<number>
Number of bytes size of the message buffers. Default is 65552 bytes, enough
for 64 Kb packets, the maximum DNS message size. No message larger than this
@@ -220,6 +228,15 @@ The qps for short queries can be about (numqueriesperthread / 2)
/ (jostletimeout in whole seconds) qps per thread, about (1024/2)*5 = 2560
qps by default.
.TP
+.B delay\-close: \fI<msec>
+Extra delay for timeouted UDP ports before they are closed, in msec.
+Default is 0, and that disables it. This prevents very delayed answer
+packets from the upstream (recursive) servers from bouncing against
+closed ports and setting off all sort of close-port counters, with
+eg. 1500 msec. When timeouts happen you need extra sockets, it checks
+the ID and remote IP of packets, and unwanted packets are added to the
+unwanted packet counter.
+.TP
.B so\-rcvbuf: \fI<number>
If not 0, then set the SO_RCVBUF socket option to get more buffer
space on UDP port 53 incoming queries. So that short spikes on busy
@@ -242,6 +259,15 @@ linux unbound needs root permission to bypass the limit, or the admin
can use sysctl net.core.wmem_max. On BSD, Solaris changes are similar
to so\-rcvbuf.
.TP
+.B so\-reuseport: \fI<yes or no>
+If yes, then open dedicated listening sockets for incoming queries for each
+thread and try to set the SO_REUSEPORT socket option on each socket. May
+distribute incoming queries to threads more evenly. Default is no. Only
+supported on Linux >= 3.9. You can enable it (on any platform and kernel),
+it then attempts to open the port and passes the option if it was available
+at compile time, if that works it is used, if it fails, it continues
+silently (unless verbosity 3) without the option.
+.TP
.B rrset\-cache\-size: \fI<number>
Number of bytes size of the RRset cache. Default is 4 megabytes.
A plain number is in bytes, append 'k', 'm' or 'g' for kilobytes, megabytes
@@ -326,7 +352,7 @@ a daemon. Default is yes.
.B access\-control: \fI<IP netblock> <action>
The netblock is given as an IP4 or IP6 address with /size appended for a
classless network block. The action can be \fIdeny\fR, \fIrefuse\fR,
-\fIallow\fR or \fIallow_snoop\fR.
+\fIallow\fR, \fIallow_snoop\fR, \fIdeny_non_local\fR or \fIrefuse_non_local\fR.
.IP
The action \fIdeny\fR stops queries from hosts from that netblock.
.IP
@@ -355,6 +381,12 @@ By default only localhost is \fIallow\fRed, the rest is \fIrefuse\fRd.
The default is \fIrefuse\fRd, because that is protocol\-friendly. The DNS
protocol is not designed to handle dropped packets due to policy, and
dropping may result in (possibly excessive) retried queries.
+.IP
+The deny_non_local and refuse_non_local settings are for hosts that are
+only allowed to query for the authoritative local\-data, they are not
+allowed full recursion but only the static data. With deny_non_local,
+messages that are disallowed are dropped, with refuse_non_local they
+receive error code REFUSED.
.TP
.B chroot: \fI<directory>
If chroot is enabled, you should pass the configfile (from the
@@ -492,7 +524,7 @@ unsigned to badly signed often. If turned off you run the risk of a
downgrade attack that disables security for a zone. Default is on.
.TP
.B harden\-below\-nxdomain: \fI<yes or no>
-From draft-vixie-dnsext-resimprove, returns nxdomain to queries for a name
+From draft\-vixie\-dnsext\-resimprove, returns nxdomain to queries for a name
below another name that is already known to be nxdomain. DNSSEC mandates
noerror for empty nonterminals, hence this is possible. Very old software
might return nxdomain for empty nonterminals (that usually happen for reverse
@@ -746,6 +778,17 @@ Number of bytes size of the aggressive negative cache. Default is 1 megabyte.
A plain number is in bytes, append 'k', 'm' or 'g' for kilobytes, megabytes
or gigabytes (1024*1024 bytes in a megabyte).
.TP
+.B unblock\-lan\-zones: \fI<yesno>
+Default is disabled. If enabled, then for private address space,
+the reverse lookups are no longer filtered. This allows unbound when
+running as dns service on a host where it provides service for that host,
+to put out all of the queries for the 'lan' upstream. When enabled,
+only localhost, 127.0.0.1 reverse and ::1 reverse zones are configured
+with default local zones. Disable the option when unbound is running
+as a (DHCP-) DNS network resolver for a group of machines, where such
+lookups should be filtered (RFC compliance), this also stops potential
+data leakage about the local network to the upstream DNS servers.
+.TP
.B local\-zone: \fI<zone> <type>
Configure a local zone. The type determines the answer to give if
there is no match from local\-data. The types are deny, refuse, static,
diff --git a/contrib/unbound/freebsd-configure.sh b/contrib/unbound/freebsd-configure.sh
index 46dc53a..c8852e7 100755
--- a/contrib/unbound/freebsd-configure.sh
+++ b/contrib/unbound/freebsd-configure.sh
@@ -32,13 +32,6 @@ autoheader
--with-run-dir=/var/unbound \
--with-username=unbound
-# Regenerate the configuration parser
-{
-cat <<EOF
-#include "config.h"
-#include "util/configyyrename.h"
-EOF
-/usr/bin/flex -L -t util/configlexer.lex
-} >util/configlexer.c
-
-/usr/bin/yacc -d -o util/configparser.c util/configparser.y
+# Don't try to provide bogus memory usage statistics based on sbrk(2).
+sed -n -i.orig -e '/HAVE_SBRK/!p' config.status
+./config.status config.h
diff --git a/contrib/unbound/iterator/iter_delegpt.c b/contrib/unbound/iterator/iter_delegpt.c
index d2f5d73..1d84280 100644
--- a/contrib/unbound/iterator/iter_delegpt.c
+++ b/contrib/unbound/iterator/iter_delegpt.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -47,6 +47,8 @@
#include "util/data/packed_rrset.h"
#include "util/data/msgreply.h"
#include "util/net_help.h"
+#include "ldns/rrdef.h"
+#include "ldns/sbuffer.h"
struct delegpt*
delegpt_create(struct regional* region)
@@ -71,7 +73,7 @@ struct delegpt* delegpt_copy(struct delegpt* dp, struct regional* region)
copy->bogus = dp->bogus;
copy->has_parent_side_NS = dp->has_parent_side_NS;
for(ns = dp->nslist; ns; ns = ns->next) {
- if(!delegpt_add_ns(copy, region, ns->name, (int)ns->lame))
+ if(!delegpt_add_ns(copy, region, ns->name, ns->lame))
return NULL;
copy->nslist->resolved = ns->resolved;
copy->nslist->got4 = ns->got4;
@@ -98,7 +100,7 @@ delegpt_set_name(struct delegpt* dp, struct regional* region, uint8_t* name)
int
delegpt_add_ns(struct delegpt* dp, struct regional* region, uint8_t* name,
- int lame)
+ uint8_t lame)
{
struct delegpt_ns* ns;
size_t len;
@@ -119,7 +121,7 @@ delegpt_add_ns(struct delegpt* dp, struct regional* region, uint8_t* name,
ns->resolved = 0;
ns->got4 = 0;
ns->got6 = 0;
- ns->lame = (uint8_t)lame;
+ ns->lame = lame;
ns->done_pside4 = 0;
ns->done_pside6 = 0;
return ns->name != 0;
@@ -156,7 +158,7 @@ delegpt_find_addr(struct delegpt* dp, struct sockaddr_storage* addr,
int
delegpt_add_target(struct delegpt* dp, struct regional* region,
uint8_t* name, size_t namelen, struct sockaddr_storage* addr,
- socklen_t addrlen, int bogus, int lame)
+ socklen_t addrlen, uint8_t bogus, uint8_t lame)
{
struct delegpt_ns* ns = delegpt_find_ns(dp, name, namelen);
log_assert(!dp->dp_type_mlc);
@@ -176,8 +178,8 @@ delegpt_add_target(struct delegpt* dp, struct regional* region,
int
delegpt_add_addr(struct delegpt* dp, struct regional* region,
- struct sockaddr_storage* addr, socklen_t addrlen, int bogus,
- int lame)
+ struct sockaddr_storage* addr, socklen_t addrlen, uint8_t bogus,
+ uint8_t lame)
{
struct delegpt_addr* a;
log_assert(!dp->dp_type_mlc);
@@ -204,6 +206,7 @@ delegpt_add_addr(struct delegpt* dp, struct regional* region,
a->attempts = 0;
a->bogus = bogus;
a->lame = lame;
+ a->dnsseclame = 0;
return 1;
}
@@ -376,7 +379,7 @@ delegpt_from_message(struct dns_msg* msg, struct regional* region)
int
delegpt_rrset_add_ns(struct delegpt* dp, struct regional* region,
- struct ub_packed_rrset_key* ns_rrset, int lame)
+ struct ub_packed_rrset_key* ns_rrset, uint8_t lame)
{
struct packed_rrset_data* nsdata = (struct packed_rrset_data*)
ns_rrset->entry.data;
@@ -387,7 +390,7 @@ delegpt_rrset_add_ns(struct delegpt* dp, struct regional* region,
for(i=0; i<nsdata->count; i++) {
if(nsdata->rr_len[i] < 2+1) continue; /* len + root label */
if(dname_valid(nsdata->rr_data[i]+2, nsdata->rr_len[i]-2) !=
- (size_t)ldns_read_uint16(nsdata->rr_data[i]))
+ (size_t)sldns_read_uint16(nsdata->rr_data[i]))
continue; /* bad format */
/* add rdata of NS (= wirefmt dname), skip rdatalen bytes */
if(!delegpt_add_ns(dp, region, nsdata->rr_data[i]+2, lame))
@@ -398,7 +401,7 @@ delegpt_rrset_add_ns(struct delegpt* dp, struct regional* region,
int
delegpt_add_rrset_A(struct delegpt* dp, struct regional* region,
- struct ub_packed_rrset_key* ak, int lame)
+ struct ub_packed_rrset_key* ak, uint8_t lame)
{
struct packed_rrset_data* d=(struct packed_rrset_data*)ak->entry.data;
size_t i;
@@ -422,7 +425,7 @@ delegpt_add_rrset_A(struct delegpt* dp, struct regional* region,
int
delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* region,
- struct ub_packed_rrset_key* ak, int lame)
+ struct ub_packed_rrset_key* ak, uint8_t lame)
{
struct packed_rrset_data* d=(struct packed_rrset_data*)ak->entry.data;
size_t i;
@@ -446,7 +449,7 @@ delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* region,
int
delegpt_add_rrset(struct delegpt* dp, struct regional* region,
- struct ub_packed_rrset_key* rrset, int lame)
+ struct ub_packed_rrset_key* rrset, uint8_t lame)
{
if(!rrset)
return 1;
@@ -548,7 +551,7 @@ int delegpt_set_name_mlc(struct delegpt* dp, uint8_t* name)
return (dp->name != NULL);
}
-int delegpt_add_ns_mlc(struct delegpt* dp, uint8_t* name, int lame)
+int delegpt_add_ns_mlc(struct delegpt* dp, uint8_t* name, uint8_t lame)
{
struct delegpt_ns* ns;
size_t len;
@@ -579,7 +582,7 @@ int delegpt_add_ns_mlc(struct delegpt* dp, uint8_t* name, int lame)
}
int delegpt_add_addr_mlc(struct delegpt* dp, struct sockaddr_storage* addr,
- socklen_t addrlen, int bogus, int lame)
+ socklen_t addrlen, uint8_t bogus, uint8_t lame)
{
struct delegpt_addr* a;
log_assert(dp->dp_type_mlc);
@@ -605,11 +608,13 @@ int delegpt_add_addr_mlc(struct delegpt* dp, struct sockaddr_storage* addr,
a->attempts = 0;
a->bogus = bogus;
a->lame = lame;
+ a->dnsseclame = 0;
return 1;
}
int delegpt_add_target_mlc(struct delegpt* dp, uint8_t* name, size_t namelen,
- struct sockaddr_storage* addr, socklen_t addrlen, int bogus, int lame)
+ struct sockaddr_storage* addr, socklen_t addrlen, uint8_t bogus,
+ uint8_t lame)
{
struct delegpt_ns* ns = delegpt_find_ns(dp, name, namelen);
log_assert(dp->dp_type_mlc);
diff --git a/contrib/unbound/iterator/iter_delegpt.h b/contrib/unbound/iterator/iter_delegpt.h
index 7728031..eb77135 100644
--- a/contrib/unbound/iterator/iter_delegpt.h
+++ b/contrib/unbound/iterator/iter_delegpt.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -140,9 +140,13 @@ struct delegpt_addr {
int sel_rtt;
/** if true, the A or AAAA RR was bogus, so this address is bad.
* Also check the dp->bogus to see if everything is bogus. */
- int bogus;
+ uint8_t bogus;
/** if true, this address is dispreferred: it is a lame IP address */
- int lame;
+ uint8_t lame;
+ /** if the address is dnsseclame, but this cannot be cached, this
+ * option is useful to mark the address dnsseclame.
+ * This value is not copied in addr-copy and dp-copy. */
+ uint8_t dnsseclame;
};
/**
@@ -179,7 +183,7 @@ int delegpt_set_name(struct delegpt* dp, struct regional* regional,
* @return false on error.
*/
int delegpt_add_ns(struct delegpt* dp, struct regional* regional,
- uint8_t* name, int lame);
+ uint8_t* name, uint8_t lame);
/**
* Add NS rrset; calls add_ns repeatedly.
@@ -190,7 +194,7 @@ int delegpt_add_ns(struct delegpt* dp, struct regional* regional,
* @return 0 on alloc error.
*/
int delegpt_rrset_add_ns(struct delegpt* dp, struct regional* regional,
- struct ub_packed_rrset_key* ns_rrset, int lame);
+ struct ub_packed_rrset_key* ns_rrset, uint8_t lame);
/**
* Add target address to the delegation point.
@@ -207,7 +211,7 @@ int delegpt_rrset_add_ns(struct delegpt* dp, struct regional* regional,
*/
int delegpt_add_target(struct delegpt* dp, struct regional* regional,
uint8_t* name, size_t namelen, struct sockaddr_storage* addr,
- socklen_t addrlen, int bogus, int lame);
+ socklen_t addrlen, uint8_t bogus, uint8_t lame);
/**
* Add A RRset to delegpt.
@@ -218,7 +222,7 @@ int delegpt_add_target(struct delegpt* dp, struct regional* regional,
* @return 0 on alloc error.
*/
int delegpt_add_rrset_A(struct delegpt* dp, struct regional* regional,
- struct ub_packed_rrset_key* rrset, int lame);
+ struct ub_packed_rrset_key* rrset, uint8_t lame);
/**
* Add AAAA RRset to delegpt.
@@ -229,7 +233,7 @@ int delegpt_add_rrset_A(struct delegpt* dp, struct regional* regional,
* @return 0 on alloc error.
*/
int delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* regional,
- struct ub_packed_rrset_key* rrset, int lame);
+ struct ub_packed_rrset_key* rrset, uint8_t lame);
/**
* Add any RRset to delegpt.
@@ -241,7 +245,7 @@ int delegpt_add_rrset_AAAA(struct delegpt* dp, struct regional* regional,
* @return 0 on alloc error.
*/
int delegpt_add_rrset(struct delegpt* dp, struct regional* regional,
- struct ub_packed_rrset_key* rrset, int lame);
+ struct ub_packed_rrset_key* rrset, uint8_t lame);
/**
* Add address to the delegation point. No servername is associated or checked.
@@ -254,7 +258,8 @@ int delegpt_add_rrset(struct delegpt* dp, struct regional* regional,
* @return false on error.
*/
int delegpt_add_addr(struct delegpt* dp, struct regional* regional,
- struct sockaddr_storage* addr, socklen_t addrlen, int bogus, int lame);
+ struct sockaddr_storage* addr, socklen_t addrlen,
+ uint8_t bogus, uint8_t lame);
/**
* Find NS record in name list of delegation point.
@@ -376,7 +381,7 @@ int delegpt_set_name_mlc(struct delegpt* dp, uint8_t* name);
* @param lame: the name is lame, disprefer.
* @return false on error.
*/
-int delegpt_add_ns_mlc(struct delegpt* dp, uint8_t* name, int lame);
+int delegpt_add_ns_mlc(struct delegpt* dp, uint8_t* name, uint8_t lame);
/**
* add an address to a malloced delegation point.
@@ -388,7 +393,7 @@ int delegpt_add_ns_mlc(struct delegpt* dp, uint8_t* name, int lame);
* @return false on error.
*/
int delegpt_add_addr_mlc(struct delegpt* dp, struct sockaddr_storage* addr,
- socklen_t addrlen, int bogus, int lame);
+ socklen_t addrlen, uint8_t bogus, uint8_t lame);
/**
* Add target address to the delegation point.
@@ -403,7 +408,8 @@ int delegpt_add_addr_mlc(struct delegpt* dp, struct sockaddr_storage* addr,
* @return false on error.
*/
int delegpt_add_target_mlc(struct delegpt* dp, uint8_t* name, size_t namelen,
- struct sockaddr_storage* addr, socklen_t addrlen, int bogus, int lame);
+ struct sockaddr_storage* addr, socklen_t addrlen, uint8_t bogus,
+ uint8_t lame);
/** get memory in use by dp */
size_t delegpt_get_mem(struct delegpt* dp);
diff --git a/contrib/unbound/iterator/iter_donotq.c b/contrib/unbound/iterator/iter_donotq.c
index bd60633..40ffb45 100644
--- a/contrib/unbound/iterator/iter_donotq.c
+++ b/contrib/unbound/iterator/iter_donotq.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/iterator/iter_donotq.h b/contrib/unbound/iterator/iter_donotq.h
index 4c4fcb2..429e5a3 100644
--- a/contrib/unbound/iterator/iter_donotq.h
+++ b/contrib/unbound/iterator/iter_donotq.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/iterator/iter_fwd.c b/contrib/unbound/iterator/iter_fwd.c
index 0b3b652..0121212 100644
--- a/contrib/unbound/iterator/iter_fwd.c
+++ b/contrib/unbound/iterator/iter_fwd.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,15 +40,14 @@
* Keep track of forward zones and config settings.
*/
#include "config.h"
-#include <ldns/rdata.h>
-#include <ldns/dname.h>
-#include <ldns/rr.h>
#include "iterator/iter_fwd.h"
#include "iterator/iter_delegpt.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "util/data/dname.h"
+#include "ldns/rrdef.h"
+#include "ldns/str2wire.h"
int
fwd_cmp(const void* k1, const void* k2)
@@ -180,22 +179,23 @@ static struct delegpt*
read_fwds_name(struct config_stub* s)
{
struct delegpt* dp;
- ldns_rdf* rdf;
+ uint8_t* dname;
+ size_t dname_len;
if(!s->name) {
log_err("forward zone without a name (use name \".\" to forward everything)");
return NULL;
}
- rdf = ldns_dname_new_frm_str(s->name);
- if(!rdf) {
+ dname = sldns_str2wire_dname(s->name, &dname_len);
+ if(!dname) {
log_err("cannot parse forward zone name %s", s->name);
return NULL;
}
- if(!(dp=delegpt_create_mlc(ldns_rdf_data(rdf)))) {
- ldns_rdf_deep_free(rdf);
+ if(!(dp=delegpt_create_mlc(dname))) {
+ free(dname);
log_err("out of memory");
return NULL;
}
- ldns_rdf_deep_free(rdf);
+ free(dname);
return dp;
}
@@ -204,21 +204,22 @@ static int
read_fwds_host(struct config_stub* s, struct delegpt* dp)
{
struct config_strlist* p;
- ldns_rdf* rdf;
+ uint8_t* dname;
+ size_t dname_len;
for(p = s->hosts; p; p = p->next) {
log_assert(p->str);
- rdf = ldns_dname_new_frm_str(p->str);
- if(!rdf) {
+ dname = sldns_str2wire_dname(p->str, &dname_len);
+ if(!dname) {
log_err("cannot parse forward %s server name: '%s'",
s->name, p->str);
return 0;
}
- if(!delegpt_add_ns_mlc(dp, ldns_rdf_data(rdf), 0)) {
- ldns_rdf_deep_free(rdf);
+ if(!delegpt_add_ns_mlc(dp, dname, 0)) {
+ free(dname);
log_err("out of memory");
return 0;
}
- ldns_rdf_deep_free(rdf);
+ free(dname);
}
return 1;
}
@@ -290,19 +291,20 @@ static int
make_stub_holes(struct iter_forwards* fwd, struct config_file* cfg)
{
struct config_stub* s;
+ uint8_t* dname;
+ size_t dname_len;
for(s = cfg->stubs; s; s = s->next) {
- ldns_rdf* rdf = ldns_dname_new_frm_str(s->name);
- if(!rdf) {
+ dname = sldns_str2wire_dname(s->name, &dname_len);
+ if(!dname) {
log_err("cannot parse stub name '%s'", s->name);
return 0;
}
- if(!fwd_add_stub_hole(fwd, LDNS_RR_CLASS_IN,
- ldns_rdf_data(rdf))) {
- ldns_rdf_deep_free(rdf);
+ if(!fwd_add_stub_hole(fwd, LDNS_RR_CLASS_IN, dname)) {
+ free(dname);
log_err("out of memory");
return 0;
}
- ldns_rdf_deep_free(rdf);
+ free(dname);
}
return 1;
}
@@ -325,6 +327,20 @@ forwards_apply_cfg(struct iter_forwards* fwd, struct config_file* cfg)
}
struct delegpt*
+forwards_find(struct iter_forwards* fwd, uint8_t* qname, uint16_t qclass)
+{
+ rbnode_t* res = NULL;
+ struct iter_forward_zone key;
+ key.node.key = &key;
+ key.dclass = qclass;
+ key.name = qname;
+ key.namelabs = dname_count_size_labels(qname, &key.namelen);
+ res = rbtree_search(fwd->tree, &key);
+ if(res) return ((struct iter_forward_zone*)res)->dp;
+ return NULL;
+}
+
+struct delegpt*
forwards_lookup(struct iter_forwards* fwd, uint8_t* qname, uint16_t qclass)
{
/* lookup the forward zone in the tree */
diff --git a/contrib/unbound/iterator/iter_fwd.h b/contrib/unbound/iterator/iter_fwd.h
index dbb84f2..20113a3 100644
--- a/contrib/unbound/iterator/iter_fwd.h
+++ b/contrib/unbound/iterator/iter_fwd.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -105,6 +105,16 @@ void forwards_delete(struct iter_forwards* fwd);
int forwards_apply_cfg(struct iter_forwards* fwd, struct config_file* cfg);
/**
+ * Find forward zone exactly by name
+ * @param fwd: forward storage.
+ * @param qname: The qname of the query.
+ * @param qclass: The qclass of the query.
+ * @return: A delegation point or null.
+ */
+struct delegpt* forwards_find(struct iter_forwards* fwd, uint8_t* qname,
+ uint16_t qclass);
+
+/**
* Find forward zone information
* For this qname/qclass find forward zone information, returns delegation
* point with server names and addresses, or NULL if no forwarding is needed.
diff --git a/contrib/unbound/iterator/iter_hints.c b/contrib/unbound/iterator/iter_hints.c
index cde3a7e..7fa07a7 100644
--- a/contrib/unbound/iterator/iter_hints.c
+++ b/contrib/unbound/iterator/iter_hints.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,14 +40,15 @@
* Keep track of stub and root hints, and read those from config.
*/
#include "config.h"
-#include <ldns/dname.h>
-#include <ldns/rr.h>
#include "iterator/iter_hints.h"
#include "iterator/iter_delegpt.h"
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
#include "util/data/dname.h"
+#include "ldns/rrdef.h"
+#include "ldns/str2wire.h"
+#include "ldns/wire2str.h"
struct iter_hints*
hints_create(void)
@@ -92,19 +93,20 @@ ah(struct delegpt* dp, const char* sv, const char* ip)
{
struct sockaddr_storage addr;
socklen_t addrlen;
- ldns_rdf* rdf = ldns_dname_new_frm_str(sv);
- if(!rdf) {
+ size_t dname_len;
+ uint8_t* dname = sldns_str2wire_dname(sv, &dname_len);
+ if(!dname) {
log_err("could not parse %s", sv);
return 0;
}
- if(!delegpt_add_ns_mlc(dp, ldns_rdf_data(rdf), 0) ||
+ if(!delegpt_add_ns_mlc(dp, dname, 0) ||
!extstrtoaddr(ip, &addr, &addrlen) ||
- !delegpt_add_target_mlc(dp, ldns_rdf_data(rdf), ldns_rdf_size(rdf),
+ !delegpt_add_target_mlc(dp, dname, dname_len,
&addr, addrlen, 0, 0)) {
- ldns_rdf_deep_free(rdf);
+ free(dname);
return 0;
}
- ldns_rdf_deep_free(rdf);
+ free(dname);
return 1;
}
@@ -186,22 +188,23 @@ static struct delegpt*
read_stubs_name(struct config_stub* s)
{
struct delegpt* dp;
- ldns_rdf* rdf;
+ size_t dname_len;
+ uint8_t* dname;
if(!s->name) {
log_err("stub zone without a name");
return NULL;
}
- rdf = ldns_dname_new_frm_str(s->name);
- if(!rdf) {
+ dname = sldns_str2wire_dname(s->name, &dname_len);
+ if(!dname) {
log_err("cannot parse stub zone name %s", s->name);
return NULL;
}
- if(!(dp=delegpt_create_mlc(ldns_rdf_data(rdf)))) {
- ldns_rdf_deep_free(rdf);
+ if(!(dp=delegpt_create_mlc(dname))) {
+ free(dname);
log_err("out of memory");
return NULL;
}
- ldns_rdf_deep_free(rdf);
+ free(dname);
return dp;
}
@@ -210,21 +213,22 @@ static int
read_stubs_host(struct config_stub* s, struct delegpt* dp)
{
struct config_strlist* p;
- ldns_rdf* rdf;
+ size_t dname_len;
+ uint8_t* dname;
for(p = s->hosts; p; p = p->next) {
log_assert(p->str);
- rdf = ldns_dname_new_frm_str(p->str);
- if(!rdf) {
+ dname = sldns_str2wire_dname(p->str, &dname_len);
+ if(!dname) {
log_err("cannot parse stub %s nameserver name: '%s'",
s->name, p->str);
return 0;
}
- if(!delegpt_add_ns_mlc(dp, ldns_rdf_data(rdf), 0)) {
- ldns_rdf_deep_free(rdf);
+ if(!delegpt_add_ns_mlc(dp, dname, 0)) {
+ free(dname);
log_err("out of memory");
return 0;
}
- ldns_rdf_deep_free(rdf);
+ free(dname);
}
return 1;
}
@@ -279,13 +283,11 @@ read_stubs(struct iter_hints* hints, struct config_file* cfg)
static int
read_root_hints(struct iter_hints* hints, char* fname)
{
- int lineno = 0;
- uint32_t default_ttl = 0;
- ldns_rdf* origin = NULL;
- ldns_rdf* prev_rr = NULL;
+ struct sldns_file_parse_state pstate;
struct delegpt* dp;
- ldns_rr* rr = NULL;
- ldns_status status;
+ uint8_t rr[LDNS_RR_BUF_SIZE];
+ size_t rr_len, dname_len;
+ int status;
uint16_t c = LDNS_RR_CLASS_IN;
FILE* f = fopen(fname, "r");
if(!f) {
@@ -300,77 +302,78 @@ read_root_hints(struct iter_hints* hints, char* fname)
return 0;
}
verbose(VERB_QUERY, "Reading root hints from %s", fname);
+ memset(&pstate, 0, sizeof(pstate));
+ pstate.lineno = 1;
dp->has_parent_side_NS = 1;
while(!feof(f)) {
- status = ldns_rr_new_frm_fp_l(&rr, f,
- &default_ttl, &origin, &prev_rr, &lineno);
- if(status == LDNS_STATUS_SYNTAX_EMPTY ||
- status == LDNS_STATUS_SYNTAX_TTL ||
- status == LDNS_STATUS_SYNTAX_ORIGIN)
- continue;
- if(status != LDNS_STATUS_OK) {
- log_err("reading root hints %s %d: %s", fname,
- lineno, ldns_get_errorstr_by_id(status));
+ rr_len = sizeof(rr);
+ dname_len = 0;
+ status = sldns_fp2wire_rr_buf(f, rr, &rr_len, &dname_len,
+ &pstate);
+ if(status != 0) {
+ log_err("reading root hints %s %d:%d: %s", fname,
+ pstate.lineno, LDNS_WIREPARSE_OFFSET(status),
+ sldns_get_errorstr_parse(status));
goto stop_read;
}
- if(ldns_rr_get_type(rr) == LDNS_RR_TYPE_NS) {
- if(!delegpt_add_ns_mlc(dp,
- ldns_rdf_data(ldns_rr_rdf(rr, 0)), 0)) {
+ if(rr_len == 0)
+ continue; /* EMPTY line, TTL or ORIGIN */
+ if(sldns_wirerr_get_type(rr, rr_len, dname_len)
+ == LDNS_RR_TYPE_NS) {
+ if(!delegpt_add_ns_mlc(dp, sldns_wirerr_get_rdata(rr,
+ rr_len, dname_len), 0)) {
log_err("out of memory reading root hints");
goto stop_read;
}
- c = ldns_rr_get_class(rr);
+ c = sldns_wirerr_get_class(rr, rr_len, dname_len);
if(!dp->name) {
- if(!delegpt_set_name_mlc(dp,
- ldns_rdf_data(ldns_rr_owner(rr)))){
+ if(!delegpt_set_name_mlc(dp, rr)) {
log_err("out of memory.");
goto stop_read;
}
}
- } else if(ldns_rr_get_type(rr) == LDNS_RR_TYPE_A) {
+ } else if(sldns_wirerr_get_type(rr, rr_len, dname_len)
+ == LDNS_RR_TYPE_A && sldns_wirerr_get_rdatalen(rr,
+ rr_len, dname_len) == INET_SIZE) {
struct sockaddr_in sa;
socklen_t len = (socklen_t)sizeof(sa);
memset(&sa, 0, len);
sa.sin_family = AF_INET;
sa.sin_port = (in_port_t)htons(UNBOUND_DNS_PORT);
memmove(&sa.sin_addr,
- ldns_rdf_data(ldns_rr_rdf(rr, 0)), INET_SIZE);
- if(!delegpt_add_target_mlc(dp,
- ldns_rdf_data(ldns_rr_owner(rr)),
- ldns_rdf_size(ldns_rr_owner(rr)),
+ sldns_wirerr_get_rdata(rr, rr_len, dname_len),
+ INET_SIZE);
+ if(!delegpt_add_target_mlc(dp, rr, dname_len,
(struct sockaddr_storage*)&sa, len,
0, 0)) {
log_err("out of memory reading root hints");
goto stop_read;
}
- } else if(ldns_rr_get_type(rr) == LDNS_RR_TYPE_AAAA) {
+ } else if(sldns_wirerr_get_type(rr, rr_len, dname_len)
+ == LDNS_RR_TYPE_AAAA && sldns_wirerr_get_rdatalen(rr,
+ rr_len, dname_len) == INET6_SIZE) {
struct sockaddr_in6 sa;
socklen_t len = (socklen_t)sizeof(sa);
memset(&sa, 0, len);
sa.sin6_family = AF_INET6;
sa.sin6_port = (in_port_t)htons(UNBOUND_DNS_PORT);
memmove(&sa.sin6_addr,
- ldns_rdf_data(ldns_rr_rdf(rr, 0)), INET6_SIZE);
- if(!delegpt_add_target_mlc(dp,
- ldns_rdf_data(ldns_rr_owner(rr)),
- ldns_rdf_size(ldns_rr_owner(rr)),
+ sldns_wirerr_get_rdata(rr, rr_len, dname_len),
+ INET6_SIZE);
+ if(!delegpt_add_target_mlc(dp, rr, dname_len,
(struct sockaddr_storage*)&sa, len,
0, 0)) {
log_err("out of memory reading root hints");
goto stop_read;
}
} else {
- log_warn("root hints %s:%d skipping type %d",
- fname, lineno, ldns_rr_get_type(rr));
+ char buf[17];
+ sldns_wire2str_type_buf(sldns_wirerr_get_type(rr,
+ rr_len, dname_len), buf, sizeof(buf));
+ log_warn("root hints %s:%d skipping type %s",
+ fname, pstate.lineno, buf);
}
-
- ldns_rr_free(rr);
}
-
- if (origin)
- ldns_rdf_deep_free(origin);
- if (prev_rr)
- ldns_rdf_deep_free(prev_rr);
fclose(f);
if(!dp->name) {
log_warn("root hints %s: no NS content", fname);
@@ -384,10 +387,6 @@ read_root_hints(struct iter_hints* hints, char* fname)
return 1;
stop_read:
- if (origin)
- ldns_rdf_deep_free(origin);
- if (prev_rr)
- ldns_rdf_deep_free(prev_rr);
delegpt_free_mlc(dp);
fclose(f);
return 0;
diff --git a/contrib/unbound/iterator/iter_hints.h b/contrib/unbound/iterator/iter_hints.h
index 7cac811..715ec9f 100644
--- a/contrib/unbound/iterator/iter_hints.h
+++ b/contrib/unbound/iterator/iter_hints.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/iterator/iter_priv.c b/contrib/unbound/iterator/iter_priv.c
index db7dbe5..9e09a84 100644
--- a/contrib/unbound/iterator/iter_priv.c
+++ b/contrib/unbound/iterator/iter_priv.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -41,7 +41,6 @@
*/
#include "config.h"
-#include <ldns/dname.h>
#include "iterator/iter_priv.h"
#include "util/regional.h"
#include "util/log.h"
@@ -50,6 +49,8 @@
#include "util/data/msgparse.h"
#include "util/net_help.h"
#include "util/storage/dnstree.h"
+#include "ldns/str2wire.h"
+#include "ldns/sbuffer.h"
struct iter_priv* priv_create(void)
{
@@ -110,23 +111,21 @@ static int read_names(struct iter_priv* priv, struct config_file* cfg)
/* parse names, report errors, insert into tree */
struct config_strlist* p;
struct name_tree_node* n;
- uint8_t* nm;
+ uint8_t* nm, *nmr;
size_t nm_len;
int nm_labs;
- ldns_rdf* rdf;
for(p = cfg->private_domain; p; p = p->next) {
log_assert(p->str);
- rdf = ldns_dname_new_frm_str(p->str);
- if(!rdf) {
+ nm = sldns_str2wire_dname(p->str, &nm_len);
+ if(!nm) {
log_err("cannot parse private-domain: %s", p->str);
return 0;
}
- nm = ldns_rdf_data(rdf);
nm_labs = dname_count_size_labels(nm, &nm_len);
- nm = (uint8_t*)regional_alloc_init(priv->region, nm, nm_len);
- ldns_rdf_deep_free(rdf);
- if(!nm) {
+ nmr = (uint8_t*)regional_alloc_init(priv->region, nm, nm_len);
+ free(nm);
+ if(!nmr) {
log_err("out of memory");
return 0;
}
@@ -136,7 +135,7 @@ static int read_names(struct iter_priv* priv, struct config_file* cfg)
log_err("out of memory");
return 0;
}
- if(!name_tree_insert(&priv->n, n, nm, nm_len, nm_labs,
+ if(!name_tree_insert(&priv->n, n, nmr, nm_len, nm_labs,
LDNS_RR_CLASS_IN)) {
verbose(VERB_QUERY, "ignoring duplicate "
"private-domain: %s", p->str);
@@ -188,7 +187,7 @@ priv_lookup_addr(struct iter_priv* priv, struct sockaddr_storage* addr,
* @return: true if the name is OK. false if unlisted.
*/
static int
-priv_lookup_name(struct iter_priv* priv, ldns_buffer* pkt,
+priv_lookup_name(struct iter_priv* priv, sldns_buffer* pkt,
uint8_t* name, size_t name_len, uint16_t dclass)
{
size_t len;
@@ -208,7 +207,29 @@ size_t priv_get_mem(struct iter_priv* priv)
return sizeof(*priv) + regional_get_mem(priv->region);
}
-int priv_rrset_bad(struct iter_priv* priv, ldns_buffer* pkt,
+/** remove RR from msgparse RRset, return true if rrset is entirely bad */
+static int
+remove_rr(const char* str, sldns_buffer* pkt, struct rrset_parse* rrset,
+ struct rr_parse* prev, struct rr_parse** rr, struct sockaddr_storage* addr, socklen_t addrlen)
+{
+ if(verbosity >= VERB_QUERY && rrset->dname_len <= LDNS_MAX_DOMAINLEN && str) {
+ uint8_t buf[LDNS_MAX_DOMAINLEN+1];
+ dname_pkt_copy(pkt, buf, rrset->dname);
+ log_name_addr(VERB_QUERY, str, buf, addr, addrlen);
+ }
+ if(prev)
+ prev->next = (*rr)->next;
+ else rrset->rr_first = (*rr)->next;
+ if(rrset->rr_last == *rr)
+ rrset->rr_last = prev;
+ rrset->rr_count --;
+ rrset->size -= (*rr)->size;
+ /* rr struct still exists, but is unlinked, so that in the for loop
+ * the rr->next works fine to continue. */
+ return rrset->rr_count == 0;
+}
+
+int priv_rrset_bad(struct iter_priv* priv, sldns_buffer* pkt,
struct rrset_parse* rrset)
{
if(priv->a.count == 0)
@@ -221,7 +242,7 @@ int priv_rrset_bad(struct iter_priv* priv, ldns_buffer* pkt,
} else {
/* so its a public name, check the address */
socklen_t len;
- struct rr_parse* rr;
+ struct rr_parse* rr, *prev = NULL;
if(rrset->type == LDNS_RR_TYPE_A) {
struct sockaddr_storage addr;
struct sockaddr_in sa;
@@ -231,14 +252,20 @@ int priv_rrset_bad(struct iter_priv* priv, ldns_buffer* pkt,
sa.sin_family = AF_INET;
sa.sin_port = (in_port_t)htons(UNBOUND_DNS_PORT);
for(rr = rrset->rr_first; rr; rr = rr->next) {
- if(ldns_read_uint16(rr->ttl_data+4)
- != INET_SIZE)
+ if(sldns_read_uint16(rr->ttl_data+4)
+ != INET_SIZE) {
+ prev = rr;
continue;
+ }
memmove(&sa.sin_addr, rr->ttl_data+4+2,
INET_SIZE);
memmove(&addr, &sa, len);
- if(priv_lookup_addr(priv, &addr, len))
- return 1;
+ if(priv_lookup_addr(priv, &addr, len)) {
+ if(remove_rr("sanitize: removing public name with private address", pkt, rrset, prev, &rr, &addr, len))
+ return 1;
+ continue;
+ }
+ prev = rr;
}
} else if(rrset->type == LDNS_RR_TYPE_AAAA) {
struct sockaddr_storage addr;
@@ -248,14 +275,20 @@ int priv_rrset_bad(struct iter_priv* priv, ldns_buffer* pkt,
sa.sin6_family = AF_INET6;
sa.sin6_port = (in_port_t)htons(UNBOUND_DNS_PORT);
for(rr = rrset->rr_first; rr; rr = rr->next) {
- if(ldns_read_uint16(rr->ttl_data+4)
- != INET6_SIZE)
+ if(sldns_read_uint16(rr->ttl_data+4)
+ != INET6_SIZE) {
+ prev = rr;
continue;
+ }
memmove(&sa.sin6_addr, rr->ttl_data+4+2,
INET6_SIZE);
memmove(&addr, &sa, len);
- if(priv_lookup_addr(priv, &addr, len))
- return 1;
+ if(priv_lookup_addr(priv, &addr, len)) {
+ if(remove_rr("sanitize: removing public name with private address", pkt, rrset, prev, &rr, &addr, len))
+ return 1;
+ continue;
+ }
+ prev = rr;
}
}
}
diff --git a/contrib/unbound/iterator/iter_priv.h b/contrib/unbound/iterator/iter_priv.h
index f6264f8..6fa8490 100644
--- a/contrib/unbound/iterator/iter_priv.h
+++ b/contrib/unbound/iterator/iter_priv.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -43,7 +43,7 @@
#ifndef ITERATOR_ITER_PRIV_H
#define ITERATOR_ITER_PRIV_H
#include "util/rbtree.h"
-#include <ldns/buffer.h>
+struct sldns_buffer;
struct iter_env;
struct config_file;
struct regional;
@@ -92,12 +92,14 @@ int priv_apply_cfg(struct iter_priv* priv, struct config_file* cfg);
/**
* See if rrset is bad.
+ * Will remove individual RRs that are bad (if possible) to
+ * sanitize the RRset without removing it completely.
* @param priv: structure for private address storage.
* @param pkt: packet to decompress rrset name in.
* @param rrset: the rrset to examine, A or AAAA.
* @return true if the rrset is bad and should be removed.
*/
-int priv_rrset_bad(struct iter_priv* priv, ldns_buffer* pkt,
+int priv_rrset_bad(struct iter_priv* priv, struct sldns_buffer* pkt,
struct rrset_parse* rrset);
/**
diff --git a/contrib/unbound/iterator/iter_resptype.c b/contrib/unbound/iterator/iter_resptype.c
index 2cdc5fc..45f9193 100644
--- a/contrib/unbound/iterator/iter_resptype.c
+++ b/contrib/unbound/iterator/iter_resptype.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,12 +40,13 @@
* one of the response types.
*/
#include "config.h"
-#include <ldns/packet.h>
#include "iterator/iter_resptype.h"
#include "iterator/iter_delegpt.h"
#include "services/cache/dns.h"
#include "util/net_help.h"
#include "util/data/dname.h"
+#include "ldns/rrdef.h"
+#include "ldns/pkthdr.h"
enum response_type
response_type_from_cache(struct dns_msg* msg,
diff --git a/contrib/unbound/iterator/iter_resptype.h b/contrib/unbound/iterator/iter_resptype.h
index 3bb3eed..fee9ef3 100644
--- a/contrib/unbound/iterator/iter_resptype.h
+++ b/contrib/unbound/iterator/iter_resptype.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/iterator/iter_scrub.c b/contrib/unbound/iterator/iter_scrub.c
index 6147c96..b2248bc 100644
--- a/contrib/unbound/iterator/iter_scrub.c
+++ b/contrib/unbound/iterator/iter_scrub.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -53,16 +53,17 @@
#include "util/data/dname.h"
#include "util/data/msgreply.h"
#include "util/alloc.h"
+#include "ldns/sbuffer.h"
/** RRset flag used during scrubbing. The RRset is OK. */
#define RRSET_SCRUB_OK 0x80
/** remove rrset, update loop variables */
static void
-remove_rrset(const char* str, ldns_buffer* pkt, struct msg_parse* msg,
+remove_rrset(const char* str, sldns_buffer* pkt, struct msg_parse* msg,
struct rrset_parse* prev, struct rrset_parse** rrset)
{
- if(verbosity >= VERB_QUERY
+ if(verbosity >= VERB_QUERY && str
&& (*rrset)->dname_len <= LDNS_MAX_DOMAINLEN) {
uint8_t buf[LDNS_MAX_DOMAINLEN+1];
dname_pkt_copy(pkt, buf, (*rrset)->dname);
@@ -108,7 +109,7 @@ has_additional(uint16_t t)
/** get additional name from rrset RR, return false if no name present */
static int
get_additional_name(struct rrset_parse* rrset, struct rr_parse* rr,
- uint8_t** nm, size_t* nmlen, ldns_buffer* pkt)
+ uint8_t** nm, size_t* nmlen, sldns_buffer* pkt)
{
size_t offset = 0;
size_t len, oldpos;
@@ -132,14 +133,14 @@ get_additional_name(struct rrset_parse* rrset, struct rr_parse* rr,
default:
return 0;
}
- len = ldns_read_uint16(rr->ttl_data+sizeof(uint32_t));
+ len = sldns_read_uint16(rr->ttl_data+sizeof(uint32_t));
if(len < offset+1)
return 0; /* rdata field too small */
*nm = rr->ttl_data+sizeof(uint32_t)+sizeof(uint16_t)+offset;
- oldpos = ldns_buffer_position(pkt);
- ldns_buffer_set_position(pkt, (size_t)(*nm - ldns_buffer_begin(pkt)));
+ oldpos = sldns_buffer_position(pkt);
+ sldns_buffer_set_position(pkt, (size_t)(*nm - sldns_buffer_begin(pkt)));
*nmlen = pkt_dname_len(pkt);
- ldns_buffer_set_position(pkt, oldpos);
+ sldns_buffer_set_position(pkt, oldpos);
if(*nmlen == 0)
return 0;
return 1;
@@ -147,7 +148,7 @@ get_additional_name(struct rrset_parse* rrset, struct rr_parse* rr,
/** Place mark on rrsets in additional section they are OK */
static void
-mark_additional_rrset(ldns_buffer* pkt, struct msg_parse* msg,
+mark_additional_rrset(sldns_buffer* pkt, struct msg_parse* msg,
struct rrset_parse* rrset)
{
/* Mark A and AAAA for NS as appropriate additional section info. */
@@ -209,7 +210,7 @@ parse_get_cname_target(struct rrset_parse* rrset, uint8_t** sname,
/** Synthesize CNAME from DNAME, false if too long */
static int
synth_cname(uint8_t* qname, size_t qnamelen, struct rrset_parse* dname_rrset,
- uint8_t* alias, size_t* aliaslen, ldns_buffer* pkt)
+ uint8_t* alias, size_t* aliaslen, sldns_buffer* pkt)
{
/* we already know that sname is a strict subdomain of DNAME owner */
uint8_t* dtarg = NULL;
@@ -233,7 +234,7 @@ static struct rrset_parse*
synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias,
size_t aliaslen, struct regional* region, struct msg_parse* msg,
struct rrset_parse* rrset, struct rrset_parse* prev,
- struct rrset_parse* nx, ldns_buffer* pkt)
+ struct rrset_parse* nx, sldns_buffer* pkt)
{
struct rrset_parse* cn = (struct rrset_parse*)regional_alloc(region,
sizeof(struct rrset_parse));
@@ -264,8 +265,8 @@ synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias,
sizeof(uint32_t)+sizeof(uint16_t)+aliaslen);
if(!cn->rr_first->ttl_data)
return NULL;
- ldns_write_uint32(cn->rr_first->ttl_data, 0); /* TTL = 0 */
- ldns_write_uint16(cn->rr_first->ttl_data+4, aliaslen);
+ sldns_write_uint32(cn->rr_first->ttl_data, 0); /* TTL = 0 */
+ sldns_write_uint16(cn->rr_first->ttl_data+4, aliaslen);
memmove(cn->rr_first->ttl_data+6, alias, aliaslen);
cn->rr_first->size = sizeof(uint16_t)+aliaslen;
@@ -287,7 +288,7 @@ synth_cname_rrset(uint8_t** sname, size_t* snamelen, uint8_t* alias,
/** check if DNAME applies to a name */
static int
-pkt_strict_sub(ldns_buffer* pkt, uint8_t* sname, uint8_t* dr)
+pkt_strict_sub(sldns_buffer* pkt, uint8_t* sname, uint8_t* dr)
{
uint8_t buf1[LDNS_MAX_DOMAINLEN+1];
uint8_t buf2[LDNS_MAX_DOMAINLEN+1];
@@ -299,7 +300,7 @@ pkt_strict_sub(ldns_buffer* pkt, uint8_t* sname, uint8_t* dr)
/** check subdomain with decompression */
static int
-pkt_sub(ldns_buffer* pkt, uint8_t* comprname, uint8_t* zone)
+pkt_sub(sldns_buffer* pkt, uint8_t* comprname, uint8_t* zone)
{
uint8_t buf[LDNS_MAX_DOMAINLEN+1];
dname_pkt_copy(pkt, buf, comprname);
@@ -308,7 +309,7 @@ pkt_sub(ldns_buffer* pkt, uint8_t* comprname, uint8_t* zone)
/** check subdomain with decompression, compressed is parent */
static int
-sub_of_pkt(ldns_buffer* pkt, uint8_t* zone, uint8_t* comprname)
+sub_of_pkt(sldns_buffer* pkt, uint8_t* zone, uint8_t* comprname)
{
uint8_t buf[LDNS_MAX_DOMAINLEN+1];
dname_pkt_copy(pkt, buf, comprname);
@@ -327,7 +328,7 @@ sub_of_pkt(ldns_buffer* pkt, uint8_t* zone, uint8_t* comprname)
* @return 0 on error.
*/
static int
-scrub_normalize(ldns_buffer* pkt, struct msg_parse* msg,
+scrub_normalize(sldns_buffer* pkt, struct msg_parse* msg,
struct query_info* qinfo, struct regional* region)
{
uint8_t* sname = qinfo->qname;
@@ -514,13 +515,13 @@ scrub_normalize(ldns_buffer* pkt, struct msg_parse* msg,
* @param rrset: to store.
*/
static void
-store_rrset(ldns_buffer* pkt, struct msg_parse* msg, struct module_env* env,
+store_rrset(sldns_buffer* pkt, struct msg_parse* msg, struct module_env* env,
struct rrset_parse* rrset)
{
struct ub_packed_rrset_key* k;
struct packed_rrset_data* d;
struct rrset_ref ref;
- uint32_t now = *env->now;
+ time_t now = *env->now;
k = alloc_special_obtain(env->alloc);
if(!k)
@@ -565,7 +566,7 @@ static int sanitize_nsec_is_overreach(struct rrset_parse* rrset,
log_assert(rrset->type == LDNS_RR_TYPE_NSEC);
for(rr = rrset->rr_first; rr; rr = rr->next) {
rhs = rr->ttl_data+4+2;
- len = ldns_read_uint16(rr->ttl_data+4);
+ len = sldns_read_uint16(rr->ttl_data+4);
if(!dname_valid(rhs, len)) {
/* malformed domain name in rdata */
return 1;
@@ -594,7 +595,7 @@ static int sanitize_nsec_is_overreach(struct rrset_parse* rrset,
* @return 0 on error.
*/
static int
-scrub_sanitize(ldns_buffer* pkt, struct msg_parse* msg,
+scrub_sanitize(sldns_buffer* pkt, struct msg_parse* msg,
struct query_info* qinfo, uint8_t* zonename, struct module_env* env,
struct iter_env* ie)
{
@@ -646,14 +647,16 @@ scrub_sanitize(ldns_buffer* pkt, struct msg_parse* msg,
/* remove private addresses */
if( (rrset->type == LDNS_RR_TYPE_A ||
- rrset->type == LDNS_RR_TYPE_AAAA) &&
- priv_rrset_bad(ie->priv, pkt, rrset)) {
+ rrset->type == LDNS_RR_TYPE_AAAA)) {
/* do not set servfail since this leads to too
* many drops of other people using rfc1918 space */
- remove_rrset("sanitize: removing public name with "
- "private address", pkt, msg, prev, &rrset);
- continue;
+ /* also do not remove entire rrset, unless all records
+ * in it are bad */
+ if(priv_rrset_bad(ie->priv, pkt, rrset)) {
+ remove_rrset(NULL, pkt, msg, prev, &rrset);
+ continue;
+ }
}
/* skip DNAME records -- they will always be followed by a
@@ -711,7 +714,7 @@ scrub_sanitize(ldns_buffer* pkt, struct msg_parse* msg,
}
int
-scrub_message(ldns_buffer* pkt, struct msg_parse* msg,
+scrub_message(sldns_buffer* pkt, struct msg_parse* msg,
struct query_info* qinfo, uint8_t* zonename, struct regional* region,
struct module_env* env, struct iter_env* ie)
{
diff --git a/contrib/unbound/iterator/iter_scrub.h b/contrib/unbound/iterator/iter_scrub.h
index 6b7274e..cbbaf73 100644
--- a/contrib/unbound/iterator/iter_scrub.h
+++ b/contrib/unbound/iterator/iter_scrub.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -42,7 +42,7 @@
#ifndef ITERATOR_ITER_SCRUB_H
#define ITERATOR_ITER_SCRUB_H
-#include <ldns/buffer.h>
+struct sldns_buffer;
struct msg_parse;
struct query_info;
struct regional;
@@ -62,7 +62,7 @@ struct iter_env;
* @param ie: iterator module environment data.
* @return: false if the message is total waste. true if scrubbed with success.
*/
-int scrub_message(ldns_buffer* pkt, struct msg_parse* msg,
+int scrub_message(struct sldns_buffer* pkt, struct msg_parse* msg,
struct query_info* qinfo, uint8_t* zonename, struct regional* regional,
struct module_env* env, struct iter_env* ie);
diff --git a/contrib/unbound/iterator/iter_utils.c b/contrib/unbound/iterator/iter_utils.c
index a500c75..5d55b62 100644
--- a/contrib/unbound/iterator/iter_utils.c
+++ b/contrib/unbound/iterator/iter_utils.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -63,6 +63,8 @@
#include "validator/val_kcache.h"
#include "validator/val_kentry.h"
#include "validator/val_utils.h"
+#include "validator/val_sigcrypt.h"
+#include "ldns/sbuffer.h"
/** time when nameserver glue is said to be 'recent' */
#define SUSPICION_RECENT_EXPIRY 86400
@@ -177,7 +179,7 @@ iter_apply_cfg(struct iter_env* iter_env, struct config_file* cfg)
*/
static int
iter_filter_unsuitable(struct iter_env* iter_env, struct module_env* env,
- uint8_t* name, size_t namelen, uint16_t qtype, uint32_t now,
+ uint8_t* name, size_t namelen, uint16_t qtype, time_t now,
struct delegpt_addr* a)
{
int rtt, lame, reclame, dnsseclame;
@@ -217,14 +219,16 @@ iter_filter_unsuitable(struct iter_env* iter_env, struct module_env* env,
/* select remainder from worst to best */
else if(reclame)
return rtt+USEFUL_SERVER_TOP_TIMEOUT*3; /* nonpref */
- else if(dnsseclame )
+ else if(dnsseclame || a->dnsseclame)
return rtt+USEFUL_SERVER_TOP_TIMEOUT*2; /* nonpref */
else if(a->lame)
return rtt+USEFUL_SERVER_TOP_TIMEOUT+1; /* nonpref */
else return rtt;
}
/* no server information present */
- if(a->lame)
+ if(a->dnsseclame)
+ return UNKNOWN_SERVER_NICENESS+USEFUL_SERVER_TOP_TIMEOUT*2; /* nonpref */
+ else if(a->lame)
return USEFUL_SERVER_TOP_TIMEOUT+1+UNKNOWN_SERVER_NICENESS; /* nonpref */
return UNKNOWN_SERVER_NICENESS;
}
@@ -232,7 +236,7 @@ iter_filter_unsuitable(struct iter_env* iter_env, struct module_env* env,
/** lookup RTT information, and also store fastest rtt (if any) */
static int
iter_fill_rtt(struct iter_env* iter_env, struct module_env* env,
- uint8_t* name, size_t namelen, uint16_t qtype, uint32_t now,
+ uint8_t* name, size_t namelen, uint16_t qtype, time_t now,
struct delegpt* dp, int* best_rtt, struct sock_list* blacklist)
{
int got_it = 0;
@@ -261,7 +265,7 @@ iter_fill_rtt(struct iter_env* iter_env, struct module_env* env,
* returns number of best targets (or 0, no suitable targets) */
static int
iter_filter_order(struct iter_env* iter_env, struct module_env* env,
- uint8_t* name, size_t namelen, uint16_t qtype, uint32_t now,
+ uint8_t* name, size_t namelen, uint16_t qtype, time_t now,
struct delegpt* dp, int* selected_rtt, int open_target,
struct sock_list* blacklist)
{
@@ -387,7 +391,7 @@ iter_server_selection(struct iter_env* iter_env,
}
struct dns_msg*
-dns_alloc_msg(ldns_buffer* pkt, struct msg_parse* msg,
+dns_alloc_msg(sldns_buffer* pkt, struct msg_parse* msg,
struct regional* region)
{
struct dns_msg* m = (struct dns_msg*)regional_alloc(region,
@@ -420,7 +424,7 @@ dns_copy_msg(struct dns_msg* from, struct regional* region)
void
iter_dns_store(struct module_env* env, struct query_info* msgqinf,
- struct reply_info* msgrep, int is_referral, uint32_t leeway, int pside,
+ struct reply_info* msgrep, int is_referral, time_t leeway, int pside,
struct regional* region)
{
if(!dns_cache_store(env, msgqinf, msgrep, is_referral, leeway,
@@ -680,7 +684,7 @@ rrset_equal(struct ub_packed_rrset_key* k1, struct ub_packed_rrset_key* k2)
}
int
-reply_equal(struct reply_info* p, struct reply_info* q, ldns_buffer* scratch)
+reply_equal(struct reply_info* p, struct reply_info* q, struct regional* region)
{
size_t i;
if(p->flags != q->flags ||
@@ -695,27 +699,12 @@ reply_equal(struct reply_info* p, struct reply_info* q, ldns_buffer* scratch)
return 0;
for(i=0; i<p->rrset_count; i++) {
if(!rrset_equal(p->rrsets[i], q->rrsets[i])) {
- /* fallback procedure: try to sort and canonicalize */
- ldns_rr_list* pl, *ql;
- pl = packed_rrset_to_rr_list(p->rrsets[i], scratch);
- ql = packed_rrset_to_rr_list(q->rrsets[i], scratch);
- if(!pl || !ql) {
- ldns_rr_list_deep_free(pl);
- ldns_rr_list_deep_free(ql);
+ if(!rrset_canonical_equal(region, p->rrsets[i],
+ q->rrsets[i])) {
+ regional_free_all(region);
return 0;
}
- ldns_rr_list2canonical(pl);
- ldns_rr_list2canonical(ql);
- ldns_rr_list_sort(pl);
- ldns_rr_list_sort(ql);
- if(ldns_rr_list_compare(pl, ql) != 0) {
- ldns_rr_list_deep_free(pl);
- ldns_rr_list_deep_free(ql);
- return 0;
- }
- ldns_rr_list_deep_free(pl);
- ldns_rr_list_deep_free(ql);
- continue;
+ regional_free_all(region);
}
}
return 1;
@@ -768,7 +757,7 @@ void iter_store_parentside_neg(struct module_env* env,
/* TTL: NS from referral in iq->deleg_msg,
* or first RR from iq->response,
* or servfail5secs if !iq->response */
- uint32_t ttl = NORR_TTL;
+ time_t ttl = NORR_TTL;
struct ub_packed_rrset_key* neg;
struct packed_rrset_data* newd;
if(rep) {
@@ -798,7 +787,7 @@ void iter_store_parentside_neg(struct module_env* env,
neg->entry.hash = rrset_key_hash(&neg->rk);
newd = (struct packed_rrset_data*)regional_alloc_zero(env->scratch,
sizeof(struct packed_rrset_data) + sizeof(size_t) +
- sizeof(uint8_t*) + sizeof(uint32_t) + sizeof(uint16_t));
+ sizeof(uint8_t*) + sizeof(time_t) + sizeof(uint16_t));
if(!newd) {
log_err("out of memory in store_parentside_neg");
return;
@@ -815,7 +804,7 @@ void iter_store_parentside_neg(struct module_env* env,
newd->rr_len[0] = 0 /* zero len rdata */ + sizeof(uint16_t);
packed_rrset_ptr_fixup(newd);
newd->rr_ttl[0] = newd->ttl;
- ldns_write_uint16(newd->rr_data[0], 0 /* zero len rdata */);
+ sldns_write_uint16(newd->rr_data[0], 0 /* zero len rdata */);
/* store it */
log_rrset_key(VERB_ALGO, "store parent-side negative", neg);
iter_store_parentside_rrset(env, neg);
diff --git a/contrib/unbound/iterator/iter_utils.h b/contrib/unbound/iterator/iter_utils.h
index 8f5a291..abdc68f 100644
--- a/contrib/unbound/iterator/iter_utils.h
+++ b/contrib/unbound/iterator/iter_utils.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -43,7 +43,7 @@
#ifndef ITERATOR_ITER_UTILS_H
#define ITERATOR_ITER_UTILS_H
#include "iterator/iter_resptype.h"
-#include <ldns/buffer.h>
+struct sldns_buffer;
struct iter_env;
struct iter_hints;
struct iter_forwards;
@@ -102,7 +102,7 @@ struct delegpt_addr* iter_server_selection(struct iter_env* iter_env,
* @param regional: regional to use for allocation.
* @return newly allocated dns_msg, or NULL on memory error.
*/
-struct dns_msg* dns_alloc_msg(ldns_buffer* pkt, struct msg_parse* msg,
+struct dns_msg* dns_alloc_msg(struct sldns_buffer* pkt, struct msg_parse* msg,
struct regional* regional);
/**
@@ -131,7 +131,7 @@ struct dns_msg* dns_copy_msg(struct dns_msg* from, struct regional* regional);
* but the query resolution can continue without cache storage.
*/
void iter_dns_store(struct module_env* env, struct query_info* qinf,
- struct reply_info* rep, int is_referral, uint32_t leeway, int pside,
+ struct reply_info* rep, int is_referral, time_t leeway, int pside,
struct regional* region);
/**
@@ -216,10 +216,10 @@ int iter_msg_from_zone(struct dns_msg* msg, struct delegpt* dp,
* @param p: reply one. The reply has rrset data pointers in region.
* Does not check rrset-IDs
* @param q: reply two
- * @param buf: scratch buffer.
+ * @param region: scratch buffer.
* @return if one and two are equal.
*/
-int reply_equal(struct reply_info* p, struct reply_info* q, ldns_buffer* buf);
+int reply_equal(struct reply_info* p, struct reply_info* q, struct regional* region);
/**
* Store parent-side rrset in seperate rrset cache entries for later
diff --git a/contrib/unbound/iterator/iterator.c b/contrib/unbound/iterator/iterator.c
index e3f058f..87fac81 100644
--- a/contrib/unbound/iterator/iterator.c
+++ b/contrib/unbound/iterator/iterator.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -41,7 +41,6 @@
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "iterator/iterator.h"
#include "iterator/iter_utils.h"
#include "iterator/iter_hints.h"
@@ -62,6 +61,10 @@
#include "util/data/msgencode.h"
#include "util/fptr_wlist.h"
#include "util/config_file.h"
+#include "ldns/rrdef.h"
+#include "ldns/wire2str.h"
+#include "ldns/parseutil.h"
+#include "ldns/sbuffer.h"
int
iter_init(struct module_env* env, int id)
@@ -228,8 +231,8 @@ static int
error_response(struct module_qstate* qstate, int id, int rcode)
{
verbose(VERB_QUERY, "return error response %s",
- ldns_lookup_by_id(ldns_rcodes, rcode)?
- ldns_lookup_by_id(ldns_rcodes, rcode)->name:"??");
+ sldns_lookup_by_id(sldns_rcodes, rcode)?
+ sldns_lookup_by_id(sldns_rcodes, rcode)->name:"??");
qstate->return_rcode = rcode;
qstate->return_msg = NULL;
qstate->ext_state[id] = module_finished;
@@ -540,8 +543,8 @@ prime_root(struct module_qstate* qstate, struct iter_qstate* iq, int id,
struct delegpt* dp;
struct module_qstate* subq;
verbose(VERB_DETAIL, "priming . %s NS",
- ldns_lookup_by_id(ldns_rr_classes, (int)qclass)?
- ldns_lookup_by_id(ldns_rr_classes, (int)qclass)->name:"??");
+ sldns_lookup_by_id(sldns_rr_classes, (int)qclass)?
+ sldns_lookup_by_id(sldns_rr_classes, (int)qclass)->name:"??");
dp = hints_lookup_root(qstate->env->hints, qclass);
if(!dp) {
verbose(VERB_ALGO, "Cannot prime due to lack of hints");
@@ -1212,7 +1215,7 @@ processInitRequest3(struct module_qstate* qstate, struct iter_qstate* iq,
* cached referral as the response. */
if(!(qstate->query_flags & BIT_RD)) {
iq->response = iq->deleg_msg;
- if(verbosity >= VERB_ALGO)
+ if(verbosity >= VERB_ALGO && iq->response)
log_dns_msg("no RD requested, using delegation msg",
&iq->response->qinfo, iq->response->rep);
if(qstate->reply_origin)
@@ -1409,6 +1412,35 @@ query_for_targets(struct module_qstate* qstate, struct iter_qstate* iq,
return 1;
}
+/** see if last resort is possible - does config allow queries to parent */
+static int
+can_have_last_resort(struct module_env* env, struct delegpt* dp,
+ struct iter_qstate* iq)
+{
+ struct delegpt* fwddp;
+ struct iter_hints_stub* stub;
+ /* do not process a last resort (the parent side) if a stub
+ * or forward is configured, because we do not want to go 'above'
+ * the configured servers */
+ if(!dname_is_root(dp->name) && (stub = (struct iter_hints_stub*)
+ name_tree_find(&env->hints->tree, dp->name, dp->namelen,
+ dp->namelabs, iq->qchase.qclass)) &&
+ /* has_parent side is turned off for stub_first, where we
+ * are allowed to go to the parent */
+ stub->dp->has_parent_side_NS) {
+ verbose(VERB_QUERY, "configured stub servers failed -- returning SERVFAIL");
+ return 0;
+ }
+ if((fwddp = forwards_find(env->fwds, dp->name, iq->qchase.qclass)) &&
+ /* has_parent_side is turned off for forward_first, where
+ * we are allowed to go to the parent */
+ fwddp->has_parent_side_NS) {
+ verbose(VERB_QUERY, "configured forward servers failed -- returning SERVFAIL");
+ return 0;
+ }
+ return 1;
+}
+
/**
* Called by processQueryTargets when it would like extra targets to query
* but it seems to be out of options. At last resort some less appealing
@@ -1430,6 +1462,11 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
verbose(VERB_ALGO, "No more query targets, attempting last resort");
log_assert(iq->dp);
+ if(!can_have_last_resort(qstate->env, iq->dp, iq)) {
+ /* fail -- no more targets, no more hope of targets, no hope
+ * of a response. */
+ return error_response_cache(qstate, id, LDNS_RCODE_SERVFAIL);
+ }
if(!iq->dp->has_parent_side_NS && dname_is_root(iq->dp->name)) {
struct delegpt* p = hints_lookup_root(qstate->env->hints,
iq->qchase.qclass);
@@ -1439,7 +1476,7 @@ processLastResort(struct module_qstate* qstate, struct iter_qstate* iq,
iq->chase_flags &= ~BIT_RD; /* go to authorities */
for(ns = p->nslist; ns; ns=ns->next) {
(void)delegpt_add_ns(iq->dp, qstate->region,
- ns->name, (int)ns->lame);
+ ns->name, ns->lame);
}
for(a = p->target_list; a; a=a->next_target) {
(void)delegpt_add_addr(iq->dp, qstate->region,
@@ -1880,12 +1917,23 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
&& type != RESPONSE_TYPE_UNTYPED) {
/* a possible answer, see if it is missing DNSSEC */
/* but not when forwarding, so we dont mark fwder lame */
- /* also make sure the answer is from the zone we expected,
- * otherwise, (due to parent,child on same server), we
- * might mark the server,zone lame inappropriately */
- if(!iter_msg_has_dnssec(iq->response) &&
- iter_msg_from_zone(iq->response, iq->dp, type,
- iq->qchase.qclass)) {
+ if(!iter_msg_has_dnssec(iq->response)) {
+ /* Mark this address as dnsseclame in this dp,
+ * because that will make serverselection disprefer
+ * it, but also, once it is the only final option,
+ * use dnssec-lame-bypass if it needs to query there.*/
+ if(qstate->reply) {
+ struct delegpt_addr* a = delegpt_find_addr(
+ iq->dp, &qstate->reply->addr,
+ qstate->reply->addrlen);
+ if(a) a->dnsseclame = 1;
+ }
+ /* test the answer is from the zone we expected,
+ * otherwise, (due to parent,child on same server), we
+ * might mark the server,zone lame inappropriately */
+ if(!iter_msg_from_zone(iq->response, iq->dp, type,
+ iq->qchase.qclass))
+ qstate->reply = NULL;
type = RESPONSE_TYPE_LAME;
dnsseclame = 1;
}
@@ -2117,8 +2165,7 @@ processQueryResponse(struct module_qstate* qstate, struct iter_qstate* iq,
*qstate->env->now, dnsseclame, 0,
iq->qchase.qtype))
log_err("mark host lame: out of memory");
- } else log_err("%slame response from cache",
- dnsseclame?"DNSSEC ":"");
+ }
} else if(type == RESPONSE_TYPE_REC_LAME) {
/* Cache the LAMEness. */
verbose(VERB_DETAIL, "query response REC_LAME: "
@@ -2326,12 +2373,12 @@ processTargetResponse(struct module_qstate* qstate, int id,
rrset->rk.dname_len)) {
/* if dpns->lame then set newcname ns lame too */
if(!delegpt_add_ns(foriq->dp, forq->region,
- rrset->rk.dname, (int)dpns->lame))
+ rrset->rk.dname, dpns->lame))
log_err("out of memory adding cnamed-ns");
}
/* if dpns->lame then set the address(es) lame too */
if(!delegpt_add_rrset(foriq->dp, forq->region, rrset,
- (int)dpns->lame))
+ dpns->lame))
log_err("out of memory adding targets");
verbose(VERB_ALGO, "added target response");
delegpt_log(VERB_ALGO, foriq->dp);
@@ -2704,7 +2751,7 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq,
{
struct msg_parse* prs;
struct edns_data edns;
- ldns_buffer* pkt;
+ sldns_buffer* pkt;
verbose(VERB_ALGO, "process_response: new external response event");
iq->response = NULL;
@@ -2731,7 +2778,7 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq,
memset(prs, 0, sizeof(*prs));
memset(&edns, 0, sizeof(edns));
pkt = qstate->reply->c->buffer;
- ldns_buffer_set_position(pkt, 0);
+ sldns_buffer_set_position(pkt, 0);
if(parse_packet(pkt, prs, qstate->env->scratch) != LDNS_RCODE_NOERROR) {
verbose(VERB_ALGO, "parse error on reply packet");
goto handle_it;
@@ -2771,7 +2818,7 @@ process_response(struct module_qstate* qstate, struct iter_qstate* iq,
} else {
/* check if reply is the same, otherwise, fail */
if(!reply_equal(iq->response->rep, iq->caps_reply,
- qstate->env->scratch_buffer)) {
+ qstate->env->scratch)) {
verbose(VERB_DETAIL, "Capsforid fallback: "
"getting different replies, failed");
outbound_list_remove(&iq->outlist, outbound);
diff --git a/contrib/unbound/iterator/iterator.h b/contrib/unbound/iterator/iterator.h
index eb33315..1816d12 100644
--- a/contrib/unbound/iterator/iterator.h
+++ b/contrib/unbound/iterator/iterator.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/ldns/keyraw.c b/contrib/unbound/ldns/keyraw.c
new file mode 100644
index 0000000..fe650aa
--- /dev/null
+++ b/contrib/unbound/ldns/keyraw.c
@@ -0,0 +1,368 @@
+/*
+ * keyraw.c - raw key operations and conversions
+ *
+ * (c) NLnet Labs, 2004-2008
+ *
+ * See the file LICENSE for the license
+ */
+/**
+ * \file
+ * Implementation of raw DNSKEY functions (work on wire rdata).
+ */
+
+#include "config.h"
+#include "ldns/keyraw.h"
+#include "ldns/rrdef.h"
+
+#ifdef HAVE_SSL
+#include <openssl/ssl.h>
+#include <openssl/evp.h>
+#include <openssl/rand.h>
+#include <openssl/err.h>
+#include <openssl/md5.h>
+#ifdef HAVE_OPENSSL_ENGINE_H
+# include <openssl/engine.h>
+#endif
+#endif /* HAVE_SSL */
+
+size_t
+sldns_rr_dnskey_key_size_raw(const unsigned char* keydata,
+ const size_t len, int alg)
+{
+ /* for DSA keys */
+ uint8_t t;
+
+ /* for RSA keys */
+ uint16_t exp;
+ uint16_t int16;
+
+ switch ((sldns_algorithm)alg) {
+ case LDNS_DSA:
+ case LDNS_DSA_NSEC3:
+ if (len > 0) {
+ t = keydata[0];
+ return (64 + t*8)*8;
+ } else {
+ return 0;
+ }
+ break;
+ case LDNS_RSAMD5:
+ case LDNS_RSASHA1:
+ case LDNS_RSASHA1_NSEC3:
+#ifdef USE_SHA2
+ case LDNS_RSASHA256:
+ case LDNS_RSASHA512:
+#endif
+ if (len > 0) {
+ if (keydata[0] == 0) {
+ /* big exponent */
+ if (len > 3) {
+ memmove(&int16, keydata + 1, 2);
+ exp = ntohs(int16);
+ return (len - exp - 3)*8;
+ } else {
+ return 0;
+ }
+ } else {
+ exp = keydata[0];
+ return (len-exp-1)*8;
+ }
+ } else {
+ return 0;
+ }
+ break;
+#ifdef USE_GOST
+ case LDNS_ECC_GOST:
+ return 512;
+#endif
+#ifdef USE_ECDSA
+ case LDNS_ECDSAP256SHA256:
+ return 256;
+ case LDNS_ECDSAP384SHA384:
+ return 384;
+#endif
+ default:
+ return 0;
+ }
+}
+
+uint16_t sldns_calc_keytag_raw(uint8_t* key, size_t keysize)
+{
+ if(keysize < 4) {
+ return 0;
+ }
+ /* look at the algorithm field, copied from 2535bis */
+ if (key[3] == LDNS_RSAMD5) {
+ uint16_t ac16 = 0;
+ if (keysize > 4) {
+ memmove(&ac16, key + keysize - 3, 2);
+ }
+ ac16 = ntohs(ac16);
+ return (uint16_t) ac16;
+ } else {
+ size_t i;
+ uint32_t ac32 = 0;
+ for (i = 0; i < keysize; ++i) {
+ ac32 += (i & 1) ? key[i] : key[i] << 8;
+ }
+ ac32 += (ac32 >> 16) & 0xFFFF;
+ return (uint16_t) (ac32 & 0xFFFF);
+ }
+}
+
+#ifdef HAVE_SSL
+#ifdef USE_GOST
+/** store GOST engine reference loaded into OpenSSL library */
+ENGINE* sldns_gost_engine = NULL;
+
+int
+sldns_key_EVP_load_gost_id(void)
+{
+ static int gost_id = 0;
+ const EVP_PKEY_ASN1_METHOD* meth;
+ ENGINE* e;
+
+ if(gost_id) return gost_id;
+
+ /* see if configuration loaded gost implementation from other engine*/
+ meth = EVP_PKEY_asn1_find_str(NULL, "gost2001", -1);
+ if(meth) {
+ EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
+ return gost_id;
+ }
+
+ /* see if engine can be loaded already */
+ e = ENGINE_by_id("gost");
+ if(!e) {
+ /* load it ourself, in case statically linked */
+ ENGINE_load_builtin_engines();
+ ENGINE_load_dynamic();
+ e = ENGINE_by_id("gost");
+ }
+ if(!e) {
+ /* no gost engine in openssl */
+ return 0;
+ }
+ if(!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
+ ENGINE_finish(e);
+ ENGINE_free(e);
+ return 0;
+ }
+
+ meth = EVP_PKEY_asn1_find_str(&e, "gost2001", -1);
+ if(!meth) {
+ /* algo not found */
+ ENGINE_finish(e);
+ ENGINE_free(e);
+ return 0;
+ }
+ /* Note: do not ENGINE_finish and ENGINE_free the acquired engine
+ * on some platforms this frees up the meth and unloads gost stuff */
+ sldns_gost_engine = e;
+
+ EVP_PKEY_asn1_get0_info(&gost_id, NULL, NULL, NULL, NULL, meth);
+ return gost_id;
+}
+
+void sldns_key_EVP_unload_gost(void)
+{
+ if(sldns_gost_engine) {
+ ENGINE_finish(sldns_gost_engine);
+ ENGINE_free(sldns_gost_engine);
+ sldns_gost_engine = NULL;
+ }
+}
+#endif /* USE_GOST */
+
+DSA *
+sldns_key_buf2dsa_raw(unsigned char* key, size_t len)
+{
+ uint8_t T;
+ uint16_t length;
+ uint16_t offset;
+ DSA *dsa;
+ BIGNUM *Q; BIGNUM *P;
+ BIGNUM *G; BIGNUM *Y;
+
+ if(len == 0)
+ return NULL;
+ T = (uint8_t)key[0];
+ length = (64 + T * 8);
+ offset = 1;
+
+ if (T > 8) {
+ return NULL;
+ }
+ if(len < (size_t)1 + SHA_DIGEST_LENGTH + 3*length)
+ return NULL;
+
+ Q = BN_bin2bn(key+offset, SHA_DIGEST_LENGTH, NULL);
+ offset += SHA_DIGEST_LENGTH;
+
+ P = BN_bin2bn(key+offset, (int)length, NULL);
+ offset += length;
+
+ G = BN_bin2bn(key+offset, (int)length, NULL);
+ offset += length;
+
+ Y = BN_bin2bn(key+offset, (int)length, NULL);
+ offset += length;
+
+ /* create the key and set its properties */
+ if(!Q || !P || !G || !Y || !(dsa = DSA_new())) {
+ BN_free(Q);
+ BN_free(P);
+ BN_free(G);
+ BN_free(Y);
+ return NULL;
+ }
+#ifndef S_SPLINT_S
+ dsa->p = P;
+ dsa->q = Q;
+ dsa->g = G;
+ dsa->pub_key = Y;
+#endif /* splint */
+
+ return dsa;
+}
+
+RSA *
+sldns_key_buf2rsa_raw(unsigned char* key, size_t len)
+{
+ uint16_t offset;
+ uint16_t exp;
+ uint16_t int16;
+ RSA *rsa;
+ BIGNUM *modulus;
+ BIGNUM *exponent;
+
+ if (len == 0)
+ return NULL;
+ if (key[0] == 0) {
+ if(len < 3)
+ return NULL;
+ memmove(&int16, key+1, 2);
+ exp = ntohs(int16);
+ offset = 3;
+ } else {
+ exp = key[0];
+ offset = 1;
+ }
+
+ /* key length at least one */
+ if(len < (size_t)offset + exp + 1)
+ return NULL;
+
+ /* Exponent */
+ exponent = BN_new();
+ if(!exponent) return NULL;
+ (void) BN_bin2bn(key+offset, (int)exp, exponent);
+ offset += exp;
+
+ /* Modulus */
+ modulus = BN_new();
+ if(!modulus) {
+ BN_free(exponent);
+ return NULL;
+ }
+ /* length of the buffer must match the key length! */
+ (void) BN_bin2bn(key+offset, (int)(len - offset), modulus);
+
+ rsa = RSA_new();
+ if(!rsa) {
+ BN_free(exponent);
+ BN_free(modulus);
+ return NULL;
+ }
+#ifndef S_SPLINT_S
+ rsa->n = modulus;
+ rsa->e = exponent;
+#endif /* splint */
+
+ return rsa;
+}
+
+#ifdef USE_GOST
+EVP_PKEY*
+sldns_gost2pkey_raw(unsigned char* key, size_t keylen)
+{
+ /* prefix header for X509 encoding */
+ uint8_t asn[37] = { 0x30, 0x63, 0x30, 0x1c, 0x06, 0x06, 0x2a, 0x85,
+ 0x03, 0x02, 0x02, 0x13, 0x30, 0x12, 0x06, 0x07, 0x2a, 0x85,
+ 0x03, 0x02, 0x02, 0x23, 0x01, 0x06, 0x07, 0x2a, 0x85, 0x03,
+ 0x02, 0x02, 0x1e, 0x01, 0x03, 0x43, 0x00, 0x04, 0x40};
+ unsigned char encoded[37+64];
+ const unsigned char* pp;
+ if(keylen != 64) {
+ /* key wrong size */
+ return NULL;
+ }
+
+ /* create evp_key */
+ memmove(encoded, asn, 37);
+ memmove(encoded+37, key, 64);
+ pp = (unsigned char*)&encoded[0];
+
+ return d2i_PUBKEY(NULL, &pp, (int)sizeof(encoded));
+}
+#endif /* USE_GOST */
+
+#ifdef USE_ECDSA
+EVP_PKEY*
+sldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo)
+{
+ unsigned char buf[256+2]; /* sufficient for 2*384/8+1 */
+ const unsigned char* pp = buf;
+ EVP_PKEY *evp_key;
+ EC_KEY *ec;
+ /* check length, which uncompressed must be 2 bignums */
+ if(algo == LDNS_ECDSAP256SHA256) {
+ if(keylen != 2*256/8) return NULL;
+ ec = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
+ } else if(algo == LDNS_ECDSAP384SHA384) {
+ if(keylen != 2*384/8) return NULL;
+ ec = EC_KEY_new_by_curve_name(NID_secp384r1);
+ } else ec = NULL;
+ if(!ec) return NULL;
+ if(keylen+1 > sizeof(buf))
+ return NULL; /* sanity check */
+ /* prepend the 0x02 (from docs) (or actually 0x04 from implementation
+ * of openssl) for uncompressed data */
+ buf[0] = POINT_CONVERSION_UNCOMPRESSED;
+ memmove(buf+1, key, keylen);
+ if(!o2i_ECPublicKey(&ec, &pp, (int)keylen+1)) {
+ EC_KEY_free(ec);
+ return NULL;
+ }
+ evp_key = EVP_PKEY_new();
+ if(!evp_key) {
+ EC_KEY_free(ec);
+ return NULL;
+ }
+ if (!EVP_PKEY_assign_EC_KEY(evp_key, ec)) {
+ EVP_PKEY_free(evp_key);
+ EC_KEY_free(ec);
+ return NULL;
+ }
+ return evp_key;
+}
+#endif /* USE_ECDSA */
+
+int
+sldns_digest_evp(unsigned char* data, unsigned int len, unsigned char* dest,
+ const EVP_MD* md)
+{
+ EVP_MD_CTX* ctx;
+ ctx = EVP_MD_CTX_create();
+ if(!ctx)
+ return 0;
+ if(!EVP_DigestInit_ex(ctx, md, NULL) ||
+ !EVP_DigestUpdate(ctx, data, len) ||
+ !EVP_DigestFinal_ex(ctx, dest, NULL)) {
+ EVP_MD_CTX_destroy(ctx);
+ return 0;
+ }
+ EVP_MD_CTX_destroy(ctx);
+ return 1;
+}
+#endif /* HAVE_SSL */
diff --git a/contrib/unbound/ldns/keyraw.h b/contrib/unbound/ldns/keyraw.h
new file mode 100644
index 0000000..8abe235
--- /dev/null
+++ b/contrib/unbound/ldns/keyraw.h
@@ -0,0 +1,112 @@
+/*
+ * keyraw.h -- raw key and signature access and conversion
+ *
+ * Copyright (c) 2005-2008, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+ *
+ */
+
+/**
+ * \file
+ *
+ * raw key and signature access and conversion
+ *
+ * Since those functions heavily rely op cryptographic operations,
+ * this module is dependent on openssl.
+ *
+ */
+
+#ifndef LDNS_KEYRAW_H
+#define LDNS_KEYRAW_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#if LDNS_BUILD_CONFIG_HAVE_SSL
+# include <openssl/ssl.h>
+# include <openssl/evp.h>
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
+
+/**
+ * get the length of the keydata in bits
+ * \param[in] keydata the raw key data
+ * \param[in] len the length of the keydata
+ * \param[in] alg the cryptographic algorithm this is a key for
+ * \return the keysize in bits, or 0 on error
+ */
+size_t sldns_rr_dnskey_key_size_raw(const unsigned char *keydata,
+ const size_t len, int alg);
+
+/**
+ * Calculates keytag of DNSSEC key, operates on wireformat rdata.
+ * \param[in] key the key as uncompressed wireformat rdata.
+ * \param[in] keysize length of key data.
+ * \return the keytag
+ */
+uint16_t sldns_calc_keytag_raw(uint8_t* key, size_t keysize);
+
+#if LDNS_BUILD_CONFIG_HAVE_SSL
+/**
+ * Get the PKEY id for GOST, loads GOST into openssl as a side effect.
+ * Only available if GOST is compiled into the library and openssl.
+ * \return the gost id for EVP_CTX creation.
+ */
+int sldns_key_EVP_load_gost_id(void);
+
+/** Release the engine reference held for the GOST engine. */
+void sldns_key_EVP_unload_gost(void);
+
+/**
+ * Like sldns_key_buf2dsa, but uses raw buffer.
+ * \param[in] key the uncompressed wireformat of the key.
+ * \param[in] len length of key data
+ * \return a DSA * structure with the key material
+ */
+DSA *sldns_key_buf2dsa_raw(unsigned char* key, size_t len);
+
+/**
+ * Converts a holding buffer with key material to EVP PKEY in openssl.
+ * Only available if ldns was compiled with GOST.
+ * \param[in] key data to convert
+ * \param[in] keylen length of the key data
+ * \return the key or NULL on error.
+ */
+EVP_PKEY* sldns_gost2pkey_raw(unsigned char* key, size_t keylen);
+
+/**
+ * Converts a holding buffer with key material to EVP PKEY in openssl.
+ * Only available if ldns was compiled with ECDSA.
+ * \param[in] key data to convert
+ * \param[in] keylen length of the key data
+ * \param[in] algo precise algorithm to initialize ECC group values.
+ * \return the key or NULL on error.
+ */
+EVP_PKEY* sldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo);
+
+/**
+ * Like sldns_key_buf2rsa, but uses raw buffer.
+ * \param[in] key the uncompressed wireformat of the key.
+ * \param[in] len length of key data
+ * \return a RSA * structure with the key material
+ */
+RSA *sldns_key_buf2rsa_raw(unsigned char* key, size_t len);
+
+/**
+ * Utility function to calculate hash using generic EVP_MD pointer.
+ * \param[in] data the data to hash.
+ * \param[in] len length of data.
+ * \param[out] dest the destination of the hash, must be large enough.
+ * \param[in] md the message digest to use.
+ * \return true if worked, false on failure.
+ */
+int sldns_digest_evp(unsigned char* data, unsigned int len,
+ unsigned char* dest, const EVP_MD* md);
+
+#endif /* LDNS_BUILD_CONFIG_HAVE_SSL */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDNS_KEYRAW_H */
diff --git a/contrib/unbound/ldns/parse.c b/contrib/unbound/ldns/parse.c
new file mode 100644
index 0000000..a605e54
--- /dev/null
+++ b/contrib/unbound/ldns/parse.c
@@ -0,0 +1,470 @@
+/*
+ * a generic (simple) parser. Use to parse rr's, private key
+ * information and /etc/resolv.conf files
+ *
+ * a Net::DNS like library for C
+ * LibDNS Team @ NLnet Labs
+ * (c) NLnet Labs, 2005-2006
+ * See the file LICENSE for the license
+ */
+#include "config.h"
+#include "ldns/parse.h"
+#include "ldns/parseutil.h"
+#include "ldns/sbuffer.h"
+
+#include <limits.h>
+#include <strings.h>
+
+sldns_lookup_table sldns_directive_types[] = {
+ { LDNS_DIR_TTL, "$TTL" },
+ { LDNS_DIR_ORIGIN, "$ORIGIN" },
+ { LDNS_DIR_INCLUDE, "$INCLUDE" },
+ { 0, NULL }
+};
+
+/* add max_limit here? */
+ssize_t
+sldns_fget_token(FILE *f, char *token, const char *delim, size_t limit)
+{
+ return sldns_fget_token_l(f, token, delim, limit, NULL);
+}
+
+ssize_t
+sldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr)
+{
+ int c, prev_c;
+ int p; /* 0 -> no parenthese seen, >0 nr of ( seen */
+ int com, quoted;
+ char *t;
+ size_t i;
+ const char *d;
+ const char *del;
+
+ /* standard delimeters */
+ if (!delim) {
+ /* from isspace(3) */
+ del = LDNS_PARSE_NORMAL;
+ } else {
+ del = delim;
+ }
+
+ p = 0;
+ i = 0;
+ com = 0;
+ quoted = 0;
+ prev_c = 0;
+ t = token;
+ if (del[0] == '"') {
+ quoted = 1;
+ }
+ while ((c = getc(f)) != EOF) {
+ if (c == '\r') /* carriage return */
+ c = ' ';
+ if (c == '(' && prev_c != '\\' && !quoted) {
+ /* this only counts for non-comments */
+ if (com == 0) {
+ p++;
+ }
+ prev_c = c;
+ continue;
+ }
+
+ if (c == ')' && prev_c != '\\' && !quoted) {
+ /* this only counts for non-comments */
+ if (com == 0) {
+ p--;
+ }
+ prev_c = c;
+ continue;
+ }
+
+ if (p < 0) {
+ /* more ) then ( - close off the string */
+ *t = '\0';
+ return 0;
+ }
+
+ /* do something with comments ; */
+ if (c == ';' && quoted == 0) {
+ if (prev_c != '\\') {
+ com = 1;
+ }
+ }
+ if (c == '\"' && com == 0 && prev_c != '\\') {
+ quoted = 1 - quoted;
+ }
+
+ if (c == '\n' && com != 0) {
+ /* comments */
+ com = 0;
+ *t = ' ';
+ if (line_nr) {
+ *line_nr = *line_nr + 1;
+ }
+ if (p == 0 && i > 0) {
+ goto tokenread;
+ } else {
+ prev_c = c;
+ continue;
+ }
+ }
+
+ if (com == 1) {
+ *t = ' ';
+ prev_c = c;
+ continue;
+ }
+
+ if (c == '\n' && p != 0 && t > token) {
+ /* in parentheses */
+ if (line_nr) {
+ *line_nr = *line_nr + 1;
+ }
+ *t++ = ' ';
+ prev_c = c;
+ continue;
+ }
+
+ /* check if we hit the delim */
+ for (d = del; *d; d++) {
+ if (c == *d && i > 0 && prev_c != '\\' && p == 0) {
+ if (c == '\n' && line_nr) {
+ *line_nr = *line_nr + 1;
+ }
+ goto tokenread;
+ }
+ }
+ if (c != '\0' && c != '\n') {
+ i++;
+ }
+ if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) {
+ *t = '\0';
+ return -1;
+ }
+ if (c != '\0' && c != '\n') {
+ *t++ = c;
+ }
+ if (c == '\\' && prev_c == '\\')
+ prev_c = 0;
+ else prev_c = c;
+ }
+ *t = '\0';
+ if (c == EOF) {
+ return (ssize_t)i;
+ }
+
+ if (i == 0) {
+ /* nothing read */
+ return -1;
+ }
+ if (p != 0) {
+ return -1;
+ }
+ return (ssize_t)i;
+
+tokenread:
+ if(*del == '"')
+ /* do not skip over quotes after the string, they are part
+ * of the next string. But skip over whitespace (if needed)*/
+ sldns_fskipcs_l(f, del+1, line_nr);
+ else sldns_fskipcs_l(f, del, line_nr);
+ *t = '\0';
+ if (p != 0) {
+ return -1;
+ }
+
+ return (ssize_t)i;
+}
+
+ssize_t
+sldns_fget_keyword_data(FILE *f, const char *keyword, const char *k_del, char *data,
+ const char *d_del, size_t data_limit)
+{
+ return sldns_fget_keyword_data_l(f, keyword, k_del, data, d_del,
+ data_limit, NULL);
+}
+
+ssize_t
+sldns_fget_keyword_data_l(FILE *f, const char *keyword, const char *k_del, char *data,
+ const char *d_del, size_t data_limit, int *line_nr)
+{
+ /* we assume: keyword|sep|data */
+ char *fkeyword;
+ ssize_t i;
+
+ if(strlen(keyword) >= LDNS_MAX_KEYWORDLEN)
+ return -1;
+ fkeyword = (char*)malloc(LDNS_MAX_KEYWORDLEN);
+ if(!fkeyword)
+ return -1;
+
+ i = sldns_fget_token(f, fkeyword, k_del, LDNS_MAX_KEYWORDLEN);
+ if(i==0 || i==-1) {
+ free(fkeyword);
+ return -1;
+ }
+
+ /* case??? i instead of strlen? */
+ if (strncmp(fkeyword, keyword, LDNS_MAX_KEYWORDLEN - 1) == 0) {
+ /* whee! */
+ /* printf("%s\n%s\n", "Matching keyword", fkeyword); */
+ i = sldns_fget_token_l(f, data, d_del, data_limit, line_nr);
+ free(fkeyword);
+ return i;
+ } else {
+ /*printf("no match for %s (read: %s)\n", keyword, fkeyword);*/
+ free(fkeyword);
+ return -1;
+ }
+}
+
+int
+sldns_bgetc(sldns_buffer *buffer)
+{
+ if (!sldns_buffer_available_at(buffer, buffer->_position, sizeof(uint8_t))) {
+ sldns_buffer_set_position(buffer, sldns_buffer_limit(buffer));
+ /* sldns_buffer_rewind(buffer);*/
+ return EOF;
+ }
+ return (int)sldns_buffer_read_u8(buffer);
+}
+
+ssize_t
+sldns_bget_token(sldns_buffer *b, char *token, const char *delim, size_t limit)
+{
+ return sldns_bget_token_par(b, token, delim, limit, NULL, NULL);
+}
+
+ssize_t
+sldns_bget_token_par(sldns_buffer *b, char *token, const char *delim,
+ size_t limit, int* par, const char* skipw)
+{
+ int c, lc;
+ int p; /* 0 -> no parenthese seen, >0 nr of ( seen */
+ int com, quoted;
+ char *t;
+ size_t i;
+ const char *d;
+ const char *del;
+
+ /* standard delimiters */
+ if (!delim) {
+ /* from isspace(3) */
+ del = LDNS_PARSE_NORMAL;
+ } else {
+ del = delim;
+ }
+
+ p = (par?*par:0);
+ i = 0;
+ com = 0;
+ quoted = 0;
+ t = token;
+ lc = 0;
+ if (del[0] == '"') {
+ quoted = 1;
+ }
+
+ while ((c = sldns_bgetc(b)) != EOF) {
+ if (c == '\r') /* carriage return */
+ c = ' ';
+ if (c == '(' && lc != '\\' && !quoted) {
+ /* this only counts for non-comments */
+ if (com == 0) {
+ if(par) (*par)++;
+ p++;
+ }
+ lc = c;
+ continue;
+ }
+
+ if (c == ')' && lc != '\\' && !quoted) {
+ /* this only counts for non-comments */
+ if (com == 0) {
+ if(par) (*par)--;
+ p--;
+ }
+ lc = c;
+ continue;
+ }
+
+ if (p < 0) {
+ /* more ) then ( */
+ *t = '\0';
+ return 0;
+ }
+
+ /* do something with comments ; */
+ if (c == ';' && quoted == 0) {
+ if (lc != '\\') {
+ com = 1;
+ }
+ }
+ if (c == '"' && com == 0 && lc != '\\') {
+ quoted = 1 - quoted;
+ }
+
+ if (c == '\n' && com != 0) {
+ /* comments */
+ com = 0;
+ *t = ' ';
+ lc = c;
+ continue;
+ }
+
+ if (com == 1) {
+ *t = ' ';
+ lc = c;
+ continue;
+ }
+
+ if (c == '\n' && p != 0) {
+ /* in parentheses */
+ /* do not write ' ' if we want to skip spaces */
+ if(!(skipw && (strchr(skipw, c)||strchr(skipw, ' '))))
+ *t++ = ' ';
+ lc = c;
+ continue;
+ }
+
+ /* check to skip whitespace at start, but also after ( */
+ if(skipw && i==0 && !com && !quoted && lc != '\\') {
+ if(strchr(skipw, c)) {
+ lc = c;
+ continue;
+ }
+ }
+
+ /* check if we hit the delim */
+ for (d = del; *d; d++) {
+ /* we can only exit if no parens or user tracks them */
+ if (c == *d && lc != '\\' && (p == 0 || par)) {
+ goto tokenread;
+ }
+ }
+
+ i++;
+ if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) {
+ *t = '\0';
+ return -1;
+ }
+ *t++ = c;
+
+ if (c == '\\' && lc == '\\') {
+ lc = 0;
+ } else {
+ lc = c;
+ }
+ }
+ *t = '\0';
+ if (i == 0) {
+ /* nothing read */
+ return -1;
+ }
+ if (!par && p != 0) {
+ return -1;
+ }
+ return (ssize_t)i;
+
+tokenread:
+ if(*del == '"')
+ /* do not skip over quotes after the string, they are part
+ * of the next string. But skip over whitespace (if needed)*/
+ sldns_bskipcs(b, del+1);
+ else sldns_bskipcs(b, del);
+ *t = '\0';
+
+ if (!par && p != 0) {
+ return -1;
+ }
+ return (ssize_t)i;
+}
+
+
+void
+sldns_bskipcs(sldns_buffer *buffer, const char *s)
+{
+ int found;
+ char c;
+ const char *d;
+
+ while(sldns_buffer_available_at(buffer, buffer->_position, sizeof(char))) {
+ c = (char) sldns_buffer_read_u8_at(buffer, buffer->_position);
+ found = 0;
+ for (d = s; *d; d++) {
+ if (*d == c) {
+ found = 1;
+ }
+ }
+ if (found && buffer->_limit > buffer->_position) {
+ buffer->_position += sizeof(char);
+ } else {
+ return;
+ }
+ }
+}
+
+void
+sldns_fskipcs(FILE *fp, const char *s)
+{
+ sldns_fskipcs_l(fp, s, NULL);
+}
+
+void
+sldns_fskipcs_l(FILE *fp, const char *s, int *line_nr)
+{
+ int found;
+ int c;
+ const char *d;
+
+ while ((c = fgetc(fp)) != EOF) {
+ if (line_nr && c == '\n') {
+ *line_nr = *line_nr + 1;
+ }
+ found = 0;
+ for (d = s; *d; d++) {
+ if (*d == c) {
+ found = 1;
+ }
+ }
+ if (!found) {
+ /* with getc, we've read too far */
+ ungetc(c, fp);
+ return;
+ }
+ }
+}
+
+ssize_t
+sldns_bget_keyword_data(sldns_buffer *b, const char *keyword, const char *k_del, char
+*data, const char *d_del, size_t data_limit)
+{
+ /* we assume: keyword|sep|data */
+ char *fkeyword;
+ ssize_t i;
+
+ if(strlen(keyword) >= LDNS_MAX_KEYWORDLEN)
+ return -1;
+ fkeyword = (char*)malloc(LDNS_MAX_KEYWORDLEN);
+ if(!fkeyword)
+ return -1; /* out of memory */
+
+ i = sldns_bget_token(b, fkeyword, k_del, data_limit);
+ if(i==0 || i==-1) {
+ free(fkeyword);
+ return -1; /* nothing read */
+ }
+
+ /* case??? */
+ if (strncmp(fkeyword, keyword, strlen(keyword)) == 0) {
+ free(fkeyword);
+ /* whee, the match! */
+ /* retrieve it's data */
+ i = sldns_bget_token(b, data, d_del, 0);
+ return i;
+ } else {
+ free(fkeyword);
+ return -1;
+ }
+}
+
diff --git a/contrib/unbound/ldns/parse.h b/contrib/unbound/ldns/parse.h
new file mode 100644
index 0000000..7b7456d
--- /dev/null
+++ b/contrib/unbound/ldns/parse.h
@@ -0,0 +1,184 @@
+/*
+ * parse.h
+ *
+ * a Net::DNS like library for C
+ * LibDNS Team @ NLnet Labs
+ * (c) NLnet Labs, 2005-2006
+ * See the file LICENSE for the license
+ */
+
+#ifndef LDNS_PARSE_H
+#define LDNS_PARSE_H
+
+struct sldns_buffer;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define LDNS_PARSE_SKIP_SPACE "\f\n\r\v"
+#define LDNS_PARSE_NORMAL " \f\n\r\t\v"
+#define LDNS_PARSE_NO_NL " \t"
+#define LDNS_MAX_LINELEN 10230
+#define LDNS_MAX_KEYWORDLEN 32
+
+
+/**
+ * \file
+ *
+ * Contains some low-level parsing functions, mostly used in the _frm_str
+ * family of functions.
+ */
+
+/**
+ * different type of directives in zone files
+ * We now deal with $TTL, $ORIGIN and $INCLUDE.
+ * The latter is not implemented in ldns (yet)
+ */
+enum sldns_enum_directive
+{
+ LDNS_DIR_TTL,
+ LDNS_DIR_ORIGIN,
+ LDNS_DIR_INCLUDE
+};
+typedef enum sldns_enum_directive sldns_directive;
+
+/**
+ * returns a token/char from the stream F.
+ * This function deals with ( and ) in the stream,
+ * and ignores them when encountered
+ * \param[in] *f the file to read from
+ * \param[out] *token the read token is put here
+ * \param[in] *delim chars at which the parsing should stop
+ * \param[in] *limit how much to read. If 0 the builtin maximum is used
+ * \return 0 on error of EOF of the stream F. Otherwise return the length of what is read
+ */
+ssize_t sldns_fget_token(FILE *f, char *token, const char *delim, size_t limit);
+
+/**
+ * returns a token/char from the stream F.
+ * This function deals with ( and ) in the stream,
+ * and ignores when it finds them.
+ * \param[in] *f the file to read from
+ * \param[out] *token the token is put here
+ * \param[in] *delim chars at which the parsing should stop
+ * \param[in] *limit how much to read. If 0 use builtin maximum
+ * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
+ * \return 0 on error of EOF of F otherwise return the length of what is read
+ */
+ssize_t sldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *line_nr);
+
+/**
+ * returns a token/char from the buffer b.
+ * This function deals with ( and ) in the buffer,
+ * and ignores when it finds them.
+ * \param[in] *b the buffer to read from
+ * \param[out] *token the token is put here
+ * \param[in] *delim chars at which the parsing should stop
+ * \param[in] *limit how much to read. If 0 the builtin maximum is used
+ * \param[in] *par if you pass nonNULL, set to 0 on first call, the parenthesis
+ * state is stored in it, for use on next call. User must check it is back
+ * to zero after last bget in string (for parse error). If you pass NULL,
+ * the entire parenthesized string is read in.
+ * \param[in] skipw string with whitespace to skip before the start of the
+ * token, like " ", or " \t", or NULL for none.
+ * \returns 0 on error of EOF of b. Otherwise return the length of what is read
+ */
+ssize_t sldns_bget_token_par(struct sldns_buffer *b, char *token, const char *delim, size_t limit, int* par, const char* skipw);
+
+/**
+ * returns a token/char from the buffer b.
+ * This function deals with ( and ) in the buffer,
+ * and ignores when it finds them.
+ * \param[in] *b the buffer to read from
+ * \param[out] *token the token is put here
+ * \param[in] *delim chars at which the parsing should stop
+ * \param[in] *limit how much to read. If 0 the builtin maximum is used
+ * \returns 0 on error of EOF of b. Otherwise return the length of what is read
+ */
+ssize_t sldns_bget_token(struct sldns_buffer *b, char *token, const char *delim, size_t limit);
+
+/*
+ * searches for keyword and delim in a file. Gives everything back
+ * after the keyword + k_del until we hit d_del
+ * \param[in] f file pointer to read from
+ * \param[in] keyword keyword to look for
+ * \param[in] k_del keyword delimeter
+ * \param[out] data the data found
+ * \param[in] d_del the data delimeter
+ * \param[in] data_limit maximum size the the data buffer
+ * \return the number of character read
+ */
+ssize_t sldns_fget_keyword_data(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit);
+
+/*
+ * searches for keyword and delim. Gives everything back
+ * after the keyword + k_del until we hit d_del
+ * \param[in] f file pointer to read from
+ * \param[in] keyword keyword to look for
+ * \param[in] k_del keyword delimeter
+ * \param[out] data the data found
+ * \param[in] d_del the data delimeter
+ * \param[in] data_limit maximum size the the data buffer
+ * \param[in] line_nr pointer to an integer containing the current line number (for
+debugging purposes)
+ * \return the number of character read
+ */
+ssize_t sldns_fget_keyword_data_l(FILE *f, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit, int *line_nr);
+
+/*
+ * searches for keyword and delim in a buffer. Gives everything back
+ * after the keyword + k_del until we hit d_del
+ * \param[in] b buffer pointer to read from
+ * \param[in] keyword keyword to look for
+ * \param[in] k_del keyword delimeter
+ * \param[out] data the data found
+ * \param[in] d_del the data delimeter
+ * \param[in] data_limit maximum size the the data buffer
+ * \return the number of character read
+ */
+ssize_t sldns_bget_keyword_data(struct sldns_buffer *b, const char *keyword, const char *k_del, char *data, const char *d_del, size_t data_limit);
+
+/**
+ * returns the next character from a buffer. Advances the position pointer with 1.
+ * When end of buffer is reached returns EOF. This is the buffer's equivalent
+ * for getc().
+ * \param[in] *buffer buffer to read from
+ * \return EOF on failure otherwise return the character
+ */
+int sldns_bgetc(struct sldns_buffer *buffer);
+
+/**
+ * skips all of the characters in the given string in the buffer, moving
+ * the position to the first character that is not in *s.
+ * \param[in] *buffer buffer to use
+ * \param[in] *s characters to skip
+ * \return void
+ */
+void sldns_bskipcs(struct sldns_buffer *buffer, const char *s);
+
+/**
+ * skips all of the characters in the given string in the fp, moving
+ * the position to the first character that is not in *s.
+ * \param[in] *fp file to use
+ * \param[in] *s characters to skip
+ * \return void
+ */
+void sldns_fskipcs(FILE *fp, const char *s);
+
+
+/**
+ * skips all of the characters in the given string in the fp, moving
+ * the position to the first character that is not in *s.
+ * \param[in] *fp file to use
+ * \param[in] *s characters to skip
+ * \param[in] line_nr pointer to an integer containing the current line number (for debugging purposes)
+ * \return void
+ */
+void sldns_fskipcs_l(FILE *fp, const char *s, int *line_nr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDNS_PARSE_H */
diff --git a/contrib/unbound/ldns/parseutil.c b/contrib/unbound/ldns/parseutil.c
new file mode 100644
index 0000000..55e3a5b
--- /dev/null
+++ b/contrib/unbound/ldns/parseutil.c
@@ -0,0 +1,726 @@
+/*
+ * parseutil.c - parse utilities for string and wire conversion
+ *
+ * (c) NLnet Labs, 2004-2006
+ *
+ * See the file LICENSE for the license
+ */
+/**
+ * \file
+ *
+ * Utility functions for parsing, base32(DNS variant) and base64 encoding
+ * and decoding, Hex, Time units, Escape codes.
+ */
+
+#include "config.h"
+#include "ldns/parseutil.h"
+#include <sys/time.h>
+#include <time.h>
+#include <ctype.h>
+
+sldns_lookup_table *
+sldns_lookup_by_name(sldns_lookup_table *table, const char *name)
+{
+ while (table->name != NULL) {
+ if (strcasecmp(name, table->name) == 0)
+ return table;
+ table++;
+ }
+ return NULL;
+}
+
+sldns_lookup_table *
+sldns_lookup_by_id(sldns_lookup_table *table, int id)
+{
+ while (table->name != NULL) {
+ if (table->id == id)
+ return table;
+ table++;
+ }
+ return NULL;
+}
+
+/* Number of days per month (except for February in leap years). */
+static const int mdays[] = {
+ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+};
+
+#define LDNS_MOD(x,y) (((x) % (y) < 0) ? ((x) % (y) + (y)) : ((x) % (y)))
+#define LDNS_DIV(x,y) (((x) % (y) < 0) ? ((x) / (y) - 1 ) : ((x) / (y)))
+
+static int
+is_leap_year(int year)
+{
+ return LDNS_MOD(year, 4) == 0 && (LDNS_MOD(year, 100) != 0
+ || LDNS_MOD(year, 400) == 0);
+}
+
+static int
+leap_days(int y1, int y2)
+{
+ --y1;
+ --y2;
+ return (LDNS_DIV(y2, 4) - LDNS_DIV(y1, 4)) -
+ (LDNS_DIV(y2, 100) - LDNS_DIV(y1, 100)) +
+ (LDNS_DIV(y2, 400) - LDNS_DIV(y1, 400));
+}
+
+/*
+ * Code adapted from Python 2.4.1 sources (Lib/calendar.py).
+ */
+time_t
+sldns_mktime_from_utc(const struct tm *tm)
+{
+ int year = 1900 + tm->tm_year;
+ time_t days = 365 * ((time_t) year - 1970) + leap_days(1970, year);
+ time_t hours;
+ time_t minutes;
+ time_t seconds;
+ int i;
+
+ for (i = 0; i < tm->tm_mon; ++i) {
+ days += mdays[i];
+ }
+ if (tm->tm_mon > 1 && is_leap_year(year)) {
+ ++days;
+ }
+ days += tm->tm_mday - 1;
+
+ hours = days * 24 + tm->tm_hour;
+ minutes = hours * 60 + tm->tm_min;
+ seconds = minutes * 60 + tm->tm_sec;
+
+ return seconds;
+}
+
+#if SIZEOF_TIME_T <= 4
+
+static void
+sldns_year_and_yday_from_days_since_epoch(int64_t days, struct tm *result)
+{
+ int year = 1970;
+ int new_year;
+
+ while (days < 0 || days >= (int64_t) (is_leap_year(year) ? 366 : 365)) {
+ new_year = year + (int) LDNS_DIV(days, 365);
+ days -= (new_year - year) * 365;
+ days -= leap_days(year, new_year);
+ year = new_year;
+ }
+ result->tm_year = year;
+ result->tm_yday = (int) days;
+}
+
+/* Number of days per month in a leap year. */
+static const int leap_year_mdays[] = {
+ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+};
+
+static void
+sldns_mon_and_mday_from_year_and_yday(struct tm *result)
+{
+ int idays = result->tm_yday;
+ const int *mon_lengths = is_leap_year(result->tm_year) ?
+ leap_year_mdays : mdays;
+
+ result->tm_mon = 0;
+ while (idays >= mon_lengths[result->tm_mon]) {
+ idays -= mon_lengths[result->tm_mon++];
+ }
+ result->tm_mday = idays + 1;
+}
+
+static void
+sldns_wday_from_year_and_yday(struct tm *result)
+{
+ result->tm_wday = 4 /* 1-1-1970 was a thursday */
+ + LDNS_MOD((result->tm_year - 1970), 7) * LDNS_MOD(365, 7)
+ + leap_days(1970, result->tm_year)
+ + result->tm_yday;
+ result->tm_wday = LDNS_MOD(result->tm_wday, 7);
+ if (result->tm_wday < 0) {
+ result->tm_wday += 7;
+ }
+}
+
+static struct tm *
+sldns_gmtime64_r(int64_t clock, struct tm *result)
+{
+ result->tm_isdst = 0;
+ result->tm_sec = (int) LDNS_MOD(clock, 60);
+ clock = LDNS_DIV(clock, 60);
+ result->tm_min = (int) LDNS_MOD(clock, 60);
+ clock = LDNS_DIV(clock, 60);
+ result->tm_hour = (int) LDNS_MOD(clock, 24);
+ clock = LDNS_DIV(clock, 24);
+
+ sldns_year_and_yday_from_days_since_epoch(clock, result);
+ sldns_mon_and_mday_from_year_and_yday(result);
+ sldns_wday_from_year_and_yday(result);
+ result->tm_year -= 1900;
+
+ return result;
+}
+
+#endif /* SIZEOF_TIME_T <= 4 */
+
+static int64_t
+sldns_serial_arithmitics_time(int32_t time, time_t now)
+{
+ int32_t offset = time - (int32_t) now;
+ return (int64_t) now + offset;
+}
+
+struct tm *
+sldns_serial_arithmitics_gmtime_r(int32_t time, time_t now, struct tm *result)
+{
+#if SIZEOF_TIME_T <= 4
+ int64_t secs_since_epoch = sldns_serial_arithmitics_time(time, now);
+ return sldns_gmtime64_r(secs_since_epoch, result);
+#else
+ time_t secs_since_epoch = sldns_serial_arithmitics_time(time, now);
+ return gmtime_r(&secs_since_epoch, result);
+#endif
+}
+
+int
+sldns_hexdigit_to_int(char ch)
+{
+ switch (ch) {
+ case '0': return 0;
+ case '1': return 1;
+ case '2': return 2;
+ case '3': return 3;
+ case '4': return 4;
+ case '5': return 5;
+ case '6': return 6;
+ case '7': return 7;
+ case '8': return 8;
+ case '9': return 9;
+ case 'a': case 'A': return 10;
+ case 'b': case 'B': return 11;
+ case 'c': case 'C': return 12;
+ case 'd': case 'D': return 13;
+ case 'e': case 'E': return 14;
+ case 'f': case 'F': return 15;
+ default:
+ return -1;
+ }
+}
+
+uint32_t
+sldns_str2period(const char *nptr, const char **endptr)
+{
+ int sign = 0;
+ uint32_t i = 0;
+ uint32_t seconds = 0;
+
+ for(*endptr = nptr; **endptr; (*endptr)++) {
+ switch (**endptr) {
+ case ' ':
+ case '\t':
+ break;
+ case '-':
+ if(sign == 0) {
+ sign = -1;
+ } else {
+ return seconds;
+ }
+ break;
+ case '+':
+ if(sign == 0) {
+ sign = 1;
+ } else {
+ return seconds;
+ }
+ break;
+ case 's':
+ case 'S':
+ seconds += i;
+ i = 0;
+ break;
+ case 'm':
+ case 'M':
+ seconds += i * 60;
+ i = 0;
+ break;
+ case 'h':
+ case 'H':
+ seconds += i * 60 * 60;
+ i = 0;
+ break;
+ case 'd':
+ case 'D':
+ seconds += i * 60 * 60 * 24;
+ i = 0;
+ break;
+ case 'w':
+ case 'W':
+ seconds += i * 60 * 60 * 24 * 7;
+ i = 0;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ i *= 10;
+ i += (**endptr - '0');
+ break;
+ default:
+ seconds += i;
+ /* disregard signedness */
+ return seconds;
+ }
+ }
+ seconds += i;
+ /* disregard signedness */
+ return seconds;
+}
+
+int
+sldns_parse_escape(uint8_t *ch_p, const char** str_p)
+{
+ uint16_t val;
+
+ if ((*str_p)[0] && isdigit((*str_p)[0]) &&
+ (*str_p)[1] && isdigit((*str_p)[1]) &&
+ (*str_p)[2] && isdigit((*str_p)[2])) {
+
+ val = (uint16_t)(((*str_p)[0] - '0') * 100 +
+ ((*str_p)[1] - '0') * 10 +
+ ((*str_p)[2] - '0'));
+
+ if (val > 255) {
+ goto error;
+ }
+ *ch_p = (uint8_t)val;
+ *str_p += 3;
+ return 1;
+
+ } else if ((*str_p)[0] && !isdigit((*str_p)[0])) {
+
+ *ch_p = (uint8_t)*(*str_p)++;
+ return 1;
+ }
+error:
+ *str_p = NULL;
+ return 0; /* LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE */
+}
+
+/** parse one character, with escape codes */
+int
+sldns_parse_char(uint8_t *ch_p, const char** str_p)
+{
+ switch (**str_p) {
+
+ case '\0': return 0;
+
+ case '\\': *str_p += 1;
+ return sldns_parse_escape(ch_p, str_p);
+
+ default: *ch_p = (uint8_t)*(*str_p)++;
+ return 1;
+ }
+}
+
+size_t sldns_b32_ntop_calculate_size(size_t src_data_length)
+{
+ return src_data_length == 0 ? 0 : ((src_data_length - 1) / 5 + 1) * 8;
+}
+
+size_t sldns_b32_ntop_calculate_size_no_padding(size_t src_data_length)
+{
+ return ((src_data_length + 3) * 8 / 5) - 4;
+}
+
+static int
+sldns_b32_ntop_base(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz,
+ int extended_hex, int add_padding)
+{
+ size_t ret_sz;
+ const char* b32 = extended_hex ? "0123456789abcdefghijklmnopqrstuv"
+ : "abcdefghijklmnopqrstuvwxyz234567";
+
+ size_t c = 0; /* c is used to carry partial base32 character over
+ * byte boundaries for sizes with a remainder.
+ * (i.e. src_sz % 5 != 0)
+ */
+
+ ret_sz = add_padding ? sldns_b32_ntop_calculate_size(src_sz)
+ : sldns_b32_ntop_calculate_size_no_padding(src_sz);
+
+ /* Do we have enough space? */
+ if (dst_sz < ret_sz + 1)
+ return -1;
+
+ /* We know the size; terminate the string */
+ dst[ret_sz] = '\0';
+
+ /* First process all chunks of five */
+ while (src_sz >= 5) {
+ /* 00000... ........ ........ ........ ........ */
+ dst[0] = b32[(src[0] ) >> 3];
+
+ /* .....111 11...... ........ ........ ........ */
+ dst[1] = b32[(src[0] & 0x07) << 2 | src[1] >> 6];
+
+ /* ........ ..22222. ........ ........ ........ */
+ dst[2] = b32[(src[1] & 0x3e) >> 1];
+
+ /* ........ .......3 3333.... ........ ........ */
+ dst[3] = b32[(src[1] & 0x01) << 4 | src[2] >> 4];
+
+ /* ........ ........ ....4444 4....... ........ */
+ dst[4] = b32[(src[2] & 0x0f) << 1 | src[3] >> 7];
+
+ /* ........ ........ ........ .55555.. ........ */
+ dst[5] = b32[(src[3] & 0x7c) >> 2];
+
+ /* ........ ........ ........ ......66 666..... */
+ dst[6] = b32[(src[3] & 0x03) << 3 | src[4] >> 5];
+
+ /* ........ ........ ........ ........ ...77777 */
+ dst[7] = b32[(src[4] & 0x1f) ];
+
+ src_sz -= 5;
+ src += 5;
+ dst += 8;
+ }
+ /* Process what remains */
+ switch (src_sz) {
+ case 4: /* ........ ........ ........ ......66 666..... */
+ dst[6] = b32[(src[3] & 0x03) << 3];
+
+ /* ........ ........ ........ .55555.. ........ */
+ dst[5] = b32[(src[3] & 0x7c) >> 2];
+
+ /* ........ ........ ....4444 4....... ........ */
+ c = src[3] >> 7 ;
+ case 3: dst[4] = b32[(src[2] & 0x0f) << 1 | c];
+
+ /* ........ .......3 3333.... ........ ........ */
+ c = src[2] >> 4 ;
+ case 2: dst[3] = b32[(src[1] & 0x01) << 4 | c];
+
+ /* ........ ..22222. ........ ........ ........ */
+ dst[2] = b32[(src[1] & 0x3e) >> 1];
+
+ /* .....111 11...... ........ ........ ........ */
+ c = src[1] >> 6 ;
+ case 1: dst[1] = b32[(src[0] & 0x07) << 2 | c];
+
+ /* 00000... ........ ........ ........ ........ */
+ dst[0] = b32[ src[0] >> 3];
+ }
+ /* Add padding */
+ if (add_padding) {
+ switch (src_sz) {
+ case 1: dst[2] = '=';
+ dst[3] = '=';
+ case 2: dst[4] = '=';
+ case 3: dst[5] = '=';
+ dst[6] = '=';
+ case 4: dst[7] = '=';
+ }
+ }
+ return (int)ret_sz;
+}
+
+int
+sldns_b32_ntop(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz)
+{
+ return sldns_b32_ntop_base(src, src_sz, dst, dst_sz, 0, 1);
+}
+
+int
+sldns_b32_ntop_extended_hex(const uint8_t* src, size_t src_sz,
+ char* dst, size_t dst_sz)
+{
+ return sldns_b32_ntop_base(src, src_sz, dst, dst_sz, 1, 1);
+}
+
+size_t sldns_b32_pton_calculate_size(size_t src_text_length)
+{
+ return src_text_length * 5 / 8;
+}
+
+static int
+sldns_b32_pton_base(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz,
+ int extended_hex, int check_padding)
+{
+ size_t i = 0;
+ char ch = '\0';
+ uint8_t buf[8];
+ uint8_t* start = dst;
+
+ while (src_sz) {
+ /* Collect 8 characters in buf (if possible) */
+ for (i = 0; i < 8; i++) {
+
+ do {
+ ch = *src++;
+ --src_sz;
+
+ } while (isspace(ch) && src_sz > 0);
+
+ if (ch == '=' || ch == '\0')
+ break;
+
+ else if (extended_hex)
+
+ if (ch >= '0' && ch <= '9')
+ buf[i] = (uint8_t)ch - '0';
+ else if (ch >= 'a' && ch <= 'v')
+ buf[i] = (uint8_t)ch - 'a' + 10;
+ else if (ch >= 'A' && ch <= 'V')
+ buf[i] = (uint8_t)ch - 'A' + 10;
+ else
+ return -1;
+
+ else if (ch >= 'a' && ch <= 'z')
+ buf[i] = (uint8_t)ch - 'a';
+ else if (ch >= 'A' && ch <= 'Z')
+ buf[i] = (uint8_t)ch - 'A';
+ else if (ch >= '2' && ch <= '7')
+ buf[i] = (uint8_t)ch - '2' + 26;
+ else
+ return -1;
+ }
+ /* Less that 8 characters. We're done. */
+ if (i < 8)
+ break;
+
+ /* Enough space available at the destination? */
+ if (dst_sz < 5)
+ return -1;
+
+ /* 00000... ........ ........ ........ ........ */
+ /* .....111 11...... ........ ........ ........ */
+ dst[0] = buf[0] << 3 | buf[1] >> 2;
+
+ /* .....111 11...... ........ ........ ........ */
+ /* ........ ..22222. ........ ........ ........ */
+ /* ........ .......3 3333.... ........ ........ */
+ dst[1] = buf[1] << 6 | buf[2] << 1 | buf[3] >> 4;
+
+ /* ........ .......3 3333.... ........ ........ */
+ /* ........ ........ ....4444 4....... ........ */
+ dst[2] = buf[3] << 4 | buf[4] >> 1;
+
+ /* ........ ........ ....4444 4....... ........ */
+ /* ........ ........ ........ .55555.. ........ */
+ /* ........ ........ ........ ......66 666..... */
+ dst[3] = buf[4] << 7 | buf[5] << 2 | buf[6] >> 3;
+
+ /* ........ ........ ........ ......66 666..... */
+ /* ........ ........ ........ ........ ...77777 */
+ dst[4] = buf[6] << 5 | buf[7];
+
+ dst += 5;
+ dst_sz -= 5;
+ }
+ /* Not ending on a eight byte boundary? */
+ if (i > 0 && i < 8) {
+
+ /* Enough space available at the destination? */
+ if (dst_sz < (i + 1) / 2)
+ return -1;
+
+ switch (i) {
+ case 7: /* ........ ........ ........ ......66 666..... */
+ /* ........ ........ ........ .55555.. ........ */
+ /* ........ ........ ....4444 4....... ........ */
+ dst[3] = buf[4] << 7 | buf[5] << 2 | buf[6] >> 3;
+
+ case 5: /* ........ ........ ....4444 4....... ........ */
+ /* ........ .......3 3333.... ........ ........ */
+ dst[2] = buf[3] << 4 | buf[4] >> 1;
+
+ case 4: /* ........ .......3 3333.... ........ ........ */
+ /* ........ ..22222. ........ ........ ........ */
+ /* .....111 11...... ........ ........ ........ */
+ dst[1] = buf[1] << 6 | buf[2] << 1 | buf[3] >> 4;
+
+ case 2: /* .....111 11...... ........ ........ ........ */
+ /* 00000... ........ ........ ........ ........ */
+ dst[0] = buf[0] << 3 | buf[1] >> 2;
+
+ break;
+
+ default:
+ return -1;
+ }
+ dst += (i + 1) / 2;
+
+ if (check_padding) {
+ /* Check remaining padding characters */
+ if (ch != '=')
+ return -1;
+
+ /* One down, 8 - i - 1 more to come... */
+ for (i = 8 - i - 1; i > 0; i--) {
+
+ do {
+ if (src_sz == 0)
+ return -1;
+ ch = *src++;
+ src_sz--;
+
+ } while (isspace(ch));
+
+ if (ch != '=')
+ return -1;
+ }
+ }
+ }
+ return dst - start;
+}
+
+int
+sldns_b32_pton(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz)
+{
+ return sldns_b32_pton_base(src, src_sz, dst, dst_sz, 0, 1);
+}
+
+int
+sldns_b32_pton_extended_hex(const char* src, size_t src_sz,
+ uint8_t* dst, size_t dst_sz)
+{
+ return sldns_b32_pton_base(src, src_sz, dst, dst_sz, 1, 1);
+}
+
+size_t sldns_b64_ntop_calculate_size(size_t srcsize)
+{
+ return ((((srcsize + 2) / 3) * 4) + 1);
+}
+
+/* RFC 1521, section 5.2.
+ *
+ * The encoding process represents 24-bit groups of input bits as output
+ * strings of 4 encoded characters. Proceeding from left to right, a
+ * 24-bit input group is formed by concatenating 3 8-bit input groups.
+ * These 24 bits are then treated as 4 concatenated 6-bit groups, each
+ * of which is translated into a single digit in the base64 alphabet.
+ *
+ * This routine does not insert spaces or linebreaks after 76 characters.
+ */
+int sldns_b64_ntop(uint8_t const *src, size_t srclength,
+ char *target, size_t targsize)
+{
+ const char* b64 =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ const char pad64 = '=';
+ size_t i = 0, o = 0;
+ if(targsize < sldns_b64_ntop_calculate_size(srclength))
+ return -1;
+ /* whole chunks: xxxxxxyy yyyyzzzz zzwwwwww */
+ while(i+3 <= srclength) {
+ if(o+4 > targsize) return -1;
+ target[o] = b64[src[i] >> 2];
+ target[o+1] = b64[ ((src[i]&0x03)<<4) | (src[i+1]>>4) ];
+ target[o+2] = b64[ ((src[i+1]&0x0f)<<2) | (src[i+2]>>6) ];
+ target[o+3] = b64[ (src[i+2]&0x3f) ];
+ i += 3;
+ o += 4;
+ }
+ /* remainder */
+ switch(srclength - i) {
+ case 2:
+ /* two at end, converted into A B C = */
+ target[o] = b64[src[i] >> 2];
+ target[o+1] = b64[ ((src[i]&0x03)<<4) | (src[i+1]>>4) ];
+ target[o+2] = b64[ ((src[i+1]&0x0f)<<2) ];
+ target[o+3] = pad64;
+ i += 2;
+ o += 4;
+ break;
+ case 1:
+ /* one at end, converted into A B = = */
+ target[o] = b64[src[i] >> 2];
+ target[o+1] = b64[ ((src[i]&0x03)<<4) ];
+ target[o+2] = pad64;
+ target[o+3] = pad64;
+ i += 1;
+ o += 4;
+ break;
+ case 0:
+ default:
+ /* nothing */
+ break;
+ }
+ /* assert: i == srclength */
+ if(o+1 > targsize) return -1;
+ target[o] = 0;
+ return (int)o;
+}
+
+size_t sldns_b64_pton_calculate_size(size_t srcsize)
+{
+ return (((((srcsize + 3) / 4) * 3)) + 1);
+}
+
+int sldns_b64_pton(char const *src, uint8_t *target, size_t targsize)
+{
+ const uint8_t pad64 = 64; /* is 64th in the b64 array */
+ const char* s = src;
+ uint8_t in[4];
+ size_t o = 0, incount = 0;
+
+ while(*s) {
+ /* skip any character that is not base64 */
+ /* conceptually we do:
+ const char* b64 = pad'=' is appended to array
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
+ const char* d = strchr(b64, *s++);
+ and use d-b64;
+ */
+ char d = *s++;
+ if(d <= 'Z' && d >= 'A')
+ d -= 'A';
+ else if(d <= 'z' && d >= 'a')
+ d = d - 'a' + 26;
+ else if(d <= '9' && d >= '0')
+ d = d - '0' + 52;
+ else if(d == '+')
+ d = 62;
+ else if(d == '/')
+ d = 63;
+ else if(d == '=')
+ d = 64;
+ else continue;
+ in[incount++] = (uint8_t)d;
+ if(incount != 4)
+ continue;
+ /* process whole block of 4 characters into 3 output bytes */
+ if(in[3] == pad64 && in[2] == pad64) { /* A B = = */
+ if(o+1 > targsize)
+ return -1;
+ target[o] = (in[0]<<2) | ((in[1]&0x30)>>4);
+ o += 1;
+ break; /* we are done */
+ } else if(in[3] == pad64) { /* A B C = */
+ if(o+2 > targsize)
+ return -1;
+ target[o] = (in[0]<<2) | ((in[1]&0x30)>>4);
+ target[o+1]= ((in[1]&0x0f)<<4) | ((in[2]&0x3c)>>2);
+ o += 2;
+ break; /* we are done */
+ } else {
+ if(o+3 > targsize)
+ return -1;
+ /* write xxxxxxyy yyyyzzzz zzwwwwww */
+ target[o] = (in[0]<<2) | ((in[1]&0x30)>>4);
+ target[o+1]= ((in[1]&0x0f)<<4) | ((in[2]&0x3c)>>2);
+ target[o+2]= ((in[2]&0x03)<<6) | in[3];
+ o += 3;
+ }
+ incount = 0;
+ }
+ return (int)o;
+}
diff --git a/contrib/unbound/ldns/parseutil.h b/contrib/unbound/ldns/parseutil.h
new file mode 100644
index 0000000..dfa1c2a
--- /dev/null
+++ b/contrib/unbound/ldns/parseutil.h
@@ -0,0 +1,148 @@
+/*
+ * parseutil.h - parse utilities for string and wire conversion
+ *
+ * (c) NLnet Labs, 2004
+ *
+ * See the file LICENSE for the license
+ */
+/**
+ * \file
+ *
+ * Utility functions for parsing, base32(DNS variant) and base64 encoding
+ * and decoding, Hex, Time units, Escape codes.
+ */
+
+#ifndef LDNS_PARSEUTIL_H
+#define LDNS_PARSEUTIL_H
+struct tm;
+
+/**
+ * A general purpose lookup table
+ *
+ * Lookup tables are arrays of (id, name) pairs,
+ * So you can for instance lookup the RCODE 3, which is "NXDOMAIN",
+ * and vice versa. The lookup tables themselves are defined wherever needed,
+ * for instance in host2str.c
+ */
+struct sldns_struct_lookup_table {
+ int id;
+ const char *name;
+};
+typedef struct sldns_struct_lookup_table sldns_lookup_table;
+
+/**
+ * Looks up the table entry by name, returns NULL if not found.
+ * \param[in] table the lookup table to search in
+ * \param[in] name what to search for
+ * \return the item found
+ */
+sldns_lookup_table *sldns_lookup_by_name(sldns_lookup_table table[],
+ const char *name);
+/**
+ * Looks up the table entry by id, returns NULL if not found.
+ * \param[in] table the lookup table to search in
+ * \param[in] id what to search for
+ * \return the item found
+ */
+sldns_lookup_table *sldns_lookup_by_id(sldns_lookup_table table[], int id);
+
+/**
+ * Convert TM to seconds since epoch (midnight, January 1st, 1970).
+ * Like timegm(3), which is not always available.
+ * \param[in] tm a struct tm* with the date
+ * \return the seconds since epoch
+ */
+time_t sldns_mktime_from_utc(const struct tm *tm);
+
+/**
+ * The function interprets time as the number of seconds since epoch
+ * with respect to now using serial arithmitics (rfc1982).
+ * That number of seconds is then converted to broken-out time information.
+ * This is especially usefull when converting the inception and expiration
+ * fields of RRSIG records.
+ *
+ * \param[in] time number of seconds since epoch (midnight, January 1st, 1970)
+ * to be intepreted as a serial arithmitics number relative to now.
+ * \param[in] now number of seconds since epoch (midnight, January 1st, 1970)
+ * to which the time value is compared to determine the final value.
+ * \param[out] result the struct with the broken-out time information
+ * \return result on success or NULL on error
+ */
+struct tm * sldns_serial_arithmitics_gmtime_r(int32_t time, time_t now, struct tm *result);
+
+/**
+ * converts a ttl value (like 5d2h) to a long.
+ * \param[in] nptr the start of the string
+ * \param[out] endptr points to the last char in case of error
+ * \return the convert duration value
+ */
+uint32_t sldns_str2period(const char *nptr, const char **endptr);
+
+/**
+ * Returns the int value of the given (hex) digit
+ * \param[in] ch the hex char to convert
+ * \return the converted decimal value
+ */
+int sldns_hexdigit_to_int(char ch);
+
+/**
+ * calculates the size needed to store the result of b64_ntop
+ */
+size_t sldns_b64_ntop_calculate_size(size_t srcsize);
+
+int sldns_b64_ntop(uint8_t const *src, size_t srclength,
+ char *target, size_t targsize);
+
+/**
+ * calculates the size needed to store the result of sldns_b64_pton
+ */
+size_t sldns_b64_pton_calculate_size(size_t srcsize);
+
+int sldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
+
+/**
+ * calculates the size needed to store the result of b32_ntop
+ */
+size_t sldns_b32_ntop_calculate_size(size_t src_data_length);
+
+size_t sldns_b32_ntop_calculate_size_no_padding(size_t src_data_length);
+
+int sldns_b32_ntop(const uint8_t* src_data, size_t src_data_length,
+ char* target_text_buffer, size_t target_text_buffer_size);
+
+int sldns_b32_ntop_extended_hex(const uint8_t* src_data, size_t src_data_length,
+ char* target_text_buffer, size_t target_text_buffer_size);
+
+/**
+ * calculates the size needed to store the result of b32_pton
+ */
+size_t sldns_b32_pton_calculate_size(size_t src_text_length);
+
+int sldns_b32_pton(const char* src_text, size_t src_text_length,
+ uint8_t* target_data_buffer, size_t target_data_buffer_size);
+
+int sldns_b32_pton_extended_hex(const char* src_text, size_t src_text_length,
+ uint8_t* target_data_buffer, size_t target_data_buffer_size);
+
+/*
+ * Checks whether the escaped value at **s is an octal value or
+ * a 'normally' escaped character (and not eos)
+ *
+ * @param ch_p: the parsed character
+ * @param str_p: the string. moved along for characters read.
+ * The string pointer at *s is increased by either 0 (on error), 1 (on
+ * normal escapes), or 3 (on octals)
+ *
+ * @return 0 on error
+ */
+int sldns_parse_escape(uint8_t *ch_p, const char** str_p);
+
+/**
+ * Parse one character, with escape codes,
+ * @param ch_p: the parsed character
+ * @param str_p: the string. moved along for characters read.
+ * @return 0 on error
+ */
+int sldns_parse_char(uint8_t *ch_p, const char** str_p);
+
+#endif /* LDNS_PARSEUTIL_H */
diff --git a/contrib/unbound/ldns/pkthdr.h b/contrib/unbound/ldns/pkthdr.h
new file mode 100644
index 0000000..de9952e
--- /dev/null
+++ b/contrib/unbound/ldns/pkthdr.h
@@ -0,0 +1,158 @@
+/*
+ * pkthdr.h - packet header from wire conversion routines
+ *
+ * a Net::DNS like library for C
+ *
+ * (c) NLnet Labs, 2005-2006
+ *
+ * See the file LICENSE for the license
+ */
+
+/**
+ * \file
+ *
+ * Contains functions that translate dns data from the wire format (as sent
+ * by servers and clients) to the internal structures for the packet header.
+ */
+
+#ifndef LDNS_PKTHDR_H
+#define LDNS_PKTHDR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The length of the header */
+#define LDNS_HEADER_SIZE 12
+
+/* First octet of flags */
+#define LDNS_RD_MASK 0x01U
+#define LDNS_RD_SHIFT 0
+#define LDNS_RD_WIRE(wirebuf) (*(wirebuf+2) & LDNS_RD_MASK)
+#define LDNS_RD_SET(wirebuf) (*(wirebuf+2) |= LDNS_RD_MASK)
+#define LDNS_RD_CLR(wirebuf) (*(wirebuf+2) &= ~LDNS_RD_MASK)
+
+#define LDNS_TC_MASK 0x02U
+#define LDNS_TC_SHIFT 1
+#define LDNS_TC_WIRE(wirebuf) (*(wirebuf+2) & LDNS_TC_MASK)
+#define LDNS_TC_SET(wirebuf) (*(wirebuf+2) |= LDNS_TC_MASK)
+#define LDNS_TC_CLR(wirebuf) (*(wirebuf+2) &= ~LDNS_TC_MASK)
+
+#define LDNS_AA_MASK 0x04U
+#define LDNS_AA_SHIFT 2
+#define LDNS_AA_WIRE(wirebuf) (*(wirebuf+2) & LDNS_AA_MASK)
+#define LDNS_AA_SET(wirebuf) (*(wirebuf+2) |= LDNS_AA_MASK)
+#define LDNS_AA_CLR(wirebuf) (*(wirebuf+2) &= ~LDNS_AA_MASK)
+
+#define LDNS_OPCODE_MASK 0x78U
+#define LDNS_OPCODE_SHIFT 3
+#define LDNS_OPCODE_WIRE(wirebuf) ((*(wirebuf+2) & LDNS_OPCODE_MASK) >> LDNS_OPCODE_SHIFT)
+#define LDNS_OPCODE_SET(wirebuf, opcode) \
+ (*(wirebuf+2) = ((*(wirebuf+2)) & ~LDNS_OPCODE_MASK) | ((opcode) << LDNS_OPCODE_SHIFT))
+
+#define LDNS_QR_MASK 0x80U
+#define LDNS_QR_SHIFT 7
+#define LDNS_QR_WIRE(wirebuf) (*(wirebuf+2) & LDNS_QR_MASK)
+#define LDNS_QR_SET(wirebuf) (*(wirebuf+2) |= LDNS_QR_MASK)
+#define LDNS_QR_CLR(wirebuf) (*(wirebuf+2) &= ~LDNS_QR_MASK)
+
+/* Second octet of flags */
+#define LDNS_RCODE_MASK 0x0fU
+#define LDNS_RCODE_SHIFT 0
+#define LDNS_RCODE_WIRE(wirebuf) (*(wirebuf+3) & LDNS_RCODE_MASK)
+#define LDNS_RCODE_SET(wirebuf, rcode) \
+ (*(wirebuf+3) = ((*(wirebuf+3)) & ~LDNS_RCODE_MASK) | (rcode))
+
+#define LDNS_CD_MASK 0x10U
+#define LDNS_CD_SHIFT 4
+#define LDNS_CD_WIRE(wirebuf) (*(wirebuf+3) & LDNS_CD_MASK)
+#define LDNS_CD_SET(wirebuf) (*(wirebuf+3) |= LDNS_CD_MASK)
+#define LDNS_CD_CLR(wirebuf) (*(wirebuf+3) &= ~LDNS_CD_MASK)
+
+#define LDNS_AD_MASK 0x20U
+#define LDNS_AD_SHIFT 5
+#define LDNS_AD_WIRE(wirebuf) (*(wirebuf+3) & LDNS_AD_MASK)
+#define LDNS_AD_SET(wirebuf) (*(wirebuf+3) |= LDNS_AD_MASK)
+#define LDNS_AD_CLR(wirebuf) (*(wirebuf+3) &= ~LDNS_AD_MASK)
+
+#define LDNS_Z_MASK 0x40U
+#define LDNS_Z_SHIFT 6
+#define LDNS_Z_WIRE(wirebuf) (*(wirebuf+3) & LDNS_Z_MASK)
+#define LDNS_Z_SET(wirebuf) (*(wirebuf+3) |= LDNS_Z_MASK)
+#define LDNS_Z_CLR(wirebuf) (*(wirebuf+3) &= ~LDNS_Z_MASK)
+
+#define LDNS_RA_MASK 0x80U
+#define LDNS_RA_SHIFT 7
+#define LDNS_RA_WIRE(wirebuf) (*(wirebuf+3) & LDNS_RA_MASK)
+#define LDNS_RA_SET(wirebuf) (*(wirebuf+3) |= LDNS_RA_MASK)
+#define LDNS_RA_CLR(wirebuf) (*(wirebuf+3) &= ~LDNS_RA_MASK)
+
+/* Query ID */
+#define LDNS_ID_WIRE(wirebuf) (sldns_read_uint16(wirebuf))
+#define LDNS_ID_SET(wirebuf, id) (sldns_write_uint16(wirebuf, id))
+
+/* Counter of the question section */
+#define LDNS_QDCOUNT_OFF 4
+/*
+#define QDCOUNT(wirebuf) (ntohs(*(uint16_t *)(wirebuf+QDCOUNT_OFF)))
+*/
+#define LDNS_QDCOUNT(wirebuf) (sldns_read_uint16(wirebuf+LDNS_QDCOUNT_OFF))
+
+/* Counter of the answer section */
+#define LDNS_ANCOUNT_OFF 6
+#define LDNS_ANCOUNT(wirebuf) (sldns_read_uint16(wirebuf+LDNS_ANCOUNT_OFF))
+
+/* Counter of the authority section */
+#define LDNS_NSCOUNT_OFF 8
+#define LDNS_NSCOUNT(wirebuf) (sldns_read_uint16(wirebuf+LDNS_NSCOUNT_OFF))
+
+/* Counter of the additional section */
+#define LDNS_ARCOUNT_OFF 10
+#define LDNS_ARCOUNT(wirebuf) (sldns_read_uint16(wirebuf+LDNS_ARCOUNT_OFF))
+
+/**
+ * The sections of a packet
+ */
+enum sldns_enum_pkt_section {
+ LDNS_SECTION_QUESTION = 0,
+ LDNS_SECTION_ANSWER = 1,
+ LDNS_SECTION_AUTHORITY = 2,
+ LDNS_SECTION_ADDITIONAL = 3,
+ /** bogus section, if not interested */
+ LDNS_SECTION_ANY = 4,
+ /** used to get all non-question rrs from a packet */
+ LDNS_SECTION_ANY_NOQUESTION = 5
+};
+typedef enum sldns_enum_pkt_section sldns_pkt_section;
+
+/* opcodes for pkt's */
+enum sldns_enum_pkt_opcode {
+ LDNS_PACKET_QUERY = 0,
+ LDNS_PACKET_IQUERY = 1,
+ LDNS_PACKET_STATUS = 2, /* there is no 3?? DNS is weird */
+ LDNS_PACKET_NOTIFY = 4,
+ LDNS_PACKET_UPDATE = 5
+};
+typedef enum sldns_enum_pkt_opcode sldns_pkt_opcode;
+
+/* rcodes for pkts */
+enum sldns_enum_pkt_rcode {
+ LDNS_RCODE_NOERROR = 0,
+ LDNS_RCODE_FORMERR = 1,
+ LDNS_RCODE_SERVFAIL = 2,
+ LDNS_RCODE_NXDOMAIN = 3,
+ LDNS_RCODE_NOTIMPL = 4,
+ LDNS_RCODE_REFUSED = 5,
+ LDNS_RCODE_YXDOMAIN = 6,
+ LDNS_RCODE_YXRRSET = 7,
+ LDNS_RCODE_NXRRSET = 8,
+ LDNS_RCODE_NOTAUTH = 9,
+ LDNS_RCODE_NOTZONE = 10
+};
+typedef enum sldns_enum_pkt_rcode sldns_pkt_rcode;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDNS_PKTHDR_H */
diff --git a/contrib/unbound/ldns/rrdef.c b/contrib/unbound/ldns/rrdef.c
new file mode 100644
index 0000000..8f7dd30
--- /dev/null
+++ b/contrib/unbound/ldns/rrdef.c
@@ -0,0 +1,738 @@
+/* rrdef.c
+ *
+ * access functions to rr definitions list.
+ * a Net::DNS like library for C
+ * LibDNS Team @ NLnet Labs
+ *
+ * (c) NLnet Labs, 2004-2006
+ * See the file LICENSE for the license
+ */
+/**
+ * \file
+ *
+ * Defines resource record types and constants.
+ */
+#include "config.h"
+#include "ldns/rrdef.h"
+#include "ldns/parseutil.h"
+
+/* classes */
+static sldns_lookup_table sldns_rr_classes_data[] = {
+ { LDNS_RR_CLASS_IN, "IN" },
+ { LDNS_RR_CLASS_CH, "CH" },
+ { LDNS_RR_CLASS_HS, "HS" },
+ { LDNS_RR_CLASS_NONE, "NONE" },
+ { LDNS_RR_CLASS_ANY, "ANY" },
+ { 0, NULL }
+};
+sldns_lookup_table* sldns_rr_classes = sldns_rr_classes_data;
+
+/* types */
+static const sldns_rdf_type type_0_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
+static const sldns_rdf_type type_a_wireformat[] = { LDNS_RDF_TYPE_A };
+static const sldns_rdf_type type_ns_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_md_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_mf_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_cname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_soa_wireformat[] = {
+ LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_INT32,
+ LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD, LDNS_RDF_TYPE_PERIOD,
+ LDNS_RDF_TYPE_PERIOD
+};
+static const sldns_rdf_type type_mb_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_mg_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_mr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_wks_wireformat[] = {
+ LDNS_RDF_TYPE_A, LDNS_RDF_TYPE_WKS
+};
+static const sldns_rdf_type type_ptr_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_hinfo_wireformat[] = {
+ LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR
+};
+static const sldns_rdf_type type_minfo_wireformat[] = {
+ LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_mx_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_rp_wireformat[] = {
+ LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_afsdb_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_x25_wireformat[] = { LDNS_RDF_TYPE_STR };
+static const sldns_rdf_type type_isdn_wireformat[] = {
+ LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR
+};
+static const sldns_rdf_type type_rt_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_nsap_wireformat[] = {
+ LDNS_RDF_TYPE_NSAP
+};
+static const sldns_rdf_type type_nsap_ptr_wireformat[] = {
+ LDNS_RDF_TYPE_STR
+};
+static const sldns_rdf_type type_sig_wireformat[] = {
+ LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT32,
+ LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_B64
+};
+static const sldns_rdf_type type_key_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_B64
+};
+static const sldns_rdf_type type_px_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_gpos_wireformat[] = {
+ LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR
+};
+static const sldns_rdf_type type_aaaa_wireformat[] = { LDNS_RDF_TYPE_AAAA };
+static const sldns_rdf_type type_loc_wireformat[] = { LDNS_RDF_TYPE_LOC };
+static const sldns_rdf_type type_nxt_wireformat[] = {
+ LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_UNKNOWN
+};
+static const sldns_rdf_type type_eid_wireformat[] = {
+ LDNS_RDF_TYPE_HEX
+};
+static const sldns_rdf_type type_nimloc_wireformat[] = {
+ LDNS_RDF_TYPE_HEX
+};
+static const sldns_rdf_type type_srv_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_atma_wireformat[] = {
+ LDNS_RDF_TYPE_ATMA
+};
+static const sldns_rdf_type type_naptr_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_STR, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_kx_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_cert_wireformat[] = {
+ LDNS_RDF_TYPE_CERT_ALG, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_B64
+};
+static const sldns_rdf_type type_a6_wireformat[] = { LDNS_RDF_TYPE_UNKNOWN };
+static const sldns_rdf_type type_dname_wireformat[] = { LDNS_RDF_TYPE_DNAME };
+static const sldns_rdf_type type_sink_wireformat[] = { LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_B64
+};
+static const sldns_rdf_type type_apl_wireformat[] = {
+ LDNS_RDF_TYPE_APL
+};
+static const sldns_rdf_type type_ds_wireformat[] = {
+ LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX
+};
+static const sldns_rdf_type type_sshfp_wireformat[] = {
+ LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_HEX
+};
+static const sldns_rdf_type type_ipseckey_wireformat[] = {
+ LDNS_RDF_TYPE_IPSECKEY
+};
+static const sldns_rdf_type type_rrsig_wireformat[] = {
+ LDNS_RDF_TYPE_TYPE, LDNS_RDF_TYPE_ALG, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT32,
+ LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_TIME, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_B64
+};
+static const sldns_rdf_type type_nsec_wireformat[] = {
+ LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_NSEC
+};
+static const sldns_rdf_type type_dhcid_wireformat[] = {
+ LDNS_RDF_TYPE_B64
+};
+static const sldns_rdf_type type_talink_wireformat[] = {
+ LDNS_RDF_TYPE_DNAME, LDNS_RDF_TYPE_DNAME
+};
+/* nsec3 is some vars, followed by same type of data of nsec */
+static const sldns_rdf_type type_nsec3_wireformat[] = {
+/* LDNS_RDF_TYPE_NSEC3_VARS, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC*/
+ LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT8, LDNS_RDF_TYPE_INT16, LDNS_RDF_TYPE_NSEC3_SALT, LDNS_RDF_TYPE_NSEC3_NEXT_OWNER, LDNS_RDF_TYPE_NSEC
+};
+
+static const sldns_rdf_type type_nsec3param_wireformat[] = {
+/* LDNS_RDF_TYPE_NSEC3_PARAMS_VARS*/
+ LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_NSEC3_SALT
+};
+
+static const sldns_rdf_type type_dnskey_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_ALG,
+ LDNS_RDF_TYPE_B64
+};
+static const sldns_rdf_type type_tkey_wireformat[] = {
+ LDNS_RDF_TYPE_DNAME,
+ LDNS_RDF_TYPE_TIME,
+ LDNS_RDF_TYPE_TIME,
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_INT16_DATA,
+ LDNS_RDF_TYPE_INT16_DATA,
+};
+static const sldns_rdf_type type_tsig_wireformat[] = {
+ LDNS_RDF_TYPE_DNAME,
+ LDNS_RDF_TYPE_TSIGTIME,
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_INT16_DATA,
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_INT16_DATA
+};
+static const sldns_rdf_type type_tlsa_wireformat[] = {
+ LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_HEX
+};
+static const sldns_rdf_type type_hip_wireformat[] = {
+ LDNS_RDF_TYPE_HIP
+};
+static const sldns_rdf_type type_nid_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_ILNP64
+};
+static const sldns_rdf_type type_l32_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_A
+};
+static const sldns_rdf_type type_l64_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_ILNP64
+};
+static const sldns_rdf_type type_lp_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_DNAME
+};
+static const sldns_rdf_type type_eui48_wireformat[] = {
+ LDNS_RDF_TYPE_EUI48
+};
+static const sldns_rdf_type type_eui64_wireformat[] = {
+ LDNS_RDF_TYPE_EUI64
+};
+#ifdef DRAFT_RRTYPES
+static const sldns_rdf_type type_uri_wireformat[] = {
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_INT16,
+ LDNS_RDF_TYPE_LONG_STR
+};
+#endif
+static const sldns_rdf_type type_caa_wireformat[] = {
+ LDNS_RDF_TYPE_INT8,
+ LDNS_RDF_TYPE_TAG,
+ LDNS_RDF_TYPE_LONG_STR
+};
+
+/* All RR's defined in 1035 are well known and can thus
+ * be compressed. See RFC3597. These RR's are:
+ * CNAME HINFO MB MD MF MG MINFO MR MX NULL NS PTR SOA TXT
+ */
+static sldns_rr_descriptor rdata_field_descriptors[] = {
+ /* 0 */
+ { 0, NULL, 0, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 1 */
+ {LDNS_RR_TYPE_A, "A", 1, 1, type_a_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 2 */
+ {LDNS_RR_TYPE_NS, "NS", 1, 1, type_ns_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 3 */
+ {LDNS_RR_TYPE_MD, "MD", 1, 1, type_md_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 4 */
+ {LDNS_RR_TYPE_MF, "MF", 1, 1, type_mf_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 5 */
+ {LDNS_RR_TYPE_CNAME, "CNAME", 1, 1, type_cname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 6 */
+ {LDNS_RR_TYPE_SOA, "SOA", 7, 7, type_soa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
+ /* 7 */
+ {LDNS_RR_TYPE_MB, "MB", 1, 1, type_mb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 8 */
+ {LDNS_RR_TYPE_MG, "MG", 1, 1, type_mg_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 9 */
+ {LDNS_RR_TYPE_MR, "MR", 1, 1, type_mr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 10 */
+ {LDNS_RR_TYPE_NULL, "NULL", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 11 */
+ {LDNS_RR_TYPE_WKS, "WKS", 2, 2, type_wks_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 12 */
+ {LDNS_RR_TYPE_PTR, "PTR", 1, 1, type_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 13 */
+ {LDNS_RR_TYPE_HINFO, "HINFO", 2, 2, type_hinfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 14 */
+ {LDNS_RR_TYPE_MINFO, "MINFO", 2, 2, type_minfo_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 2 },
+ /* 15 */
+ {LDNS_RR_TYPE_MX, "MX", 2, 2, type_mx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_COMPRESS, 1 },
+ /* 16 */
+ {LDNS_RR_TYPE_TXT, "TXT", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
+ /* 17 */
+ {LDNS_RR_TYPE_RP, "RP", 2, 2, type_rp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
+ /* 18 */
+ {LDNS_RR_TYPE_AFSDB, "AFSDB", 2, 2, type_afsdb_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 19 */
+ {LDNS_RR_TYPE_X25, "X25", 1, 1, type_x25_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 20 */
+ {LDNS_RR_TYPE_ISDN, "ISDN", 1, 2, type_isdn_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 21 */
+ {LDNS_RR_TYPE_RT, "RT", 2, 2, type_rt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 22 */
+ {LDNS_RR_TYPE_NSAP, "NSAP", 1, 1, type_nsap_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 23 */
+ {LDNS_RR_TYPE_NSAP_PTR, "NSAP-PTR", 1, 1, type_nsap_ptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 24 */
+ {LDNS_RR_TYPE_SIG, "SIG", 9, 9, type_sig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 25 */
+ {LDNS_RR_TYPE_KEY, "KEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 26 */
+ {LDNS_RR_TYPE_PX, "PX", 3, 3, type_px_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
+ /* 27 */
+ {LDNS_RR_TYPE_GPOS, "GPOS", 3, 3, type_gpos_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 28 */
+ {LDNS_RR_TYPE_AAAA, "AAAA", 1, 1, type_aaaa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 29 */
+ {LDNS_RR_TYPE_LOC, "LOC", 1, 1, type_loc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 30 */
+ {LDNS_RR_TYPE_NXT, "NXT", 2, 2, type_nxt_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 31 */
+ {LDNS_RR_TYPE_EID, "EID", 1, 1, type_eid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 32 */
+ {LDNS_RR_TYPE_NIMLOC, "NIMLOC", 1, 1, type_nimloc_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 33 */
+ {LDNS_RR_TYPE_SRV, "SRV", 4, 4, type_srv_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 34 */
+ {LDNS_RR_TYPE_ATMA, "ATMA", 1, 1, type_atma_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 35 */
+ {LDNS_RR_TYPE_NAPTR, "NAPTR", 6, 6, type_naptr_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 36 */
+ {LDNS_RR_TYPE_KX, "KX", 2, 2, type_kx_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 37 */
+ {LDNS_RR_TYPE_CERT, "CERT", 4, 4, type_cert_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 38 */
+ {LDNS_RR_TYPE_A6, "A6", 1, 1, type_a6_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 39 */
+ {LDNS_RR_TYPE_DNAME, "DNAME", 1, 1, type_dname_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 40 */
+ {LDNS_RR_TYPE_SINK, "SINK", 1, 1, type_sink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 41 */
+ {LDNS_RR_TYPE_OPT, "OPT", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 42 */
+ {LDNS_RR_TYPE_APL, "APL", 0, 0, type_apl_wireformat, LDNS_RDF_TYPE_APL, LDNS_RR_NO_COMPRESS, 0 },
+ /* 43 */
+ {LDNS_RR_TYPE_DS, "DS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 44 */
+ {LDNS_RR_TYPE_SSHFP, "SSHFP", 3, 3, type_sshfp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 45 */
+ {LDNS_RR_TYPE_IPSECKEY, "IPSECKEY", 1, 1, type_ipseckey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 46 */
+ {LDNS_RR_TYPE_RRSIG, "RRSIG", 9, 9, type_rrsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 47 */
+ {LDNS_RR_TYPE_NSEC, "NSEC", 1, 2, type_nsec_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* 48 */
+ {LDNS_RR_TYPE_DNSKEY, "DNSKEY", 4, 4, type_dnskey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 49 */
+ {LDNS_RR_TYPE_DHCID, "DHCID", 1, 1, type_dhcid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 50 */
+ {LDNS_RR_TYPE_NSEC3, "NSEC3", 5, 6, type_nsec3_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 51 */
+ {LDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAM", 4, 4, type_nsec3param_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 52 */
+ {LDNS_RR_TYPE_TLSA, "TLSA", 4, 4, type_tlsa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+
+{LDNS_RR_TYPE_NULL, "TYPE53", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE54", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 55
+ * Hip ends with 0 or more Rendezvous Servers represented as dname's.
+ * Hence the LDNS_RDF_TYPE_DNAME _variable field and the _maximum field
+ * set to 0.
+ */
+ {LDNS_RR_TYPE_HIP, "HIP", 1, 1, type_hip_wireformat, LDNS_RDF_TYPE_DNAME, LDNS_RR_NO_COMPRESS, 0 },
+
+#ifdef DRAFT_RRTYPES
+ /* 56 */
+ {LDNS_RR_TYPE_NINFO, "NINFO", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
+ /* 57 */
+ {LDNS_RR_TYPE_RKEY, "RKEY", 4, 4, type_key_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#else
+{LDNS_RR_TYPE_NULL, "TYPE56", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE57", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#endif
+ /* 58 */
+ {LDNS_RR_TYPE_TALINK, "TALINK", 2, 2, type_talink_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 2 },
+
+#ifdef DRAFT_RRTYPES
+ /* 59 */
+ {LDNS_RR_TYPE_CDS, "CDS", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#else
+{LDNS_RR_TYPE_NULL, "TYPE59", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#endif
+
+{LDNS_RR_TYPE_NULL, "TYPE60", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE61", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE62", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE63", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE64", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE65", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE66", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE67", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE68", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE69", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE70", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE71", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE72", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE73", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE74", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE75", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE76", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE77", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE78", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE79", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE80", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE81", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE82", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE83", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE84", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE85", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE86", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE87", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE88", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE89", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE90", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE91", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE92", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE93", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE94", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE95", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE96", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE97", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE98", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+
+ /* 99 */
+ {LDNS_RR_TYPE_SPF, "SPF", 1, 0, NULL, LDNS_RDF_TYPE_STR, LDNS_RR_NO_COMPRESS, 0 },
+
+ /* UINFO [IANA-Reserved] */
+{LDNS_RR_TYPE_NULL, "TYPE100", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* UID [IANA-Reserved] */
+{LDNS_RR_TYPE_NULL, "TYPE101", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* GID [IANA-Reserved] */
+{LDNS_RR_TYPE_NULL, "TYPE102", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* UNSPEC [IANA-Reserved] */
+{LDNS_RR_TYPE_NULL, "TYPE103", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+
+ /* 104 */
+ {LDNS_RR_TYPE_NID, "NID", 2, 2, type_nid_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 105 */
+ {LDNS_RR_TYPE_L32, "L32", 2, 2, type_l32_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 106 */
+ {LDNS_RR_TYPE_L64, "L64", 2, 2, type_l64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 107 */
+ {LDNS_RR_TYPE_LP, "LP", 2, 2, type_lp_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+
+ /* 108 */
+ {LDNS_RR_TYPE_EUI48, "EUI48", 1, 1, type_eui48_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* 109 */
+ {LDNS_RR_TYPE_EUI64, "EUI64", 1, 1, type_eui64_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+
+{LDNS_RR_TYPE_NULL, "TYPE110", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE111", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE112", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE113", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE114", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE115", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE116", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE117", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE118", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE119", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE120", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE121", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE122", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE123", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE124", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE125", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE126", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE127", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE128", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE129", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE130", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE131", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE132", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE133", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE134", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE135", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE136", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE137", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE138", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE139", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE140", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE141", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE142", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE143", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE144", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE145", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE146", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE147", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE148", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE149", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE150", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE151", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE152", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE153", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE154", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE155", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE156", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE157", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE158", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE159", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE160", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE161", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE162", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE163", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE164", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE165", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE166", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE167", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE168", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE169", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE170", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE171", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE172", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE173", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE174", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE175", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE176", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE177", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE178", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE179", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE180", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE181", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE182", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE183", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE184", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE185", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE186", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE187", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE188", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE189", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE190", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE191", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE192", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE193", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE194", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE195", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE196", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE197", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE198", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE199", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE200", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE201", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE202", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE203", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE204", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE205", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE206", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE207", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE208", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE209", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE210", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE211", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE212", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE213", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE214", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE215", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE216", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE217", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE218", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE219", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE220", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE221", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE222", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE223", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE224", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE225", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE226", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE227", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE228", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE229", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE230", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE231", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE232", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE233", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE234", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE235", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE236", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE237", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE238", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE239", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE240", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE241", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE242", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE243", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE244", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE245", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE246", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE247", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+{LDNS_RR_TYPE_NULL, "TYPE248", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+
+ /* LDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one.
+ * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9.
+ */
+ /* 249 */
+ {LDNS_RR_TYPE_TKEY, "TKEY", 7, 7, type_tkey_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+ /* LDNS_RDF_TYPE_INT16_DATA takes two fields (length and data) as one.
+ * So, unlike RFC 2930 spec, we have 7 min/max rdf's i.s.o. 8/9.
+ */
+ /* 250 */
+ {LDNS_RR_TYPE_TSIG, "TSIG", 7, 7, type_tsig_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 1 },
+
+ /* IXFR: A request for a transfer of an incremental zone transfer */
+{LDNS_RR_TYPE_IXFR, "IXFR", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* AXFR: A request for a transfer of an entire zone */
+{LDNS_RR_TYPE_AXFR, "AXFR", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* MAILB: A request for mailbox-related records (MB, MG or MR) */
+{LDNS_RR_TYPE_MAILB, "MAILB", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* MAILA: A request for mail agent RRs (Obsolete - see MX) */
+{LDNS_RR_TYPE_MAILA, "MAILA", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+ /* ANY: A request for all (available) records */
+{LDNS_RR_TYPE_ANY, "ANY", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+
+#ifdef DRAFT_RRTYPES
+ /* 256 */
+ {LDNS_RR_TYPE_URI, "URI", 3, 3, type_uri_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#else
+{LDNS_RR_TYPE_NULL, "TYPE256", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#endif
+ /* 257 */
+ {LDNS_RR_TYPE_CAA, "CAA", 3, 3, type_caa_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+
+/* split in array, no longer contiguous */
+
+#ifdef DRAFT_RRTYPES
+ /* 32768 */
+ {LDNS_RR_TYPE_TA, "TA", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#else
+{LDNS_RR_TYPE_NULL, "TYPE32768", 1, 1, type_0_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 },
+#endif
+ /* 32769 */
+ {LDNS_RR_TYPE_DLV, "DLV", 4, 4, type_ds_wireformat, LDNS_RDF_TYPE_NONE, LDNS_RR_NO_COMPRESS, 0 }
+};
+
+/**
+ * \def LDNS_RDATA_FIELD_DESCRIPTORS_COUNT
+ * computes the number of rdata fields
+ */
+#define LDNS_RDATA_FIELD_DESCRIPTORS_COUNT \
+ (sizeof(rdata_field_descriptors)/sizeof(rdata_field_descriptors[0]))
+
+const sldns_rr_descriptor *
+sldns_rr_descript(uint16_t type)
+{
+ size_t i;
+ if (type < LDNS_RDATA_FIELD_DESCRIPTORS_COMMON) {
+ return &rdata_field_descriptors[type];
+ } else {
+ /* because not all array index equals type code */
+ for (i = LDNS_RDATA_FIELD_DESCRIPTORS_COMMON;
+ i < LDNS_RDATA_FIELD_DESCRIPTORS_COUNT;
+ i++) {
+ if (rdata_field_descriptors[i]._type == type) {
+ return &rdata_field_descriptors[i];
+ }
+ }
+ return &rdata_field_descriptors[0];
+ }
+}
+
+size_t
+sldns_rr_descriptor_minimum(const sldns_rr_descriptor *descriptor)
+{
+ if (descriptor) {
+ return descriptor->_minimum;
+ } else {
+ return 0;
+ }
+}
+
+size_t
+sldns_rr_descriptor_maximum(const sldns_rr_descriptor *descriptor)
+{
+ if (descriptor) {
+ if (descriptor->_variable != LDNS_RDF_TYPE_NONE) {
+ return 65535; /* cannot be more than 64k */
+ } else {
+ return descriptor->_maximum;
+ }
+ } else {
+ return 0;
+ }
+}
+
+sldns_rdf_type
+sldns_rr_descriptor_field_type(const sldns_rr_descriptor *descriptor,
+ size_t index)
+{
+ assert(descriptor != NULL);
+ assert(index < descriptor->_maximum
+ || descriptor->_variable != LDNS_RDF_TYPE_NONE);
+ if (index < descriptor->_maximum) {
+ return descriptor->_wireformat[index];
+ } else {
+ return descriptor->_variable;
+ }
+}
+
+sldns_rr_type
+sldns_get_rr_type_by_name(const char *name)
+{
+ unsigned int i;
+ const char *desc_name;
+ const sldns_rr_descriptor *desc;
+
+ /* TYPEXX representation */
+ if (strlen(name) > 4 && strncasecmp(name, "TYPE", 4) == 0) {
+ return atoi(name + 4);
+ }
+
+ /* Normal types */
+ for (i = 0; i < (unsigned int) LDNS_RDATA_FIELD_DESCRIPTORS_COUNT; i++) {
+ desc = &rdata_field_descriptors[i];
+ desc_name = desc->_name;
+ if(desc_name &&
+ strlen(name) == strlen(desc_name) &&
+ strncasecmp(name, desc_name, strlen(desc_name)) == 0) {
+ /* because not all array index equals type code */
+ return desc->_type;
+ }
+ }
+
+ /* special cases for query types */
+ if (strlen(name) == 4 && strncasecmp(name, "IXFR", 4) == 0) {
+ return 251;
+ } else if (strlen(name) == 4 && strncasecmp(name, "AXFR", 4) == 0) {
+ return 252;
+ } else if (strlen(name) == 5 && strncasecmp(name, "MAILB", 5) == 0) {
+ return 253;
+ } else if (strlen(name) == 5 && strncasecmp(name, "MAILA", 5) == 0) {
+ return 254;
+ } else if (strlen(name) == 3 && strncasecmp(name, "ANY", 3) == 0) {
+ return 255;
+ }
+
+ return 0;
+}
+
+sldns_rr_class
+sldns_get_rr_class_by_name(const char *name)
+{
+ sldns_lookup_table *lt;
+
+ /* CLASSXX representation */
+ if (strlen(name) > 5 && strncasecmp(name, "CLASS", 5) == 0) {
+ return atoi(name + 5);
+ }
+
+ /* Normal types */
+ lt = sldns_lookup_by_name(sldns_rr_classes, name);
+ if (lt) {
+ return lt->id;
+ }
+ return 0;
+}
diff --git a/contrib/unbound/ldns/rrdef.h b/contrib/unbound/ldns/rrdef.h
new file mode 100644
index 0000000..442eb26
--- /dev/null
+++ b/contrib/unbound/ldns/rrdef.h
@@ -0,0 +1,503 @@
+/*
+ * rrdef.h
+ *
+ * RR definitions
+ *
+ * a Net::DNS like library for C
+ *
+ * (c) NLnet Labs, 2005-2006
+ *
+ * See the file LICENSE for the license
+ */
+
+/**
+ * \file
+ *
+ * Defines resource record types and constants.
+ */
+
+#ifndef LDNS_RRDEF_H
+#define LDNS_RRDEF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Maximum length of a dname label */
+#define LDNS_MAX_LABELLEN 63
+/** Maximum length of a complete dname */
+#define LDNS_MAX_DOMAINLEN 255
+/** Maximum number of pointers in 1 dname */
+#define LDNS_MAX_POINTERS 65535
+/** The bytes TTL, CLASS and length use up in an rr */
+#define LDNS_RR_OVERHEAD 10
+
+#define LDNS_DNSSEC_KEYPROTO 3
+#define LDNS_KEY_ZONE_KEY 0x0100 /* set for ZSK&KSK, rfc 4034 */
+#define LDNS_KEY_SEP_KEY 0x0001 /* set for KSK, rfc 4034 */
+#define LDNS_KEY_REVOKE_KEY 0x0080 /* used to revoke KSK, rfc 5011 */
+
+/* The first fields are contiguous and can be referenced instantly */
+#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 258
+
+/** lookuptable for rr classes */
+extern struct sldns_struct_lookup_table* sldns_rr_classes;
+
+/**
+ * The different RR classes.
+ */
+enum sldns_enum_rr_class
+{
+ /** the Internet */
+ LDNS_RR_CLASS_IN = 1,
+ /** Chaos class */
+ LDNS_RR_CLASS_CH = 3,
+ /** Hesiod (Dyer 87) */
+ LDNS_RR_CLASS_HS = 4,
+ /** None class, dynamic update */
+ LDNS_RR_CLASS_NONE = 254,
+ /** Any class */
+ LDNS_RR_CLASS_ANY = 255,
+
+ LDNS_RR_CLASS_FIRST = 0,
+ LDNS_RR_CLASS_LAST = 65535,
+ LDNS_RR_CLASS_COUNT = LDNS_RR_CLASS_LAST - LDNS_RR_CLASS_FIRST + 1
+};
+typedef enum sldns_enum_rr_class sldns_rr_class;
+
+/**
+ * Used to specify whether compression is allowed.
+ */
+enum sldns_enum_rr_compress
+{
+ /** compression is allowed */
+ LDNS_RR_COMPRESS,
+ LDNS_RR_NO_COMPRESS
+};
+typedef enum sldns_enum_rr_compress sldns_rr_compress;
+
+/**
+ * The different RR types.
+ */
+enum sldns_enum_rr_type
+{
+ /** a host address */
+ LDNS_RR_TYPE_A = 1,
+ /** an authoritative name server */
+ LDNS_RR_TYPE_NS = 2,
+ /** a mail destination (Obsolete - use MX) */
+ LDNS_RR_TYPE_MD = 3,
+ /** a mail forwarder (Obsolete - use MX) */
+ LDNS_RR_TYPE_MF = 4,
+ /** the canonical name for an alias */
+ LDNS_RR_TYPE_CNAME = 5,
+ /** marks the start of a zone of authority */
+ LDNS_RR_TYPE_SOA = 6,
+ /** a mailbox domain name (EXPERIMENTAL) */
+ LDNS_RR_TYPE_MB = 7,
+ /** a mail group member (EXPERIMENTAL) */
+ LDNS_RR_TYPE_MG = 8,
+ /** a mail rename domain name (EXPERIMENTAL) */
+ LDNS_RR_TYPE_MR = 9,
+ /** a null RR (EXPERIMENTAL) */
+ LDNS_RR_TYPE_NULL = 10,
+ /** a well known service description */
+ LDNS_RR_TYPE_WKS = 11,
+ /** a domain name pointer */
+ LDNS_RR_TYPE_PTR = 12,
+ /** host information */
+ LDNS_RR_TYPE_HINFO = 13,
+ /** mailbox or mail list information */
+ LDNS_RR_TYPE_MINFO = 14,
+ /** mail exchange */
+ LDNS_RR_TYPE_MX = 15,
+ /** text strings */
+ LDNS_RR_TYPE_TXT = 16,
+ /** RFC1183 */
+ LDNS_RR_TYPE_RP = 17,
+ /** RFC1183 */
+ LDNS_RR_TYPE_AFSDB = 18,
+ /** RFC1183 */
+ LDNS_RR_TYPE_X25 = 19,
+ /** RFC1183 */
+ LDNS_RR_TYPE_ISDN = 20,
+ /** RFC1183 */
+ LDNS_RR_TYPE_RT = 21,
+ /** RFC1706 */
+ LDNS_RR_TYPE_NSAP = 22,
+ /** RFC1348 */
+ LDNS_RR_TYPE_NSAP_PTR = 23,
+ /** 2535typecode */
+ LDNS_RR_TYPE_SIG = 24,
+ /** 2535typecode */
+ LDNS_RR_TYPE_KEY = 25,
+ /** RFC2163 */
+ LDNS_RR_TYPE_PX = 26,
+ /** RFC1712 */
+ LDNS_RR_TYPE_GPOS = 27,
+ /** ipv6 address */
+ LDNS_RR_TYPE_AAAA = 28,
+ /** LOC record RFC1876 */
+ LDNS_RR_TYPE_LOC = 29,
+ /** 2535typecode */
+ LDNS_RR_TYPE_NXT = 30,
+ /** draft-ietf-nimrod-dns-01.txt */
+ LDNS_RR_TYPE_EID = 31,
+ /** draft-ietf-nimrod-dns-01.txt */
+ LDNS_RR_TYPE_NIMLOC = 32,
+ /** SRV record RFC2782 */
+ LDNS_RR_TYPE_SRV = 33,
+ /** http://www.jhsoft.com/rfc/af-saa-0069.000.rtf */
+ LDNS_RR_TYPE_ATMA = 34,
+ /** RFC2915 */
+ LDNS_RR_TYPE_NAPTR = 35,
+ /** RFC2230 */
+ LDNS_RR_TYPE_KX = 36,
+ /** RFC2538 */
+ LDNS_RR_TYPE_CERT = 37,
+ /** RFC2874 */
+ LDNS_RR_TYPE_A6 = 38,
+ /** RFC2672 */
+ LDNS_RR_TYPE_DNAME = 39,
+ /** dnsind-kitchen-sink-02.txt */
+ LDNS_RR_TYPE_SINK = 40,
+ /** Pseudo OPT record... */
+ LDNS_RR_TYPE_OPT = 41,
+ /** RFC3123 */
+ LDNS_RR_TYPE_APL = 42,
+ /** RFC4034, RFC3658 */
+ LDNS_RR_TYPE_DS = 43,
+ /** SSH Key Fingerprint */
+ LDNS_RR_TYPE_SSHFP = 44, /* RFC 4255 */
+ /** IPsec Key */
+ LDNS_RR_TYPE_IPSECKEY = 45, /* RFC 4025 */
+ /** DNSSEC */
+ LDNS_RR_TYPE_RRSIG = 46, /* RFC 4034 */
+ LDNS_RR_TYPE_NSEC = 47, /* RFC 4034 */
+ LDNS_RR_TYPE_DNSKEY = 48, /* RFC 4034 */
+
+ LDNS_RR_TYPE_DHCID = 49, /* RFC 4701 */
+ /* NSEC3 */
+ LDNS_RR_TYPE_NSEC3 = 50, /* RFC 5155 */
+ LDNS_RR_TYPE_NSEC3PARAM = 51, /* RFC 5155 */
+ LDNS_RR_TYPE_NSEC3PARAMS = 51,
+ LDNS_RR_TYPE_TLSA = 52, /* RFC 6698 */
+
+ LDNS_RR_TYPE_HIP = 55, /* RFC 5205 */
+
+ /** draft-reid-dnsext-zs */
+ LDNS_RR_TYPE_NINFO = 56,
+ /** draft-reid-dnsext-rkey */
+ LDNS_RR_TYPE_RKEY = 57,
+ /** draft-ietf-dnsop-trust-history */
+ LDNS_RR_TYPE_TALINK = 58,
+ /** draft-barwood-dnsop-ds-publis */
+ LDNS_RR_TYPE_CDS = 59,
+
+ LDNS_RR_TYPE_SPF = 99, /* RFC 4408 */
+
+ LDNS_RR_TYPE_UINFO = 100,
+ LDNS_RR_TYPE_UID = 101,
+ LDNS_RR_TYPE_GID = 102,
+ LDNS_RR_TYPE_UNSPEC = 103,
+
+ LDNS_RR_TYPE_NID = 104, /* RFC 6742 */
+ LDNS_RR_TYPE_L32 = 105, /* RFC 6742 */
+ LDNS_RR_TYPE_L64 = 106, /* RFC 6742 */
+ LDNS_RR_TYPE_LP = 107, /* RFC 6742 */
+
+ /** draft-jabley-dnsext-eui48-eui64-rrtypes */
+ LDNS_RR_TYPE_EUI48 = 108,
+ LDNS_RR_TYPE_EUI64 = 109,
+
+ LDNS_RR_TYPE_TKEY = 249, /* RFC 2930 */
+ LDNS_RR_TYPE_TSIG = 250,
+ LDNS_RR_TYPE_IXFR = 251,
+ LDNS_RR_TYPE_AXFR = 252,
+ /** A request for mailbox-related records (MB, MG or MR) */
+ LDNS_RR_TYPE_MAILB = 253,
+ /** A request for mail agent RRs (Obsolete - see MX) */
+ LDNS_RR_TYPE_MAILA = 254,
+ /** any type (wildcard) */
+ LDNS_RR_TYPE_ANY = 255,
+ /** draft-faltstrom-uri-06 */
+ LDNS_RR_TYPE_URI = 256,
+ LDNS_RR_TYPE_CAA = 257, /* RFC 6844 */
+
+ /** DNSSEC Trust Authorities */
+ LDNS_RR_TYPE_TA = 32768,
+ /* RFC 4431, 5074, DNSSEC Lookaside Validation */
+ LDNS_RR_TYPE_DLV = 32769,
+
+ /* type codes from nsec3 experimental phase
+ LDNS_RR_TYPE_NSEC3 = 65324,
+ LDNS_RR_TYPE_NSEC3PARAMS = 65325, */
+ LDNS_RR_TYPE_FIRST = 0,
+ LDNS_RR_TYPE_LAST = 65535,
+ LDNS_RR_TYPE_COUNT = LDNS_RR_TYPE_LAST - LDNS_RR_TYPE_FIRST + 1
+};
+typedef enum sldns_enum_rr_type sldns_rr_type;
+
+/* RDATA */
+#define LDNS_MAX_RDFLEN 65535
+
+#define LDNS_RDF_SIZE_BYTE 1
+#define LDNS_RDF_SIZE_WORD 2
+#define LDNS_RDF_SIZE_DOUBLEWORD 4
+#define LDNS_RDF_SIZE_6BYTES 6
+#define LDNS_RDF_SIZE_8BYTES 8
+#define LDNS_RDF_SIZE_16BYTES 16
+
+#define LDNS_NSEC3_VARS_OPTOUT_MASK 0x01
+
+#define LDNS_APL_IP4 1
+#define LDNS_APL_IP6 2
+#define LDNS_APL_MASK 0x7f
+#define LDNS_APL_NEGATION 0x80
+
+/**
+ * The different types of RDATA fields.
+ */
+enum sldns_enum_rdf_type
+{
+ /** none */
+ LDNS_RDF_TYPE_NONE,
+ /** domain name */
+ LDNS_RDF_TYPE_DNAME,
+ /** 8 bits */
+ LDNS_RDF_TYPE_INT8,
+ /** 16 bits */
+ LDNS_RDF_TYPE_INT16,
+ /** 32 bits */
+ LDNS_RDF_TYPE_INT32,
+ /** A record */
+ LDNS_RDF_TYPE_A,
+ /** AAAA record */
+ LDNS_RDF_TYPE_AAAA,
+ /** txt string */
+ LDNS_RDF_TYPE_STR,
+ /** apl data */
+ LDNS_RDF_TYPE_APL,
+ /** b32 string */
+ LDNS_RDF_TYPE_B32_EXT,
+ /** b64 string */
+ LDNS_RDF_TYPE_B64,
+ /** hex string */
+ LDNS_RDF_TYPE_HEX,
+ /** nsec type codes */
+ LDNS_RDF_TYPE_NSEC,
+ /** a RR type */
+ LDNS_RDF_TYPE_TYPE,
+ /** a class */
+ LDNS_RDF_TYPE_CLASS,
+ /** certificate algorithm */
+ LDNS_RDF_TYPE_CERT_ALG,
+ /** a key algorithm */
+ LDNS_RDF_TYPE_ALG,
+ /** unknown types */
+ LDNS_RDF_TYPE_UNKNOWN,
+ /** time (32 bits) */
+ LDNS_RDF_TYPE_TIME,
+ /** period */
+ LDNS_RDF_TYPE_PERIOD,
+ /** tsig time 48 bits */
+ LDNS_RDF_TYPE_TSIGTIME,
+ /** Represents the Public Key Algorithm, HIT and Public Key fields
+ for the HIP RR types. A HIP specific rdf type is used because of
+ the unusual layout in wireformat (see RFC 5205 Section 5) */
+ LDNS_RDF_TYPE_HIP,
+ /** variable length any type rdata where the length
+ is specified by the first 2 bytes */
+ LDNS_RDF_TYPE_INT16_DATA,
+ /** protocol and port bitmaps */
+ LDNS_RDF_TYPE_SERVICE,
+ /** location data */
+ LDNS_RDF_TYPE_LOC,
+ /** well known services */
+ LDNS_RDF_TYPE_WKS,
+ /** NSAP */
+ LDNS_RDF_TYPE_NSAP,
+ /** ATMA */
+ LDNS_RDF_TYPE_ATMA,
+ /** IPSECKEY */
+ LDNS_RDF_TYPE_IPSECKEY,
+ /** nsec3 hash salt */
+ LDNS_RDF_TYPE_NSEC3_SALT,
+ /** nsec3 base32 string (with length byte on wire */
+ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER,
+
+ /** 4 shorts represented as 4 * 16 bit hex numbers
+ * seperated by colons. For NID and L64.
+ */
+ LDNS_RDF_TYPE_ILNP64,
+
+ /** 6 * 8 bit hex numbers seperated by dashes. For EUI48. */
+ LDNS_RDF_TYPE_EUI48,
+ /** 8 * 8 bit hex numbers seperated by dashes. For EUI64. */
+ LDNS_RDF_TYPE_EUI64,
+
+ /** A non-zero sequence of US-ASCII letters and numbers in lower case.
+ * For CAA.
+ */
+ LDNS_RDF_TYPE_TAG,
+
+ /** A <character-string> encoding of the value field as specified
+ * [RFC1035], Section 5.1., encoded as remaining rdata.
+ * For CAA.
+ */
+ LDNS_RDF_TYPE_LONG_STR,
+
+ /* Aliases */
+ LDNS_RDF_TYPE_BITMAP = LDNS_RDF_TYPE_NSEC
+};
+typedef enum sldns_enum_rdf_type sldns_rdf_type;
+
+/**
+ * Algorithms used in dns
+ */
+enum sldns_enum_algorithm
+{
+ LDNS_RSAMD5 = 1, /* RFC 4034,4035 */
+ LDNS_DH = 2,
+ LDNS_DSA = 3,
+ LDNS_ECC = 4,
+ LDNS_RSASHA1 = 5,
+ LDNS_DSA_NSEC3 = 6,
+ LDNS_RSASHA1_NSEC3 = 7,
+ LDNS_RSASHA256 = 8, /* RFC 5702 */
+ LDNS_RSASHA512 = 10, /* RFC 5702 */
+ LDNS_ECC_GOST = 12, /* RFC 5933 */
+ LDNS_ECDSAP256SHA256 = 13, /* RFC 6605 */
+ LDNS_ECDSAP384SHA384 = 14, /* RFC 6605 */
+ LDNS_INDIRECT = 252,
+ LDNS_PRIVATEDNS = 253,
+ LDNS_PRIVATEOID = 254
+};
+typedef enum sldns_enum_algorithm sldns_algorithm;
+
+/**
+ * Hashing algorithms used in the DS record
+ */
+enum sldns_enum_hash
+{
+ LDNS_SHA1 = 1, /* RFC 4034 */
+ LDNS_SHA256 = 2, /* RFC 4509 */
+ LDNS_HASH_GOST = 3, /* RFC 5933 */
+ LDNS_SHA384 = 4 /* RFC 6605 */
+};
+typedef enum sldns_enum_hash sldns_hash;
+
+/**
+ * algorithms used in CERT rrs
+ */
+enum sldns_enum_cert_algorithm
+{
+ LDNS_CERT_PKIX = 1,
+ LDNS_CERT_SPKI = 2,
+ LDNS_CERT_PGP = 3,
+ LDNS_CERT_IPKIX = 4,
+ LDNS_CERT_ISPKI = 5,
+ LDNS_CERT_IPGP = 6,
+ LDNS_CERT_ACPKIX = 7,
+ LDNS_CERT_IACPKIX = 8,
+ LDNS_CERT_URI = 253,
+ LDNS_CERT_OID = 254
+};
+typedef enum sldns_enum_cert_algorithm sldns_cert_algorithm;
+
+/**
+ * EDNS option codes
+ */
+enum sldns_enum_edns_option
+{
+ LDNS_EDNS_LLQ = 1, /* http://files.dns-sd.org/draft-sekar-dns-llq.txt */
+ LDNS_EDNS_UL = 2, /* http://files.dns-sd.org/draft-sekar-dns-ul.txt */
+ LDNS_EDNS_NSID = 3, /* RFC5001 */
+ /* 4 draft-cheshire-edns0-owner-option */
+ LDNS_EDNS_DAU = 5, /* RFC6975 */
+ LDNS_EDNS_DHU = 6, /* RFC6975 */
+ LDNS_EDNS_N3U = 7, /* RFC6975 */
+ LDNS_EDNS_CLIENT_SUBNET = 8 /* draft-vandergaast-edns-client-subnet */
+};
+typedef enum sldns_edns_option sldns_edns_option;
+
+#define LDNS_EDNS_MASK_DO_BIT 0x8000
+
+/**
+ * Contains all information about resource record types.
+ *
+ * This structure contains, for all rr types, the rdata fields that are defined.
+ */
+struct sldns_struct_rr_descriptor
+{
+ /** Type of the RR that is described here */
+ sldns_rr_type _type;
+ /** Textual name of the RR type. */
+ const char *_name;
+ /** Minimum number of rdata fields in the RRs of this type. */
+ uint8_t _minimum;
+ /** Maximum number of rdata fields in the RRs of this type. */
+ uint8_t _maximum;
+ /** Wireformat specification for the rr, i.e. the types of rdata fields in their respective order. */
+ const sldns_rdf_type *_wireformat;
+ /** Special rdf types */
+ sldns_rdf_type _variable;
+ /** Specifies whether compression can be used for dnames in this RR type. */
+ sldns_rr_compress _compress;
+ /** The number of DNAMEs in the _wireformat string, for parsing. */
+ uint8_t _dname_count;
+};
+typedef struct sldns_struct_rr_descriptor sldns_rr_descriptor;
+
+/**
+ * returns the resource record descriptor for the given rr type.
+ *
+ * \param[in] type the type value of the rr type
+ *\return the sldns_rr_descriptor for this type
+ */
+const sldns_rr_descriptor *sldns_rr_descript(uint16_t type);
+
+/**
+ * returns the minimum number of rdata fields of the rr type this descriptor describes.
+ *
+ * \param[in] descriptor for an rr type
+ * \return the minimum number of rdata fields
+ */
+size_t sldns_rr_descriptor_minimum(const sldns_rr_descriptor *descriptor);
+
+/**
+ * returns the maximum number of rdata fields of the rr type this descriptor describes.
+ *
+ * \param[in] descriptor for an rr type
+ * \return the maximum number of rdata fields
+ */
+size_t sldns_rr_descriptor_maximum(const sldns_rr_descriptor *descriptor);
+
+/**
+ * returns the rdf type for the given rdata field number of the rr type for the given descriptor.
+ *
+ * \param[in] descriptor for an rr type
+ * \param[in] field the field number
+ * \return the rdf type for the field
+ */
+sldns_rdf_type sldns_rr_descriptor_field_type(const sldns_rr_descriptor *descriptor, size_t field);
+
+/**
+ * retrieves a rrtype by looking up its name.
+ * \param[in] name a string with the name
+ * \return the type which corresponds with the name
+ */
+sldns_rr_type sldns_get_rr_type_by_name(const char *name);
+
+/**
+ * retrieves a class by looking up its name.
+ * \param[in] name string with the name
+ * \return the cass which corresponds with the name
+ */
+sldns_rr_class sldns_get_rr_class_by_name(const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDNS_RRDEF_H */
diff --git a/contrib/unbound/ldns/sbuffer.c b/contrib/unbound/ldns/sbuffer.c
new file mode 100644
index 0000000..3d087bf
--- /dev/null
+++ b/contrib/unbound/ldns/sbuffer.c
@@ -0,0 +1,178 @@
+/*
+ * buffer.c -- generic memory buffer .
+ *
+ * Copyright (c) 2001-2008, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+ *
+ */
+/**
+ * \file
+ *
+ * This file contains the definition of sldns_buffer, and functions to manipulate those.
+ */
+#include "config.h"
+#include "ldns/sbuffer.h"
+#include <stdarg.h>
+
+sldns_buffer *
+sldns_buffer_new(size_t capacity)
+{
+ sldns_buffer *buffer = (sldns_buffer*)malloc(sizeof(sldns_buffer));
+
+ if (!buffer) {
+ return NULL;
+ }
+
+ buffer->_data = (uint8_t *) malloc(capacity);
+ if (!buffer->_data) {
+ free(buffer);
+ return NULL;
+ }
+
+ buffer->_position = 0;
+ buffer->_limit = buffer->_capacity = capacity;
+ buffer->_fixed = 0;
+ buffer->_status_err = 0;
+
+ sldns_buffer_invariant(buffer);
+
+ return buffer;
+}
+
+void
+sldns_buffer_new_frm_data(sldns_buffer *buffer, void *data, size_t size)
+{
+ assert(data != NULL);
+
+ buffer->_position = 0;
+ buffer->_limit = buffer->_capacity = size;
+ buffer->_fixed = 0;
+ buffer->_data = malloc(size);
+ if(!buffer->_data) {
+ buffer->_status_err = 1;
+ return;
+ }
+ memcpy(buffer->_data, data, size);
+ buffer->_status_err = 0;
+
+ sldns_buffer_invariant(buffer);
+}
+
+void
+sldns_buffer_init_frm_data(sldns_buffer *buffer, void *data, size_t size)
+{
+ memset(buffer, 0, sizeof(*buffer));
+ buffer->_data = data;
+ buffer->_capacity = buffer->_limit = size;
+ buffer->_fixed = 1;
+}
+
+int
+sldns_buffer_set_capacity(sldns_buffer *buffer, size_t capacity)
+{
+ void *data;
+
+ sldns_buffer_invariant(buffer);
+ assert(buffer->_position <= capacity);
+
+ data = (uint8_t *) realloc(buffer->_data, capacity);
+ if (!data) {
+ buffer->_status_err = 1;
+ return 0;
+ } else {
+ buffer->_data = data;
+ buffer->_limit = buffer->_capacity = capacity;
+ return 1;
+ }
+}
+
+int
+sldns_buffer_reserve(sldns_buffer *buffer, size_t amount)
+{
+ sldns_buffer_invariant(buffer);
+ assert(!buffer->_fixed);
+ if (buffer->_capacity < buffer->_position + amount) {
+ size_t new_capacity = buffer->_capacity * 3 / 2;
+
+ if (new_capacity < buffer->_position + amount) {
+ new_capacity = buffer->_position + amount;
+ }
+ if (!sldns_buffer_set_capacity(buffer, new_capacity)) {
+ buffer->_status_err = 1;
+ return 0;
+ }
+ }
+ buffer->_limit = buffer->_capacity;
+ return 1;
+}
+
+int
+sldns_buffer_printf(sldns_buffer *buffer, const char *format, ...)
+{
+ va_list args;
+ int written = 0;
+ size_t remaining;
+
+ if (sldns_buffer_status_ok(buffer)) {
+ sldns_buffer_invariant(buffer);
+ assert(buffer->_limit == buffer->_capacity);
+
+ remaining = sldns_buffer_remaining(buffer);
+ va_start(args, format);
+ written = vsnprintf((char *) sldns_buffer_current(buffer), remaining,
+ format, args);
+ va_end(args);
+ if (written == -1) {
+ buffer->_status_err = 1;
+ return -1;
+ } else if ((size_t) written >= remaining) {
+ if (!sldns_buffer_reserve(buffer, (size_t) written + 1)) {
+ buffer->_status_err = 1;
+ return -1;
+ }
+ va_start(args, format);
+ written = vsnprintf((char *) sldns_buffer_current(buffer),
+ sldns_buffer_remaining(buffer), format, args);
+ va_end(args);
+ if (written == -1) {
+ buffer->_status_err = 1;
+ return -1;
+ }
+ }
+ buffer->_position += written;
+ }
+ return written;
+}
+
+void
+sldns_buffer_free(sldns_buffer *buffer)
+{
+ if (!buffer) {
+ return;
+ }
+
+ if (!buffer->_fixed)
+ free(buffer->_data);
+
+ free(buffer);
+}
+
+void *
+sldns_buffer_export(sldns_buffer *buffer)
+{
+ buffer->_fixed = 1;
+ return buffer->_data;
+}
+
+void
+sldns_buffer_copy(sldns_buffer* result, sldns_buffer* from)
+{
+ size_t tocopy = sldns_buffer_limit(from);
+
+ if(tocopy > sldns_buffer_capacity(result))
+ tocopy = sldns_buffer_capacity(result);
+ sldns_buffer_clear(result);
+ sldns_buffer_write(result, sldns_buffer_begin(from), tocopy);
+ sldns_buffer_flip(result);
+}
diff --git a/contrib/unbound/ldns/sbuffer.h b/contrib/unbound/ldns/sbuffer.h
new file mode 100644
index 0000000..2436763
--- /dev/null
+++ b/contrib/unbound/ldns/sbuffer.h
@@ -0,0 +1,706 @@
+/*
+ * buffer.h -- generic memory buffer.
+ *
+ * Copyright (c) 2005-2008, NLnet Labs. All rights reserved.
+ *
+ * See LICENSE for the license.
+ *
+ *
+ * The buffer module implements a generic buffer. The API is based on
+ * the java.nio.Buffer interface.
+ */
+
+#ifndef LDNS_SBUFFER_H
+#define LDNS_SBUFFER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef S_SPLINT_S
+# define INLINE
+#else
+# ifdef SWIG
+# define INLINE static
+# else
+# define INLINE static inline
+# endif
+#endif
+
+/*
+ * Copy data allowing for unaligned accesses in network byte order
+ * (big endian).
+ */
+INLINE uint16_t
+sldns_read_uint16(const void *src)
+{
+#ifdef ALLOW_UNALIGNED_ACCESSES
+ return ntohs(*(uint16_t *) src);
+#else
+ uint8_t *p = (uint8_t *) src;
+ return ((uint16_t) p[0] << 8) | (uint16_t) p[1];
+#endif
+}
+
+INLINE uint32_t
+sldns_read_uint32(const void *src)
+{
+#ifdef ALLOW_UNALIGNED_ACCESSES
+ return ntohl(*(uint32_t *) src);
+#else
+ uint8_t *p = (uint8_t *) src;
+ return ( ((uint32_t) p[0] << 24)
+ | ((uint32_t) p[1] << 16)
+ | ((uint32_t) p[2] << 8)
+ | (uint32_t) p[3]);
+#endif
+}
+
+/*
+ * Copy data allowing for unaligned accesses in network byte order
+ * (big endian).
+ */
+INLINE void
+sldns_write_uint16(void *dst, uint16_t data)
+{
+#ifdef ALLOW_UNALIGNED_ACCESSES
+ * (uint16_t *) dst = htons(data);
+#else
+ uint8_t *p = (uint8_t *) dst;
+ p[0] = (uint8_t) ((data >> 8) & 0xff);
+ p[1] = (uint8_t) (data & 0xff);
+#endif
+}
+
+INLINE void
+sldns_write_uint32(void *dst, uint32_t data)
+{
+#ifdef ALLOW_UNALIGNED_ACCESSES
+ * (uint32_t *) dst = htonl(data);
+#else
+ uint8_t *p = (uint8_t *) dst;
+ p[0] = (uint8_t) ((data >> 24) & 0xff);
+ p[1] = (uint8_t) ((data >> 16) & 0xff);
+ p[2] = (uint8_t) ((data >> 8) & 0xff);
+ p[3] = (uint8_t) (data & 0xff);
+#endif
+}
+
+
+/**
+ * \file sbuffer.h
+ *
+ * This file contains the definition of sldns_buffer, and functions to manipulate those.
+ */
+
+/**
+ * implementation of buffers to ease operations
+ *
+ * sldns_buffers can contain arbitrary information, per octet. You can write
+ * to the current end of a buffer, read from the current position, and
+ * access any data within it.
+ */
+struct sldns_buffer
+{
+ /** The current position used for reading/writing */
+ size_t _position;
+
+ /** The read/write limit */
+ size_t _limit;
+
+ /** The amount of data the buffer can contain */
+ size_t _capacity;
+
+ /** The data contained in the buffer */
+ uint8_t *_data;
+
+ /** If the buffer is fixed it cannot be resized */
+ unsigned _fixed : 1;
+
+ /** The current state of the buffer. If writing to the buffer fails
+ * for any reason, this value is changed. This way, you can perform
+ * multiple writes in sequence and check for success afterwards. */
+ unsigned _status_err : 1;
+};
+typedef struct sldns_buffer sldns_buffer;
+
+#ifdef NDEBUG
+INLINE void
+sldns_buffer_invariant(sldns_buffer *ATTR_UNUSED(buffer))
+{
+}
+#else
+INLINE void
+sldns_buffer_invariant(sldns_buffer *buffer)
+{
+ assert(buffer != NULL);
+ assert(buffer->_position <= buffer->_limit);
+ assert(buffer->_limit <= buffer->_capacity);
+ assert(buffer->_data != NULL);
+}
+#endif
+
+/**
+ * creates a new buffer with the specified capacity.
+ *
+ * \param[in] capacity the size (in bytes) to allocate for the buffer
+ * \return the created buffer
+ */
+sldns_buffer *sldns_buffer_new(size_t capacity);
+
+/**
+ * creates a buffer with the specified data. The data IS copied
+ * and MEMORY allocations are done. The buffer is not fixed and can
+ * be resized using buffer_reserve().
+ *
+ * \param[in] buffer pointer to the buffer to put the data in
+ * \param[in] data the data to encapsulate in the buffer
+ * \param[in] size the size of the data
+ */
+void sldns_buffer_new_frm_data(sldns_buffer *buffer, void *data, size_t size);
+
+/**
+ * Setup a buffer with the data pointed to. No data copied, no memory allocs.
+ * The buffer is fixed.
+ * \param[in] buffer pointer to the buffer to put the data in
+ * \param[in] data the data to encapsulate in the buffer
+ * \param[in] size the size of the data
+ */
+void sldns_buffer_init_frm_data(sldns_buffer *buffer, void *data, size_t size);
+
+/**
+ * clears the buffer and make it ready for writing. The buffer's limit
+ * is set to the capacity and the position is set to 0.
+ * \param[in] buffer the buffer to clear
+ */
+INLINE void sldns_buffer_clear(sldns_buffer *buffer)
+{
+ sldns_buffer_invariant(buffer);
+
+ /* reset status here? */
+
+ buffer->_position = 0;
+ buffer->_limit = buffer->_capacity;
+}
+
+/**
+ * makes the buffer ready for reading the data that has been written to
+ * the buffer. The buffer's limit is set to the current position and
+ * the position is set to 0.
+ *
+ * \param[in] buffer the buffer to flip
+ * \return void
+ */
+INLINE void sldns_buffer_flip(sldns_buffer *buffer)
+{
+ sldns_buffer_invariant(buffer);
+
+ buffer->_limit = buffer->_position;
+ buffer->_position = 0;
+}
+
+/**
+ * make the buffer ready for re-reading the data. The buffer's
+ * position is reset to 0.
+ * \param[in] buffer the buffer to rewind
+ */
+INLINE void sldns_buffer_rewind(sldns_buffer *buffer)
+{
+ sldns_buffer_invariant(buffer);
+
+ buffer->_position = 0;
+}
+
+/**
+ * returns the current position in the buffer (as a number of bytes)
+ * \param[in] buffer the buffer
+ * \return the current position
+ */
+INLINE size_t
+sldns_buffer_position(sldns_buffer *buffer)
+{
+ return buffer->_position;
+}
+
+/**
+ * sets the buffer's position to MARK. The position must be less than
+ * or equal to the buffer's limit.
+ * \param[in] buffer the buffer
+ * \param[in] mark the mark to use
+ */
+INLINE void
+sldns_buffer_set_position(sldns_buffer *buffer, size_t mark)
+{
+ assert(mark <= buffer->_limit);
+ buffer->_position = mark;
+}
+
+/**
+ * changes the buffer's position by COUNT bytes. The position must not
+ * be moved behind the buffer's limit or before the beginning of the
+ * buffer.
+ * \param[in] buffer the buffer
+ * \param[in] count the count to use
+ */
+INLINE void
+sldns_buffer_skip(sldns_buffer *buffer, ssize_t count)
+{
+ assert(buffer->_position + count <= buffer->_limit);
+ buffer->_position += count;
+}
+
+/**
+ * returns the maximum size of the buffer
+ * \param[in] buffer
+ * \return the size
+ */
+INLINE size_t
+sldns_buffer_limit(sldns_buffer *buffer)
+{
+ return buffer->_limit;
+}
+
+/**
+ * changes the buffer's limit. If the buffer's position is greater
+ * than the new limit the position is set to the limit.
+ * \param[in] buffer the buffer
+ * \param[in] limit the new limit
+ */
+INLINE void
+sldns_buffer_set_limit(sldns_buffer *buffer, size_t limit)
+{
+ assert(limit <= buffer->_capacity);
+ buffer->_limit = limit;
+ if (buffer->_position > buffer->_limit)
+ buffer->_position = buffer->_limit;
+}
+
+/**
+ * returns the number of bytes the buffer can hold.
+ * \param[in] buffer the buffer
+ * \return the number of bytes
+ */
+INLINE size_t
+sldns_buffer_capacity(sldns_buffer *buffer)
+{
+ return buffer->_capacity;
+}
+
+/**
+ * changes the buffer's capacity. The data is reallocated so any
+ * pointers to the data may become invalid. The buffer's limit is set
+ * to the buffer's new capacity.
+ * \param[in] buffer the buffer
+ * \param[in] capacity the capacity to use
+ * \return whether this failed or succeeded
+ */
+int sldns_buffer_set_capacity(sldns_buffer *buffer, size_t capacity);
+
+/**
+ * ensures BUFFER can contain at least AMOUNT more bytes. The buffer's
+ * capacity is increased if necessary using buffer_set_capacity().
+ *
+ * The buffer's limit is always set to the (possibly increased)
+ * capacity.
+ * \param[in] buffer the buffer
+ * \param[in] amount amount to use
+ * \return whether this failed or succeeded
+ */
+int sldns_buffer_reserve(sldns_buffer *buffer, size_t amount);
+
+/**
+ * returns a pointer to the data at the indicated position.
+ * \param[in] buffer the buffer
+ * \param[in] at position
+ * \return the pointer to the data
+ */
+INLINE uint8_t *
+sldns_buffer_at(const sldns_buffer *buffer, size_t at)
+{
+ assert(at <= buffer->_limit);
+ return buffer->_data + at;
+}
+
+/**
+ * returns a pointer to the beginning of the buffer (the data at
+ * position 0).
+ * \param[in] buffer the buffer
+ * \return the pointer
+ */
+INLINE uint8_t *
+sldns_buffer_begin(const sldns_buffer *buffer)
+{
+ return sldns_buffer_at(buffer, 0);
+}
+
+/**
+ * returns a pointer to the end of the buffer (the data at the buffer's
+ * limit).
+ * \param[in] buffer the buffer
+ * \return the pointer
+ */
+INLINE uint8_t *
+sldns_buffer_end(sldns_buffer *buffer)
+{
+ return sldns_buffer_at(buffer, buffer->_limit);
+}
+
+/**
+ * returns a pointer to the data at the buffer's current position.
+ * \param[in] buffer the buffer
+ * \return the pointer
+ */
+INLINE uint8_t *
+sldns_buffer_current(sldns_buffer *buffer)
+{
+ return sldns_buffer_at(buffer, buffer->_position);
+}
+
+/**
+ * returns the number of bytes remaining between the indicated position and
+ * the limit.
+ * \param[in] buffer the buffer
+ * \param[in] at indicated position
+ * \return number of bytes
+ */
+INLINE size_t
+sldns_buffer_remaining_at(sldns_buffer *buffer, size_t at)
+{
+ sldns_buffer_invariant(buffer);
+ assert(at <= buffer->_limit);
+ return buffer->_limit - at;
+}
+
+/**
+ * returns the number of bytes remaining between the buffer's position and
+ * limit.
+ * \param[in] buffer the buffer
+ * \return the number of bytes
+ */
+INLINE size_t
+sldns_buffer_remaining(sldns_buffer *buffer)
+{
+ return sldns_buffer_remaining_at(buffer, buffer->_position);
+}
+
+/**
+ * checks if the buffer has at least COUNT more bytes available.
+ * Before reading or writing the caller needs to ensure enough space
+ * is available!
+ * \param[in] buffer the buffer
+ * \param[in] at indicated position
+ * \param[in] count how much is available
+ * \return true or false (as int?)
+ */
+INLINE int
+sldns_buffer_available_at(sldns_buffer *buffer, size_t at, size_t count)
+{
+ return count <= sldns_buffer_remaining_at(buffer, at);
+}
+
+/**
+ * checks if the buffer has count bytes available at the current position
+ * \param[in] buffer the buffer
+ * \param[in] count how much is available
+ * \return true or false (as int?)
+ */
+INLINE int
+sldns_buffer_available(sldns_buffer *buffer, size_t count)
+{
+ return sldns_buffer_available_at(buffer, buffer->_position, count);
+}
+
+/**
+ * writes the given data to the buffer at the specified position
+ * \param[in] buffer the buffer
+ * \param[in] at the position (in number of bytes) to write the data at
+ * \param[in] data pointer to the data to write to the buffer
+ * \param[in] count the number of bytes of data to write
+ */
+INLINE void
+sldns_buffer_write_at(sldns_buffer *buffer, size_t at, const void *data, size_t count)
+{
+ assert(sldns_buffer_available_at(buffer, at, count));
+ memcpy(buffer->_data + at, data, count);
+}
+
+/**
+ * writes count bytes of data to the current position of the buffer
+ * \param[in] buffer the buffer
+ * \param[in] data the data to write
+ * \param[in] count the lenght of the data to write
+ */
+INLINE void
+sldns_buffer_write(sldns_buffer *buffer, const void *data, size_t count)
+{
+ sldns_buffer_write_at(buffer, buffer->_position, data, count);
+ buffer->_position += count;
+}
+
+/**
+ * copies the given (null-delimited) string to the specified position at the buffer
+ * \param[in] buffer the buffer
+ * \param[in] at the position in the buffer
+ * \param[in] str the string to write
+ */
+INLINE void
+sldns_buffer_write_string_at(sldns_buffer *buffer, size_t at, const char *str)
+{
+ sldns_buffer_write_at(buffer, at, str, strlen(str));
+}
+
+/**
+ * copies the given (null-delimited) string to the current position at the buffer
+ * \param[in] buffer the buffer
+ * \param[in] str the string to write
+ */
+INLINE void
+sldns_buffer_write_string(sldns_buffer *buffer, const char *str)
+{
+ sldns_buffer_write(buffer, str, strlen(str));
+}
+
+/**
+ * writes the given byte of data at the given position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] at the position in the buffer
+ * \param[in] data the 8 bits to write
+ */
+INLINE void
+sldns_buffer_write_u8_at(sldns_buffer *buffer, size_t at, uint8_t data)
+{
+ assert(sldns_buffer_available_at(buffer, at, sizeof(data)));
+ buffer->_data[at] = data;
+}
+
+/**
+ * writes the given byte of data at the current position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] data the 8 bits to write
+ */
+INLINE void
+sldns_buffer_write_u8(sldns_buffer *buffer, uint8_t data)
+{
+ sldns_buffer_write_u8_at(buffer, buffer->_position, data);
+ buffer->_position += sizeof(data);
+}
+
+/**
+ * writes the given 2 byte integer at the given position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] at the position in the buffer
+ * \param[in] data the 16 bits to write
+ */
+INLINE void
+sldns_buffer_write_u16_at(sldns_buffer *buffer, size_t at, uint16_t data)
+{
+ assert(sldns_buffer_available_at(buffer, at, sizeof(data)));
+ sldns_write_uint16(buffer->_data + at, data);
+}
+
+/**
+ * writes the given 2 byte integer at the current position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] data the 16 bits to write
+ */
+INLINE void
+sldns_buffer_write_u16(sldns_buffer *buffer, uint16_t data)
+{
+ sldns_buffer_write_u16_at(buffer, buffer->_position, data);
+ buffer->_position += sizeof(data);
+}
+
+/**
+ * writes the given 4 byte integer at the given position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] at the position in the buffer
+ * \param[in] data the 32 bits to write
+ */
+INLINE void
+sldns_buffer_write_u32_at(sldns_buffer *buffer, size_t at, uint32_t data)
+{
+ assert(sldns_buffer_available_at(buffer, at, sizeof(data)));
+ sldns_write_uint32(buffer->_data + at, data);
+}
+
+/**
+ * writes the given 4 byte integer at the current position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] data the 32 bits to write
+ */
+INLINE void
+sldns_buffer_write_u32(sldns_buffer *buffer, uint32_t data)
+{
+ sldns_buffer_write_u32_at(buffer, buffer->_position, data);
+ buffer->_position += sizeof(data);
+}
+
+/**
+ * copies count bytes of data at the given position to the given data-array
+ * \param[in] buffer the buffer
+ * \param[in] at the position in the buffer to start
+ * \param[out] data buffer to copy to
+ * \param[in] count the length of the data to copy
+ */
+INLINE void
+sldns_buffer_read_at(sldns_buffer *buffer, size_t at, void *data, size_t count)
+{
+ assert(sldns_buffer_available_at(buffer, at, count));
+ memcpy(data, buffer->_data + at, count);
+}
+
+/**
+ * copies count bytes of data at the current position to the given data-array
+ * \param[in] buffer the buffer
+ * \param[out] data buffer to copy to
+ * \param[in] count the length of the data to copy
+ */
+INLINE void
+sldns_buffer_read(sldns_buffer *buffer, void *data, size_t count)
+{
+ sldns_buffer_read_at(buffer, buffer->_position, data, count);
+ buffer->_position += count;
+}
+
+/**
+ * returns the byte value at the given position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] at the position in the buffer
+ * \return 1 byte integer
+ */
+INLINE uint8_t
+sldns_buffer_read_u8_at(sldns_buffer *buffer, size_t at)
+{
+ assert(sldns_buffer_available_at(buffer, at, sizeof(uint8_t)));
+ return buffer->_data[at];
+}
+
+/**
+ * returns the byte value at the current position in the buffer
+ * \param[in] buffer the buffer
+ * \return 1 byte integer
+ */
+INLINE uint8_t
+sldns_buffer_read_u8(sldns_buffer *buffer)
+{
+ uint8_t result = sldns_buffer_read_u8_at(buffer, buffer->_position);
+ buffer->_position += sizeof(uint8_t);
+ return result;
+}
+
+/**
+ * returns the 2-byte integer value at the given position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] at position in the buffer
+ * \return 2 byte integer
+ */
+INLINE uint16_t
+sldns_buffer_read_u16_at(sldns_buffer *buffer, size_t at)
+{
+ assert(sldns_buffer_available_at(buffer, at, sizeof(uint16_t)));
+ return sldns_read_uint16(buffer->_data + at);
+}
+
+/**
+ * returns the 2-byte integer value at the current position in the buffer
+ * \param[in] buffer the buffer
+ * \return 2 byte integer
+ */
+INLINE uint16_t
+sldns_buffer_read_u16(sldns_buffer *buffer)
+{
+ uint16_t result = sldns_buffer_read_u16_at(buffer, buffer->_position);
+ buffer->_position += sizeof(uint16_t);
+ return result;
+}
+
+/**
+ * returns the 4-byte integer value at the given position in the buffer
+ * \param[in] buffer the buffer
+ * \param[in] at position in the buffer
+ * \return 4 byte integer
+ */
+INLINE uint32_t
+sldns_buffer_read_u32_at(sldns_buffer *buffer, size_t at)
+{
+ assert(sldns_buffer_available_at(buffer, at, sizeof(uint32_t)));
+ return sldns_read_uint32(buffer->_data + at);
+}
+
+/**
+ * returns the 4-byte integer value at the current position in the buffer
+ * \param[in] buffer the buffer
+ * \return 4 byte integer
+ */
+INLINE uint32_t
+sldns_buffer_read_u32(sldns_buffer *buffer)
+{
+ uint32_t result = sldns_buffer_read_u32_at(buffer, buffer->_position);
+ buffer->_position += sizeof(uint32_t);
+ return result;
+}
+
+/**
+ * returns the status of the buffer
+ * \param[in] buffer
+ * \return the status
+ */
+INLINE int
+sldns_buffer_status(sldns_buffer *buffer)
+{
+ return (int)buffer->_status_err;
+}
+
+/**
+ * returns true if the status of the buffer is LDNS_STATUS_OK, false otherwise
+ * \param[in] buffer the buffer
+ * \return true or false
+ */
+INLINE int
+sldns_buffer_status_ok(sldns_buffer *buffer)
+{
+ if (buffer) {
+ return sldns_buffer_status(buffer) == 0;
+ } else {
+ return 0;
+ }
+}
+
+/**
+ * prints to the buffer, increasing the capacity if required using
+ * buffer_reserve(). The buffer's position is set to the terminating '\\0'
+ * Returns the number of characters written (not including the
+ * terminating '\\0') or -1 on failure.
+ */
+int sldns_buffer_printf(sldns_buffer *buffer, const char *format, ...)
+ ATTR_FORMAT(printf, 2, 3);
+
+/**
+ * frees the buffer.
+ * \param[in] *buffer the buffer to be freed
+ * \return void
+ */
+void sldns_buffer_free(sldns_buffer *buffer);
+
+/**
+ * Makes the buffer fixed and returns a pointer to the data. The
+ * caller is responsible for free'ing the result.
+ * \param[in] *buffer the buffer to be exported
+ * \return void
+ */
+void *sldns_buffer_export(sldns_buffer *buffer);
+
+/**
+ * Copy contents of the from buffer to the result buffer and then flips
+ * the result buffer. Data will be silently truncated if the result buffer is
+ * too small.
+ * \param[out] *result resulting buffer which is copied to.
+ * \param[in] *from what to copy to result.
+ */
+void sldns_buffer_copy(sldns_buffer* result, sldns_buffer* from);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDNS_SBUFFER_H */
diff --git a/contrib/unbound/ldns/str2wire.c b/contrib/unbound/ldns/str2wire.c
new file mode 100644
index 0000000..92eefa8
--- /dev/null
+++ b/contrib/unbound/ldns/str2wire.c
@@ -0,0 +1,2001 @@
+/**
+ * str2wire.c - read txt presentation of RRs
+ *
+ * (c) NLnet Labs, 2005-2006
+ *
+ * See the file LICENSE for the license
+ */
+
+/**
+ * \file
+ *
+ * Parses text to wireformat.
+ */
+#include "config.h"
+#include "ldns/str2wire.h"
+#include "ldns/wire2str.h"
+#include "ldns/sbuffer.h"
+#include "ldns/parse.h"
+#include "ldns/parseutil.h"
+#include <ctype.h>
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+/** return an error */
+#define RET_ERR(e, off) ((int)((e)|((off)<<LDNS_WIREPARSE_SHIFT)))
+/** Move parse error but keep its ID */
+#define RET_ERR_SHIFT(e, move) RET_ERR(LDNS_WIREPARSE_ERROR(e), LDNS_WIREPARSE_OFFSET(e)+(move));
+#define LDNS_IP6ADDRLEN (128/8)
+
+/*
+ * No special care is taken, all dots are translated into
+ * label separators.
+ * @param rel: true if the domain is not absolute (not terminated in .).
+ * The output is then still terminated with a '0' rootlabel.
+ */
+static int sldns_str2wire_dname_buf_rel(const char* str, uint8_t* buf,
+ size_t* olen, int* rel)
+{
+ size_t len;
+
+ const char *s;
+ uint8_t *q, *pq, label_len;
+
+ if(rel) *rel = 0;
+ len = strlen((char*)str);
+ /* octet representation can make strings a lot longer than actual length */
+ if (len > LDNS_MAX_DOMAINLEN * 4) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, 0);
+ }
+ if (0 == len) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW, 0);
+ }
+
+ /* root label */
+ if (1 == len && *str == '.') {
+ if(*olen < 1)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, 0);
+ buf[0] = 0;
+ *olen = 1;
+ return LDNS_WIREPARSE_ERR_OK;
+ }
+
+ /* get on with the rest */
+
+ /* s is on the current character in the string
+ * pq points to where the labellength is going to go
+ * label_len keeps track of the current label's length
+ * q builds the dname inside the buf array
+ */
+ len = 0;
+ if(*olen < 1)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, 0);
+ q = buf+1;
+ pq = buf;
+ label_len = 0;
+ for (s = str; *s; s++, q++) {
+ if (q >= buf + *olen)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, q-buf);
+ if (q > buf + LDNS_MAX_DOMAINLEN)
+ return RET_ERR(LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, q-buf);
+ switch (*s) {
+ case '.':
+ if (label_len > LDNS_MAX_LABELLEN) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_LABEL_OVERFLOW, q-buf);
+ }
+ if (label_len == 0) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_EMPTY_LABEL, q-buf);
+ }
+ len += label_len + 1;
+ *q = 0;
+ *pq = label_len;
+ label_len = 0;
+ pq = q;
+ break;
+ case '\\':
+ /* octet value or literal char */
+ s += 1;
+ if (!sldns_parse_escape(q, &s)) {
+ *q = 0;
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE, q-buf);
+ }
+ s -= 1;
+ label_len++;
+ break;
+ default:
+ *q = (uint8_t)*s;
+ label_len++;
+ }
+ }
+
+ /* add root label if last char was not '.' */
+ if(label_len != 0) {
+ if(rel) *rel = 1;
+ if (q >= buf + *olen)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, q-buf);
+ if (q > buf + LDNS_MAX_DOMAINLEN) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, q-buf);
+ }
+ if (label_len > LDNS_MAX_LABELLEN) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_LABEL_OVERFLOW, q-buf);
+ }
+ if (label_len == 0) { /* label_len 0 but not . at end? */
+ return RET_ERR(LDNS_WIREPARSE_ERR_EMPTY_LABEL, q-buf);
+ }
+ len += label_len + 1;
+ *pq = label_len;
+ *q = 0;
+ }
+ len++;
+ *olen = len;
+
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_dname_buf(const char* str, uint8_t* buf, size_t* len)
+{
+ return sldns_str2wire_dname_buf_rel(str, buf, len, NULL);
+}
+
+int sldns_str2wire_dname_buf_origin(const char* str, uint8_t* buf, size_t* len,
+ uint8_t* origin, size_t origin_len)
+{
+ size_t dlen = *len;
+ int rel = 0;
+ int s = sldns_str2wire_dname_buf_rel(str, buf, &dlen, &rel);
+ if(s) return s;
+
+ if(rel && origin && dlen > 0) {
+ if(dlen + origin_len - 1 > LDNS_MAX_DOMAINLEN)
+ return RET_ERR(LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW,
+ LDNS_MAX_DOMAINLEN);
+ if(dlen + origin_len - 1 > *len)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ *len);
+ memmove(buf+dlen-1, origin, origin_len);
+ *len = dlen + origin_len - 1;
+ } else
+ *len = dlen;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+uint8_t* sldns_str2wire_dname(const char* str, size_t* len)
+{
+ uint8_t dname[LDNS_MAX_DOMAINLEN+1];
+ *len = sizeof(dname);
+ if(sldns_str2wire_dname_buf(str, dname, len) == 0) {
+ uint8_t* r = (uint8_t*)malloc(*len);
+ if(r) return memcpy(r, dname, *len);
+ }
+ *len = 0;
+ return NULL;
+}
+
+/** read owner name */
+static int
+rrinternal_get_owner(sldns_buffer* strbuf, uint8_t* rr, size_t* len,
+ size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev,
+ size_t prev_len, char* token, size_t token_len)
+{
+ /* split the rr in its parts -1 signals trouble */
+ if(sldns_bget_token(strbuf, token, "\t\n ", token_len) == -1) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX,
+ sldns_buffer_position(strbuf));
+ }
+
+ if(strcmp(token, "@") == 0) {
+ uint8_t* tocopy;
+ if (origin) {
+ *dname_len = origin_len;
+ tocopy = origin;
+ } else if (prev) {
+ *dname_len = prev_len;
+ tocopy = prev;
+ } else {
+ /* default to root */
+ *dname_len = 1;
+ tocopy = (uint8_t*)"\0";
+ }
+ if(*len < *dname_len)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(strbuf));
+ memmove(rr, tocopy, *dname_len);
+ } else if(strlen(token) == 0) {
+ /* no ownername was given, try prev, if that fails
+ * origin, else default to root */
+ uint8_t* tocopy;
+ if(prev) {
+ *dname_len = prev_len;
+ tocopy = prev;
+ } else if(origin) {
+ *dname_len = origin_len;
+ tocopy = origin;
+ } else {
+ *dname_len = 1;
+ tocopy = (uint8_t*)"\0";
+ }
+ if(*len < *dname_len)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(strbuf));
+ memmove(rr, tocopy, *dname_len);
+ } else {
+ size_t dlen = *len;
+ int s = sldns_str2wire_dname_buf_origin(token, rr, &dlen,
+ origin, origin_len);
+ if(s) return RET_ERR_SHIFT(s,
+ sldns_buffer_position(strbuf)-strlen(token));
+ *dname_len = dlen;
+ }
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/** read ttl */
+static int
+rrinternal_get_ttl(sldns_buffer* strbuf, char* token, size_t token_len,
+ int* not_there, uint32_t* ttl, uint32_t default_ttl)
+{
+ const char* endptr;
+ if(sldns_bget_token(strbuf, token, "\t\n ", token_len) == -1) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_TTL,
+ sldns_buffer_position(strbuf));
+ }
+ *ttl = (uint32_t) sldns_str2period(token, &endptr);
+
+ if (strlen(token) > 0 && !isdigit((int)token[0])) {
+ *not_there = 1;
+ /* ah, it's not there or something */
+ if (default_ttl == 0) {
+ *ttl = LDNS_DEFAULT_TTL;
+ } else {
+ *ttl = default_ttl;
+ }
+ }
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/** read class */
+static int
+rrinternal_get_class(sldns_buffer* strbuf, char* token, size_t token_len,
+ int* not_there, uint16_t* cl)
+{
+ /* if 'not_there' then we got token from previous parse routine */
+ if(!*not_there) {
+ /* parse new token for class */
+ if(sldns_bget_token(strbuf, token, "\t\n ", token_len) == -1) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_CLASS,
+ sldns_buffer_position(strbuf));
+ }
+ } else *not_there = 0;
+ *cl = sldns_get_rr_class_by_name(token);
+ /* class can be left out too, assume IN, current token must be type */
+ if(*cl == 0 && strcmp(token, "CLASS0") != 0) {
+ *not_there = 1;
+ *cl = LDNS_RR_CLASS_IN;
+ }
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/** read type */
+static int
+rrinternal_get_type(sldns_buffer* strbuf, char* token, size_t token_len,
+ int* not_there, uint16_t* tp)
+{
+ /* if 'not_there' then we got token from previous parse routine */
+ if(!*not_there) {
+ /* parse new token for type */
+ if(sldns_bget_token(strbuf, token, "\t\n ", token_len) == -1) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_TYPE,
+ sldns_buffer_position(strbuf));
+ }
+ }
+ *tp = sldns_get_rr_type_by_name(token);
+ if(*tp == 0 && strcmp(token, "TYPE0") != 0) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_TYPE,
+ sldns_buffer_position(strbuf));
+ }
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/** put type, class, ttl into rr buffer */
+static int
+rrinternal_write_typeclassttl(sldns_buffer* strbuf, uint8_t* rr, size_t len,
+ size_t dname_len, uint16_t tp, uint16_t cl, uint32_t ttl, int question)
+{
+ if(question) {
+ /* question is : name, type, class */
+ if(dname_len + 4 > len)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(strbuf));
+ sldns_write_uint16(rr+dname_len, tp);
+ sldns_write_uint16(rr+dname_len+2, cl);
+ return LDNS_WIREPARSE_ERR_OK;
+ }
+
+ /* type(2), class(2), ttl(4), rdatalen(2 (later)) = 10 */
+ if(dname_len + 10 > len)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(strbuf));
+ sldns_write_uint16(rr+dname_len, tp);
+ sldns_write_uint16(rr+dname_len+2, cl);
+ sldns_write_uint32(rr+dname_len+4, ttl);
+ sldns_write_uint16(rr+dname_len+8, 0); /* rdatalen placeholder */
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/** find delimiters for type */
+static const char*
+rrinternal_get_delims(sldns_rdf_type rdftype, uint16_t r_cnt, uint16_t r_max)
+{
+ switch(rdftype) {
+ case LDNS_RDF_TYPE_B64 :
+ case LDNS_RDF_TYPE_HEX : /* These rdf types may con- */
+ case LDNS_RDF_TYPE_LOC : /* tain whitespace, only if */
+ case LDNS_RDF_TYPE_WKS : /* it is the last rd field. */
+ case LDNS_RDF_TYPE_IPSECKEY :
+ case LDNS_RDF_TYPE_NSEC : if (r_cnt == r_max - 1) {
+ return "\n\t";
+ }
+ break;
+ default : break;
+ }
+ return "\n\t ";
+}
+
+/* Syntactic sugar for sldns_rr_new_frm_str_internal */
+static int
+sldns_rdf_type_maybe_quoted(sldns_rdf_type rdf_type)
+{
+ return rdf_type == LDNS_RDF_TYPE_STR ||
+ rdf_type == LDNS_RDF_TYPE_LONG_STR;
+}
+
+/** see if rdata is quoted */
+static int
+rrinternal_get_quoted(sldns_buffer* strbuf, const char** delimiters,
+ sldns_rdf_type rdftype)
+{
+ if(sldns_rdf_type_maybe_quoted(rdftype) &&
+ sldns_buffer_remaining(strbuf) > 0) {
+
+ /* skip spaces */
+ while(sldns_buffer_remaining(strbuf) > 0 &&
+ *(sldns_buffer_current(strbuf)) == ' ') {
+ sldns_buffer_skip(strbuf, 1);
+ }
+
+ if(sldns_buffer_remaining(strbuf) > 0 &&
+ *(sldns_buffer_current(strbuf)) == '\"') {
+ *delimiters = "\"\0";
+ sldns_buffer_skip(strbuf, 1);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/** spool hex data into rdata */
+static int
+rrinternal_spool_hex(char* token, uint8_t* rr, size_t rr_len,
+ size_t rr_cur_len, size_t* cur_hex_data_size, size_t hex_data_size)
+{
+ char* p = token;
+ while(*p) {
+ if(isspace(*p)) {
+ p++;
+ continue;
+ }
+ if(!isxdigit(*p))
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_RDATA,
+ p-token);
+ if(*cur_hex_data_size >= hex_data_size)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_RDATA,
+ p-token);
+ /* extra robust check */
+ if(rr_cur_len+(*cur_hex_data_size)/2 >= rr_len)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ p-token);
+ /* see if 16s or 1s */
+ if( ((*cur_hex_data_size)&1) == 0) {
+ rr[rr_cur_len+(*cur_hex_data_size)/2] =
+ (uint8_t)sldns_hexdigit_to_int(*p)*16;
+ } else {
+ rr[rr_cur_len+(*cur_hex_data_size)/2] +=
+ (uint8_t)sldns_hexdigit_to_int(*p);
+ }
+ p++;
+ (*cur_hex_data_size)++;
+ }
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/** read unknown rr type format */
+static int
+rrinternal_parse_unknown(sldns_buffer* strbuf, char* token, size_t token_len,
+ uint8_t* rr, size_t* rr_len, size_t* rr_cur_len, size_t pre_data_pos)
+{
+ const char* delim = "\n\t ";
+ size_t hex_data_size, cur_hex_data_size;
+ /* go back to before \#
+ * and skip it while setting delimiters better
+ */
+ sldns_buffer_set_position(strbuf, pre_data_pos);
+ if(sldns_bget_token(strbuf, token, delim, token_len) == -1)
+ return LDNS_WIREPARSE_ERR_GENERAL; /* should not fail */
+ /* read rdata octet length */
+ if(sldns_bget_token(strbuf, token, delim, token_len) == -1) {
+ /* something goes very wrong here */
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_RDATA,
+ sldns_buffer_position(strbuf));
+ }
+ hex_data_size = (size_t)atoi(token);
+ if(hex_data_size > LDNS_MAX_RDFLEN ||
+ *rr_cur_len + hex_data_size > *rr_len) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(strbuf));
+ }
+ /* copy hex chars into hex str (2 chars per byte) */
+ hex_data_size *= 2;
+ cur_hex_data_size = 0;
+ while(cur_hex_data_size < hex_data_size) {
+ int status;
+ ssize_t c = sldns_bget_token(strbuf, token, delim, token_len);
+ if((status = rrinternal_spool_hex(token, rr, *rr_len,
+ *rr_cur_len, &cur_hex_data_size, hex_data_size)) != 0)
+ return RET_ERR_SHIFT(status,
+ sldns_buffer_position(strbuf)-strlen(token));
+ if(c == -1) {
+ if(cur_hex_data_size != hex_data_size)
+ return RET_ERR(
+ LDNS_WIREPARSE_ERR_SYNTAX_RDATA,
+ sldns_buffer_position(strbuf));
+ break;
+ }
+ }
+ *rr_cur_len += hex_data_size/2;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/** parse normal RR rdata element */
+static int
+rrinternal_parse_rdf(sldns_buffer* strbuf, char* token, size_t token_len,
+ uint8_t* rr, size_t rr_len, size_t* rr_cur_len, sldns_rdf_type rdftype,
+ uint16_t rr_type, uint16_t r_cnt, uint16_t r_max, size_t dname_len,
+ uint8_t* origin, size_t origin_len)
+{
+ size_t len;
+ int status;
+
+ switch(rdftype) {
+ case LDNS_RDF_TYPE_DNAME:
+ /* check if the origin should be used or concatenated */
+ if(strcmp(token, "@") == 0) {
+ uint8_t* tocopy;
+ size_t copylen;
+ if(origin) {
+ copylen = origin_len;
+ tocopy = origin;
+ } else if(rr_type == LDNS_RR_TYPE_SOA) {
+ copylen = dname_len;
+ tocopy = rr; /* copy rr owner name */
+ } else {
+ copylen = 1;
+ tocopy = (uint8_t*)"\0";
+ }
+ if((*rr_cur_len) + copylen > rr_len)
+ return RET_ERR(
+ LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(strbuf));
+ memmove(rr+*rr_cur_len, tocopy, copylen);
+ (*rr_cur_len) += copylen;
+ } else {
+ size_t dlen = rr_len - (*rr_cur_len);
+ int s = sldns_str2wire_dname_buf_origin(token,
+ rr+*rr_cur_len, &dlen, origin, origin_len);
+ if(s) return RET_ERR_SHIFT(s,
+ sldns_buffer_position(strbuf)-strlen(token));
+ (*rr_cur_len) += dlen;
+ }
+ return LDNS_WIREPARSE_ERR_OK;
+
+ case LDNS_RDF_TYPE_HEX:
+ case LDNS_RDF_TYPE_B64:
+ /* When this is the last rdata field, then the
+ * rest should be read in (cause then these
+ * rdf types may contain spaces). */
+ if(r_cnt == r_max - 1) {
+ size_t tlen = strlen(token);
+ (void)sldns_bget_token(strbuf, token+tlen, "\n",
+ token_len - tlen);
+ }
+ break;
+ default:
+ break;
+ }
+
+ len = rr_len - (*rr_cur_len);
+ if((status=sldns_str2wire_rdf_buf(token, rr+(*rr_cur_len), &len,
+ rdftype)) != 0)
+ return RET_ERR_SHIFT(status,
+ sldns_buffer_position(strbuf)-strlen(token));
+ *rr_cur_len += len;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/**
+ * Parse one rdf token. Takes care of quotes and parenthesis.
+ */
+static int
+sldns_parse_rdf_token(sldns_buffer* strbuf, char* token, size_t token_len,
+ int* quoted, int* parens, size_t* pre_data_pos,
+ const char* delimiters, sldns_rdf_type rdftype, size_t* token_strlen)
+{
+ size_t slen;
+
+ /* skip spaces */
+ while(sldns_buffer_remaining(strbuf) > 0 && !*quoted &&
+ *(sldns_buffer_current(strbuf)) == ' ') {
+ sldns_buffer_skip(strbuf, 1);
+ }
+
+ *pre_data_pos = sldns_buffer_position(strbuf);
+ if(sldns_bget_token_par(strbuf, token, (*quoted)?"\"":delimiters,
+ token_len, parens, (*quoted)?NULL:" \t") == -1) {
+ return 0;
+ }
+ slen = strlen(token);
+ /* check if not quoted yet, and we have encountered quotes */
+ if(!*quoted && sldns_rdf_type_maybe_quoted(rdftype) &&
+ slen >= 2 &&
+ (token[0] == '"' || token[0] == '\'') &&
+ (token[slen-1] == '"' || token[slen-1] == '\'')) {
+ /* move token two smaller (quotes) with endnull */
+ memmove(token, token+1, slen-2);
+ token[slen-2] = 0;
+ slen -= 2;
+ *quoted = 1;
+ } else if(!*quoted && sldns_rdf_type_maybe_quoted(rdftype) &&
+ slen >= 2 &&
+ (token[0] == '"' || token[0] == '\'')) {
+ /* got the start quote (remove it) but read remainder
+ * of quoted string as well into remainder of token */
+ memmove(token, token+1, slen-1);
+ token[slen-1] = 0;
+ slen -= 1;
+ *quoted = 1;
+ /* rewind buffer over skipped whitespace */
+ while(sldns_buffer_position(strbuf) > 0 &&
+ (sldns_buffer_current(strbuf)[-1] == ' ' ||
+ sldns_buffer_current(strbuf)[-1] == '\t')) {
+ sldns_buffer_skip(strbuf, -1);
+ }
+ if(sldns_bget_token_par(strbuf, token+slen,
+ "\"", token_len-slen,
+ parens, NULL) == -1) {
+ return 0;
+ }
+ slen = strlen(token);
+ }
+ *token_strlen = slen;
+ return 1;
+}
+
+/** Add space and one more rdf token onto the existing token string. */
+static int
+sldns_affix_token(sldns_buffer* strbuf, char* token, size_t* token_len,
+ int* quoted, int* parens, size_t* pre_data_pos,
+ const char* delimiters, sldns_rdf_type rdftype, size_t* token_strlen)
+{
+ size_t addlen = *token_len - *token_strlen;
+ size_t addstrlen = 0;
+
+ /* add space */
+ if(addlen < 1) return 0;
+ token[*token_strlen] = ' ';
+ token[++(*token_strlen)] = 0;
+
+ /* read another token */
+ addlen = *token_len - *token_strlen;
+ if(!sldns_parse_rdf_token(strbuf, token+*token_strlen, addlen, quoted,
+ parens, pre_data_pos, delimiters, rdftype, &addstrlen))
+ return 0;
+ (*token_strlen) += addstrlen;
+ return 1;
+}
+
+/** parse rdata from string into rr buffer(-remainder after dname). */
+static int
+rrinternal_parse_rdata(sldns_buffer* strbuf, char* token, size_t token_len,
+ uint8_t* rr, size_t* rr_len, size_t dname_len, uint16_t rr_type,
+ uint8_t* origin, size_t origin_len)
+{
+ const sldns_rr_descriptor *desc = sldns_rr_descript((uint16_t)rr_type);
+ uint16_t r_cnt, r_min, r_max;
+ size_t rr_cur_len = dname_len + 10, pre_data_pos, token_strlen;
+ int was_unknown_rr_format = 0, parens = 0, status, quoted;
+ const char* delimiters;
+ sldns_rdf_type rdftype;
+ /* a desc is always returned */
+ if(!desc) return LDNS_WIREPARSE_ERR_GENERAL;
+ r_max = sldns_rr_descriptor_maximum(desc);
+ r_min = sldns_rr_descriptor_minimum(desc);
+ /* robust check */
+ if(rr_cur_len > *rr_len)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(strbuf));
+
+ /* because number of fields can be variable, we can't rely on
+ * _maximum() only */
+ for(r_cnt=0; r_cnt < r_max; r_cnt++) {
+ rdftype = sldns_rr_descriptor_field_type(desc, r_cnt);
+ delimiters = rrinternal_get_delims(rdftype, r_cnt, r_max);
+ quoted = rrinternal_get_quoted(strbuf, &delimiters, rdftype);
+
+ if(!sldns_parse_rdf_token(strbuf, token, token_len, &quoted,
+ &parens, &pre_data_pos, delimiters, rdftype,
+ &token_strlen))
+ break;
+
+ /* rfc3597 specifies that any type can be represented
+ * with \# method, which can contain spaces...
+ * it does specify size though... */
+
+ /* unknown RR data */
+ if(token_strlen>=2 && strncmp(token, "\\#", 2) == 0 &&
+ !quoted && (token_strlen == 2 || token[2]==' ')) {
+ was_unknown_rr_format = 1;
+ if((status=rrinternal_parse_unknown(strbuf, token,
+ token_len, rr, rr_len, &rr_cur_len,
+ pre_data_pos)) != 0)
+ return status;
+ } else if(token_strlen > 0 || quoted) {
+ if(rdftype == LDNS_RDF_TYPE_HIP) {
+ /* affix the HIT and PK fields, with a space */
+ if(!sldns_affix_token(strbuf, token,
+ &token_len, &quoted, &parens,
+ &pre_data_pos, delimiters,
+ rdftype, &token_strlen))
+ break;
+ if(!sldns_affix_token(strbuf, token,
+ &token_len, &quoted, &parens,
+ &pre_data_pos, delimiters,
+ rdftype, &token_strlen))
+ break;
+ }
+
+ /* normal RR */
+ if((status=rrinternal_parse_rdf(strbuf, token,
+ token_len, rr, *rr_len, &rr_cur_len, rdftype,
+ rr_type, r_cnt, r_max, dname_len, origin,
+ origin_len)) != 0) {
+ return status;
+ }
+ }
+ }
+ if(!was_unknown_rr_format && r_cnt+1 < r_min) {
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE,
+ sldns_buffer_position(strbuf));
+ }
+ while(parens != 0) {
+ /* read remainder, must be "" */
+ if(sldns_bget_token_par(strbuf, token, "\n", token_len,
+ &parens, " \t") == -1) {
+ if(parens != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_PARENTHESIS,
+ sldns_buffer_position(strbuf));
+ break;
+ }
+ if(strcmp(token, "") != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_PARENTHESIS,
+ sldns_buffer_position(strbuf));
+ }
+ /* write rdata length */
+ sldns_write_uint16(rr+dname_len+8, rr_cur_len-dname_len-10);
+ *rr_len = rr_cur_len;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/*
+ * trailing spaces are allowed
+ * leading spaces are not allowed
+ * allow ttl to be optional
+ * class is optional too
+ * if ttl is missing, and default_ttl is 0, use DEF_TTL
+ * allow ttl to be written as 1d3h
+ * So the RR should look like. e.g.
+ * miek.nl. 3600 IN MX 10 elektron.atoom.net
+ * or
+ * miek.nl. 1h IN MX 10 elektron.atoom.net
+ * or
+ * miek.nl. IN MX 10 elektron.atoom.net
+ */
+static int
+sldns_str2wire_rr_buf_internal(const char* str, uint8_t* rr, size_t* len,
+ size_t* dname_len, uint32_t default_ttl, uint8_t* origin,
+ size_t origin_len, uint8_t* prev, size_t prev_len, int question)
+{
+ int status;
+ int not_there = 0;
+ char token[LDNS_MAX_RDFLEN+1];
+ uint32_t ttl = 0;
+ uint16_t tp = 0, cl = 0;
+ size_t ddlen = 0;
+
+ /* string in buffer */
+ sldns_buffer strbuf;
+ sldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str));
+ if(!dname_len) dname_len = &ddlen;
+
+ /* parse the owner */
+ if((status=rrinternal_get_owner(&strbuf, rr, len, dname_len, origin,
+ origin_len, prev, prev_len, token, sizeof(token))) != 0)
+ return status;
+
+ /* parse the [ttl] [class] <type> */
+ if((status=rrinternal_get_ttl(&strbuf, token, sizeof(token),
+ &not_there, &ttl, default_ttl)) != 0)
+ return status;
+ if((status=rrinternal_get_class(&strbuf, token, sizeof(token),
+ &not_there, &cl)) != 0)
+ return status;
+ if((status=rrinternal_get_type(&strbuf, token, sizeof(token),
+ &not_there, &tp)) != 0)
+ return status;
+ /* put ttl, class, type into the rr result */
+ if((status=rrinternal_write_typeclassttl(&strbuf, rr, *len, *dname_len, tp, cl,
+ ttl, question)) != 0)
+ return status;
+ /* for a question-RR we are done, no rdata */
+ if(question) {
+ *len = *dname_len + 4;
+ return LDNS_WIREPARSE_ERR_OK;
+ }
+
+ /* rdata */
+ if((status=rrinternal_parse_rdata(&strbuf, token, sizeof(token),
+ rr, len, *dname_len, tp, origin, origin_len)) != 0)
+ return status;
+
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_rr_buf(const char* str, uint8_t* rr, size_t* len,
+ size_t* dname_len, uint32_t default_ttl, uint8_t* origin,
+ size_t origin_len, uint8_t* prev, size_t prev_len)
+{
+ return sldns_str2wire_rr_buf_internal(str, rr, len, dname_len,
+ default_ttl, origin, origin_len, prev, prev_len, 0);
+}
+
+int sldns_str2wire_rr_question_buf(const char* str, uint8_t* rr, size_t* len,
+ size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev,
+ size_t prev_len)
+{
+ return sldns_str2wire_rr_buf_internal(str, rr, len, dname_len,
+ 0, origin, origin_len, prev, prev_len, 1);
+}
+
+uint16_t sldns_wirerr_get_type(uint8_t* rr, size_t len, size_t dname_len)
+{
+ if(len < dname_len+2)
+ return 0;
+ return sldns_read_uint16(rr+dname_len);
+}
+
+uint16_t sldns_wirerr_get_class(uint8_t* rr, size_t len, size_t dname_len)
+{
+ if(len < dname_len+4)
+ return 0;
+ return sldns_read_uint16(rr+dname_len+2);
+}
+
+uint32_t sldns_wirerr_get_ttl(uint8_t* rr, size_t len, size_t dname_len)
+{
+ if(len < dname_len+8)
+ return 0;
+ return sldns_read_uint32(rr+dname_len+4);
+}
+
+uint16_t sldns_wirerr_get_rdatalen(uint8_t* rr, size_t len, size_t dname_len)
+{
+ if(len < dname_len+10)
+ return 0;
+ return sldns_read_uint16(rr+dname_len+8);
+}
+
+uint8_t* sldns_wirerr_get_rdata(uint8_t* rr, size_t len, size_t dname_len)
+{
+ if(len < dname_len+10)
+ return NULL;
+ return rr+dname_len+10;
+}
+
+uint8_t* sldns_wirerr_get_rdatawl(uint8_t* rr, size_t len, size_t dname_len)
+{
+ if(len < dname_len+10)
+ return NULL;
+ return rr+dname_len+8;
+}
+
+const char* sldns_get_errorstr_parse(int e)
+{
+ sldns_lookup_table *lt;
+ lt = sldns_lookup_by_id(sldns_wireparse_errors, LDNS_WIREPARSE_ERROR(e));
+ return lt?lt->name:"unknown error";
+}
+
+int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
+ struct sldns_file_parse_state* parse_state)
+{
+ char line[LDNS_RR_BUF_SIZE+1];
+ ssize_t size;
+
+ /* read an entire line in from the file */
+ if((size = sldns_fget_token_l(in, line, LDNS_PARSE_SKIP_SPACE,
+ LDNS_RR_BUF_SIZE, parse_state?&parse_state->lineno:NULL))
+ == -1) {
+ /* if last line was empty, we are now at feof, which is not
+ * always a parse error (happens when for instance last line
+ * was a comment)
+ */
+ return LDNS_WIREPARSE_ERR_SYNTAX;
+ }
+
+ /* we can have the situation, where we've read ok, but still got
+ * no bytes to play with, in this case size is 0 */
+ if(size == 0) {
+ *len = 0;
+ *dname_len = 0;
+ return LDNS_WIREPARSE_ERR_OK;
+ }
+
+ if(strncmp(line, "$ORIGIN", 7) == 0 && isspace(line[7])) {
+ size_t off = 8;
+ int s;
+ *len = 0;
+ *dname_len = 0;
+ if(!parse_state) return LDNS_WIREPARSE_ERR_OK;
+ while(isspace(line[off]))
+ off++;
+ parse_state->origin_len = sizeof(parse_state->origin);
+ s = sldns_str2wire_dname_buf(line+off, parse_state->origin,
+ &parse_state->origin_len);
+ if(s) parse_state->origin_len = 0;
+ return s;
+ } else if(strncmp(line, "$TTL", 4) == 0 && isspace(line[4])) {
+ const char* end = NULL;
+ size_t off = 8;
+ *len = 0;
+ *dname_len = 0;
+ if(!parse_state) return LDNS_WIREPARSE_ERR_OK;
+ while(isspace(line[off]))
+ off++;
+ parse_state->default_ttl = sldns_str2period(line+off, &end);
+ } else if (strncmp(line, "$INCLUDE", 8) == 0) {
+ *len = 0;
+ *dname_len = 0;
+ return LDNS_WIREPARSE_ERR_INCLUDE;
+ } else {
+ return sldns_str2wire_rr_buf(line, rr, len, dname_len,
+ parse_state?parse_state->default_ttl:0,
+ (parse_state&&parse_state->origin_len)?
+ parse_state->origin:NULL,
+ parse_state->origin_len,
+ (parse_state&&parse_state->prev_rr_len)?
+ parse_state->prev_rr:NULL,
+ parse_state->prev_rr_len);
+ }
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len,
+ sldns_rdf_type rdftype)
+{
+ switch (rdftype) {
+ case LDNS_RDF_TYPE_DNAME:
+ return sldns_str2wire_dname_buf(str, rd, len);
+ case LDNS_RDF_TYPE_INT8:
+ return sldns_str2wire_int8_buf(str, rd, len);
+ case LDNS_RDF_TYPE_INT16:
+ return sldns_str2wire_int16_buf(str, rd, len);
+ case LDNS_RDF_TYPE_INT32:
+ return sldns_str2wire_int32_buf(str, rd, len);
+ case LDNS_RDF_TYPE_A:
+ return sldns_str2wire_a_buf(str, rd, len);
+ case LDNS_RDF_TYPE_AAAA:
+ return sldns_str2wire_aaaa_buf(str, rd, len);
+ case LDNS_RDF_TYPE_STR:
+ return sldns_str2wire_str_buf(str, rd, len);
+ case LDNS_RDF_TYPE_APL:
+ return sldns_str2wire_apl_buf(str, rd, len);
+ case LDNS_RDF_TYPE_B64:
+ return sldns_str2wire_b64_buf(str, rd, len);
+ case LDNS_RDF_TYPE_B32_EXT:
+ return sldns_str2wire_b32_ext_buf(str, rd, len);
+ case LDNS_RDF_TYPE_HEX:
+ return sldns_str2wire_hex_buf(str, rd, len);
+ case LDNS_RDF_TYPE_NSEC:
+ return sldns_str2wire_nsec_buf(str, rd, len);
+ case LDNS_RDF_TYPE_TYPE:
+ return sldns_str2wire_type_buf(str, rd, len);
+ case LDNS_RDF_TYPE_CLASS:
+ return sldns_str2wire_class_buf(str, rd, len);
+ case LDNS_RDF_TYPE_CERT_ALG:
+ return sldns_str2wire_cert_alg_buf(str, rd, len);
+ case LDNS_RDF_TYPE_ALG:
+ return sldns_str2wire_alg_buf(str, rd, len);
+ case LDNS_RDF_TYPE_TIME:
+ return sldns_str2wire_time_buf(str, rd, len);
+ case LDNS_RDF_TYPE_PERIOD:
+ return sldns_str2wire_period_buf(str, rd, len);
+ case LDNS_RDF_TYPE_LOC:
+ return sldns_str2wire_loc_buf(str, rd, len);
+ case LDNS_RDF_TYPE_WKS:
+ return sldns_str2wire_wks_buf(str, rd, len);
+ case LDNS_RDF_TYPE_NSAP:
+ return sldns_str2wire_nsap_buf(str, rd, len);
+ case LDNS_RDF_TYPE_ATMA:
+ return sldns_str2wire_atma_buf(str, rd, len);
+ case LDNS_RDF_TYPE_IPSECKEY:
+ return sldns_str2wire_ipseckey_buf(str, rd, len);
+ case LDNS_RDF_TYPE_NSEC3_SALT:
+ return sldns_str2wire_nsec3_salt_buf(str, rd, len);
+ case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
+ return sldns_str2wire_b32_ext_buf(str, rd, len);
+ case LDNS_RDF_TYPE_ILNP64:
+ return sldns_str2wire_ilnp64_buf(str, rd, len);
+ case LDNS_RDF_TYPE_EUI48:
+ return sldns_str2wire_eui48_buf(str, rd, len);
+ case LDNS_RDF_TYPE_EUI64:
+ return sldns_str2wire_eui64_buf(str, rd, len);
+ case LDNS_RDF_TYPE_TAG:
+ return sldns_str2wire_tag_buf(str, rd, len);
+ case LDNS_RDF_TYPE_LONG_STR:
+ return sldns_str2wire_long_str_buf(str, rd, len);
+ case LDNS_RDF_TYPE_HIP:
+ return sldns_str2wire_hip_buf(str, rd, len);
+ case LDNS_RDF_TYPE_INT16_DATA:
+ return sldns_str2wire_int16_data_buf(str, rd, len);
+ case LDNS_RDF_TYPE_UNKNOWN:
+ case LDNS_RDF_TYPE_SERVICE:
+ return LDNS_WIREPARSE_ERR_NOT_IMPL;
+ case LDNS_RDF_TYPE_NONE:
+ default:
+ break;
+ }
+ return LDNS_WIREPARSE_ERR_GENERAL;
+}
+
+int sldns_str2wire_int8_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ char* end;
+ uint8_t r = (uint8_t)strtol((char*)str, &end, 10);
+ if(*end != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_INT, end-(char*)str);
+ if(*len < 1)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ rd[0] = r;
+ *len = 1;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_int16_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ char* end;
+ uint16_t r = (uint16_t)strtol((char*)str, &end, 10);
+ if(*end != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_INT, end-(char*)str);
+ if(*len < 2)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ sldns_write_uint16(rd, r);
+ *len = 2;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_int32_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ char* end;
+ uint32_t r;
+ errno = 0; /* must set to zero before call,
+ note race condition on errno */
+ if(*str == '-')
+ r = (uint32_t)strtol((char*)str, &end, 10);
+ else r = (uint32_t)strtoul((char*)str, &end, 10);
+ if(*end != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_INT, end-(char*)str);
+ if(errno == ERANGE)
+ return LDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW;
+ if(*len < 4)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ sldns_write_uint32(rd, r);
+ *len = 4;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_a_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ struct in_addr address;
+ if(inet_pton(AF_INET, (char*)str, &address) != 1)
+ return LDNS_WIREPARSE_ERR_SYNTAX_IP4;
+ if(*len < sizeof(address))
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ memmove(rd, &address, sizeof(address));
+ *len = sizeof(address);
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_aaaa_buf(const char* str, uint8_t* rd, size_t* len)
+{
+#ifdef AF_INET6
+ uint8_t address[LDNS_IP6ADDRLEN + 1];
+ if(inet_pton(AF_INET6, (char*)str, address) != 1)
+ return LDNS_WIREPARSE_ERR_SYNTAX_IP6;
+ if(*len < LDNS_IP6ADDRLEN)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ memmove(rd, address, LDNS_IP6ADDRLEN);
+ *len = LDNS_IP6ADDRLEN;
+ return LDNS_WIREPARSE_ERR_OK;
+#else
+ return LDNS_WIREPARSE_ERR_NOT_IMPL;
+#endif
+}
+
+int sldns_str2wire_str_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ uint8_t ch = 0;
+ size_t sl = 0;
+ const char* s = str;
+ /* skip length byte */
+ if(*len < 1)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+
+ /* read characters */
+ while(sldns_parse_char(&ch, &s)) {
+ if(sl >= 255)
+ return RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR, s-str);
+ if(*len < sl+1)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ s-str);
+ rd[++sl] = ch;
+ }
+ if(!s)
+ return LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE;
+ rd[0] = (uint8_t)sl;
+ *len = sl+1;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_apl_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ const char *my_str = str;
+
+ char my_ip_str[64];
+ size_t ip_str_len;
+
+ uint16_t family;
+ int negation;
+ size_t adflength = 0;
+ uint8_t data[16+4];
+ uint8_t prefix;
+ size_t i;
+
+ if(strlen(my_str) == 0) {
+ /* empty APL element, no data, no string */
+ *len = 0;
+ return LDNS_WIREPARSE_ERR_OK;
+ }
+
+ /* [!]afi:address/prefix */
+ if (strlen(my_str) < 2
+ || strchr(my_str, ':') == NULL
+ || strchr(my_str, '/') == NULL
+ || strchr(my_str, ':') > strchr(my_str, '/')) {
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ if (my_str[0] == '!') {
+ negation = 1;
+ my_str += 1;
+ } else {
+ negation = 0;
+ }
+
+ family = (uint16_t) atoi(my_str);
+
+ my_str = strchr(my_str, ':') + 1;
+
+ /* need ip addr and only ip addr for inet_pton */
+ ip_str_len = (size_t) (strchr(my_str, '/') - my_str);
+ if(ip_str_len+1 > sizeof(my_ip_str))
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ (void)strlcpy(my_ip_str, my_str, sizeof(my_ip_str));
+ my_ip_str[ip_str_len] = 0;
+
+ if (family == 1) {
+ /* ipv4 */
+ if(inet_pton(AF_INET, my_ip_str, data+4) == 0)
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ for (i = 0; i < 4; i++) {
+ if (data[i+4] != 0) {
+ adflength = i + 1;
+ }
+ }
+ } else if (family == 2) {
+ /* ipv6 */
+ if (inet_pton(AF_INET6, my_ip_str, data+4) == 0)
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ for (i = 0; i < 16; i++) {
+ if (data[i+4] != 0) {
+ adflength = i + 1;
+ }
+ }
+ } else {
+ /* unknown family */
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ my_str = strchr(my_str, '/') + 1;
+ prefix = (uint8_t) atoi(my_str);
+
+ sldns_write_uint16(data, family);
+ data[2] = prefix;
+ data[3] = (uint8_t)adflength;
+ if (negation) {
+ /* set bit 1 of byte 3 */
+ data[3] = data[3] | 0x80;
+ }
+
+ if(*len < 4+adflength)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ memmove(rd, data, 4+adflength);
+ *len = 4+adflength;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ size_t sz = sldns_b64_pton_calculate_size(strlen(str));
+ int n;
+ if(*len < sz)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ n = sldns_b64_pton(str, rd, *len);
+ if(n < 0)
+ return LDNS_WIREPARSE_ERR_SYNTAX_B64;
+ *len = (size_t)n;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_b32_ext_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ size_t slen = strlen(str);
+ size_t sz = sldns_b32_pton_calculate_size(slen);
+ int n;
+ if(*len < 1+sz)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ rd[0] = (uint8_t)sz;
+ n = sldns_b32_pton_extended_hex(str, slen, rd+1, *len-1);
+ if(n < 0)
+ return LDNS_WIREPARSE_ERR_SYNTAX_B32_EXT;
+ *len = (size_t)n+1;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ const char* s = str;
+ size_t dlen = 0; /* number of hexdigits parsed */
+ while(*s) {
+ if(isspace(*s)) {
+ s++;
+ continue;
+ }
+ if(!isxdigit(*s))
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
+ if(*len < dlen/2 + 1)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ s-str);
+ if((dlen&1)==0)
+ rd[dlen/2] = (uint8_t)sldns_hexdigit_to_int(*s++) * 16;
+ else rd[dlen/2] += (uint8_t)sldns_hexdigit_to_int(*s++);
+ dlen++;
+ }
+ if((dlen&1)!=0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
+ *len = dlen/2;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_nsec_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ const char *delim = "\n\t ";
+ char token[64]; /* for a type name */
+ size_t type_count = 0;
+ int block;
+ size_t used = 0;
+ uint16_t maxtype = 0;
+ uint8_t typebits[8192]; /* 65536 bits */
+ uint8_t window_in_use[256];
+
+ /* string in buffer */
+ sldns_buffer strbuf;
+ sldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str));
+
+ /* parse the types */
+ memset(typebits, 0, sizeof(typebits));
+ memset(window_in_use, 0, sizeof(window_in_use));
+ while(sldns_buffer_remaining(&strbuf) > 0 &&
+ sldns_bget_token(&strbuf, token, delim, sizeof(token)) != -1) {
+ uint16_t t = sldns_get_rr_type_by_name(token);
+ if(token[0] == 0)
+ continue;
+ if(t == 0 && strcmp(token, "TYPE0") != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_TYPE,
+ sldns_buffer_position(&strbuf));
+ typebits[t/8] |= (0x80>>(t%8));
+ window_in_use[t/256] = 1;
+ type_count++;
+ if(t > maxtype) maxtype = t;
+ }
+
+ /* empty NSEC bitmap */
+ if(type_count == 0) {
+ *len = 0;
+ return LDNS_WIREPARSE_ERR_OK;
+ }
+
+ /* encode windows {u8 windowblock, u8 bitmaplength, 0-32u8 bitmap},
+ * block is 0-255 upper octet of types, length if 0-32. */
+ for(block = 0; block <= (int)maxtype/256; block++) {
+ int i, blocklen = 0;
+ if(!window_in_use[block])
+ continue;
+ for(i=0; i<32; i++) {
+ if(typebits[block*32+i] != 0)
+ blocklen = i+1;
+ }
+ if(blocklen == 0)
+ continue; /* empty window should have been !in_use */
+ if(used+blocklen+2 > *len)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ rd[used+0] = (uint8_t)block;
+ rd[used+1] = (uint8_t)blocklen;
+ for(i=0; i<blocklen; i++) {
+ rd[used+2+i] = typebits[block*32+i];
+ }
+ used += blocklen+2;
+ }
+ *len = used;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_type_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ uint16_t t = sldns_get_rr_type_by_name(str);
+ if(t == 0 && strcmp(str, "TYPE0") != 0)
+ return LDNS_WIREPARSE_ERR_SYNTAX_TYPE;
+ if(*len < 2)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ sldns_write_uint16(rd, t);
+ *len = 2;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_class_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ uint16_t c = sldns_get_rr_class_by_name(str);
+ if(c == 0 && strcmp(str, "CLASS0") != 0)
+ return LDNS_WIREPARSE_ERR_SYNTAX_CLASS;
+ if(*len < 2)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ sldns_write_uint16(rd, c);
+ *len = 2;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/* An certificate alg field can either be specified as a 8 bits number
+ * or by its symbolic name. Handle both */
+int sldns_str2wire_cert_alg_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ sldns_lookup_table *lt = sldns_lookup_by_name(sldns_cert_algorithms,
+ str);
+ if(*len < 2)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ if(lt) {
+ sldns_write_uint16(rd, (uint16_t)lt->id);
+ } else {
+ int s = sldns_str2wire_int16_buf(str, rd, len);
+ if(s) return s;
+ if(sldns_read_uint16(rd) == 0)
+ return LDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM;
+ }
+ *len = 2;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/* An alg field can either be specified as a 8 bits number
+ * or by its symbolic name. Handle both */
+int sldns_str2wire_alg_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ sldns_lookup_table *lt = sldns_lookup_by_name(sldns_algorithms, str);
+ if(*len < 1)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ if(lt) {
+ rd[0] = (uint8_t)lt->id;
+ *len = 1;
+ } else {
+ /* try as-is (a number) */
+ return sldns_str2wire_int8_buf(str, rd, len);
+ }
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ /* convert a time YYYYDDMMHHMMSS to wireformat */
+ struct tm tm;
+ if(*len < 4)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+
+ /* Try to scan the time... */
+ memset(&tm, 0, sizeof(tm));
+ if (strlen(str) == 14 && sscanf(str, "%4d%2d%2d%2d%2d%2d",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday, &tm.tm_hour,
+ &tm.tm_min, &tm.tm_sec) == 6) {
+ tm.tm_year -= 1900;
+ tm.tm_mon--;
+ /* Check values */
+ if (tm.tm_year < 70)
+ return LDNS_WIREPARSE_ERR_SYNTAX_TIME;
+ if (tm.tm_mon < 0 || tm.tm_mon > 11)
+ return LDNS_WIREPARSE_ERR_SYNTAX_TIME;
+ if (tm.tm_mday < 1 || tm.tm_mday > 31)
+ return LDNS_WIREPARSE_ERR_SYNTAX_TIME;
+ if (tm.tm_hour < 0 || tm.tm_hour > 23)
+ return LDNS_WIREPARSE_ERR_SYNTAX_TIME;
+ if (tm.tm_min < 0 || tm.tm_min > 59)
+ return LDNS_WIREPARSE_ERR_SYNTAX_TIME;
+ if (tm.tm_sec < 0 || tm.tm_sec > 59)
+ return LDNS_WIREPARSE_ERR_SYNTAX_TIME;
+
+ sldns_write_uint32(rd, sldns_mktime_from_utc(&tm));
+ } else {
+ /* handle it as 32 bits timestamp */
+ char *end;
+ uint32_t l = (uint32_t)strtol((char*)str, &end, 10);
+ if(*end != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_TIME,
+ end-(char*)str);
+ sldns_write_uint32(rd, l);
+ }
+ *len = 4;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ const char* end;
+ uint32_t p = sldns_str2period(str, &end);
+ if(*end != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_PERIOD, end-str);
+ if(*len < 4)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ sldns_write_uint32(rd, p);
+ *len = 4;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+/** read "<digits>[.<digits>][mM]" into mantissa exponent format for LOC type */
+static int
+loc_parse_cm(char* my_str, char** endstr, uint8_t* m, uint8_t* e)
+{
+ uint32_t meters = 0, cm = 0, val;
+ while (isblank(*my_str)) {
+ my_str++;
+ }
+ meters = (uint32_t)strtol(my_str, &my_str, 10);
+ if (*my_str == '.') {
+ my_str++;
+ cm = (uint32_t)strtol(my_str, &my_str, 10);
+ }
+ if (meters >= 1) {
+ *e = 2;
+ val = meters;
+ } else {
+ *e = 0;
+ val = cm;
+ }
+ while(val >= 10) {
+ (*e)++;
+ val /= 10;
+ }
+ *m = (uint8_t)val;
+
+ if (*e > 9)
+ return 0;
+ if (*my_str == 'm' || *my_str == 'M') {
+ my_str++;
+ }
+ *endstr = my_str;
+ return 1;
+}
+
+int sldns_str2wire_loc_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ uint32_t latitude = 0;
+ uint32_t longitude = 0;
+ uint32_t altitude = 0;
+
+ uint32_t equator = (uint32_t)1<<31; /* 2**31 */
+
+ /* only support version 0 */
+ uint32_t h = 0;
+ uint32_t m = 0;
+ uint8_t size_b = 1, size_e = 2;
+ uint8_t horiz_pre_b = 1, horiz_pre_e = 6;
+ uint8_t vert_pre_b = 1, vert_pre_e = 3;
+
+ double s = 0.0;
+ int northerness;
+ int easterness;
+
+ char *my_str = (char *) str;
+
+ if (isdigit((int) *my_str)) {
+ h = (uint32_t) strtol(my_str, &my_str, 10);
+ } else {
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ while (isblank((int) *my_str)) {
+ my_str++;
+ }
+
+ if (isdigit((int) *my_str)) {
+ m = (uint32_t) strtol(my_str, &my_str, 10);
+ } else if (*my_str == 'N' || *my_str == 'S') {
+ goto north;
+ } else {
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ while (isblank((int) *my_str)) {
+ my_str++;
+ }
+
+ if (isdigit((int) *my_str)) {
+ s = strtod(my_str, &my_str);
+ }
+
+ /* skip blanks before norterness */
+ while (isblank((int) *my_str)) {
+ my_str++;
+ }
+
+north:
+ if (*my_str == 'N') {
+ northerness = 1;
+ } else if (*my_str == 'S') {
+ northerness = 0;
+ } else {
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ my_str++;
+
+ /* store number */
+ s = 1000.0 * s;
+ /* add a little to make floor in conversion a round */
+ s += 0.0005;
+ latitude = (uint32_t) s;
+ latitude += 1000 * 60 * m;
+ latitude += 1000 * 60 * 60 * h;
+ if (northerness) {
+ latitude = equator + latitude;
+ } else {
+ latitude = equator - latitude;
+ }
+ while (isblank(*my_str)) {
+ my_str++;
+ }
+
+ if (isdigit((int) *my_str)) {
+ h = (uint32_t) strtol(my_str, &my_str, 10);
+ } else {
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ while (isblank((int) *my_str)) {
+ my_str++;
+ }
+
+ if (isdigit((int) *my_str)) {
+ m = (uint32_t) strtol(my_str, &my_str, 10);
+ } else if (*my_str == 'E' || *my_str == 'W') {
+ goto east;
+ } else {
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ while (isblank(*my_str)) {
+ my_str++;
+ }
+
+ if (isdigit((int) *my_str)) {
+ s = strtod(my_str, &my_str);
+ }
+
+ /* skip blanks before easterness */
+ while (isblank(*my_str)) {
+ my_str++;
+ }
+
+east:
+ if (*my_str == 'E') {
+ easterness = 1;
+ } else if (*my_str == 'W') {
+ easterness = 0;
+ } else {
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ my_str++;
+
+ /* store number */
+ s *= 1000.0;
+ /* add a little to make floor in conversion a round */
+ s += 0.0005;
+ longitude = (uint32_t) s;
+ longitude += 1000 * 60 * m;
+ longitude += 1000 * 60 * 60 * h;
+
+ if (easterness) {
+ longitude += equator;
+ } else {
+ longitude = equator - longitude;
+ }
+
+ altitude = (uint32_t)(strtod(my_str, &my_str)*100.0 +
+ 10000000.0 + 0.5);
+ if (*my_str == 'm' || *my_str == 'M') {
+ my_str++;
+ }
+
+ if (strlen(my_str) > 0) {
+ if(!loc_parse_cm(my_str, &my_str, &size_b, &size_e))
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ if (strlen(my_str) > 0) {
+ if(!loc_parse_cm(my_str, &my_str, &horiz_pre_b, &horiz_pre_e))
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ if (strlen(my_str) > 0) {
+ if(!loc_parse_cm(my_str, &my_str, &vert_pre_b, &vert_pre_e))
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ }
+
+ if(*len < 16)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ rd[0] = 0;
+ rd[1] = ((size_b << 4) & 0xf0) | (size_e & 0x0f);
+ rd[2] = ((horiz_pre_b << 4) & 0xf0) | (horiz_pre_e & 0x0f);
+ rd[3] = ((vert_pre_b << 4) & 0xf0) | (vert_pre_e & 0x0f);
+ sldns_write_uint32(rd + 4, latitude);
+ sldns_write_uint32(rd + 8, longitude);
+ sldns_write_uint32(rd + 12, altitude);
+ *len = 16;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ int rd_len = 1;
+ int have_proto = 0;
+ char token[50], proto_str[50];
+ sldns_buffer strbuf;
+ sldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str));
+ proto_str[0]=0;
+
+ /* check we have one byte for proto */
+ if(*len < 1)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+
+ while(sldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) > 0) {
+ if(!have_proto) {
+ struct protoent *p = getprotobyname(token);
+ have_proto = 1;
+ if(p) rd[0] = (uint8_t)p->p_proto;
+ else rd[0] = (uint8_t)atoi(token);
+ (void)strlcpy(proto_str, token, sizeof(proto_str));
+ } else {
+ int serv_port;
+ struct servent *serv = getservbyname(token, proto_str);
+ if(serv) serv_port=(int)ntohs((uint16_t)serv->s_port);
+ else {
+ serv_port = atoi(token);
+ if(serv_port == 0 && strcmp(token, "0") != 0) {
+#ifdef HAVE_ENDSERVENT
+ endservent();
+#endif
+#ifdef HAVE_ENDPROTOENT
+ endprotoent();
+#endif
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX,
+ sldns_buffer_position(&strbuf));
+ }
+ if(serv_port < 0 || serv_port > 65535) {
+#ifdef HAVE_ENDSERVENT
+ endservent();
+#endif
+#ifdef HAVE_ENDPROTOENT
+ endprotoent();
+#endif
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX,
+ sldns_buffer_position(&strbuf));
+ }
+ }
+ if(rd_len < 1+serv_port/8+1) {
+ /* bitmap is larger, init new bytes at 0 */
+ if(*len < 1+(size_t)serv_port/8+1) {
+#ifdef HAVE_ENDSERVENT
+ endservent();
+#endif
+#ifdef HAVE_ENDPROTOENT
+ endprotoent();
+#endif
+ return RET_ERR(
+ LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(&strbuf));
+ }
+ memset(rd+rd_len, 0, 1+(size_t)serv_port/8+1-rd_len);
+ rd_len = 1+serv_port/8+1;
+ }
+ rd[1+ serv_port/8] |= (1 << (7 - serv_port % 8));
+ }
+ }
+ *len = (size_t)rd_len;
+
+#ifdef HAVE_ENDSERVENT
+ endservent();
+#endif
+#ifdef HAVE_ENDPROTOENT
+ endprotoent();
+#endif
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_nsap_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ const char* s = str;
+ size_t slen;
+ size_t dlen = 0; /* number of hexdigits parsed */
+
+ /* just a hex string with optional dots? */
+ if (s[0] != '0' || s[1] != 'x')
+ return LDNS_WIREPARSE_ERR_INVALID_STR;
+ s += 2;
+ slen = strlen(s);
+ if(slen > LDNS_MAX_RDFLEN*2)
+ return LDNS_WIREPARSE_ERR_LABEL_OVERFLOW;
+ while(*s) {
+ if(isspace(*s) || *s == '.') {
+ s++;
+ continue;
+ }
+ if(!isxdigit(*s))
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
+ if(*len < dlen/2 + 1)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ s-str);
+ if((dlen&1)==0)
+ rd[dlen/2] = (uint8_t)sldns_hexdigit_to_int(*s++) * 16;
+ else rd[dlen/2] += sldns_hexdigit_to_int(*s++);
+ dlen++;
+ }
+ if((dlen&1)!=0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
+ *len = dlen/2;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ const char* s = str;
+ size_t slen = strlen(str);
+ size_t dlen = 0; /* number of hexdigits parsed */
+
+ /* just a hex string with optional dots? */
+ /* notimpl e.164 format */
+ if(slen > LDNS_MAX_RDFLEN*2)
+ return LDNS_WIREPARSE_ERR_LABEL_OVERFLOW;
+ while(*s) {
+ if(isspace(*s) || *s == '.') {
+ s++;
+ continue;
+ }
+ if(!isxdigit(*s))
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
+ if(*len < dlen/2 + 1)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ s-str);
+ if((dlen&1)==0)
+ rd[dlen/2] = (uint8_t)sldns_hexdigit_to_int(*s++) * 16;
+ else rd[dlen/2] += sldns_hexdigit_to_int(*s++);
+ dlen++;
+ }
+ if((dlen&1)!=0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
+ *len = dlen/2;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_ipseckey_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ size_t gwlen = 0, keylen = 0;
+ int s;
+ uint8_t gwtype;
+ char token[512];
+ sldns_buffer strbuf;
+ sldns_buffer_init_frm_data(&strbuf, (uint8_t*)str, strlen(str));
+
+ if(*len < 3)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ /* precedence */
+ if(sldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) <= 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,
+ sldns_buffer_position(&strbuf));
+ rd[0] = (uint8_t)atoi(token);
+ /* gateway_type */
+ if(sldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) <= 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,
+ sldns_buffer_position(&strbuf));
+ rd[1] = (uint8_t)atoi(token);
+ gwtype = rd[1];
+ /* algorithm */
+ if(sldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) <= 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,
+ sldns_buffer_position(&strbuf));
+ rd[2] = (uint8_t)atoi(token);
+
+ /* gateway */
+ if(sldns_bget_token(&strbuf, token, "\t\n ", sizeof(token)) <= 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,
+ sldns_buffer_position(&strbuf));
+ if(gwtype == 0) {
+ /* NOGATEWAY */
+ if(strcmp(token, ".") != 0)
+ return RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,
+ sldns_buffer_position(&strbuf));
+ gwlen = 0;
+ } else if(gwtype == 1) {
+ /* IP4 */
+ gwlen = *len - 3;
+ s = sldns_str2wire_a_buf(token, rd+3, &gwlen);
+ if(s) return RET_ERR_SHIFT(s, sldns_buffer_position(&strbuf));
+ } else if(gwtype == 2) {
+ /* IP6 */
+ gwlen = *len - 3;
+ s = sldns_str2wire_aaaa_buf(token, rd+3, &gwlen);
+ if(s) return RET_ERR_SHIFT(s, sldns_buffer_position(&strbuf));
+ } else if(gwtype == 3) {
+ /* DNAME */
+ gwlen = *len - 3;
+ s = sldns_str2wire_dname_buf(token, rd+3, &gwlen);
+ if(s) return RET_ERR_SHIFT(s, sldns_buffer_position(&strbuf));
+ } else {
+ /* unknown gateway type */
+ return RET_ERR(LDNS_WIREPARSE_ERR_INVALID_STR,
+ sldns_buffer_position(&strbuf));
+ }
+ /* double check for size */
+ if(*len < 3 + gwlen)
+ return RET_ERR(LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL,
+ sldns_buffer_position(&strbuf));
+
+ /* publickey in remainder of strbuf */
+ keylen = *len - 3 - gwlen;
+ s = sldns_str2wire_b64_buf((const char*)sldns_buffer_current(&strbuf),
+ rd+3+gwlen, &keylen);
+ if(s) return RET_ERR_SHIFT(s, sldns_buffer_position(&strbuf));
+
+ *len = 3 + gwlen + keylen;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_nsec3_salt_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ int i, salt_length_str = (int)strlen(str);
+ if (salt_length_str == 1 && str[0] == '-') {
+ salt_length_str = 0;
+ } else if (salt_length_str % 2 != 0) {
+ return LDNS_WIREPARSE_ERR_SYNTAX_HEX;
+ }
+ if (salt_length_str > 512)
+ return LDNS_WIREPARSE_ERR_SYNTAX_HEX;
+ if(*len < 1+(size_t)salt_length_str / 2)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ rd[0] = (uint8_t) (salt_length_str / 2);
+ for (i = 0; i < salt_length_str; i += 2) {
+ if (isxdigit((int)str[i]) && isxdigit((int)str[i+1])) {
+ rd[1+i/2] = (uint8_t)(sldns_hexdigit_to_int(str[i])*16
+ + sldns_hexdigit_to_int(str[i+1]));
+ } else {
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_HEX, i);
+ }
+ }
+ *len = 1 + (size_t)rd[0];
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_ilnp64_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ unsigned int a, b, c, d;
+ uint16_t shorts[4];
+ int l;
+ if(*len < sizeof(shorts))
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+
+ if (sscanf(str, "%4x:%4x:%4x:%4x%n", &a, &b, &c, &d, &l) != 4 ||
+ l != (int)strlen(str) || /* more data to read */
+ strpbrk(str, "+-") /* signed hexes */
+ )
+ return LDNS_WIREPARSE_ERR_SYNTAX_ILNP64;
+ shorts[0] = htons(a);
+ shorts[1] = htons(b);
+ shorts[2] = htons(c);
+ shorts[3] = htons(d);
+ memmove(rd, &shorts, sizeof(shorts));
+ *len = sizeof(shorts);
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_eui48_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ unsigned int a, b, c, d, e, f;
+ int l;
+
+ if(*len < 6)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ if (sscanf(str, "%2x-%2x-%2x-%2x-%2x-%2x%n",
+ &a, &b, &c, &d, &e, &f, &l) != 6 ||
+ l != (int)strlen(str))
+ return LDNS_WIREPARSE_ERR_SYNTAX_EUI48;
+ rd[0] = a;
+ rd[1] = b;
+ rd[2] = c;
+ rd[3] = d;
+ rd[4] = e;
+ rd[5] = f;
+ *len = 6;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_eui64_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ unsigned int a, b, c, d, e, f, g, h;
+ int l;
+
+ if(*len < 8)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ if (sscanf(str, "%2x-%2x-%2x-%2x-%2x-%2x-%2x-%2x%n",
+ &a, &b, &c, &d, &e, &f, &g, &h, &l) != 8 ||
+ l != (int)strlen(str))
+ return LDNS_WIREPARSE_ERR_SYNTAX_EUI64;
+ rd[0] = a;
+ rd[1] = b;
+ rd[2] = c;
+ rd[3] = d;
+ rd[4] = e;
+ rd[5] = f;
+ rd[6] = g;
+ rd[7] = h;
+ *len = 8;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ size_t slen = strlen(str);
+ const char* ptr;
+
+ if (slen > 255)
+ return LDNS_WIREPARSE_ERR_SYNTAX_TAG;
+ if(*len < slen+1)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ for (ptr = str; *ptr; ptr++) {
+ if(!isalnum(*ptr))
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_TAG, ptr-str);
+ }
+ rd[0] = slen;
+ memmove(rd+1, str, slen);
+ *len = slen+1;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_long_str_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ uint8_t ch = 0;
+ const char* pstr = str;
+ size_t length = 0;
+
+ /* Fill data with parsed bytes */
+ while (sldns_parse_char(&ch, &pstr)) {
+ if(*len < length+1)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ rd[length++] = ch;
+ }
+ if(!pstr)
+ return LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE;
+ *len = length;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ char* s, *end;
+ int e;
+ size_t hitlen, pklen = 0;
+ /* presentation format:
+ * pk-algo HIThex pubkeybase64
+ * wireformat:
+ * hitlen[1byte] pkalgo[1byte] pubkeylen[2byte] [hit] [pubkey] */
+ if(*len < 4)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+
+ /* read PK algorithm */
+ rd[1] = (uint8_t)strtol((char*)str, &s, 10);
+ if(*s != ' ')
+ return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX_INT, s-(char*)str);
+ s++;
+ while(*s == ' ')
+ s++;
+
+ /* read HIT hex tag */
+ /* zero terminate the tag (replace later) */
+ end = strchr(s, ' ');
+ if(!end) return RET_ERR(LDNS_WIREPARSE_ERR_SYNTAX, s-(char*)str);
+ *end = 0;
+ hitlen = *len - 4;
+ if((e = sldns_str2wire_hex_buf(s, rd+4, &hitlen)) != 0) {
+ *end = ' ';
+ return RET_ERR_SHIFT(e, s-(char*)str);
+ }
+ if(hitlen > 255) {
+ *end = ' ';
+ return RET_ERR(LDNS_WIREPARSE_ERR_LABEL_OVERFLOW, s-(char*)str+255*2);
+ }
+ rd[0] = (uint8_t)hitlen;
+ *end = ' ';
+ s = end+1;
+
+ /* read pubkey base64 sequence */
+ pklen = *len - 4 - hitlen;
+ if((e = sldns_str2wire_b64_buf(s, rd+4+hitlen, &pklen)) != 0)
+ return RET_ERR_SHIFT(e, s-(char*)str);
+ if(pklen > 65535)
+ return RET_ERR(LDNS_WIREPARSE_ERR_LABEL_OVERFLOW, s-(char*)str+65535);
+ sldns_write_uint16(rd+2, pklen);
+
+ *len = 4 + hitlen + pklen;
+ return LDNS_WIREPARSE_ERR_OK;
+}
+
+int sldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ size_t sz = sldns_b64_pton_calculate_size(strlen(str));
+ int n;
+ if(*len < sz+2)
+ return LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ if(sz > 65535)
+ return LDNS_WIREPARSE_ERR_LABEL_OVERFLOW;
+ n = sldns_b64_pton(str, rd+2, (*len)-2);
+ if(n < 0)
+ return LDNS_WIREPARSE_ERR_SYNTAX_B64;
+ sldns_write_uint16(rd, (uint16_t)n);
+ *len = (size_t)n;
+ return LDNS_WIREPARSE_ERR_OK;
+}
diff --git a/contrib/unbound/ldns/str2wire.h b/contrib/unbound/ldns/str2wire.h
new file mode 100644
index 0000000..94c8933
--- /dev/null
+++ b/contrib/unbound/ldns/str2wire.h
@@ -0,0 +1,541 @@
+/**
+ * str2wire.h - read txt presentation of RRs
+ *
+ * (c) NLnet Labs, 2005-2006
+ *
+ * See the file LICENSE for the license
+ */
+
+/**
+ * \file
+ *
+ * Parses text to wireformat.
+ */
+
+#ifndef LDNS_STR2WIRE_H
+#define LDNS_STR2WIRE_H
+
+/* include rrdef for MAX_DOMAINLEN constant */
+#include <ldns/rrdef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+struct sldns_struct_lookup_table;
+
+/** buffer to read an RR, cannot be larger than 64K because of packet size */
+#define LDNS_RR_BUF_SIZE 65535 /* bytes */
+#define LDNS_DEFAULT_TTL 3600
+
+/*
+ * To convert class and type to string see
+ * sldns_get_rr_class_by_name(str)
+ * sldns_get_rr_type_by_name(str)
+ * from rrdef.h
+ */
+
+/**
+ * Convert text string into dname wireformat, mallocless, with user buffer.
+ * @param str: the text string with the domain name.
+ * @param buf: the result buffer, suggested size LDNS_MAX_DOMAINLEN+1
+ * @param len: length of the buffer on input, length of the result on output.
+ * @return 0 on success, otherwise an error.
+ */
+int sldns_str2wire_dname_buf(const char* str, uint8_t* buf, size_t* len);
+
+/**
+ * Same as sldns_str2wire_dname_buf, but concatenates origin if the domain
+ * name is relative (does not end in '.').
+ * @param str: the text string with the domain name.
+ * @param buf: the result buffer, suggested size LDNS_MAX_DOMAINLEN+1
+ * @param len: length of the buffer on input, length of the result on output.
+ * @param origin: the origin to append or NULL (nothing is appended).
+ * @param origin_len: length of origin.
+ * @return 0 on success, otherwise an error.
+ */
+int sldns_str2wire_dname_buf_origin(const char* str, uint8_t* buf, size_t* len,
+ uint8_t* origin, size_t origin_len);
+
+/**
+ * Convert text string into dname wireformat
+ * @param str: the text string with the domain name.
+ * @param len: returned length of wireformat.
+ * @return wireformat dname (malloced) or NULL on failure.
+ */
+uint8_t* sldns_str2wire_dname(const char* str, size_t* len);
+
+/**
+ * Convert text RR to wireformat, with user buffer.
+ * @param str: the RR data in text presentation format.
+ * @param rr: the buffer where the result is stored into. This buffer has
+ * the wire-dname(uncompressed), type, class, ttl, rdatalen, rdata.
+ * These values are probably not aligned, and in network format.
+ * Use the sldns_wirerr_get_xxx functions to access them safely.
+ * buffer size LDNS_RR_BUF_SIZE is suggested.
+ * @param len: on input the length of the buffer, on output the amount of
+ * the buffer used for the rr.
+ * @param dname_len: if non-NULL, filled with the dname length as result.
+ * Because after the dname you find the type, class, ttl, rdatalen, rdata.
+ * @param default_ttl: TTL used if no TTL available.
+ * @param origin: used for origin dname (if not NULL)
+ * @param origin_len: length of origin.
+ * @param prev: used for prev_rr dname (if not NULL)
+ * @param prev_len: length of prev.
+ * @return 0 on success, an error on failure.
+ */
+int sldns_str2wire_rr_buf(const char* str, uint8_t* rr, size_t* len,
+ size_t* dname_len, uint32_t default_ttl, uint8_t* origin,
+ size_t origin_len, uint8_t* prev, size_t prev_len);
+
+/**
+ * Same as sldns_str2wire_rr_buf, but there is no rdata, it returns an RR
+ * with zero rdata and no ttl. It has name, type, class.
+ * You can access those with the sldns_wirerr_get_type and class functions.
+ * @param str: the RR data in text presentation format.
+ * @param rr: the buffer where the result is stored into.
+ * @param len: on input the length of the buffer, on output the amount of
+ * the buffer used for the rr.
+ * @param dname_len: if non-NULL, filled with the dname length as result.
+ * Because after the dname you find the type, class, ttl, rdatalen, rdata.
+ * @param origin: used for origin dname (if not NULL)
+ * @param origin_len: length of origin.
+ * @param prev: used for prev_rr dname (if not NULL)
+ * @param prev_len: length of prev.
+ * @return 0 on success, an error on failure.
+ */
+int sldns_str2wire_rr_question_buf(const char* str, uint8_t* rr, size_t* len,
+ size_t* dname_len, uint8_t* origin, size_t origin_len, uint8_t* prev,
+ size_t prev_len);
+
+/**
+ * Get the type of the RR.
+ * @param rr: the RR in wire format.
+ * @param len: rr length.
+ * @param dname_len: dname length to skip.
+ * @return type in host byteorder
+ */
+uint16_t sldns_wirerr_get_type(uint8_t* rr, size_t len, size_t dname_len);
+
+/**
+ * Get the class of the RR.
+ * @param rr: the RR in wire format.
+ * @param len: rr length.
+ * @param dname_len: dname length to skip.
+ * @return class in host byteorder
+ */
+uint16_t sldns_wirerr_get_class(uint8_t* rr, size_t len, size_t dname_len);
+
+/**
+ * Get the ttl of the RR.
+ * @param rr: the RR in wire format.
+ * @param len: rr length.
+ * @param dname_len: dname length to skip.
+ * @return ttl in host byteorder
+ */
+uint32_t sldns_wirerr_get_ttl(uint8_t* rr, size_t len, size_t dname_len);
+
+/**
+ * Get the rdata length of the RR.
+ * @param rr: the RR in wire format.
+ * @param len: rr length.
+ * @param dname_len: dname length to skip.
+ * @return rdata length in host byteorder
+ * If the rdata length is larger than the rr-len allows, it is truncated.
+ * So, that it is safe to read the data length returned
+ * from this function from the rdata pointer of sldns_wirerr_get_rdata.
+ */
+uint16_t sldns_wirerr_get_rdatalen(uint8_t* rr, size_t len, size_t dname_len);
+
+/**
+ * Get the rdata pointer of the RR.
+ * @param rr: the RR in wire format.
+ * @param len: rr length.
+ * @param dname_len: dname length to skip.
+ * @return rdata pointer
+ */
+uint8_t* sldns_wirerr_get_rdata(uint8_t* rr, size_t len, size_t dname_len);
+
+/**
+ * Get the rdata pointer of the RR. prefixed with rdata length.
+ * @param rr: the RR in wire format.
+ * @param len: rr length.
+ * @param dname_len: dname length to skip.
+ * @return pointer to rdatalength, followed by the rdata.
+ */
+uint8_t* sldns_wirerr_get_rdatawl(uint8_t* rr, size_t len, size_t dname_len);
+
+/**
+ * Parse result codes
+ */
+#define LDNS_WIREPARSE_MASK 0x0fff
+#define LDNS_WIREPARSE_SHIFT 12
+#define LDNS_WIREPARSE_ERROR(e) ((e)&LDNS_WIREPARSE_MASK)
+#define LDNS_WIREPARSE_OFFSET(e) (((e)&~LDNS_WIREPARSE_MASK)>>LDNS_WIREPARSE_SHIFT)
+/* use lookuptable to get error string, sldns_wireparse_errors */
+#define LDNS_WIREPARSE_ERR_OK 0
+#define LDNS_WIREPARSE_ERR_GENERAL 342
+#define LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW 343
+#define LDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW 344
+#define LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL 345
+#define LDNS_WIREPARSE_ERR_LABEL_OVERFLOW 346
+#define LDNS_WIREPARSE_ERR_EMPTY_LABEL 347
+#define LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE 348
+#define LDNS_WIREPARSE_ERR_SYNTAX 349
+#define LDNS_WIREPARSE_ERR_SYNTAX_TTL 350
+#define LDNS_WIREPARSE_ERR_SYNTAX_TYPE 351
+#define LDNS_WIREPARSE_ERR_SYNTAX_CLASS 352
+#define LDNS_WIREPARSE_ERR_SYNTAX_RDATA 353
+#define LDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE 354
+#define LDNS_WIREPARSE_ERR_INVALID_STR 355
+#define LDNS_WIREPARSE_ERR_SYNTAX_B64 356
+#define LDNS_WIREPARSE_ERR_SYNTAX_B32_EXT 357
+#define LDNS_WIREPARSE_ERR_SYNTAX_HEX 358
+#define LDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM 359
+#define LDNS_WIREPARSE_ERR_SYNTAX_TIME 360
+#define LDNS_WIREPARSE_ERR_SYNTAX_PERIOD 361
+#define LDNS_WIREPARSE_ERR_SYNTAX_ILNP64 362
+#define LDNS_WIREPARSE_ERR_SYNTAX_EUI48 363
+#define LDNS_WIREPARSE_ERR_SYNTAX_EUI64 364
+#define LDNS_WIREPARSE_ERR_SYNTAX_TAG 365
+#define LDNS_WIREPARSE_ERR_NOT_IMPL 366
+#define LDNS_WIREPARSE_ERR_SYNTAX_INT 367
+#define LDNS_WIREPARSE_ERR_SYNTAX_IP4 368
+#define LDNS_WIREPARSE_ERR_SYNTAX_IP6 369
+#define LDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW 370
+#define LDNS_WIREPARSE_ERR_INCLUDE 371
+#define LDNS_WIREPARSE_ERR_PARENTHESIS 372
+
+/**
+ * Get reference to a constant string for the (parse) error.
+ * @param e: error return value
+ * @return string.
+ */
+const char* sldns_get_errorstr_parse(int e);
+
+/**
+ * wire parse state for parsing files
+ */
+struct sldns_file_parse_state {
+ /** the origin domain name, if len!=0. uncompressed wireformat */
+ uint8_t origin[LDNS_MAX_DOMAINLEN+1];
+ /** length of origin domain name, in bytes. 0 if not set. */
+ size_t origin_len;
+ /** the previous domain name, if len!=0. uncompressed wireformat*/
+ uint8_t prev_rr[LDNS_MAX_DOMAINLEN+1];
+ /** length of the previous domain name, in bytes. 0 if not set. */
+ size_t prev_rr_len;
+ /** default TTL, this is used if the text does not specify a TTL,
+ * host byteorder */
+ uint32_t default_ttl;
+ /** line number information */
+ int lineno;
+};
+
+/**
+ * Read one RR from zonefile with buffer for the data.
+ * @param in: file that is read from (one RR, multiple lines if it spans them).
+ * @param rr: this is malloced by the user and the result is stored here,
+ * if an RR is read. If no RR is read this is signalled with the
+ * return len set to 0 (for ORIGIN, TTL directives).
+ * @param len: on input, the length of the rr buffer. on output the rr len.
+ * Buffer size of 64k should be enough.
+ * @param dname_len: returns the length of the dname initial part of the rr.
+ * @param parse_state: pass a pointer to user-allocated struct.
+ * Contents are maintained by this function.
+ * If you pass NULL then ORIGIN and TTL directives are not honored.
+ * You can start out with a particular origin by pre-filling it.
+ * otherwise, zero the structure before passing it.
+ * lineno is incremented when a newline is passed by the parser,
+ * you should initialize it at 1 at the start of the file.
+ * @return 0 on success, error on failure.
+ */
+int sldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
+ struct sldns_file_parse_state* parse_state);
+
+/**
+ * Convert one rdf in rdata to wireformat and parse from string.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @param rdftype: the type of the rdf.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len,
+ sldns_rdf_type rdftype);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_INT8 from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_int8_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_INT16 from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_int16_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_INT32 from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_int32_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_A from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_a_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_AAAA from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_aaaa_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_STR from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_str_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_APL from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_apl_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_B64 from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_B32_EXT from string to wireformat.
+ * And also LDNS_RDF_TYPE_NSEC3_NEXT_OWNER.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_b32_ext_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_HEX from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_NSEC from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_nsec_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_TYPE from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_type_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_CLASS from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_class_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_CERT_ALG from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_cert_alg_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_ALG from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_alg_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_TIME from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_PERIOD from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_LOC from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_loc_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_WKS from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_wks_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_NSAP from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_nsap_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_ATMA from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_atma_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_IPSECKEY from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_ipseckey_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_NSEC3_SALT from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_nsec3_salt_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_ILNP64 from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_ilnp64_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_EUI48 from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_eui48_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_EUI64 from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_eui64_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_TAG from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_LONG_STR from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_long_str_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_HIP from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type LDNS_RDF_TYPE_INT16_DATA from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int sldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDNS_STR2WIRE_H */
diff --git a/contrib/unbound/ldns/wire2str.c b/contrib/unbound/ldns/wire2str.c
new file mode 100644
index 0000000..c2a1850
--- /dev/null
+++ b/contrib/unbound/ldns/wire2str.c
@@ -0,0 +1,1967 @@
+/*
+ * wire2str.c
+ *
+ * conversion routines from the wire format
+ * to the presentation format (strings)
+ *
+ * (c) NLnet Labs, 2004-2006
+ *
+ * See the file LICENSE for the license
+ */
+/**
+ * \file
+ *
+ * Contains functions to translate the wireformat to text
+ * representation, as well as functions to print them.
+ */
+#include "config.h"
+#include "ldns/wire2str.h"
+#include "ldns/str2wire.h"
+#include "ldns/rrdef.h"
+#include "ldns/pkthdr.h"
+#include "ldns/parseutil.h"
+#include "ldns/sbuffer.h"
+#include "ldns/keyraw.h"
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#include <sys/time.h>
+#include <stdarg.h>
+#include <ctype.h>
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+
+/* lookup tables for standard DNS stuff */
+/* Taken from RFC 2535, section 7. */
+static sldns_lookup_table sldns_algorithms_data[] = {
+ { LDNS_RSAMD5, "RSAMD5" },
+ { LDNS_DH, "DH" },
+ { LDNS_DSA, "DSA" },
+ { LDNS_ECC, "ECC" },
+ { LDNS_RSASHA1, "RSASHA1" },
+ { LDNS_DSA_NSEC3, "DSA-NSEC3-SHA1" },
+ { LDNS_RSASHA1_NSEC3, "RSASHA1-NSEC3-SHA1" },
+ { LDNS_RSASHA256, "RSASHA256"},
+ { LDNS_RSASHA512, "RSASHA512"},
+ { LDNS_ECC_GOST, "ECC-GOST"},
+ { LDNS_ECDSAP256SHA256, "ECDSAP256SHA256"},
+ { LDNS_ECDSAP384SHA384, "ECDSAP384SHA384"},
+ { LDNS_INDIRECT, "INDIRECT" },
+ { LDNS_PRIVATEDNS, "PRIVATEDNS" },
+ { LDNS_PRIVATEOID, "PRIVATEOID" },
+ { 0, NULL }
+};
+sldns_lookup_table* sldns_algorithms = sldns_algorithms_data;
+
+/* hash algorithms in DS record */
+static sldns_lookup_table sldns_hashes_data[] = {
+ { LDNS_SHA1, "SHA1" },
+ { LDNS_SHA256, "SHA256" },
+ { LDNS_HASH_GOST, "HASH-GOST" },
+ { LDNS_SHA384, "SHA384" },
+ { 0, NULL }
+};
+sldns_lookup_table* sldns_hashes = sldns_hashes_data;
+
+/* Taken from RFC 4398 */
+static sldns_lookup_table sldns_cert_algorithms_data[] = {
+ { LDNS_CERT_PKIX, "PKIX" },
+ { LDNS_CERT_SPKI, "SPKI" },
+ { LDNS_CERT_PGP, "PGP" },
+ { LDNS_CERT_IPKIX, "IPKIX" },
+ { LDNS_CERT_ISPKI, "ISPKI" },
+ { LDNS_CERT_IPGP, "IPGP" },
+ { LDNS_CERT_ACPKIX, "ACPKIX" },
+ { LDNS_CERT_IACPKIX, "IACPKIX" },
+ { LDNS_CERT_URI, "URI" },
+ { LDNS_CERT_OID, "OID" },
+ { 0, NULL }
+};
+sldns_lookup_table* sldns_cert_algorithms = sldns_cert_algorithms_data;
+
+/* if these are used elsewhere */
+static sldns_lookup_table sldns_rcodes_data[] = {
+ { LDNS_RCODE_NOERROR, "NOERROR" },
+ { LDNS_RCODE_FORMERR, "FORMERR" },
+ { LDNS_RCODE_SERVFAIL, "SERVFAIL" },
+ { LDNS_RCODE_NXDOMAIN, "NXDOMAIN" },
+ { LDNS_RCODE_NOTIMPL, "NOTIMPL" },
+ { LDNS_RCODE_REFUSED, "REFUSED" },
+ { LDNS_RCODE_YXDOMAIN, "YXDOMAIN" },
+ { LDNS_RCODE_YXRRSET, "YXRRSET" },
+ { LDNS_RCODE_NXRRSET, "NXRRSET" },
+ { LDNS_RCODE_NOTAUTH, "NOTAUTH" },
+ { LDNS_RCODE_NOTZONE, "NOTZONE" },
+ { 0, NULL }
+};
+sldns_lookup_table* sldns_rcodes = sldns_rcodes_data;
+
+static sldns_lookup_table sldns_opcodes_data[] = {
+ { LDNS_PACKET_QUERY, "QUERY" },
+ { LDNS_PACKET_IQUERY, "IQUERY" },
+ { LDNS_PACKET_STATUS, "STATUS" },
+ { LDNS_PACKET_NOTIFY, "NOTIFY" },
+ { LDNS_PACKET_UPDATE, "UPDATE" },
+ { 0, NULL }
+};
+sldns_lookup_table* sldns_opcodes = sldns_opcodes_data;
+
+static sldns_lookup_table sldns_wireparse_errors_data[] = {
+ { LDNS_WIREPARSE_ERR_OK, "no parse error" },
+ { LDNS_WIREPARSE_ERR_GENERAL, "parse error" },
+ { LDNS_WIREPARSE_ERR_DOMAINNAME_OVERFLOW, "Domainname length overflow" },
+ { LDNS_WIREPARSE_ERR_DOMAINNAME_UNDERFLOW, "Domainname length underflow (zero length)" },
+ { LDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL, "buffer too small" },
+ { LDNS_WIREPARSE_ERR_LABEL_OVERFLOW, "Label length overflow" },
+ { LDNS_WIREPARSE_ERR_EMPTY_LABEL, "Empty label" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_BAD_ESCAPE, "Syntax error, bad escape sequence" },
+ { LDNS_WIREPARSE_ERR_SYNTAX, "Syntax error, could not parse the RR" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_TTL, "Syntax error, could not parse the RR's TTL" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_TYPE, "Syntax error, could not parse the RR's type" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_CLASS, "Syntax error, could not parse the RR's class" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_RDATA, "Syntax error, could not parse the RR's rdata" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_MISSING_VALUE, "Syntax error, value expected" },
+ { LDNS_WIREPARSE_ERR_INVALID_STR, "Conversion error, string expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_B64, "Conversion error, b64 encoding expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_B32_EXT, "Conversion error, b32 ext encoding expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_HEX, "Conversion error, hex encoding expected" },
+ { LDNS_WIREPARSE_ERR_CERT_BAD_ALGORITHM, "Bad algorithm type for CERT record" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_TIME, "Conversion error, time encoding expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_PERIOD, "Conversion error, time period encoding expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_ILNP64, "Conversion error, 4 colon separated hex numbers expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_EUI48,
+ "Conversion error, 6 two character hex numbers "
+ "separated by dashes expected (i.e. xx-xx-xx-xx-xx-xx" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_EUI64,
+ "Conversion error, 8 two character hex numbers "
+ "separated by dashes expected (i.e. xx-xx-xx-xx-xx-xx-xx-xx" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_TAG,
+ "Conversion error, a non-zero sequence of US-ASCII letters "
+ "and numbers in lower case expected" },
+ { LDNS_WIREPARSE_ERR_NOT_IMPL, "not implemented" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_INT, "Conversion error, integer expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_IP4, "Conversion error, ip4 addr expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_IP6, "Conversion error, ip6 addr expected" },
+ { LDNS_WIREPARSE_ERR_SYNTAX_INTEGER_OVERFLOW, "Syntax error, integer overflow" },
+ { LDNS_WIREPARSE_ERR_INCLUDE, "$INCLUDE directive was seen in the zone" },
+ { LDNS_WIREPARSE_ERR_PARENTHESIS, "Parse error, parenthesis mismatch" },
+ { 0, NULL }
+};
+sldns_lookup_table* sldns_wireparse_errors = sldns_wireparse_errors_data;
+
+static sldns_lookup_table sldns_edns_flags_data[] = {
+ { 3600, "do"},
+ { 0, NULL}
+};
+sldns_lookup_table* sldns_edns_flags = sldns_edns_flags_data;
+
+static sldns_lookup_table sldns_edns_options_data[] = {
+ { 1, "LLQ" },
+ { 2, "UL" },
+ { 3, "NSID" },
+ /* 4 draft-cheshire-edns0-owner-option */
+ { 5, "DAU" },
+ { 6, "DHU" },
+ { 7, "N3U" },
+ { 8, "edns-client-subnet" },
+ { 0, NULL}
+};
+sldns_lookup_table* sldns_edns_options = sldns_edns_options_data;
+
+char* sldns_wire2str_pkt(uint8_t* data, size_t len)
+{
+ size_t slen = (size_t)sldns_wire2str_pkt_buf(data, len, NULL, 0);
+ char* result = (char*)malloc(slen+1);
+ if(!result) return NULL;
+ sldns_wire2str_pkt_buf(data, len, result, slen+1);
+ return result;
+}
+
+char* sldns_wire2str_rr(uint8_t* rr, size_t len)
+{
+ size_t slen = (size_t)sldns_wire2str_rr_buf(rr, len, NULL, 0);
+ char* result = (char*)malloc(slen+1);
+ if(!result) return NULL;
+ sldns_wire2str_rr_buf(rr, len, result, slen+1);
+ return result;
+}
+
+char* sldns_wire2str_type(uint16_t rrtype)
+{
+ char buf[16];
+ sldns_wire2str_type_buf(rrtype, buf, sizeof(buf));
+ return strdup(buf);
+}
+
+char* sldns_wire2str_class(uint16_t rrclass)
+{
+ char buf[16];
+ sldns_wire2str_class_buf(rrclass, buf, sizeof(buf));
+ return strdup(buf);
+}
+
+char* sldns_wire2str_dname(uint8_t* dname, size_t dname_len)
+{
+ size_t slen=(size_t)sldns_wire2str_dname_buf(dname, dname_len, NULL, 0);
+ char* result = (char*)malloc(slen+1);
+ if(!result) return NULL;
+ sldns_wire2str_dname_buf(dname, dname_len, result, slen+1);
+ return result;
+}
+
+char* sldns_wire2str_rcode(int rcode)
+{
+ char buf[16];
+ sldns_wire2str_rcode_buf(rcode, buf, sizeof(buf));
+ return strdup(buf);
+}
+
+int sldns_wire2str_pkt_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_pkt_scan(&d, &dlen, &s, &slen);
+}
+
+int sldns_wire2str_rr_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_rr_scan(&d, &dlen, &s, &slen, NULL, 0);
+}
+
+int sldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str,
+ size_t str_len, uint16_t rrtype)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_rdata_scan(&rdata, &rdata_len, &str, &str_len,
+ rrtype, NULL, 0);
+}
+
+int sldns_wire2str_rr_unknown_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_rr_unknown_scan(&d, &dlen, &s, &slen, NULL, 0);
+}
+
+int sldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rrlen, size_t dname_len,
+ char* s, size_t slen)
+{
+ uint16_t rrtype = sldns_wirerr_get_type(rr, rrlen, dname_len);
+ return sldns_wire2str_rr_comment_print(&s, &slen, rr, rrlen, dname_len,
+ rrtype);
+}
+
+int sldns_wire2str_type_buf(uint16_t rrtype, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_type_print(&s, &slen, rrtype);
+}
+
+int sldns_wire2str_class_buf(uint16_t rrclass, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_class_print(&s, &slen, rrclass);
+}
+
+int sldns_wire2str_rcode_buf(int rcode, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_rcode_print(&s, &slen, rcode);
+}
+
+int sldns_wire2str_dname_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return sldns_wire2str_dname_scan(&d, &dlen, &s, &slen, NULL, 0);
+}
+
+int sldns_str_vprint(char** str, size_t* slen, const char* format, va_list args)
+{
+ int w = vsnprintf(*str, *slen, format, args);
+ if(w < 0) {
+ /* error in printout */
+ return 0;
+ } else if((size_t)w >= *slen) {
+ *str = NULL; /* we do not want str to point outside of buffer*/
+ *slen = 0;
+ } else {
+ *str += w;
+ *slen -= w;
+ }
+ return w;
+}
+
+int sldns_str_print(char** str, size_t* slen, const char* format, ...)
+{
+ int w;
+ va_list args;
+ va_start(args, format);
+ w = sldns_str_vprint(str, slen, format, args);
+ va_end(args);
+ return w;
+}
+
+/** print hex format into text buffer for specified length */
+static int print_hex_buf(char** s, size_t* slen, uint8_t* buf, size_t len)
+{
+ const char* hex = "0123456789ABCDEF";
+ size_t i;
+ for(i=0; i<len; i++) {
+ (void)sldns_str_print(s, slen, "%c%c", hex[(buf[i]&0xf0)>>4],
+ hex[buf[i]&0x0f]);
+ }
+ return (int)len*2;
+}
+
+/** print remainder of buffer in hex format with prefixed text */
+static int print_remainder_hex(const char* pref, uint8_t** d, size_t* dlen,
+ char** s, size_t* slen)
+{
+ int w = 0;
+ w += sldns_str_print(s, slen, "%s", pref);
+ w += print_hex_buf(s, slen, *d, *dlen);
+ *d += *dlen;
+ *dlen = 0;
+ return w;
+}
+
+int sldns_wire2str_pkt_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen)
+{
+ int w = 0;
+ unsigned qdcount, ancount, nscount, arcount, i;
+ uint8_t* pkt = *d;
+ size_t pktlen = *dlen;
+ if(*dlen >= LDNS_HEADER_SIZE) {
+ qdcount = (unsigned)LDNS_QDCOUNT(*d);
+ ancount = (unsigned)LDNS_ANCOUNT(*d);
+ nscount = (unsigned)LDNS_NSCOUNT(*d);
+ arcount = (unsigned)LDNS_ARCOUNT(*d);
+ } else {
+ qdcount = ancount = nscount = arcount = 0;
+ }
+ w += sldns_wire2str_header_scan(d, dlen, s, slen);
+ w += sldns_str_print(s, slen, "\n");
+ w += sldns_str_print(s, slen, ";; QUESTION SECTION:\n");
+ for(i=0; i<qdcount; i++) {
+ w += sldns_wire2str_rrquestion_scan(d, dlen, s, slen,
+ pkt, pktlen);
+ if(!*dlen) break;
+ }
+ w += sldns_str_print(s, slen, "\n");
+ w += sldns_str_print(s, slen, ";; ANSWER SECTION:\n");
+ for(i=0; i<ancount; i++) {
+ w += sldns_wire2str_rr_scan(d, dlen, s, slen, pkt, pktlen);
+ if(!*dlen) break;
+ }
+ w += sldns_str_print(s, slen, "\n");
+ w += sldns_str_print(s, slen, ";; AUTHORITY SECTION:\n");
+ for(i=0; i<nscount; i++) {
+ w += sldns_wire2str_rr_scan(d, dlen, s, slen, pkt, pktlen);
+ if(!*dlen) break;
+ }
+ w += sldns_str_print(s, slen, "\n");
+ w += sldns_str_print(s, slen, ";; ADDITIONAL SECTION:\n");
+ for(i=0; i<arcount; i++) {
+ w += sldns_wire2str_rr_scan(d, dlen, s, slen, pkt, pktlen);
+ if(!*dlen) break;
+ }
+ /* other fields: WHEN(time), SERVER(IP) not available here. */
+ w += sldns_str_print(s, slen, ";; MSG SIZE rcvd: %d\n", (int)pktlen);
+ if(*dlen > 0) {
+ w += print_remainder_hex(";; trailing garbage 0x",
+ d, dlen, s, slen);
+ w += sldns_str_print(s, slen, "\n");
+ }
+ return w;
+}
+
+/** scan type, class and ttl and printout, for rr */
+static int sldns_rr_tcttl_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w = 0;
+ uint16_t t, c;
+ uint32_t ttl;
+ if(*dl < 8) {
+ if(*dl < 4)
+ return w + print_remainder_hex("; Error malformed 0x",
+ d, dl, s, sl);
+ /* these print values or 0x.. if none left */
+ t = sldns_read_uint16(*d);
+ c = sldns_read_uint16((*d)+2);
+ (*d)+=4;
+ (*dl)-=4;
+ w += sldns_wire2str_class_print(s, sl, c);
+ w += sldns_str_print(s, sl, "\t");
+ w += sldns_wire2str_type_print(s, sl, t);
+ if(*dl == 0)
+ return w + sldns_str_print(s, sl, "; Error no ttl");
+ return w + print_remainder_hex(
+ "; Error malformed ttl 0x", d, dl, s, sl);
+ }
+ t = sldns_read_uint16(*d);
+ c = sldns_read_uint16((*d)+2);
+ ttl = sldns_read_uint32((*d)+4);
+ (*d)+=8;
+ (*dl)-=8;
+ w += sldns_str_print(s, sl, "%lu\t", (unsigned long)ttl);
+ w += sldns_wire2str_class_print(s, sl, c);
+ w += sldns_str_print(s, sl, "\t");
+ w += sldns_wire2str_type_print(s, sl, t);
+ return w;
+}
+
+int sldns_wire2str_rr_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen,
+ uint8_t* pkt, size_t pktlen)
+{
+ int w = 0;
+ uint8_t* rr = *d;
+ size_t rrlen = *dlen, dname_off, rdlen, ordlen;
+ uint16_t rrtype = 0;
+
+ if(*dlen >= 3 && (*d)[0]==0 &&
+ sldns_read_uint16((*d)+1)==LDNS_RR_TYPE_OPT) {
+ /* perform EDNS OPT processing */
+ return sldns_wire2str_edns_scan(d, dlen, s, slen, pkt, pktlen);
+ }
+
+ /* try to scan the rdata with pretty-printing, but if that fails, then
+ * scan the rdata as an unknown RR type */
+ w += sldns_wire2str_dname_scan(d, dlen, s, slen, pkt, pktlen);
+ w += sldns_str_print(s, slen, "\t");
+ dname_off = rrlen-(*dlen);
+ if(*dlen == 4) {
+ /* like a question-RR */
+ uint16_t t = sldns_read_uint16(*d);
+ uint16_t c = sldns_read_uint16((*d)+2);
+ (*d)+=4;
+ (*dlen)-=4;
+ w += sldns_wire2str_class_print(s, slen, c);
+ w += sldns_str_print(s, slen, "\t");
+ w += sldns_wire2str_type_print(s, slen, t);
+ w += sldns_str_print(s, slen, " ; Error no ttl,rdata\n");
+ return w;
+ }
+ if(*dlen < 8) {
+ if(*dlen == 0)
+ return w + sldns_str_print(s, slen, ";Error missing RR\n");
+ w += print_remainder_hex(";Error partial RR 0x", d, dlen, s, slen);
+ return w + sldns_str_print(s, slen, "\n");
+ }
+ rrtype = sldns_read_uint16(*d);
+ w += sldns_rr_tcttl_scan(d, dlen, s, slen);
+ w += sldns_str_print(s, slen, "\t");
+
+ /* rdata */
+ if(*dlen < 2) {
+ if(*dlen == 0)
+ return w + sldns_str_print(s, slen, ";Error missing rdatalen\n");
+ w += print_remainder_hex(";Error missing rdatalen 0x",
+ d, dlen, s, slen);
+ return w + sldns_str_print(s, slen, "\n");
+ }
+ rdlen = sldns_read_uint16(*d);
+ ordlen = rdlen;
+ (*d)+=2;
+ (*dlen)-=2;
+ if(*dlen < rdlen) {
+ w += sldns_str_print(s, slen, "\\# %u ", (unsigned)rdlen);
+ if(*dlen == 0)
+ return w + sldns_str_print(s, slen, ";Error missing rdata\n");
+ w += print_remainder_hex(";Error partial rdata 0x", d, dlen, s, slen);
+ return w + sldns_str_print(s, slen, "\n");
+ }
+ w += sldns_wire2str_rdata_scan(d, &rdlen, s, slen, rrtype, pkt, pktlen);
+ (*dlen) -= (ordlen-rdlen);
+
+ /* default comment */
+ w += sldns_wire2str_rr_comment_print(s, slen, rr, rrlen, dname_off,
+ rrtype);
+ w += sldns_str_print(s, slen, "\n");
+ return w;
+}
+
+int sldns_wire2str_rrquestion_scan(uint8_t** d, size_t* dlen, char** s,
+ size_t* slen, uint8_t* pkt, size_t pktlen)
+{
+ int w = 0;
+ uint16_t t, c;
+ w += sldns_wire2str_dname_scan(d, dlen, s, slen, pkt, pktlen);
+ w += sldns_str_print(s, slen, "\t");
+ if(*dlen < 4) {
+ if(*dlen == 0)
+ return w + sldns_str_print(s, slen, "Error malformed\n");
+ w += print_remainder_hex("Error malformed 0x", d, dlen, s, slen);
+ return w + sldns_str_print(s, slen, "\n");
+ }
+ t = sldns_read_uint16(*d);
+ c = sldns_read_uint16((*d)+2);
+ (*d)+=4;
+ (*dlen)-=4;
+ w += sldns_wire2str_class_print(s, slen, c);
+ w += sldns_str_print(s, slen, "\t");
+ w += sldns_wire2str_type_print(s, slen, t);
+ w += sldns_str_print(s, slen, "\n");
+ return w;
+}
+
+int sldns_wire2str_rr_unknown_scan(uint8_t** d, size_t* dlen, char** s,
+ size_t* slen, uint8_t* pkt, size_t pktlen)
+{
+ size_t rdlen, ordlen;
+ int w = 0;
+ w += sldns_wire2str_dname_scan(d, dlen, s, slen, pkt, pktlen);
+ w += sldns_str_print(s, slen, "\t");
+ w += sldns_rr_tcttl_scan(d, dlen, s, slen);
+ w += sldns_str_print(s, slen, "\t");
+ if(*dlen < 2) {
+ if(*dlen == 0)
+ return w + sldns_str_print(s, slen, ";Error missing rdatalen\n");
+ w += print_remainder_hex(";Error missing rdatalen 0x",
+ d, dlen, s, slen);
+ return w + sldns_str_print(s, slen, "\n");
+ }
+ rdlen = sldns_read_uint16(*d);
+ ordlen = rdlen;
+ (*d) += 2;
+ (*dlen) -= 2;
+ if(*dlen < rdlen) {
+ w += sldns_str_print(s, slen, "\\# %u ", (unsigned)rdlen);
+ if(*dlen == 0)
+ return w + sldns_str_print(s, slen, ";Error missing rdata\n");
+ w += print_remainder_hex(";Error partial rdata 0x", d, dlen, s, slen);
+ return w + sldns_str_print(s, slen, "\n");
+ }
+ w += sldns_wire2str_rdata_unknown_scan(d, &rdlen, s, slen);
+ (*dlen) -= (ordlen-rdlen);
+ w += sldns_str_print(s, slen, "\n");
+ return w;
+}
+
+/** print rr comment for type DNSKEY */
+static int rr_comment_dnskey(char** s, size_t* slen, uint8_t* rr,
+ size_t rrlen, size_t dname_off)
+{
+ size_t rdlen;
+ uint8_t* rdata;
+ int flags, w = 0;
+ if(rrlen < dname_off + 10) return 0;
+ rdlen = sldns_read_uint16(rr+dname_off+8);
+ if(rrlen < dname_off + 10 + rdlen) return 0;
+ rdata = rr + dname_off + 10;
+ flags = (int)sldns_read_uint16(rdata);
+ w += sldns_str_print(s, slen, " ;{");
+
+ /* id */
+ w += sldns_str_print(s, slen, "id = %u",
+ sldns_calc_keytag_raw(rdata, rdlen));
+
+ /* flags */
+ if((flags&LDNS_KEY_ZONE_KEY)) {
+ if((flags&LDNS_KEY_SEP_KEY))
+ w += sldns_str_print(s, slen, " (ksk)");
+ else w += sldns_str_print(s, slen, " (zsk)");
+ }
+
+ /* keysize */
+ if(rdlen > 4) {
+ w += sldns_str_print(s, slen, ", ");
+ w += sldns_str_print(s, slen, "size = %db",
+ (int)sldns_rr_dnskey_key_size_raw(
+ (unsigned char*)rdata+4, rdlen-4, (int)(rdata[3])));
+ }
+
+ w += sldns_str_print(s, slen, "}");
+ return w;
+}
+
+/** print rr comment for type RRSIG */
+static int rr_comment_rrsig(char** s, size_t* slen, uint8_t* rr,
+ size_t rrlen, size_t dname_off)
+{
+ size_t rdlen;
+ uint8_t* rdata;
+ if(rrlen < dname_off + 10) return 0;
+ rdlen = sldns_read_uint16(rr+dname_off+8);
+ if(rrlen < dname_off + 10 + rdlen) return 0;
+ rdata = rr + dname_off + 10;
+ if(rdlen < 18) return 0;
+ return sldns_str_print(s, slen, " ;{id = %d}",
+ (int)sldns_read_uint16(rdata+16));
+}
+
+/** print rr comment for type NSEC3 */
+static int rr_comment_nsec3(char** s, size_t* slen, uint8_t* rr,
+ size_t rrlen, size_t dname_off)
+{
+ size_t rdlen;
+ uint8_t* rdata;
+ int w = 0;
+ if(rrlen < dname_off + 10) return 0;
+ rdlen = sldns_read_uint16(rr+dname_off+8);
+ if(rrlen < dname_off + 10 + rdlen) return 0;
+ rdata = rr + dname_off + 10;
+ if(rdlen < 2) return 0;
+ if((rdata[1] & LDNS_NSEC3_VARS_OPTOUT_MASK))
+ w += sldns_str_print(s, slen, " ;{flags: optout}");
+ return w;
+}
+
+int sldns_wire2str_rr_comment_print(char** s, size_t* slen, uint8_t* rr,
+ size_t rrlen, size_t dname_off, uint16_t rrtype)
+{
+ if(rrtype == LDNS_RR_TYPE_DNSKEY) {
+ return rr_comment_dnskey(s, slen, rr, rrlen, dname_off);
+ } else if(rrtype == LDNS_RR_TYPE_RRSIG) {
+ return rr_comment_rrsig(s, slen, rr, rrlen, dname_off);
+ } else if(rrtype == LDNS_RR_TYPE_NSEC3) {
+ return rr_comment_nsec3(s, slen, rr, rrlen, dname_off);
+ }
+ return 0;
+}
+
+int sldns_wire2str_header_scan(uint8_t** d, size_t* dlen, char** s,
+ size_t* slen)
+{
+ int w = 0;
+ int opcode, rcode;
+ w += sldns_str_print(s, slen, ";; ->>HEADER<<- ");
+ if(*dlen == 0)
+ return w+sldns_str_print(s, slen, "Error empty packet");
+ if(*dlen < 4)
+ return w+print_remainder_hex("Error header too short 0x", d, dlen, s, slen);
+ opcode = (int)LDNS_OPCODE_WIRE(*d);
+ rcode = (int)LDNS_RCODE_WIRE(*d);
+ w += sldns_str_print(s, slen, "opcode: ");
+ w += sldns_wire2str_opcode_print(s, slen, opcode);
+ w += sldns_str_print(s, slen, ", ");
+ w += sldns_str_print(s, slen, "rcode: ");
+ w += sldns_wire2str_rcode_print(s, slen, rcode);
+ w += sldns_str_print(s, slen, ", ");
+ w += sldns_str_print(s, slen, "id: %d\n", (int)LDNS_ID_WIRE(*d));
+ w += sldns_str_print(s, slen, ";; flags:");
+ if(LDNS_QR_WIRE(*d)) w += sldns_str_print(s, slen, " qr");
+ if(LDNS_AA_WIRE(*d)) w += sldns_str_print(s, slen, " aa");
+ if(LDNS_TC_WIRE(*d)) w += sldns_str_print(s, slen, " tc");
+ if(LDNS_RD_WIRE(*d)) w += sldns_str_print(s, slen, " rd");
+ if(LDNS_CD_WIRE(*d)) w += sldns_str_print(s, slen, " cd");
+ if(LDNS_RA_WIRE(*d)) w += sldns_str_print(s, slen, " ra");
+ if(LDNS_AD_WIRE(*d)) w += sldns_str_print(s, slen, " ad");
+ if(LDNS_Z_WIRE(*d)) w += sldns_str_print(s, slen, " z");
+ w += sldns_str_print(s, slen, " ; ");
+ if(*dlen < LDNS_HEADER_SIZE)
+ return w+print_remainder_hex("Error header too short 0x", d, dlen, s, slen);
+ w += sldns_str_print(s, slen, "QUERY: %d, ", (int)LDNS_QDCOUNT(*d));
+ w += sldns_str_print(s, slen, "ANSWER: %d, ", (int)LDNS_ANCOUNT(*d));
+ w += sldns_str_print(s, slen, "AUTHORITY: %d, ", (int)LDNS_NSCOUNT(*d));
+ w += sldns_str_print(s, slen, "ADDITIONAL: %d ", (int)LDNS_ARCOUNT(*d));
+ *d += LDNS_HEADER_SIZE;
+ *dlen -= LDNS_HEADER_SIZE;
+ return w;
+}
+
+int sldns_wire2str_rdata_scan(uint8_t** d, size_t* dlen, char** s,
+ size_t* slen, uint16_t rrtype, uint8_t* pkt, size_t pktlen)
+{
+ /* try to prettyprint, but if that fails, use unknown format */
+ uint8_t* origd = *d;
+ char* origs = *s;
+ size_t origdlen = *dlen, origslen = *slen;
+ uint16_t r_cnt, r_max;
+ sldns_rdf_type rdftype;
+ int w = 0, n;
+
+ const sldns_rr_descriptor *desc = sldns_rr_descript(rrtype);
+ if(!desc) /* unknown format */
+ return sldns_wire2str_rdata_unknown_scan(d, dlen, s, slen);
+ /* dlen equals the rdatalen for the rdata */
+
+ r_max = sldns_rr_descriptor_maximum(desc);
+ for(r_cnt=0; r_cnt < r_max; r_cnt++) {
+ if(*dlen == 0) {
+ if(r_cnt < sldns_rr_descriptor_minimum(desc))
+ goto failed;
+ break; /* nothing more to print */
+ }
+ rdftype = sldns_rr_descriptor_field_type(desc, r_cnt);
+ if(r_cnt != 0)
+ w += sldns_str_print(s, slen, " ");
+ n = sldns_wire2str_rdf_scan(d, dlen, s, slen, rdftype,
+ pkt, pktlen);
+ if(n == -1) {
+ failed:
+ /* failed, use unknown format */
+ *d = origd; *s = origs;
+ *dlen = origdlen; *slen = origslen;
+ return sldns_wire2str_rdata_unknown_scan(d, dlen,
+ s, slen);
+ }
+ w += n;
+ }
+ return w;
+}
+
+int sldns_wire2str_rdata_unknown_scan(uint8_t** d, size_t* dlen, char** s,
+ size_t* slen)
+{
+ int w = 0;
+
+ /* print length */
+ w += sldns_str_print(s, slen, "\\# %u", (unsigned)*dlen);
+
+ /* print rdlen in hex */
+ if(*dlen != 0)
+ w += sldns_str_print(s, slen, " ");
+ w += print_hex_buf(s, slen, *d, *dlen);
+ (*d) += *dlen;
+ (*dlen) = 0;
+ return w;
+}
+
+/** print and escape one character for a domain dname */
+static int dname_char_print(char** s, size_t* slen, uint8_t c)
+{
+ if(c == '.' || c == ';' || c == '(' || c == ')' || c == '\\')
+ return sldns_str_print(s, slen, "\\%c", c);
+ else if(!(isascii((int)c) && isgraph((int)c)))
+ return sldns_str_print(s, slen, "\\%03u", (unsigned)c);
+ /* plain printout */
+ if(*slen) {
+ **s = (char)c;
+ (*s)++;
+ (*slen)--;
+ }
+ return 1;
+}
+
+int sldns_wire2str_dname_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen,
+ uint8_t* pkt, size_t pktlen)
+{
+ int w = 0;
+ /* spool labels onto the string, use compression if its there */
+ uint8_t* pos = *d;
+ unsigned i, counter=0;
+ const unsigned maxcompr = 1000; /* loop detection, max compr ptrs */
+ int in_buf = 1;
+ if(*dlen == 0) return sldns_str_print(s, slen, "ErrorMissingDname");
+ if(*pos == 0) {
+ (*d)++;
+ (*dlen)--;
+ return sldns_str_print(s, slen, ".");
+ }
+ while(*pos) {
+ /* read label length */
+ uint8_t labellen = *pos++;
+ if(in_buf) { (*d)++; (*dlen)--; }
+
+ /* find out what sort of label we have */
+ if((labellen&0xc0) == 0xc0) {
+ /* compressed */
+ uint16_t target = 0;
+ if(in_buf && *dlen == 0)
+ return w + sldns_str_print(s, slen,
+ "ErrorPartialDname");
+ else if(!in_buf && pos+1 > pkt+pktlen)
+ return w + sldns_str_print(s, slen,
+ "ErrorPartialDname");
+ target = ((labellen&0x3f)<<8) | *pos;
+ if(in_buf) { (*d)++; (*dlen)--; }
+ /* move to target, if possible */
+ if(!pkt || target >= pktlen)
+ return w + sldns_str_print(s, slen,
+ "ErrorComprPtrOutOfBounds");
+ if(counter++ > maxcompr)
+ return w + sldns_str_print(s, slen,
+ "ErrorComprPtrLooped");
+ in_buf = 0;
+ pos = pkt+target;
+ continue;
+ } else if((labellen&0xc0)) {
+ /* notimpl label type */
+ w += sldns_str_print(s, slen,
+ "ErrorLABELTYPE%xIsUnknown",
+ (int)(labellen&0xc0));
+ return w;
+ }
+
+ /* spool label characters, end with '.' */
+ if(in_buf && *dlen < labellen) labellen = *dlen;
+ else if(!in_buf && pos+labellen > pkt+pktlen)
+ labellen = (uint8_t)(pkt + pktlen - pos);
+ for(i=0; i<(unsigned)labellen; i++) {
+ w += dname_char_print(s, slen, *pos++);
+ }
+ if(in_buf) {
+ (*d) += labellen;
+ (*dlen) -= labellen;
+ if(*dlen == 0) break;
+ }
+ w += sldns_str_print(s, slen, ".");
+ }
+ /* skip over final root label */
+ if(in_buf && *dlen > 0) { (*d)++; (*dlen)--; }
+ /* in case we printed no labels, terminate dname */
+ if(w == 0) w += sldns_str_print(s, slen, ".");
+ return w;
+}
+
+int sldns_wire2str_opcode_print(char** s, size_t* slen, int opcode)
+{
+ sldns_lookup_table *lt = sldns_lookup_by_id(sldns_opcodes, opcode);
+ if (lt && lt->name) {
+ return sldns_str_print(s, slen, "%s", lt->name);
+ }
+ return sldns_str_print(s, slen, "OPCODE%u", (unsigned)opcode);
+}
+
+int sldns_wire2str_rcode_print(char** s, size_t* slen, int rcode)
+{
+ sldns_lookup_table *lt = sldns_lookup_by_id(sldns_rcodes, rcode);
+ if (lt && lt->name) {
+ return sldns_str_print(s, slen, "%s", lt->name);
+ }
+ return sldns_str_print(s, slen, "RCODE%u", (unsigned)rcode);
+}
+
+int sldns_wire2str_class_print(char** s, size_t* slen, uint16_t rrclass)
+{
+ sldns_lookup_table *lt = sldns_lookup_by_id(sldns_rr_classes,
+ (int)rrclass);
+ if (lt && lt->name) {
+ return sldns_str_print(s, slen, "%s", lt->name);
+ }
+ return sldns_str_print(s, slen, "CLASS%u", (unsigned)rrclass);
+}
+
+int sldns_wire2str_type_print(char** s, size_t* slen, uint16_t rrtype)
+{
+ const sldns_rr_descriptor *descriptor = sldns_rr_descript(rrtype);
+ if (descriptor && descriptor->_name) {
+ return sldns_str_print(s, slen, "%s", descriptor->_name);
+ }
+ return sldns_str_print(s, slen, "TYPE%u", (unsigned)rrtype);
+}
+
+int sldns_wire2str_edns_option_code_print(char** s, size_t* slen,
+ uint16_t opcode)
+{
+ sldns_lookup_table *lt = sldns_lookup_by_id(sldns_edns_options,
+ (int)opcode);
+ if (lt && lt->name) {
+ return sldns_str_print(s, slen, "%s", lt->name);
+ }
+ return sldns_str_print(s, slen, "OPT%u", (unsigned)opcode);
+}
+
+int sldns_wire2str_class_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen)
+{
+ uint16_t c;
+ if(*dlen == 0) return 0;
+ if(*dlen < 2) return print_remainder_hex("Error malformed 0x", d, dlen, s, slen);
+ c = sldns_read_uint16(*d);
+ (*d)+=2;
+ (*dlen)-=2;
+ return sldns_wire2str_class_print(s, slen, c);
+}
+
+int sldns_wire2str_type_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen)
+{
+ uint16_t t;
+ if(*dlen == 0) return 0;
+ if(*dlen < 2) return print_remainder_hex("Error malformed 0x", d, dlen, s, slen);
+ t = sldns_read_uint16(*d);
+ (*d)+=2;
+ (*dlen)-=2;
+ return sldns_wire2str_type_print(s, slen, t);
+}
+
+int sldns_wire2str_ttl_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen)
+{
+ uint32_t ttl;
+ if(*dlen == 0) return 0;
+ if(*dlen < 4) return print_remainder_hex("Error malformed 0x", d, dlen, s, slen);
+ ttl = sldns_read_uint32(*d);
+ (*d)+=4;
+ (*dlen)-=4;
+ return sldns_str_print(s, slen, "%u", (unsigned)ttl);
+}
+
+int sldns_wire2str_rdf_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen,
+ int rdftype, uint8_t* pkt, size_t pktlen)
+{
+ if(*dlen == 0) return 0;
+ switch(rdftype) {
+ case LDNS_RDF_TYPE_NONE:
+ return 0;
+ case LDNS_RDF_TYPE_DNAME:
+ return sldns_wire2str_dname_scan(d, dlen, s, slen, pkt, pktlen);
+ case LDNS_RDF_TYPE_INT8:
+ return sldns_wire2str_int8_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_INT16:
+ return sldns_wire2str_int16_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_INT32:
+ return sldns_wire2str_int32_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_PERIOD:
+ return sldns_wire2str_period_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_TSIGTIME:
+ return sldns_wire2str_tsigtime_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_A:
+ return sldns_wire2str_a_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_AAAA:
+ return sldns_wire2str_aaaa_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_STR:
+ return sldns_wire2str_str_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_APL:
+ return sldns_wire2str_apl_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_B32_EXT:
+ return sldns_wire2str_b32_ext_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_B64:
+ return sldns_wire2str_b64_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_HEX:
+ return sldns_wire2str_hex_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_NSEC:
+ return sldns_wire2str_nsec_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_NSEC3_SALT:
+ return sldns_wire2str_nsec3_salt_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_TYPE:
+ return sldns_wire2str_type_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_CLASS:
+ return sldns_wire2str_class_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_CERT_ALG:
+ return sldns_wire2str_cert_alg_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_ALG:
+ return sldns_wire2str_alg_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_UNKNOWN:
+ return sldns_wire2str_unknown_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_TIME:
+ return sldns_wire2str_time_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_LOC:
+ return sldns_wire2str_loc_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_WKS:
+ case LDNS_RDF_TYPE_SERVICE:
+ return sldns_wire2str_wks_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_NSAP:
+ return sldns_wire2str_nsap_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_ATMA:
+ return sldns_wire2str_atma_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_IPSECKEY:
+ return sldns_wire2str_ipseckey_scan(d, dlen, s, slen, pkt,
+ pktlen);
+ case LDNS_RDF_TYPE_HIP:
+ return sldns_wire2str_hip_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_INT16_DATA:
+ return sldns_wire2str_int16_data_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
+ return sldns_wire2str_b32_ext_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_ILNP64:
+ return sldns_wire2str_ilnp64_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_EUI48:
+ return sldns_wire2str_eui48_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_EUI64:
+ return sldns_wire2str_eui64_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_TAG:
+ return sldns_wire2str_tag_scan(d, dlen, s, slen);
+ case LDNS_RDF_TYPE_LONG_STR:
+ return sldns_wire2str_long_str_scan(d, dlen, s, slen);
+ }
+ /* unknown rdf type */
+ return -1;
+}
+
+int sldns_wire2str_int8_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w;
+ if(*dl < 1) return -1;
+ w = sldns_str_print(s, sl, "%u", (unsigned)**d);
+ (*d)++;
+ (*dl)--;
+ return w;
+}
+
+int sldns_wire2str_int16_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w;
+ if(*dl < 2) return -1;
+ w = sldns_str_print(s, sl, "%lu", (unsigned long)sldns_read_uint16(*d));
+ (*d)+=2;
+ (*dl)-=2;
+ return w;
+}
+
+int sldns_wire2str_int32_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w;
+ if(*dl < 4) return -1;
+ w = sldns_str_print(s, sl, "%lu", (unsigned long)sldns_read_uint32(*d));
+ (*d)+=4;
+ (*dl)-=4;
+ return w;
+}
+
+int sldns_wire2str_period_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w;
+ if(*dl < 4) return -1;
+ w = sldns_str_print(s, sl, "%u", (unsigned)sldns_read_uint32(*d));
+ (*d)+=4;
+ (*dl)-=4;
+ return w;
+}
+
+int sldns_wire2str_tsigtime_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ /* tsigtime is 48 bits network order unsigned integer */
+ int w;
+ uint64_t tsigtime = 0;
+ uint64_t d0, d1, d2, d3, d4, d5;
+ if(*dl < 6) return -1;
+ d0 = (*d)[0]; /* cast to uint64 for shift operations */
+ d1 = (*d)[1];
+ d2 = (*d)[2];
+ d3 = (*d)[3];
+ d4 = (*d)[4];
+ d5 = (*d)[5];
+ tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
+#ifndef USE_WINSOCK
+ w = sldns_str_print(s, sl, "%llu", (long long)tsigtime);
+#else
+ w = sldns_str_print(s, sl, "%I64u", (long long)tsigtime);
+#endif
+ (*d)+=6;
+ (*dl)-=6;
+ return w;
+}
+
+int sldns_wire2str_a_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ char buf[32];
+ int w;
+ if(*dl < 4) return -1;
+ if(!inet_ntop(AF_INET, *d, buf, (socklen_t)sizeof(buf)))
+ return -1;
+ w = sldns_str_print(s, sl, "%s", buf);
+ (*d)+=4;
+ (*dl)-=4;
+ return w;
+}
+
+int sldns_wire2str_aaaa_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+#ifdef AF_INET6
+ char buf[64];
+ int w;
+ if(*dl < 16) return -1;
+ if(!inet_ntop(AF_INET6, *d, buf, (socklen_t)sizeof(buf)))
+ return -1;
+ w = sldns_str_print(s, sl, "%s", buf);
+ (*d)+=16;
+ (*dl)-=16;
+ return w;
+#else
+ return -1;
+#endif
+}
+
+/** printout escaped TYPE_STR character */
+static int str_char_print(char** s, size_t* sl, uint8_t c)
+{
+ if(isprint((int)c) || c == '\t') {
+ if(c == '\"' || c == '\\')
+ return sldns_str_print(s, sl, "\\%c", c);
+ if(*sl) {
+ **s = (char)c;
+ (*s)++;
+ (*sl)--;
+ }
+ return 1;
+ }
+ return sldns_str_print(s, sl, "\\%03u", (unsigned)c);
+}
+
+int sldns_wire2str_str_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w = 0;
+ size_t i, len;
+ if(*dl < 1) return -1;
+ len = **d;
+ if(*dl < 1+len) return -1;
+ (*d)++;
+ (*dl)--;
+ w += sldns_str_print(s, sl, "\"");
+ for(i=0; i<len; i++)
+ w += str_char_print(s, sl, (*d)[i]);
+ w += sldns_str_print(s, sl, "\"");
+ (*d)+=len;
+ (*dl)-=len;
+ return w;
+}
+
+int sldns_wire2str_apl_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int i, w = 0;
+ uint16_t family;
+ uint8_t negation, prefix, adflength;
+ if(*dl < 4) return -1;
+ family = sldns_read_uint16(*d);
+ prefix = (*d)[2];
+ negation = ((*d)[3] & LDNS_APL_NEGATION);
+ adflength = ((*d)[3] & LDNS_APL_MASK);
+ if(*dl < 4+(size_t)adflength) return -1;
+ if(family != LDNS_APL_IP4 && family != LDNS_APL_IP6)
+ return -1; /* unknown address family */
+ if(negation)
+ w += sldns_str_print(s, sl, "!");
+ w += sldns_str_print(s, sl, "%u:", (unsigned)family);
+ if(family == LDNS_APL_IP4) {
+ /* check if prefix <32 ? */
+ /* address is variable length 0 - 4 */
+ for(i=0; i<4; i++) {
+ if(i > 0)
+ w += sldns_str_print(s, sl, ".");
+ if(i < (int)adflength)
+ w += sldns_str_print(s, sl, "%d", (*d)[4+i]);
+ else w += sldns_str_print(s, sl, "0");
+ }
+ } else if(family == LDNS_APL_IP6) {
+ /* check if prefix <128 ? */
+ /* address is variable length 0 - 16 */
+ for(i=0; i<16; i++) {
+ if(i%2 == 0 && i>0)
+ w += sldns_str_print(s, sl, ":");
+ if(i < (int)adflength)
+ w += sldns_str_print(s, sl, "%02x", (*d)[4+i]);
+ else w += sldns_str_print(s, sl, "00");
+ }
+ }
+ w += sldns_str_print(s, sl, "/%u", (unsigned)prefix);
+ (*d) += 4+adflength;
+ (*dl) -= 4+adflength;
+ return w;
+}
+
+int sldns_wire2str_b32_ext_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ size_t datalen;
+ size_t sz;
+ if(*dl < 1) return -1;
+ datalen = (*d)[0];
+ if(*dl < 1+datalen) return -1;
+ sz = sldns_b32_ntop_calculate_size(datalen);
+ if(*sl < sz+1) {
+ (*d) += datalen+1;
+ (*dl) -= (datalen+1);
+ return (int)sz; /* out of space really, but would need buffer
+ in order to truncate the output */
+ }
+ sldns_b32_ntop_extended_hex((*d)+1, datalen, *s, *sl);
+ (*d) += datalen+1;
+ (*dl) -= (datalen+1);
+ (*s) += sz;
+ (*sl) -= sz;
+ return (int)sz;
+}
+
+/** scan number of bytes from wire into b64 presentation format */
+static int sldns_wire2str_b64_scan_num(uint8_t** d, size_t* dl, char** s,
+ size_t* sl, size_t num)
+{
+ /* b64_ntop_calculate size includes null at the end */
+ size_t sz = sldns_b64_ntop_calculate_size(num)-1;
+ if(*sl < sz+1) {
+ (*d) += num;
+ (*dl) -= num;
+ return (int)sz; /* out of space really, but would need buffer
+ in order to truncate the output */
+ }
+ sldns_b64_ntop(*d, num, *s, *sl);
+ (*d) += num;
+ (*dl) -= num;
+ (*s) += sz;
+ (*sl) -= sz;
+ return (int)sz;
+}
+
+int sldns_wire2str_b64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ return sldns_wire2str_b64_scan_num(d, dl, s, sl, *dl);
+}
+
+int sldns_wire2str_hex_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ return print_remainder_hex("", d, dl, s, sl);
+}
+
+int sldns_wire2str_nsec_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ uint8_t* p = *d;
+ size_t pl = *dl;
+ unsigned i, bit, window, block_len;
+ uint16_t t;
+ int w = 0;
+
+ /* check for errors */
+ while(pl) {
+ if(pl < 2) return -1;
+ block_len = (unsigned)p[1];
+ if(pl < 2+block_len) return -1;
+ p += block_len+2;
+ pl -= block_len+2;
+ }
+
+ /* do it */
+ p = *d;
+ pl = *dl;
+ while(pl) {
+ if(pl < 2) return -1; /* cannot happen */
+ window = (unsigned)p[0];
+ block_len = (unsigned)p[1];
+ if(pl < 2+block_len) return -1; /* cannot happen */
+ p += 2;
+ for(i=0; i<block_len; i++) {
+ if(p[i] == 0) continue;
+ /* base type number for this octet */
+ t = ((window)<<8) | (i << 3);
+ for(bit=0; bit<8; bit++) {
+ if((p[i]&(0x80>>bit))) {
+ if(w) w += sldns_str_print(s, sl, " ");
+ w += sldns_wire2str_type_print(s, sl,
+ t+bit);
+ }
+ }
+ }
+ p += block_len;
+ pl -= block_len+2;
+ }
+ (*d) += *dl;
+ (*dl) = 0;
+ return w;
+}
+
+int sldns_wire2str_nsec3_salt_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ size_t salt_len;
+ int w;
+ if(*dl < 1) return -1;
+ salt_len = (size_t)(*d)[0];
+ if(*dl < 1+salt_len) return -1;
+ (*d)++;
+ (*dl)--;
+ if(salt_len == 0) {
+ return sldns_str_print(s, sl, "-");
+ }
+ w = print_hex_buf(s, sl, *d, salt_len);
+ (*dl)-=salt_len;
+ (*d)+=salt_len;
+ return w;
+}
+
+int sldns_wire2str_cert_alg_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ sldns_lookup_table *lt;
+ int data, w;
+ if(*dl < 2) return -1;
+ data = (int)sldns_read_uint16(*d);
+ lt = sldns_lookup_by_id(sldns_cert_algorithms, data);
+ if(lt && lt->name)
+ w = sldns_str_print(s, sl, "%s", lt->name);
+ else w = sldns_str_print(s, sl, "%d", data);
+ (*dl)-=2;
+ (*d)+=2;
+ return w;
+}
+
+int sldns_wire2str_alg_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ /* don't use algorithm mnemonics in the presentation format
+ * this kind of got sneaked into the rfc's */
+ return sldns_wire2str_int8_scan(d, dl, s, sl);
+}
+
+int sldns_wire2str_unknown_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ return sldns_wire2str_rdata_unknown_scan(d, dl, s, sl);
+}
+
+int sldns_wire2str_time_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ /* create a YYYYMMDDHHMMSS string if possible */
+ struct tm tm;
+ char date_buf[16];
+ uint32_t t;
+ memset(&tm, 0, sizeof(tm));
+ if(*dl < 4) return -1;
+ t = sldns_read_uint32(*d);
+ date_buf[15]=0;
+ if(sldns_serial_arithmitics_gmtime_r(t, time(NULL), &tm) &&
+ strftime(date_buf, 15, "%Y%m%d%H%M%S", &tm)) {
+ (*d) += 4;
+ (*dl) -= 4;
+ return sldns_str_print(s, sl, "%s", date_buf);
+ }
+ return -1;
+}
+
+static int
+loc_cm_print(char** str, size_t* sl, uint8_t mantissa, uint8_t exponent)
+{
+ int w = 0;
+ uint8_t i;
+ /* is it 0.<two digits> ? */
+ if(exponent < 2) {
+ if(exponent == 1)
+ mantissa *= 10;
+ return sldns_str_print(str, sl, "0.%02ld", (long)mantissa);
+ }
+ /* always <digit><string of zeros> */
+ w += sldns_str_print(str, sl, "%d", (int)mantissa);
+ for(i=0; i<exponent-2; i++)
+ w += sldns_str_print(str, sl, "0");
+ return w;
+}
+
+int sldns_wire2str_loc_scan(uint8_t** d, size_t* dl, char** str, size_t* sl)
+{
+ /* we could do checking (ie degrees < 90 etc)? */
+ uint8_t version;
+ uint8_t size;
+ uint8_t horizontal_precision;
+ uint8_t vertical_precision;
+ uint32_t longitude;
+ uint32_t latitude;
+ uint32_t altitude;
+ char northerness;
+ char easterness;
+ uint32_t h;
+ uint32_t m;
+ double s;
+ uint32_t equator = (uint32_t)1 << 31; /* 2**31 */
+ int w = 0;
+
+ if(*dl < 16) return -1;
+ version = (*d)[0];
+ if(version != 0)
+ return sldns_wire2str_hex_scan(d, dl, str, sl);
+ size = (*d)[1];
+ horizontal_precision = (*d)[2];
+ vertical_precision = (*d)[3];
+
+ latitude = sldns_read_uint32((*d)+4);
+ longitude = sldns_read_uint32((*d)+8);
+ altitude = sldns_read_uint32((*d)+12);
+
+ if (latitude > equator) {
+ northerness = 'N';
+ latitude = latitude - equator;
+ } else {
+ northerness = 'S';
+ latitude = equator - latitude;
+ }
+ h = latitude / (1000 * 60 * 60);
+ latitude = latitude % (1000 * 60 * 60);
+ m = latitude / (1000 * 60);
+ latitude = latitude % (1000 * 60);
+ s = (double) latitude / 1000.0;
+ w += sldns_str_print(str, sl, "%02u %02u %06.3f %c ",
+ h, m, s, northerness);
+
+ if (longitude > equator) {
+ easterness = 'E';
+ longitude = longitude - equator;
+ } else {
+ easterness = 'W';
+ longitude = equator - longitude;
+ }
+ h = longitude / (1000 * 60 * 60);
+ longitude = longitude % (1000 * 60 * 60);
+ m = longitude / (1000 * 60);
+ longitude = longitude % (1000 * 60);
+ s = (double) longitude / (1000.0);
+ w += sldns_str_print(str, sl, "%02u %02u %06.3f %c ",
+ h, m, s, easterness);
+
+ s = ((double) altitude) / 100;
+ s -= 100000;
+
+ if(altitude%100 != 0)
+ w += sldns_str_print(str, sl, "%.2f", s);
+ else
+ w += sldns_str_print(str, sl, "%.0f", s);
+
+ w += sldns_str_print(str, sl, "m ");
+
+ w += loc_cm_print(str, sl, (size & 0xf0) >> 4, size & 0x0f);
+ w += sldns_str_print(str, sl, "m ");
+
+ w += loc_cm_print(str, sl, (horizontal_precision & 0xf0) >> 4,
+ horizontal_precision & 0x0f);
+ w += sldns_str_print(str, sl, "m ");
+
+ w += loc_cm_print(str, sl, (vertical_precision & 0xf0) >> 4,
+ vertical_precision & 0x0f);
+ w += sldns_str_print(str, sl, "m");
+
+ (*d)+=16;
+ (*dl)-=16;
+ return w;
+}
+
+int sldns_wire2str_wks_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ /* protocol, followed by bitmap of services */
+ const char* proto_name = NULL;
+ struct protoent *protocol;
+ struct servent *service;
+ uint8_t protocol_nr;
+ int bit, port, w = 0;
+ size_t i;
+ /* we cannot print with strings because they
+ * are not portable, the presentation format may
+ * not be able to be read in on another computer. */
+ int print_symbols = 0;
+
+ /* protocol */
+ if(*dl < 1) return -1;
+ protocol_nr = (*d)[0];
+ (*d)++;
+ (*dl)--;
+ protocol = getprotobynumber((int)protocol_nr);
+ if(protocol && (protocol->p_name != NULL)) {
+ w += sldns_str_print(s, sl, "%s", protocol->p_name);
+ proto_name = protocol->p_name;
+ } else {
+ w += sldns_str_print(s, sl, "%u", (unsigned)protocol_nr);
+ }
+
+ for(i=0; i<*dl; i++) {
+ if((*d)[i] == 0)
+ continue;
+ for(bit=0; bit<8; bit++) {
+ if(!(((*d)[i])&(0x80>>bit)))
+ continue;
+ port = (int)i*8 + bit;
+
+ if(!print_symbols)
+ service = NULL;
+ else
+ service = getservbyport(
+ (int)htons((uint16_t)port), proto_name);
+ if(service && service->s_name)
+ w += sldns_str_print(s, sl, " %s",
+ service->s_name);
+ else w += sldns_str_print(s, sl, " %u",
+ (unsigned)port);
+ }
+ }
+
+#ifdef HAVE_ENDSERVENT
+ endservent();
+#endif
+#ifdef HAVE_ENDPROTOENT
+ endprotoent();
+#endif
+ (*d) += *dl;
+ (*dl) = 0;
+ return w;
+}
+
+int sldns_wire2str_nsap_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ return print_remainder_hex("0x", d, dl, s, sl);
+}
+
+int sldns_wire2str_atma_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ return print_remainder_hex("", d, dl, s, sl);
+}
+
+/* internal scan routine that can modify arguments on failure */
+static int sldns_wire2str_ipseckey_scan_internal(uint8_t** d, size_t* dl,
+ char** s, size_t* sl, uint8_t* pkt, size_t pktlen)
+{
+ /* http://www.ietf.org/internet-drafts/draft-ietf-ipseckey-rr-12.txt*/
+ uint8_t precedence, gateway_type, algorithm;
+ int w = 0;
+
+ if(*dl < 3) return -1;
+ precedence = (*d)[0];
+ gateway_type = (*d)[1];
+ algorithm = (*d)[2];
+ if(gateway_type > 3)
+ return -1; /* unknown */
+ (*d)+=3;
+ (*dl)-=3;
+ w += sldns_str_print(s, sl, "%d %d %d ",
+ (int)precedence, (int)gateway_type, (int)algorithm);
+
+ switch(gateway_type) {
+ case 0: /* no gateway */
+ w += sldns_str_print(s, sl, ".");
+ break;
+ case 1: /* ip4 */
+ w += sldns_wire2str_a_scan(d, dl, s, sl);
+ break;
+ case 2: /* ip6 */
+ w += sldns_wire2str_aaaa_scan(d, dl, s, sl);
+ break;
+ case 3: /* dname */
+ w += sldns_wire2str_dname_scan(d, dl, s, sl, pkt, pktlen);
+ break;
+ default: /* unknown */
+ return -1;
+ }
+
+ if(*dl < 1)
+ return -1;
+ w += sldns_str_print(s, sl, " ");
+ w += sldns_wire2str_b64_scan_num(d, dl, s, sl, *dl);
+ return w;
+}
+
+int sldns_wire2str_ipseckey_scan(uint8_t** d, size_t* dl, char** s, size_t* sl,
+ uint8_t* pkt, size_t pktlen)
+{
+ uint8_t* od = *d;
+ char* os = *s;
+ size_t odl = *dl, osl = *sl;
+ int w=sldns_wire2str_ipseckey_scan_internal(d, dl, s, sl, pkt, pktlen);
+ if(w == -1) {
+ *d = od;
+ *s = os;
+ *dl = odl;
+ *sl = osl;
+ return -1;
+ }
+ return w;
+}
+
+int sldns_wire2str_hip_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w;
+ uint8_t algo, hitlen;
+ uint16_t pklen;
+
+ /* read lengths */
+ if(*dl < 4)
+ return -1;
+ hitlen = (*d)[0];
+ algo = (*d)[1];
+ pklen = sldns_read_uint16((*d)+2);
+ if(*dl < (size_t)4 + (size_t)hitlen + (size_t)pklen)
+ return -1;
+
+ /* write: algo hit pubkey */
+ w = sldns_str_print(s, sl, "%u ", (unsigned)algo);
+ w += print_hex_buf(s, sl, (*d)+4, hitlen);
+ w += sldns_str_print(s, sl, " ");
+ (*d)+=4+hitlen;
+ (*dl)-= (4+hitlen);
+ w += sldns_wire2str_b64_scan_num(d, dl, s, sl, pklen);
+ return w;
+}
+
+int sldns_wire2str_int16_data_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ uint16_t n;
+ if(*dl < 2)
+ return -1;
+ n = sldns_read_uint16(*d);
+ if(*dl < 2+(size_t)n)
+ return -1;
+ (*d)+=2;
+ (*dl)-=2;
+ return sldns_wire2str_b64_scan_num(d, dl, s, sl, n);
+}
+
+int sldns_wire2str_nsec3_next_owner_scan(uint8_t** d, size_t* dl, char** s,
+ size_t* sl)
+{
+ return sldns_wire2str_b32_ext_scan(d, dl, s, sl);
+}
+
+int sldns_wire2str_ilnp64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w;
+ if(*dl < 8)
+ return -1;
+ w = sldns_str_print(s, sl, "%.4x:%.4x:%.4x:%.4x",
+ sldns_read_uint16(*d), sldns_read_uint16((*d)+2),
+ sldns_read_uint16((*d)+4), sldns_read_uint16((*d)+6));
+ (*d)+=8;
+ (*dl)-=8;
+ return w;
+}
+
+int sldns_wire2str_eui48_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w;
+ if(*dl < 6)
+ return -1;
+ w = sldns_str_print(s, sl, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ (*d)[0], (*d)[1], (*d)[2], (*d)[3], (*d)[4], (*d)[5]);
+ (*d)+=6;
+ (*dl)-=6;
+ return w;
+}
+
+int sldns_wire2str_eui64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ int w;
+ if(*dl < 8)
+ return -1;
+ w = sldns_str_print(s, sl, "%.2x-%.2x-%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ (*d)[0], (*d)[1], (*d)[2], (*d)[3], (*d)[4], (*d)[5],
+ (*d)[6], (*d)[7]);
+ (*d)+=8;
+ (*dl)-=8;
+ return w;
+}
+
+int sldns_wire2str_tag_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ size_t i, n;
+ int w = 0;
+ if(*dl < 1)
+ return -1;
+ n = (size_t)((*d)[0]);
+ if(*dl < 1+n)
+ return -1;
+ for(i=0; i<n; i++)
+ if(!isalnum((int)(*d)[i]))
+ return -1;
+ for(i=0; i<n; i++)
+ w += sldns_str_print(s, sl, "%c", (char)(*d)[i]);
+ (*d)+=n+1;
+ (*dl)-=(n+1);
+ return w;
+}
+
+int sldns_wire2str_long_str_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
+{
+ size_t i;
+ int w = 0;
+ w += sldns_str_print(s, sl, "\"");
+ for(i=0; i<*dl; i++)
+ w += str_char_print(s, sl, (*d)[i]);
+ w += sldns_str_print(s, sl, "\"");
+ (*d)+=*dl;
+ (*dl)=0;
+ return w;
+}
+
+int sldns_wire2str_edns_llq_print(char** s, size_t* sl, uint8_t* data,
+ size_t len)
+{
+ /* LLQ constants */
+ const char* llq_errors[] = {"NO-ERROR", "SERV-FULL", "STATIC",
+ "FORMAT-ERR", "NO-SUCH-LLQ", "BAD-VERS", "UNKNOWN_ERR"};
+ const unsigned int llq_errors_num = 7;
+ const char* llq_opcodes[] = {"LLQ-SETUP", "LLQ-REFRESH", "LLQ-EVENT"};
+ const unsigned int llq_opcodes_num = 3;
+ uint16_t version, llq_opcode, error_code;
+ uint64_t llq_id;
+ uint32_t lease_life; /* Requested or granted life of LLQ, in seconds */
+ int w = 0;
+
+ /* read the record */
+ if(len != 18) {
+ w += sldns_str_print(s, sl, "malformed LLQ ");
+ w += print_hex_buf(s, sl, data, len);
+ return w;
+ }
+ version = sldns_read_uint16(data);
+ llq_opcode = sldns_read_uint16(data+2);
+ error_code = sldns_read_uint16(data+4);
+ memmove(&llq_id, data+6, sizeof(llq_id));
+ lease_life = sldns_read_uint32(data+14);
+
+ /* print it */
+ w += sldns_str_print(s, sl, "v%d ", (int)version);
+ if(llq_opcode < llq_opcodes_num)
+ w += sldns_str_print(s, sl, "%s", llq_opcodes[llq_opcode]);
+ else w += sldns_str_print(s, sl, "opcode %d", (int)llq_opcode);
+ if(error_code < llq_errors_num)
+ w += sldns_str_print(s, sl, " %s", llq_errors[error_code]);
+ else w += sldns_str_print(s, sl, " error %d", (int)error_code);
+#ifndef USE_WINSOCK
+ w += sldns_str_print(s, sl, " id %llx lease-life %lu",
+ (unsigned long long)llq_id, (unsigned long)lease_life);
+#else
+ w += sldns_str_print(s, sl, " id %I64x lease-life %lu",
+ (unsigned long long)llq_id, (unsigned long)lease_life);
+#endif
+ return w;
+}
+
+int sldns_wire2str_edns_ul_print(char** s, size_t* sl, uint8_t* data,
+ size_t len)
+{
+ uint32_t lease;
+ int w = 0;
+ if(len != 4) {
+ w += sldns_str_print(s, sl, "malformed UL ");
+ w += print_hex_buf(s, sl, data, len);
+ return w;
+ }
+ lease = sldns_read_uint32(data);
+ w += sldns_str_print(s, sl, "lease %lu", (unsigned long)lease);
+ return w;
+}
+
+int sldns_wire2str_edns_nsid_print(char** s, size_t* sl, uint8_t* data,
+ size_t len)
+{
+ int w = 0;
+ size_t i, printed=0;
+ w += print_hex_buf(s, sl, data, len);
+ for(i=0; i<len; i++) {
+ if(isprint((int)data[i]) || data[i] == '\t') {
+ if(!printed) {
+ w += sldns_str_print(s, sl, " (");
+ printed = 1;
+ }
+ w += sldns_str_print(s, sl, "%c", (char)data[i]);
+ }
+ }
+ if(printed)
+ w += sldns_str_print(s, sl, ")");
+ return w;
+}
+
+int sldns_wire2str_edns_dau_print(char** s, size_t* sl, uint8_t* data,
+ size_t len)
+{
+ sldns_lookup_table *lt;
+ size_t i;
+ int w = 0;
+ for(i=0; i<len; i++) {
+ lt = sldns_lookup_by_id(sldns_algorithms, (int)data[i]);
+ if(lt && lt->name)
+ w += sldns_str_print(s, sl, " %s", lt->name);
+ else w += sldns_str_print(s, sl, " %d", (int)data[i]);
+ }
+ return w;
+}
+
+int sldns_wire2str_edns_dhu_print(char** s, size_t* sl, uint8_t* data,
+ size_t len)
+{
+ sldns_lookup_table *lt;
+ size_t i;
+ int w = 0;
+ for(i=0; i<len; i++) {
+ lt = sldns_lookup_by_id(sldns_hashes, (int)data[i]);
+ if(lt && lt->name)
+ w += sldns_str_print(s, sl, " %s", lt->name);
+ else w += sldns_str_print(s, sl, " %d", (int)data[i]);
+ }
+ return w;
+}
+
+int sldns_wire2str_edns_n3u_print(char** s, size_t* sl, uint8_t* data,
+ size_t len)
+{
+ size_t i;
+ int w = 0;
+ for(i=0; i<len; i++) {
+ if(data[i] == 1)
+ w += sldns_str_print(s, sl, " SHA1");
+ else w += sldns_str_print(s, sl, " %d", (int)data[i]);
+ }
+ return w;
+}
+
+int sldns_wire2str_edns_subnet_print(char** s, size_t* sl, uint8_t* data,
+ size_t len)
+{
+ int w = 0;
+ uint16_t family;
+ uint8_t source, scope;
+ if(len < 4) {
+ w += sldns_str_print(s, sl, "malformed subnet ");
+ w += print_hex_buf(s, sl, data, len);
+ return w;
+ }
+ family = sldns_read_uint16(data);
+ source = data[2];
+ scope = data[3];
+ if(family == 1) {
+ /* IP4 */
+ char buf[64];
+ uint8_t ip4[4];
+ memset(ip4, 0, sizeof(ip4));
+ if(len-4 > 4) {
+ w += sldns_str_print(s, sl, "trailingdata:");
+ w += print_hex_buf(s, sl, data+4+4, len-4-4);
+ w += sldns_str_print(s, sl, " ");
+ len = 4+4;
+ }
+ memmove(ip4, data+4, len-4);
+ if(!inet_ntop(AF_INET, ip4, buf, (socklen_t)sizeof(buf))) {
+ w += sldns_str_print(s, sl, "ip4ntoperror ");
+ w += print_hex_buf(s, sl, data+4+4, len-4-4);
+ } else {
+ w += sldns_str_print(s, sl, "%s", buf);
+ }
+ } else if(family == 2) {
+ /* IP6 */
+ char buf[64];
+ uint8_t ip6[16];
+ memset(ip6, 0, sizeof(ip6));
+ if(len-4 > 16) {
+ w += sldns_str_print(s, sl, "trailingdata:");
+ w += print_hex_buf(s, sl, data+4+16, len-4-16);
+ w += sldns_str_print(s, sl, " ");
+ len = 4+16;
+ }
+ memmove(ip6, data+4, len-4);
+#ifdef AF_INET6
+ if(!inet_ntop(AF_INET6, ip6, buf, (socklen_t)sizeof(buf))) {
+ w += sldns_str_print(s, sl, "ip6ntoperror ");
+ w += print_hex_buf(s, sl, data+4+4, len-4-4);
+ } else {
+ w += sldns_str_print(s, sl, "%s", buf);
+ }
+#else
+ w += print_hex_buf(s, sl, data+4+4, len-4-4);
+#endif
+ } else {
+ /* unknown */
+ w += sldns_str_print(s, sl, "family %d ",
+ (int)family);
+ w += print_hex_buf(s, sl, data, len);
+ }
+ w += sldns_str_print(s, sl, "/%d scope /%d", (int)source, (int)scope);
+ return w;
+}
+
+int sldns_wire2str_edns_option_print(char** s, size_t* sl,
+ uint16_t option_code, uint8_t* optdata, size_t optlen)
+{
+ int w = 0;
+ w += sldns_wire2str_edns_option_code_print(s, sl, option_code);
+ w += sldns_str_print(s, sl, ": ");
+ switch(option_code) {
+ case LDNS_EDNS_LLQ:
+ w += sldns_wire2str_edns_llq_print(s, sl, optdata, optlen);
+ break;
+ case LDNS_EDNS_UL:
+ w += sldns_wire2str_edns_ul_print(s, sl, optdata, optlen);
+ break;
+ case LDNS_EDNS_NSID:
+ w += sldns_wire2str_edns_nsid_print(s, sl, optdata, optlen);
+ break;
+ case LDNS_EDNS_DAU:
+ w += sldns_wire2str_edns_dau_print(s, sl, optdata, optlen);
+ break;
+ case LDNS_EDNS_DHU:
+ w += sldns_wire2str_edns_dhu_print(s, sl, optdata, optlen);
+ break;
+ case LDNS_EDNS_N3U:
+ w += sldns_wire2str_edns_n3u_print(s, sl, optdata, optlen);
+ break;
+ case LDNS_EDNS_CLIENT_SUBNET:
+ w += sldns_wire2str_edns_subnet_print(s, sl, optdata, optlen);
+ break;
+ default:
+ /* unknown option code */
+ w += print_hex_buf(s, sl, optdata, optlen);
+ break;
+ }
+ return w;
+}
+
+/** print the edns options to string */
+static int
+print_edns_opts(char** s, size_t* sl, uint8_t* rdata, size_t rdatalen)
+{
+ uint16_t option_code, option_len;
+ int w = 0;
+ while(rdatalen > 0) {
+ /* option name */
+ if(rdatalen < 4) {
+ w += sldns_str_print(s, sl, " ; malformed: ");
+ w += print_hex_buf(s, sl, rdata, rdatalen);
+ return w;
+ }
+ option_code = sldns_read_uint16(rdata);
+ option_len = sldns_read_uint16(rdata+2);
+ rdata += 4;
+ rdatalen -= 4;
+
+ /* option value */
+ if(rdatalen < (size_t)option_len) {
+ w += sldns_str_print(s, sl, " ; malformed ");
+ w += sldns_wire2str_edns_option_code_print(s, sl,
+ option_code);
+ w += sldns_str_print(s, sl, ": ");
+ w += print_hex_buf(s, sl, rdata, rdatalen);
+ return w;
+ }
+ w += sldns_str_print(s, sl, " ; ");
+ w += sldns_wire2str_edns_option_print(s, sl, option_code,
+ rdata, option_len);
+ rdata += option_len;
+ rdatalen -= option_len;
+ }
+ return w;
+}
+
+int sldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, uint8_t* pkt, size_t pktlen)
+{
+ int w = 0;
+ uint8_t ext_rcode, edns_version;
+ uint16_t udpsize, edns_bits, rdatalen;
+ w += sldns_str_print(str, str_len, "; EDNS:");
+
+ /* some input checks, domain name */
+ if(*data_len < 1+10)
+ return w + print_remainder_hex("Error malformed 0x",
+ data, data_len, str, str_len);
+ if(*data[0] != 0) {
+ return w + print_remainder_hex("Error nonrootdname 0x",
+ data, data_len, str, str_len);
+ }
+ (*data)++;
+ (*data_len)--;
+
+ /* check type and read fixed contents */
+ if(sldns_read_uint16((*data)) != LDNS_RR_TYPE_OPT) {
+ return w + print_remainder_hex("Error nottypeOPT 0x",
+ data, data_len, str, str_len);
+ }
+ udpsize = sldns_read_uint16((*data)+2);
+ ext_rcode = (*data)[4];
+ edns_version = (*data)[5];
+ edns_bits = sldns_read_uint16((*data)+6);
+ rdatalen = sldns_read_uint16((*data)+8);
+ (*data)+=10;
+ (*data_len)-=10;
+
+ w += sldns_str_print(str, str_len, " version: %u;",
+ (unsigned)edns_version);
+ w += sldns_str_print(str, str_len, " flags:");
+ if((edns_bits & LDNS_EDNS_MASK_DO_BIT))
+ w += sldns_str_print(str, str_len, " do");
+ /* the extended rcode is the value set, shifted four bits,
+ * and or'd with the original rcode */
+ if(ext_rcode) {
+ int rc = ((int)ext_rcode)<<4;
+ if(pkt && pktlen >= LDNS_HEADER_SIZE)
+ rc |= LDNS_RCODE_WIRE(pkt);
+ w += sldns_str_print(str, str_len, " ; ext-rcode: %d", rc);
+ }
+ w += sldns_str_print(str, str_len, " ; udp: %u", (unsigned)udpsize);
+
+ if(rdatalen) {
+ if(*data_len < rdatalen) {
+ w += sldns_str_print(str, str_len,
+ " ; Error EDNS rdata too short; ");
+ rdatalen = *data_len;
+ }
+ w += print_edns_opts(str, str_len, *data, rdatalen);
+ (*data) += rdatalen;
+ (*data_len) -= rdatalen;
+ }
+ w += sldns_str_print(str, str_len, "\n");
+ return w;
+}
diff --git a/contrib/unbound/ldns/wire2str.h b/contrib/unbound/ldns/wire2str.h
new file mode 100644
index 0000000..67f5435
--- /dev/null
+++ b/contrib/unbound/ldns/wire2str.h
@@ -0,0 +1,984 @@
+/**
+ * wire2str.h - txt presentation of RRs
+ *
+ * (c) NLnet Labs, 2005-2006
+ *
+ * See the file LICENSE for the license
+ */
+
+/**
+ * \file
+ *
+ * Contains functions to translate the wireformat to text
+ * representation, as well as functions to print them.
+ */
+
+#ifndef LDNS_WIRE2STR_H
+#define LDNS_WIRE2STR_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+struct sldns_struct_lookup_table;
+
+/* lookup tables for standard DNS stuff */
+/** Taken from RFC 2535, section 7. */
+extern struct sldns_struct_lookup_table* sldns_algorithms;
+/** DS record hash algorithms */
+extern struct sldns_struct_lookup_table* sldns_hashes;
+/** Taken from RFC 2538, section 2.1. */
+extern struct sldns_struct_lookup_table* sldns_cert_algorithms;
+/** Response codes */
+extern struct sldns_struct_lookup_table* sldns_rcodes;
+/** Operation codes */
+extern struct sldns_struct_lookup_table* sldns_opcodes;
+/** EDNS flags */
+extern struct sldns_struct_lookup_table* sldns_edns_flags;
+/** EDNS option codes */
+extern struct sldns_struct_lookup_table* sldns_edns_options;
+/** error string from wireparse */
+extern struct sldns_struct_lookup_table* sldns_wireparse_errors;
+
+/**
+ * Convert wireformat packet to a string representation
+ * @param data: wireformat packet data (starting at ID bytes).
+ * @param len: length of packet.
+ * @return string(malloced) or NULL on failure.
+ */
+char* sldns_wire2str_pkt(uint8_t* data, size_t len);
+
+/**
+ * Convert wireformat RR to a string representation.
+ * @param rr: the wireformat RR, in uncompressed form. Starts at the domain
+ * name start, ends with the rdata of the RR.
+ * @param len: length of the rr wireformat.
+ * @return string(malloced) or NULL on failure.
+ */
+char* sldns_wire2str_rr(uint8_t* rr, size_t len);
+
+/**
+ * Conver wire dname to a string.
+ * @param dname: the dname in uncompressed wireformat.
+ * @param dname_len: length of the dname.
+ * @return string or NULL on failure.
+ */
+char* sldns_wire2str_dname(uint8_t* dname, size_t dname_len);
+
+/**
+ * Convert wire RR type to a string, 'MX', 'TYPE1234'...
+ * @param rrtype: the RR type in host order.
+ * @return malloced string with the RR type or NULL on malloc failure.
+ */
+char* sldns_wire2str_type(uint16_t rrtype);
+
+/**
+ * Convert wire RR class to a string, 'IN', 'CLASS1'.
+ * @param rrclass: the RR class in host order.
+ * @return malloced string with the RR class or NULL on malloc failure.
+ */
+char* sldns_wire2str_class(uint16_t rrclass);
+
+/**
+ * Convert wire packet rcode to a string, 'NOERROR', 'NXDOMAIN'...
+ * @param rcode: as integer, host order
+ * @return malloced string with the rcode or NULL on malloc failure.
+ */
+char* sldns_wire2str_rcode(int rcode);
+
+/**
+ * Print to string, move string along for next content. With va_list.
+ * @param str: string buffer. Adjusted at end to after the output.
+ * @param slen: length of the string buffer. Adjusted at end.
+ * @param format: printf format string.
+ * @param args: arguments for printf.
+ * @return number of characters needed. Can be larger than slen.
+ */
+int sldns_str_vprint(char** str, size_t* slen, const char* format, va_list args);
+
+/**
+ * Print to string, move string along for next content.
+ * @param str: string buffer. Adjusted at end to after the output.
+ * @param slen: length of the string buffer. Adjusted at end.
+ * @param format: printf format string and arguments for it.
+ * @return number of characters needed. Can be larger than slen.
+ */
+int sldns_str_print(char** str, size_t* slen, const char* format, ...)
+ ATTR_FORMAT(printf, 3, 4);
+
+/**
+ * Convert wireformat packet to a string representation with user buffer
+ * It appends every RR with default comments.
+ * For more formatter options use the function: TBD(TODO)
+ * @param data: wireformat packet data (starting at ID bytes).
+ * @param data_len: length of packet.
+ * @param str: the string buffer for the output.
+ * If you pass NULL as the str the return value of the function is
+ * the str_len you need for the entire packet. It does not include
+ * the 0 byte at the end.
+ * @param str_len: the size of the string buffer. If more is needed, it'll
+ * silently truncate the output to fit in the buffer.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_pkt_buf(uint8_t* data, size_t data_len, char* str,
+ size_t str_len);
+
+/**
+ * Scan wireformat packet to a string representation with user buffer
+ * It appends every RR with default comments.
+ * For more formatter options use the function: TBD(TODO)
+ * @param data: wireformat packet data (starting at ID bytes).
+ * @param data_len: length of packet.
+ * @param str: the string buffer for the output.
+ * @param str_len: the size of the string buffer.
+ * @return number of characters for string.
+ * returns the number of characters that are needed (except terminating null),
+ * so it may return a value larger than str_len.
+ * On error you get less output (i.e. shorter output in str (null terminated))
+ * On exit the data, data_len, str and str_len values are adjusted to move them
+ * from their original position along the input and output for the content
+ * that has been consumed (and produced) by this function. If the end of the
+ * output string is reached, *str_len is set to 0. The output string is null
+ * terminated (shortening the output if necessary). If the end of the input
+ * is reached *data_len is set to 0.
+ */
+int sldns_wire2str_pkt_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat rr to string, with user buffers. It shifts the arguments
+ * to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param pkt: packet for decompression, if NULL no decompression.
+ * @param pktlen: length of packet buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_rr_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, uint8_t* pkt, size_t pktlen);
+
+/**
+ * Scan wireformat question rr to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param pkt: packet for decompression, if NULL no decompression.
+ * @param pktlen: length of packet buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_rrquestion_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, uint8_t* pkt, size_t pktlen);
+
+/**
+ * Scan wireformat RR to string in unknown RR format, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param pkt: packet for decompression, if NULL no decompression.
+ * @param pktlen: length of packet buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_rr_unknown_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, uint8_t* pkt, size_t pktlen);
+
+/**
+ * Print to string the RR-information comment in default format,
+ * with user buffers. Moves string along.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param rr: wireformat data.
+ * @param rrlen: length of data buffer.
+ * @param dname_off: offset in buffer behind owner dname, the compressed size
+ * of the owner name.
+ * @param rrtype: type of the RR, host format.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_rr_comment_print(char** str, size_t* str_len, uint8_t* rr,
+ size_t rrlen, size_t dname_off, uint16_t rrtype);
+
+/**
+ * Scan wireformat packet header to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_header_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat rdata to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer. The length of the rdata in the
+ * buffer. The rdatalen itself has already been scanned, the data
+ * points to the rdata after the rdatalen.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param rrtype: RR type of Rdata, host format.
+ * @param pkt: packet for decompression, if NULL no decompression.
+ * @param pktlen: length of packet buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_rdata_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, uint16_t rrtype, uint8_t* pkt, size_t pktlen);
+
+/**
+ * Scan wireformat rdata to string in unknown format, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer, the length of the rdata in buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_rdata_unknown_scan(uint8_t** data, size_t* data_len,
+ char** str, size_t* str_len);
+
+/**
+ * Scan wireformat domain name to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param pkt: packet for decompression, if NULL no decompression.
+ * @param pktlen: length of packet buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_dname_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, uint8_t* pkt, size_t pktlen);
+
+/**
+ * Scan wireformat rr type to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_type_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat rr class to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_class_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat rr ttl to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_ttl_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+
+/**
+ * Print host format rr type to string. Moves string along, user buffers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param rrtype: host format rr type.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_type_print(char** str, size_t* str_len, uint16_t rrtype);
+
+/**
+ * Print host format rr class to string. Moves string along, user buffers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param rrclass: host format rr class.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_class_print(char** str, size_t* str_len, uint16_t rrclass);
+
+/**
+ * Print host format rcode to string. Moves string along, user buffers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param rcode: host format rcode number.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_rcode_print(char** str, size_t* str_len, int rcode);
+
+/**
+ * Print host format opcode to string. Moves string along, user buffers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param opcode: host format opcode number.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_opcode_print(char** str, size_t* str_len, int opcode);
+
+/**
+ * Print host format EDNS0 option to string. Moves string along, user buffers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param opcode: host format option number.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_option_code_print(char** str, size_t* str_len,
+ uint16_t opcode);
+
+/**
+ * Convert RR to string presentation format, on one line. User buffer.
+ * @param rr: wireformat RR data
+ * @param rr_len: length of the rr wire data.
+ * @param str: the string buffer to write to.
+ * If you pass NULL as the str, the return value of the function is
+ * the str_len you need for the entire packet. It does not include
+ * the 0 byte at the end.
+ * @param str_len: the size of the string buffer. If more is needed, it'll
+ * silently truncate the output to fit in the buffer.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str,
+ size_t str_len);
+
+/**
+ * 3597 printout of an RR in unknown rr format.
+ * There are more format and comment options available for printout
+ * with the function: TBD(TODO)
+ * @param rr: wireformat RR data
+ * @param rr_len: length of the rr wire data.
+ * @param str: the string buffer to write to.
+ * If you pass NULL as the str, the return value of the function is
+ * the str_len you need for the entire rr. It does not include
+ * the 0 byte at the end.
+ * @param str_len: the size of the string buffer. If more is needed, it'll
+ * silently truncate the output to fit in the buffer.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_rr_unknown_buf(uint8_t* rr, size_t rr_len, char* str,
+ size_t str_len);
+
+/**
+ * This creates the comment to print after the RR. ; keytag=... , and other
+ * basic comments for RRs.
+ * There are more format and comment options available for printout
+ * with the function: TBD(TODO)
+ * @param rr: wireformat RR data
+ * @param rr_len: length of the rr wire data.
+ * @param dname_len: length of the dname in front of the RR.
+ * @param str: the string buffer to write to.
+ * If you pass NULL as the str, the return value of the function is
+ * the str_len you need for the entire comment. It does not include
+ * the 0 byte at the end.
+ * @param str_len: the size of the string buffer. If more is needed, it'll
+ * silently truncate the output to fit in the buffer.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rr_len, size_t dname_len,
+ char* str, size_t str_len);
+
+/**
+ * Convert RDATA to string presentation format, on one line. User buffer.
+ * @param rdata: wireformat rdata part of an RR.
+ * @param rdata_len: length of the rr wire data.
+ * @param str: the string buffer to write to.
+ * If you pass NULL as the str, the return value of the function is
+ * the str_len you need for the entire packet. It does not include
+ * the 0 byte at the end.
+ * @param str_len: the size of the string buffer. If more is needed, it'll
+ * silently truncate the output to fit in the buffer.
+ * @param rrtype: rr type of the data
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str,
+ size_t str_len, uint16_t rrtype);
+
+/**
+ * Convert wire RR type to a string, 'MX', 'TYPE12'. With user buffer.
+ * @param rrtype: the RR type in host order.
+ * @param str: the string to write to.
+ * @param len: length of str.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_type_buf(uint16_t rrtype, char* str, size_t len);
+
+/**
+ * Convert wire RR class to a string, 'IN', 'CLASS12'. With user buffer.
+ * @param rrclass: the RR class in host order.
+ * @param str: the string to write to.
+ * @param len: length of str.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_class_buf(uint16_t rrclass, char* str, size_t len);
+
+/**
+ * Convert wire RR rcode to a string, 'NOERROR', 'NXDOMAIN'. With user buffer.
+ * @param rcode: rcode as integer in host order
+ * @param str: the string to write to.
+ * @param len: length of str.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_rcode_buf(int rcode, char* str, size_t len);
+
+/**
+ * Convert wire dname to a string, "example.com.". With user buffer.
+ * @param dname: the dname in uncompressed wireformat.
+ * @param dname_len: length of the dname.
+ * @param str: the string to write to.
+ * @param len: length of string.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger than str_len if output was truncated.
+ */
+int sldns_wire2str_dname_buf(uint8_t* dname, size_t dname_len, char* str,
+ size_t len);
+
+/**
+ * Scan wireformat rdf field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param rdftype: the type of the rdata field, enum sldns_rdf_type.
+ * @param pkt: packet for decompression, if NULL no decompression.
+ * @param pktlen: length of packet buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_rdf_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, int rdftype, uint8_t* pkt, size_t pktlen);
+
+/**
+ * Scan wireformat int8 field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_int8_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat int16 field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_int16_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat int32 field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_int32_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat period field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_period_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat tsigtime field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_tsigtime_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat ip4 A field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_a_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat ip6 AAAA field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_aaaa_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat str field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_str_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat apl field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_apl_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat b32_ext field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_b32_ext_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat b64 field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_b64_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat hex field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_hex_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat nsec bitmap field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_nsec_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat nsec3_salt field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_nsec3_salt_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat cert_alg field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_cert_alg_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat alg field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_alg_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat type unknown field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_unknown_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat time field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_time_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat LOC field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_loc_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat WKS field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_wks_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat NSAP field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_nsap_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat ATMA field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_atma_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat IPSECKEY field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param pkt: packet for decompression, if NULL no decompression.
+ * @param pktlen: length of packet buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_ipseckey_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, uint8_t* pkt, size_t pktlen);
+
+/**
+ * Scan wireformat HIP (algo, HIT, pubkey) field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_hip_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat int16_data field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_int16_data_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat nsec3_next_owner field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_nsec3_next_owner_scan(uint8_t** data, size_t* data_len,
+ char** str, size_t* str_len);
+
+/**
+ * Scan wireformat ILNP64 field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_ilnp64_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat EUI48 field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_eui48_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat EUI64 field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_eui64_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat TAG field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_tag_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Scan wireformat long_str field to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int sldns_wire2str_long_str_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
+/**
+ * Print EDNS LLQ option data to string. User buffers, moves string pointers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param option_data: buffer with EDNS option code data.
+ * @param option_len: length of the data for this option.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_llq_print(char** str, size_t* str_len,
+ uint8_t* option_data, size_t option_len);
+
+/**
+ * Print EDNS UL option data to string. User buffers, moves string pointers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param option_data: buffer with EDNS option code data.
+ * @param option_len: length of the data for this option.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_ul_print(char** str, size_t* str_len,
+ uint8_t* option_data, size_t option_len);
+
+/**
+ * Print EDNS NSID option data to string. User buffers, moves string pointers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param option_data: buffer with EDNS option code data.
+ * @param option_len: length of the data for this option.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_nsid_print(char** str, size_t* str_len,
+ uint8_t* option_data, size_t option_len);
+
+/**
+ * Print EDNS DAU option data to string. User buffers, moves string pointers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param option_data: buffer with EDNS option code data.
+ * @param option_len: length of the data for this option.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_dau_print(char** str, size_t* str_len,
+ uint8_t* option_data, size_t option_len);
+
+/**
+ * Print EDNS DHU option data to string. User buffers, moves string pointers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param option_data: buffer with EDNS option code data.
+ * @param option_len: length of the data for this option.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_dhu_print(char** str, size_t* str_len,
+ uint8_t* option_data, size_t option_len);
+
+/**
+ * Print EDNS N3U option data to string. User buffers, moves string pointers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param option_data: buffer with EDNS option code data.
+ * @param option_len: length of the data for this option.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_n3u_print(char** str, size_t* str_len,
+ uint8_t* option_data, size_t option_len);
+
+/**
+ * Print EDNS SUBNET option data to string. User buffers, moves string pointers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param option_data: buffer with EDNS option code data.
+ * @param option_len: length of the data for this option.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_subnet_print(char** str, size_t* str_len,
+ uint8_t* option_data, size_t option_len);
+
+/**
+ * Print an EDNS option as OPT: VALUE. User buffers, moves string pointers.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param option_code: host format EDNS option code.
+ * @param option_data: buffer with EDNS option code data.
+ * @param option_len: length of the data for this option.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_option_print(char** str, size_t* str_len,
+ uint16_t option_code, uint8_t* option_data, size_t option_len);
+
+/**
+ * Scan wireformat EDNS OPT to string, with user buffers.
+ * It shifts the arguments to move along (see sldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @param pkt: packet with header and other info (may be NULL)
+ * @param pktlen: length of packet buffer.
+ * @return number of characters (except null) needed to print.
+ */
+int sldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len, uint8_t* pkt, size_t pktlen);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDNS_WIRE2STR_H */
diff --git a/contrib/unbound/libunbound/context.c b/contrib/unbound/libunbound/context.c
index e3e6496..c21f941 100644
--- a/contrib/unbound/libunbound/context.c
+++ b/contrib/unbound/libunbound/context.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -49,6 +49,7 @@
#include "services/cache/infra.h"
#include "util/data/msgreply.h"
#include "util/storage/slabhash.h"
+#include "ldns/sbuffer.h"
int
context_finalize(struct ub_ctx* ctx)
@@ -124,7 +125,7 @@ find_id(struct ub_ctx* ctx, int* id)
}
struct ctx_query*
-context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass,
+context_new(struct ub_ctx* ctx, const char* name, int rrtype, int rrclass,
ub_callback_t cb, void* cbarg)
{
struct ctx_query* q = (struct ctx_query*)calloc(1, sizeof(*q));
@@ -220,10 +221,10 @@ context_serialize_new_query(struct ctx_query* q, uint32_t* len)
*len = sizeof(uint32_t)*4 + slen;
p = (uint8_t*)malloc(*len);
if(!p) return NULL;
- ldns_write_uint32(p, UB_LIBCMD_NEWQUERY);
- ldns_write_uint32(p+sizeof(uint32_t), (uint32_t)q->querynum);
- ldns_write_uint32(p+2*sizeof(uint32_t), (uint32_t)q->res->qtype);
- ldns_write_uint32(p+3*sizeof(uint32_t), (uint32_t)q->res->qclass);
+ sldns_write_uint32(p, UB_LIBCMD_NEWQUERY);
+ sldns_write_uint32(p+sizeof(uint32_t), (uint32_t)q->querynum);
+ sldns_write_uint32(p+2*sizeof(uint32_t), (uint32_t)q->res->qtype);
+ sldns_write_uint32(p+3*sizeof(uint32_t), (uint32_t)q->res->qclass);
memmove(p+4*sizeof(uint32_t), q->res->qname, slen);
return p;
}
@@ -237,8 +238,8 @@ context_deserialize_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len)
free(q);
return NULL;
}
- log_assert( ldns_read_uint32(p) == UB_LIBCMD_NEWQUERY);
- q->querynum = (int)ldns_read_uint32(p+sizeof(uint32_t));
+ log_assert( sldns_read_uint32(p) == UB_LIBCMD_NEWQUERY);
+ q->querynum = (int)sldns_read_uint32(p+sizeof(uint32_t));
q->node.key = &q->querynum;
q->async = 1;
q->res = (struct ub_result*)calloc(1, sizeof(*q->res));
@@ -246,8 +247,8 @@ context_deserialize_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len)
free(q);
return NULL;
}
- q->res->qtype = (int)ldns_read_uint32(p+2*sizeof(uint32_t));
- q->res->qclass = (int)ldns_read_uint32(p+3*sizeof(uint32_t));
+ q->res->qtype = (int)sldns_read_uint32(p+2*sizeof(uint32_t));
+ q->res->qclass = (int)sldns_read_uint32(p+3*sizeof(uint32_t));
q->res->qname = strdup((char*)(p+4*sizeof(uint32_t)));
if(!q->res->qname) {
free(q->res);
@@ -269,8 +270,8 @@ context_lookup_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len)
if(len < 4*sizeof(uint32_t)+1) {
return NULL;
}
- log_assert( ldns_read_uint32(p) == UB_LIBCMD_NEWQUERY);
- querynum = (int)ldns_read_uint32(p+sizeof(uint32_t));
+ log_assert( sldns_read_uint32(p) == UB_LIBCMD_NEWQUERY);
+ querynum = (int)sldns_read_uint32(p+sizeof(uint32_t));
q = (struct ctx_query*)rbtree_search(&ctx->queries, &querynum);
if(!q) {
return NULL;
@@ -280,7 +281,7 @@ context_lookup_new_query(struct ub_ctx* ctx, uint8_t* p, uint32_t len)
}
uint8_t*
-context_serialize_answer(struct ctx_query* q, int err, ldns_buffer* pkt,
+context_serialize_answer(struct ctx_query* q, int err, sldns_buffer* pkt,
uint32_t* len)
{
/* answer format
@@ -293,22 +294,22 @@ context_serialize_answer(struct ctx_query* q, int err, ldns_buffer* pkt,
* o the remainder is the answer msg from resolver lookup.
* remainder can be length 0.
*/
- size_t pkt_len = pkt?ldns_buffer_remaining(pkt):0;
+ size_t pkt_len = pkt?sldns_buffer_remaining(pkt):0;
size_t wlen = (pkt&&q->res->why_bogus)?strlen(q->res->why_bogus)+1:0;
uint8_t* p;
*len = sizeof(uint32_t)*5 + pkt_len + wlen;
p = (uint8_t*)malloc(*len);
if(!p) return NULL;
- ldns_write_uint32(p, UB_LIBCMD_ANSWER);
- ldns_write_uint32(p+sizeof(uint32_t), (uint32_t)q->querynum);
- ldns_write_uint32(p+2*sizeof(uint32_t), (uint32_t)err);
- ldns_write_uint32(p+3*sizeof(uint32_t), (uint32_t)q->msg_security);
- ldns_write_uint32(p+4*sizeof(uint32_t), (uint32_t)wlen);
+ sldns_write_uint32(p, UB_LIBCMD_ANSWER);
+ sldns_write_uint32(p+sizeof(uint32_t), (uint32_t)q->querynum);
+ sldns_write_uint32(p+2*sizeof(uint32_t), (uint32_t)err);
+ sldns_write_uint32(p+3*sizeof(uint32_t), (uint32_t)q->msg_security);
+ sldns_write_uint32(p+4*sizeof(uint32_t), (uint32_t)wlen);
if(wlen > 0)
memmove(p+5*sizeof(uint32_t), q->res->why_bogus, wlen);
if(pkt_len > 0)
memmove(p+5*sizeof(uint32_t)+wlen,
- ldns_buffer_begin(pkt), pkt_len);
+ sldns_buffer_begin(pkt), pkt_len);
return p;
}
@@ -320,13 +321,13 @@ context_deserialize_answer(struct ub_ctx* ctx,
int id;
size_t wlen;
if(len < 5*sizeof(uint32_t)) return NULL;
- log_assert( ldns_read_uint32(p) == UB_LIBCMD_ANSWER);
- id = (int)ldns_read_uint32(p+sizeof(uint32_t));
+ log_assert( sldns_read_uint32(p) == UB_LIBCMD_ANSWER);
+ id = (int)sldns_read_uint32(p+sizeof(uint32_t));
q = (struct ctx_query*)rbtree_search(&ctx->queries, &id);
if(!q) return NULL;
- *err = (int)ldns_read_uint32(p+2*sizeof(uint32_t));
- q->msg_security = ldns_read_uint32(p+3*sizeof(uint32_t));
- wlen = (size_t)ldns_read_uint32(p+4*sizeof(uint32_t));
+ *err = (int)sldns_read_uint32(p+2*sizeof(uint32_t));
+ q->msg_security = sldns_read_uint32(p+3*sizeof(uint32_t));
+ wlen = (size_t)sldns_read_uint32(p+4*sizeof(uint32_t));
if(len > 5*sizeof(uint32_t) && wlen > 0) {
if(len >= 5*sizeof(uint32_t)+wlen)
q->res->why_bogus = (char*)memdup(
@@ -362,8 +363,8 @@ context_serialize_cancel(struct ctx_query* q, uint32_t* len)
uint8_t* p = (uint8_t*)malloc(2*sizeof(uint32_t));
if(!p) return NULL;
*len = 2*sizeof(uint32_t);
- ldns_write_uint32(p, UB_LIBCMD_CANCEL);
- ldns_write_uint32(p+sizeof(uint32_t), (uint32_t)q->querynum);
+ sldns_write_uint32(p, UB_LIBCMD_CANCEL);
+ sldns_write_uint32(p+sizeof(uint32_t), (uint32_t)q->querynum);
return p;
}
@@ -373,8 +374,8 @@ struct ctx_query* context_deserialize_cancel(struct ub_ctx* ctx,
struct ctx_query* q;
int id;
if(len != 2*sizeof(uint32_t)) return NULL;
- log_assert( ldns_read_uint32(p) == UB_LIBCMD_CANCEL);
- id = (int)ldns_read_uint32(p+sizeof(uint32_t));
+ log_assert( sldns_read_uint32(p) == UB_LIBCMD_CANCEL);
+ id = (int)sldns_read_uint32(p+sizeof(uint32_t));
q = (struct ctx_query*)rbtree_search(&ctx->queries, &id);
return q;
}
@@ -386,7 +387,7 @@ context_serialize_quit(uint32_t* len)
if(!p)
return NULL;
*len = sizeof(uint32_t);
- ldns_write_uint32(p, UB_LIBCMD_QUIT);
+ sldns_write_uint32(p, UB_LIBCMD_QUIT);
return p;
}
@@ -395,6 +396,6 @@ enum ub_ctx_cmd context_serial_getcmd(uint8_t* p, uint32_t len)
uint32_t v;
if((size_t)len < sizeof(v))
return UB_LIBCMD_QUIT;
- v = ldns_read_uint32(p);
+ v = sldns_read_uint32(p);
return v;
}
diff --git a/contrib/unbound/libunbound/context.h b/contrib/unbound/libunbound/context.h
index 743178b..31ca09c 100644
--- a/contrib/unbound/libunbound/context.h
+++ b/contrib/unbound/libunbound/context.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -48,6 +48,8 @@
#include "util/data/packed_rrset.h"
struct libworker;
struct tube;
+struct sldns_buffer;
+struct event_base;
/**
* The context structure
@@ -111,6 +113,11 @@ struct ub_ctx {
/** random state used to seed new random state structures */
struct ub_randstate* seed_rnd;
+ /** event base for event oriented interface */
+ struct event_base* event_base;
+ /** libworker for event based interface */
+ struct libworker* event_worker;
+
/** next query number (to try) to use */
int next_querynum;
/** number of async queries outstanding */
@@ -234,8 +241,8 @@ void context_query_delete(struct ctx_query* q);
* @param cbarg: user arg for async queries.
* @return new ctx_query or NULL for malloc failure.
*/
-struct ctx_query* context_new(struct ub_ctx* ctx, const char* name,
- int rrtype, int rrclass, ub_callback_t cb, void* cbarg);
+struct ctx_query* context_new(struct ub_ctx* ctx, const char* name, int rrtype,
+ int rrclass, ub_callback_t cb, void* cbarg);
/**
* Get a new alloc. Creates a new one or uses a cached one.
@@ -275,7 +282,7 @@ uint8_t* context_serialize_new_query(struct ctx_query* q, uint32_t* len);
* @return: an alloc, or NULL on mem error.
*/
uint8_t* context_serialize_answer(struct ctx_query* q, int err,
- ldns_buffer* pkt, uint32_t* len);
+ struct sldns_buffer* pkt, uint32_t* len);
/**
* Serialize a query cancellation. Serializes query async id
diff --git a/contrib/unbound/libunbound/libunbound.c b/contrib/unbound/libunbound/libunbound.c
index 7efd4cb..78d3196 100644
--- a/contrib/unbound/libunbound/libunbound.c
+++ b/contrib/unbound/libunbound/libunbound.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -43,6 +43,7 @@
/* include the public api first, it should be able to stand alone */
#include "libunbound/unbound.h"
+#include "libunbound/unbound-event.h"
#include "config.h"
#include <ctype.h>
#include "libunbound/context.h"
@@ -60,14 +61,18 @@
#include "services/localzone.h"
#include "services/cache/infra.h"
#include "services/cache/rrset.h"
+#include "ldns/sbuffer.h"
+#ifdef HAVE_PTHREAD
+#include <signal.h>
+#endif
#if defined(UB_ON_WINDOWS) && defined (HAVE_WINDOWS_H)
#include <windows.h>
#include <iphlpapi.h>
#endif /* UB_ON_WINDOWS */
-struct ub_ctx*
-ub_ctx_create(void)
+/** create context functionality, but no pipes */
+static struct ub_ctx* ub_ctx_create_nopipe(void)
{
struct ub_ctx* ctx;
unsigned int seed;
@@ -102,28 +107,11 @@ ub_ctx_create(void)
return NULL;
}
seed = 0;
- if((ctx->qq_pipe = tube_create()) == NULL) {
- int e = errno;
- ub_randfree(ctx->seed_rnd);
- free(ctx);
- errno = e;
- return NULL;
- }
- if((ctx->rr_pipe = tube_create()) == NULL) {
- int e = errno;
- tube_delete(ctx->qq_pipe);
- ub_randfree(ctx->seed_rnd);
- free(ctx);
- errno = e;
- return NULL;
- }
lock_basic_init(&ctx->qqpipe_lock);
lock_basic_init(&ctx->rrpipe_lock);
lock_basic_init(&ctx->cfglock);
ctx->env = (struct module_env*)calloc(1, sizeof(*ctx->env));
if(!ctx->env) {
- tube_delete(ctx->qq_pipe);
- tube_delete(ctx->rr_pipe);
ub_randfree(ctx->seed_rnd);
free(ctx);
errno = ENOMEM;
@@ -131,8 +119,6 @@ ub_ctx_create(void)
}
ctx->env->cfg = config_create_forlib();
if(!ctx->env->cfg) {
- tube_delete(ctx->qq_pipe);
- tube_delete(ctx->rr_pipe);
free(ctx->env);
ub_randfree(ctx->seed_rnd);
free(ctx);
@@ -147,6 +133,50 @@ ub_ctx_create(void)
return ctx;
}
+struct ub_ctx*
+ub_ctx_create(void)
+{
+ struct ub_ctx* ctx = ub_ctx_create_nopipe();
+ if(!ctx)
+ return NULL;
+ if((ctx->qq_pipe = tube_create()) == NULL) {
+ int e = errno;
+ ub_randfree(ctx->seed_rnd);
+ config_delete(ctx->env->cfg);
+ modstack_desetup(&ctx->mods, ctx->env);
+ free(ctx->env);
+ free(ctx);
+ errno = e;
+ return NULL;
+ }
+ if((ctx->rr_pipe = tube_create()) == NULL) {
+ int e = errno;
+ tube_delete(ctx->qq_pipe);
+ ub_randfree(ctx->seed_rnd);
+ config_delete(ctx->env->cfg);
+ modstack_desetup(&ctx->mods, ctx->env);
+ free(ctx->env);
+ free(ctx);
+ errno = e;
+ return NULL;
+ }
+ return ctx;
+}
+
+struct ub_ctx*
+ub_ctx_create_event(struct event_base* eb)
+{
+ struct ub_ctx* ctx = ub_ctx_create_nopipe();
+ if(!ctx)
+ return NULL;
+ /* no pipes, but we have the locks to make sure everything works */
+ ctx->created_bg = 0;
+ ctx->dothread = 1; /* the processing is in the same process,
+ makes ub_cancel and ub_ctx_delete do the right thing */
+ ctx->event_base = eb;
+ return ctx;
+}
+
/** delete q */
static void
delq(rbnode_t* n, void* ATTR_UNUSED(arg))
@@ -155,11 +185,9 @@ delq(rbnode_t* n, void* ATTR_UNUSED(arg))
context_query_delete(q);
}
-void
-ub_ctx_delete(struct ub_ctx* ctx)
+/** stop the bg thread */
+static void ub_stop_bg(struct ub_ctx* ctx)
{
- struct alloc_cache* a, *na;
- if(!ctx) return;
/* stop the bg thread */
lock_basic_lock(&ctx->cfglock);
if(ctx->created_bg) {
@@ -195,7 +223,29 @@ ub_ctx_delete(struct ub_ctx* ctx)
else {
lock_basic_unlock(&ctx->cfglock);
}
+}
+
+void
+ub_ctx_delete(struct ub_ctx* ctx)
+{
+ struct alloc_cache* a, *na;
+ int do_stop = 1;
+ if(!ctx) return;
+ /* see if bg thread is created and if threads have been killed */
+ /* no locks, because those may be held by terminated threads */
+ /* for processes the read pipe is closed and we see that on read */
+#ifdef HAVE_PTHREAD
+ if(ctx->created_bg && ctx->dothread) {
+ if(pthread_kill(ctx->bg_tid, 0) == ESRCH) {
+ /* thread has been killed */
+ do_stop = 0;
+ }
+ }
+#endif /* HAVE_PTHREAD */
+ if(do_stop)
+ ub_stop_bg(ctx);
+ libworker_delete_event(ctx->event_worker);
modstack_desetup(&ctx->mods, ctx->env);
a = ctx->alloc_list;
@@ -419,21 +469,21 @@ process_answer_detail(struct ub_ctx* ctx, uint8_t* msg, uint32_t len,
ub_resolve_free(q->res);
} else {
/* parse the message, extract rcode, fill result */
- ldns_buffer* buf = ldns_buffer_new(q->msg_len);
+ sldns_buffer* buf = sldns_buffer_new(q->msg_len);
struct regional* region = regional_create();
*res = q->res;
(*res)->rcode = LDNS_RCODE_SERVFAIL;
if(region && buf) {
- ldns_buffer_clear(buf);
- ldns_buffer_write(buf, q->msg, q->msg_len);
- ldns_buffer_flip(buf);
+ sldns_buffer_clear(buf);
+ sldns_buffer_write(buf, q->msg, q->msg_len);
+ sldns_buffer_flip(buf);
libworker_enter_result(*res, buf, region,
q->msg_security);
}
(*res)->answer_packet = q->msg;
(*res)->answer_len = (int)q->msg_len;
q->msg = NULL;
- ldns_buffer_free(buf);
+ sldns_buffer_free(buf);
regional_destroy(region);
}
q->res = NULL;
@@ -591,6 +641,45 @@ ub_resolve(struct ub_ctx* ctx, const char* name, int rrtype,
}
int
+ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype,
+ int rrclass, void* mydata, ub_event_callback_t callback, int* async_id)
+{
+ struct ctx_query* q;
+ int r;
+
+ if(async_id)
+ *async_id = 0;
+ lock_basic_lock(&ctx->cfglock);
+ if(!ctx->finalized) {
+ int r = context_finalize(ctx);
+ if(r) {
+ lock_basic_unlock(&ctx->cfglock);
+ return r;
+ }
+ }
+ lock_basic_unlock(&ctx->cfglock);
+ if(!ctx->event_worker) {
+ ctx->event_worker = libworker_create_event(ctx,
+ ctx->event_base);
+ if(!ctx->event_worker) {
+ return UB_INITFAIL;
+ }
+ }
+
+ /* create new ctx_query and attempt to add to the list */
+ q = context_new(ctx, name, rrtype, rrclass, (ub_callback_t)callback,
+ mydata);
+ if(!q)
+ return UB_NOMEM;
+
+ /* attach to mesh */
+ if((r=libworker_attach_mesh(ctx, q, async_id)) != 0)
+ return r;
+ return UB_NOERROR;
+}
+
+
+int
ub_resolve_async(struct ub_ctx* ctx, const char* name, int rrtype,
int rrclass, void* mydata, ub_callback_t callback, int* async_id)
{
@@ -1016,7 +1105,8 @@ int ub_ctx_print_local_zones(struct ub_ctx* ctx)
}
/* Add a new zone */
-int ub_ctx_zone_add(struct ub_ctx* ctx, char *zone_name, char *zone_type)
+int ub_ctx_zone_add(struct ub_ctx* ctx, const char *zone_name,
+ const char *zone_type)
{
enum localzone_type t;
struct local_zone* z;
@@ -1035,28 +1125,28 @@ int ub_ctx_zone_add(struct ub_ctx* ctx, char *zone_name, char *zone_type)
return UB_SYNTAX;
}
- lock_quick_lock(&ctx->local_zones->lock);
+ lock_rw_wrlock(&ctx->local_zones->lock);
if((z=local_zones_find(ctx->local_zones, nm, nmlen, nmlabs,
LDNS_RR_CLASS_IN))) {
/* already present in tree */
lock_rw_wrlock(&z->lock);
z->type = t; /* update type anyway */
lock_rw_unlock(&z->lock);
- lock_quick_unlock(&ctx->local_zones->lock);
+ lock_rw_unlock(&ctx->local_zones->lock);
free(nm);
return UB_NOERROR;
}
if(!local_zones_add_zone(ctx->local_zones, nm, nmlen, nmlabs,
LDNS_RR_CLASS_IN, t)) {
- lock_quick_unlock(&ctx->local_zones->lock);
+ lock_rw_unlock(&ctx->local_zones->lock);
return UB_NOMEM;
}
- lock_quick_unlock(&ctx->local_zones->lock);
+ lock_rw_unlock(&ctx->local_zones->lock);
return UB_NOERROR;
}
/* Remove zone */
-int ub_ctx_zone_remove(struct ub_ctx* ctx, char *zone_name)
+int ub_ctx_zone_remove(struct ub_ctx* ctx, const char *zone_name)
{
struct local_zone* z;
uint8_t* nm;
@@ -1070,37 +1160,29 @@ int ub_ctx_zone_remove(struct ub_ctx* ctx, char *zone_name)
return UB_SYNTAX;
}
- lock_quick_lock(&ctx->local_zones->lock);
+ lock_rw_wrlock(&ctx->local_zones->lock);
if((z=local_zones_find(ctx->local_zones, nm, nmlen, nmlabs,
LDNS_RR_CLASS_IN))) {
/* present in tree */
local_zones_del_zone(ctx->local_zones, z);
}
- lock_quick_unlock(&ctx->local_zones->lock);
+ lock_rw_unlock(&ctx->local_zones->lock);
free(nm);
return UB_NOERROR;
}
/* Add new RR data */
-int ub_ctx_data_add(struct ub_ctx* ctx, char *data)
+int ub_ctx_data_add(struct ub_ctx* ctx, const char *data)
{
- ldns_buffer* buf;
int res = ub_ctx_finalize(ctx);
if (res) return res;
- lock_basic_lock(&ctx->cfglock);
- buf = ldns_buffer_new(ctx->env->cfg->msg_buffer_size);
- lock_basic_unlock(&ctx->cfglock);
- if(!buf) return UB_NOMEM;
-
- res = local_zones_add_RR(ctx->local_zones, data, buf);
-
- ldns_buffer_free(buf);
+ res = local_zones_add_RR(ctx->local_zones, data);
return (!res) ? UB_NOMEM : UB_NOERROR;
}
/* Remove RR data */
-int ub_ctx_data_remove(struct ub_ctx* ctx, char *data)
+int ub_ctx_data_remove(struct ub_ctx* ctx, const char *data)
{
uint8_t* nm;
int nmlabs;
@@ -1122,3 +1204,24 @@ const char* ub_version(void)
{
return PACKAGE_VERSION;
}
+
+int
+ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base) {
+ if (!ctx || !ctx->event_base || !base) {
+ return UB_INITFAIL;
+ }
+ if (ctx->event_base == base) {
+ /* already set */
+ return UB_NOERROR;
+ }
+
+ lock_basic_lock(&ctx->cfglock);
+ /* destroy the current worker - safe to pass in NULL */
+ libworker_delete_event(ctx->event_worker);
+ ctx->event_worker = NULL;
+ ctx->event_base = base;
+ ctx->created_bg = 0;
+ ctx->dothread = 1;
+ lock_basic_unlock(&ctx->cfglock);
+ return UB_NOERROR;
+}
diff --git a/contrib/unbound/libunbound/libworker.c b/contrib/unbound/libunbound/libworker.c
index ffc4716..fa54180 100644
--- a/contrib/unbound/libunbound/libworker.c
+++ b/contrib/unbound/libunbound/libworker.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -42,8 +42,6 @@
* returns from the procedure when done.
*/
#include "config.h"
-#include <ldns/dname.h>
-#include <ldns/wire2host.h>
#ifdef HAVE_SSL
#include <openssl/ssl.h>
#endif
@@ -51,6 +49,7 @@
#include "libunbound/context.h"
#include "libunbound/unbound.h"
#include "libunbound/worker.h"
+#include "libunbound/unbound-event.h"
#include "services/outside_network.h"
#include "services/mesh.h"
#include "services/localzone.h"
@@ -71,21 +70,22 @@
#include "util/tube.h"
#include "iterator/iter_fwd.h"
#include "iterator/iter_hints.h"
+#include "ldns/sbuffer.h"
+#include "ldns/str2wire.h"
/** handle new query command for bg worker */
static void handle_newq(struct libworker* w, uint8_t* buf, uint32_t len);
-/** delete libworker struct */
+/** delete libworker env */
static void
-libworker_delete(struct libworker* w)
+libworker_delete_env(struct libworker* w)
{
- if(!w) return;
if(w->env) {
outside_network_quit_prepare(w->back);
mesh_delete(w->env->mesh);
context_release_alloc(w->ctx, w->env->alloc,
!w->is_bg || w->is_bg_thread);
- ldns_buffer_free(w->env->scratch_buffer);
+ sldns_buffer_free(w->env->scratch_buffer);
regional_destroy(w->env->scratch);
forwards_delete(w->env->fwds);
hints_delete(w->env->hints);
@@ -96,13 +96,30 @@ libworker_delete(struct libworker* w)
SSL_CTX_free(w->sslctx);
#endif
outside_network_delete(w->back);
+}
+
+/** delete libworker struct */
+static void
+libworker_delete(struct libworker* w)
+{
+ if(!w) return;
+ libworker_delete_env(w);
comm_base_delete(w->base);
free(w);
}
+void
+libworker_delete_event(struct libworker* w)
+{
+ if(!w) return;
+ libworker_delete_env(w);
+ comm_base_delete_no_base(w->base);
+ free(w);
+}
+
/** setup fresh libworker struct */
static struct libworker*
-libworker_setup(struct ub_ctx* ctx, int is_bg)
+libworker_setup(struct ub_ctx* ctx, int is_bg, struct event_base* eb)
{
unsigned int seed;
struct libworker* w = (struct libworker*)calloc(1, sizeof(*w));
@@ -129,7 +146,7 @@ libworker_setup(struct ub_ctx* ctx, int is_bg)
lock_basic_lock(&ctx->cfglock);
}
w->env->scratch = regional_create_custom(cfg->msg_buffer_size);
- w->env->scratch_buffer = ldns_buffer_new(cfg->msg_buffer_size);
+ w->env->scratch_buffer = sldns_buffer_new(cfg->msg_buffer_size);
w->env->fwds = forwards_create();
if(w->env->fwds && !forwards_apply_cfg(w->env->fwds, cfg)) {
forwards_delete(w->env->fwds);
@@ -190,7 +207,9 @@ libworker_setup(struct ub_ctx* ctx, int is_bg)
}
seed = 0;
- w->base = comm_base_create(0);
+ if(eb)
+ w->base = comm_base_create_event(eb);
+ else w->base = comm_base_create(0);
if(!w->base) {
libworker_delete(w);
return NULL;
@@ -200,7 +219,11 @@ libworker_setup(struct ub_ctx* ctx, int is_bg)
}
numports = cfg_condense_ports(cfg, &ports);
if(numports == 0) {
+ int locked = !w->is_bg || w->is_bg_thread;
libworker_delete(w);
+ if(locked) {
+ lock_basic_unlock(&ctx->cfglock);
+ }
return NULL;
}
w->back = outside_network_create(w->base, cfg->msg_buffer_size,
@@ -209,7 +232,8 @@ libworker_setup(struct ub_ctx* ctx, int is_bg)
cfg->do_tcp?cfg->outgoing_num_tcp:0,
w->env->infra_cache, w->env->rnd, cfg->use_caps_bits_for_id,
ports, numports, cfg->unwanted_threshold,
- &libworker_alloc_cleanup, w, cfg->do_udp, w->sslctx);
+ &libworker_alloc_cleanup, w, cfg->do_udp, w->sslctx,
+ cfg->delay_close);
if(!w->is_bg || w->is_bg_thread) {
lock_basic_unlock(&ctx->cfglock);
}
@@ -232,6 +256,12 @@ libworker_setup(struct ub_ctx* ctx, int is_bg)
return w;
}
+struct libworker* libworker_create_event(struct ub_ctx* ctx,
+ struct event_base* eb)
+{
+ return libworker_setup(ctx, 0, eb);
+}
+
/** handle cancel command for bg worker */
static void
handle_cancel(struct libworker* w, uint8_t* buf, uint32_t len)
@@ -348,7 +378,7 @@ int libworker_bg(struct ub_ctx* ctx)
lock_basic_lock(&ctx->cfglock);
if(ctx->dothread) {
lock_basic_unlock(&ctx->cfglock);
- w = libworker_setup(ctx, 1);
+ w = libworker_setup(ctx, 1, NULL);
if(!w) return UB_NOMEM;
w->is_bg_thread = 1;
#ifdef ENABLE_LOCK_CHECKS
@@ -363,7 +393,7 @@ int libworker_bg(struct ub_ctx* ctx)
#else /* HAVE_FORK */
switch((ctx->bg_pid=fork())) {
case 0:
- w = libworker_setup(ctx, 1);
+ w = libworker_setup(ctx, 1, NULL);
if(!w) fatal_exit("out of memory");
/* close non-used parts of the pipes */
tube_close_write(ctx->qq_pipe);
@@ -374,6 +404,11 @@ int libworker_bg(struct ub_ctx* ctx)
case -1:
return UB_FORKFAIL;
default:
+ /* close non-used parts, so that the worker
+ * bgprocess gets 'pipe closed' when the
+ * main process exits */
+ tube_close_read(ctx->qq_pipe);
+ tube_close_write(ctx->rr_pipe);
break;
}
#endif /* HAVE_FORK */
@@ -383,7 +418,7 @@ int libworker_bg(struct ub_ctx* ctx)
/** get msg reply struct (in temp region) */
static struct reply_info*
-parse_reply(ldns_buffer* pkt, struct regional* region, struct query_info* qi)
+parse_reply(sldns_buffer* pkt, struct regional* region, struct query_info* qi)
{
struct reply_info* rep;
struct msg_parse* msg;
@@ -391,7 +426,7 @@ parse_reply(ldns_buffer* pkt, struct regional* region, struct query_info* qi)
return NULL;
}
memset(msg, 0, sizeof(*msg));
- ldns_buffer_set_position(pkt, 0);
+ sldns_buffer_set_position(pkt, 0);
if(parse_packet(pkt, msg, region) != 0)
return 0;
if(!parse_create_msg(pkt, msg, NULL, qi, &rep, region)) {
@@ -467,7 +502,7 @@ fill_res(struct ub_result* res, struct ub_packed_rrset_key* answer,
/** fill result from parsed message, on error fills servfail */
void
-libworker_enter_result(struct ub_result* res, ldns_buffer* buf,
+libworker_enter_result(struct ub_result* res, sldns_buffer* buf,
struct regional* temp, enum sec_status msg_security)
{
struct query_info rq;
@@ -495,7 +530,7 @@ libworker_enter_result(struct ub_result* res, ldns_buffer* buf,
/** fillup fg results */
static void
-libworker_fillup_fg(struct ctx_query* q, int rcode, ldns_buffer* buf,
+libworker_fillup_fg(struct ctx_query* q, int rcode, sldns_buffer* buf,
enum sec_status s, char* why_bogus)
{
if(why_bogus)
@@ -508,8 +543,8 @@ libworker_fillup_fg(struct ctx_query* q, int rcode, ldns_buffer* buf,
q->res->rcode = LDNS_RCODE_SERVFAIL;
q->msg_security = 0;
- q->msg = memdup(ldns_buffer_begin(buf), ldns_buffer_limit(buf));
- q->msg_len = ldns_buffer_limit(buf);
+ q->msg = memdup(sldns_buffer_begin(buf), sldns_buffer_limit(buf));
+ q->msg_len = sldns_buffer_limit(buf);
if(!q->msg) {
return; /* the error is in the rcode */
}
@@ -520,7 +555,7 @@ libworker_fillup_fg(struct ctx_query* q, int rcode, ldns_buffer* buf,
}
void
-libworker_fg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s,
+libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf, enum sec_status s,
char* why_bogus)
{
struct ctx_query* q = (struct ctx_query*)arg;
@@ -535,37 +570,26 @@ static int
setup_qinfo_edns(struct libworker* w, struct ctx_query* q,
struct query_info* qinfo, struct edns_data* edns)
{
- ldns_rdf* rdf;
qinfo->qtype = (uint16_t)q->res->qtype;
qinfo->qclass = (uint16_t)q->res->qclass;
- rdf = ldns_dname_new_frm_str(q->res->qname);
- if(!rdf) {
+ qinfo->qname = sldns_str2wire_dname(q->res->qname, &qinfo->qname_len);
+ if(!qinfo->qname) {
return 0;
}
-#ifdef UNBOUND_ALLOC_LITE
- qinfo->qname = memdup(ldns_rdf_data(rdf), ldns_rdf_size(rdf));
- qinfo->qname_len = ldns_rdf_size(rdf);
- ldns_rdf_deep_free(rdf);
- rdf = 0;
-#else
- qinfo->qname = ldns_rdf_data(rdf);
- qinfo->qname_len = ldns_rdf_size(rdf);
-#endif
edns->edns_present = 1;
edns->ext_rcode = 0;
edns->edns_version = 0;
edns->bits = EDNS_DO;
- if(ldns_buffer_capacity(w->back->udp_buff) < 65535)
- edns->udp_size = (uint16_t)ldns_buffer_capacity(
+ if(sldns_buffer_capacity(w->back->udp_buff) < 65535)
+ edns->udp_size = (uint16_t)sldns_buffer_capacity(
w->back->udp_buff);
else edns->udp_size = 65535;
- ldns_rdf_free(rdf);
return 1;
}
int libworker_fg(struct ub_ctx* ctx, struct ctx_query* q)
{
- struct libworker* w = libworker_setup(ctx, 0);
+ struct libworker* w = libworker_setup(ctx, 0, NULL);
uint16_t qflags, qid;
struct query_info qinfo;
struct edns_data edns;
@@ -579,8 +603,8 @@ int libworker_fg(struct ub_ctx* ctx, struct ctx_query* q)
qflags = BIT_RD;
q->w = w;
/* see if there is a fixed answer */
- ldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
- ldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
+ sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
+ sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
if(local_zones_answer(ctx->local_zones, &qinfo, &edns,
w->back->udp_buff, w->env->scratch)) {
regional_free_all(w->env->scratch);
@@ -605,9 +629,75 @@ int libworker_fg(struct ub_ctx* ctx, struct ctx_query* q)
return UB_NOERROR;
}
+void
+libworker_event_done_cb(void* arg, int rcode, sldns_buffer* buf,
+ enum sec_status s, char* why_bogus)
+{
+ struct ctx_query* q = (struct ctx_query*)arg;
+ ub_event_callback_t cb = (ub_event_callback_t)q->cb;
+ void* cb_arg = q->cb_arg;
+ int cancelled = q->cancelled;
+
+ /* delete it now */
+ struct ub_ctx* ctx = q->w->ctx;
+ lock_basic_lock(&ctx->cfglock);
+ (void)rbtree_delete(&ctx->queries, q->node.key);
+ ctx->num_async--;
+ context_query_delete(q);
+ lock_basic_unlock(&ctx->cfglock);
+
+ if(!cancelled) {
+ /* call callback */
+ int sec = 0;
+ if(s == sec_status_bogus)
+ sec = 1;
+ else if(s == sec_status_secure)
+ sec = 2;
+ (*cb)(cb_arg, rcode, (void*)sldns_buffer_begin(buf),
+ (int)sldns_buffer_limit(buf), sec, why_bogus);
+ }
+}
+
+int libworker_attach_mesh(struct ub_ctx* ctx, struct ctx_query* q,
+ int* async_id)
+{
+ struct libworker* w = ctx->event_worker;
+ uint16_t qflags, qid;
+ struct query_info qinfo;
+ struct edns_data edns;
+ if(!w)
+ return UB_INITFAIL;
+ if(!setup_qinfo_edns(w, q, &qinfo, &edns))
+ return UB_SYNTAX;
+ qid = 0;
+ qflags = BIT_RD;
+ q->w = w;
+ /* see if there is a fixed answer */
+ sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
+ sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
+ if(local_zones_answer(ctx->local_zones, &qinfo, &edns,
+ w->back->udp_buff, w->env->scratch)) {
+ regional_free_all(w->env->scratch);
+ free(qinfo.qname);
+ libworker_event_done_cb(q, LDNS_RCODE_NOERROR,
+ w->back->udp_buff, sec_status_insecure, NULL);
+ return UB_NOERROR;
+ }
+ /* process new query */
+ if(async_id)
+ *async_id = q->querynum;
+ if(!mesh_new_callback(w->env->mesh, &qinfo, qflags, &edns,
+ w->back->udp_buff, qid, libworker_event_done_cb, q)) {
+ free(qinfo.qname);
+ return UB_NOMEM;
+ }
+ free(qinfo.qname);
+ return UB_NOERROR;
+}
+
/** add result to the bg worker result queue */
static void
-add_bg_result(struct libworker* w, struct ctx_query* q, ldns_buffer* pkt,
+add_bg_result(struct libworker* w, struct ctx_query* q, sldns_buffer* pkt,
int err, char* reason)
{
uint8_t* msg = NULL;
@@ -619,8 +709,8 @@ add_bg_result(struct libworker* w, struct ctx_query* q, ldns_buffer* pkt,
if(reason)
q->res->why_bogus = strdup(reason);
if(pkt) {
- q->msg_len = ldns_buffer_remaining(pkt);
- q->msg = memdup(ldns_buffer_begin(pkt), q->msg_len);
+ q->msg_len = sldns_buffer_remaining(pkt);
+ q->msg = memdup(sldns_buffer_begin(pkt), q->msg_len);
if(!q->msg)
msg = context_serialize_answer(q, UB_NOMEM,
NULL, &len);
@@ -648,7 +738,7 @@ add_bg_result(struct libworker* w, struct ctx_query* q, ldns_buffer* pkt,
}
void
-libworker_bg_done_cb(void* arg, int rcode, ldns_buffer* buf, enum sec_status s,
+libworker_bg_done_cb(void* arg, int rcode, sldns_buffer* buf, enum sec_status s,
char* why_bogus)
{
struct ctx_query* q = (struct ctx_query*)arg;
@@ -703,8 +793,8 @@ handle_newq(struct libworker* w, uint8_t* buf, uint32_t len)
qid = 0;
qflags = BIT_RD;
/* see if there is a fixed answer */
- ldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
- ldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
+ sldns_buffer_write_u16_at(w->back->udp_buff, 0, qid);
+ sldns_buffer_write_u16_at(w->back->udp_buff, 2, qflags);
if(local_zones_answer(w->ctx->local_zones, &qinfo, &edns,
w->back->udp_buff, w->env->scratch)) {
regional_free_all(w->env->scratch);
@@ -766,10 +856,10 @@ libworker_handle_reply(struct comm_point* c, void* arg, int error,
return 0;
}
/* sanity check. */
- if(!LDNS_QR_WIRE(ldns_buffer_begin(c->buffer))
- || LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) !=
+ if(!LDNS_QR_WIRE(sldns_buffer_begin(c->buffer))
+ || LDNS_OPCODE_WIRE(sldns_buffer_begin(c->buffer)) !=
LDNS_PACKET_QUERY
- || LDNS_QDCOUNT(ldns_buffer_begin(c->buffer)) > 1) {
+ || LDNS_QDCOUNT(sldns_buffer_begin(c->buffer)) > 1) {
/* error becomes timeout for the module as if this reply
* never arrived. */
mesh_report_reply(lw->env->mesh, &e, reply_info,
@@ -792,10 +882,10 @@ libworker_handle_service_reply(struct comm_point* c, void* arg, int error,
return 0;
}
/* sanity check. */
- if(!LDNS_QR_WIRE(ldns_buffer_begin(c->buffer))
- || LDNS_OPCODE_WIRE(ldns_buffer_begin(c->buffer)) !=
+ if(!LDNS_QR_WIRE(sldns_buffer_begin(c->buffer))
+ || LDNS_OPCODE_WIRE(sldns_buffer_begin(c->buffer)) !=
LDNS_PACKET_QUERY
- || LDNS_QDCOUNT(ldns_buffer_begin(c->buffer)) > 1) {
+ || LDNS_QDCOUNT(sldns_buffer_begin(c->buffer)) > 1) {
/* error becomes timeout for the module as if this reply
* never arrived. */
mesh_report_reply(lw->env->mesh, e, reply_info,
diff --git a/contrib/unbound/libunbound/libworker.h b/contrib/unbound/libunbound/libworker.h
index 86b187a..0103b5d 100644
--- a/contrib/unbound/libunbound/libworker.h
+++ b/contrib/unbound/libunbound/libworker.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -57,6 +57,8 @@ struct comm_point;
struct comm_reply;
struct regional;
struct tube;
+struct sldns_buffer;
+struct event_base;
/**
* The library-worker status structure
@@ -106,6 +108,31 @@ int libworker_bg(struct ub_ctx* ctx);
*/
int libworker_fg(struct ub_ctx* ctx, struct ctx_query* q);
+/**
+ * create worker for event-based interface.
+ * @param ctx: context with config.
+ * @param eb: event base.
+ * @return new worker or NULL.
+ */
+struct libworker* libworker_create_event(struct ub_ctx* ctx,
+ struct event_base* eb);
+
+/**
+ * Attach context_query to mesh for callback in event-driven setup.
+ * @param ctx: context
+ * @param q: context query entry
+ * @param async_id: store query num if query takes long.
+ * @return 0 if finished OK, else error.
+ */
+int libworker_attach_mesh(struct ub_ctx* ctx, struct ctx_query* q,
+ int* async_id);
+
+/**
+ * delete worker for event-based interface. does not free the event_base.
+ * @param w: event-based worker to delete.
+ */
+void libworker_delete_event(struct libworker* w);
+
/** cleanup the cache to remove all rrset IDs from it, arg is libworker */
void libworker_alloc_cleanup(void* arg);
@@ -118,7 +145,7 @@ void libworker_alloc_cleanup(void* arg);
* On error, the res may contain a different status
* (out of memory is not secure, not bogus).
*/
-void libworker_enter_result(struct ub_result* res, ldns_buffer* buf,
+void libworker_enter_result(struct ub_result* res, struct sldns_buffer* buf,
struct regional* temp, enum sec_status msg_security);
#endif /* LIBUNBOUND_LIBWORKER_H */
diff --git a/contrib/unbound/libunbound/ubsyms.def b/contrib/unbound/libunbound/ubsyms.def
index 7e3fdd1..866c176 100644
--- a/contrib/unbound/libunbound/ubsyms.def
+++ b/contrib/unbound/libunbound/ubsyms.def
@@ -1,4 +1,5 @@
ub_ctx_create
+ub_ctx_create_event
ub_ctx_delete
ub_ctx_get_option
ub_ctx_set_option
@@ -18,6 +19,7 @@ ub_fd
ub_process
ub_resolve
ub_resolve_async
+ub_resolve_event
ub_cancel
ub_resolve_free
ub_strerror
@@ -27,3 +29,4 @@ ub_ctx_zone_remove
ub_ctx_data_add
ub_ctx_data_remove
ub_version
+ub_ctx_set_event
diff --git a/contrib/unbound/libunbound/unbound-event.h b/contrib/unbound/libunbound/unbound-event.h
new file mode 100644
index 0000000..b80de38
--- /dev/null
+++ b/contrib/unbound/libunbound/unbound-event.h
@@ -0,0 +1,135 @@
+/*
+ * unbound-event.h - unbound validating resolver public API with events
+ *
+ * Copyright (c) 2007, NLnet Labs. All rights reserved.
+ *
+ * This software is open source.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of the NLNET LABS nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * \file
+ *
+ * This file contains the unbound interface for use with libevent.
+ * You have to use the same libevent that unbound was compiled with,
+ * otherwise it wouldn't work, the event and event_base structures would
+ * be different. If unbound is compiled without libevent support then
+ * this header file is not supposed to be installed on the system.
+ *
+ * Use ub_ctx_create_event_base() to create an unbound context that uses
+ * the event base that you have made. Then, use the ub_resolve_event call
+ * to add DNS resolve queries to the context. Those then run when you
+ * call event_dispatch() on your event_base, and when they are done you
+ * get a function callback.
+ *
+ * This method does not fork another process or create a thread, the effort
+ * is done by the unbound state machines that are connected to the event_base.
+ */
+#ifndef _UB_UNBOUND_EVENT_H
+#define _UB_UNBOUND_EVENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ub_ctx;
+struct ub_result;
+struct event_base;
+
+typedef void (*ub_event_callback_t)(void*, int, void*, int, int, char*);
+
+/**
+ * Create a resolving and validation context.
+ * The information from /etc/resolv.conf and /etc/hosts is not utilised by
+ * default. Use ub_ctx_resolvconf and ub_ctx_hosts to read them.
+ * @param base: the event base that the caller has created. The unbound
+ * context uses this event base.
+ * @return a new context. default initialisation.
+ * returns NULL on error.
+ * You must use ub_resolve_event with this context.
+ * Do not call ub_ctx_async, ub_poll, ub_wait, ub_process, this is all done
+ * with the event_base. Setup the options you like with the other functions.
+ */
+struct ub_ctx* ub_ctx_create_event(struct event_base* base);
+
+/**
+ * Set a new event_base on a context created with ub_ctx_create_event.
+ * Any outbound queries will be canceled.
+ * @param ctx the ub_ctx to update. Must have been created with ub_ctx_create_event
+ * @param base the new event_base to attach to the ctx
+ * @return 0 if OK, else error
+ */
+int ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base);
+
+/**
+ * Perform resolution and validation of the target name.
+ * Asynchronous, after a while, the callback will be called with your
+ * data and the result. Uses the event_base user installed by creating the
+ * context with ub_ctx_create_event().
+ * @param ctx: context with event_base in it.
+ * The context is finalized, and can no longer accept all config changes.
+ * @param name: domain name in text format (a string).
+ * @param rrtype: type of RR in host order, 1 is A.
+ * @param rrclass: class of RR in host order, 1 is IN (for internet).
+ * @param mydata: this data is your own data (you can pass NULL),
+ * and is passed on to the callback function.
+ * @param callback: this is called on completion of the resolution.
+ * It is called as:
+ * void callback(void* mydata, int rcode, void* packet, int packet_len,
+ * int sec, char* why_bogus)
+ * with mydata: the same as passed here, you may pass NULL,
+ * with rcode: 0 on no error, nonzero for mostly SERVFAIL situations,
+ * this is a DNS rcode.
+ * with packet: a buffer with DNS wireformat packet with the answer.
+ * do not inspect if rcode != 0.
+ * do not write or free the packet buffer, it is used internally
+ * in unbound (for other callbacks that want the same data).
+ * with packet_len: length in bytes of the packet buffer.
+ * with sec: 0 if insecure, 1 if bogus, 2 if DNSSEC secure.
+ * with why_bogus: text string explaining why it is bogus (or NULL).
+ * These point to buffers inside unbound; do not deallocate the packet or
+ * error string.
+ *
+ * If an error happens during processing, your callback will be called
+ * with error set to a nonzero value (and result==NULL).
+ * For localdata (etc/hosts) the callback is called immediately, before
+ * resolve_event returns, async_id=0 is returned.
+ * @param async_id: if you pass a non-NULL value, an identifier number is
+ * returned for the query as it is in progress. It can be used to
+ * cancel the query.
+ * @return 0 if OK, else error.
+ */
+int ub_resolve_event(struct ub_ctx* ctx, const char* name, int rrtype,
+ int rrclass, void* mydata, ub_event_callback_t callback, int* async_id);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _UB_UNBOUND_H */
diff --git a/contrib/unbound/libunbound/unbound.h b/contrib/unbound/libunbound/unbound.h
index 1de9566..86bd3bf 100644
--- a/contrib/unbound/libunbound/unbound.h
+++ b/contrib/unbound/libunbound/unbound.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -78,6 +78,10 @@
* ... same as async for non-threaded
* ... the callbacks are called in the thread that calls process(ctx)
*
+ * Openssl needs to have locking in place, and the application must set
+ * it up, because a mere library cannot do this, use the calls
+ * CRYPTO_set_id_callback and CRYPTO_set_locking_callback.
+ *
* If no threading is compiled in, the above async example uses fork(2) to
* create a process to perform the work. The forked process exits when the
* calling process exits, or ctx_delete() is called.
@@ -97,6 +101,11 @@
extern "C" {
#endif
+/** the version of this header file */
+#define UNBOUND_VERSION_MAJOR @UNBOUND_VERSION_MAJOR@
+#define UNBOUND_VERSION_MINOR @UNBOUND_VERSION_MINOR@
+#define UNBOUND_VERSION_MICRO @UNBOUND_VERSION_MICRO@
+
/**
* The validation context is created to hold the resolver status,
* validation keys and a small cache (containing messages, rrsets,
@@ -520,7 +529,8 @@ int ub_ctx_print_local_zones(struct ub_ctx* ctx);
* @param zone_type: type of the zone (like for unbound.conf) in text.
* @return 0 if OK, else error.
*/
-int ub_ctx_zone_add(struct ub_ctx* ctx, char *zone_name, char *zone_type);
+int ub_ctx_zone_add(struct ub_ctx* ctx, const char *zone_name,
+ const char *zone_type);
/**
* Remove zone from local authority info of the library.
@@ -529,7 +539,7 @@ int ub_ctx_zone_add(struct ub_ctx* ctx, char *zone_name, char *zone_type);
* If it does not exist, nothing happens.
* @return 0 if OK, else error.
*/
-int ub_ctx_zone_remove(struct ub_ctx* ctx, char *zone_name);
+int ub_ctx_zone_remove(struct ub_ctx* ctx, const char *zone_name);
/**
* Add localdata to the library local authority info.
@@ -539,7 +549,7 @@ int ub_ctx_zone_remove(struct ub_ctx* ctx, char *zone_name);
* "www.example.com IN A 127.0.0.1"
* @return 0 if OK, else error.
*/
-int ub_ctx_data_add(struct ub_ctx* ctx, char *data);
+int ub_ctx_data_add(struct ub_ctx* ctx, const char *data);
/**
* Remove localdata from the library local authority info.
@@ -547,7 +557,7 @@ int ub_ctx_data_add(struct ub_ctx* ctx, char *data);
* @param data: the name to delete all data from, like "www.example.com".
* @return 0 if OK, else error.
*/
-int ub_ctx_data_remove(struct ub_ctx* ctx, char *data);
+int ub_ctx_data_remove(struct ub_ctx* ctx, const char *data);
/**
* Get a version string from the libunbound implementation.
diff --git a/contrib/unbound/libunbound/worker.h b/contrib/unbound/libunbound/worker.h
index bdcb033..d8354c6 100644
--- a/contrib/unbound/libunbound/worker.h
+++ b/contrib/unbound/libunbound/worker.h
@@ -42,6 +42,7 @@
#ifndef LIBUNBOUND_WORKER_H
#define LIBUNBOUND_WORKER_H
+#include "ldns/sbuffer.h"
#include "util/data/packed_rrset.h" /* for enum sec_status */
struct comm_reply;
struct comm_point;
@@ -83,11 +84,15 @@ void libworker_handle_control_cmd(struct tube* tube, uint8_t* msg, size_t len,
int err, void* arg);
/** mesh callback with fg results */
-void libworker_fg_done_cb(void* arg, int rcode, ldns_buffer* buf,
+void libworker_fg_done_cb(void* arg, int rcode, sldns_buffer* buf,
enum sec_status s, char* why_bogus);
/** mesh callback with bg results */
-void libworker_bg_done_cb(void* arg, int rcode, ldns_buffer* buf,
+void libworker_bg_done_cb(void* arg, int rcode, sldns_buffer* buf,
+ enum sec_status s, char* why_bogus);
+
+/** mesh callback with event results */
+void libworker_event_done_cb(void* arg, int rcode, struct sldns_buffer* buf,
enum sec_status s, char* why_bogus);
/**
diff --git a/contrib/unbound/services/cache/dns.c b/contrib/unbound/services/cache/dns.c
index 6e99b7f..f2a04a2 100644
--- a/contrib/unbound/services/cache/dns.c
+++ b/contrib/unbound/services/cache/dns.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -50,6 +50,7 @@
#include "util/net_help.h"
#include "util/regional.h"
#include "util/config_file.h"
+#include "ldns/sbuffer.h"
/** store rrsets in the rrset cache.
* @param env: module environment with caches.
@@ -66,8 +67,8 @@
* @param region: for qrep allocs.
*/
static void
-store_rrsets(struct module_env* env, struct reply_info* rep, uint32_t now,
- uint32_t leeway, int pside, struct reply_info* qrep,
+store_rrsets(struct module_env* env, struct reply_info* rep, time_t now,
+ time_t leeway, int pside, struct reply_info* qrep,
struct regional* region)
{
size_t i;
@@ -105,11 +106,11 @@ store_rrsets(struct module_env* env, struct reply_info* rep, uint32_t now,
void
dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
- hashvalue_t hash, struct reply_info* rep, uint32_t leeway, int pside,
+ hashvalue_t hash, struct reply_info* rep, time_t leeway, int pside,
struct reply_info* qrep, struct regional* region)
{
struct msgreply_entry* e;
- uint32_t ttl = rep->ttl;
+ time_t ttl = rep->ttl;
size_t i;
/* store RRsets */
@@ -142,7 +143,7 @@ dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
/** find closest NS or DNAME and returns the rrset (locked) */
static struct ub_packed_rrset_key*
find_closest_of_type(struct module_env* env, uint8_t* qname, size_t qnamelen,
- uint16_t qclass, uint32_t now, uint16_t searchtype, int stripfront)
+ uint16_t qclass, time_t now, uint16_t searchtype, int stripfront)
{
struct ub_packed_rrset_key *rrset;
uint8_t lablen;
@@ -171,7 +172,7 @@ find_closest_of_type(struct module_env* env, uint8_t* qname, size_t qnamelen,
/** add addr to additional section */
static void
addr_to_additional(struct ub_packed_rrset_key* rrset, struct regional* region,
- struct dns_msg* msg, uint32_t now)
+ struct dns_msg* msg, time_t now)
{
if((msg->rep->rrsets[msg->rep->rrset_count] =
packed_rrset_copy_region(rrset, region, now))) {
@@ -183,7 +184,7 @@ addr_to_additional(struct ub_packed_rrset_key* rrset, struct regional* region,
/** lookup message in message cache */
static struct msgreply_entry*
msg_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen,
- uint16_t qtype, uint16_t qclass, uint32_t now, int wr)
+ uint16_t qtype, uint16_t qclass, time_t now, int wr)
{
struct lruhash_entry* e;
struct query_info k;
@@ -207,7 +208,7 @@ msg_cache_lookup(struct module_env* env, uint8_t* qname, size_t qnamelen,
/** find and add A and AAAA records for nameservers in delegpt */
static int
find_add_addrs(struct module_env* env, uint16_t qclass,
- struct regional* region, struct delegpt* dp, uint32_t now,
+ struct regional* region, struct delegpt* dp, time_t now,
struct dns_msg** msg)
{
struct delegpt_ns* ns;
@@ -262,12 +263,12 @@ cache_fill_missing(struct module_env* env, uint16_t qclass,
struct delegpt_ns* ns;
struct msgreply_entry* neg;
struct ub_packed_rrset_key* akey;
- uint32_t now = *env->now;
+ time_t now = *env->now;
for(ns = dp->nslist; ns; ns = ns->next) {
akey = rrset_cache_lookup(env->rrset_cache, ns->name,
ns->namelen, LDNS_RR_TYPE_A, qclass, 0, now, 0);
if(akey) {
- if(!delegpt_add_rrset_A(dp, region, akey, (int)ns->lame)) {
+ if(!delegpt_add_rrset_A(dp, region, akey, ns->lame)) {
lock_rw_unlock(&akey->entry.lock);
return 0;
}
@@ -285,7 +286,7 @@ cache_fill_missing(struct module_env* env, uint16_t qclass,
akey = rrset_cache_lookup(env->rrset_cache, ns->name,
ns->namelen, LDNS_RR_TYPE_AAAA, qclass, 0, now, 0);
if(akey) {
- if(!delegpt_add_rrset_AAAA(dp, region, akey, (int)ns->lame)) {
+ if(!delegpt_add_rrset_AAAA(dp, region, akey, ns->lame)) {
lock_rw_unlock(&akey->entry.lock);
return 0;
}
@@ -307,7 +308,7 @@ cache_fill_missing(struct module_env* env, uint16_t qclass,
/** find and add DS or NSEC to delegation msg */
static void
find_add_ds(struct module_env* env, struct regional* region,
- struct dns_msg* msg, struct delegpt* dp, uint32_t now)
+ struct dns_msg* msg, struct delegpt* dp, time_t now)
{
/* Lookup the DS or NSEC at the delegation point. */
struct ub_packed_rrset_key* rrset = rrset_cache_lookup(
@@ -369,7 +370,7 @@ dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype,
int
dns_msg_authadd(struct dns_msg* msg, struct regional* region,
- struct ub_packed_rrset_key* rrset, uint32_t now)
+ struct ub_packed_rrset_key* rrset, time_t now)
{
if(!(msg->rep->rrsets[msg->rep->rrset_count++] =
packed_rrset_copy_region(rrset, region, now)))
@@ -381,7 +382,7 @@ dns_msg_authadd(struct dns_msg* msg, struct regional* region,
struct delegpt*
dns_cache_find_delegation(struct module_env* env, uint8_t* qname,
size_t qnamelen, uint16_t qtype, uint16_t qclass,
- struct regional* region, struct dns_msg** msg, uint32_t now)
+ struct regional* region, struct dns_msg** msg, time_t now)
{
/* try to find closest NS rrset */
struct ub_packed_rrset_key* nskey;
@@ -455,7 +456,7 @@ gen_dns_msg(struct regional* region, struct query_info* q, size_t num)
/** generate dns_msg from cached message */
static struct dns_msg*
tomsg(struct module_env* env, struct query_info* q, struct reply_info* r,
- struct regional* region, uint32_t now, struct regional* scratch)
+ struct regional* region, time_t now, struct regional* scratch)
{
struct dns_msg* msg;
size_t i;
@@ -506,7 +507,7 @@ tomsg(struct module_env* env, struct query_info* q, struct reply_info* r,
/** synthesize RRset-only response from cached RRset item */
static struct dns_msg*
rrset_msg(struct ub_packed_rrset_key* rrset, struct regional* region,
- uint32_t now, struct query_info* q)
+ time_t now, struct query_info* q)
{
struct dns_msg* msg;
struct packed_rrset_data* d = (struct packed_rrset_data*)
@@ -535,7 +536,7 @@ rrset_msg(struct ub_packed_rrset_key* rrset, struct regional* region,
/** synthesize DNAME+CNAME response from cached DNAME item */
static struct dns_msg*
synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region,
- uint32_t now, struct query_info* q)
+ time_t now, struct query_info* q)
{
struct dns_msg* msg;
struct ub_packed_rrset_key* ck;
@@ -599,7 +600,7 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region,
ck->entry.hash = rrset_key_hash(&ck->rk);
newd = (struct packed_rrset_data*)regional_alloc_zero(region,
sizeof(struct packed_rrset_data) + sizeof(size_t) +
- sizeof(uint8_t*) + sizeof(uint32_t) + sizeof(uint16_t)
+ sizeof(uint8_t*) + sizeof(time_t) + sizeof(uint16_t)
+ newlen);
if(!newd)
return NULL;
@@ -615,7 +616,7 @@ synth_dname_msg(struct ub_packed_rrset_key* rrset, struct regional* region,
newd->rr_ttl[0] = newd->ttl;
msg->rep->ttl = newd->ttl;
msg->rep->prefetch_ttl = PREFETCH_TTL_CALC(newd->ttl);
- ldns_write_uint16(newd->rr_data[0], newlen);
+ sldns_write_uint16(newd->rr_data[0], newlen);
memmove(newd->rr_data[0] + sizeof(uint16_t), newname, newlen);
msg->rep->an_numrrsets ++;
msg->rep->rrset_count ++;
@@ -630,7 +631,7 @@ dns_cache_lookup(struct module_env* env,
struct lruhash_entry* e;
struct query_info k;
hashvalue_t h;
- uint32_t now = *env->now;
+ time_t now = *env->now;
struct ub_packed_rrset_key* rrset;
/* lookup first, this has both NXdomains and ANSWER responses */
@@ -739,7 +740,7 @@ dns_cache_lookup(struct module_env* env,
int
dns_cache_store(struct module_env* env, struct query_info* msgqinf,
- struct reply_info* msgrep, int is_referral, uint32_t leeway, int pside,
+ struct reply_info* msgrep, int is_referral, time_t leeway, int pside,
struct regional* region)
{
struct reply_info* rep = NULL;
diff --git a/contrib/unbound/services/cache/dns.h b/contrib/unbound/services/cache/dns.h
index bc9f57c..a7a6190 100644
--- a/contrib/unbound/services/cache/dns.h
+++ b/contrib/unbound/services/cache/dns.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -82,7 +82,7 @@ struct dns_msg {
* @return 0 on alloc error (out of memory).
*/
int dns_cache_store(struct module_env* env, struct query_info* qinf,
- struct reply_info* rep, int is_referral, uint32_t leeway, int pside,
+ struct reply_info* rep, int is_referral, time_t leeway, int pside,
struct regional* region);
/**
@@ -105,7 +105,7 @@ int dns_cache_store(struct module_env* env, struct query_info* qinf,
* @param region: to allocate into for qmsg.
*/
void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
- hashvalue_t hash, struct reply_info* rep, uint32_t leeway, int pside,
+ hashvalue_t hash, struct reply_info* rep, time_t leeway, int pside,
struct reply_info* qrep, struct regional* region);
/**
@@ -123,7 +123,7 @@ void dns_cache_store_msg(struct module_env* env, struct query_info* qinfo,
*/
struct delegpt* dns_cache_find_delegation(struct module_env* env,
uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass,
- struct regional* region, struct dns_msg** msg, uint32_t timenow);
+ struct regional* region, struct dns_msg** msg, time_t timenow);
/**
* Find cached message
@@ -177,6 +177,6 @@ struct dns_msg* dns_msg_create(uint8_t* qname, size_t qnamelen, uint16_t qtype,
* @return true if worked, false on fail
*/
int dns_msg_authadd(struct dns_msg* msg, struct regional* region,
- struct ub_packed_rrset_key* rrset, uint32_t now);
+ struct ub_packed_rrset_key* rrset, time_t now);
#endif /* SERVICES_CACHE_DNS_H */
diff --git a/contrib/unbound/services/cache/infra.c b/contrib/unbound/services/cache/infra.c
index c674aca..07f2103 100644
--- a/contrib/unbound/services/cache/infra.c
+++ b/contrib/unbound/services/cache/infra.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -39,7 +39,7 @@
* This file contains the infrastructure cache.
*/
#include "config.h"
-#include <ldns/rr.h>
+#include "ldns/rrdef.h"
#include "services/cache/infra.h"
#include "util/storage/slabhash.h"
#include "util/storage/lookup3.h"
@@ -189,7 +189,7 @@ infra_lookup_nottl(struct infra_cache* infra, struct sockaddr_storage* addr,
/** init the data elements */
static void
data_entry_init(struct infra_cache* infra, struct lruhash_entry* e,
- uint32_t timenow)
+ time_t timenow)
{
struct infra_data* data = (struct infra_data*)e->data;
data->ttl = timenow + infra->host_ttl;
@@ -218,7 +218,7 @@ data_entry_init(struct infra_cache* infra, struct lruhash_entry* e,
*/
static struct lruhash_entry*
new_entry(struct infra_cache* infra, struct sockaddr_storage* addr,
- socklen_t addrlen, uint8_t* name, size_t namelen, uint32_t tm)
+ socklen_t addrlen, uint8_t* name, size_t namelen, time_t tm)
{
struct infra_data* data;
struct infra_key* key = (struct infra_key*)malloc(sizeof(*key));
@@ -248,7 +248,7 @@ new_entry(struct infra_cache* infra, struct sockaddr_storage* addr,
int
infra_host(struct infra_cache* infra, struct sockaddr_storage* addr,
- socklen_t addrlen, uint8_t* nm, size_t nmlen, uint32_t timenow,
+ socklen_t addrlen, uint8_t* nm, size_t nmlen, time_t timenow,
int* edns_vs, uint8_t* edns_lame_known, int* to)
{
struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen,
@@ -317,7 +317,7 @@ infra_host(struct infra_cache* infra, struct sockaddr_storage* addr,
int
infra_set_lame(struct infra_cache* infra, struct sockaddr_storage* addr,
- socklen_t addrlen, uint8_t* nm, size_t nmlen, uint32_t timenow,
+ socklen_t addrlen, uint8_t* nm, size_t nmlen, time_t timenow,
int dnsseclame, int reclame, uint16_t qtype)
{
struct infra_data* data;
@@ -374,7 +374,7 @@ infra_update_tcp_works(struct infra_cache* infra,
int
infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr,
socklen_t addrlen, uint8_t* nm, size_t nmlen, int qtype,
- int roundtrip, int orig_rtt, uint32_t timenow)
+ int roundtrip, int orig_rtt, time_t timenow)
{
struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen,
nm, nmlen, 1);
@@ -425,19 +425,19 @@ infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr,
return rto;
}
-int infra_get_host_rto(struct infra_cache* infra,
+long long infra_get_host_rto(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* nm,
- size_t nmlen, struct rtt_info* rtt, int* delay, uint32_t timenow,
+ size_t nmlen, struct rtt_info* rtt, int* delay, time_t timenow,
int* tA, int* tAAAA, int* tother)
{
struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen,
nm, nmlen, 0);
struct infra_data* data;
- int ttl = -2;
+ long long ttl = -2;
if(!e) return -1;
data = (struct infra_data*)e->data;
if(data->ttl >= timenow) {
- ttl = (int)(data->ttl - timenow);
+ ttl = (long long)(data->ttl - timenow);
memmove(rtt, &data->rtt, sizeof(*rtt));
if(timenow < data->probedelay)
*delay = (int)(data->probedelay - timenow);
@@ -453,7 +453,7 @@ int infra_get_host_rto(struct infra_cache* infra,
int
infra_edns_update(struct infra_cache* infra, struct sockaddr_storage* addr,
socklen_t addrlen, uint8_t* nm, size_t nmlen, int edns_version,
- uint32_t timenow)
+ time_t timenow)
{
struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen,
nm, nmlen, 1);
@@ -485,7 +485,7 @@ int
infra_get_lame_rtt(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen,
uint8_t* name, size_t namelen, uint16_t qtype,
- int* lame, int* dnsseclame, int* reclame, int* rtt, uint32_t timenow)
+ int* lame, int* dnsseclame, int* reclame, int* rtt, time_t timenow)
{
struct infra_data* host;
struct lruhash_entry* e = infra_lookup_nottl(infra, addr, addrlen,
diff --git a/contrib/unbound/services/cache/infra.h b/contrib/unbound/services/cache/infra.h
index 161f5ab..fc54f7f 100644
--- a/contrib/unbound/services/cache/infra.h
+++ b/contrib/unbound/services/cache/infra.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -68,10 +68,10 @@ struct infra_key {
*/
struct infra_data {
/** TTL value for this entry. absolute time. */
- uint32_t ttl;
+ time_t ttl;
/** time in seconds (absolute) when probing re-commences, 0 disabled */
- uint32_t probedelay;
+ time_t probedelay;
/** round trip times for timeout calculation */
struct rtt_info rtt;
@@ -173,7 +173,7 @@ struct lruhash_entry* infra_lookup_nottl(struct infra_cache* infra,
*/
int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr,
socklen_t addrlen, uint8_t* name, size_t namelen,
- uint32_t timenow, int* edns_vs, uint8_t* edns_lame_known, int* to);
+ time_t timenow, int* edns_vs, uint8_t* edns_lame_known, int* to);
/**
* Set a host to be lame for the given zone.
@@ -192,7 +192,7 @@ int infra_host(struct infra_cache* infra, struct sockaddr_storage* addr,
*/
int infra_set_lame(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen,
- uint8_t* name, size_t namelen, uint32_t timenow, int dnsseclame,
+ uint8_t* name, size_t namelen, time_t timenow, int dnsseclame,
int reclame, uint16_t qtype);
/**
@@ -212,7 +212,7 @@ int infra_set_lame(struct infra_cache* infra,
*/
int infra_rtt_update(struct infra_cache* infra, struct sockaddr_storage* addr,
socklen_t addrlen, uint8_t* name, size_t namelen, int qtype,
- int roundtrip, int orig_rtt, uint32_t timenow);
+ int roundtrip, int orig_rtt, time_t timenow);
/**
* Update information for the host, store that a TCP transaction works.
@@ -240,7 +240,7 @@ void infra_update_tcp_works(struct infra_cache* infra,
*/
int infra_edns_update(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen,
- uint8_t* name, size_t namelen, int edns_version, uint32_t timenow);
+ uint8_t* name, size_t namelen, int edns_version, time_t timenow);
/**
* Get Lameness information and average RTT if host is in the cache.
@@ -263,7 +263,7 @@ int infra_edns_update(struct infra_cache* infra,
int infra_get_lame_rtt(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen,
uint8_t* name, size_t namelen, uint16_t qtype,
- int* lame, int* dnsseclame, int* reclame, int* rtt, uint32_t timenow);
+ int* lame, int* dnsseclame, int* reclame, int* rtt, time_t timenow);
/**
* Get additional (debug) info on timing.
@@ -281,9 +281,9 @@ int infra_get_lame_rtt(struct infra_cache* infra,
* @return TTL the infra host element is valid for. If -1: not found in cache.
* TTL -2: found but expired.
*/
-int infra_get_host_rto(struct infra_cache* infra,
+long long infra_get_host_rto(struct infra_cache* infra,
struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* name,
- size_t namelen, struct rtt_info* rtt, int* delay, uint32_t timenow,
+ size_t namelen, struct rtt_info* rtt, int* delay, time_t timenow,
int* tA, int* tAAAA, int* tother);
/**
diff --git a/contrib/unbound/services/cache/rrset.c b/contrib/unbound/services/cache/rrset.c
index b9d20db..5f52dbc 100644
--- a/contrib/unbound/services/cache/rrset.c
+++ b/contrib/unbound/services/cache/rrset.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,6 +40,7 @@
*/
#include "config.h"
#include "services/cache/rrset.h"
+#include "ldns/rrdef.h"
#include "util/storage/slabhash.h"
#include "util/config_file.h"
#include "util/data/packed_rrset.h"
@@ -120,7 +121,7 @@ rrset_cache_touch(struct rrset_cache* r, struct ub_packed_rrset_key* key,
/** see if rrset needs to be updated in the cache */
static int
-need_to_update_rrset(void* nd, void* cd, uint32_t timenow, int equal, int ns)
+need_to_update_rrset(void* nd, void* cd, time_t timenow, int equal, int ns)
{
struct packed_rrset_data* newd = (struct packed_rrset_data*)nd;
struct packed_rrset_data* cached = (struct packed_rrset_data*)cd;
@@ -181,7 +182,7 @@ rrset_update_id(struct rrset_ref* ref, struct alloc_cache* alloc)
int
rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref,
- struct alloc_cache* alloc, uint32_t timenow)
+ struct alloc_cache* alloc, time_t timenow)
{
struct lruhash_entry* e;
struct ub_packed_rrset_key* k = ref->key;
@@ -237,7 +238,7 @@ rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref,
struct ub_packed_rrset_key*
rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen,
- uint16_t qtype, uint16_t qclass, uint32_t flags, uint32_t timenow,
+ uint16_t qtype, uint16_t qclass, uint32_t flags, time_t timenow,
int wr)
{
struct lruhash_entry* e;
@@ -268,7 +269,7 @@ rrset_cache_lookup(struct rrset_cache* r, uint8_t* qname, size_t qnamelen,
}
int
-rrset_array_lock(struct rrset_ref* ref, size_t count, uint32_t timenow)
+rrset_array_lock(struct rrset_ref* ref, size_t count, time_t timenow)
{
size_t i;
for(i=0; i<count; i++) {
@@ -327,7 +328,7 @@ rrset_array_unlock_touch(struct rrset_cache* r, struct regional* scratch,
void
rrset_update_sec_status(struct rrset_cache* r,
- struct ub_packed_rrset_key* rrset, uint32_t now)
+ struct ub_packed_rrset_key* rrset, time_t now)
{
struct packed_rrset_data* updata =
(struct packed_rrset_data*)rrset->entry.data;
@@ -366,7 +367,7 @@ rrset_update_sec_status(struct rrset_cache* r,
void
rrset_check_sec_status(struct rrset_cache* r,
- struct ub_packed_rrset_key* rrset, uint32_t now)
+ struct ub_packed_rrset_key* rrset, time_t now)
{
struct packed_rrset_data* updata =
(struct packed_rrset_data*)rrset->entry.data;
diff --git a/contrib/unbound/services/cache/rrset.h b/contrib/unbound/services/cache/rrset.h
index 22d3671..98e44a4 100644
--- a/contrib/unbound/services/cache/rrset.h
+++ b/contrib/unbound/services/cache/rrset.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -131,7 +131,7 @@ void rrset_cache_touch(struct rrset_cache* r, struct ub_packed_rrset_key* key,
* also the rdata is equal (but other parameters in cache are superior).
*/
int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref,
- struct alloc_cache* alloc, uint32_t timenow);
+ struct alloc_cache* alloc, time_t timenow);
/**
* Lookup rrset. You obtain read/write lock. You must unlock before lookup
@@ -149,7 +149,7 @@ int rrset_cache_update(struct rrset_cache* r, struct rrset_ref* ref,
*/
struct ub_packed_rrset_key* rrset_cache_lookup(struct rrset_cache* r,
uint8_t* qname, size_t qnamelen, uint16_t qtype, uint16_t qclass,
- uint32_t flags, uint32_t timenow, int wr);
+ uint32_t flags, time_t timenow, int wr);
/**
* Obtain readlock on a (sorted) list of rrset references.
@@ -163,7 +163,7 @@ struct ub_packed_rrset_key* rrset_cache_lookup(struct rrset_cache* r,
* RRsets have been purged from the cache.
* If true, you hold readlocks on all the ref items.
*/
-int rrset_array_lock(struct rrset_ref* ref, size_t count, uint32_t timenow);
+int rrset_array_lock(struct rrset_ref* ref, size_t count, time_t timenow);
/**
* Unlock array (sorted) of rrset references.
@@ -199,7 +199,7 @@ void rrset_array_unlock_touch(struct rrset_cache* r, struct regional* scratch,
* @param now: current time.
*/
void rrset_update_sec_status(struct rrset_cache* r,
- struct ub_packed_rrset_key* rrset, uint32_t now);
+ struct ub_packed_rrset_key* rrset, time_t now);
/**
* Looks up security status of an rrset. Looks up the rrset.
@@ -211,7 +211,7 @@ void rrset_update_sec_status(struct rrset_cache* r,
* @param now: current time.
*/
void rrset_check_sec_status(struct rrset_cache* r,
- struct ub_packed_rrset_key* rrset, uint32_t now);
+ struct ub_packed_rrset_key* rrset, time_t now);
/**
* Remove an rrset from the cache, by name and type and flags
diff --git a/contrib/unbound/services/listen_dnsport.c b/contrib/unbound/services/listen_dnsport.c
index 647cbe0..8b1d62e3 100644
--- a/contrib/unbound/services/listen_dnsport.c
+++ b/contrib/unbound/services/listen_dnsport.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -49,6 +49,7 @@
#include "util/log.h"
#include "util/config_file.h"
#include "util/net_help.h"
+#include "ldns/sbuffer.h"
#ifdef HAVE_NETDB_H
#include <netdb.h>
@@ -75,7 +76,7 @@ verbose_print_addr(struct addrinfo *addr)
#endif /* INET6 */
if(inet_ntop(addr->ai_family, sinaddr, buf,
(socklen_t)sizeof(buf)) == 0) {
- strncpy(buf, "(null)", sizeof(buf));
+ (void)strlcpy(buf, "(null)", sizeof(buf));
}
buf[sizeof(buf)-1] = 0;
verbose(VERB_ALGO, "creating %s%s socket %s %d",
@@ -91,10 +92,10 @@ verbose_print_addr(struct addrinfo *addr)
int
create_udp_sock(int family, int socktype, struct sockaddr* addr,
socklen_t addrlen, int v6only, int* inuse, int* noproto,
- int rcv, int snd)
+ int rcv, int snd, int listen, int* reuseport)
{
int s;
-#if defined(IPV6_USE_MIN_MTU)
+#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || defined(IPV6_USE_MIN_MTU)
int on=1;
#endif
#ifdef IPV6_MTU
@@ -129,6 +130,50 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
*noproto = 0;
return -1;
}
+ if(listen) {
+#ifdef SO_REUSEADDR
+ if(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (void*)&on,
+ (socklen_t)sizeof(on)) < 0) {
+#ifndef USE_WINSOCK
+ log_err("setsockopt(.. SO_REUSEADDR ..) failed: %s",
+ strerror(errno));
+ if(errno != ENOSYS) {
+ close(s);
+ *noproto = 0;
+ *inuse = 0;
+ return -1;
+ }
+#else
+ log_err("setsockopt(.. SO_REUSEADDR ..) failed: %s",
+ wsa_strerror(WSAGetLastError()));
+ closesocket(s);
+ *noproto = 0;
+ *inuse = 0;
+ return -1;
+#endif
+ }
+#endif /* SO_REUSEADDR */
+#if defined(__linux__) && defined(SO_REUSEPORT)
+ /* Linux specific: try to set SO_REUSEPORT so that incoming
+ * queries are distributed evenly among the receiving threads.
+ * Each thread must have its own socket bound to the same port,
+ * with SO_REUSEPORT set on each socket.
+ */
+ if (reuseport && *reuseport &&
+ setsockopt(s, SOL_SOCKET, SO_REUSEPORT, (void*)&on,
+ (socklen_t)sizeof(on)) < 0) {
+#ifdef ENOPROTOOPT
+ if(errno != ENOPROTOOPT || verbosity >= 3)
+ log_warn("setsockopt(.. SO_REUSEPORT ..) failed: %s",
+ strerror(errno));
+#endif
+ /* this option is not essential, we can continue */
+ *reuseport = 0;
+ }
+#else
+ (void)reuseport;
+#endif /* defined(__linux__) && defined(SO_REUSEPORT) */
+ }
if(rcv) {
#ifdef SO_RCVBUF
int got;
@@ -328,6 +373,8 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
# else
closesocket(s);
# endif
+ *noproto = 0;
+ *inuse = 0;
return -1;
}
# elif defined(IP_DONTFRAG)
@@ -341,12 +388,15 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
# else
closesocket(s);
# endif
+ *noproto = 0;
+ *inuse = 0;
return -1;
}
# endif /* IPv4 MTU */
}
if(bind(s, (struct sockaddr*)addr, addrlen) != 0) {
*noproto = 0;
+ *inuse = 0;
#ifndef USE_WINSOCK
#ifdef EADDRINUSE
*inuse = (errno == EADDRINUSE);
@@ -386,10 +436,11 @@ create_udp_sock(int family, int socktype, struct sockaddr* addr,
}
int
-create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto)
+create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto,
+ int* reuseport)
{
int s;
-#if defined(SO_REUSEADDR) || defined(IPV6_V6ONLY)
+#if defined(SO_REUSEADDR) || defined(SO_REUSEPORT) || defined(IPV6_V6ONLY)
int on = 1;
#endif /* SO_REUSEADDR || IPV6_V6ONLY */
verbose_print_addr(addr);
@@ -427,6 +478,26 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto)
return -1;
}
#endif /* SO_REUSEADDR */
+#if defined(__linux__) && defined(SO_REUSEPORT)
+ /* Linux specific: try to set SO_REUSEPORT so that incoming
+ * connections are distributed evenly among the receiving threads.
+ * Each thread must have its own socket bound to the same port,
+ * with SO_REUSEPORT set on each socket.
+ */
+ if (reuseport && *reuseport &&
+ setsockopt(s, SOL_SOCKET, SO_REUSEPORT, (void*)&on,
+ (socklen_t)sizeof(on)) < 0) {
+#ifdef ENOPROTOOPT
+ if(errno != ENOPROTOOPT || verbosity >= 3)
+ log_warn("setsockopt(.. SO_REUSEPORT ..) failed: %s",
+ strerror(errno));
+#endif
+ /* this option is not essential, we can continue */
+ *reuseport = 0;
+ }
+#else
+ (void)reuseport;
+#endif /* defined(__linux__) && defined(SO_REUSEPORT) */
#if defined(IPV6_V6ONLY)
if(addr->ai_family == AF_INET6 && v6only) {
if(setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
@@ -494,7 +565,8 @@ create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto)
*/
static int
make_sock(int stype, const char* ifname, const char* port,
- struct addrinfo *hints, int v6only, int* noip6, size_t rcv, size_t snd)
+ struct addrinfo *hints, int v6only, int* noip6, size_t rcv, size_t snd,
+ int* reuseport)
{
struct addrinfo *res = NULL;
int r, s, inuse, noproto;
@@ -521,14 +593,15 @@ make_sock(int stype, const char* ifname, const char* port,
verbose_print_addr(res);
s = create_udp_sock(res->ai_family, res->ai_socktype,
(struct sockaddr*)res->ai_addr, res->ai_addrlen,
- v6only, &inuse, &noproto, (int)rcv, (int)snd);
+ v6only, &inuse, &noproto, (int)rcv, (int)snd, 1,
+ reuseport);
if(s == -1 && inuse) {
log_err("bind: address already in use");
} else if(s == -1 && noproto && hints->ai_family == AF_INET6){
*noip6 = 1;
}
} else {
- s = create_tcp_accept_sock(res, v6only, &noproto);
+ s = create_tcp_accept_sock(res, v6only, &noproto, reuseport);
if(s == -1 && noproto && hints->ai_family == AF_INET6){
*noip6 = 1;
}
@@ -540,7 +613,8 @@ make_sock(int stype, const char* ifname, const char* port,
/** make socket and first see if ifname contains port override info */
static int
make_sock_port(int stype, const char* ifname, const char* port,
- struct addrinfo *hints, int v6only, int* noip6, size_t rcv, size_t snd)
+ struct addrinfo *hints, int v6only, int* noip6, size_t rcv, size_t snd,
+ int* reuseport)
{
char* s = strchr(ifname, '@');
if(s) {
@@ -557,14 +631,15 @@ make_sock_port(int stype, const char* ifname, const char* port,
*noip6 = 0;
return -1;
}
- strncpy(newif, ifname, sizeof(newif));
+ (void)strlcpy(newif, ifname, sizeof(newif));
newif[s-ifname] = 0;
- strncpy(p, s+1, sizeof(p));
+ (void)strlcpy(p, s+1, sizeof(p));
p[strlen(s+1)]=0;
return make_sock(stype, newif, p, hints, v6only, noip6,
- rcv, snd);
+ rcv, snd, reuseport);
}
- return make_sock(stype, ifname, port, hints, v6only, noip6, rcv, snd);
+ return make_sock(stype, ifname, port, hints, v6only, noip6, rcv, snd,
+ reuseport);
}
/**
@@ -656,19 +731,21 @@ set_recvpktinfo(int s, int family)
* @param rcv: receive buffer size for UDP
* @param snd: send buffer size for UDP
* @param ssl_port: ssl service port number
+ * @param reuseport: try to set SO_REUSEPORT if nonNULL and true.
+ * set to false on exit if reuseport failed due to no kernel support.
* @return: returns false on error.
*/
static int
ports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp,
struct addrinfo *hints, const char* port, struct listen_port** list,
- size_t rcv, size_t snd, int ssl_port)
+ size_t rcv, size_t snd, int ssl_port, int* reuseport)
{
int s, noip6=0;
if(!do_udp && !do_tcp)
return 0;
if(do_auto) {
if((s = make_sock_port(SOCK_DGRAM, ifname, port, hints, 1,
- &noip6, rcv, snd)) == -1) {
+ &noip6, rcv, snd, reuseport)) == -1) {
if(noip6) {
log_warn("IPv6 protocol not available");
return 1;
@@ -695,7 +772,7 @@ ports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp,
} else if(do_udp) {
/* regular udp socket */
if((s = make_sock_port(SOCK_DGRAM, ifname, port, hints, 1,
- &noip6, rcv, snd)) == -1) {
+ &noip6, rcv, snd, reuseport)) == -1) {
if(noip6) {
log_warn("IPv6 protocol not available");
return 1;
@@ -716,7 +793,7 @@ ports_create_if(const char* ifname, int do_auto, int do_udp, int do_tcp,
atoi(strchr(ifname, '@')+1) == ssl_port) ||
(!strchr(ifname, '@') && atoi(port) == ssl_port));
if((s = make_sock_port(SOCK_STREAM, ifname, port, hints, 1,
- &noip6, 0, 0)) == -1) {
+ &noip6, 0, 0, reuseport)) == -1) {
if(noip6) {
/*log_warn("IPv6 protocol not available");*/
return 1;
@@ -767,7 +844,7 @@ listen_create(struct comm_base* base, struct listen_port* ports,
if(!front)
return NULL;
front->cps = NULL;
- front->udp_buff = ldns_buffer_new(bufsize);
+ front->udp_buff = sldns_buffer_new(bufsize);
if(!front->udp_buff) {
free(front);
return NULL;
@@ -830,12 +907,12 @@ listen_delete(struct listen_dnsport* front)
if(!front)
return;
listen_list_delete(front->cps);
- ldns_buffer_free(front->udp_buff);
+ sldns_buffer_free(front->udp_buff);
free(front);
}
struct listen_port*
-listening_ports_open(struct config_file* cfg)
+listening_ports_open(struct config_file* cfg, int* reuseport)
{
struct listen_port* list = NULL;
struct addrinfo hints;
@@ -871,7 +948,7 @@ listening_ports_open(struct config_file* cfg)
do_auto, cfg->do_udp, do_tcp,
&hints, portbuf, &list,
cfg->so_rcvbuf, cfg->so_sndbuf,
- cfg->ssl_port)) {
+ cfg->ssl_port, reuseport)) {
listening_ports_free(list);
return NULL;
}
@@ -882,7 +959,7 @@ listening_ports_open(struct config_file* cfg)
do_auto, cfg->do_udp, do_tcp,
&hints, portbuf, &list,
cfg->so_rcvbuf, cfg->so_sndbuf,
- cfg->ssl_port)) {
+ cfg->ssl_port, reuseport)) {
listening_ports_free(list);
return NULL;
}
@@ -895,7 +972,7 @@ listening_ports_open(struct config_file* cfg)
if(!ports_create_if(cfg->ifs[i], 0, cfg->do_udp,
do_tcp, &hints, portbuf, &list,
cfg->so_rcvbuf, cfg->so_sndbuf,
- cfg->ssl_port)) {
+ cfg->ssl_port, reuseport)) {
listening_ports_free(list);
return NULL;
}
@@ -906,7 +983,7 @@ listening_ports_open(struct config_file* cfg)
if(!ports_create_if(cfg->ifs[i], 0, cfg->do_udp,
do_tcp, &hints, portbuf, &list,
cfg->so_rcvbuf, cfg->so_sndbuf,
- cfg->ssl_port)) {
+ cfg->ssl_port, reuseport)) {
listening_ports_free(list);
return NULL;
}
@@ -936,7 +1013,7 @@ size_t listen_get_mem(struct listen_dnsport* listen)
{
size_t s = sizeof(*listen) + sizeof(*listen->base) +
sizeof(*listen->udp_buff) +
- ldns_buffer_capacity(listen->udp_buff);
+ sldns_buffer_capacity(listen->udp_buff);
struct listen_list* p;
for(p = listen->cps; p; p = p->next) {
s += sizeof(*p);
diff --git a/contrib/unbound/services/listen_dnsport.h b/contrib/unbound/services/listen_dnsport.h
index 4d37aca..61fb9a0 100644
--- a/contrib/unbound/services/listen_dnsport.h
+++ b/contrib/unbound/services/listen_dnsport.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -46,6 +46,7 @@
struct listen_list;
struct config_file;
struct addrinfo;
+struct sldns_buffer;
/**
* Listening for queries structure.
@@ -57,7 +58,7 @@ struct listen_dnsport {
/** buffer shared by UDP connections, since there is only one
datagram at any time. */
- ldns_buffer* udp_buff;
+ struct sldns_buffer* udp_buff;
/** list of comm points used to get incoming events */
struct listen_list* cps;
@@ -106,9 +107,13 @@ struct listen_port {
* interfaces for IP4 and/or IP6, for UDP and/or TCP.
* On the given port number. It creates the sockets.
* @param cfg: settings on what ports to open.
+ * @param reuseport: set to true if you want reuseport, or NULL to not have it,
+ * set to false on exit if reuseport failed to apply (because of no
+ * kernel support).
* @return: linked list of ports or NULL on error.
*/
-struct listen_port* listening_ports_open(struct config_file* cfg);
+struct listen_port* listening_ports_open(struct config_file* cfg,
+ int* reuseport);
/**
* Close and delete the (list of) listening ports.
@@ -178,19 +183,26 @@ void listen_start_accept(struct listen_dnsport* listen);
IPv6 proto (family) is not available.
* @param rcv: set size on rcvbuf with socket option, if 0 it is not set.
* @param snd: set size on sndbuf with socket option, if 0 it is not set.
+ * @param listen: if true, this is a listening UDP port, eg port 53, and
+ * set SO_REUSEADDR on it.
+ * @param reuseport: if nonNULL and true, try to set SO_REUSEPORT on
+ * listening UDP port. Set to false on return if it failed to do so.
* @return: the socket. -1 on error.
*/
int create_udp_sock(int family, int socktype, struct sockaddr* addr,
socklen_t addrlen, int v6only, int* inuse, int* noproto, int rcv,
- int snd);
+ int snd, int listen, int* reuseport);
/**
* Create and bind TCP listening socket
* @param addr: address info ready to make socket.
* @param v6only: enable ip6 only flag on ip6 sockets.
* @param noproto: if error caused by lack of protocol support.
+ * @param reuseport: if nonNULL and true, try to set SO_REUSEPORT on
+ * listening UDP port. Set to false on return if it failed to do so.
* @return: the socket. -1 on error.
*/
-int create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto);
+int create_tcp_accept_sock(struct addrinfo *addr, int v6only, int* noproto,
+ int* reuseport);
#endif /* LISTEN_DNSPORT_H */
diff --git a/contrib/unbound/services/localzone.c b/contrib/unbound/services/localzone.c
index 9fdab51..a1688e1 100644
--- a/contrib/unbound/services/localzone.c
+++ b/contrib/unbound/services/localzone.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -39,9 +39,9 @@
* This file contains functions to enable local zone authority service.
*/
#include "config.h"
-#include <ldns/dname.h>
-#include <ldns/host2wire.h>
#include "services/localzone.h"
+#include "ldns/str2wire.h"
+#include "ldns/sbuffer.h"
#include "util/regional.h"
#include "util/config_file.h"
#include "util/data/dname.h"
@@ -59,7 +59,7 @@ local_zones_create(void)
if(!zones)
return NULL;
rbtree_init(&zones->ztree, &local_zone_cmp);
- lock_quick_init(&zones->lock);
+ lock_rw_init(&zones->lock);
lock_protect(&zones->lock, &zones->ztree, sizeof(zones->ztree));
/* also lock protects the rbnode's in struct local_zone */
return zones;
@@ -78,7 +78,7 @@ local_zones_delete(struct local_zones* zones)
{
if(!zones)
return;
- lock_quick_destroy(&zones->lock);
+ lock_rw_destroy(&zones->lock);
/* walk through zones and delete them all */
traverse_postorder(&zones->ztree, lzdel, NULL);
free(zones);
@@ -125,19 +125,10 @@ local_data_cmp(const void* d1, const void* d2)
int
parse_dname(const char* str, uint8_t** res, size_t* len, int* labs)
{
- ldns_rdf* rdf;
- *res = NULL;
- *len = 0;
+ *res = sldns_str2wire_dname(str, len);
*labs = 0;
- rdf = ldns_dname_new_frm_str(str);
- if(!rdf) {
- log_err("cannot parse name %s", str);
- return 0;
- }
- *res = memdup(ldns_rdf_data(rdf), ldns_rdf_size(rdf));
- ldns_rdf_deep_free(rdf);
if(!*res) {
- log_err("out of memory");
+ log_err("cannot parse name %s", str);
return 0;
}
*labs = dname_count_size_labels(*res, len);
@@ -183,16 +174,16 @@ lz_enter_zone_dname(struct local_zones* zones, uint8_t* nm, size_t len,
}
/* add to rbtree */
- lock_quick_lock(&zones->lock);
+ lock_rw_wrlock(&zones->lock);
lock_rw_wrlock(&z->lock);
if(!rbtree_insert(&zones->ztree, &z->node)) {
log_warn("duplicate local-zone");
lock_rw_unlock(&z->lock);
local_zone_delete(z);
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
return NULL;
}
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
return z;
}
@@ -225,39 +216,28 @@ lz_enter_zone(struct local_zones* zones, const char* name, const char* type,
/** return name and class and rdata of rr; parses string */
static int
get_rr_content(const char* str, uint8_t** nm, uint16_t* type,
- uint16_t* dclass, uint32_t* ttl, ldns_buffer* rdata)
+ uint16_t* dclass, time_t* ttl, uint8_t* rr, size_t len,
+ uint8_t** rdata, size_t* rdata_len)
{
- ldns_rr* rr = NULL;
- ldns_status status = ldns_rr_new_frm_str(&rr, str, 3600, NULL, NULL);
- if(status != LDNS_STATUS_OK) {
- log_err("error parsing local-data '%s': %s",
- str, ldns_get_errorstr_by_id(status));
- ldns_rr_free(rr);
+ size_t dname_len = 0;
+ int e = sldns_str2wire_rr_buf(str, rr, &len, &dname_len, 3600,
+ NULL, 0, NULL, 0);
+ if(e) {
+ log_err("error parsing local-data at %d: '%s': %s",
+ LDNS_WIREPARSE_OFFSET(e), str,
+ sldns_get_errorstr_parse(e));
return 0;
}
- *nm = memdup(ldns_rdf_data(ldns_rr_owner(rr)),
- ldns_rdf_size(ldns_rr_owner(rr)));
+ *nm = memdup(rr, dname_len);
if(!*nm) {
log_err("out of memory");
- ldns_rr_free(rr);
return 0;
}
- *dclass = ldns_rr_get_class(rr);
- *type = ldns_rr_get_type(rr);
- *ttl = (uint32_t)ldns_rr_ttl(rr);
- ldns_buffer_clear(rdata);
- ldns_buffer_skip(rdata, 2);
- status = ldns_rr_rdata2buffer_wire(rdata, rr);
- ldns_rr_free(rr);
- if(status != LDNS_STATUS_OK) {
- log_err("error converting RR '%s' to wireformat: %s",
- str, ldns_get_errorstr_by_id(status));
- free(*nm);
- *nm = NULL;
- return 0;
- }
- ldns_buffer_flip(rdata);
- ldns_buffer_write_u16_at(rdata, 0, ldns_buffer_limit(rdata) - 2);
+ *dclass = sldns_wirerr_get_class(rr, len, dname_len);
+ *type = sldns_wirerr_get_type(rr, len, dname_len);
+ *ttl = (time_t)sldns_wirerr_get_ttl(rr, len, dname_len);
+ *rdata = sldns_wirerr_get_rdatawl(rr, len, dname_len);
+ *rdata_len = sldns_wirerr_get_rdatalen(rr, len, dname_len)+2;
return 1;
}
@@ -265,18 +245,18 @@ get_rr_content(const char* str, uint8_t** nm, uint16_t* type,
static int
get_rr_nameclass(const char* str, uint8_t** nm, uint16_t* dclass)
{
- ldns_rr* rr = NULL;
- ldns_status status = ldns_rr_new_frm_str(&rr, str, 3600, NULL, NULL);
- if(status != LDNS_STATUS_OK) {
- log_err("error parsing local-data '%s': %s",
- str, ldns_get_errorstr_by_id(status));
- ldns_rr_free(rr);
+ uint8_t rr[LDNS_RR_BUF_SIZE];
+ size_t len = sizeof(rr), dname_len = 0;
+ int s = sldns_str2wire_rr_buf(str, rr, &len, &dname_len, 3600,
+ NULL, 0, NULL, 0);
+ if(s != 0) {
+ log_err("error parsing local-data at %d '%s': %s",
+ LDNS_WIREPARSE_OFFSET(s), str,
+ sldns_get_errorstr_parse(s));
return 0;
}
- *nm = memdup(ldns_rdf_data(ldns_rr_owner(rr)),
- ldns_rdf_size(ldns_rr_owner(rr)));
- *dclass = ldns_rr_get_class(rr);
- ldns_rr_free(rr);
+ *nm = memdup(rr, dname_len);
+ *dclass = sldns_wirerr_get_class(rr, len, dname_len);
if(!*nm) {
log_err("out of memory");
return 0;
@@ -304,13 +284,12 @@ local_data_find_type(struct local_data* data, uint16_t type)
/** check for RR duplicates */
static int
-rr_is_duplicate(struct packed_rrset_data* pd, ldns_buffer* buf)
+rr_is_duplicate(struct packed_rrset_data* pd, uint8_t* rdata, size_t rdata_len)
{
size_t i;
for(i=0; i<pd->count; i++) {
- if(ldns_buffer_limit(buf) == pd->rr_len[i] &&
- memcmp(ldns_buffer_begin(buf), pd->rr_data[i],
- ldns_buffer_limit(buf)) == 0)
+ if(pd->rr_len[i] == rdata_len &&
+ memcmp(pd->rr_data[i], rdata, rdata_len) == 0)
return 1;
}
return 0;
@@ -356,10 +335,10 @@ new_local_rrset(struct regional* region, struct local_data* node,
/** insert RR into RRset data structure; Wastes a couple of bytes */
static int
insert_rr(struct regional* region, struct packed_rrset_data* pd,
- ldns_buffer* buf, uint32_t ttl)
+ uint8_t* rdata, size_t rdata_len, time_t ttl)
{
size_t* oldlen = pd->rr_len;
- uint32_t* oldttl = pd->rr_ttl;
+ time_t* oldttl = pd->rr_ttl;
uint8_t** olddata = pd->rr_data;
/* add RR to rrset */
@@ -379,10 +358,9 @@ insert_rr(struct regional* region, struct packed_rrset_data* pd,
memcpy(pd->rr_data+1, olddata,
sizeof(*pd->rr_data)*(pd->count-1));
}
- pd->rr_len[0] = ldns_buffer_limit(buf);
+ pd->rr_len[0] = rdata_len;
pd->rr_ttl[0] = ttl;
- pd->rr_data[0] = regional_alloc_init(region,
- ldns_buffer_begin(buf), ldns_buffer_limit(buf));
+ pd->rr_data[0] = regional_alloc_init(region, rdata, rdata_len);
if(!pd->rr_data[0]) {
log_err("out of memory");
return 0;
@@ -440,8 +418,7 @@ lz_find_create_node(struct local_zone* z, uint8_t* nm, size_t nmlen,
/** enter data RR into auth zone */
static int
-lz_enter_rr_into_zone(struct local_zone* z, ldns_buffer* buf,
- const char* rrstr)
+lz_enter_rr_into_zone(struct local_zone* z, const char* rrstr)
{
uint8_t* nm;
size_t nmlen;
@@ -450,8 +427,12 @@ lz_enter_rr_into_zone(struct local_zone* z, ldns_buffer* buf,
struct local_rrset* rrset;
struct packed_rrset_data* pd;
uint16_t rrtype = 0, rrclass = 0;
- uint32_t ttl = 0;
- if(!get_rr_content(rrstr, &nm, &rrtype, &rrclass, &ttl, buf)) {
+ time_t ttl = 0;
+ uint8_t rr[LDNS_RR_BUF_SIZE];
+ uint8_t* rdata;
+ size_t rdata_len;
+ if(!get_rr_content(rrstr, &nm, &rrtype, &rrclass, &ttl, rr, sizeof(rr),
+ &rdata, &rdata_len)) {
log_err("bad local-data: %s", rrstr);
return 0;
}
@@ -487,16 +468,16 @@ lz_enter_rr_into_zone(struct local_zone* z, ldns_buffer* buf,
log_assert(rrset && pd);
/* check for duplicate RR */
- if(rr_is_duplicate(pd, buf)) {
+ if(rr_is_duplicate(pd, rdata, rdata_len)) {
verbose(VERB_ALGO, "ignoring duplicate RR: %s", rrstr);
return 1;
}
- return insert_rr(z->region, pd, buf, ttl);
+ return insert_rr(z->region, pd, rdata, rdata_len, ttl);
}
/** enter a data RR into auth data; a zone for it must exist */
static int
-lz_enter_rr_str(struct local_zones* zones, const char* rr, ldns_buffer* buf)
+lz_enter_rr_str(struct local_zones* zones, const char* rr)
{
uint8_t* rr_name;
uint16_t rr_class;
@@ -509,16 +490,16 @@ lz_enter_rr_str(struct local_zones* zones, const char* rr, ldns_buffer* buf)
return 0;
}
labs = dname_count_size_labels(rr_name, &len);
- lock_quick_lock(&zones->lock);
+ lock_rw_rdlock(&zones->lock);
z = local_zones_lookup(zones, rr_name, len, labs, rr_class);
if(!z) {
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
fatal_exit("internal error: no zone for rr %s", rr);
}
lock_rw_wrlock(&z->lock);
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
free(rr_name);
- r = lz_enter_rr_into_zone(z, buf, rr);
+ r = lz_enter_rr_into_zone(z, rr);
lock_rw_unlock(&z->lock);
return r;
}
@@ -549,13 +530,13 @@ lz_exists(struct local_zones* zones, const char* name)
log_err("bad name %s", name);
return 0;
}
- lock_quick_lock(&zones->lock);
+ lock_rw_rdlock(&zones->lock);
if(rbtree_search(&zones->ztree, &z.node)) {
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
free(z.name);
return 1;
}
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
free(z.name);
return 0;
}
@@ -582,7 +563,7 @@ lz_nodefault(struct config_file* cfg, const char* name)
/** enter AS112 default zone */
static int
add_as112_default(struct local_zones* zones, struct config_file* cfg,
- ldns_buffer* buf, const char* name)
+ const char* name)
{
struct local_zone* z;
char str[1024]; /* known long enough */
@@ -592,12 +573,12 @@ add_as112_default(struct local_zones* zones, struct config_file* cfg,
return 0;
snprintf(str, sizeof(str), "%s 10800 IN SOA localhost. "
"nobody.invalid. 1 3600 1200 604800 10800", name);
- if(!lz_enter_rr_into_zone(z, buf, str)) {
+ if(!lz_enter_rr_into_zone(z, str)) {
lock_rw_unlock(&z->lock);
return 0;
}
snprintf(str, sizeof(str), "%s 10800 IN NS localhost. ", name);
- if(!lz_enter_rr_into_zone(z, buf, str)) {
+ if(!lz_enter_rr_into_zone(z, str)) {
lock_rw_unlock(&z->lock);
return 0;
}
@@ -607,26 +588,27 @@ add_as112_default(struct local_zones* zones, struct config_file* cfg,
/** enter default zones */
static int
-lz_enter_defaults(struct local_zones* zones, struct config_file* cfg,
- ldns_buffer* buf)
+lz_enter_defaults(struct local_zones* zones, struct config_file* cfg)
{
struct local_zone* z;
/* this list of zones is from RFC 6303 */
+ /* block localhost level zones, first, later the LAN zones */
+
/* localhost. zone */
if(!lz_exists(zones, "localhost.") &&
!lz_nodefault(cfg, "localhost.")) {
if(!(z=lz_enter_zone(zones, "localhost.", "static",
LDNS_RR_CLASS_IN)) ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"localhost. 10800 IN NS localhost.") ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"localhost. 10800 IN SOA localhost. nobody.invalid. "
"1 3600 1200 604800 10800") ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"localhost. 10800 IN A 127.0.0.1") ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"localhost. 10800 IN AAAA ::1")) {
log_err("out of memory adding default zone");
if(z) { lock_rw_unlock(&z->lock); }
@@ -639,12 +621,12 @@ lz_enter_defaults(struct local_zones* zones, struct config_file* cfg,
!lz_nodefault(cfg, "127.in-addr.arpa.")) {
if(!(z=lz_enter_zone(zones, "127.in-addr.arpa.", "static",
LDNS_RR_CLASS_IN)) ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"127.in-addr.arpa. 10800 IN NS localhost.") ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"127.in-addr.arpa. 10800 IN SOA localhost. "
"nobody.invalid. 1 3600 1200 604800 10800") ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"1.0.0.127.in-addr.arpa. 10800 IN PTR localhost.")) {
log_err("out of memory adding default zone");
if(z) { lock_rw_unlock(&z->lock); }
@@ -657,12 +639,12 @@ lz_enter_defaults(struct local_zones* zones, struct config_file* cfg,
!lz_nodefault(cfg, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.")) {
if(!(z=lz_enter_zone(zones, "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.", "static",
LDNS_RR_CLASS_IN)) ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. 10800 IN NS localhost.") ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. 10800 IN SOA localhost. "
"nobody.invalid. 1 3600 1200 604800 10800") ||
- !lz_enter_rr_into_zone(z, buf,
+ !lz_enter_rr_into_zone(z,
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa. 10800 IN PTR localhost.")) {
log_err("out of memory adding default zone");
if(z) { lock_rw_unlock(&z->lock); }
@@ -670,37 +652,45 @@ lz_enter_defaults(struct local_zones* zones, struct config_file* cfg,
}
lock_rw_unlock(&z->lock);
}
- if ( !add_as112_default(zones, cfg, buf, "10.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "16.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "17.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "18.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "19.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "20.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "21.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "22.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "23.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "24.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "25.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "26.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "27.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "28.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "29.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "30.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "31.172.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "168.192.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "0.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "254.169.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "2.0.192.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "100.51.198.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "113.0.203.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "255.255.255.255.in-addr.arpa.") ||
- !add_as112_default(zones, cfg, buf, "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.") ||
- !add_as112_default(zones, cfg, buf, "d.f.ip6.arpa.") ||
- !add_as112_default(zones, cfg, buf, "8.e.f.ip6.arpa.") ||
- !add_as112_default(zones, cfg, buf, "9.e.f.ip6.arpa.") ||
- !add_as112_default(zones, cfg, buf, "a.e.f.ip6.arpa.") ||
- !add_as112_default(zones, cfg, buf, "b.e.f.ip6.arpa.") ||
- !add_as112_default(zones, cfg, buf, "8.b.d.0.1.0.0.2.ip6.arpa.")) {
+
+ /* if unblock lan-zones, then do not add the zones below.
+ * we do add the zones above, about 127.0.0.1, because localhost is
+ * not on the lan. */
+ if(cfg->unblock_lan_zones)
+ return 1;
+
+ /* block LAN level zones */
+ if ( !add_as112_default(zones, cfg, "10.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "16.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "17.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "18.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "19.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "20.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "21.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "22.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "23.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "24.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "25.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "26.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "27.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "28.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "29.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "30.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "31.172.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "168.192.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "0.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "254.169.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "2.0.192.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "100.51.198.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "113.0.203.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "255.255.255.255.in-addr.arpa.") ||
+ !add_as112_default(zones, cfg, "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa.") ||
+ !add_as112_default(zones, cfg, "d.f.ip6.arpa.") ||
+ !add_as112_default(zones, cfg, "8.e.f.ip6.arpa.") ||
+ !add_as112_default(zones, cfg, "9.e.f.ip6.arpa.") ||
+ !add_as112_default(zones, cfg, "a.e.f.ip6.arpa.") ||
+ !add_as112_default(zones, cfg, "b.e.f.ip6.arpa.") ||
+ !add_as112_default(zones, cfg, "8.b.d.0.1.0.0.2.ip6.arpa.")) {
log_err("out of memory adding default zone");
return 0;
}
@@ -713,7 +703,7 @@ init_parents(struct local_zones* zones)
{
struct local_zone* node, *prev = NULL, *p;
int m;
- lock_quick_lock(&zones->lock);
+ lock_rw_wrlock(&zones->lock);
RBTREE_FOR(node, struct local_zone*, &zones->ztree) {
lock_rw_wrlock(&node->lock);
node->parent = NULL;
@@ -738,7 +728,7 @@ init_parents(struct local_zones* zones)
prev = node;
lock_rw_unlock(&node->lock);
}
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
}
/** enter implicit transparent zone for local-data: without local-zone: */
@@ -768,7 +758,7 @@ lz_setup_implicit(struct local_zones* zones, struct config_file* cfg)
return 0;
}
labs = dname_count_size_labels(rr_name, &len);
- lock_quick_lock(&zones->lock);
+ lock_rw_rdlock(&zones->lock);
if(!local_zones_lookup(zones, rr_name, len, labs, rr_class)) {
if(!have_name) {
dclass = rr_class;
@@ -783,7 +773,7 @@ lz_setup_implicit(struct local_zones* zones, struct config_file* cfg)
/* process other classes later */
free(rr_name);
have_other_classes = 1;
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
continue;
}
/* find smallest shared topdomain */
@@ -794,7 +784,7 @@ lz_setup_implicit(struct local_zones* zones, struct config_file* cfg)
match = m;
}
} else free(rr_name);
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
}
if(have_name) {
uint8_t* n2;
@@ -825,12 +815,11 @@ lz_setup_implicit(struct local_zones* zones, struct config_file* cfg)
/** enter auth data */
static int
-lz_enter_data(struct local_zones* zones, struct config_file* cfg,
- ldns_buffer* buf)
+lz_enter_data(struct local_zones* zones, struct config_file* cfg)
{
struct config_strlist* p;
for(p = cfg->local_data; p; p = p->next) {
- if(!lz_enter_rr_str(zones, p->str, buf))
+ if(!lz_enter_rr_str(zones, p->str))
return 0;
}
return 1;
@@ -851,35 +840,27 @@ lz_freeup_cfg(struct config_file* cfg)
int
local_zones_apply_cfg(struct local_zones* zones, struct config_file* cfg)
{
- ldns_buffer* buf = ldns_buffer_new(65535);
- if(!buf) fatal_exit("cannot create temporary buffer");
-
/* create zones from zone statements. */
if(!lz_enter_zones(zones, cfg)) {
- ldns_buffer_free(buf);
return 0;
}
/* apply default zones+content (unless disabled, or overridden) */
- if(!lz_enter_defaults(zones, cfg, buf)) {
- ldns_buffer_free(buf);
+ if(!lz_enter_defaults(zones, cfg)) {
return 0;
}
/* create implicit transparent zone from data. */
if(!lz_setup_implicit(zones, cfg)) {
- ldns_buffer_free(buf);
return 0;
}
/* setup parent ptrs for lookup during data entry */
init_parents(zones);
/* insert local data */
- if(!lz_enter_data(zones, cfg, buf)) {
- ldns_buffer_free(buf);
+ if(!lz_enter_data(zones, cfg)) {
return 0;
}
/* freeup memory from cfg struct. */
lz_freeup_cfg(cfg);
- ldns_buffer_free(buf);
return 1;
}
@@ -948,7 +929,7 @@ local_zone_out(struct local_zone* z)
void local_zones_print(struct local_zones* zones)
{
struct local_zone* z;
- lock_quick_lock(&zones->lock);
+ lock_rw_rdlock(&zones->lock);
log_info("number of auth zones %u", (unsigned)zones->ztree.count);
RBTREE_FOR(z, struct local_zone*, &zones->ztree) {
lock_rw_rdlock(&z->lock);
@@ -985,13 +966,13 @@ void local_zones_print(struct local_zones* zones)
local_zone_out(z);
lock_rw_unlock(&z->lock);
}
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
}
/** encode answer consisting of 1 rrset */
static int
local_encode(struct query_info* qinfo, struct edns_data* edns,
- ldns_buffer* buf, struct regional* temp,
+ sldns_buffer* buf, struct regional* temp,
struct ub_packed_rrset_key* rrset, int ansec, int rcode)
{
struct reply_info rep;
@@ -1011,20 +992,20 @@ local_encode(struct query_info* qinfo, struct edns_data* edns,
edns->ext_rcode = 0;
edns->bits &= EDNS_DO;
if(!reply_info_answer_encode(qinfo, &rep,
- *(uint16_t*)ldns_buffer_begin(buf),
- ldns_buffer_read_u16_at(buf, 2),
+ *(uint16_t*)sldns_buffer_begin(buf),
+ sldns_buffer_read_u16_at(buf, 2),
buf, 0, 0, temp, udpsize, edns,
(int)(edns->bits&EDNS_DO), 0))
error_encode(buf, (LDNS_RCODE_SERVFAIL|BIT_AA), qinfo,
- *(uint16_t*)ldns_buffer_begin(buf),
- ldns_buffer_read_u16_at(buf, 2), edns);
+ *(uint16_t*)sldns_buffer_begin(buf),
+ sldns_buffer_read_u16_at(buf, 2), edns);
return 1;
}
/** answer local data match */
static int
local_data_answer(struct local_zone* z, struct query_info* qinfo,
- struct edns_data* edns, ldns_buffer* buf, struct regional* temp,
+ struct edns_data* edns, sldns_buffer* buf, struct regional* temp,
int labs, struct local_data** ldp)
{
struct local_data key;
@@ -1071,18 +1052,18 @@ local_data_answer(struct local_zone* z, struct query_info* qinfo,
*/
static int
lz_zone_answer(struct local_zone* z, struct query_info* qinfo,
- struct edns_data* edns, ldns_buffer* buf, struct regional* temp,
+ struct edns_data* edns, sldns_buffer* buf, struct regional* temp,
struct local_data* ld)
{
if(z->type == local_zone_deny) {
/** no reply at all, signal caller by clearing buffer. */
- ldns_buffer_clear(buf);
- ldns_buffer_flip(buf);
+ sldns_buffer_clear(buf);
+ sldns_buffer_flip(buf);
return 1;
} else if(z->type == local_zone_refuse) {
error_encode(buf, (LDNS_RCODE_REFUSED|BIT_AA), qinfo,
- *(uint16_t*)ldns_buffer_begin(buf),
- ldns_buffer_read_u16_at(buf, 2), edns);
+ *(uint16_t*)sldns_buffer_begin(buf),
+ sldns_buffer_read_u16_at(buf, 2), edns);
return 1;
} else if(z->type == local_zone_static ||
z->type == local_zone_redirect) {
@@ -1098,8 +1079,8 @@ lz_zone_answer(struct local_zone* z, struct query_info* qinfo,
return local_encode(qinfo, edns, buf, temp,
z->soa, 0, rcode);
error_encode(buf, (rcode|BIT_AA), qinfo,
- *(uint16_t*)ldns_buffer_begin(buf),
- ldns_buffer_read_u16_at(buf, 2), edns);
+ *(uint16_t*)sldns_buffer_begin(buf),
+ sldns_buffer_read_u16_at(buf, 2), edns);
return 1;
} else if(z->type == local_zone_typetransparent) {
/* no NODATA or NXDOMAINS for this zone type */
@@ -1115,8 +1096,8 @@ lz_zone_answer(struct local_zone* z, struct query_info* qinfo,
return local_encode(qinfo, edns, buf, temp,
z->soa, 0, rcode);
error_encode(buf, (rcode|BIT_AA), qinfo,
- *(uint16_t*)ldns_buffer_begin(buf),
- ldns_buffer_read_u16_at(buf, 2), edns);
+ *(uint16_t*)sldns_buffer_begin(buf),
+ sldns_buffer_read_u16_at(buf, 2), edns);
return 1;
}
@@ -1126,7 +1107,7 @@ lz_zone_answer(struct local_zone* z, struct query_info* qinfo,
int
local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
- struct edns_data* edns, ldns_buffer* buf, struct regional* temp)
+ struct edns_data* edns, sldns_buffer* buf, struct regional* temp)
{
/* see if query is covered by a zone,
* if so: - try to match (exact) local data
@@ -1135,15 +1116,15 @@ local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
struct local_data* ld;
struct local_zone* z;
int r;
- lock_quick_lock(&zones->lock);
+ lock_rw_rdlock(&zones->lock);
z = local_zones_lookup(zones, qinfo->qname,
qinfo->qname_len, labs, qinfo->qclass);
if(!z) {
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
return 0;
}
lock_rw_rdlock(&z->lock);
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
if(local_data_answer(z, qinfo, edns, buf, temp, labs, &ld)) {
lock_rw_unlock(&z->lock);
@@ -1255,7 +1236,7 @@ void local_zones_del_zone(struct local_zones* zones, struct local_zone* z)
}
int
-local_zones_add_RR(struct local_zones* zones, const char* rr, ldns_buffer* buf)
+local_zones_add_RR(struct local_zones* zones, const char* rr)
{
uint8_t* rr_name;
uint16_t rr_class;
@@ -1267,21 +1248,23 @@ local_zones_add_RR(struct local_zones* zones, const char* rr, ldns_buffer* buf)
return 0;
}
labs = dname_count_size_labels(rr_name, &len);
- lock_quick_lock(&zones->lock);
+ /* could first try readlock then get writelock if zone does not exist,
+ * but we do not add enough RRs (from multiple threads) to optimize */
+ lock_rw_wrlock(&zones->lock);
z = local_zones_lookup(zones, rr_name, len, labs, rr_class);
if(!z) {
z = local_zones_add_zone(zones, rr_name, len, labs, rr_class,
local_zone_transparent);
if(!z) {
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
return 0;
}
} else {
free(rr_name);
}
lock_rw_wrlock(&z->lock);
- lock_quick_unlock(&zones->lock);
- r = lz_enter_rr_into_zone(z, buf, rr);
+ lock_rw_unlock(&zones->lock);
+ r = lz_enter_rr_into_zone(z, rr);
lock_rw_unlock(&z->lock);
return r;
}
@@ -1326,15 +1309,15 @@ void local_zones_del_data(struct local_zones* zones,
/* find zone */
struct local_zone* z;
struct local_data* d;
- lock_quick_lock(&zones->lock);
+ lock_rw_rdlock(&zones->lock);
z = local_zones_lookup(zones, name, len, labs, dclass);
if(!z) {
/* no such zone, we're done */
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
return;
}
lock_rw_wrlock(&z->lock);
- lock_quick_unlock(&zones->lock);
+ lock_rw_unlock(&zones->lock);
/* find the domain */
d = lz_find_node(z, name, len, labs);
diff --git a/contrib/unbound/services/localzone.h b/contrib/unbound/services/localzone.h
index 794988e..788fbfb 100644
--- a/contrib/unbound/services/localzone.h
+++ b/contrib/unbound/services/localzone.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -48,6 +48,7 @@ struct regional;
struct config_file;
struct edns_data;
struct query_info;
+struct sldns_buffer;
/**
* Local zone type
@@ -77,7 +78,7 @@ enum localzone_type {
*/
struct local_zones {
/** lock on the localzone tree */
- lock_quick_t lock;
+ lock_rw_t lock;
/** rbtree of struct local_zone */
rbtree_t ztree;
};
@@ -224,7 +225,7 @@ void local_zones_print(struct local_zones* zones);
* value is true, but the buffer is cleared (empty).
*/
int local_zones_answer(struct local_zones* zones, struct query_info* qinfo,
- struct edns_data* edns, ldns_buffer* buf, struct regional* temp);
+ struct edns_data* edns, struct sldns_buffer* buf, struct regional* temp);
/**
* Parse the string into localzone type.
@@ -286,11 +287,9 @@ void local_zones_del_zone(struct local_zones* zones, struct local_zone* zone);
* name of the RR is created.
* @param zones: the zones tree. Not locked by caller.
* @param rr: string with on RR.
- * @param buf: buffer for scratch.
* @return false on failure.
*/
-int local_zones_add_RR(struct local_zones* zones, const char* rr,
- ldns_buffer* buf);
+int local_zones_add_RR(struct local_zones* zones, const char* rr);
/**
* Remove data from domain name in the tree.
diff --git a/contrib/unbound/services/mesh.c b/contrib/unbound/services/mesh.c
index 5c66caf..bc711d9 100644
--- a/contrib/unbound/services/mesh.c
+++ b/contrib/unbound/services/mesh.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -43,7 +43,6 @@
* send back to clients.
*/
#include "config.h"
-#include <ldns/wire2host.h>
#include "services/mesh.h"
#include "services/outbound_list.h"
#include "services/cache/dns.h"
@@ -56,6 +55,7 @@
#include "util/fptr_wlist.h"
#include "util/alloc.h"
#include "util/config_file.h"
+#include "ldns/sbuffer.h"
/** subtract timers and the values do not overflow or become negative */
static void
@@ -162,7 +162,7 @@ mesh_create(struct module_stack* stack, struct module_env* env)
return NULL;
}
mesh->histogram = timehist_setup();
- mesh->qbuf_bak = ldns_buffer_new(env->cfg->msg_buffer_size);
+ mesh->qbuf_bak = sldns_buffer_new(env->cfg->msg_buffer_size);
if(!mesh->histogram || !mesh->qbuf_bak) {
free(mesh);
log_err("mesh area alloc: out of memory");
@@ -210,7 +210,7 @@ mesh_delete(struct mesh_area* mesh)
while(mesh->all.count)
mesh_delete_helper(mesh->all.root);
timehist_delete(mesh->histogram);
- ldns_buffer_free(mesh->qbuf_bak);
+ sldns_buffer_free(mesh->qbuf_bak);
free(mesh);
}
@@ -234,7 +234,7 @@ mesh_delete_all(struct mesh_area* mesh)
mesh->jostle_last = NULL;
}
-int mesh_make_new_space(struct mesh_area* mesh, ldns_buffer* qbuf)
+int mesh_make_new_space(struct mesh_area* mesh, sldns_buffer* qbuf)
{
struct mesh_state* m = mesh->jostle_first;
/* free space is available */
@@ -253,7 +253,7 @@ int mesh_make_new_space(struct mesh_area* mesh, ldns_buffer* qbuf)
m->s.qinfo.qname, m->s.qinfo.qtype,
m->s.qinfo.qclass);
/* backup the query */
- if(qbuf) ldns_buffer_copy(mesh->qbuf_bak, qbuf);
+ if(qbuf) sldns_buffer_copy(mesh->qbuf_bak, qbuf);
/* notify supers */
if(m->super_set.count > 0) {
verbose(VERB_ALGO, "notify supers of failure");
@@ -265,7 +265,7 @@ int mesh_make_new_space(struct mesh_area* mesh, ldns_buffer* qbuf)
mesh_state_delete(&m->s);
/* restore the query - note that the qinfo ptr to
* the querybuffer is then correct again. */
- if(qbuf) ldns_buffer_copy(qbuf, mesh->qbuf_bak);
+ if(qbuf) sldns_buffer_copy(qbuf, mesh->qbuf_bak);
return 1;
}
}
@@ -321,6 +321,8 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
}
#ifdef UNBOUND_DEBUG
n =
+#else
+ (void)
#endif
rbtree_insert(&mesh->all, &s->node);
log_assert(n != NULL);
@@ -370,7 +372,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
int
mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
- uint16_t qflags, struct edns_data* edns, ldns_buffer* buf,
+ uint16_t qflags, struct edns_data* edns, sldns_buffer* buf,
uint16_t qid, mesh_cb_func_t cb, void* cb_arg)
{
struct mesh_state* s = mesh_area_find(mesh, qinfo, qflags&BIT_RD, 0);
@@ -390,6 +392,8 @@ mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
}
#ifdef UNBOUND_DEBUG
n =
+#else
+ (void)
#endif
rbtree_insert(&mesh->all, &s->node);
log_assert(n != NULL);
@@ -422,7 +426,7 @@ mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
}
void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo,
- uint16_t qflags, uint32_t leeway)
+ uint16_t qflags, time_t leeway)
{
struct mesh_state* s = mesh_area_find(mesh, qinfo, qflags&BIT_RD, 0);
#ifdef UNBOUND_DEBUG
@@ -450,6 +454,8 @@ void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo,
}
#ifdef UNBOUND_DEBUG
n =
+#else
+ (void)
#endif
rbtree_insert(&mesh->all, &s->node);
log_assert(n != NULL);
@@ -657,6 +663,8 @@ void mesh_detach_subs(struct module_qstate* qstate)
RBTREE_FOR(ref, struct mesh_state_ref*, &qstate->mesh_info->sub_set) {
#ifdef UNBOUND_DEBUG
n =
+#else
+ (void)
#endif
rbtree_delete(&ref->s->super_set, &lookup);
log_assert(n != NULL); /* must have been present */
@@ -693,6 +701,8 @@ int mesh_attach_sub(struct module_qstate* qstate, struct query_info* qinfo,
}
#ifdef UNBOUND_DEBUG
n =
+#else
+ (void)
#endif
rbtree_insert(&mesh->all, &sub->node);
log_assert(n != NULL);
@@ -701,6 +711,8 @@ int mesh_attach_sub(struct module_qstate* qstate, struct query_info* qinfo,
/* set new query state to run */
#ifdef UNBOUND_DEBUG
n =
+#else
+ (void)
#endif
rbtree_insert(&mesh->run, &sub->run_node);
log_assert(n != NULL);
@@ -749,6 +761,8 @@ int mesh_state_attachment(struct mesh_state* super, struct mesh_state* sub)
}
#ifdef UNBOUND_DEBUG
n =
+#else
+ (void)
#endif
rbtree_insert(&super->sub_set, &subref->node);
log_assert(n != NULL); /* we checked above if statement, the reverse
@@ -786,7 +800,7 @@ mesh_do_callback(struct mesh_state* m, int rcode, struct reply_info* rep,
(*r->cb)(r->cb_arg, rcode, r->buf, sec_status_unchecked, NULL);
} else {
size_t udp_size = r->edns.udp_size;
- ldns_buffer_clear(r->buf);
+ sldns_buffer_clear(r->buf);
r->edns.edns_version = EDNS_ADVERTISED_VERSION;
r->edns.udp_size = EDNS_ADVERTISED_SIZE;
r->edns.ext_rcode = 0;
@@ -844,11 +858,11 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
prev->edns.udp_size == r->edns.udp_size) {
/* if the previous reply is identical to this one, fix ID */
if(prev->query_reply.c->buffer != r->query_reply.c->buffer)
- ldns_buffer_copy(r->query_reply.c->buffer,
+ sldns_buffer_copy(r->query_reply.c->buffer,
prev->query_reply.c->buffer);
- ldns_buffer_write_at(r->query_reply.c->buffer, 0,
+ sldns_buffer_write_at(r->query_reply.c->buffer, 0,
&r->qid, sizeof(uint16_t));
- ldns_buffer_write_at(r->query_reply.c->buffer, 12,
+ sldns_buffer_write_at(r->query_reply.c->buffer, 12,
r->qname, m->s.qinfo.qname_len);
comm_point_send_reply(&r->query_reply);
} else if(rcode) {
@@ -878,17 +892,17 @@ mesh_send_reply(struct mesh_state* m, int rcode, struct reply_info* rep,
m->s.env->mesh->num_reply_addrs--;
end_time = *m->s.env->now_tv;
timeval_subtract(&duration, &end_time, &r->start_time);
- verbose(VERB_ALGO, "query took %d.%6.6d sec",
- (int)duration.tv_sec, (int)duration.tv_usec);
+ verbose(VERB_ALGO, "query took " ARG_LL "d.%6.6d sec",
+ (long long)duration.tv_sec, (int)duration.tv_usec);
m->s.env->mesh->replies_sent++;
timeval_add(&m->s.env->mesh->replies_sum_wait, &duration);
timehist_insert(m->s.env->mesh->histogram, &duration);
if(m->s.env->cfg->stat_extended) {
- uint16_t rc = FLAGS_GET_RCODE(ldns_buffer_read_u16_at(r->
+ uint16_t rc = FLAGS_GET_RCODE(sldns_buffer_read_u16_at(r->
query_reply.c->buffer, 2));
if(secure) m->s.env->mesh->ans_secure++;
m->s.env->mesh->ans_rcode[ rc ] ++;
- if(rc == 0 && LDNS_ANCOUNT(ldns_buffer_begin(r->
+ if(rc == 0 && LDNS_ANCOUNT(sldns_buffer_begin(r->
query_reply.c->buffer)) == 0)
m->s.env->mesh->ans_nodata++;
}
@@ -942,7 +956,7 @@ struct mesh_state* mesh_area_find(struct mesh_area* mesh,
}
int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
- ldns_buffer* buf, mesh_cb_func_t cb, void* cb_arg,
+ sldns_buffer* buf, mesh_cb_func_t cb, void* cb_arg,
uint16_t qid, uint16_t qflags)
{
struct mesh_cb* r = regional_alloc(s->s.region,
@@ -1124,7 +1138,8 @@ mesh_stats(struct mesh_area* mesh, const char* str)
timeval_divide(&avg, &mesh->replies_sum_wait,
mesh->replies_sent);
log_info("average recursion processing time "
- "%d.%6.6d sec", (int)avg.tv_sec, (int)avg.tv_usec);
+ ARG_LL "d.%6.6d sec",
+ (long long)avg.tv_sec, (int)avg.tv_usec);
log_info("histogram of recursion processing times");
timehist_log(mesh->histogram, "recursions");
}
@@ -1153,7 +1168,7 @@ mesh_get_mem(struct mesh_area* mesh)
struct mesh_state* m;
size_t s = sizeof(*mesh) + sizeof(struct timehist) +
sizeof(struct th_buck)*mesh->histogram->num +
- sizeof(ldns_buffer) + ldns_buffer_capacity(mesh->qbuf_bak);
+ sizeof(sldns_buffer) + sldns_buffer_capacity(mesh->qbuf_bak);
RBTREE_FOR(m, struct mesh_state*, &mesh->all) {
/* all, including m itself allocated in qstate region */
s += regional_get_mem(m->s.region);
diff --git a/contrib/unbound/services/mesh.h b/contrib/unbound/services/mesh.h
index 5f10977..fbfbbcb 100644
--- a/contrib/unbound/services/mesh.h
+++ b/contrib/unbound/services/mesh.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -51,6 +51,7 @@
#include "util/data/msgparse.h"
#include "util/module.h"
#include "services/modstack.h"
+struct sldns_buffer;
struct mesh_state;
struct mesh_reply;
struct mesh_cb;
@@ -125,7 +126,7 @@ struct mesh_area {
/** backup of query if other operations recurse and need the
* network buffers */
- ldns_buffer* qbuf_bak;
+ struct sldns_buffer* qbuf_bak;
/** double linked list of the run-to-completion query states.
* These are query states with a reply */
@@ -219,7 +220,7 @@ struct mesh_reply {
* Mesh result callback func.
* called as func(cb_arg, rcode, buffer_with_reply, security, why_bogus);
*/
-typedef void (*mesh_cb_func_t)(void*, int, ldns_buffer*, enum sec_status,
+typedef void (*mesh_cb_func_t)(void*, int, struct sldns_buffer*, enum sec_status,
char*);
/**
@@ -235,7 +236,7 @@ struct mesh_cb {
/** flags of query, for reply flags */
uint16_t qflags;
/** buffer for reply */
- ldns_buffer* buf;
+ struct sldns_buffer* buf;
/** callback routine for results. if rcode != 0 buf has message.
* called as cb(cb_arg, rcode, buf, sec_state);
@@ -294,7 +295,7 @@ void mesh_new_client(struct mesh_area* mesh, struct query_info* qinfo,
* @return 0 on error.
*/
int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
- uint16_t qflags, struct edns_data* edns, ldns_buffer* buf,
+ uint16_t qflags, struct edns_data* edns, struct sldns_buffer* buf,
uint16_t qid, mesh_cb_func_t cb, void* cb_arg);
/**
@@ -307,7 +308,7 @@ int mesh_new_callback(struct mesh_area* mesh, struct query_info* qinfo,
* @param leeway: TTL leeway what to expire earlier for this update.
*/
void mesh_new_prefetch(struct mesh_area* mesh, struct query_info* qinfo,
- uint16_t qflags, uint32_t leeway);
+ uint16_t qflags, time_t leeway);
/**
* Handle new event from the wire. A serviced query has returned.
@@ -473,7 +474,7 @@ int mesh_state_add_reply(struct mesh_state* s, struct edns_data* edns,
* @return: 0 on alloc error.
*/
int mesh_state_add_cb(struct mesh_state* s, struct edns_data* edns,
- ldns_buffer* buf, mesh_cb_func_t cb, void* cb_arg, uint16_t qid,
+ struct sldns_buffer* buf, mesh_cb_func_t cb, void* cb_arg, uint16_t qid,
uint16_t qflags);
/**
@@ -548,7 +549,7 @@ int mesh_state_ref_compare(const void* ap, const void* bp);
* You can pass NULL if there is no buffer that must be backed up.
* @return false if no space is available.
*/
-int mesh_make_new_space(struct mesh_area* mesh, ldns_buffer* qbuf);
+int mesh_make_new_space(struct mesh_area* mesh, struct sldns_buffer* qbuf);
/**
* Insert mesh state into a double linked list. Inserted at end.
diff --git a/contrib/unbound/services/modstack.c b/contrib/unbound/services/modstack.c
index 7395598..56515a6 100644
--- a/contrib/unbound/services/modstack.c
+++ b/contrib/unbound/services/modstack.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/services/modstack.h b/contrib/unbound/services/modstack.h
index 869b593..cb86132 100644
--- a/contrib/unbound/services/modstack.h
+++ b/contrib/unbound/services/modstack.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/services/outbound_list.c b/contrib/unbound/services/outbound_list.c
index be49149..ad73380 100644
--- a/contrib/unbound/services/outbound_list.c
+++ b/contrib/unbound/services/outbound_list.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/services/outbound_list.h b/contrib/unbound/services/outbound_list.h
index 5631910..ad59e42 100644
--- a/contrib/unbound/services/outbound_list.h
+++ b/contrib/unbound/services/outbound_list.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/services/outside_network.c b/contrib/unbound/services/outside_network.c
index e1cd0fd..fedbd0f 100644
--- a/contrib/unbound/services/outside_network.c
+++ b/contrib/unbound/services/outside_network.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -45,7 +45,6 @@
# include <sys/types.h>
#endif
#include <sys/time.h>
-#include <ldns/wire2host.h>
#include "services/outside_network.h"
#include "services/listen_dnsport.h"
#include "services/cache/infra.h"
@@ -58,6 +57,7 @@
#include "util/net_help.h"
#include "util/random.h"
#include "util/fptr_wlist.h"
+#include "ldns/sbuffer.h"
#ifdef HAVE_OPENSSL_SSL_H
#include <openssl/ssl.h>
#endif
@@ -76,10 +76,10 @@
/** initiate TCP transaction for serviced query */
static void serviced_tcp_initiate(struct outside_network* outnet,
- struct serviced_query* sq, ldns_buffer* buff);
+ struct serviced_query* sq, sldns_buffer* buff);
/** with a fd available, randomize and send UDP */
static int randomize_and_send_udp(struct outside_network* outnet,
- struct pending* pend, ldns_buffer* packet, int timeout);
+ struct pending* pend, sldns_buffer* packet, int timeout);
int
pending_cmp(const void* key1, const void* key2)
@@ -263,9 +263,9 @@ outnet_tcp_take_into_use(struct waiting_tcp* w, uint8_t* pkt, size_t pkt_len)
pend->query = w;
pend->c->repinfo.addrlen = w->addrlen;
memcpy(&pend->c->repinfo.addr, &w->addr, w->addrlen);
- ldns_buffer_clear(pend->c->buffer);
- ldns_buffer_write(pend->c->buffer, pkt, pkt_len);
- ldns_buffer_flip(pend->c->buffer);
+ sldns_buffer_clear(pend->c->buffer);
+ sldns_buffer_write(pend->c->buffer, pkt, pkt_len);
+ sldns_buffer_flip(pend->c->buffer);
pend->c->tcp_is_reading = 0;
pend->c->tcp_byte_count = 0;
comm_point_start_listening(pend->c, s, -1);
@@ -325,8 +325,8 @@ outnet_tcp_cb(struct comm_point* c, void* arg, int error,
/* pass error below and exit */
} else {
/* check ID */
- if(ldns_buffer_limit(c->buffer) < sizeof(uint16_t) ||
- LDNS_ID_WIRE(ldns_buffer_begin(c->buffer))!=pend->id) {
+ if(sldns_buffer_limit(c->buffer) < sizeof(uint16_t) ||
+ LDNS_ID_WIRE(sldns_buffer_begin(c->buffer))!=pend->id) {
log_addr(VERB_QUERY,
"outnettcp: bad ID in reply, from:",
&pend->query->addr, pend->query->addrlen);
@@ -372,18 +372,20 @@ outnet_send_wait_udp(struct outside_network* outnet)
pend = outnet->udp_wait_first;
outnet->udp_wait_first = pend->next_waiting;
if(!pend->next_waiting) outnet->udp_wait_last = NULL;
- ldns_buffer_clear(outnet->udp_buff);
- ldns_buffer_write(outnet->udp_buff, pend->pkt, pend->pkt_len);
- ldns_buffer_flip(outnet->udp_buff);
+ sldns_buffer_clear(outnet->udp_buff);
+ sldns_buffer_write(outnet->udp_buff, pend->pkt, pend->pkt_len);
+ sldns_buffer_flip(outnet->udp_buff);
free(pend->pkt); /* freeing now makes get_mem correct */
pend->pkt = NULL;
pend->pkt_len = 0;
if(!randomize_and_send_udp(outnet, pend, outnet->udp_buff,
pend->timeout)) {
/* callback error on pending */
- fptr_ok(fptr_whitelist_pending_udp(pend->cb));
- (void)(*pend->cb)(outnet->unused_fds->cp, pend->cb_arg,
- NETEVENT_CLOSED, NULL);
+ if(pend->cb) {
+ fptr_ok(fptr_whitelist_pending_udp(pend->cb));
+ (void)(*pend->cb)(outnet->unused_fds->cp, pend->cb_arg,
+ NETEVENT_CLOSED, NULL);
+ }
pending_delete(outnet, pend);
}
}
@@ -402,14 +404,14 @@ outnet_udp_cb(struct comm_point* c, void* arg, int error,
verbose(VERB_QUERY, "outnetudp got udp error %d", error);
return 0;
}
- if(ldns_buffer_limit(c->buffer) < LDNS_HEADER_SIZE) {
+ if(sldns_buffer_limit(c->buffer) < LDNS_HEADER_SIZE) {
verbose(VERB_QUERY, "outnetudp udp too short");
return 0;
}
log_assert(reply_info);
/* setup lookup key */
- key.id = (unsigned)LDNS_ID_WIRE(ldns_buffer_begin(c->buffer));
+ key.id = (unsigned)LDNS_ID_WIRE(sldns_buffer_begin(c->buffer));
memcpy(&key.addr, &reply_info->addr, reply_info->addrlen);
key.addrlen = reply_info->addrlen;
verbose(VERB_ALGO, "Incoming reply id = %4.4x", key.id);
@@ -460,8 +462,10 @@ outnet_udp_cb(struct comm_point* c, void* arg, int error,
verbose(VERB_ALGO, "outnet handle udp reply");
/* delete from tree first in case callback creates a retry */
(void)rbtree_delete(outnet->pending, p->node.key);
- fptr_ok(fptr_whitelist_pending_udp(p->cb));
- (void)(*p->cb)(p->pc->cp, p->cb_arg, NETEVENT_NOERROR, reply_info);
+ if(p->cb) {
+ fptr_ok(fptr_whitelist_pending_udp(p->cb));
+ (void)(*p->cb)(p->pc->cp, p->cb_arg, NETEVENT_NOERROR, reply_info);
+ }
portcomm_loweruse(outnet, p->pc);
pending_delete(NULL, p);
outnet_send_wait_udp(outnet);
@@ -496,6 +500,17 @@ calc_num46(char** ifs, int num_ifs, int do_ip4, int do_ip6,
}
+void
+pending_udp_timer_delay_cb(void* arg)
+{
+ struct pending* p = (struct pending*)arg;
+ struct outside_network* outnet = p->outnet;
+ verbose(VERB_ALGO, "timeout udp with delay");
+ portcomm_loweruse(outnet, p->pc);
+ pending_delete(outnet, p);
+ outnet_send_wait_udp(outnet);
+}
+
void
pending_udp_timer_cb(void *arg)
{
@@ -503,8 +518,20 @@ pending_udp_timer_cb(void *arg)
struct outside_network* outnet = p->outnet;
/* it timed out */
verbose(VERB_ALGO, "timeout udp");
- fptr_ok(fptr_whitelist_pending_udp(p->cb));
- (void)(*p->cb)(p->pc->cp, p->cb_arg, NETEVENT_TIMEOUT, NULL);
+ if(p->cb) {
+ fptr_ok(fptr_whitelist_pending_udp(p->cb));
+ (void)(*p->cb)(p->pc->cp, p->cb_arg, NETEVENT_TIMEOUT, NULL);
+ }
+ /* if delayclose, keep port open for a longer time.
+ * But if the udpwaitlist exists, then we are struggling to
+ * keep up with demand for sockets, so do not wait, but service
+ * the customer (customer service more important than portICMPs) */
+ if(outnet->delayclose && !outnet->udp_wait_first) {
+ p->cb = NULL;
+ p->timer->callback = &pending_udp_timer_delay_cb;
+ comm_timer_set(p->timer, &outnet->delay_tv);
+ return;
+ }
portcomm_loweruse(outnet, p->pc);
pending_delete(outnet, p);
outnet_send_wait_udp(outnet);
@@ -561,7 +588,7 @@ outside_network_create(struct comm_base *base, size_t bufsize,
struct ub_randstate* rnd, int use_caps_for_id, int* availports,
int numavailports, size_t unwanted_threshold,
void (*unwanted_action)(void*), void* unwanted_param, int do_udp,
- void* sslctx)
+ void* sslctx, int delayclose)
{
struct outside_network* outnet = (struct outside_network*)
calloc(1, sizeof(struct outside_network));
@@ -583,6 +610,13 @@ outside_network_create(struct comm_base *base, size_t bufsize,
outnet->unwanted_param = unwanted_param;
outnet->use_caps_for_id = use_caps_for_id;
outnet->do_udp = do_udp;
+#ifndef S_SPLINT_S
+ if(delayclose) {
+ outnet->delayclose = 1;
+ outnet->delay_tv.tv_sec = delayclose/1000;
+ outnet->delay_tv.tv_usec = (delayclose%1000)*1000;
+ }
+#endif
if(numavailports == 0) {
log_err("no outgoing ports available");
outside_network_delete(outnet);
@@ -609,7 +643,7 @@ outside_network_create(struct comm_base *base, size_t bufsize,
return NULL;
}
}
- if( !(outnet->udp_buff = ldns_buffer_new(bufsize)) ||
+ if( !(outnet->udp_buff = sldns_buffer_new(bufsize)) ||
!(outnet->pending = rbtree_create(pending_cmp)) ||
!(outnet->serviced = rbtree_create(serviced_cmp)) ||
!create_pending_tcp(outnet, bufsize)) {
@@ -731,7 +765,7 @@ outside_network_delete(struct outside_network* outnet)
free(outnet->serviced);
}
if(outnet->udp_buff)
- ldns_buffer_free(outnet->udp_buff);
+ sldns_buffer_free(outnet->udp_buff);
if(outnet->unused_fds) {
struct port_comm* p = outnet->unused_fds, *np;
while(p) {
@@ -849,13 +883,13 @@ udp_sockport(struct sockaddr_storage* addr, socklen_t addrlen, int port,
sa->sin6_port = (in_port_t)htons((uint16_t)port);
fd = create_udp_sock(AF_INET6, SOCK_DGRAM,
(struct sockaddr*)addr, addrlen, 1, inuse, &noproto,
- 0, 0);
+ 0, 0, 0, NULL);
} else {
struct sockaddr_in* sa = (struct sockaddr_in*)addr;
sa->sin_port = (in_port_t)htons((uint16_t)port);
fd = create_udp_sock(AF_INET, SOCK_DGRAM,
(struct sockaddr*)addr, addrlen, 1, inuse, &noproto,
- 0, 0);
+ 0, 0, 0, NULL);
}
return fd;
}
@@ -863,18 +897,18 @@ udp_sockport(struct sockaddr_storage* addr, socklen_t addrlen, int port,
/** Select random ID */
static int
select_id(struct outside_network* outnet, struct pending* pend,
- ldns_buffer* packet)
+ sldns_buffer* packet)
{
int id_tries = 0;
pend->id = ((unsigned)ub_random(outnet->rnd)>>8) & 0xffff;
- LDNS_ID_SET(ldns_buffer_begin(packet), pend->id);
+ LDNS_ID_SET(sldns_buffer_begin(packet), pend->id);
/* insert in tree */
pend->node.key = pend;
while(!rbtree_insert(outnet->pending, &pend->node)) {
/* change ID to avoid collision */
pend->id = ((unsigned)ub_random(outnet->rnd)>>8) & 0xffff;
- LDNS_ID_SET(ldns_buffer_begin(packet), pend->id);
+ LDNS_ID_SET(sldns_buffer_begin(packet), pend->id);
id_tries++;
if(id_tries == MAX_ID_RETRY) {
pend->id=99999; /* non existant ID */
@@ -958,7 +992,7 @@ select_ifport(struct outside_network* outnet, struct pending* pend,
static int
randomize_and_send_udp(struct outside_network* outnet, struct pending* pend,
- ldns_buffer* packet, int timeout)
+ sldns_buffer* packet, int timeout)
{
struct timeval tv;
@@ -997,7 +1031,7 @@ randomize_and_send_udp(struct outside_network* outnet, struct pending* pend,
}
struct pending*
-pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
+pending_udp_query(struct outside_network* outnet, sldns_buffer* packet,
struct sockaddr_storage* addr, socklen_t addrlen, int timeout,
comm_point_callback_t* cb, void* cb_arg)
{
@@ -1020,8 +1054,8 @@ pending_udp_query(struct outside_network* outnet, ldns_buffer* packet,
/* no unused fd, cannot create a new port (randomly) */
verbose(VERB_ALGO, "no fds available, udp query waiting");
pend->timeout = timeout;
- pend->pkt_len = ldns_buffer_limit(packet);
- pend->pkt = (uint8_t*)memdup(ldns_buffer_begin(packet),
+ pend->pkt_len = sldns_buffer_limit(packet);
+ pend->pkt = (uint8_t*)memdup(sldns_buffer_begin(packet),
pend->pkt_len);
if(!pend->pkt) {
comm_timer_delete(pend->timer);
@@ -1080,7 +1114,7 @@ outnet_tcptimer(void* arg)
}
struct waiting_tcp*
-pending_tcp_query(struct outside_network* outnet, ldns_buffer* packet,
+pending_tcp_query(struct outside_network* outnet, sldns_buffer* packet,
struct sockaddr_storage* addr, socklen_t addrlen, int timeout,
comm_point_callback_t* callback, void* callback_arg, int ssl_upstream)
{
@@ -1090,7 +1124,7 @@ pending_tcp_query(struct outside_network* outnet, ldns_buffer* packet,
uint16_t id;
/* if no buffer is free allocate space to store query */
w = (struct waiting_tcp*)malloc(sizeof(struct waiting_tcp)
- + (pend?0:ldns_buffer_limit(packet)));
+ + (pend?0:sldns_buffer_limit(packet)));
if(!w) {
return NULL;
}
@@ -1101,7 +1135,7 @@ pending_tcp_query(struct outside_network* outnet, ldns_buffer* packet,
w->pkt = NULL;
w->pkt_len = 0;
id = ((unsigned)ub_random(outnet->rnd)>>8) & 0xffff;
- LDNS_ID_SET(ldns_buffer_begin(packet), id);
+ LDNS_ID_SET(sldns_buffer_begin(packet), id);
memcpy(&w->addr, addr, addrlen);
w->addrlen = addrlen;
w->outnet = outnet;
@@ -1115,16 +1149,16 @@ pending_tcp_query(struct outside_network* outnet, ldns_buffer* packet,
comm_timer_set(w->timer, &tv);
if(pend) {
/* we have a buffer available right now */
- if(!outnet_tcp_take_into_use(w, ldns_buffer_begin(packet),
- ldns_buffer_limit(packet))) {
+ if(!outnet_tcp_take_into_use(w, sldns_buffer_begin(packet),
+ sldns_buffer_limit(packet))) {
waiting_tcp_delete(w);
return NULL;
}
} else {
/* queue up */
w->pkt = (uint8_t*)w + sizeof(struct waiting_tcp);
- w->pkt_len = ldns_buffer_limit(packet);
- memmove(w->pkt, ldns_buffer_begin(packet), w->pkt_len);
+ w->pkt_len = sldns_buffer_limit(packet);
+ memmove(w->pkt, sldns_buffer_begin(packet), w->pkt_len);
w->next_waiting = NULL;
if(outnet->tcp_wait_last)
outnet->tcp_wait_last->next_waiting = w;
@@ -1136,31 +1170,31 @@ pending_tcp_query(struct outside_network* outnet, ldns_buffer* packet,
/** create query for serviced queries */
static void
-serviced_gen_query(ldns_buffer* buff, uint8_t* qname, size_t qnamelen,
+serviced_gen_query(sldns_buffer* buff, uint8_t* qname, size_t qnamelen,
uint16_t qtype, uint16_t qclass, uint16_t flags)
{
- ldns_buffer_clear(buff);
+ sldns_buffer_clear(buff);
/* skip id */
- ldns_buffer_write_u16(buff, flags);
- ldns_buffer_write_u16(buff, 1); /* qdcount */
- ldns_buffer_write_u16(buff, 0); /* ancount */
- ldns_buffer_write_u16(buff, 0); /* nscount */
- ldns_buffer_write_u16(buff, 0); /* arcount */
- ldns_buffer_write(buff, qname, qnamelen);
- ldns_buffer_write_u16(buff, qtype);
- ldns_buffer_write_u16(buff, qclass);
- ldns_buffer_flip(buff);
+ sldns_buffer_write_u16(buff, flags);
+ sldns_buffer_write_u16(buff, 1); /* qdcount */
+ sldns_buffer_write_u16(buff, 0); /* ancount */
+ sldns_buffer_write_u16(buff, 0); /* nscount */
+ sldns_buffer_write_u16(buff, 0); /* arcount */
+ sldns_buffer_write(buff, qname, qnamelen);
+ sldns_buffer_write_u16(buff, qtype);
+ sldns_buffer_write_u16(buff, qclass);
+ sldns_buffer_flip(buff);
}
/** lookup serviced query in serviced query rbtree */
static struct serviced_query*
-lookup_serviced(struct outside_network* outnet, ldns_buffer* buff, int dnssec,
+lookup_serviced(struct outside_network* outnet, sldns_buffer* buff, int dnssec,
struct sockaddr_storage* addr, socklen_t addrlen)
{
struct serviced_query key;
key.node.key = &key;
- key.qbuf = ldns_buffer_begin(buff);
- key.qbuflen = ldns_buffer_limit(buff);
+ key.qbuf = sldns_buffer_begin(buff);
+ key.qbuflen = sldns_buffer_limit(buff);
key.dnssec = dnssec;
memcpy(&key.addr, addr, addrlen);
key.addrlen = addrlen;
@@ -1170,7 +1204,7 @@ lookup_serviced(struct outside_network* outnet, ldns_buffer* buff, int dnssec,
/** Create new serviced entry */
static struct serviced_query*
-serviced_create(struct outside_network* outnet, ldns_buffer* buff, int dnssec,
+serviced_create(struct outside_network* outnet, sldns_buffer* buff, int dnssec,
int want_dnssec, int tcp_upstream, int ssl_upstream,
struct sockaddr_storage* addr, socklen_t addrlen, uint8_t* zone,
size_t zonelen, int qtype)
@@ -1182,12 +1216,12 @@ serviced_create(struct outside_network* outnet, ldns_buffer* buff, int dnssec,
if(!sq)
return NULL;
sq->node.key = sq;
- sq->qbuf = memdup(ldns_buffer_begin(buff), ldns_buffer_limit(buff));
+ sq->qbuf = memdup(sldns_buffer_begin(buff), sldns_buffer_limit(buff));
if(!sq->qbuf) {
free(sq);
return NULL;
}
- sq->qbuflen = ldns_buffer_limit(buff);
+ sq->qbuflen = sldns_buffer_limit(buff);
sq->zone = memdup(zone, zonelen);
if(!sq->zone) {
free(sq->qbuf);
@@ -1210,6 +1244,8 @@ serviced_create(struct outside_network* outnet, ldns_buffer* buff, int dnssec,
sq->to_be_deleted = 0;
#ifdef UNBOUND_DEBUG
ins =
+#else
+ (void)
#endif
rbtree_insert(outnet->serviced, &sq->node);
log_assert(ins != NULL); /* must not be already present */
@@ -1310,17 +1346,17 @@ serviced_perturb_qname(struct ub_randstate* rnd, uint8_t* qbuf, size_t len)
/** put serviced query into a buffer */
static void
-serviced_encode(struct serviced_query* sq, ldns_buffer* buff, int with_edns)
+serviced_encode(struct serviced_query* sq, sldns_buffer* buff, int with_edns)
{
/* if we are using 0x20 bits for ID randomness, perturb them */
if(sq->outnet->use_caps_for_id) {
serviced_perturb_qname(sq->outnet->rnd, sq->qbuf, sq->qbuflen);
}
/* generate query */
- ldns_buffer_clear(buff);
- ldns_buffer_write_u16(buff, 0); /* id placeholder */
- ldns_buffer_write(buff, sq->qbuf, sq->qbuflen);
- ldns_buffer_flip(buff);
+ sldns_buffer_clear(buff);
+ sldns_buffer_write_u16(buff, 0); /* id placeholder */
+ sldns_buffer_write(buff, sq->qbuf, sq->qbuflen);
+ sldns_buffer_flip(buff);
if(with_edns) {
/* add edns section */
struct edns_data edns;
@@ -1344,7 +1380,7 @@ serviced_encode(struct serviced_query* sq, ldns_buffer* buff, int with_edns)
if(sq->dnssec & EDNS_DO)
edns.bits = EDNS_DO;
if(sq->dnssec & BIT_CD)
- LDNS_CD_SET(ldns_buffer_begin(buff));
+ LDNS_CD_SET(sldns_buffer_begin(buff));
attach_edns_record(buff, &edns);
}
}
@@ -1357,11 +1393,11 @@ serviced_encode(struct serviced_query* sq, ldns_buffer* buff, int with_edns)
* @return 0 on error.
*/
static int
-serviced_udp_send(struct serviced_query* sq, ldns_buffer* buff)
+serviced_udp_send(struct serviced_query* sq, sldns_buffer* buff)
{
int rtt, vs;
uint8_t edns_lame_known;
- uint32_t now = *sq->outnet->now_secs;
+ time_t now = *sq->outnet->now_secs;
if(!infra_host(sq->outnet->infra, &sq->addr, sq->addrlen, sq->zone,
sq->zonelen, now, &vs, &edns_lame_known, &rtt))
@@ -1397,21 +1433,21 @@ serviced_udp_send(struct serviced_query* sq, ldns_buffer* buff)
/** check that perturbed qname is identical */
static int
-serviced_check_qname(ldns_buffer* pkt, uint8_t* qbuf, size_t qbuflen)
+serviced_check_qname(sldns_buffer* pkt, uint8_t* qbuf, size_t qbuflen)
{
- uint8_t* d1 = ldns_buffer_at(pkt, 12);
+ uint8_t* d1 = sldns_buffer_at(pkt, 12);
uint8_t* d2 = qbuf+10;
uint8_t len1, len2;
int count = 0;
log_assert(qbuflen >= 15 /* 10 header, root, type, class */);
len1 = *d1++;
len2 = *d2++;
- if(ldns_buffer_limit(pkt) < 12+1+4) /* packet too small for qname */
+ if(sldns_buffer_limit(pkt) < 12+1+4) /* packet too small for qname */
return 0;
while(len1 != 0 || len2 != 0) {
if(LABEL_IS_PTR(len1)) {
- d1 = ldns_buffer_at(pkt, PTR_OFFSET(len1, *d1));
- if(d1 >= ldns_buffer_at(pkt, ldns_buffer_limit(pkt)))
+ d1 = sldns_buffer_at(pkt, PTR_OFFSET(len1, *d1));
+ if(d1 >= sldns_buffer_at(pkt, sldns_buffer_limit(pkt)))
return 0;
len1 = *d1++;
if(count++ > MAX_COMPRESS_PTRS)
@@ -1449,6 +1485,8 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c,
size_t backlen = 0;
#ifdef UNBOUND_DEBUG
rbnode_t* rem =
+#else
+ (void)
#endif
/* remove from tree, and schedule for deletion, so that callbacks
* can safely deregister themselves and even create new serviced
@@ -1459,10 +1497,10 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c,
verbose(VERB_ALGO, "svcd callbacks start");
if(sq->outnet->use_caps_for_id && error == NETEVENT_NOERROR && c) {
/* noerror and nxdomain must have a qname in reply */
- if(ldns_buffer_read_u16_at(c->buffer, 4) == 0 &&
- (LDNS_RCODE_WIRE(ldns_buffer_begin(c->buffer))
+ if(sldns_buffer_read_u16_at(c->buffer, 4) == 0 &&
+ (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer))
== LDNS_RCODE_NOERROR ||
- LDNS_RCODE_WIRE(ldns_buffer_begin(c->buffer))
+ LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer))
== LDNS_RCODE_NXDOMAIN)) {
verbose(VERB_DETAIL, "no qname in reply to check 0x20ID");
log_addr(VERB_DETAIL, "from server",
@@ -1470,7 +1508,7 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c,
log_buf(VERB_DETAIL, "for packet", c->buffer);
error = NETEVENT_CLOSED;
c = NULL;
- } else if(ldns_buffer_read_u16_at(c->buffer, 4) > 0 &&
+ } else if(sldns_buffer_read_u16_at(c->buffer, 4) > 0 &&
!serviced_check_qname(c->buffer, sq->qbuf,
sq->qbuflen)) {
verbose(VERB_DETAIL, "wrong 0x20-ID in reply qname");
@@ -1480,12 +1518,12 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c,
error = NETEVENT_CAPSFAIL;
/* and cleanup too */
pkt_dname_tolower(c->buffer,
- ldns_buffer_at(c->buffer, 12));
+ sldns_buffer_at(c->buffer, 12));
} else {
verbose(VERB_ALGO, "good 0x20-ID in reply qname");
/* cleanup caps, prettier cache contents. */
pkt_dname_tolower(c->buffer,
- ldns_buffer_at(c->buffer, 12));
+ sldns_buffer_at(c->buffer, 12));
}
}
if(dobackup && c) {
@@ -1493,8 +1531,8 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c,
* may send outgoing queries that overwrite the buffer.
* use secondary buffer to store the query.
* This is a data copy, but faster than packet to server */
- backlen = ldns_buffer_limit(c->buffer);
- backup_p = memdup(ldns_buffer_begin(c->buffer), backlen);
+ backlen = sldns_buffer_limit(c->buffer);
+ backup_p = memdup(sldns_buffer_begin(c->buffer), backlen);
if(!backup_p) {
log_err("malloc failure in serviced query callbacks");
error = NETEVENT_CLOSED;
@@ -1506,9 +1544,9 @@ serviced_callbacks(struct serviced_query* sq, int error, struct comm_point* c,
while((p=sq->cblist) != NULL) {
sq->cblist = p->next; /* remove this element */
if(dobackup && c) {
- ldns_buffer_clear(c->buffer);
- ldns_buffer_write(c->buffer, backup_p, backlen);
- ldns_buffer_flip(c->buffer);
+ sldns_buffer_clear(c->buffer);
+ sldns_buffer_write(c->buffer, backup_p, backlen);
+ sldns_buffer_flip(c->buffer);
}
fptr_ok(fptr_whitelist_serviced_query(p->cb));
(void)(*p->cb)(c, p->cb_arg, error, rep);
@@ -1537,8 +1575,8 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error,
infra_update_tcp_works(sq->outnet->infra, &sq->addr,
sq->addrlen, sq->zone, sq->zonelen);
if(error==NETEVENT_NOERROR && sq->status == serviced_query_TCP_EDNS &&
- (LDNS_RCODE_WIRE(ldns_buffer_begin(c->buffer)) ==
- LDNS_RCODE_FORMERR || LDNS_RCODE_WIRE(ldns_buffer_begin(
+ (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) ==
+ LDNS_RCODE_FORMERR || LDNS_RCODE_WIRE(sldns_buffer_begin(
c->buffer)) == LDNS_RCODE_NOTIMPL) ) {
/* attempt to fallback to nonEDNS */
sq->status = serviced_query_TCP_EDNS_fallback;
@@ -1546,10 +1584,10 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error,
return 0;
} else if(error==NETEVENT_NOERROR &&
sq->status == serviced_query_TCP_EDNS_fallback &&
- (LDNS_RCODE_WIRE(ldns_buffer_begin(c->buffer)) ==
+ (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) ==
LDNS_RCODE_NOERROR || LDNS_RCODE_WIRE(
- ldns_buffer_begin(c->buffer)) == LDNS_RCODE_NXDOMAIN
- || LDNS_RCODE_WIRE(ldns_buffer_begin(c->buffer))
+ sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NXDOMAIN
+ || LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer))
== LDNS_RCODE_YXDOMAIN)) {
/* the fallback produced a result that looks promising, note
* that this server should be approached without EDNS */
@@ -1567,7 +1605,7 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error,
(now.tv_sec == sq->last_sent_time.tv_sec &&
now.tv_usec > sq->last_sent_time.tv_usec)) {
/* convert from microseconds to milliseconds */
- int roundtime = ((int)now.tv_sec - (int)sq->last_sent_time.tv_sec)*1000
+ int roundtime = ((int)(now.tv_sec - sq->last_sent_time.tv_sec))*1000
+ ((int)now.tv_usec - (int)sq->last_sent_time.tv_usec)/1000;
verbose(VERB_ALGO, "measured TCP-time at %d msec", roundtime);
log_assert(roundtime >= 0);
@@ -1576,7 +1614,7 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error,
if(roundtime < TCP_AUTH_QUERY_TIMEOUT*1000) {
if(!infra_rtt_update(sq->outnet->infra, &sq->addr,
sq->addrlen, sq->zone, sq->zonelen, sq->qtype,
- roundtime, sq->last_rtt, (uint32_t)now.tv_sec))
+ roundtime, sq->last_rtt, (time_t)now.tv_sec))
log_err("out of memory noting rtt.");
}
}
@@ -1595,7 +1633,7 @@ serviced_tcp_callback(struct comm_point* c, void* arg, int error,
static void
serviced_tcp_initiate(struct outside_network* outnet,
- struct serviced_query* sq, ldns_buffer* buff)
+ struct serviced_query* sq, sldns_buffer* buff)
{
verbose(VERB_ALGO, "initiate TCP query %s",
sq->status==serviced_query_TCP_EDNS?"EDNS":"");
@@ -1614,7 +1652,7 @@ serviced_tcp_initiate(struct outside_network* outnet,
/** Send serviced query over TCP return false on initial failure */
static int
-serviced_tcp_send(struct serviced_query* sq, ldns_buffer* buff)
+serviced_tcp_send(struct serviced_query* sq, sldns_buffer* buff)
{
int vs, rtt;
uint8_t edns_lame_known;
@@ -1668,7 +1706,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
sq->retry++;
if(!(rto=infra_rtt_update(outnet->infra, &sq->addr, sq->addrlen,
sq->zone, sq->zonelen, sq->qtype, -1, sq->last_rtt,
- (uint32_t)now.tv_sec)))
+ (time_t)now.tv_sec)))
log_err("out of memory in UDP exponential backoff");
if(sq->retry < OUTBOUND_UDP_RETRY) {
log_name_addr(VERB_ALGO, "retry query", sq->qbuf+10,
@@ -1693,9 +1731,9 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
if(!fallback_tcp) {
if( (sq->status == serviced_query_UDP_EDNS
||sq->status == serviced_query_UDP_EDNS_FRAG)
- && (LDNS_RCODE_WIRE(ldns_buffer_begin(c->buffer))
+ && (LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer))
== LDNS_RCODE_FORMERR || LDNS_RCODE_WIRE(
- ldns_buffer_begin(c->buffer)) == LDNS_RCODE_NOTIMPL)) {
+ sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NOTIMPL)) {
/* try to get an answer by falling back without EDNS */
verbose(VERB_ALGO, "serviced query: attempt without EDNS");
sq->status = serviced_query_UDP_EDNS_fallback;
@@ -1712,7 +1750,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
/* only store noEDNS in cache if domain is noDNSSEC */
if(!sq->want_dnssec)
if(!infra_edns_update(outnet->infra, &sq->addr, sq->addrlen,
- sq->zone, sq->zonelen, -1, (uint32_t)now.tv_sec)) {
+ sq->zone, sq->zonelen, -1, (time_t)now.tv_sec)) {
log_err("Out of memory caching no edns for host");
}
sq->status = serviced_query_UDP;
@@ -1722,15 +1760,15 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
log_addr(VERB_ALGO, "serviced query: EDNS works for",
&sq->addr, sq->addrlen);
if(!infra_edns_update(outnet->infra, &sq->addr, sq->addrlen,
- sq->zone, sq->zonelen, 0, (uint32_t)now.tv_sec)) {
+ sq->zone, sq->zonelen, 0, (time_t)now.tv_sec)) {
log_err("Out of memory caching edns works");
}
sq->edns_lame_known = 1;
} else if(sq->status == serviced_query_UDP_EDNS_fallback &&
!sq->edns_lame_known && (LDNS_RCODE_WIRE(
- ldns_buffer_begin(c->buffer)) == LDNS_RCODE_NOERROR ||
- LDNS_RCODE_WIRE(ldns_buffer_begin(c->buffer)) ==
- LDNS_RCODE_NXDOMAIN || LDNS_RCODE_WIRE(ldns_buffer_begin(
+ sldns_buffer_begin(c->buffer)) == LDNS_RCODE_NOERROR ||
+ LDNS_RCODE_WIRE(sldns_buffer_begin(c->buffer)) ==
+ LDNS_RCODE_NXDOMAIN || LDNS_RCODE_WIRE(sldns_buffer_begin(
c->buffer)) == LDNS_RCODE_YXDOMAIN)) {
/* the fallback produced a result that looks promising, note
* that this server should be approached without EDNS */
@@ -1739,7 +1777,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
log_addr(VERB_ALGO, "serviced query: EDNS fails for",
&sq->addr, sq->addrlen);
if(!infra_edns_update(outnet->infra, &sq->addr, sq->addrlen,
- sq->zone, sq->zonelen, -1, (uint32_t)now.tv_sec)) {
+ sq->zone, sq->zonelen, -1, (time_t)now.tv_sec)) {
log_err("Out of memory caching no edns for host");
}
} else {
@@ -1753,7 +1791,7 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
(now.tv_sec == sq->last_sent_time.tv_sec &&
now.tv_usec > sq->last_sent_time.tv_usec)) {
/* convert from microseconds to milliseconds */
- int roundtime = ((int)now.tv_sec - (int)sq->last_sent_time.tv_sec)*1000
+ int roundtime = ((int)(now.tv_sec - sq->last_sent_time.tv_sec))*1000
+ ((int)now.tv_usec - (int)sq->last_sent_time.tv_usec)/1000;
verbose(VERB_ALGO, "measured roundtrip at %d msec", roundtime);
log_assert(roundtime >= 0);
@@ -1762,14 +1800,14 @@ serviced_udp_callback(struct comm_point* c, void* arg, int error,
if(roundtime < 60000) {
if(!infra_rtt_update(outnet->infra, &sq->addr, sq->addrlen,
sq->zone, sq->zonelen, sq->qtype, roundtime,
- sq->last_rtt, (uint32_t)now.tv_sec))
+ sq->last_rtt, (time_t)now.tv_sec))
log_err("out of memory noting rtt.");
}
}
} /* end of if_!fallback_tcp */
/* perform TC flag check and TCP fallback after updating our
* cache entries for EDNS status and RTT times */
- if(LDNS_TC_WIRE(ldns_buffer_begin(c->buffer)) || fallback_tcp) {
+ if(LDNS_TC_WIRE(sldns_buffer_begin(c->buffer)) || fallback_tcp) {
/* fallback to TCP */
/* this discards partial UDP contents */
if(sq->status == serviced_query_UDP_EDNS ||
@@ -1792,7 +1830,7 @@ outnet_serviced_query(struct outside_network* outnet,
uint16_t flags, int dnssec, int want_dnssec, int tcp_upstream,
int ssl_upstream, struct sockaddr_storage* addr, socklen_t addrlen,
uint8_t* zone, size_t zonelen, comm_point_callback_t* callback,
- void* callback_arg, ldns_buffer* buff)
+ void* callback_arg, sldns_buffer* buff)
{
struct serviced_query* sq;
struct service_callback* cb;
@@ -1866,6 +1904,8 @@ void outnet_serviced_query_stop(struct serviced_query* sq, void* cb_arg)
if(!sq->cblist && !sq->to_be_deleted) {
#ifdef UNBOUND_DEBUG
rbnode_t* rem =
+#else
+ (void)
#endif
rbtree_delete(sq->outnet->serviced, sq);
log_assert(rem); /* should be present */
@@ -1919,7 +1959,7 @@ size_t outnet_get_mem(struct outside_network* outnet)
struct port_comm* pc;
size_t s = sizeof(*outnet) + sizeof(*outnet->base) +
sizeof(*outnet->udp_buff) +
- ldns_buffer_capacity(outnet->udp_buff);
+ sldns_buffer_capacity(outnet->udp_buff);
/* second buffer is not ours */
for(pc = outnet->unused_fds; pc; pc = pc->next) {
s += sizeof(*pc) + comm_point_get_mem(pc->cp);
diff --git a/contrib/unbound/services/outside_network.h b/contrib/unbound/services/outside_network.h
index 9ec81f4..dda9d6f 100644
--- a/contrib/unbound/services/outside_network.h
+++ b/contrib/unbound/services/outside_network.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -54,6 +54,7 @@ struct waiting_udp;
struct infra_cache;
struct port_comm;
struct port_if;
+struct sldns_buffer;
/**
* Send queries to outside servers and wait for answers from servers.
@@ -63,13 +64,13 @@ struct outside_network {
/** Base for select calls */
struct comm_base* base;
/** pointer to time in seconds */
- uint32_t* now_secs;
+ time_t* now_secs;
/** pointer to time in microseconds */
struct timeval* now_tv;
/** buffer shared by UDP connections, since there is only one
datagram at any time. */
- ldns_buffer* udp_buff;
+ struct sldns_buffer* udp_buff;
/** serviced_callbacks malloc overhead when processing multiple
* identical serviced queries to the same server. */
size_t svcd_overhead;
@@ -94,6 +95,10 @@ struct outside_network {
struct port_comm* unused_fds;
/** if udp is done */
int do_udp;
+ /** if udp is delay-closed (delayed answers do not meet closed port)*/
+ int delayclose;
+ /** timeout for delayclose */
+ struct timeval delay_tv;
/** array of outgoing IP4 interfaces */
struct port_if* ip4_ifs;
@@ -376,6 +381,8 @@ struct serviced_query {
* @param unwanted_param: user parameter to action.
* @param do_udp: if udp is done.
* @param sslctx: context to create outgoing connections with (if enabled).
+ * @param delayclose: if not 0, udp sockets are delayed before timeout closure.
+ * msec to wait on timeouted udp sockets.
* @return: the new structure (with no pending answers) or NULL on error.
*/
struct outside_network* outside_network_create(struct comm_base* base,
@@ -384,7 +391,7 @@ struct outside_network* outside_network_create(struct comm_base* base,
struct ub_randstate* rnd, int use_caps_for_id, int* availports,
int numavailports, size_t unwanted_threshold,
void (*unwanted_action)(void*), void* unwanted_param, int do_udp,
- void* sslctx);
+ void* sslctx, int delayclose);
/**
* Delete outside_network structure.
@@ -411,7 +418,7 @@ void outside_network_quit_prepare(struct outside_network* outnet);
* @return: NULL on error for malloc or socket. Else the pending query object.
*/
struct pending* pending_udp_query(struct outside_network* outnet,
- ldns_buffer* packet, struct sockaddr_storage* addr,
+ struct sldns_buffer* packet, struct sockaddr_storage* addr,
socklen_t addrlen, int timeout, comm_point_callback_t* callback,
void* callback_arg);
@@ -431,7 +438,7 @@ struct pending* pending_udp_query(struct outside_network* outnet,
* @return: false on error for malloc or socket. Else the pending TCP object.
*/
struct waiting_tcp* pending_tcp_query(struct outside_network* outnet,
- ldns_buffer* packet, struct sockaddr_storage* addr,
+ struct sldns_buffer* packet, struct sockaddr_storage* addr,
socklen_t addrlen, int timeout, comm_point_callback_t* callback,
void* callback_arg, int ssl_upstream);
@@ -476,7 +483,7 @@ struct serviced_query* outnet_serviced_query(struct outside_network* outnet,
uint16_t flags, int dnssec, int want_dnssec, int tcp_upstream,
int ssl_upstream, struct sockaddr_storage* addr, socklen_t addrlen,
uint8_t* zone, size_t zonelen, comm_point_callback_t* callback,
- void* callback_arg, ldns_buffer* buff);
+ void* callback_arg, struct sldns_buffer* buff);
/**
* Remove service query callback.
@@ -515,6 +522,9 @@ int outnet_tcp_cb(struct comm_point* c, void* arg, int error,
/** callback for udp timeout */
void pending_udp_timer_cb(void *arg);
+/** callback for udp delay for timeout */
+void pending_udp_timer_delay_cb(void *arg);
+
/** callback for outgoing TCP timer event */
void outnet_tcptimer(void* arg);
diff --git a/contrib/unbound/smallapp/unbound-anchor.c b/contrib/unbound/smallapp/unbound-anchor.c
index eeb7682..33d8c54 100644
--- a/contrib/unbound/smallapp/unbound-anchor.c
+++ b/contrib/unbound/smallapp/unbound-anchor.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -116,7 +116,7 @@
#include "config.h"
#include "libunbound/unbound.h"
-#include <ldns/rr.h>
+#include "ldns/rrdef.h"
#include <expat.h>
#ifndef HAVE_EXPAT_H
#error "need libexpat to parse root-anchors.xml file."
@@ -667,6 +667,15 @@ count_unused(struct ip_list* p)
return num;
}
+static int get_random(void)
+{
+ int r;
+ if (RAND_bytes((unsigned char*)&r, (int)sizeof(r)) == 1) {
+ return r;
+ }
+ return (int)random();
+}
+
/** pick random unused element from IP list */
static struct ip_list*
pick_random_ip(struct ip_list* list)
@@ -676,7 +685,7 @@ pick_random_ip(struct ip_list* list)
int sel;
if(num == 0) return NULL;
/* not perfect, but random enough */
- sel = (int)ldns_get_random() % num;
+ sel = get_random() % num;
/* skip over unused elements that we did not select */
while(sel > 0 && p) {
if(!p->used) sel--;
@@ -1229,7 +1238,7 @@ xml_charhandle(void *userData, const XML_Char *s, int len)
printf("'\n");
}
if(strcasecmp(data->tag, "Zone") == 0) {
- if(BIO_write(data->czone, s, len) <= 0) {
+ if(BIO_write(data->czone, s, len) < 0) {
if(verb) printf("out of memory in BIO_write\n");
exit(0);
}
@@ -1240,7 +1249,7 @@ xml_charhandle(void *userData, const XML_Char *s, int len)
return;
b = xml_selectbio(data, data->tag);
if(b) {
- if(BIO_write(b, s, len) <= 0) {
+ if(BIO_write(b, s, len) < 0) {
if(verb) printf("out of memory in BIO_write\n");
exit(0);
}
@@ -1433,7 +1442,7 @@ xml_startelem(void *userData, const XML_Char *name, const XML_Char **atts)
static void
xml_append_str(BIO* b, const char* s)
{
- if(BIO_write(b, s, (int)strlen(s)) <= 0) {
+ if(BIO_write(b, s, (int)strlen(s)) < 0) {
if(verb) printf("out of memory in BIO_write\n");
exit(0);
}
@@ -1457,7 +1466,7 @@ xml_append_bio(BIO* b, BIO* a)
z[i] = ' ';
}
/* write to BIO */
- if(BIO_write(b, z, len) <= 0) {
+ if(BIO_write(b, z, len) < 0) {
if(verb) printf("out of memory in BIO_write\n");
exit(0);
}
@@ -1543,7 +1552,7 @@ xml_parse_setup(XML_Parser parser, struct xml_data* data, time_t now)
}
snprintf(buf, sizeof(buf), "; created by unbound-anchor on %s",
ctime(&now));
- if(BIO_write(data->ds, buf, (int)strlen(buf)) <= 0) {
+ if(BIO_write(data->ds, buf, (int)strlen(buf)) < 0) {
if(verb) printf("out of memory\n");
exit(0);
}
diff --git a/contrib/unbound/smallapp/unbound-checkconf.c b/contrib/unbound/smallapp/unbound-checkconf.c
index c73d8bd..78733ed 100644
--- a/contrib/unbound/smallapp/unbound-checkconf.c
+++ b/contrib/unbound/smallapp/unbound-checkconf.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -53,6 +53,7 @@
#include "iterator/iter_hints.h"
#include "validator/validator.h"
#include "services/localzone.h"
+#include "ldns/sbuffer.h"
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
@@ -105,14 +106,14 @@ check_mod(struct config_file* cfg, struct module_func_block* fb)
memset(&env, 0, sizeof(env));
env.cfg = cfg;
env.scratch = regional_create();
- env.scratch_buffer = ldns_buffer_new(BUFSIZ);
+ env.scratch_buffer = sldns_buffer_new(BUFSIZ);
if(!env.scratch || !env.scratch_buffer)
fatal_exit("out of memory");
if(!(*fb->init)(&env, 0)) {
fatal_exit("bad config for %s module", fb->name);
}
(*fb->deinit)(&env, 0);
- ldns_buffer_free(env.scratch_buffer);
+ sldns_buffer_free(env.scratch_buffer);
regional_destroy(env.scratch);
}
@@ -343,9 +344,9 @@ morechecks(struct config_file* cfg, const char* fname)
if(fname[0] != '/') {
if(getcwd(buf, sizeof(buf)) == NULL)
fatal_exit("getcwd: %s", strerror(errno));
- strncat(buf, "/", sizeof(buf)-strlen(buf)-1);
+ (void)strlcat(buf, "/", sizeof(buf));
}
- strncat(buf, fname, sizeof(buf)-strlen(buf)-1);
+ (void)strlcat(buf, fname, sizeof(buf));
if(strncmp(buf, cfg->chrootdir, strlen(cfg->chrootdir)) != 0)
fatal_exit("config file %s is not inside chroot %s",
buf, cfg->chrootdir);
diff --git a/contrib/unbound/smallapp/unbound-control-setup.sh b/contrib/unbound/smallapp/unbound-control-setup.sh
index 7fe1c33..f22f4b8 100755
--- a/contrib/unbound/smallapp/unbound-control-setup.sh
+++ b/contrib/unbound/smallapp/unbound-control-setup.sh
@@ -22,16 +22,16 @@
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# settings:
diff --git a/contrib/unbound/smallapp/unbound-control-setup.sh.in b/contrib/unbound/smallapp/unbound-control-setup.sh.in
index a2caffe..79605dc 100755
--- a/contrib/unbound/smallapp/unbound-control-setup.sh.in
+++ b/contrib/unbound/smallapp/unbound-control-setup.sh.in
@@ -22,16 +22,16 @@
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# settings:
diff --git a/contrib/unbound/smallapp/unbound-control.c b/contrib/unbound/smallapp/unbound-control.c
index cc48866..067e133 100644
--- a/contrib/unbound/smallapp/unbound-control.c
+++ b/contrib/unbound/smallapp/unbound-control.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -106,6 +106,8 @@ usage()
printf(" list_forwards list forward-zones in use\n");
printf(" list_local_zones list local-zones in use\n");
printf(" list_local_data list local-data RRs in use\n");
+ printf(" insecure_add zone add domain-insecure zone\n");
+ printf(" insecure_remove zone remove domain-insecure zone\n");
printf(" forward_add [+i] zone addr.. add forward-zone with servers\n");
printf(" forward_remove [+i] zone remove forward zone\n");
printf(" stub_add [+ip] zone addr.. add stub-zone with servers\n");
diff --git a/contrib/unbound/smallapp/unbound-host.c b/contrib/unbound/smallapp/unbound-host.c
index 715aa4a..12c60f4 100644
--- a/contrib/unbound/smallapp/unbound-host.c
+++ b/contrib/unbound/smallapp/unbound-host.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -60,7 +60,8 @@
#define unbound_lite_wrapstr(s) s
#endif
#include "libunbound/unbound.h"
-#include <ldns/ldns.h>
+#include "ldns/rrdef.h"
+#include "ldns/wire2str.h"
#ifdef HAVE_NSS
/* nss3 */
#include "nss.h"
@@ -172,7 +173,7 @@ static int
massage_type(const char* t, int reverse, int* multi)
{
if(t) {
- int r = ldns_get_rr_type_by_name(t);
+ int r = sldns_get_rr_type_by_name(t);
if(r == 0 && strcasecmp(t, "TYPE0") != 0 &&
strcmp(t, "") != 0) {
fprintf(stderr, "error unknown type %s\n", t);
@@ -191,7 +192,7 @@ static int
massage_class(const char* c)
{
if(c) {
- int r = ldns_get_rr_class_by_name(c);
+ int r = sldns_get_rr_class_by_name(c);
if(r == 0 && strcasecmp(c, "CLASS0") != 0 &&
strcmp(c, "") != 0) {
fprintf(stderr, "error unknown class %s\n", c);
@@ -215,61 +216,36 @@ secure_str(struct ub_result* result)
static void
pretty_type(char* s, size_t len, int t)
{
- char* d = ldns_rr_type2str(t);
+ char d[16];
+ sldns_wire2str_type_buf((uint16_t)t, d, sizeof(d));
snprintf(s, len, "%s", d);
- free(d);
}
/** nice string for class */
static void
pretty_class(char* s, size_t len, int c)
{
- char* d = ldns_rr_class2str(c);
+ char d[16];
+ sldns_wire2str_class_buf((uint16_t)c, d, sizeof(d));
snprintf(s, len, "%s", d);
- free(d);
}
/** nice string for rcode */
static void
pretty_rcode(char* s, size_t len, int r)
{
- ldns_lookup_table *rcode = ldns_lookup_by_id(ldns_rcodes, r);
- if(rcode) {
- snprintf(s, len, "%s", rcode->name);
- } else {
- snprintf(s, len, "RCODE%d", r);
- }
+ char d[16];
+ sldns_wire2str_rcode_buf(r, d, sizeof(d));
+ snprintf(s, len, "%s", d);
}
/** convert and print rdata */
static void
print_rd(int t, char* data, size_t len)
{
- size_t i, pos = 0;
- uint8_t* rd = (uint8_t*)malloc(len+2);
- ldns_rr* rr = ldns_rr_new();
- ldns_status status;
- if(!rd || !rr) {
- fprintf(stderr, "out of memory");
- exit(1);
- }
- ldns_rr_set_type(rr, t);
- ldns_write_uint16(rd, len);
- memmove(rd+2, data, len);
- ldns_rr_set_owner(rr, NULL);
- status = ldns_wire2rdf(rr, rd, len+2, &pos);
- if(status != LDNS_STATUS_OK) {
- free(rd);
- ldns_rr_free(rr);
- printf("error_printing_data");
- return;
- }
- for(i=0; i<ldns_rr_rd_count(rr); i++) {
- printf(" ");
- ldns_rdf_print(stdout, ldns_rr_rdf(rr, i));
- }
- ldns_rr_free(rr);
- free(rd);
+ char s[65535];
+ sldns_wire2str_rdata_buf((uint8_t*)data, len, s, sizeof(s), (uint16_t)t);
+ printf(" %s", s);
}
/** pretty line of RR data for results */
@@ -344,24 +320,14 @@ pretty_output(char* q, int t, int c, struct ub_result* result, int docname)
else if(t == LDNS_RR_TYPE_MX)
printf(" has no mail handler record");
else if(t == LDNS_RR_TYPE_ANY) {
- ldns_pkt* p = NULL;
- if(ldns_wire2pkt(&p, result->answer_packet,
- (size_t)result->answer_len)==LDNS_STATUS_OK){
- if(ldns_rr_list_rr_count(
- ldns_pkt_answer(p)) == 0)
- printf(" has no records\n");
- else {
- printf(" ANY:\n");
- ldns_rr_list_print(stdout,
- ldns_pkt_answer(p));
- }
- } else {
- fprintf(stderr, "could not parse "
- "reply packet to ANY query\n");
+ char* s = sldns_wire2str_pkt(
+ result->answer_packet,
+ (size_t)result->answer_len);
+ if(!s) {
+ fprintf(stderr, "alloc failure\n");
exit(1);
}
- ldns_pkt_free(p);
-
+ printf("%s\n", s);
} else printf(" has no %s record", tstr);
printf(" %s\n", secstatus);
}
diff --git a/contrib/unbound/smallapp/worker_cb.c b/contrib/unbound/smallapp/worker_cb.c
index fd8498f..035d908 100644
--- a/contrib/unbound/smallapp/worker_cb.c
+++ b/contrib/unbound/smallapp/worker_cb.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -167,14 +167,21 @@ void libworker_handle_control_cmd(struct tube* ATTR_UNUSED(tube),
}
void libworker_fg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
- ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
+ struct sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
char* ATTR_UNUSED(why_bogus))
{
log_assert(0);
}
void libworker_bg_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
- ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
+ struct sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
+ char* ATTR_UNUSED(why_bogus))
+{
+ log_assert(0);
+}
+
+void libworker_event_done_cb(void* ATTR_UNUSED(arg), int ATTR_UNUSED(rcode),
+ struct sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(s),
char* ATTR_UNUSED(why_bogus))
{
log_assert(0);
diff --git a/contrib/unbound/util/alloc.c b/contrib/unbound/util/alloc.c
index b5ccd96..4b81beb 100644
--- a/contrib/unbound/util/alloc.c
+++ b/contrib/unbound/util/alloc.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -601,13 +601,13 @@ char* unbound_lite_wrapstr(char* s)
return n;
}
-#undef ldns_pkt2wire
-ldns_status unbound_lite_pkt2wire(uint8_t **dest, const ldns_pkt *p,
+#undef sldns_pkt2wire
+sldns_status unbound_lite_pkt2wire(uint8_t **dest, const sldns_pkt *p,
size_t *size)
{
uint8_t* md = NULL;
size_t ms = 0;
- ldns_status s = ldns_pkt2wire(&md, p, &ms);
+ sldns_status s = sldns_pkt2wire(&md, p, &ms);
if(md) {
*dest = unbound_stat_malloc_lite(ms, __FILE__, __LINE__,
__func__);
diff --git a/contrib/unbound/util/alloc.h b/contrib/unbound/util/alloc.h
index cb8d6b1..ffd605c 100644
--- a/contrib/unbound/util/alloc.h
+++ b/contrib/unbound/util/alloc.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -201,15 +201,15 @@ void *unbound_stat_realloc_lite(void *ptr, size_t size, const char* file,
char* unbound_strdup_lite(const char* s, const char* file, int line,
const char* func);
char* unbound_lite_wrapstr(char* s);
-# define ldns_rr2str(rr) unbound_lite_wrapstr(ldns_rr2str(rr))
-# define ldns_rdf2str(rdf) unbound_lite_wrapstr(ldns_rdf2str(rdf))
-# define ldns_rr_type2str(t) unbound_lite_wrapstr(ldns_rr_type2str(t))
-# define ldns_rr_class2str(c) unbound_lite_wrapstr(ldns_rr_class2str(c))
-# define ldns_rr_list2str(r) unbound_lite_wrapstr(ldns_rr_list2str(r))
-# define ldns_pkt2str(p) unbound_lite_wrapstr(ldns_pkt2str(p))
-# define ldns_pkt_rcode2str(r) unbound_lite_wrapstr(ldns_pkt_rcode2str(r))
-# define ldns_pkt2wire(a, r, s) unbound_lite_pkt2wire(a, r, s)
-ldns_status unbound_lite_pkt2wire(uint8_t **dest, const ldns_pkt *p, size_t *size);
+# define sldns_rr2str(rr) unbound_lite_wrapstr(sldns_rr2str(rr))
+# define sldns_rdf2str(rdf) unbound_lite_wrapstr(sldns_rdf2str(rdf))
+# define sldns_rr_type2str(t) unbound_lite_wrapstr(sldns_rr_type2str(t))
+# define sldns_rr_class2str(c) unbound_lite_wrapstr(sldns_rr_class2str(c))
+# define sldns_rr_list2str(r) unbound_lite_wrapstr(sldns_rr_list2str(r))
+# define sldns_pkt2str(p) unbound_lite_wrapstr(sldns_pkt2str(p))
+# define sldns_pkt_rcode2str(r) unbound_lite_wrapstr(sldns_pkt_rcode2str(r))
+# define sldns_pkt2wire(a, r, s) unbound_lite_pkt2wire(a, r, s)
+sldns_status unbound_lite_pkt2wire(uint8_t **dest, const sldns_pkt *p, size_t *size);
# define i2d_DSA_SIG(d, s) unbound_lite_i2d_DSA_SIG(d, s)
int unbound_lite_i2d_DSA_SIG(DSA_SIG* dsasig, unsigned char** sig);
#endif /* UNBOUND_ALLOC_LITE */
diff --git a/contrib/unbound/util/config_file.c b/contrib/unbound/util/config_file.c
index ebfb795..f8341cc 100644
--- a/contrib/unbound/util/config_file.c
+++ b/contrib/unbound/util/config_file.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -41,18 +41,22 @@
#include "config.h"
#include <ctype.h>
-#include <ldns/ldns.h>
+#include <stdarg.h>
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
#include "util/log.h"
-
#include "util/configyyrename.h"
#include "util/config_file.h"
-#include "util/configparser.h"
+#include "configparser.h"
#include "util/net_help.h"
#include "util/data/msgparse.h"
#include "util/module.h"
#include "util/regional.h"
#include "util/fptr_wlist.h"
#include "util/data/dname.h"
+#include "ldns/wire2str.h"
+#include "ldns/parseutil.h"
#ifdef HAVE_GLOB_H
# include <glob.h>
#endif
@@ -122,6 +126,7 @@ config_create(void)
cfg->prefetch_key = 0;
cfg->infra_cache_slabs = 4;
cfg->infra_cache_numhosts = 10000;
+ cfg->delay_close = 0;
if(!(cfg->outgoing_avail_ports = (int*)calloc(65536, sizeof(int))))
goto error_exit;
init_outgoing_availports(cfg->outgoing_avail_ports, 65536);
@@ -140,6 +145,7 @@ config_create(void)
cfg->if_automatic = 0;
cfg->so_rcvbuf = 0;
cfg->so_sndbuf = 0;
+ cfg->so_reuseport = 0;
cfg->num_ifs = 0;
cfg->ifs = NULL;
cfg->num_out_ifs = 0;
@@ -185,12 +191,14 @@ config_create(void)
cfg->local_zones = NULL;
cfg->local_zones_nodefault = NULL;
cfg->local_data = NULL;
+ cfg->unblock_lan_zones = 0;
cfg->python_script = NULL;
cfg->remote_control_enable = 0;
cfg->control_ifs = NULL;
cfg->control_port = UNBOUND_CONTROL_PORT;
cfg->minimal_responses = 0;
cfg->rrset_roundrobin = 0;
+ cfg->max_udp_size = 4096;
if(!(cfg->server_key_file = strdup(RUN_DIR"/unbound_server.key")))
goto error_exit;
if(!(cfg->server_cert_file = strdup(RUN_DIR"/unbound_server.pem")))
@@ -317,7 +325,11 @@ int config_set_option(struct config_file* cfg, const char* opt,
cfg->use_syslog = 0;
free(cfg->logfile);
return (cfg->logfile = strdup(val)) != NULL;
- }
+ }
+ else if(strcmp(opt, "log-time-ascii:") == 0)
+ { IS_YES_OR_NO; cfg->log_time_ascii = (strcmp(val, "yes") == 0);
+ log_set_time_asc(cfg->log_time_ascii); }
+ else S_SIZET_NONZERO("max-udp-size:", max_udp_size)
else S_YNO("use-syslog:", use_syslog)
else S_YNO("extended-statistics:", stat_extended)
else S_YNO("statistics-cumulative:", stat_cumulative)
@@ -344,14 +356,19 @@ int config_set_option(struct config_file* cfg, const char* opt,
else S_SIZET_OR_ZERO("jostle-timeout:", jostle_time)
else S_MEMSIZE("so-rcvbuf:", so_rcvbuf)
else S_MEMSIZE("so-sndbuf:", so_sndbuf)
+ else S_YNO("so-reuseport:", so_reuseport)
else S_MEMSIZE("rrset-cache-size:", rrset_cache_size)
else S_POW2("rrset-cache-slabs:", rrset_cache_slabs)
else S_YNO("prefetch:", prefetch)
else S_YNO("prefetch-key:", prefetch_key)
- else S_NUMBER_OR_ZERO("cache-max-ttl:", max_ttl)
+ else if(strcmp(opt, "cache-max-ttl:") == 0)
+ { IS_NUMBER_OR_ZERO; cfg->max_ttl = atoi(val); MAX_TTL=(time_t)cfg->max_ttl;}
+ else if(strcmp(opt, "cache-min-ttl:") == 0)
+ { IS_NUMBER_OR_ZERO; cfg->min_ttl = atoi(val); MIN_TTL=(time_t)cfg->min_ttl;}
else S_NUMBER_OR_ZERO("infra-host-ttl:", host_ttl)
else S_POW2("infra-cache-slabs:", infra_cache_slabs)
else S_SIZET_NONZERO("infra-cache-numhosts:", infra_cache_numhosts)
+ else S_NUMBER_OR_ZERO("delay-close:", delay_close)
else S_STR("chroot:", chrootdir)
else S_STR("username:", username)
else S_STR("directory:", directory)
@@ -398,6 +415,7 @@ int config_set_option(struct config_file* cfg, const char* opt,
else S_YNO("minimal-responses:", minimal_responses)
else S_YNO("rrset-roundrobin:", rrset_roundrobin)
else S_STRLIST("local-data:", local_data)
+ else S_YNO("unblock-lan-zones:", unblock_lan_zones)
else S_YNO("control-enable:", remote_control_enable)
else S_STRLIST("control-interface:", control_ifs)
else S_NUMBER_NONZERO("control-port:", control_port)
@@ -407,6 +425,12 @@ int config_set_option(struct config_file* cfg, const char* opt,
else S_STR("control-cert-file:", control_cert_file)
else S_STR("module-config:", module_conf)
else S_STR("python-script:", python_script)
+ /* val_sig_skew_min and max are copied into val_env during init,
+ * so this does not update val_env with set_option */
+ else if(strcmp(opt, "val-sig-skew-min:") == 0)
+ { IS_NUMBER_OR_ZERO; cfg->val_sig_skew_min = (int32_t)atoi(val); }
+ else if(strcmp(opt, "val-sig-skew-max:") == 0)
+ { IS_NUMBER_OR_ZERO; cfg->val_sig_skew_max = (int32_t)atoi(val); }
else if (strcmp(opt, "outgoing-interface:") == 0) {
char* d = strdup(val);
char** oi = (char**)malloc((cfg->num_out_ifs+1)*sizeof(char*));
@@ -506,8 +530,9 @@ config_collate_cat(struct config_strlist* list)
return NULL;
}
snprintf(w, left, "%s\n", s->str);
- w += this+1;
- left -= this+1;
+ this = strlen(w);
+ w += this;
+ left -= this;
}
return r;
}
@@ -562,6 +587,7 @@ config_get_option(struct config_file* cfg, const char* opt,
else O_YNO(opt, "statistics-cumulative", stat_cumulative)
else O_YNO(opt, "extended-statistics", stat_extended)
else O_YNO(opt, "use-syslog", use_syslog)
+ else O_YNO(opt, "log-time-ascii", log_time_ascii)
else O_DEC(opt, "num-threads", num_threads)
else O_IFC(opt, "interface", num_ifs, ifs)
else O_IFC(opt, "outgoing-interface", num_out_ifs, out_ifs)
@@ -578,14 +604,17 @@ config_get_option(struct config_file* cfg, const char* opt,
else O_UNS(opt, "jostle-timeout", jostle_time)
else O_MEM(opt, "so-rcvbuf", so_rcvbuf)
else O_MEM(opt, "so-sndbuf", so_sndbuf)
+ else O_YNO(opt, "so-reuseport", so_reuseport)
else O_MEM(opt, "rrset-cache-size", rrset_cache_size)
else O_DEC(opt, "rrset-cache-slabs", rrset_cache_slabs)
else O_YNO(opt, "prefetch-key", prefetch_key)
else O_YNO(opt, "prefetch", prefetch)
else O_DEC(opt, "cache-max-ttl", max_ttl)
+ else O_DEC(opt, "cache-min-ttl", min_ttl)
else O_DEC(opt, "infra-host-ttl", host_ttl)
else O_DEC(opt, "infra-cache-slabs", infra_cache_slabs)
else O_MEM(opt, "infra-cache-numhosts", infra_cache_numhosts)
+ else O_UNS(opt, "delay-close", delay_close)
else O_YNO(opt, "do-ip4", do_ip4)
else O_YNO(opt, "do-ip6", do_ip6)
else O_YNO(opt, "do-udp", do_udp)
@@ -651,6 +680,11 @@ config_get_option(struct config_file* cfg, const char* opt,
else O_UNS(opt, "val-override-date", val_date_override)
else O_YNO(opt, "minimal-responses", minimal_responses)
else O_YNO(opt, "rrset-roundrobin", rrset_roundrobin)
+ else O_YNO(opt, "unblock-lan-zones", unblock_lan_zones)
+ else O_DEC(opt, "max-udp-size", max_udp_size)
+ else O_STR(opt, "python-script", python_script)
+ else O_DEC(opt, "val-sig-skew-min", val_sig_skew_min)
+ else O_DEC(opt, "val-sig-skew-max", val_sig_skew_max)
/* not here:
* outgoing-permit, outgoing-avoid - have list of ports
* local-zone - zones and nodefault variables
@@ -674,6 +708,7 @@ create_cfg_parser(struct config_file* cfg, char* filename, const char* chroot)
cfg_parser->errors = 0;
cfg_parser->cfg = cfg;
cfg_parser->chroot = chroot;
+ init_cfg_parse();
}
int
@@ -1030,10 +1065,10 @@ cfg_str2list_insert(struct config_str2list** head, char* item, char* i2)
return 1;
}
-uint32_t
+time_t
cfg_convert_timeval(const char* str)
{
- uint32_t t;
+ time_t t;
struct tm tm;
memset(&tm, 0, sizeof(tm));
if(strlen(str) < 14)
@@ -1051,7 +1086,7 @@ cfg_convert_timeval(const char* str)
if (tm.tm_min < 0 || tm.tm_min > 59) return 0;
if (tm.tm_sec < 0 || tm.tm_sec > 59) return 0;
/* call ldns conversion function */
- t = mktime_from_utc(&tm);
+ t = sldns_mktime_from_utc(&tm);
return t;
}
@@ -1137,8 +1172,8 @@ cfg_parse_memsize(const char* str, size_t* res)
void
config_apply(struct config_file* config)
{
- MAX_TTL = (uint32_t)config->max_ttl;
- MIN_TTL = (uint32_t)config->min_ttl;
+ MAX_TTL = (time_t)config->max_ttl;
+ MIN_TTL = (time_t)config->min_ttl;
EDNS_ADVERTISED_SIZE = (uint16_t)config->edns_buffer_size;
MINIMAL_RESPONSES = config->minimal_responses;
RRSET_ROUNDROBIN = config->rrset_roundrobin;
@@ -1199,9 +1234,9 @@ strlen_after_chroot(const char* fname, struct config_file* cfg, int use_chdir)
char*
fname_after_chroot(const char* fname, struct config_file* cfg, int use_chdir)
{
- size_t len = strlen_after_chroot(fname, cfg, use_chdir);
+ size_t len = strlen_after_chroot(fname, cfg, use_chdir)+1;
int slashit = 0;
- char* buf = (char*)malloc(len+1);
+ char* buf = (char*)malloc(len);
if(!buf)
return NULL;
buf[0] = 0;
@@ -1209,14 +1244,14 @@ fname_after_chroot(const char* fname, struct config_file* cfg, int use_chdir)
if(cfg->chrootdir && cfg->chrootdir[0] &&
strncmp(cfg->chrootdir, fname, strlen(cfg->chrootdir)) == 0) {
/* already full pathname, return it */
- strncpy(buf, fname, len);
- buf[len] = 0;
+ (void)strlcpy(buf, fname, len);
+ buf[len-1] = 0;
return buf;
}
/* chroot */
if(cfg->chrootdir && cfg->chrootdir[0]) {
/* start with chrootdir */
- strncpy(buf, cfg->chrootdir, len);
+ (void)strlcpy(buf, cfg->chrootdir, len);
slashit = 1;
}
#ifdef UB_ON_WINDOWS
@@ -1230,21 +1265,21 @@ fname_after_chroot(const char* fname, struct config_file* cfg, int use_chdir)
} else if(cfg->directory && cfg->directory[0]) {
/* prepend chdir */
if(slashit && cfg->directory[0] != '/')
- strncat(buf, "/", len-strlen(buf));
+ (void)strlcat(buf, "/", len);
/* is the directory already in the chroot? */
if(cfg->chrootdir && cfg->chrootdir[0] &&
strncmp(cfg->chrootdir, cfg->directory,
strlen(cfg->chrootdir)) == 0)
- strncat(buf, cfg->directory+strlen(cfg->chrootdir),
- len-strlen(buf));
- else strncat(buf, cfg->directory, len-strlen(buf));
+ (void)strlcat(buf, cfg->directory+strlen(cfg->chrootdir),
+ len);
+ else (void)strlcat(buf, cfg->directory, len);
slashit = 1;
}
/* fname */
if(slashit && fname[0] != '/')
- strncat(buf, "/", len-strlen(buf));
- strncat(buf, fname, len-strlen(buf));
- buf[len] = 0;
+ (void)strlcat(buf, "/", len);
+ (void)strlcat(buf, fname, len);
+ buf[len-1] = 0;
return buf;
}
@@ -1295,7 +1330,7 @@ cfg_parse_local_zone(struct config_file* cfg, const char* val)
log_err("syntax error: bad zone name: %s", val);
return 0;
}
- strncpy(buf, name, (size_t)(name_end-name));
+ (void)strlcpy(buf, name, sizeof(buf));
buf[name_end-name] = '\0';
type = last_space_pos(name_end);
@@ -1485,18 +1520,11 @@ char* errinf_to_str(struct module_qstate* qstate)
size_t left = sizeof(buf);
struct config_strlist* s;
char dname[LDNS_MAX_DOMAINLEN+1];
- char* t = ldns_rr_type2str(qstate->qinfo.qtype);
- char* c = ldns_rr_class2str(qstate->qinfo.qclass);
- if(!t || !c) {
- free(t);
- free(c);
- log_err("malloc failure in errinf_to_str");
- return NULL;
- }
+ char t[16], c[16];
+ sldns_wire2str_type_buf(qstate->qinfo.qtype, t, sizeof(t));
+ sldns_wire2str_class_buf(qstate->qinfo.qclass, c, sizeof(c));
dname_str(qstate->qinfo.qname, dname);
snprintf(p, left, "validation failure <%s %s %s>:", dname, t, c);
- free(t);
- free(c);
left -= strlen(p); p += strlen(p);
if(!qstate->errinf)
snprintf(p, left, " misc failure");
@@ -1514,21 +1542,13 @@ void errinf_rrset(struct module_qstate* qstate, struct ub_packed_rrset_key *rr)
{
char buf[1024];
char dname[LDNS_MAX_DOMAINLEN+1];
- char *t, *c;
+ char t[16], c[16];
if(qstate->env->cfg->val_log_level < 2 || !rr)
return;
- t = ldns_rr_type2str(ntohs(rr->rk.type));
- c = ldns_rr_class2str(ntohs(rr->rk.rrset_class));
- if(!t || !c) {
- free(t);
- free(c);
- log_err("malloc failure in errinf_rrset");
- return;
- }
+ sldns_wire2str_type_buf(ntohs(rr->rk.type), t, sizeof(t));
+ sldns_wire2str_class_buf(ntohs(rr->rk.rrset_class), c, sizeof(c));
dname_str(rr->rk.dname, dname);
snprintf(buf, sizeof(buf), "for <%s %s %s>", dname, t, c);
- free(t);
- free(c);
errinf(qstate, buf);
}
diff --git a/contrib/unbound/util/config_file.h b/contrib/unbound/util/config_file.h
index e790cec..f041df1 100644
--- a/contrib/unbound/util/config_file.h
+++ b/contrib/unbound/util/config_file.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -119,6 +119,8 @@ struct config_file {
size_t infra_cache_slabs;
/** max number of hosts in the infra cache */
size_t infra_cache_numhosts;
+ /** delay close of udp-timeouted ports, if 0 no delayclose. in msec */
+ int delay_close;
/** the target fetch policy for the iterator */
char* target_fetch_policy;
@@ -130,6 +132,8 @@ struct config_file {
size_t so_rcvbuf;
/** SO_SNDBUF size to set on port 53 UDP socket */
size_t so_sndbuf;
+ /** SO_REUSEPORT requested on port 53 sockets */
+ int so_reuseport;
/** number of interfaces to open. If 0 default all interfaces. */
int num_ifs;
@@ -269,6 +273,8 @@ struct config_file {
struct config_strlist* local_zones_nodefault;
/** local data RRs configged */
struct config_strlist* local_data;
+ /** unblock lan zones (reverse lookups for 10/8 and so on) */
+ int unblock_lan_zones;
/** remote control section. enable toggle. */
int remote_control_enable;
@@ -296,6 +302,9 @@ struct config_file {
/* RRSet roundrobin */
int rrset_roundrobin;
+
+ /* maximum UDP response size */
+ size_t max_udp_size;
};
/**
@@ -493,7 +502,7 @@ void config_delstubs(struct config_stub* list);
* @param str: string of 14 digits
* @return time value or 0 for error.
*/
-uint32_t cfg_convert_timeval(const char* str);
+time_t cfg_convert_timeval(const char* str);
/**
* Count number of values in the string.
@@ -632,6 +641,8 @@ struct config_parser_state {
/** global config parser object used during config parsing */
extern struct config_parser_state* cfg_parser;
+/** init lex state */
+void init_cfg_parse(void);
/** lex in file */
extern FILE* ub_c_in;
/** lex out file */
diff --git a/contrib/unbound/util/configlexer.c b/contrib/unbound/util/configlexer.c
deleted file mode 100644
index 505c787..0000000
--- a/contrib/unbound/util/configlexer.c
+++ /dev/null
@@ -1,3536 +0,0 @@
-#include "config.h"
-#include "util/configyyrename.h"
-
-#line 3 "<stdout>"
-
-#define YY_INT_ALIGNED short int
-
-/* A lexical scanner generated by flex */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 37
-#if YY_FLEX_SUBMINOR_VERSION > 0
-#define FLEX_BETA
-#endif
-
-/* First, we deal with platform-specific or compiler-specific issues. */
-
-#if defined(__FreeBSD__)
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS
-#endif
-#include <sys/cdefs.h>
-#include <stdint.h>
-#else
-#define __dead2
-#endif
-
-/* begin standard C headers. */
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-
-/* end standard C headers. */
-
-/* flex integer type definitions */
-
-#ifndef FLEXINT_H
-#define FLEXINT_H
-
-/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-
-#if defined(__FreeBSD__) || \
- (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
-
-/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
- * if you want the limit (max/min) macros for int types.
- */
-#ifndef __STDC_LIMIT_MACROS
-#define __STDC_LIMIT_MACROS 1
-#endif
-
-#include <inttypes.h>
-typedef int8_t flex_int8_t;
-typedef uint8_t flex_uint8_t;
-typedef int16_t flex_int16_t;
-typedef uint16_t flex_uint16_t;
-typedef int32_t flex_int32_t;
-typedef uint32_t flex_uint32_t;
-#else
-typedef signed char flex_int8_t;
-typedef short int flex_int16_t;
-typedef int flex_int32_t;
-typedef unsigned char flex_uint8_t;
-typedef unsigned short int flex_uint16_t;
-typedef unsigned int flex_uint32_t;
-
-/* Limits of integral types. */
-#ifndef INT8_MIN
-#define INT8_MIN (-128)
-#endif
-#ifndef INT16_MIN
-#define INT16_MIN (-32767-1)
-#endif
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647-1)
-#endif
-#ifndef INT8_MAX
-#define INT8_MAX (127)
-#endif
-#ifndef INT16_MAX
-#define INT16_MAX (32767)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX (2147483647)
-#endif
-#ifndef UINT8_MAX
-#define UINT8_MAX (255U)
-#endif
-#ifndef UINT16_MAX
-#define UINT16_MAX (65535U)
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX (4294967295U)
-#endif
-
-#endif /* ! C99 */
-
-#endif /* ! FLEXINT_H */
-
-#ifdef __cplusplus
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
-
-#define YY_USE_CONST
-
-#endif /* defined (__STDC__) */
-#endif /* ! __cplusplus */
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN (yy_start) = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START (((yy_start) - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart(yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#ifndef YY_BUF_SIZE
-#define YY_BUF_SIZE 16384
-#endif
-
-/* The state buf must be large enough to hold one state per character in the main buffer.
- */
-#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
-
-#ifndef YY_TYPEDEF_YY_BUFFER_STATE
-#define YY_TYPEDEF_YY_BUFFER_STATE
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-#endif
-
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
-extern yy_size_t yyleng;
-
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
- #define YY_LESS_LINENO(n)
-
-/* Return all but the first "n" matched characters back to the input stream. */
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- *yy_cp = (yy_hold_char); \
- YY_RESTORE_YY_MORE_OFFSET \
- (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, (yytext_ptr) )
-
-#ifndef YY_STRUCT_YY_BUFFER_STATE
-#define YY_STRUCT_YY_BUFFER_STATE
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- yy_size_t yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- int yy_bs_lineno; /**< The line count. */
- int yy_bs_column; /**< The column count. */
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
-
- };
-#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-
-/* Stack of input buffers. */
-static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
-static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
-static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- *
- * Returns the top of the stack, or NULL.
- */
-#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
- ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
- : NULL)
-#define yy_current_buffer YY_CURRENT_BUFFER
-
-/* Same as previous macro, but useful when we know that the buffer stack is not
- * NULL or when we need an lvalue. For internal use only.
- */
-#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
-yy_size_t yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 0; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart (FILE *input_file );
-void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
-YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
-void yy_delete_buffer (YY_BUFFER_STATE b );
-void yy_flush_buffer (YY_BUFFER_STATE b );
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
-void yypop_buffer_state (void );
-
-static void yyensure_buffer_stack (void );
-static void yy_load_buffer_state (void );
-static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
-
-#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
-
-YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
-YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
-
-void *yyalloc (yy_size_t );
-void *yyrealloc (void *,yy_size_t );
-void yyfree (void * );
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! YY_CURRENT_BUFFER ){ \
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! YY_CURRENT_BUFFER ){\
- yyensure_buffer_stack (); \
- YY_CURRENT_BUFFER_LVALUE = \
- yy_create_buffer(yyin,YY_BUF_SIZE ); \
- } \
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-
-/* Begin user sect3 */
-
-typedef unsigned char YY_CHAR;
-
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-
-typedef int yy_state_type;
-
-extern int yylineno;
-
-int yylineno = 1;
-
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state (void );
-static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
-static int yy_get_next_buffer (void );
-static void yy_fatal_error (yyconst char msg[] ) __dead2;
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- (yytext_ptr) = yy_bp; \
- (yytext_ptr) -= (yy_more_len); \
- yyleng = (size_t) (yy_cp - (yytext_ptr)); \
- (yy_hold_char) = *yy_cp; \
- *yy_cp = '\0'; \
- (yy_c_buf_p) = yy_cp;
-
-#define YY_NUM_RULES 142
-#define YY_END_OF_BUFFER 143
-/* This struct is not used in this scanner,
- but its presence is necessary. */
-struct yy_trans_info
- {
- flex_int32_t yy_verify;
- flex_int32_t yy_nxt;
- };
-static yyconst flex_int16_t yy_accept[1343] =
- { 0,
- 1, 1, 124, 124, 128, 128, 132, 132, 136, 136,
- 1, 1, 143, 140, 1, 122, 122, 141, 2, 141,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 124,
- 125, 125, 126, 141, 128, 129, 129, 130, 141, 135,
- 132, 133, 133, 134, 141, 136, 137, 137, 138, 141,
- 139, 123, 2, 127, 141, 139, 140, 0, 1, 2,
- 2, 2, 2, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 124,
- 0, 128, 0, 135, 0, 132, 136, 0, 139, 0,
- 2, 2, 139, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 139, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 139,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 62, 140, 140,
- 140, 140, 140, 6, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 139, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 140, 139, 140, 140, 140, 140, 27,
- 140, 140, 140, 140, 140, 12, 13, 140, 15, 14,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 118, 140, 140, 140, 140,
- 140, 3, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 139, 140, 140, 140, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 131, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 30,
- 140, 140, 140, 140, 140, 140, 140, 140, 31, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 77, 131, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 140, 140, 140, 140, 76, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 60, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 20, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 28, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 29, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 22, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 25, 26, 140, 140, 140, 63, 140, 64,
- 140, 61, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 5, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 79,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 104, 103, 140,
-
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 32, 140, 140,
- 140, 140, 140, 140, 140, 66, 65, 140, 140, 140,
- 140, 140, 140, 100, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 51, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 102, 140, 140, 140, 140, 140, 140, 140, 140,
- 4, 140, 140, 140, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 97, 140, 140, 140, 140, 140, 140, 140,
- 112, 98, 140, 21, 140, 140, 140, 140, 68, 140,
- 69, 67, 140, 140, 140, 140, 140, 140, 75, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 99, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 59, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 17, 140, 140, 140, 16,
- 140, 84, 140, 140, 140, 140, 140, 140, 140, 140,
-
- 140, 140, 140, 140, 39, 40, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 70, 140, 140, 140,
- 140, 140, 74, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 78, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 117,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 88, 140, 92, 140, 140,
- 140, 140, 73, 140, 140, 110, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 91,
- 140, 140, 140, 140, 41, 42, 140, 47, 93, 140,
-
- 105, 101, 140, 140, 35, 140, 95, 140, 140, 140,
- 140, 140, 7, 140, 58, 109, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 80, 140, 140, 119, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 94, 140, 34, 36,
- 140, 140, 140, 140, 140, 57, 140, 140, 140, 140,
- 113, 18, 19, 140, 140, 140, 140, 140, 140, 55,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 115,
- 140, 140, 33, 140, 140, 140, 140, 140, 140, 11,
-
- 140, 140, 140, 140, 140, 140, 140, 10, 140, 140,
- 37, 140, 121, 114, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 140, 87, 86, 140, 116, 111, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 43,
- 140, 120, 140, 140, 140, 140, 38, 140, 140, 140,
- 81, 83, 140, 140, 140, 85, 140, 140, 140, 140,
- 140, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 23, 140, 140, 140, 140, 140, 140, 140, 140, 140,
- 140, 140, 140, 108, 140, 140, 140, 140, 140, 140,
- 140, 24, 140, 9, 140, 140, 106, 48, 140, 140,
-
- 140, 90, 140, 71, 140, 140, 140, 50, 54, 49,
- 140, 44, 140, 8, 140, 140, 89, 140, 140, 140,
- 53, 140, 45, 140, 107, 140, 140, 82, 72, 52,
- 46, 140, 140, 140, 140, 56, 140, 140, 140, 140,
- 96, 0
- } ;
-
-static yyconst flex_int32_t yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 5, 6, 1, 1, 1, 7, 1,
- 1, 1, 1, 1, 8, 1, 1, 1, 1, 1,
- 9, 10, 1, 11, 1, 1, 1, 12, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 13, 1, 1, 1, 1, 14, 15, 16, 17,
-
- 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
- 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
- 38, 39, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst flex_int32_t yy_meta[40] =
- { 0,
- 1, 2, 3, 4, 5, 1, 6, 1, 1, 1,
- 1, 7, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1
- } ;
-
-static yyconst flex_int16_t yy_base[1357] =
- { 0,
- 0, 0, 37, 40, 44, 51, 63, 75, 56, 68,
- 87, 108, 2577, 2563, 50, 2683, 2683, 2683, 129, 94,
- 70, 104, 122, 90, 92, 115, 126, 95, 84, 132,
- 135, 138, 50, 142, 148, 156, 169, 164, 179, 2493,
- 2683, 2683, 2683, 70, 2371, 2683, 2683, 2683, 42, 2326,
- 1987, 2683, 2683, 2683, 197, 1681, 2683, 2683, 2683, 154,
- 1191, 2683, 201, 2683, 205, 111, 1082, 211, 120, 0,
- 222, 0, 0, 103, 158, 165, 149, 155, 168, 206,
- 207, 198, 217, 209, 204, 208, 215, 177, 136, 227,
- 228, 219, 232, 236, 235, 240, 245, 229, 246, 247,
-
- 250, 251, 254, 256, 258, 262, 259, 263, 266, 269,
- 267, 276, 268, 271, 273, 49, 280, 281, 283, 853,
- 297, 751, 301, 603, 311, 572, 360, 299, 298, 315,
- 319, 0, 296, 312, 320, 314, 316, 318, 321, 327,
- 323, 330, 342, 331, 326, 334, 335, 336, 338, 347,
- 337, 353, 348, 344, 350, 355, 359, 372, 369, 367,
- 357, 379, 377, 385, 386, 383, 387, 384, 388, 389,
- 391, 392, 395, 396, 397, 398, 405, 402, 406, 403,
- 414, 412, 420, 418, 428, 424, 425, 427, 430, 434,
- 435, 432, 433, 441, 439, 444, 452, 448, 450, 454,
-
- 455, 458, 461, 460, 462, 466, 473, 469, 470, 472,
- 477, 475, 478, 479, 485, 481, 482, 483, 486, 492,
- 487, 504, 498, 508, 501, 502, 510, 513, 509, 515,
- 520, 522, 528, 524, 525, 526, 527, 531, 534, 537,
- 533, 536, 539, 540, 545, 546, 565, 551, 549, 553,
- 556, 555, 562, 576, 563, 572, 573, 569, 578, 585,
- 596, 586, 591, 595, 598, 597, 600, 601, 602, 605,
- 608, 610, 609, 620, 623, 622, 621, 624, 630, 638,
- 625, 632, 635, 639, 643, 634, 644, 2683, 649, 636,
- 651, 652, 642, 2683, 653, 656, 658, 660, 662, 668,
-
- 664, 666, 667, 669, 674, 675, 677, 697, 680, 678,
- 690, 681, 686, 683, 692, 689, 699, 702, 706, 707,
- 709, 710, 712, 715, 716, 726, 722, 718, 724, 728,
- 732, 733, 735, 738, 739, 743, 747, 753, 755, 757,
- 763, 740, 759, 762, 765, 767, 768, 749, 775, 772,
- 774, 778, 779, 787, 776, 789, 791, 793, 783, 794,
- 797, 805, 801, 803, 808, 810, 784, 804, 814, 813,
- 820, 827, 828, 812, 829, 835, 831, 836, 824, 837,
- 839, 840, 841, 843, 844, 846, 848, 854, 850, 856,
- 861, 862, 866, 851, 868, 871, 872, 873, 874, 883,
-
- 875, 884, 876, 886, 887, 894, 895, 889, 902, 2683,
- 901, 904, 898, 905, 906, 2683, 2683, 890, 2683, 2683,
- 909, 914, 915, 917, 922, 923, 925, 927, 930, 932,
- 935, 936, 938, 944, 946, 939, 947, 948, 950, 954,
- 955, 957, 961, 963, 964, 965, 968, 970, 972, 974,
- 975, 981, 977, 988, 984, 2683, 986, 987, 991, 993,
- 994, 2683, 995, 996, 998, 999, 1000, 1002, 1006, 1004,
- 1007, 1014, 1013, 1009, 1012, 1019, 1029, 1030, 1025, 1028,
- 1031, 1035, 1037, 1046, 1039, 1043, 1045, 1052, 1048, 1050,
- 1054, 1051, 1055, 1057, 1060, 1063, 1085, 1065, 1062, 1064,
-
- 1067, 1070, 1072, 1074, 1078, 1092, 1097, 1075, 1071, 1103,
- 1105, 1099, 1095, 1106, 1112, 1113, 2683, 1119, 1120, 1108,
- 1115, 1116, 1122, 1124, 1129, 1126, 1130, 1132, 1138, 2683,
- 1135, 1136, 1137, 1140, 1147, 1139, 1149, 1159, 2683, 1161,
- 1162, 1155, 1157, 1164, 1165, 1167, 1169, 1170, 1171, 1173,
- 1181, 1176, 1178, 1183, 1182, 1187, 1189, 1190, 1192, 1193,
- 1194, 1199, 1204, 1210, 1213, 1201, 1218, 1195, 1207, 1211,
- 1224, 1219, 1222, 1225, 1226, 2683, 174, 1227, 1228, 1229,
- 1235, 1238, 1234, 1232, 1236, 1240, 1242, 1247, 1253, 1248,
- 1254, 1255, 1256, 1259, 1258, 1261, 1267, 1268, 1269, 1270,
-
- 1271, 1272, 1273, 1274, 1279, 1278, 1286, 2683, 1292, 1285,
- 1281, 1288, 1296, 1305, 1297, 1302, 1312, 1313, 1315, 1316,
- 1317, 1319, 1309, 1322, 1330, 1331, 1327, 1329, 1328, 1334,
- 2683, 1335, 1336, 1338, 1341, 1343, 1349, 1347, 1348, 1350,
- 1353, 1359, 2683, 1303, 1360, 1354, 1364, 1367, 1369, 1371,
- 1378, 1370, 1374, 1372, 1381, 1382, 1383, 1384, 2683, 1393,
- 1397, 1394, 1401, 1395, 1398, 1402, 1406, 1403, 1385, 1412,
- 1409, 1410, 1414, 1415, 1411, 1418, 1419, 1421, 2683, 1425,
- 1422, 1427, 1428, 1434, 1426, 1435, 1436, 1438, 1441, 1447,
- 1440, 1451, 1442, 1453, 1450, 1460, 1461, 1464, 1463, 1466,
-
- 1472, 1478, 1474, 2683, 1477, 1465, 1480, 1486, 1488, 1483,
- 1489, 1490, 1491, 1498, 1492, 1494, 1495, 1496, 1503, 1500,
- 1501, 1504, 1507, 1506, 1518, 1519, 1520, 1523, 1524, 1526,
- 1525, 1532, 2683, 2683, 1533, 1534, 1541, 2683, 1543, 2683,
- 1547, 2683, 1548, 1549, 1537, 1539, 1553, 1544, 1555, 1556,
- 1560, 1557, 1562, 1563, 1565, 1566, 2683, 1568, 1569, 1574,
- 1570, 1572, 1577, 1578, 1582, 1593, 1581, 1585, 1589, 2683,
- 1591, 1594, 1600, 1607, 1604, 1598, 1606, 1608, 1609, 1610,
- 1612, 1621, 1613, 1611, 1615, 1622, 1623, 1624, 1626, 1632,
- 1630, 1631, 1634, 1638, 1640, 1645, 1643, 2683, 2683, 1649,
-
- 1641, 1646, 1652, 1656, 1658, 1660, 1668, 1665, 1666, 1671,
- 1672, 1673, 1674, 1676, 1677, 1679, 1680, 2683, 1688, 1682,
- 1696, 1697, 1706, 1689, 1704, 2683, 2683, 1685, 1692, 1708,
- 1709, 1711, 1712, 2683, 1714, 1715, 1716, 1717, 1718, 1720,
- 1710, 1724, 1732, 1735, 1725, 1736, 1743, 1740, 1741, 1744,
- 1746, 1754, 1742, 1756, 1762, 1747, 1758, 1760, 1764, 1761,
- 1766, 1770, 1772, 1771, 2683, 1778, 1775, 1784, 1776, 1783,
- 1785, 1792, 1788, 1789, 1790, 1791, 1794, 1796, 1797, 1798,
- 1804, 2683, 1803, 1805, 1806, 1808, 1814, 1818, 1816, 1821,
- 2683, 1822, 1830, 1826, 1828, 1832, 1829, 1836, 1833, 1839,
-
- 1838, 1841, 1843, 1850, 1844, 1848, 1851, 1852, 1863, 1862,
- 1869, 1870, 1867, 1876, 1873, 1874, 1875, 1877, 1886, 1882,
- 1888, 1880, 2683, 1890, 1895, 1897, 1899, 1884, 1900, 1898,
- 2683, 2683, 1891, 2683, 1908, 1901, 1912, 1913, 2683, 1911,
- 2683, 2683, 1914, 1923, 1915, 1916, 1924, 1930, 2683, 1927,
- 1925, 1935, 1931, 1937, 1938, 1939, 1933, 1940, 2683, 1941,
- 1942, 1943, 1947, 1953, 1955, 1957, 1958, 1962, 1965, 1966,
- 1959, 1968, 1974, 1973, 2683, 1972, 1975, 1980, 1981, 1985,
- 1982, 1986, 1987, 1996, 1998, 2683, 1992, 1990, 2000, 2683,
- 2002, 2683, 2006, 2004, 2009, 2014, 2011, 2022, 2007, 2015,
-
- 2023, 2017, 2025, 2027, 2683, 2683, 2031, 2033, 2036, 2034,
- 2038, 2041, 2039, 2042, 2044, 2048, 2683, 2049, 2050, 2051,
- 2052, 2053, 2683, 2056, 2057, 2058, 2062, 2065, 2077, 2079,
- 2068, 2083, 2085, 2061, 2087, 2089, 2090, 2683, 2091, 2093,
- 2094, 2098, 2099, 2095, 2100, 2104, 2107, 2102, 2111, 2683,
- 2115, 2108, 2118, 2116, 2112, 2122, 2123, 2126, 2128, 2130,
- 2129, 2131, 2132, 2138, 2059, 2683, 2136, 2683, 2137, 2142,
- 2150, 2151, 2683, 2147, 2153, 2683, 2154, 2158, 2167, 2155,
- 2161, 2169, 2170, 2171, 2172, 2173, 2174, 2182, 2178, 2683,
- 2180, 2181, 2187, 2183, 2683, 2683, 2188, 2683, 2683, 2198,
-
- 2683, 2683, 2194, 2201, 2683, 2203, 2683, 2209, 2205, 2192,
- 2190, 2210, 2683, 2214, 2683, 2683, 2211, 2217, 2207, 2218,
- 2225, 2227, 2229, 2220, 2222, 2230, 2231, 2233, 2234, 2236,
- 2237, 2238, 2239, 2244, 2241, 2247, 2248, 2250, 2251, 2253,
- 2683, 2249, 2262, 2683, 2269, 2270, 2258, 2260, 2271, 2272,
- 2274, 2276, 2282, 2280, 2281, 2283, 2683, 2285, 2683, 2683,
- 2286, 2284, 2291, 2292, 2294, 2683, 2297, 2298, 2302, 2309,
- 2683, 2683, 2683, 2310, 2299, 2305, 2313, 2315, 2316, 2683,
- 2319, 2322, 2323, 2325, 2330, 2332, 2338, 2336, 2342, 2683,
- 2339, 2337, 2683, 2343, 2345, 2347, 2348, 2350, 2352, 2683,
-
- 2353, 2354, 2360, 2355, 2363, 2366, 2365, 2683, 2367, 2368,
- 2683, 2378, 2683, 2683, 2369, 2379, 2382, 2384, 2387, 2375,
- 2388, 2395, 2392, 2394, 2683, 2683, 2397, 2683, 2683, 2396,
- 2399, 2400, 2404, 2401, 2406, 2408, 2409, 2412, 2410, 2683,
- 2413, 2683, 2414, 2423, 2420, 2418, 2683, 2425, 2426, 2429,
- 2683, 2683, 2431, 2439, 2433, 2683, 2441, 2443, 2437, 2444,
- 2448, 2449, 2445, 2450, 2455, 2457, 2451, 2453, 2465, 2466,
- 2683, 2468, 2460, 2470, 2474, 2476, 2478, 2479, 2481, 2483,
- 2484, 2486, 2487, 2683, 2488, 2489, 2499, 2504, 2508, 2490,
- 2510, 2683, 2511, 2683, 2514, 2500, 2683, 2683, 2515, 2517,
-
- 2519, 2683, 2520, 2683, 2518, 2522, 2526, 2683, 2683, 2683,
- 2528, 2683, 2529, 2683, 2532, 2534, 2683, 2535, 2537, 2540,
- 2683, 2542, 2683, 2544, 2683, 2545, 2546, 2683, 2683, 2683,
- 2683, 2548, 2550, 2555, 2551, 2683, 2556, 2558, 2559, 2562,
- 2683, 2683, 2591, 2598, 2605, 2612, 2619, 94, 2626, 2633,
- 2640, 2647, 2654, 2661, 2668, 2675
- } ;
-
-static yyconst flex_int16_t yy_def[1357] =
- { 0,
- 1342, 1, 1343, 1343, 1344, 1344, 1345, 1345, 1346, 1346,
- 1347, 1347, 1342, 1348, 1342, 1342, 1342, 1342, 1349, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1350,
- 1342, 1342, 1342, 1350, 1351, 1342, 1342, 1342, 1351, 1352,
- 1342, 1342, 1342, 1342, 1352, 1353, 1342, 1342, 1342, 1353,
- 1354, 1342, 1355, 1342, 1354, 1354, 1348, 1348, 1342, 1356,
- 1349, 1356, 1349, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1350,
- 1350, 1351, 1351, 1352, 1352, 1342, 1353, 1353, 1354, 1354,
- 1355, 1355, 1354, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1354, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1354,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348,
- 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1354, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1348, 1354, 1348, 1348, 1348, 1348, 1342,
- 1348, 1348, 1348, 1348, 1348, 1342, 1342, 1348, 1342, 1342,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348,
- 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1354, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1342, 1354, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1342, 1342, 1348, 1348, 1348, 1342, 1348, 1342,
- 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1342, 1348,
-
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1342, 1342, 1348, 1348, 1348,
- 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1342, 1342, 1348, 1342, 1348, 1348, 1348, 1348, 1342, 1348,
- 1342, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1342,
- 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
-
- 1348, 1348, 1348, 1348, 1342, 1342, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348,
- 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1342, 1348, 1348,
- 1348, 1348, 1342, 1348, 1348, 1342, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342,
- 1348, 1348, 1348, 1348, 1342, 1342, 1348, 1342, 1342, 1348,
-
- 1342, 1342, 1348, 1348, 1342, 1348, 1342, 1348, 1348, 1348,
- 1348, 1348, 1342, 1348, 1342, 1342, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1342, 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1342, 1342,
- 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348,
- 1342, 1342, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1342,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342,
- 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1342,
-
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342, 1348, 1348,
- 1342, 1348, 1342, 1342, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1342, 1342, 1348, 1342, 1342, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1342,
- 1348, 1342, 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348,
- 1342, 1342, 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1342, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348, 1348, 1348,
- 1348, 1342, 1348, 1342, 1348, 1348, 1342, 1342, 1348, 1348,
-
- 1348, 1342, 1348, 1342, 1348, 1348, 1348, 1342, 1342, 1342,
- 1348, 1342, 1348, 1342, 1348, 1348, 1342, 1348, 1348, 1348,
- 1342, 1348, 1342, 1348, 1342, 1348, 1348, 1342, 1342, 1342,
- 1342, 1348, 1348, 1348, 1348, 1342, 1348, 1348, 1348, 1348,
- 1342, 0, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
- 1342, 1342, 1342, 1342, 1342, 1342
- } ;
-
-static yyconst flex_int16_t yy_nxt[2723] =
- { 0,
- 14, 15, 16, 17, 18, 19, 18, 14, 14, 14,
- 14, 18, 20, 21, 14, 22, 23, 24, 25, 14,
- 26, 27, 28, 29, 30, 31, 32, 33, 34, 14,
- 35, 36, 37, 38, 39, 14, 14, 14, 14, 41,
- 42, 43, 41, 42, 43, 122, 46, 47, 122, 44,
- 48, 69, 44, 46, 47, 70, 49, 48, 57, 58,
- 59, 68, 68, 49, 51, 52, 53, 54, 60, 18,
- 57, 58, 59, 120, 120, 55, 51, 52, 53, 54,
- 60, 18, 68, 101, 183, 74, 75, 55, 15, 16,
- 17, 62, 63, 64, 67, 67, 68, 67, 67, 65,
-
- 67, 93, 68, 76, 68, 67, 84, 68, 66, 15,
- 16, 17, 62, 63, 64, 68, 68, 77, 134, 86,
- 65, 69, 92, 130, 78, 70, 85, 68, 87, 66,
- 72, 79, 72, 72, 68, 72, 88, 133, 68, 80,
- 72, 73, 89, 81, 68, 90, 82, 68, 68, 83,
- 68, 98, 91, 150, 68, 99, 95, 127, 127, 94,
- 68, 68, 96, 102, 137, 106, 97, 68, 68, 103,
- 68, 100, 104, 109, 135, 107, 68, 68, 108, 105,
- 68, 68, 113, 110, 114, 138, 130, 111, 112, 68,
- 116, 68, 118, 149, 139, 117, 119, 136, 124, 115,
-
- 124, 124, 72, 124, 72, 72, 129, 72, 129, 129,
- 68, 129, 67, 132, 67, 67, 68, 67, 68, 68,
- 68, 68, 67, 72, 143, 72, 72, 68, 72, 68,
- 140, 68, 142, 72, 73, 145, 146, 141, 147, 68,
- 68, 68, 144, 152, 68, 148, 153, 68, 68, 156,
- 155, 158, 68, 151, 163, 159, 161, 68, 68, 68,
- 154, 160, 68, 68, 162, 164, 68, 167, 68, 157,
- 68, 68, 165, 169, 68, 68, 176, 170, 68, 68,
- 68, 68, 166, 68, 168, 68, 173, 172, 68, 178,
- 171, 177, 68, 68, 174, 68, 175, 184, 180, 181,
-
- 120, 120, 127, 127, 122, 185, 182, 122, 130, 179,
- 130, 187, 124, 186, 124, 124, 129, 124, 129, 129,
- 72, 129, 72, 72, 68, 72, 68, 189, 68, 188,
- 68, 132, 68, 68, 194, 68, 191, 196, 68, 68,
- 195, 190, 68, 68, 202, 192, 68, 68, 68, 68,
- 68, 204, 206, 193, 68, 207, 68, 203, 197, 68,
- 68, 213, 68, 198, 209, 68, 216, 68, 199, 68,
- 205, 68, 128, 208, 200, 201, 218, 210, 212, 68,
- 211, 68, 214, 215, 68, 217, 222, 219, 220, 68,
- 221, 68, 224, 225, 223, 68, 68, 68, 68, 68,
-
- 68, 68, 226, 68, 68, 227, 229, 68, 68, 68,
- 68, 231, 238, 234, 68, 68, 228, 68, 68, 232,
- 240, 242, 241, 230, 68, 245, 68, 233, 236, 237,
- 68, 235, 68, 244, 239, 247, 68, 130, 248, 68,
- 68, 253, 68, 243, 68, 68, 68, 68, 246, 250,
- 252, 68, 254, 68, 258, 249, 68, 259, 251, 255,
- 68, 257, 68, 256, 68, 260, 68, 68, 266, 263,
- 68, 264, 68, 68, 68, 268, 261, 262, 68, 265,
- 270, 68, 68, 269, 68, 68, 267, 68, 275, 68,
- 68, 68, 278, 68, 68, 68, 279, 68, 68, 68,
-
- 272, 271, 274, 277, 68, 273, 280, 283, 276, 288,
- 68, 285, 281, 68, 68, 282, 68, 284, 286, 287,
- 68, 68, 68, 289, 294, 68, 295, 68, 296, 292,
- 290, 293, 68, 291, 68, 299, 68, 68, 68, 68,
- 68, 302, 301, 68, 308, 68, 68, 297, 68, 68,
- 309, 68, 68, 303, 298, 307, 300, 68, 68, 304,
- 313, 68, 305, 68, 306, 130, 312, 68, 68, 310,
- 324, 311, 315, 126, 68, 68, 314, 68, 323, 316,
- 317, 68, 327, 329, 68, 68, 325, 326, 68, 318,
- 68, 319, 320, 321, 328, 330, 322, 68, 68, 331,
-
- 332, 333, 335, 68, 334, 336, 337, 68, 68, 68,
- 68, 342, 68, 68, 68, 125, 343, 68, 338, 339,
- 68, 68, 68, 340, 341, 350, 346, 349, 345, 348,
- 352, 344, 68, 68, 68, 68, 68, 68, 354, 347,
- 353, 351, 68, 356, 68, 357, 68, 68, 68, 355,
- 68, 68, 361, 359, 68, 68, 68, 364, 358, 360,
- 362, 68, 365, 68, 68, 68, 369, 363, 68, 366,
- 68, 367, 68, 368, 68, 375, 68, 373, 68, 68,
- 68, 68, 374, 378, 372, 370, 68, 68, 371, 68,
- 68, 380, 68, 68, 376, 68, 379, 390, 68, 393,
-
- 377, 68, 68, 381, 68, 395, 389, 391, 382, 68,
- 383, 68, 388, 392, 68, 384, 396, 385, 68, 68,
- 394, 68, 68, 397, 68, 386, 401, 68, 130, 398,
- 68, 402, 405, 406, 68, 387, 68, 399, 68, 410,
- 68, 400, 404, 403, 68, 68, 407, 68, 408, 409,
- 68, 68, 68, 414, 416, 68, 411, 412, 417, 68,
- 418, 68, 413, 123, 415, 68, 419, 68, 420, 68,
- 421, 68, 425, 422, 68, 68, 423, 68, 424, 68,
- 68, 428, 429, 426, 68, 427, 68, 68, 68, 430,
- 68, 68, 435, 432, 436, 68, 68, 437, 433, 68,
-
- 431, 68, 434, 68, 438, 68, 68, 439, 442, 68,
- 441, 443, 445, 68, 450, 68, 68, 68, 447, 446,
- 68, 444, 68, 448, 68, 68, 68, 449, 453, 440,
- 451, 452, 68, 458, 455, 457, 68, 454, 456, 68,
- 68, 68, 461, 68, 459, 463, 462, 68, 68, 68,
- 464, 68, 68, 68, 465, 68, 68, 469, 68, 460,
- 68, 474, 68, 68, 470, 121, 68, 466, 68, 476,
- 467, 471, 468, 68, 68, 473, 472, 477, 68, 478,
- 68, 475, 480, 68, 68, 68, 68, 68, 68, 483,
- 482, 485, 484, 481, 479, 68, 68, 489, 68, 130,
-
- 486, 68, 68, 488, 491, 487, 68, 68, 497, 492,
- 68, 493, 490, 68, 68, 495, 68, 68, 68, 502,
- 498, 68, 494, 496, 506, 500, 68, 68, 499, 68,
- 503, 505, 504, 501, 68, 68, 507, 68, 508, 68,
- 513, 509, 68, 517, 68, 516, 510, 68, 68, 519,
- 68, 68, 511, 512, 518, 514, 68, 521, 68, 68,
- 68, 522, 68, 526, 515, 520, 68, 68, 525, 68,
- 531, 523, 530, 68, 529, 68, 68, 68, 524, 532,
- 68, 527, 68, 533, 68, 528, 68, 68, 534, 68,
- 535, 537, 539, 68, 538, 541, 68, 540, 68, 68,
-
- 68, 543, 536, 68, 545, 68, 68, 68, 68, 547,
- 68, 68, 68, 544, 68, 542, 68, 548, 68, 68,
- 546, 68, 555, 554, 68, 68, 68, 560, 549, 550,
- 551, 68, 553, 552, 556, 558, 563, 68, 557, 559,
- 68, 68, 68, 68, 561, 562, 564, 68, 567, 68,
- 569, 68, 566, 570, 571, 68, 565, 68, 68, 574,
- 68, 576, 68, 68, 68, 577, 130, 68, 568, 68,
- 573, 579, 68, 572, 68, 68, 68, 68, 578, 68,
- 575, 588, 68, 68, 68, 595, 68, 68, 580, 582,
- 68, 590, 594, 591, 68, 602, 581, 68, 593, 589,
-
- 583, 601, 584, 592, 68, 596, 585, 68, 586, 68,
- 597, 68, 598, 587, 600, 68, 603, 68, 68, 605,
- 68, 606, 604, 608, 68, 68, 610, 68, 68, 609,
- 599, 68, 68, 614, 68, 611, 68, 607, 68, 612,
- 613, 68, 68, 615, 68, 621, 617, 68, 68, 68,
- 68, 68, 68, 620, 624, 616, 619, 625, 618, 68,
- 627, 68, 628, 623, 626, 622, 629, 68, 630, 68,
- 634, 68, 631, 68, 68, 632, 68, 68, 633, 68,
- 637, 68, 68, 68, 635, 68, 639, 640, 68, 641,
- 68, 642, 643, 68, 68, 68, 636, 644, 646, 68,
-
- 638, 68, 68, 130, 68, 68, 68, 68, 645, 651,
- 652, 68, 647, 68, 654, 650, 68, 656, 648, 68,
- 657, 649, 68, 68, 653, 68, 660, 655, 658, 659,
- 68, 68, 663, 661, 68, 662, 68, 68, 68, 68,
- 68, 68, 671, 665, 68, 672, 68, 68, 68, 664,
- 68, 673, 68, 668, 68, 669, 666, 676, 674, 68,
- 68, 670, 675, 667, 679, 68, 68, 68, 68, 677,
- 68, 68, 682, 68, 678, 681, 684, 686, 680, 68,
- 68, 68, 68, 68, 68, 68, 68, 683, 687, 685,
- 68, 68, 694, 68, 690, 688, 689, 68, 68, 698,
-
- 68, 700, 691, 693, 68, 692, 695, 697, 68, 68,
- 696, 699, 703, 702, 68, 68, 704, 68, 735, 707,
- 701, 68, 705, 706, 68, 68, 708, 68, 68, 68,
- 711, 68, 709, 710, 68, 713, 712, 715, 716, 68,
- 68, 68, 68, 68, 717, 718, 68, 68, 68, 719,
- 68, 724, 714, 68, 720, 68, 721, 723, 722, 68,
- 68, 68, 68, 725, 733, 68, 68, 727, 726, 729,
- 734, 68, 68, 730, 728, 738, 68, 736, 731, 68,
- 740, 68, 68, 68, 68, 737, 68, 732, 741, 742,
- 68, 744, 745, 68, 68, 68, 68, 68, 746, 739,
-
- 750, 748, 743, 749, 751, 68, 68, 68, 753, 68,
- 68, 752, 747, 68, 68, 68, 754, 757, 68, 760,
- 759, 68, 68, 68, 68, 756, 68, 68, 764, 755,
- 68, 68, 769, 68, 68, 758, 770, 68, 68, 68,
- 68, 761, 762, 765, 763, 773, 68, 68, 68, 767,
- 68, 776, 68, 68, 68, 766, 768, 772, 775, 68,
- 771, 783, 68, 68, 774, 68, 777, 779, 782, 778,
- 784, 781, 68, 68, 780, 68, 68, 68, 68, 791,
- 785, 786, 788, 790, 68, 792, 68, 793, 787, 68,
- 68, 795, 68, 797, 794, 68, 789, 798, 68, 799,
-
- 68, 68, 68, 68, 68, 804, 68, 68, 68, 803,
- 68, 796, 68, 68, 800, 68, 68, 812, 68, 68,
- 801, 802, 814, 805, 813, 806, 807, 808, 811, 809,
- 68, 68, 68, 810, 818, 68, 68, 68, 68, 822,
- 816, 819, 820, 815, 68, 68, 68, 824, 825, 68,
- 823, 68, 817, 68, 826, 68, 68, 821, 827, 68,
- 68, 68, 829, 828, 830, 68, 834, 68, 68, 68,
- 832, 833, 68, 836, 68, 68, 831, 68, 68, 839,
- 68, 68, 68, 841, 68, 838, 68, 844, 835, 68,
- 68, 837, 848, 68, 68, 843, 840, 68, 842, 849,
-
- 850, 68, 845, 68, 846, 68, 68, 853, 854, 847,
- 68, 852, 68, 851, 857, 856, 68, 858, 68, 68,
- 68, 68, 68, 68, 68, 68, 862, 68, 859, 864,
- 866, 855, 865, 68, 68, 68, 68, 860, 68, 873,
- 861, 867, 68, 68, 68, 863, 68, 868, 871, 870,
- 68, 872, 68, 68, 869, 68, 883, 68, 68, 878,
- 882, 68, 874, 875, 68, 877, 879, 876, 68, 880,
- 68, 881, 68, 885, 884, 890, 891, 68, 68, 887,
- 68, 889, 888, 68, 68, 68, 68, 886, 68, 68,
- 898, 68, 68, 128, 68, 901, 893, 68, 892, 895,
-
- 68, 68, 894, 903, 68, 909, 897, 899, 68, 68,
- 900, 896, 902, 905, 906, 904, 68, 910, 68, 907,
- 68, 68, 68, 68, 68, 908, 68, 68, 68, 68,
- 68, 916, 68, 917, 918, 919, 68, 68, 911, 913,
- 912, 920, 914, 923, 68, 921, 915, 68, 68, 925,
- 927, 922, 68, 68, 68, 68, 68, 931, 68, 68,
- 926, 924, 930, 933, 928, 932, 68, 934, 68, 935,
- 68, 929, 68, 68, 68, 939, 68, 941, 68, 943,
- 936, 942, 68, 68, 68, 945, 944, 68, 68, 937,
- 68, 947, 938, 940, 949, 68, 68, 68, 950, 951,
-
- 68, 68, 68, 68, 68, 946, 68, 959, 68, 68,
- 68, 961, 952, 948, 953, 68, 68, 68, 68, 954,
- 68, 955, 956, 957, 963, 965, 68, 958, 68, 966,
- 68, 968, 964, 68, 68, 960, 962, 972, 68, 971,
- 68, 68, 68, 975, 68, 68, 976, 974, 68, 970,
- 68, 68, 967, 68, 969, 68, 68, 977, 973, 986,
- 68, 982, 68, 68, 68, 978, 979, 984, 981, 980,
- 989, 983, 985, 990, 68, 68, 991, 993, 988, 68,
- 992, 68, 68, 995, 987, 68, 68, 68, 68, 68,
- 997, 994, 68, 1000, 68, 1002, 68, 996, 68, 998,
-
- 68, 1008, 68, 68, 1003, 1004, 1005, 68, 1006, 68,
- 68, 68, 68, 68, 999, 1011, 1001, 1007, 1009, 1010,
- 68, 1012, 1017, 68, 68, 68, 68, 68, 68, 1021,
- 1019, 1014, 1013, 1015, 1016, 68, 68, 68, 1022, 68,
- 1018, 1023, 68, 68, 1020, 68, 1024, 68, 1026, 68,
- 68, 68, 68, 68, 68, 68, 1034, 1025, 1033, 68,
- 1031, 1028, 1029, 1030, 1027, 68, 1038, 68, 1036, 68,
- 68, 68, 1032, 1035, 68, 1040, 1041, 68, 68, 1037,
- 68, 1046, 1042, 1043, 68, 68, 68, 68, 126, 1044,
- 1047, 1050, 68, 68, 68, 1039, 1054, 68, 68, 68,
-
- 1045, 1049, 68, 1048, 68, 1051, 1052, 1055, 68, 1053,
- 68, 1056, 68, 1057, 68, 1058, 68, 1059, 68, 68,
- 1062, 68, 1060, 68, 1063, 1066, 68, 68, 1061, 68,
- 1065, 1070, 1067, 1068, 68, 68, 1073, 68, 1069, 68,
- 1071, 1064, 1072, 68, 1076, 68, 68, 1074, 68, 1077,
- 68, 68, 1075, 68, 68, 1079, 68, 1080, 1078, 1082,
- 68, 68, 68, 68, 68, 68, 1081, 1090, 68, 68,
- 68, 68, 1091, 68, 68, 1130, 1088, 68, 1094, 1084,
- 68, 1086, 1083, 1092, 1087, 1085, 1089, 1093, 1095, 68,
- 1096, 68, 1100, 1097, 1098, 68, 1099, 68, 1101, 68,
-
- 1102, 68, 68, 68, 1105, 68, 68, 68, 1104, 1107,
- 68, 68, 68, 1109, 68, 1110, 68, 1111, 1113, 68,
- 68, 1103, 1115, 68, 68, 1106, 1116, 68, 68, 1108,
- 68, 1118, 1112, 1114, 68, 68, 1120, 1119, 68, 1121,
- 68, 68, 68, 68, 68, 1129, 1117, 1125, 68, 68,
- 68, 1123, 1127, 1128, 68, 1133, 1126, 1134, 1132, 68,
- 1122, 1124, 68, 68, 1135, 68, 68, 68, 1131, 1139,
- 68, 1142, 1136, 68, 1137, 1140, 1143, 1138, 1141, 68,
- 1144, 68, 68, 68, 68, 68, 68, 1145, 1147, 1150,
- 68, 1149, 68, 68, 68, 68, 1151, 1155, 1153, 68,
-
- 68, 1156, 68, 1146, 68, 1148, 68, 1154, 1152, 1157,
- 68, 1158, 1159, 68, 1160, 68, 1161, 68, 1162, 68,
- 1163, 68, 68, 68, 1164, 1166, 68, 1165, 1167, 68,
- 68, 1168, 68, 1169, 68, 1170, 1171, 68, 1172, 68,
- 1173, 68, 68, 68, 1174, 68, 68, 1180, 68, 68,
- 68, 68, 1175, 68, 1176, 1177, 68, 1178, 1181, 68,
- 68, 68, 68, 68, 1190, 68, 1179, 1188, 1189, 1184,
- 68, 1183, 68, 1186, 68, 1192, 1182, 1185, 1187, 1191,
- 1193, 68, 68, 68, 68, 1195, 68, 1200, 68, 1201,
- 1196, 1194, 68, 68, 68, 68, 68, 68, 68, 1207,
-
- 1198, 1197, 1208, 68, 68, 1199, 68, 1202, 1211, 68,
- 68, 68, 1203, 1213, 68, 1204, 1205, 68, 1206, 1209,
- 1214, 68, 68, 1215, 1210, 68, 1217, 68, 68, 1212,
- 1218, 68, 1219, 1216, 68, 68, 1220, 68, 125, 1222,
- 1223, 1225, 68, 1226, 68, 1227, 1221, 1228, 68, 68,
- 68, 68, 1224, 1229, 68, 68, 1230, 68, 1232, 68,
- 68, 1231, 68, 1236, 68, 68, 68, 68, 1234, 1235,
- 1233, 1240, 68, 1237, 1242, 68, 1241, 68, 68, 68,
- 68, 68, 1244, 123, 1238, 1239, 1243, 68, 1245, 1247,
- 68, 68, 1249, 1246, 68, 1251, 68, 1250, 1252, 68,
-
- 68, 1248, 1255, 1256, 68, 1253, 68, 68, 68, 68,
- 1257, 68, 68, 68, 1254, 1258, 68, 1262, 68, 1260,
- 68, 68, 68, 1264, 68, 68, 68, 1259, 1269, 1263,
- 68, 1261, 68, 1267, 1271, 68, 1272, 68, 68, 1273,
- 1265, 68, 1268, 68, 1270, 68, 1274, 1266, 1277, 68,
- 1275, 68, 1278, 68, 1279, 68, 68, 68, 1280, 1284,
- 68, 68, 68, 68, 1281, 68, 1276, 68, 1282, 68,
- 1285, 1283, 68, 1286, 1289, 1288, 1292, 68, 68, 1294,
- 68, 1287, 68, 1293, 1291, 1297, 68, 1298, 68, 1290,
- 68, 68, 1295, 68, 1302, 68, 68, 1304, 68, 68,
-
- 68, 68, 68, 1300, 1296, 121, 1307, 1311, 1303, 1299,
- 1308, 68, 68, 1301, 1306, 1309, 68, 1315, 1305, 1310,
- 68, 1312, 68, 68, 1313, 1314, 68, 68, 1317, 68,
- 68, 68, 68, 1321, 68, 1316, 1318, 1319, 68, 1323,
- 68, 68, 1322, 1325, 68, 1324, 68, 68, 1328, 68,
- 1320, 1329, 68, 1330, 68, 1331, 68, 68, 68, 1333,
- 68, 1326, 68, 68, 1334, 1327, 1336, 68, 68, 1332,
- 68, 68, 1337, 1341, 68, 68, 1342, 1342, 1342, 1342,
- 1342, 1342, 1335, 1338, 1339, 1342, 1342, 1342, 1342, 1342,
- 1340, 40, 40, 40, 40, 40, 40, 40, 45, 45,
-
- 45, 45, 45, 45, 45, 50, 50, 50, 50, 50,
- 50, 50, 56, 56, 56, 56, 56, 56, 56, 61,
- 61, 61, 61, 61, 61, 61, 71, 71, 1342, 71,
- 71, 71, 71, 120, 120, 1342, 1342, 1342, 120, 120,
- 122, 122, 1342, 1342, 122, 1342, 122, 124, 1342, 1342,
- 1342, 1342, 1342, 124, 127, 127, 1342, 1342, 1342, 127,
- 127, 129, 1342, 1342, 1342, 1342, 1342, 129, 131, 131,
- 1342, 131, 131, 131, 131, 72, 72, 1342, 72, 72,
- 72, 72, 13, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
- 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
-
- 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
- 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
- 1342, 1342
- } ;
-
-static yyconst flex_int16_t yy_chk[2723] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
- 3, 3, 4, 4, 4, 49, 5, 5, 49, 3,
- 5, 15, 4, 6, 6, 15, 5, 6, 9, 9,
- 9, 116, 33, 6, 7, 7, 7, 7, 9, 7,
- 10, 10, 10, 44, 44, 7, 8, 8, 8, 8,
- 10, 8, 21, 33, 116, 21, 21, 8, 11, 11,
- 11, 11, 11, 11, 1348, 20, 29, 20, 20, 11,
-
- 20, 29, 24, 21, 25, 20, 24, 28, 11, 12,
- 12, 12, 12, 12, 12, 74, 22, 22, 74, 25,
- 12, 69, 28, 66, 22, 69, 24, 26, 26, 12,
- 19, 22, 19, 19, 23, 19, 26, 66, 27, 23,
- 19, 19, 27, 23, 30, 27, 23, 31, 89, 23,
- 32, 32, 27, 89, 34, 32, 31, 60, 60, 30,
- 35, 77, 31, 34, 77, 35, 31, 78, 36, 34,
- 75, 32, 34, 36, 75, 35, 38, 76, 35, 34,
- 79, 37, 37, 36, 37, 78, 577, 36, 36, 88,
- 38, 39, 39, 88, 79, 38, 39, 76, 55, 37,
-
- 55, 55, 63, 55, 63, 63, 65, 63, 65, 65,
- 82, 65, 68, 63, 68, 68, 85, 68, 80, 81,
- 86, 84, 68, 71, 83, 71, 71, 87, 71, 83,
- 80, 92, 82, 71, 71, 84, 85, 81, 86, 90,
- 91, 98, 83, 91, 93, 87, 91, 95, 94, 93,
- 92, 94, 96, 90, 98, 94, 96, 97, 99, 100,
- 91, 95, 101, 102, 97, 99, 103, 102, 104, 93,
- 105, 107, 100, 104, 106, 108, 110, 104, 109, 111,
- 113, 110, 101, 114, 103, 115, 107, 106, 112, 112,
- 105, 111, 117, 118, 108, 119, 109, 117, 113, 114,
-
- 121, 121, 128, 128, 123, 118, 115, 123, 133, 112,
- 129, 133, 125, 119, 125, 125, 130, 125, 130, 130,
- 131, 130, 131, 131, 134, 131, 136, 135, 137, 134,
- 138, 131, 135, 139, 140, 141, 137, 142, 145, 140,
- 141, 136, 142, 144, 144, 138, 146, 147, 148, 151,
- 149, 146, 148, 139, 143, 149, 154, 145, 143, 150,
- 153, 154, 155, 143, 151, 152, 157, 156, 143, 161,
- 147, 157, 127, 150, 143, 143, 159, 152, 153, 160,
- 152, 159, 155, 156, 158, 158, 162, 159, 160, 163,
- 161, 162, 164, 165, 163, 166, 168, 164, 165, 167,
-
- 169, 170, 166, 171, 172, 167, 169, 173, 174, 175,
- 176, 171, 177, 174, 178, 180, 168, 177, 179, 172,
- 179, 181, 180, 170, 182, 184, 181, 173, 176, 176,
- 184, 175, 183, 183, 178, 185, 186, 187, 186, 188,
- 185, 190, 189, 182, 192, 193, 190, 191, 184, 187,
- 189, 195, 191, 194, 195, 186, 196, 196, 188, 192,
- 198, 194, 199, 193, 197, 197, 200, 201, 203, 200,
- 202, 201, 204, 203, 205, 205, 198, 199, 206, 202,
- 207, 208, 209, 206, 210, 207, 204, 212, 212, 211,
- 213, 214, 215, 216, 217, 218, 216, 215, 219, 221,
-
- 209, 208, 211, 214, 220, 210, 217, 219, 213, 223,
- 223, 221, 218, 225, 226, 218, 222, 220, 222, 222,
- 224, 229, 227, 224, 228, 228, 229, 230, 230, 226,
- 225, 227, 231, 225, 232, 233, 234, 235, 236, 237,
- 233, 236, 235, 238, 240, 241, 239, 231, 242, 240,
- 241, 243, 244, 237, 232, 239, 234, 245, 246, 238,
- 245, 249, 238, 248, 238, 250, 244, 252, 251, 242,
- 249, 243, 246, 126, 253, 255, 245, 247, 248, 247,
- 247, 258, 252, 254, 256, 257, 250, 251, 254, 247,
- 259, 247, 247, 247, 253, 255, 247, 260, 262, 256,
-
- 257, 258, 260, 263, 259, 261, 261, 264, 261, 266,
- 265, 266, 267, 268, 269, 124, 267, 270, 262, 263,
- 271, 273, 272, 264, 265, 273, 270, 272, 269, 271,
- 275, 268, 274, 277, 276, 275, 278, 281, 277, 270,
- 276, 274, 279, 279, 282, 280, 286, 283, 290, 278,
- 280, 284, 284, 282, 293, 285, 287, 287, 281, 283,
- 285, 289, 289, 291, 292, 295, 293, 286, 296, 290,
- 297, 291, 298, 292, 299, 300, 301, 298, 302, 303,
- 300, 304, 299, 303, 297, 295, 305, 306, 296, 307,
- 310, 305, 309, 312, 301, 314, 304, 311, 313, 313,
-
- 302, 316, 311, 306, 315, 315, 310, 311, 307, 308,
- 308, 317, 309, 312, 318, 308, 316, 308, 319, 320,
- 314, 321, 322, 317, 323, 308, 321, 324, 325, 318,
- 328, 322, 325, 326, 327, 308, 329, 319, 326, 330,
- 330, 320, 324, 323, 331, 332, 327, 333, 328, 329,
- 334, 335, 342, 334, 336, 336, 331, 332, 337, 337,
- 338, 348, 333, 122, 335, 338, 339, 339, 340, 340,
- 341, 343, 345, 342, 344, 341, 343, 345, 344, 346,
- 347, 348, 349, 346, 350, 347, 351, 349, 355, 350,
- 352, 353, 353, 352, 354, 359, 367, 355, 352, 354,
-
- 351, 356, 352, 357, 356, 358, 360, 357, 359, 361,
- 358, 360, 362, 363, 367, 364, 368, 362, 364, 363,
- 365, 361, 366, 365, 374, 370, 369, 366, 370, 357,
- 368, 369, 371, 374, 372, 373, 379, 371, 372, 372,
- 373, 375, 376, 377, 375, 377, 376, 376, 378, 380,
- 378, 381, 382, 383, 379, 384, 385, 383, 386, 375,
- 387, 388, 389, 394, 384, 120, 388, 380, 390, 390,
- 381, 385, 382, 391, 392, 387, 386, 391, 393, 392,
- 395, 389, 394, 396, 397, 398, 399, 401, 403, 397,
- 396, 399, 398, 395, 393, 400, 402, 403, 404, 405,
-
- 400, 408, 418, 402, 405, 401, 406, 407, 411, 406,
- 413, 407, 404, 411, 409, 409, 412, 414, 415, 418,
- 412, 421, 408, 409, 424, 414, 422, 423, 413, 424,
- 421, 423, 422, 415, 425, 426, 425, 427, 425, 428,
- 426, 425, 429, 430, 430, 429, 425, 431, 432, 432,
- 433, 436, 425, 425, 431, 427, 434, 434, 435, 437,
- 438, 435, 439, 439, 428, 433, 440, 441, 438, 442,
- 444, 436, 443, 443, 442, 444, 445, 446, 437, 445,
- 447, 440, 448, 446, 449, 441, 450, 451, 447, 453,
- 448, 450, 452, 452, 451, 454, 455, 453, 457, 458,
-
- 454, 457, 449, 459, 459, 460, 461, 463, 464, 461,
- 465, 466, 467, 458, 468, 455, 470, 461, 469, 471,
- 460, 474, 469, 468, 475, 473, 472, 474, 463, 464,
- 465, 476, 467, 466, 470, 472, 477, 479, 471, 473,
- 480, 477, 478, 481, 475, 476, 478, 482, 481, 483,
- 483, 485, 480, 484, 485, 486, 479, 487, 484, 488,
- 489, 490, 490, 492, 488, 491, 491, 493, 482, 494,
- 487, 493, 495, 486, 499, 496, 500, 498, 492, 501,
- 489, 498, 502, 509, 503, 505, 504, 508, 494, 496,
- 505, 500, 504, 501, 67, 509, 495, 497, 503, 499,
-
- 497, 508, 497, 502, 506, 506, 497, 513, 497, 507,
- 506, 512, 506, 497, 507, 510, 510, 511, 514, 512,
- 520, 513, 511, 515, 515, 516, 518, 521, 522, 516,
- 506, 518, 519, 522, 523, 519, 524, 514, 526, 520,
- 521, 525, 527, 523, 528, 529, 525, 531, 532, 533,
- 529, 536, 534, 528, 533, 524, 527, 534, 526, 535,
- 536, 537, 537, 532, 535, 531, 538, 542, 540, 543,
- 542, 538, 540, 540, 541, 541, 544, 545, 541, 546,
- 545, 547, 548, 549, 543, 550, 547, 548, 552, 549,
- 553, 550, 551, 551, 555, 554, 544, 552, 554, 556,
-
- 546, 557, 558, 61, 559, 560, 561, 568, 553, 559,
- 560, 562, 555, 566, 562, 558, 563, 564, 556, 569,
- 565, 557, 564, 570, 561, 565, 568, 563, 566, 567,
- 567, 572, 571, 569, 573, 570, 571, 574, 575, 578,
- 579, 580, 581, 573, 584, 582, 583, 581, 585, 572,
- 582, 583, 586, 578, 587, 579, 574, 586, 584, 588,
- 590, 580, 585, 575, 589, 589, 591, 592, 593, 587,
- 595, 594, 592, 596, 588, 591, 594, 596, 590, 597,
- 598, 599, 600, 601, 602, 603, 604, 593, 597, 595,
- 606, 605, 604, 611, 600, 598, 599, 610, 607, 609,
-
- 612, 611, 601, 603, 609, 602, 605, 607, 613, 615,
- 606, 610, 614, 613, 616, 644, 614, 614, 644, 617,
- 612, 623, 615, 616, 617, 618, 618, 619, 620, 621,
- 621, 622, 619, 620, 624, 623, 622, 625, 626, 627,
- 629, 628, 625, 626, 627, 628, 630, 632, 633, 629,
- 634, 632, 624, 635, 629, 636, 629, 630, 629, 638,
- 639, 637, 640, 633, 641, 641, 646, 635, 634, 637,
- 642, 642, 645, 638, 636, 647, 647, 645, 639, 648,
- 649, 649, 652, 650, 654, 646, 653, 640, 650, 651,
- 651, 653, 654, 655, 656, 657, 658, 669, 655, 648,
-
- 660, 657, 652, 658, 661, 660, 662, 664, 663, 661,
- 665, 662, 656, 663, 666, 668, 664, 667, 667, 670,
- 669, 671, 672, 675, 670, 666, 673, 674, 674, 665,
- 676, 677, 680, 678, 681, 668, 680, 680, 685, 682,
- 683, 671, 672, 675, 673, 683, 684, 686, 687, 677,
- 688, 686, 691, 689, 693, 676, 678, 682, 685, 690,
- 681, 693, 695, 692, 684, 694, 687, 689, 692, 688,
- 694, 691, 696, 697, 690, 699, 698, 706, 700, 701,
- 695, 696, 698, 700, 701, 702, 703, 703, 697, 705,
- 702, 706, 707, 708, 705, 710, 699, 708, 708, 709,
-
- 709, 711, 712, 713, 715, 714, 716, 717, 718, 713,
- 714, 707, 720, 721, 710, 719, 722, 722, 724, 723,
- 711, 712, 724, 715, 723, 716, 717, 718, 721, 719,
- 725, 726, 727, 720, 728, 728, 729, 731, 730, 732,
- 726, 729, 730, 725, 732, 735, 736, 736, 737, 745,
- 735, 746, 727, 737, 739, 739, 748, 731, 741, 741,
- 743, 744, 744, 743, 745, 747, 749, 749, 750, 752,
- 747, 748, 751, 751, 753, 754, 746, 755, 756, 754,
- 758, 759, 761, 756, 762, 753, 760, 760, 750, 763,
- 764, 752, 764, 767, 765, 759, 755, 768, 758, 765,
-
- 766, 769, 761, 771, 762, 766, 772, 769, 771, 763,
- 776, 768, 773, 767, 774, 773, 775, 775, 777, 774,
- 778, 779, 780, 784, 781, 783, 779, 785, 776, 781,
- 783, 772, 782, 782, 786, 787, 788, 777, 789, 790,
- 778, 784, 791, 792, 790, 780, 793, 785, 788, 787,
- 794, 789, 795, 801, 786, 797, 801, 796, 802, 795,
- 800, 800, 791, 792, 803, 794, 796, 793, 804, 796,
- 805, 797, 806, 803, 802, 807, 808, 808, 809, 805,
- 807, 806, 805, 810, 811, 812, 813, 804, 814, 815,
- 815, 816, 817, 56, 820, 819, 810, 828, 809, 812,
-
- 819, 824, 811, 821, 829, 828, 814, 816, 821, 822,
- 817, 813, 820, 823, 824, 822, 825, 829, 823, 825,
- 830, 831, 841, 832, 833, 825, 835, 836, 837, 838,
- 839, 836, 840, 837, 838, 839, 842, 845, 830, 832,
- 831, 840, 833, 843, 843, 841, 835, 844, 846, 845,
- 847, 842, 848, 849, 853, 847, 850, 851, 851, 856,
- 846, 844, 850, 853, 848, 852, 852, 854, 854, 855,
- 857, 849, 858, 860, 855, 859, 859, 861, 861, 863,
- 856, 862, 862, 864, 863, 866, 864, 867, 869, 857,
- 866, 868, 858, 860, 870, 870, 868, 871, 871, 872,
-
- 873, 874, 875, 876, 872, 867, 877, 878, 878, 879,
- 880, 880, 873, 869, 873, 883, 881, 884, 885, 873,
- 886, 874, 875, 876, 883, 885, 887, 877, 889, 886,
- 888, 888, 884, 890, 892, 879, 881, 893, 894, 892,
- 895, 897, 893, 896, 896, 899, 897, 895, 898, 890,
- 901, 900, 887, 902, 889, 903, 905, 898, 894, 906,
- 906, 903, 904, 907, 908, 899, 900, 905, 902, 901,
- 909, 904, 905, 910, 910, 909, 911, 912, 908, 913,
- 911, 911, 912, 914, 907, 915, 916, 917, 914, 918,
- 916, 913, 922, 919, 920, 921, 928, 915, 919, 917,
-
- 921, 928, 924, 933, 922, 924, 925, 925, 926, 926,
- 930, 927, 929, 936, 918, 933, 920, 927, 929, 930,
- 935, 935, 940, 940, 937, 938, 943, 945, 946, 946,
- 944, 936, 935, 937, 938, 944, 947, 951, 947, 950,
- 943, 948, 948, 953, 945, 957, 950, 952, 952, 954,
- 955, 956, 958, 960, 961, 962, 961, 951, 960, 963,
- 957, 954, 955, 956, 953, 964, 965, 965, 963, 966,
- 967, 971, 958, 962, 968, 967, 968, 969, 970, 964,
- 972, 973, 969, 970, 976, 974, 973, 977, 51, 971,
- 974, 978, 978, 979, 981, 966, 981, 980, 982, 983,
-
- 972, 977, 988, 976, 987, 979, 980, 982, 984, 980,
- 985, 983, 989, 984, 991, 985, 994, 987, 993, 999,
- 991, 995, 988, 997, 993, 996, 996, 1000, 989, 1002,
- 995, 1000, 997, 998, 998, 1001, 1003, 1003, 999, 1004,
- 1001, 994, 1002, 1007, 1008, 1008, 1010, 1004, 1009, 1009,
- 1011, 1013, 1007, 1012, 1014, 1011, 1015, 1012, 1010, 1014,
- 1016, 1018, 1019, 1020, 1021, 1022, 1013, 1024, 1024, 1025,
- 1026, 1065, 1025, 1034, 1027, 1065, 1021, 1028, 1028, 1016,
- 1031, 1019, 1015, 1026, 1020, 1018, 1022, 1027, 1029, 1029,
- 1030, 1030, 1034, 1031, 1032, 1032, 1033, 1033, 1035, 1035,
-
- 1036, 1036, 1037, 1039, 1040, 1040, 1041, 1044, 1039, 1042,
- 1042, 1043, 1045, 1044, 1048, 1045, 1046, 1046, 1047, 1047,
- 1052, 1037, 1049, 1049, 1055, 1041, 1051, 1051, 1054, 1043,
- 1053, 1053, 1046, 1048, 1056, 1057, 1055, 1054, 1058, 1056,
- 1059, 1061, 1060, 1062, 1063, 1064, 1052, 1060, 1067, 1069,
- 1064, 1058, 1062, 1063, 1070, 1070, 1061, 1071, 1069, 1074,
- 1057, 1059, 1071, 1072, 1072, 1075, 1077, 1080, 1067, 1077,
- 1078, 1080, 1072, 1081, 1074, 1078, 1081, 1075, 1079, 1079,
- 1082, 1082, 1083, 1084, 1085, 1086, 1087, 1083, 1085, 1088,
- 1089, 1087, 1091, 1092, 1088, 1094, 1089, 1094, 1092, 1093,
-
- 1097, 1097, 1111, 1084, 1110, 1086, 1103, 1093, 1091, 1100,
- 1100, 1103, 1104, 1104, 1106, 1106, 1108, 1109, 1109, 1119,
- 1110, 1108, 1112, 1117, 1111, 1114, 1114, 1112, 1117, 1118,
- 1120, 1118, 1124, 1119, 1125, 1120, 1121, 1121, 1122, 1122,
- 1123, 1123, 1126, 1127, 1124, 1128, 1129, 1130, 1130, 1131,
- 1132, 1133, 1125, 1135, 1126, 1127, 1134, 1128, 1131, 1136,
- 1137, 1142, 1138, 1139, 1140, 1140, 1129, 1138, 1139, 1134,
- 1147, 1133, 1148, 1136, 1143, 1143, 1132, 1135, 1137, 1142,
- 1145, 1145, 1146, 1149, 1150, 1147, 1151, 1152, 1152, 1153,
- 1148, 1146, 1154, 1155, 1153, 1156, 1162, 1158, 1161, 1162,
-
- 1150, 1149, 1163, 1163, 1164, 1151, 1165, 1154, 1167, 1167,
- 1168, 1175, 1155, 1169, 1169, 1156, 1158, 1176, 1161, 1164,
- 1170, 1170, 1174, 1174, 1165, 1177, 1176, 1178, 1179, 1168,
- 1177, 1181, 1178, 1175, 1182, 1183, 1179, 1184, 50, 1182,
- 1183, 1185, 1185, 1186, 1186, 1187, 1181, 1188, 1188, 1192,
- 1187, 1191, 1184, 1189, 1189, 1194, 1191, 1195, 1194, 1196,
- 1197, 1192, 1198, 1198, 1199, 1201, 1202, 1204, 1196, 1197,
- 1195, 1203, 1203, 1199, 1205, 1205, 1204, 1207, 1206, 1209,
- 1210, 1215, 1207, 45, 1201, 1202, 1206, 1220, 1209, 1212,
- 1212, 1216, 1216, 1210, 1217, 1218, 1218, 1217, 1219, 1219,
-
- 1221, 1215, 1222, 1223, 1223, 1220, 1224, 1222, 1230, 1227,
- 1224, 1231, 1232, 1234, 1221, 1227, 1233, 1233, 1235, 1231,
- 1236, 1237, 1239, 1235, 1238, 1241, 1243, 1230, 1241, 1234,
- 1246, 1232, 1245, 1238, 1244, 1244, 1245, 1248, 1249, 1246,
- 1236, 1250, 1239, 1253, 1243, 1255, 1248, 1237, 1253, 1259,
- 1249, 1254, 1254, 1257, 1255, 1258, 1260, 1263, 1257, 1261,
- 1261, 1262, 1264, 1267, 1258, 1268, 1250, 1265, 1259, 1266,
- 1262, 1260, 1273, 1263, 1266, 1265, 1269, 1269, 1270, 1272,
- 1272, 1264, 1274, 1270, 1268, 1275, 1275, 1276, 1276, 1267,
- 1277, 1278, 1273, 1279, 1280, 1280, 1281, 1282, 1282, 1283,
-
- 1285, 1286, 1290, 1278, 1274, 40, 1286, 1290, 1281, 1277,
- 1287, 1287, 1296, 1279, 1285, 1288, 1288, 1296, 1283, 1289,
- 1289, 1291, 1291, 1293, 1293, 1295, 1295, 1299, 1300, 1300,
- 1305, 1301, 1303, 1306, 1306, 1299, 1301, 1303, 1307, 1311,
- 1311, 1313, 1307, 1315, 1315, 1313, 1316, 1318, 1319, 1319,
- 1305, 1320, 1320, 1322, 1322, 1324, 1324, 1326, 1327, 1327,
- 1332, 1316, 1333, 1335, 1332, 1318, 1334, 1334, 1337, 1326,
- 1338, 1339, 1335, 1340, 1340, 14, 13, 0, 0, 0,
- 0, 0, 1333, 1337, 1338, 0, 0, 0, 0, 0,
- 1339, 1343, 1343, 1343, 1343, 1343, 1343, 1343, 1344, 1344,
-
- 1344, 1344, 1344, 1344, 1344, 1345, 1345, 1345, 1345, 1345,
- 1345, 1345, 1346, 1346, 1346, 1346, 1346, 1346, 1346, 1347,
- 1347, 1347, 1347, 1347, 1347, 1347, 1349, 1349, 0, 1349,
- 1349, 1349, 1349, 1350, 1350, 0, 0, 0, 1350, 1350,
- 1351, 1351, 0, 0, 1351, 0, 1351, 1352, 0, 0,
- 0, 0, 0, 1352, 1353, 1353, 0, 0, 0, 1353,
- 1353, 1354, 0, 0, 0, 0, 0, 1354, 1355, 1355,
- 0, 1355, 1355, 1355, 1355, 1356, 1356, 0, 1356, 1356,
- 1356, 1356, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
- 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
-
- 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
- 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342, 1342,
- 1342, 1342
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-extern int yy_flex_debug;
-int yy_flex_debug = 0;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-static int yy_more_flag = 0;
-static int yy_more_len = 0;
-#define yymore() ((yy_more_flag) = 1)
-#define YY_MORE_ADJ (yy_more_len)
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-/*
- * configlexer.lex - lexical analyzer for unbound config file
- *
- * Copyright (c) 2001-2006, NLnet Labs. All rights reserved
- *
- * See LICENSE for the license.
- *
- */
-
-#include <ctype.h>
-#include <string.h>
-#include <strings.h>
-#ifdef HAVE_GLOB_H
-# include <glob.h>
-#endif
-
-#include "util/config_file.h"
-#include "util/configparser.h"
-void ub_c_error(const char *message);
-
-#if 0
-#define LEXOUT(s) printf s /* used ONLY when debugging */
-#else
-#define LEXOUT(s)
-#endif
-
-/** avoid warning in about fwrite return value */
-#define ECHO ub_c_error_msg("syntax error at text: %s", yytext)
-
-/** A parser variable, this is a statement in the config file which is
- * of the form variable: value1 value2 ... nargs is the number of values. */
-#define YDVAR(nargs, var) \
- num_args=(nargs); \
- LEXOUT(("v(%s%d) ", yytext, num_args)); \
- if(num_args > 0) { BEGIN(val); } \
- return (var);
-
-struct inc_state {
- char* filename;
- int line;
-};
-static struct inc_state parse_stack[MAXINCLUDES];
-static YY_BUFFER_STATE include_stack[MAXINCLUDES];
-static int config_include_stack_ptr = 0;
-static int inc_prev = 0;
-static int num_args = 0;
-
-static void config_start_include(const char* filename)
-{
- FILE *input;
- if(strlen(filename) == 0) {
- ub_c_error_msg("empty include file name");
- return;
- }
- if(config_include_stack_ptr >= MAXINCLUDES) {
- ub_c_error_msg("includes nested too deeply, skipped (>%d)", MAXINCLUDES);
- return;
- }
- if(cfg_parser->chroot && strncmp(filename, cfg_parser->chroot,
- strlen(cfg_parser->chroot)) == 0) {
- filename += strlen(cfg_parser->chroot);
- }
- input = fopen(filename, "r");
- if(!input) {
- ub_c_error_msg("cannot open include file '%s': %s",
- filename, strerror(errno));
- return;
- }
- LEXOUT(("switch_to_include_file(%s) ", filename));
- parse_stack[config_include_stack_ptr].filename = cfg_parser->filename;
- parse_stack[config_include_stack_ptr].line = cfg_parser->line;
- include_stack[config_include_stack_ptr] = YY_CURRENT_BUFFER;
- cfg_parser->filename = strdup(filename);
- cfg_parser->line = 1;
- yy_switch_to_buffer(yy_create_buffer(input,YY_BUF_SIZE));
- ++config_include_stack_ptr;
-}
-
-static void config_start_include_glob(const char* filename)
-{
-
- /* check for wildcards */
-#ifdef HAVE_GLOB
- glob_t g;
- size_t i;
- int r, flags;
- if(!(!strchr(filename, '*') && !strchr(filename, '?') && !strchr(filename, '[') &&
- !strchr(filename, '{') && !strchr(filename, '~'))) {
- flags = 0
-#ifdef GLOB_ERR
- | GLOB_ERR
-#endif
-#ifdef GLOB_NOSORT
- | GLOB_NOSORT
-#endif
-#ifdef GLOB_BRACE
- | GLOB_BRACE
-#endif
-#ifdef GLOB_TILDE
- | GLOB_TILDE
-#endif
- ;
- memset(&g, 0, sizeof(g));
- r = glob(filename, flags, NULL, &g);
- if(r) {
- /* some error */
- globfree(&g);
- config_start_include(filename); /* let original deal with it */
- return;
- }
- /* process files found, if any */
- for(i=0; i<(size_t)g.gl_pathc; i++) {
- config_start_include(g.gl_pathv[i]);
- }
- globfree(&g);
- return;
- }
-#endif /* HAVE_GLOB */
-
- config_start_include(filename);
-}
-
-static void config_end_include(void)
-{
- --config_include_stack_ptr;
- free(cfg_parser->filename);
- cfg_parser->filename = parse_stack[config_include_stack_ptr].filename;
- cfg_parser->line = parse_stack[config_include_stack_ptr].line;
- yy_delete_buffer(YY_CURRENT_BUFFER);
- yy_switch_to_buffer(include_stack[config_include_stack_ptr]);
-}
-
-#ifndef yy_set_bol /* compat definition, for flex 2.4.6 */
-#define yy_set_bol(at_bol) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer(yyin,YY_BUF_SIZE ); \
- yy_current_buffer->yy_ch_buf[0] = ((at_bol)?'\n':' '); \
- }
-#endif
-
-#define YY_NO_INPUT 1
-#ifndef YY_NO_UNPUT
-#define YY_NO_UNPUT 1
-#endif
-#ifndef YY_NO_INPUT
-#define YY_NO_INPUT 1
-#endif
-
-#define INITIAL 0
-#define quotedstring 1
-#define singlequotedstr 2
-#define include 3
-#define include_quoted 4
-#define val 5
-
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
-
-static int yy_init_globals (void );
-
-/* Accessor methods to globals.
- These are made visible to non-reentrant scanners for convenience. */
-
-int yylex_destroy (void );
-
-int yyget_debug (void );
-
-void yyset_debug (int debug_flag );
-
-YY_EXTRA_TYPE yyget_extra (void );
-
-void yyset_extra (YY_EXTRA_TYPE user_defined );
-
-FILE *yyget_in (void );
-
-void yyset_in (FILE * in_str );
-
-FILE *yyget_out (void );
-
-void yyset_out (FILE * out_str );
-
-yy_size_t yyget_leng (void );
-
-char *yyget_text (void );
-
-int yyget_lineno (void );
-
-void yyset_lineno (int line_number );
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap (void );
-#else
-extern int yywrap (void );
-#endif
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char *,yyconst char *,int );
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * );
-#endif
-
-#ifndef YY_NO_INPUT
-
-#ifdef __cplusplus
-static int yyinput (void );
-#else
-static int input (void );
-#endif
-
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
- { \
- int c = '*'; \
- size_t n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else \
- { \
- errno=0; \
- while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
- { \
- if( errno != EINTR) \
- { \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- break; \
- } \
- errno=0; \
- clearerr(yyin); \
- } \
- }\
-\
-
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* end tables serialization structures and prototypes */
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL_IS_OURS 1
-
-extern int yylex (void);
-
-#define YY_DECL int yylex (void)
-#endif /* !YY_DECL */
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- YY_USER_ACTION
-
-/** The main scanner function which does all the work.
- */
-YY_DECL
-{
- yy_state_type yy_current_state;
- char *yy_cp, *yy_bp;
- int yy_act;
-
- if ( !(yy_init) )
- {
- (yy_init) = 1;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! (yy_start) )
- (yy_start) = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! YY_CURRENT_BUFFER ) {
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_load_buffer_state( );
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- (yy_more_len) = 0;
- if ( (yy_more_flag) )
- {
- (yy_more_len) = (yy_c_buf_p) - (yytext_ptr);
- (yy_more_flag) = 0;
- }
- yy_cp = (yy_c_buf_p);
-
- /* Support of yytext. */
- *yy_cp = (yy_hold_char);
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = (yy_start);
-yy_match:
- do
- {
- YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 1343 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 2683 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-do_action: /* This label is used only to access EOF actions. */
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = (yy_hold_char);
- yy_cp = (yy_last_accepting_cpos);
- yy_current_state = (yy_last_accepting_state);
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-{
- LEXOUT(("SP ")); /* ignore */ }
- YY_BREAK
-case 2:
-YY_RULE_SETUP
-{
- /* note that flex makes the longest match and '.' is any but not nl */
- LEXOUT(("comment(%s) ", yytext)); /* ignore */ }
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-{ YDVAR(0, VAR_SERVER) }
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_NUM_THREADS) }
- YY_BREAK
-case 5:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_VERBOSITY) }
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_PORT) }
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_OUTGOING_RANGE) }
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_OUTGOING_PORT_PERMIT) }
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_OUTGOING_PORT_AVOID) }
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_OUTGOING_NUM_TCP) }
- YY_BREAK
-case 11:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_INCOMING_NUM_TCP) }
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DO_IP4) }
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DO_IP6) }
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DO_UDP) }
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DO_TCP) }
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_TCP_UPSTREAM) }
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_SSL_UPSTREAM) }
- YY_BREAK
-case 18:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_SSL_SERVICE_KEY) }
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_SSL_SERVICE_PEM) }
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_SSL_PORT) }
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DO_DAEMONIZE) }
- YY_BREAK
-case 22:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_INTERFACE) }
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_OUTGOING_INTERFACE) }
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_INTERFACE_AUTOMATIC) }
- YY_BREAK
-case 25:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_SO_RCVBUF) }
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_SO_SNDBUF) }
- YY_BREAK
-case 27:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_CHROOT) }
- YY_BREAK
-case 28:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_USERNAME) }
- YY_BREAK
-case 29:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DIRECTORY) }
- YY_BREAK
-case 30:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_LOGFILE) }
- YY_BREAK
-case 31:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_PIDFILE) }
- YY_BREAK
-case 32:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_ROOT_HINTS) }
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_EDNS_BUFFER_SIZE) }
- YY_BREAK
-case 34:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_MSG_BUFFER_SIZE) }
- YY_BREAK
-case 35:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_MSG_CACHE_SIZE) }
- YY_BREAK
-case 36:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_MSG_CACHE_SLABS) }
- YY_BREAK
-case 37:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_RRSET_CACHE_SIZE) }
- YY_BREAK
-case 38:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_RRSET_CACHE_SLABS) }
- YY_BREAK
-case 39:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_CACHE_MAX_TTL) }
- YY_BREAK
-case 40:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_CACHE_MIN_TTL) }
- YY_BREAK
-case 41:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_INFRA_HOST_TTL) }
- YY_BREAK
-case 42:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_INFRA_LAME_TTL) }
- YY_BREAK
-case 43:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_INFRA_CACHE_SLABS) }
- YY_BREAK
-case 44:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_INFRA_CACHE_NUMHOSTS) }
- YY_BREAK
-case 45:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_INFRA_CACHE_LAME_SIZE) }
- YY_BREAK
-case 46:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_NUM_QUERIES_PER_THREAD) }
- YY_BREAK
-case 47:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_JOSTLE_TIMEOUT) }
- YY_BREAK
-case 48:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_TARGET_FETCH_POLICY) }
- YY_BREAK
-case 49:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_HARDEN_SHORT_BUFSIZE) }
- YY_BREAK
-case 50:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_HARDEN_LARGE_QUERIES) }
- YY_BREAK
-case 51:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_HARDEN_GLUE) }
- YY_BREAK
-case 52:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_HARDEN_DNSSEC_STRIPPED) }
- YY_BREAK
-case 53:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_HARDEN_BELOW_NXDOMAIN) }
- YY_BREAK
-case 54:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_HARDEN_REFERRAL_PATH) }
- YY_BREAK
-case 55:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_USE_CAPS_FOR_ID) }
- YY_BREAK
-case 56:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_UNWANTED_REPLY_THRESHOLD) }
- YY_BREAK
-case 57:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_PRIVATE_ADDRESS) }
- YY_BREAK
-case 58:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_PRIVATE_DOMAIN) }
- YY_BREAK
-case 59:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_PREFETCH_KEY) }
- YY_BREAK
-case 60:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_PREFETCH) }
- YY_BREAK
-case 61:
-YY_RULE_SETUP
-{ YDVAR(0, VAR_STUB_ZONE) }
- YY_BREAK
-case 62:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_NAME) }
- YY_BREAK
-case 63:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_STUB_ADDR) }
- YY_BREAK
-case 64:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_STUB_HOST) }
- YY_BREAK
-case 65:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_STUB_PRIME) }
- YY_BREAK
-case 66:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_STUB_FIRST) }
- YY_BREAK
-case 67:
-YY_RULE_SETUP
-{ YDVAR(0, VAR_FORWARD_ZONE) }
- YY_BREAK
-case 68:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_FORWARD_ADDR) }
- YY_BREAK
-case 69:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_FORWARD_HOST) }
- YY_BREAK
-case 70:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_FORWARD_FIRST) }
- YY_BREAK
-case 71:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DO_NOT_QUERY_ADDRESS) }
- YY_BREAK
-case 72:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DO_NOT_QUERY_LOCALHOST) }
- YY_BREAK
-case 73:
-YY_RULE_SETUP
-{ YDVAR(2, VAR_ACCESS_CONTROL) }
- YY_BREAK
-case 74:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_HIDE_IDENTITY) }
- YY_BREAK
-case 75:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_HIDE_VERSION) }
- YY_BREAK
-case 76:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_IDENTITY) }
- YY_BREAK
-case 77:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_VERSION) }
- YY_BREAK
-case 78:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_MODULE_CONF) }
- YY_BREAK
-case 79:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DLV_ANCHOR) }
- YY_BREAK
-case 80:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DLV_ANCHOR_FILE) }
- YY_BREAK
-case 81:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_TRUST_ANCHOR_FILE) }
- YY_BREAK
-case 82:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_AUTO_TRUST_ANCHOR_FILE) }
- YY_BREAK
-case 83:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_TRUSTED_KEYS_FILE) }
- YY_BREAK
-case 84:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_TRUST_ANCHOR) }
- YY_BREAK
-case 85:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_VAL_OVERRIDE_DATE) }
- YY_BREAK
-case 86:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_VAL_SIG_SKEW_MIN) }
- YY_BREAK
-case 87:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_VAL_SIG_SKEW_MAX) }
- YY_BREAK
-case 88:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_BOGUS_TTL) }
- YY_BREAK
-case 89:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_VAL_CLEAN_ADDITIONAL) }
- YY_BREAK
-case 90:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_VAL_PERMISSIVE_MODE) }
- YY_BREAK
-case 91:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_IGNORE_CD_FLAG) }
- YY_BREAK
-case 92:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_VAL_LOG_LEVEL) }
- YY_BREAK
-case 93:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_KEY_CACHE_SIZE) }
- YY_BREAK
-case 94:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_KEY_CACHE_SLABS) }
- YY_BREAK
-case 95:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_NEG_CACHE_SIZE) }
- YY_BREAK
-case 96:
-YY_RULE_SETUP
-{
- YDVAR(1, VAR_VAL_NSEC3_KEYSIZE_ITERATIONS) }
- YY_BREAK
-case 97:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_ADD_HOLDDOWN) }
- YY_BREAK
-case 98:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DEL_HOLDDOWN) }
- YY_BREAK
-case 99:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_KEEP_MISSING) }
- YY_BREAK
-case 100:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_USE_SYSLOG) }
- YY_BREAK
-case 101:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_LOG_TIME_ASCII) }
- YY_BREAK
-case 102:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_LOG_QUERIES) }
- YY_BREAK
-case 103:
-YY_RULE_SETUP
-{ YDVAR(2, VAR_LOCAL_ZONE) }
- YY_BREAK
-case 104:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_LOCAL_DATA) }
- YY_BREAK
-case 105:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_LOCAL_DATA_PTR) }
- YY_BREAK
-case 106:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_STATISTICS_INTERVAL) }
- YY_BREAK
-case 107:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_STATISTICS_CUMULATIVE) }
- YY_BREAK
-case 108:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_EXTENDED_STATISTICS) }
- YY_BREAK
-case 109:
-YY_RULE_SETUP
-{ YDVAR(0, VAR_REMOTE_CONTROL) }
- YY_BREAK
-case 110:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_CONTROL_ENABLE) }
- YY_BREAK
-case 111:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_CONTROL_INTERFACE) }
- YY_BREAK
-case 112:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_CONTROL_PORT) }
- YY_BREAK
-case 113:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_SERVER_KEY_FILE) }
- YY_BREAK
-case 114:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_SERVER_CERT_FILE) }
- YY_BREAK
-case 115:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_CONTROL_KEY_FILE) }
- YY_BREAK
-case 116:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_CONTROL_CERT_FILE) }
- YY_BREAK
-case 117:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_PYTHON_SCRIPT) }
- YY_BREAK
-case 118:
-YY_RULE_SETUP
-{ YDVAR(0, VAR_PYTHON) }
- YY_BREAK
-case 119:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_DOMAIN_INSECURE) }
- YY_BREAK
-case 120:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_MINIMAL_RESPONSES) }
- YY_BREAK
-case 121:
-YY_RULE_SETUP
-{ YDVAR(1, VAR_RRSET_ROUNDROBIN) }
- YY_BREAK
-case 122:
-/* rule 122 can match eol */
-YY_RULE_SETUP
-{ LEXOUT(("NL\n")); cfg_parser->line++; }
- YY_BREAK
-/* Quoted strings. Strip leading and ending quotes */
-case 123:
-YY_RULE_SETUP
-{ BEGIN(quotedstring); LEXOUT(("QS ")); }
- YY_BREAK
-case YY_STATE_EOF(quotedstring):
-{
- yyerror("EOF inside quoted string");
- if(--num_args == 0) { BEGIN(INITIAL); }
- else { BEGIN(val); }
-}
- YY_BREAK
-case 124:
-YY_RULE_SETUP
-{ LEXOUT(("STR(%s) ", yytext)); yymore(); }
- YY_BREAK
-case 125:
-/* rule 125 can match eol */
-YY_RULE_SETUP
-{ yyerror("newline inside quoted string, no end \"");
- cfg_parser->line++; BEGIN(INITIAL); }
- YY_BREAK
-case 126:
-YY_RULE_SETUP
-{
- LEXOUT(("QE "));
- if(--num_args == 0) { BEGIN(INITIAL); }
- else { BEGIN(val); }
- yytext[yyleng - 1] = '\0';
- yylval.str = strdup(yytext);
- if(!yylval.str)
- yyerror("out of memory");
- return STRING_ARG;
-}
- YY_BREAK
-/* Single Quoted strings. Strip leading and ending quotes */
-case 127:
-YY_RULE_SETUP
-{ BEGIN(singlequotedstr); LEXOUT(("SQS ")); }
- YY_BREAK
-case YY_STATE_EOF(singlequotedstr):
-{
- yyerror("EOF inside quoted string");
- if(--num_args == 0) { BEGIN(INITIAL); }
- else { BEGIN(val); }
-}
- YY_BREAK
-case 128:
-YY_RULE_SETUP
-{ LEXOUT(("STR(%s) ", yytext)); yymore(); }
- YY_BREAK
-case 129:
-/* rule 129 can match eol */
-YY_RULE_SETUP
-{ yyerror("newline inside quoted string, no end '");
- cfg_parser->line++; BEGIN(INITIAL); }
- YY_BREAK
-case 130:
-YY_RULE_SETUP
-{
- LEXOUT(("SQE "));
- if(--num_args == 0) { BEGIN(INITIAL); }
- else { BEGIN(val); }
- yytext[yyleng - 1] = '\0';
- yylval.str = strdup(yytext);
- if(!yylval.str)
- yyerror("out of memory");
- return STRING_ARG;
-}
- YY_BREAK
-/* include: directive */
-case 131:
-YY_RULE_SETUP
-{
- LEXOUT(("v(%s) ", yytext)); inc_prev = YYSTATE; BEGIN(include); }
- YY_BREAK
-case YY_STATE_EOF(include):
-{
- yyerror("EOF inside include directive");
- BEGIN(inc_prev);
-}
- YY_BREAK
-case 132:
-YY_RULE_SETUP
-{ LEXOUT(("ISP ")); /* ignore */ }
- YY_BREAK
-case 133:
-/* rule 133 can match eol */
-YY_RULE_SETUP
-{ LEXOUT(("NL\n")); cfg_parser->line++;}
- YY_BREAK
-case 134:
-YY_RULE_SETUP
-{ LEXOUT(("IQS ")); BEGIN(include_quoted); }
- YY_BREAK
-case 135:
-YY_RULE_SETUP
-{
- LEXOUT(("Iunquotedstr(%s) ", yytext));
- config_start_include_glob(yytext);
- BEGIN(inc_prev);
-}
- YY_BREAK
-case YY_STATE_EOF(include_quoted):
-{
- yyerror("EOF inside quoted string");
- BEGIN(inc_prev);
-}
- YY_BREAK
-case 136:
-YY_RULE_SETUP
-{ LEXOUT(("ISTR(%s) ", yytext)); yymore(); }
- YY_BREAK
-case 137:
-/* rule 137 can match eol */
-YY_RULE_SETUP
-{ yyerror("newline before \" in include name");
- cfg_parser->line++; BEGIN(inc_prev); }
- YY_BREAK
-case 138:
-YY_RULE_SETUP
-{
- LEXOUT(("IQE "));
- yytext[yyleng - 1] = '\0';
- config_start_include_glob(yytext);
- BEGIN(inc_prev);
-}
- YY_BREAK
-case YY_STATE_EOF(INITIAL):
-case YY_STATE_EOF(val):
-{
- yy_set_bol(1); /* Set beginning of line, so "^" rules match. */
- if (config_include_stack_ptr == 0) {
- yyterminate();
- } else {
- fclose(yyin);
- config_end_include();
- }
-}
- YY_BREAK
-case 139:
-YY_RULE_SETUP
-{ LEXOUT(("unquotedstr(%s) ", yytext));
- if(--num_args == 0) { BEGIN(INITIAL); }
- yylval.str = strdup(yytext); return STRING_ARG; }
- YY_BREAK
-case 140:
-YY_RULE_SETUP
-{
- ub_c_error_msg("unknown keyword '%s'", yytext);
- }
- YY_BREAK
-case 141:
-YY_RULE_SETUP
-{
- ub_c_error_msg("stray '%s'", yytext);
- }
- YY_BREAK
-case 142:
-YY_RULE_SETUP
-ECHO;
- YY_BREAK
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = (yy_hold_char);
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between YY_CURRENT_BUFFER and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++(yy_c_buf_p);
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = (yy_c_buf_p);
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_END_OF_FILE:
- {
- (yy_did_buffer_switch_on_eof) = 0;
-
- if ( yywrap( ) )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) =
- (yytext_ptr) + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- (yy_c_buf_p) =
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
-
- yy_current_state = yy_get_previous_state( );
-
- yy_cp = (yy_c_buf_p);
- yy_bp = (yytext_ptr) + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
-} /* end of yylex */
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-static int yy_get_next_buffer (void)
-{
- char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
- char *source = (yytext_ptr);
- int number_to_move, i;
- int ret_val;
-
- if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
-
- else
- {
- yy_size_t num_to_read =
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
-
- int yy_c_buf_p_offset =
- (int) ((yy_c_buf_p) - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- yy_size_t new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
- number_to_move - 1;
-
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), num_to_read );
-
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- if ( (yy_n_chars) == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart(yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
- /* Extend the array by 50%, plus the number we really need. */
- yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
- }
-
- (yy_n_chars) += number_to_move;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
-
- (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
-
- return ret_val;
-}
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
- static yy_state_type yy_get_previous_state (void)
-{
- yy_state_type yy_current_state;
- char *yy_cp;
-
- yy_current_state = (yy_start);
-
- for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
- {
- YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 1343 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
-}
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
-{
- int yy_is_jam;
- char *yy_cp = (yy_c_buf_p);
-
- YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- (yy_last_accepting_state) = yy_current_state;
- (yy_last_accepting_cpos) = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 1343 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 1342);
-
- return yy_is_jam ? 0 : yy_current_state;
-}
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
- static int yyinput (void)
-#else
- static int input (void)
-#endif
-
-{
- int c;
-
- *(yy_c_buf_p) = (yy_hold_char);
-
- if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
- /* This was really a NUL. */
- *(yy_c_buf_p) = '\0';
-
- else
- { /* need more input */
- yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
- ++(yy_c_buf_p);
-
- switch ( yy_get_next_buffer( ) )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart(yyin );
-
- /*FALLTHROUGH*/
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap( ) )
- return EOF;
-
- if ( ! (yy_did_buffer_switch_on_eof) )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- (yy_c_buf_p) = (yytext_ptr) + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
- *(yy_c_buf_p) = '\0'; /* preserve yytext */
- (yy_hold_char) = *++(yy_c_buf_p);
-
- return c;
-}
-#endif /* ifndef YY_NO_INPUT */
-
-/** Immediately switch to a different input stream.
- * @param input_file A readable stream.
- *
- * @note This function does not reset the start condition to @c INITIAL .
- */
- void yyrestart (FILE * input_file )
-{
-
- if ( ! YY_CURRENT_BUFFER ){
- yyensure_buffer_stack ();
- YY_CURRENT_BUFFER_LVALUE =
- yy_create_buffer(yyin,YY_BUF_SIZE );
- }
-
- yy_init_buffer(YY_CURRENT_BUFFER,input_file );
- yy_load_buffer_state( );
-}
-
-/** Switch to a different input buffer.
- * @param new_buffer The new input buffer.
- *
- */
- void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
-{
-
- /* TODO. We should be able to replace this entire function body
- * with
- * yypop_buffer_state();
- * yypush_buffer_state(new_buffer);
- */
- yyensure_buffer_stack ();
- if ( YY_CURRENT_BUFFER == new_buffer )
- return;
-
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
- yy_load_buffer_state( );
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-static void yy_load_buffer_state (void)
-{
- (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
- (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
- yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
- (yy_hold_char) = *(yy_c_buf_p);
-}
-
-/** Allocate and initialize an input buffer state.
- * @param file A readable stream.
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
- *
- * @return the allocated buffer state.
- */
- YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
-{
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer(b,file );
-
- return b;
-}
-
-/** Destroy the buffer.
- * @param b a buffer created with yy_create_buffer()
- *
- */
- void yy_delete_buffer (YY_BUFFER_STATE b )
-{
-
- if ( ! b )
- return;
-
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yyfree((void *) b->yy_ch_buf );
-
- yyfree((void *) b );
-}
-
-/* Initializes or reinitializes a buffer.
- * This function is sometimes called more than once on the same buffer,
- * such as during a yyrestart() or at EOF.
- */
- static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
-
-{
- int oerrno = errno;
-
- yy_flush_buffer(b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
- /* If b is the current buffer, then yy_init_buffer was _probably_
- * called from yyrestart() or through yy_get_next_buffer.
- * In that case, we don't want to reset the lineno or column.
- */
- if (b != YY_CURRENT_BUFFER){
- b->yy_bs_lineno = 1;
- b->yy_bs_column = 0;
- }
-
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-
- errno = oerrno;
-}
-
-/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
- *
- */
- void yy_flush_buffer (YY_BUFFER_STATE b )
-{
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == YY_CURRENT_BUFFER )
- yy_load_buffer_state( );
-}
-
-/** Pushes the new state onto the stack. The new state becomes
- * the current state. This function will allocate the stack
- * if necessary.
- * @param new_buffer The new state.
- *
- */
-void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
-{
- if (new_buffer == NULL)
- return;
-
- yyensure_buffer_stack();
-
- /* This block is copied from yy_switch_to_buffer. */
- if ( YY_CURRENT_BUFFER )
- {
- /* Flush out information for old buffer. */
- *(yy_c_buf_p) = (yy_hold_char);
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
- }
-
- /* Only push if top exists. Otherwise, replace top. */
- if (YY_CURRENT_BUFFER)
- (yy_buffer_stack_top)++;
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
-
- /* copied from yy_switch_to_buffer. */
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
-}
-
-/** Removes and deletes the top of the stack, if present.
- * The next element becomes the new top.
- *
- */
-void yypop_buffer_state (void)
-{
- if (!YY_CURRENT_BUFFER)
- return;
-
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- if ((yy_buffer_stack_top) > 0)
- --(yy_buffer_stack_top);
-
- if (YY_CURRENT_BUFFER) {
- yy_load_buffer_state( );
- (yy_did_buffer_switch_on_eof) = 1;
- }
-}
-
-/* Allocates the stack if it does not exist.
- * Guarantees space for at least one push.
- */
-static void yyensure_buffer_stack (void)
-{
- yy_size_t num_to_alloc;
-
- if (!(yy_buffer_stack)) {
-
- /* First allocation is just for 2 elements, since we don't know if this
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
- * immediate realloc on the next call.
- */
- num_to_alloc = 1;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
- (num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
-
- (yy_buffer_stack_max) = num_to_alloc;
- (yy_buffer_stack_top) = 0;
- return;
- }
-
- if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
-
- /* Increase the buffer to prepare for a possible push. */
- int grow_size = 8 /* arbitrary grow size */;
-
- num_to_alloc = (yy_buffer_stack_max) + grow_size;
- (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
- ((yy_buffer_stack),
- num_to_alloc * sizeof(struct yy_buffer_state*)
- );
- if ( ! (yy_buffer_stack) )
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-
- /* zero only the new slots.*/
- memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
- (yy_buffer_stack_max) = num_to_alloc;
- }
-}
-
-/** Setup the input buffer state to scan directly from a user-specified character buffer.
- * @param base the character buffer
- * @param size the size in bytes of the character buffer
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
-{
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer(b );
-
- return b;
-}
-
-/** Setup the input buffer state to scan a string. The next call to yylex() will
- * scan from a @e copy of @a str.
- * @param yystr a NUL-terminated string to scan
- *
- * @return the newly allocated buffer state object.
- * @note If you want to scan bytes that may contain NUL values, then use
- * yy_scan_bytes() instead.
- */
-YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
-{
-
- return yy_scan_bytes(yystr,strlen(yystr) );
-}
-
-/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
- * scan from a @e copy of @a bytes.
- * @param yybytes the byte buffer to scan
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
- *
- * @return the newly allocated buffer state object.
- */
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
-{
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- yy_size_t i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = _yybytes_len + 2;
- buf = (char *) yyalloc(n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < _yybytes_len; ++i )
- buf[i] = yybytes[i];
-
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer(buf,n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
-}
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-static void yy_fatal_error (yyconst char* msg )
-{
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
-}
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- int yyless_macro_arg = (n); \
- YY_LESS_LINENO(yyless_macro_arg);\
- yytext[yyleng] = (yy_hold_char); \
- (yy_c_buf_p) = yytext + yyless_macro_arg; \
- (yy_hold_char) = *(yy_c_buf_p); \
- *(yy_c_buf_p) = '\0'; \
- yyleng = yyless_macro_arg; \
- } \
- while ( 0 )
-
-/* Accessor methods (get/set functions) to struct members. */
-
-/** Get the current line number.
- *
- */
-int yyget_lineno (void)
-{
-
- return yylineno;
-}
-
-/** Get the input stream.
- *
- */
-FILE *yyget_in (void)
-{
- return yyin;
-}
-
-/** Get the output stream.
- *
- */
-FILE *yyget_out (void)
-{
- return yyout;
-}
-
-/** Get the length of the current token.
- *
- */
-yy_size_t yyget_leng (void)
-{
- return yyleng;
-}
-
-/** Get the current token.
- *
- */
-
-char *yyget_text (void)
-{
- return yytext;
-}
-
-/** Set the current line number.
- * @param line_number
- *
- */
-void yyset_lineno (int line_number )
-{
-
- yylineno = line_number;
-}
-
-/** Set the input stream. This does not discard the current
- * input buffer.
- * @param in_str A readable stream.
- *
- * @see yy_switch_to_buffer
- */
-void yyset_in (FILE * in_str )
-{
- yyin = in_str ;
-}
-
-void yyset_out (FILE * out_str )
-{
- yyout = out_str ;
-}
-
-int yyget_debug (void)
-{
- return yy_flex_debug;
-}
-
-void yyset_debug (int bdebug )
-{
- yy_flex_debug = bdebug ;
-}
-
-static int yy_init_globals (void)
-{
- /* Initialization is the same as for the non-reentrant scanner.
- * This function is called from yylex_destroy(), so don't allocate here.
- */
-
- (yy_buffer_stack) = 0;
- (yy_buffer_stack_top) = 0;
- (yy_buffer_stack_max) = 0;
- (yy_c_buf_p) = (char *) 0;
- (yy_init) = 0;
- (yy_start) = 0;
-
-/* Defined in main.c */
-#ifdef YY_STDINIT
- yyin = stdin;
- yyout = stdout;
-#else
- yyin = (FILE *) 0;
- yyout = (FILE *) 0;
-#endif
-
- /* For future reference: Set errno on error, since we are called by
- * yylex_init()
- */
- return 0;
-}
-
-/* yylex_destroy is for both reentrant and non-reentrant scanners. */
-int yylex_destroy (void)
-{
-
- /* Pop the buffer stack, destroying each element. */
- while(YY_CURRENT_BUFFER){
- yy_delete_buffer(YY_CURRENT_BUFFER );
- YY_CURRENT_BUFFER_LVALUE = NULL;
- yypop_buffer_state();
- }
-
- /* Destroy the stack itself. */
- yyfree((yy_buffer_stack) );
- (yy_buffer_stack) = NULL;
-
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
- * yylex() is called, initialization will occur. */
- yy_init_globals( );
-
- return 0;
-}
-
-/*
- * Internal utility routines.
- */
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
-{
- int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
-}
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen (yyconst char * s )
-{
- int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
-}
-#endif
-
-void *yyalloc (yy_size_t size )
-{
- return (void *) malloc( size );
-}
-
-void *yyrealloc (void * ptr, yy_size_t size )
-{
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
-}
-
-void yyfree (void * ptr )
-{
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
-}
-
-#define YYTABLES_NAME "yytables"
-
diff --git a/contrib/unbound/util/configlexer.lex b/contrib/unbound/util/configlexer.lex
index 4694cdd..6c22609 100644
--- a/contrib/unbound/util/configlexer.lex
+++ b/contrib/unbound/util/configlexer.lex
@@ -8,6 +8,8 @@
*
*/
+#include "config.h"
+
#include <ctype.h>
#include <string.h>
#include <strings.h>
@@ -16,7 +18,7 @@
#endif
#include "util/config_file.h"
-#include "util/configparser.h"
+#include "configparser.h"
void ub_c_error(const char *message);
#if 0
@@ -26,56 +28,80 @@ void ub_c_error(const char *message);
#endif
/** avoid warning in about fwrite return value */
-#define ECHO ub_c_error_msg("syntax error at text: %s", yytext)
+#define ECHO ub_c_error_msg("syntax error at text: %s", ub_c_text)
/** A parser variable, this is a statement in the config file which is
* of the form variable: value1 value2 ... nargs is the number of values. */
#define YDVAR(nargs, var) \
num_args=(nargs); \
- LEXOUT(("v(%s%d) ", yytext, num_args)); \
+ LEXOUT(("v(%s%d) ", ub_c_text, num_args)); \
if(num_args > 0) { BEGIN(val); } \
return (var);
struct inc_state {
char* filename;
int line;
+ YY_BUFFER_STATE buffer;
+ struct inc_state* next;
};
-static struct inc_state parse_stack[MAXINCLUDES];
-static YY_BUFFER_STATE include_stack[MAXINCLUDES];
-static int config_include_stack_ptr = 0;
+static struct inc_state* config_include_stack = NULL;
+static int inc_depth = 0;
static int inc_prev = 0;
static int num_args = 0;
+void init_cfg_parse(void)
+{
+ config_include_stack = NULL;
+ inc_depth = 0;
+ inc_prev = 0;
+ num_args = 0;
+}
static void config_start_include(const char* filename)
{
FILE *input;
+ struct inc_state* s;
+ char* nm;
+ if(inc_depth++ > 100000) {
+ ub_c_error_msg("too many include files");
+ return;
+ }
if(strlen(filename) == 0) {
ub_c_error_msg("empty include file name");
return;
}
- if(config_include_stack_ptr >= MAXINCLUDES) {
- ub_c_error_msg("includes nested too deeply, skipped (>%d)", MAXINCLUDES);
+ s = (struct inc_state*)malloc(sizeof(*s));
+ if(!s) {
+ ub_c_error_msg("include %s: malloc failure", filename);
return;
}
if(cfg_parser->chroot && strncmp(filename, cfg_parser->chroot,
strlen(cfg_parser->chroot)) == 0) {
filename += strlen(cfg_parser->chroot);
}
+ nm = strdup(filename);
+ if(!nm) {
+ ub_c_error_msg("include %s: strdup failure", filename);
+ free(s);
+ return;
+ }
input = fopen(filename, "r");
if(!input) {
ub_c_error_msg("cannot open include file '%s': %s",
filename, strerror(errno));
+ free(s);
+ free(nm);
return;
}
- LEXOUT(("switch_to_include_file(%s) ", filename));
- parse_stack[config_include_stack_ptr].filename = cfg_parser->filename;
- parse_stack[config_include_stack_ptr].line = cfg_parser->line;
- include_stack[config_include_stack_ptr] = YY_CURRENT_BUFFER;
- cfg_parser->filename = strdup(filename);
+ LEXOUT(("switch_to_include_file(%s)\n", filename));
+ s->filename = cfg_parser->filename;
+ s->line = cfg_parser->line;
+ s->buffer = YY_CURRENT_BUFFER;
+ s->next = config_include_stack;
+ config_include_stack = s;
+ cfg_parser->filename = nm;
cfg_parser->line = 1;
yy_switch_to_buffer(yy_create_buffer(input, YY_BUF_SIZE));
- ++config_include_stack_ptr;
}
static void config_start_include_glob(const char* filename)
@@ -107,6 +133,8 @@ static void config_start_include_glob(const char* filename)
if(r) {
/* some error */
globfree(&g);
+ if(r == GLOB_NOMATCH)
+ return; /* no matches for pattern */
config_start_include(filename); /* let original deal with it */
return;
}
@@ -124,19 +152,23 @@ static void config_start_include_glob(const char* filename)
static void config_end_include(void)
{
- --config_include_stack_ptr;
+ struct inc_state* s = config_include_stack;
+ --inc_depth;
+ if(!s) return;
free(cfg_parser->filename);
- cfg_parser->filename = parse_stack[config_include_stack_ptr].filename;
- cfg_parser->line = parse_stack[config_include_stack_ptr].line;
+ cfg_parser->filename = s->filename;
+ cfg_parser->line = s->line;
yy_delete_buffer(YY_CURRENT_BUFFER);
- yy_switch_to_buffer(include_stack[config_include_stack_ptr]);
+ yy_switch_to_buffer(s->buffer);
+ config_include_stack = s->next;
+ free(s);
}
#ifndef yy_set_bol /* compat definition, for flex 2.4.6 */
#define yy_set_bol(at_bol) \
{ \
if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer = yy_create_buffer( ub_c_in, YY_BUF_SIZE ); \
yy_current_buffer->yy_ch_buf[0] = ((at_bol)?'\n':' '); \
}
#endif
@@ -170,7 +202,7 @@ SQANY [^\'\n\r\\]|\\.
LEXOUT(("SP ")); /* ignore */ }
<INITIAL,val>{SPACE}*{COMMENT}.* {
/* note that flex makes the longest match and '.' is any but not nl */
- LEXOUT(("comment(%s) ", yytext)); /* ignore */ }
+ LEXOUT(("comment(%s) ", ub_c_text)); /* ignore */ }
server{COLON} { YDVAR(0, VAR_SERVER) }
num-threads{COLON} { YDVAR(1, VAR_NUM_THREADS) }
verbosity{COLON} { YDVAR(1, VAR_VERBOSITY) }
@@ -191,10 +223,12 @@ ssl-service-pem{COLON} { YDVAR(1, VAR_SSL_SERVICE_PEM) }
ssl-port{COLON} { YDVAR(1, VAR_SSL_PORT) }
do-daemonize{COLON} { YDVAR(1, VAR_DO_DAEMONIZE) }
interface{COLON} { YDVAR(1, VAR_INTERFACE) }
+ip-address{COLON} { YDVAR(1, VAR_INTERFACE) }
outgoing-interface{COLON} { YDVAR(1, VAR_OUTGOING_INTERFACE) }
interface-automatic{COLON} { YDVAR(1, VAR_INTERFACE_AUTOMATIC) }
so-rcvbuf{COLON} { YDVAR(1, VAR_SO_RCVBUF) }
so-sndbuf{COLON} { YDVAR(1, VAR_SO_SNDBUF) }
+so-reuseport{COLON} { YDVAR(1, VAR_SO_REUSEPORT) }
chroot{COLON} { YDVAR(1, VAR_CHROOT) }
username{COLON} { YDVAR(1, VAR_USERNAME) }
directory{COLON} { YDVAR(1, VAR_DIRECTORY) }
@@ -216,6 +250,7 @@ infra-cache-numhosts{COLON} { YDVAR(1, VAR_INFRA_CACHE_NUMHOSTS) }
infra-cache-lame-size{COLON} { YDVAR(1, VAR_INFRA_CACHE_LAME_SIZE) }
num-queries-per-thread{COLON} { YDVAR(1, VAR_NUM_QUERIES_PER_THREAD) }
jostle-timeout{COLON} { YDVAR(1, VAR_JOSTLE_TIMEOUT) }
+delay-close{COLON} { YDVAR(1, VAR_DELAY_CLOSE) }
target-fetch-policy{COLON} { YDVAR(1, VAR_TARGET_FETCH_POLICY) }
harden-short-bufsize{COLON} { YDVAR(1, VAR_HARDEN_SHORT_BUFSIZE) }
harden-large-queries{COLON} { YDVAR(1, VAR_HARDEN_LARGE_QUERIES) }
@@ -275,6 +310,7 @@ log-queries{COLON} { YDVAR(1, VAR_LOG_QUERIES) }
local-zone{COLON} { YDVAR(2, VAR_LOCAL_ZONE) }
local-data{COLON} { YDVAR(1, VAR_LOCAL_DATA) }
local-data-ptr{COLON} { YDVAR(1, VAR_LOCAL_DATA_PTR) }
+unblock-lan-zones{COLON} { YDVAR(1, VAR_UNBLOCK_LAN_ZONES) }
statistics-interval{COLON} { YDVAR(1, VAR_STATISTICS_INTERVAL) }
statistics-cumulative{COLON} { YDVAR(1, VAR_STATISTICS_CUMULATIVE) }
extended-statistics{COLON} { YDVAR(1, VAR_EXTENDED_STATISTICS) }
@@ -291,98 +327,100 @@ python{COLON} { YDVAR(0, VAR_PYTHON) }
domain-insecure{COLON} { YDVAR(1, VAR_DOMAIN_INSECURE) }
minimal-responses{COLON} { YDVAR(1, VAR_MINIMAL_RESPONSES) }
rrset-roundrobin{COLON} { YDVAR(1, VAR_RRSET_ROUNDROBIN) }
+max-udp-size{COLON} { YDVAR(1, VAR_MAX_UDP_SIZE) }
<INITIAL,val>{NEWLINE} { LEXOUT(("NL\n")); cfg_parser->line++; }
/* Quoted strings. Strip leading and ending quotes */
<val>\" { BEGIN(quotedstring); LEXOUT(("QS ")); }
<quotedstring><<EOF>> {
- yyerror("EOF inside quoted string");
+ ub_c_error("EOF inside quoted string");
if(--num_args == 0) { BEGIN(INITIAL); }
else { BEGIN(val); }
}
-<quotedstring>{DQANY}* { LEXOUT(("STR(%s) ", yytext)); yymore(); }
-<quotedstring>{NEWLINE} { yyerror("newline inside quoted string, no end \"");
+<quotedstring>{DQANY}* { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
+<quotedstring>{NEWLINE} { ub_c_error("newline inside quoted string, no end \"");
cfg_parser->line++; BEGIN(INITIAL); }
<quotedstring>\" {
LEXOUT(("QE "));
if(--num_args == 0) { BEGIN(INITIAL); }
else { BEGIN(val); }
- yytext[yyleng - 1] = '\0';
- yylval.str = strdup(yytext);
- if(!yylval.str)
- yyerror("out of memory");
+ ub_c_text[ub_c_leng - 1] = '\0';
+ ub_c_lval.str = strdup(ub_c_text);
+ if(!ub_c_lval.str)
+ ub_c_error("out of memory");
return STRING_ARG;
}
/* Single Quoted strings. Strip leading and ending quotes */
<val>\' { BEGIN(singlequotedstr); LEXOUT(("SQS ")); }
<singlequotedstr><<EOF>> {
- yyerror("EOF inside quoted string");
+ ub_c_error("EOF inside quoted string");
if(--num_args == 0) { BEGIN(INITIAL); }
else { BEGIN(val); }
}
-<singlequotedstr>{SQANY}* { LEXOUT(("STR(%s) ", yytext)); yymore(); }
-<singlequotedstr>{NEWLINE} { yyerror("newline inside quoted string, no end '");
+<singlequotedstr>{SQANY}* { LEXOUT(("STR(%s) ", ub_c_text)); yymore(); }
+<singlequotedstr>{NEWLINE} { ub_c_error("newline inside quoted string, no end '");
cfg_parser->line++; BEGIN(INITIAL); }
<singlequotedstr>\' {
LEXOUT(("SQE "));
if(--num_args == 0) { BEGIN(INITIAL); }
else { BEGIN(val); }
- yytext[yyleng - 1] = '\0';
- yylval.str = strdup(yytext);
- if(!yylval.str)
- yyerror("out of memory");
+ ub_c_text[ub_c_leng - 1] = '\0';
+ ub_c_lval.str = strdup(ub_c_text);
+ if(!ub_c_lval.str)
+ ub_c_error("out of memory");
return STRING_ARG;
}
/* include: directive */
<INITIAL,val>include{COLON} {
- LEXOUT(("v(%s) ", yytext)); inc_prev = YYSTATE; BEGIN(include); }
+ LEXOUT(("v(%s) ", ub_c_text)); inc_prev = YYSTATE; BEGIN(include); }
<include><<EOF>> {
- yyerror("EOF inside include directive");
+ ub_c_error("EOF inside include directive");
BEGIN(inc_prev);
}
<include>{SPACE}* { LEXOUT(("ISP ")); /* ignore */ }
<include>{NEWLINE} { LEXOUT(("NL\n")); cfg_parser->line++;}
<include>\" { LEXOUT(("IQS ")); BEGIN(include_quoted); }
<include>{UNQUOTEDLETTER}* {
- LEXOUT(("Iunquotedstr(%s) ", yytext));
- config_start_include_glob(yytext);
+ LEXOUT(("Iunquotedstr(%s) ", ub_c_text));
+ config_start_include_glob(ub_c_text);
BEGIN(inc_prev);
}
<include_quoted><<EOF>> {
- yyerror("EOF inside quoted string");
+ ub_c_error("EOF inside quoted string");
BEGIN(inc_prev);
}
-<include_quoted>{DQANY}* { LEXOUT(("ISTR(%s) ", yytext)); yymore(); }
-<include_quoted>{NEWLINE} { yyerror("newline before \" in include name");
+<include_quoted>{DQANY}* { LEXOUT(("ISTR(%s) ", ub_c_text)); yymore(); }
+<include_quoted>{NEWLINE} { ub_c_error("newline before \" in include name");
cfg_parser->line++; BEGIN(inc_prev); }
<include_quoted>\" {
LEXOUT(("IQE "));
- yytext[yyleng - 1] = '\0';
- config_start_include_glob(yytext);
+ ub_c_text[ub_c_leng - 1] = '\0';
+ config_start_include_glob(ub_c_text);
BEGIN(inc_prev);
}
<INITIAL,val><<EOF>> {
+ LEXOUT(("LEXEOF "));
yy_set_bol(1); /* Set beginning of line, so "^" rules match. */
- if (config_include_stack_ptr == 0) {
+ if (!config_include_stack) {
yyterminate();
} else {
- fclose(yyin);
+ fclose(ub_c_in);
config_end_include();
}
}
-<val>{UNQUOTEDLETTER}* { LEXOUT(("unquotedstr(%s) ", yytext));
+<val>{UNQUOTEDLETTER}* { LEXOUT(("unquotedstr(%s) ", ub_c_text));
if(--num_args == 0) { BEGIN(INITIAL); }
- yylval.str = strdup(yytext); return STRING_ARG; }
+ ub_c_lval.str = strdup(ub_c_text); return STRING_ARG; }
{UNQUOTEDLETTER_NOCOLON}* {
- ub_c_error_msg("unknown keyword '%s'", yytext);
+ ub_c_error_msg("unknown keyword '%s'", ub_c_text);
}
<*>. {
- ub_c_error_msg("stray '%s'", yytext);
+ ub_c_error_msg("stray '%s'", ub_c_text);
}
%%
diff --git a/contrib/unbound/util/configparser.c b/contrib/unbound/util/configparser.c
deleted file mode 100644
index 1f89d57..0000000
--- a/contrib/unbound/util/configparser.c
+++ /dev/null
@@ -1,2330 +0,0 @@
-#ifndef lint
-static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
-#endif
-
-#define YYBYACC 1
-#define YYMAJOR 1
-#define YYMINOR 9
-
-#define YYEMPTY (-1)
-#define yyclearin (yychar = YYEMPTY)
-#define yyerrok (yyerrflag = 0)
-#define YYRECOVERING() (yyerrflag != 0)
-
-#define YYPREFIX "yy"
-
-#define YYPURE 0
-
-#line 39 "util/configparser.y"
-#include "config.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "util/configyyrename.h"
-#include "util/config_file.h"
-#include "util/net_help.h"
-
-int ub_c_lex(void);
-void ub_c_error(const char *message);
-
-/* these need to be global, otherwise they cannot be used inside yacc */
-extern struct config_parser_state* cfg_parser;
-
-#if 0
-#define OUTYY(s) printf s /* used ONLY when debugging */
-#else
-#define OUTYY(s)
-#endif
-
-#line 64 "util/configparser.y"
-#ifdef YYSTYPE
-#undef YYSTYPE_IS_DECLARED
-#define YYSTYPE_IS_DECLARED 1
-#endif
-#ifndef YYSTYPE_IS_DECLARED
-#define YYSTYPE_IS_DECLARED 1
-typedef union {
- char* str;
-} YYSTYPE;
-#endif /* !YYSTYPE_IS_DECLARED */
-#line 54 "util/configparser.c"
-
-/* compatibility with bison */
-#ifdef YYPARSE_PARAM
-/* compatibility with FreeBSD */
-# ifdef YYPARSE_PARAM_TYPE
-# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
-# else
-# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
-# endif
-#else
-# define YYPARSE_DECL() yyparse(void)
-#endif
-
-/* Parameters sent to lex. */
-#ifdef YYLEX_PARAM
-# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
-# define YYLEX yylex(YYLEX_PARAM)
-#else
-# define YYLEX_DECL() yylex(void)
-# define YYLEX yylex()
-#endif
-
-/* Parameters sent to yyerror. */
-#ifndef YYERROR_DECL
-#define YYERROR_DECL() yyerror(const char *s)
-#endif
-#ifndef YYERROR_CALL
-#define YYERROR_CALL(msg) yyerror(msg)
-#endif
-
-extern int YYPARSE_DECL();
-
-#define SPACE 257
-#define LETTER 258
-#define NEWLINE 259
-#define COMMENT 260
-#define COLON 261
-#define ANY 262
-#define ZONESTR 263
-#define STRING_ARG 264
-#define VAR_SERVER 265
-#define VAR_VERBOSITY 266
-#define VAR_NUM_THREADS 267
-#define VAR_PORT 268
-#define VAR_OUTGOING_RANGE 269
-#define VAR_INTERFACE 270
-#define VAR_DO_IP4 271
-#define VAR_DO_IP6 272
-#define VAR_DO_UDP 273
-#define VAR_DO_TCP 274
-#define VAR_CHROOT 275
-#define VAR_USERNAME 276
-#define VAR_DIRECTORY 277
-#define VAR_LOGFILE 278
-#define VAR_PIDFILE 279
-#define VAR_MSG_CACHE_SIZE 280
-#define VAR_MSG_CACHE_SLABS 281
-#define VAR_NUM_QUERIES_PER_THREAD 282
-#define VAR_RRSET_CACHE_SIZE 283
-#define VAR_RRSET_CACHE_SLABS 284
-#define VAR_OUTGOING_NUM_TCP 285
-#define VAR_INFRA_HOST_TTL 286
-#define VAR_INFRA_LAME_TTL 287
-#define VAR_INFRA_CACHE_SLABS 288
-#define VAR_INFRA_CACHE_NUMHOSTS 289
-#define VAR_INFRA_CACHE_LAME_SIZE 290
-#define VAR_NAME 291
-#define VAR_STUB_ZONE 292
-#define VAR_STUB_HOST 293
-#define VAR_STUB_ADDR 294
-#define VAR_TARGET_FETCH_POLICY 295
-#define VAR_HARDEN_SHORT_BUFSIZE 296
-#define VAR_HARDEN_LARGE_QUERIES 297
-#define VAR_FORWARD_ZONE 298
-#define VAR_FORWARD_HOST 299
-#define VAR_FORWARD_ADDR 300
-#define VAR_DO_NOT_QUERY_ADDRESS 301
-#define VAR_HIDE_IDENTITY 302
-#define VAR_HIDE_VERSION 303
-#define VAR_IDENTITY 304
-#define VAR_VERSION 305
-#define VAR_HARDEN_GLUE 306
-#define VAR_MODULE_CONF 307
-#define VAR_TRUST_ANCHOR_FILE 308
-#define VAR_TRUST_ANCHOR 309
-#define VAR_VAL_OVERRIDE_DATE 310
-#define VAR_BOGUS_TTL 311
-#define VAR_VAL_CLEAN_ADDITIONAL 312
-#define VAR_VAL_PERMISSIVE_MODE 313
-#define VAR_INCOMING_NUM_TCP 314
-#define VAR_MSG_BUFFER_SIZE 315
-#define VAR_KEY_CACHE_SIZE 316
-#define VAR_KEY_CACHE_SLABS 317
-#define VAR_TRUSTED_KEYS_FILE 318
-#define VAR_VAL_NSEC3_KEYSIZE_ITERATIONS 319
-#define VAR_USE_SYSLOG 320
-#define VAR_OUTGOING_INTERFACE 321
-#define VAR_ROOT_HINTS 322
-#define VAR_DO_NOT_QUERY_LOCALHOST 323
-#define VAR_CACHE_MAX_TTL 324
-#define VAR_HARDEN_DNSSEC_STRIPPED 325
-#define VAR_ACCESS_CONTROL 326
-#define VAR_LOCAL_ZONE 327
-#define VAR_LOCAL_DATA 328
-#define VAR_INTERFACE_AUTOMATIC 329
-#define VAR_STATISTICS_INTERVAL 330
-#define VAR_DO_DAEMONIZE 331
-#define VAR_USE_CAPS_FOR_ID 332
-#define VAR_STATISTICS_CUMULATIVE 333
-#define VAR_OUTGOING_PORT_PERMIT 334
-#define VAR_OUTGOING_PORT_AVOID 335
-#define VAR_DLV_ANCHOR_FILE 336
-#define VAR_DLV_ANCHOR 337
-#define VAR_NEG_CACHE_SIZE 338
-#define VAR_HARDEN_REFERRAL_PATH 339
-#define VAR_PRIVATE_ADDRESS 340
-#define VAR_PRIVATE_DOMAIN 341
-#define VAR_REMOTE_CONTROL 342
-#define VAR_CONTROL_ENABLE 343
-#define VAR_CONTROL_INTERFACE 344
-#define VAR_CONTROL_PORT 345
-#define VAR_SERVER_KEY_FILE 346
-#define VAR_SERVER_CERT_FILE 347
-#define VAR_CONTROL_KEY_FILE 348
-#define VAR_CONTROL_CERT_FILE 349
-#define VAR_EXTENDED_STATISTICS 350
-#define VAR_LOCAL_DATA_PTR 351
-#define VAR_JOSTLE_TIMEOUT 352
-#define VAR_STUB_PRIME 353
-#define VAR_UNWANTED_REPLY_THRESHOLD 354
-#define VAR_LOG_TIME_ASCII 355
-#define VAR_DOMAIN_INSECURE 356
-#define VAR_PYTHON 357
-#define VAR_PYTHON_SCRIPT 358
-#define VAR_VAL_SIG_SKEW_MIN 359
-#define VAR_VAL_SIG_SKEW_MAX 360
-#define VAR_CACHE_MIN_TTL 361
-#define VAR_VAL_LOG_LEVEL 362
-#define VAR_AUTO_TRUST_ANCHOR_FILE 363
-#define VAR_KEEP_MISSING 364
-#define VAR_ADD_HOLDDOWN 365
-#define VAR_DEL_HOLDDOWN 366
-#define VAR_SO_RCVBUF 367
-#define VAR_EDNS_BUFFER_SIZE 368
-#define VAR_PREFETCH 369
-#define VAR_PREFETCH_KEY 370
-#define VAR_SO_SNDBUF 371
-#define VAR_HARDEN_BELOW_NXDOMAIN 372
-#define VAR_IGNORE_CD_FLAG 373
-#define VAR_LOG_QUERIES 374
-#define VAR_TCP_UPSTREAM 375
-#define VAR_SSL_UPSTREAM 376
-#define VAR_SSL_SERVICE_KEY 377
-#define VAR_SSL_SERVICE_PEM 378
-#define VAR_SSL_PORT 379
-#define VAR_FORWARD_FIRST 380
-#define VAR_STUB_FIRST 381
-#define VAR_MINIMAL_RESPONSES 382
-#define VAR_RRSET_ROUNDROBIN 383
-#define YYERRCODE 256
-static const short yylhs[] = { -1,
- 0, 0, 1, 1, 1, 1, 1, 2, 3, 3,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
- 12, 12, 12, 12, 12, 12, 12, 12, 4, 5,
- 5, 111, 111, 111, 111, 111, 6, 7, 7, 117,
- 117, 117, 117, 13, 14, 70, 73, 82, 15, 21,
- 61, 16, 74, 75, 32, 54, 69, 17, 18, 19,
- 20, 104, 105, 106, 107, 108, 71, 60, 86, 103,
- 22, 23, 24, 25, 26, 62, 76, 77, 92, 48,
- 58, 49, 87, 42, 43, 44, 45, 96, 100, 97,
- 55, 27, 28, 29, 84, 30, 31, 33, 34, 36,
- 37, 35, 38, 39, 40, 46, 65, 101, 79, 72,
- 80, 81, 98, 99, 85, 41, 63, 66, 47, 50,
- 88, 89, 64, 90, 51, 52, 53, 102, 91, 59,
- 93, 94, 95, 56, 57, 78, 67, 68, 83, 109,
- 110, 112, 113, 114, 116, 115, 118, 119, 120, 121,
- 10, 11, 11, 122, 122, 122, 122, 122, 122, 122,
- 123, 125, 124, 126, 127, 128, 129, 8, 9, 9,
- 130, 131,
-};
-static const short yylen[] = { 2,
- 0, 2, 2, 2, 2, 2, 2, 1, 2, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
- 0, 1, 1, 1, 1, 1, 1, 2, 0, 1,
- 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 3, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 3, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 1, 2, 0, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 1, 2, 0,
- 1, 2,
-};
-static const short yydefred[] = { 1,
- 0, 8, 109, 117, 231, 248, 2, 10, 111, 119,
- 250, 233, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 9, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
- 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
- 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
- 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
- 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
- 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
- 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
- 105, 106, 107, 108, 0, 0, 0, 0, 0, 110,
- 112, 113, 114, 115, 116, 0, 0, 0, 0, 118,
- 120, 121, 122, 123, 0, 249, 251, 0, 0, 0,
- 0, 0, 0, 0, 232, 234, 235, 236, 237, 238,
- 239, 240, 125, 124, 129, 132, 130, 138, 139, 140,
- 141, 151, 152, 153, 154, 155, 172, 173, 174, 176,
- 177, 135, 178, 179, 182, 180, 181, 183, 184, 185,
- 196, 164, 165, 166, 167, 186, 199, 160, 162, 200,
- 205, 206, 207, 136, 171, 214, 215, 161, 210, 148,
- 131, 156, 197, 203, 187, 0, 0, 218, 137, 126,
- 147, 190, 127, 133, 134, 157, 158, 216, 189, 191,
- 192, 128, 219, 175, 195, 149, 163, 201, 202, 204,
- 209, 159, 213, 211, 212, 168, 170, 193, 194, 169,
- 188, 208, 150, 142, 143, 144, 145, 146, 220, 221,
- 222, 223, 224, 226, 225, 227, 228, 229, 230, 252,
- 241, 243, 242, 244, 245, 246, 247, 198, 217,
-};
-static const short yydgoto[] = { 1,
- 7, 8, 13, 9, 14, 10, 15, 11, 16, 12,
- 17, 116, 117, 118, 119, 120, 121, 122, 123, 124,
- 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
- 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
- 145, 146, 147, 148, 149, 150, 151, 152, 153, 154,
- 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
- 165, 166, 167, 168, 169, 170, 171, 172, 173, 174,
- 175, 176, 177, 178, 179, 180, 181, 182, 183, 184,
- 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
- 195, 196, 197, 198, 199, 200, 201, 202, 203, 204,
- 205, 206, 207, 208, 209, 210, 211, 212, 213, 214,
- 220, 221, 222, 223, 224, 225, 230, 231, 232, 233,
- 234, 245, 246, 247, 248, 249, 250, 251, 252, 236,
- 237,
-};
-static const short yysindex[] = { 0,
- -172, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -260, -209, -202, -358, -216, -233, -232, -231,
- -230, -226, -225, -224, -181, -178, -177, -176, -143, -140,
- -139, -130, -129, -128, -127, -126, -125, -124, -123, -122,
- -121, -119, -118, -117, -116, -115, -114, -113, -112, -111,
- -110, -109, -108, -107, -106, -105, -104, -103, -102, -101,
- -100, -99, -98, -97, -96, -95, -93, -91, -90, -89,
- -88, -87, -85, -84, -83, -82, -81, -80, -78, -77,
- -76, -75, -74, -73, -72, -71, -70, -69, -68, -67,
- -66, -65, -64, -63, -62, -61, -60, -59, -58, -57,
- -56, -55, -54, -53, -52, -51, -50, -49, -48, -47,
- -46, -45, -44, -43, -42, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, -41, -40, -39, -38, -37, 0,
- 0, 0, 0, 0, 0, -36, -35, -34, -33, 0,
- 0, 0, 0, 0, -32, 0, 0, -31, -30, -29,
- -28, -27, -26, -25, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, -24, -23, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const short yyrindex[] = { 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 1, 2, 3, 4, 5, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-static const short yygindex[] = { 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0,
-};
-#define YYTABLESIZE 362
-static const short yytable[] = { 235,
- 3, 4, 5, 6, 7, 18, 19, 20, 21, 22,
- 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
- 253, 254, 255, 256, 43, 44, 45, 257, 258, 259,
- 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
- 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
- 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
- 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
- 86, 215, 260, 216, 217, 261, 262, 263, 226, 87,
- 88, 89, 2, 90, 91, 92, 227, 228, 93, 94,
- 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
- 105, 106, 107, 108, 109, 110, 111, 112, 113, 3,
- 264, 114, 115, 265, 266, 4, 238, 239, 240, 241,
- 242, 243, 244, 267, 268, 269, 270, 271, 272, 273,
- 274, 275, 276, 218, 277, 278, 279, 280, 281, 282,
- 283, 284, 285, 286, 287, 288, 289, 290, 291, 292,
- 293, 294, 295, 296, 297, 298, 299, 300, 301, 5,
- 302, 219, 303, 304, 305, 306, 307, 229, 308, 309,
- 310, 311, 312, 313, 6, 314, 315, 316, 317, 318,
- 319, 320, 321, 322, 323, 324, 325, 326, 327, 328,
- 329, 330, 331, 332, 333, 334, 335, 336, 337, 338,
- 339, 340, 341, 342, 343, 344, 345, 346, 347, 348,
- 349, 350, 351, 352, 353, 354, 355, 356, 357, 358,
- 359, 360, 361, 362, 363, 364, 365, 366, 367, 368,
- 369, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 3, 4, 5, 6, 7,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 4, 5, 6, 7, 0, 3, 4,
- 5, 6, 7, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 3, 4, 5, 6, 7, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 3, 4, 5,
- 6, 7,
-};
-static const short yycheck[] = { 358,
- 0, 0, 0, 0, 0, 266, 267, 268, 269, 270,
- 271, 272, 273, 274, 275, 276, 277, 278, 279, 280,
- 281, 282, 283, 284, 285, 286, 287, 288, 289, 290,
- 264, 264, 264, 264, 295, 296, 297, 264, 264, 264,
- 301, 302, 303, 304, 305, 306, 307, 308, 309, 310,
- 311, 312, 313, 314, 315, 316, 317, 318, 319, 320,
- 321, 322, 323, 324, 325, 326, 327, 328, 329, 330,
- 331, 332, 333, 334, 335, 336, 337, 338, 339, 340,
- 341, 291, 264, 293, 294, 264, 264, 264, 291, 350,
- 351, 352, 265, 354, 355, 356, 299, 300, 359, 360,
- 361, 362, 363, 364, 365, 366, 367, 368, 369, 370,
- 371, 372, 373, 374, 375, 376, 377, 378, 379, 292,
- 264, 382, 383, 264, 264, 298, 343, 344, 345, 346,
- 347, 348, 349, 264, 264, 264, 264, 264, 264, 264,
- 264, 264, 264, 353, 264, 264, 264, 264, 264, 264,
- 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- 264, 264, 264, 264, 264, 264, 264, 264, 264, 342,
- 264, 381, 264, 264, 264, 264, 264, 380, 264, 264,
- 264, 264, 264, 264, 357, 264, 264, 264, 264, 264,
- 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- 264, 264, 264, 264, 264, 264, 264, 264, 264, 264,
- 264, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 265, 265, 265, 265, 265,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 292, 292, 292, 292, 292, -1, 298, 298,
- 298, 298, 298, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, 342, 342, 342, 342, 342, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, 357, 357, 357,
- 357, 357,
-};
-#define YYFINAL 1
-#ifndef YYDEBUG
-#define YYDEBUG 0
-#endif
-#define YYMAXTOKEN 383
-#if YYDEBUG
-static const char *yyname[] = {
-
-"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
-0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"SPACE","LETTER","NEWLINE",
-"COMMENT","COLON","ANY","ZONESTR","STRING_ARG","VAR_SERVER","VAR_VERBOSITY",
-"VAR_NUM_THREADS","VAR_PORT","VAR_OUTGOING_RANGE","VAR_INTERFACE","VAR_DO_IP4",
-"VAR_DO_IP6","VAR_DO_UDP","VAR_DO_TCP","VAR_CHROOT","VAR_USERNAME",
-"VAR_DIRECTORY","VAR_LOGFILE","VAR_PIDFILE","VAR_MSG_CACHE_SIZE",
-"VAR_MSG_CACHE_SLABS","VAR_NUM_QUERIES_PER_THREAD","VAR_RRSET_CACHE_SIZE",
-"VAR_RRSET_CACHE_SLABS","VAR_OUTGOING_NUM_TCP","VAR_INFRA_HOST_TTL",
-"VAR_INFRA_LAME_TTL","VAR_INFRA_CACHE_SLABS","VAR_INFRA_CACHE_NUMHOSTS",
-"VAR_INFRA_CACHE_LAME_SIZE","VAR_NAME","VAR_STUB_ZONE","VAR_STUB_HOST",
-"VAR_STUB_ADDR","VAR_TARGET_FETCH_POLICY","VAR_HARDEN_SHORT_BUFSIZE",
-"VAR_HARDEN_LARGE_QUERIES","VAR_FORWARD_ZONE","VAR_FORWARD_HOST",
-"VAR_FORWARD_ADDR","VAR_DO_NOT_QUERY_ADDRESS","VAR_HIDE_IDENTITY",
-"VAR_HIDE_VERSION","VAR_IDENTITY","VAR_VERSION","VAR_HARDEN_GLUE",
-"VAR_MODULE_CONF","VAR_TRUST_ANCHOR_FILE","VAR_TRUST_ANCHOR",
-"VAR_VAL_OVERRIDE_DATE","VAR_BOGUS_TTL","VAR_VAL_CLEAN_ADDITIONAL",
-"VAR_VAL_PERMISSIVE_MODE","VAR_INCOMING_NUM_TCP","VAR_MSG_BUFFER_SIZE",
-"VAR_KEY_CACHE_SIZE","VAR_KEY_CACHE_SLABS","VAR_TRUSTED_KEYS_FILE",
-"VAR_VAL_NSEC3_KEYSIZE_ITERATIONS","VAR_USE_SYSLOG","VAR_OUTGOING_INTERFACE",
-"VAR_ROOT_HINTS","VAR_DO_NOT_QUERY_LOCALHOST","VAR_CACHE_MAX_TTL",
-"VAR_HARDEN_DNSSEC_STRIPPED","VAR_ACCESS_CONTROL","VAR_LOCAL_ZONE",
-"VAR_LOCAL_DATA","VAR_INTERFACE_AUTOMATIC","VAR_STATISTICS_INTERVAL",
-"VAR_DO_DAEMONIZE","VAR_USE_CAPS_FOR_ID","VAR_STATISTICS_CUMULATIVE",
-"VAR_OUTGOING_PORT_PERMIT","VAR_OUTGOING_PORT_AVOID","VAR_DLV_ANCHOR_FILE",
-"VAR_DLV_ANCHOR","VAR_NEG_CACHE_SIZE","VAR_HARDEN_REFERRAL_PATH",
-"VAR_PRIVATE_ADDRESS","VAR_PRIVATE_DOMAIN","VAR_REMOTE_CONTROL",
-"VAR_CONTROL_ENABLE","VAR_CONTROL_INTERFACE","VAR_CONTROL_PORT",
-"VAR_SERVER_KEY_FILE","VAR_SERVER_CERT_FILE","VAR_CONTROL_KEY_FILE",
-"VAR_CONTROL_CERT_FILE","VAR_EXTENDED_STATISTICS","VAR_LOCAL_DATA_PTR",
-"VAR_JOSTLE_TIMEOUT","VAR_STUB_PRIME","VAR_UNWANTED_REPLY_THRESHOLD",
-"VAR_LOG_TIME_ASCII","VAR_DOMAIN_INSECURE","VAR_PYTHON","VAR_PYTHON_SCRIPT",
-"VAR_VAL_SIG_SKEW_MIN","VAR_VAL_SIG_SKEW_MAX","VAR_CACHE_MIN_TTL",
-"VAR_VAL_LOG_LEVEL","VAR_AUTO_TRUST_ANCHOR_FILE","VAR_KEEP_MISSING",
-"VAR_ADD_HOLDDOWN","VAR_DEL_HOLDDOWN","VAR_SO_RCVBUF","VAR_EDNS_BUFFER_SIZE",
-"VAR_PREFETCH","VAR_PREFETCH_KEY","VAR_SO_SNDBUF","VAR_HARDEN_BELOW_NXDOMAIN",
-"VAR_IGNORE_CD_FLAG","VAR_LOG_QUERIES","VAR_TCP_UPSTREAM","VAR_SSL_UPSTREAM",
-"VAR_SSL_SERVICE_KEY","VAR_SSL_SERVICE_PEM","VAR_SSL_PORT","VAR_FORWARD_FIRST",
-"VAR_STUB_FIRST","VAR_MINIMAL_RESPONSES","VAR_RRSET_ROUNDROBIN",
-};
-static const char *yyrule[] = {
-"$accept : toplevelvars",
-"toplevelvars :",
-"toplevelvars : toplevelvars toplevelvar",
-"toplevelvar : serverstart contents_server",
-"toplevelvar : stubstart contents_stub",
-"toplevelvar : forwardstart contents_forward",
-"toplevelvar : pythonstart contents_py",
-"toplevelvar : rcstart contents_rc",
-"serverstart : VAR_SERVER",
-"contents_server : contents_server content_server",
-"contents_server :",
-"content_server : server_num_threads",
-"content_server : server_verbosity",
-"content_server : server_port",
-"content_server : server_outgoing_range",
-"content_server : server_do_ip4",
-"content_server : server_do_ip6",
-"content_server : server_do_udp",
-"content_server : server_do_tcp",
-"content_server : server_interface",
-"content_server : server_chroot",
-"content_server : server_username",
-"content_server : server_directory",
-"content_server : server_logfile",
-"content_server : server_pidfile",
-"content_server : server_msg_cache_size",
-"content_server : server_msg_cache_slabs",
-"content_server : server_num_queries_per_thread",
-"content_server : server_rrset_cache_size",
-"content_server : server_rrset_cache_slabs",
-"content_server : server_outgoing_num_tcp",
-"content_server : server_infra_host_ttl",
-"content_server : server_infra_lame_ttl",
-"content_server : server_infra_cache_slabs",
-"content_server : server_infra_cache_numhosts",
-"content_server : server_infra_cache_lame_size",
-"content_server : server_target_fetch_policy",
-"content_server : server_harden_short_bufsize",
-"content_server : server_harden_large_queries",
-"content_server : server_do_not_query_address",
-"content_server : server_hide_identity",
-"content_server : server_hide_version",
-"content_server : server_identity",
-"content_server : server_version",
-"content_server : server_harden_glue",
-"content_server : server_module_conf",
-"content_server : server_trust_anchor_file",
-"content_server : server_trust_anchor",
-"content_server : server_val_override_date",
-"content_server : server_bogus_ttl",
-"content_server : server_val_clean_additional",
-"content_server : server_val_permissive_mode",
-"content_server : server_incoming_num_tcp",
-"content_server : server_msg_buffer_size",
-"content_server : server_key_cache_size",
-"content_server : server_key_cache_slabs",
-"content_server : server_trusted_keys_file",
-"content_server : server_val_nsec3_keysize_iterations",
-"content_server : server_use_syslog",
-"content_server : server_outgoing_interface",
-"content_server : server_root_hints",
-"content_server : server_do_not_query_localhost",
-"content_server : server_cache_max_ttl",
-"content_server : server_harden_dnssec_stripped",
-"content_server : server_access_control",
-"content_server : server_local_zone",
-"content_server : server_local_data",
-"content_server : server_interface_automatic",
-"content_server : server_statistics_interval",
-"content_server : server_do_daemonize",
-"content_server : server_use_caps_for_id",
-"content_server : server_statistics_cumulative",
-"content_server : server_outgoing_port_permit",
-"content_server : server_outgoing_port_avoid",
-"content_server : server_dlv_anchor_file",
-"content_server : server_dlv_anchor",
-"content_server : server_neg_cache_size",
-"content_server : server_harden_referral_path",
-"content_server : server_private_address",
-"content_server : server_private_domain",
-"content_server : server_extended_statistics",
-"content_server : server_local_data_ptr",
-"content_server : server_jostle_timeout",
-"content_server : server_unwanted_reply_threshold",
-"content_server : server_log_time_ascii",
-"content_server : server_domain_insecure",
-"content_server : server_val_sig_skew_min",
-"content_server : server_val_sig_skew_max",
-"content_server : server_cache_min_ttl",
-"content_server : server_val_log_level",
-"content_server : server_auto_trust_anchor_file",
-"content_server : server_add_holddown",
-"content_server : server_del_holddown",
-"content_server : server_keep_missing",
-"content_server : server_so_rcvbuf",
-"content_server : server_edns_buffer_size",
-"content_server : server_prefetch",
-"content_server : server_prefetch_key",
-"content_server : server_so_sndbuf",
-"content_server : server_harden_below_nxdomain",
-"content_server : server_ignore_cd_flag",
-"content_server : server_log_queries",
-"content_server : server_tcp_upstream",
-"content_server : server_ssl_upstream",
-"content_server : server_ssl_service_key",
-"content_server : server_ssl_service_pem",
-"content_server : server_ssl_port",
-"content_server : server_minimal_responses",
-"content_server : server_rrset_roundrobin",
-"stubstart : VAR_STUB_ZONE",
-"contents_stub : contents_stub content_stub",
-"contents_stub :",
-"content_stub : stub_name",
-"content_stub : stub_host",
-"content_stub : stub_addr",
-"content_stub : stub_prime",
-"content_stub : stub_first",
-"forwardstart : VAR_FORWARD_ZONE",
-"contents_forward : contents_forward content_forward",
-"contents_forward :",
-"content_forward : forward_name",
-"content_forward : forward_host",
-"content_forward : forward_addr",
-"content_forward : forward_first",
-"server_num_threads : VAR_NUM_THREADS STRING_ARG",
-"server_verbosity : VAR_VERBOSITY STRING_ARG",
-"server_statistics_interval : VAR_STATISTICS_INTERVAL STRING_ARG",
-"server_statistics_cumulative : VAR_STATISTICS_CUMULATIVE STRING_ARG",
-"server_extended_statistics : VAR_EXTENDED_STATISTICS STRING_ARG",
-"server_port : VAR_PORT STRING_ARG",
-"server_interface : VAR_INTERFACE STRING_ARG",
-"server_outgoing_interface : VAR_OUTGOING_INTERFACE STRING_ARG",
-"server_outgoing_range : VAR_OUTGOING_RANGE STRING_ARG",
-"server_outgoing_port_permit : VAR_OUTGOING_PORT_PERMIT STRING_ARG",
-"server_outgoing_port_avoid : VAR_OUTGOING_PORT_AVOID STRING_ARG",
-"server_outgoing_num_tcp : VAR_OUTGOING_NUM_TCP STRING_ARG",
-"server_incoming_num_tcp : VAR_INCOMING_NUM_TCP STRING_ARG",
-"server_interface_automatic : VAR_INTERFACE_AUTOMATIC STRING_ARG",
-"server_do_ip4 : VAR_DO_IP4 STRING_ARG",
-"server_do_ip6 : VAR_DO_IP6 STRING_ARG",
-"server_do_udp : VAR_DO_UDP STRING_ARG",
-"server_do_tcp : VAR_DO_TCP STRING_ARG",
-"server_tcp_upstream : VAR_TCP_UPSTREAM STRING_ARG",
-"server_ssl_upstream : VAR_SSL_UPSTREAM STRING_ARG",
-"server_ssl_service_key : VAR_SSL_SERVICE_KEY STRING_ARG",
-"server_ssl_service_pem : VAR_SSL_SERVICE_PEM STRING_ARG",
-"server_ssl_port : VAR_SSL_PORT STRING_ARG",
-"server_do_daemonize : VAR_DO_DAEMONIZE STRING_ARG",
-"server_use_syslog : VAR_USE_SYSLOG STRING_ARG",
-"server_log_time_ascii : VAR_LOG_TIME_ASCII STRING_ARG",
-"server_log_queries : VAR_LOG_QUERIES STRING_ARG",
-"server_chroot : VAR_CHROOT STRING_ARG",
-"server_username : VAR_USERNAME STRING_ARG",
-"server_directory : VAR_DIRECTORY STRING_ARG",
-"server_logfile : VAR_LOGFILE STRING_ARG",
-"server_pidfile : VAR_PIDFILE STRING_ARG",
-"server_root_hints : VAR_ROOT_HINTS STRING_ARG",
-"server_dlv_anchor_file : VAR_DLV_ANCHOR_FILE STRING_ARG",
-"server_dlv_anchor : VAR_DLV_ANCHOR STRING_ARG",
-"server_auto_trust_anchor_file : VAR_AUTO_TRUST_ANCHOR_FILE STRING_ARG",
-"server_trust_anchor_file : VAR_TRUST_ANCHOR_FILE STRING_ARG",
-"server_trusted_keys_file : VAR_TRUSTED_KEYS_FILE STRING_ARG",
-"server_trust_anchor : VAR_TRUST_ANCHOR STRING_ARG",
-"server_domain_insecure : VAR_DOMAIN_INSECURE STRING_ARG",
-"server_hide_identity : VAR_HIDE_IDENTITY STRING_ARG",
-"server_hide_version : VAR_HIDE_VERSION STRING_ARG",
-"server_identity : VAR_IDENTITY STRING_ARG",
-"server_version : VAR_VERSION STRING_ARG",
-"server_so_rcvbuf : VAR_SO_RCVBUF STRING_ARG",
-"server_so_sndbuf : VAR_SO_SNDBUF STRING_ARG",
-"server_edns_buffer_size : VAR_EDNS_BUFFER_SIZE STRING_ARG",
-"server_msg_buffer_size : VAR_MSG_BUFFER_SIZE STRING_ARG",
-"server_msg_cache_size : VAR_MSG_CACHE_SIZE STRING_ARG",
-"server_msg_cache_slabs : VAR_MSG_CACHE_SLABS STRING_ARG",
-"server_num_queries_per_thread : VAR_NUM_QUERIES_PER_THREAD STRING_ARG",
-"server_jostle_timeout : VAR_JOSTLE_TIMEOUT STRING_ARG",
-"server_rrset_cache_size : VAR_RRSET_CACHE_SIZE STRING_ARG",
-"server_rrset_cache_slabs : VAR_RRSET_CACHE_SLABS STRING_ARG",
-"server_infra_host_ttl : VAR_INFRA_HOST_TTL STRING_ARG",
-"server_infra_lame_ttl : VAR_INFRA_LAME_TTL STRING_ARG",
-"server_infra_cache_numhosts : VAR_INFRA_CACHE_NUMHOSTS STRING_ARG",
-"server_infra_cache_lame_size : VAR_INFRA_CACHE_LAME_SIZE STRING_ARG",
-"server_infra_cache_slabs : VAR_INFRA_CACHE_SLABS STRING_ARG",
-"server_target_fetch_policy : VAR_TARGET_FETCH_POLICY STRING_ARG",
-"server_harden_short_bufsize : VAR_HARDEN_SHORT_BUFSIZE STRING_ARG",
-"server_harden_large_queries : VAR_HARDEN_LARGE_QUERIES STRING_ARG",
-"server_harden_glue : VAR_HARDEN_GLUE STRING_ARG",
-"server_harden_dnssec_stripped : VAR_HARDEN_DNSSEC_STRIPPED STRING_ARG",
-"server_harden_below_nxdomain : VAR_HARDEN_BELOW_NXDOMAIN STRING_ARG",
-"server_harden_referral_path : VAR_HARDEN_REFERRAL_PATH STRING_ARG",
-"server_use_caps_for_id : VAR_USE_CAPS_FOR_ID STRING_ARG",
-"server_private_address : VAR_PRIVATE_ADDRESS STRING_ARG",
-"server_private_domain : VAR_PRIVATE_DOMAIN STRING_ARG",
-"server_prefetch : VAR_PREFETCH STRING_ARG",
-"server_prefetch_key : VAR_PREFETCH_KEY STRING_ARG",
-"server_unwanted_reply_threshold : VAR_UNWANTED_REPLY_THRESHOLD STRING_ARG",
-"server_do_not_query_address : VAR_DO_NOT_QUERY_ADDRESS STRING_ARG",
-"server_do_not_query_localhost : VAR_DO_NOT_QUERY_LOCALHOST STRING_ARG",
-"server_access_control : VAR_ACCESS_CONTROL STRING_ARG STRING_ARG",
-"server_module_conf : VAR_MODULE_CONF STRING_ARG",
-"server_val_override_date : VAR_VAL_OVERRIDE_DATE STRING_ARG",
-"server_val_sig_skew_min : VAR_VAL_SIG_SKEW_MIN STRING_ARG",
-"server_val_sig_skew_max : VAR_VAL_SIG_SKEW_MAX STRING_ARG",
-"server_cache_max_ttl : VAR_CACHE_MAX_TTL STRING_ARG",
-"server_cache_min_ttl : VAR_CACHE_MIN_TTL STRING_ARG",
-"server_bogus_ttl : VAR_BOGUS_TTL STRING_ARG",
-"server_val_clean_additional : VAR_VAL_CLEAN_ADDITIONAL STRING_ARG",
-"server_val_permissive_mode : VAR_VAL_PERMISSIVE_MODE STRING_ARG",
-"server_ignore_cd_flag : VAR_IGNORE_CD_FLAG STRING_ARG",
-"server_val_log_level : VAR_VAL_LOG_LEVEL STRING_ARG",
-"server_val_nsec3_keysize_iterations : VAR_VAL_NSEC3_KEYSIZE_ITERATIONS STRING_ARG",
-"server_add_holddown : VAR_ADD_HOLDDOWN STRING_ARG",
-"server_del_holddown : VAR_DEL_HOLDDOWN STRING_ARG",
-"server_keep_missing : VAR_KEEP_MISSING STRING_ARG",
-"server_key_cache_size : VAR_KEY_CACHE_SIZE STRING_ARG",
-"server_key_cache_slabs : VAR_KEY_CACHE_SLABS STRING_ARG",
-"server_neg_cache_size : VAR_NEG_CACHE_SIZE STRING_ARG",
-"server_local_zone : VAR_LOCAL_ZONE STRING_ARG STRING_ARG",
-"server_local_data : VAR_LOCAL_DATA STRING_ARG",
-"server_local_data_ptr : VAR_LOCAL_DATA_PTR STRING_ARG",
-"server_minimal_responses : VAR_MINIMAL_RESPONSES STRING_ARG",
-"server_rrset_roundrobin : VAR_RRSET_ROUNDROBIN STRING_ARG",
-"stub_name : VAR_NAME STRING_ARG",
-"stub_host : VAR_STUB_HOST STRING_ARG",
-"stub_addr : VAR_STUB_ADDR STRING_ARG",
-"stub_first : VAR_STUB_FIRST STRING_ARG",
-"stub_prime : VAR_STUB_PRIME STRING_ARG",
-"forward_name : VAR_NAME STRING_ARG",
-"forward_host : VAR_FORWARD_HOST STRING_ARG",
-"forward_addr : VAR_FORWARD_ADDR STRING_ARG",
-"forward_first : VAR_FORWARD_FIRST STRING_ARG",
-"rcstart : VAR_REMOTE_CONTROL",
-"contents_rc : contents_rc content_rc",
-"contents_rc :",
-"content_rc : rc_control_enable",
-"content_rc : rc_control_interface",
-"content_rc : rc_control_port",
-"content_rc : rc_server_key_file",
-"content_rc : rc_server_cert_file",
-"content_rc : rc_control_key_file",
-"content_rc : rc_control_cert_file",
-"rc_control_enable : VAR_CONTROL_ENABLE STRING_ARG",
-"rc_control_port : VAR_CONTROL_PORT STRING_ARG",
-"rc_control_interface : VAR_CONTROL_INTERFACE STRING_ARG",
-"rc_server_key_file : VAR_SERVER_KEY_FILE STRING_ARG",
-"rc_server_cert_file : VAR_SERVER_CERT_FILE STRING_ARG",
-"rc_control_key_file : VAR_CONTROL_KEY_FILE STRING_ARG",
-"rc_control_cert_file : VAR_CONTROL_CERT_FILE STRING_ARG",
-"pythonstart : VAR_PYTHON",
-"contents_py : contents_py content_py",
-"contents_py :",
-"content_py : py_script",
-"py_script : VAR_PYTHON_SCRIPT STRING_ARG",
-
-};
-#endif
-
-int yydebug;
-int yynerrs;
-
-int yyerrflag;
-int yychar;
-YYSTYPE yyval;
-YYSTYPE yylval;
-
-/* define the initial stack-sizes */
-#ifdef YYSTACKSIZE
-#undef YYMAXDEPTH
-#define YYMAXDEPTH YYSTACKSIZE
-#else
-#ifdef YYMAXDEPTH
-#define YYSTACKSIZE YYMAXDEPTH
-#else
-#define YYSTACKSIZE 500
-#define YYMAXDEPTH 500
-#endif
-#endif
-
-#define YYINITSTACKSIZE 500
-
-typedef struct {
- unsigned stacksize;
- short *s_base;
- short *s_mark;
- short *s_last;
- YYSTYPE *l_base;
- YYSTYPE *l_mark;
-} YYSTACKDATA;
-/* variables for the parser stack */
-static YYSTACKDATA yystack;
-#line 1277 "util/configparser.y"
-
-/* parse helper routines could be here */
-#line 845 "util/configparser.c"
-
-#if YYDEBUG
-#include <stdio.h> /* needed for printf */
-#endif
-
-#include <stdlib.h> /* needed for malloc, etc */
-#include <string.h> /* needed for memset */
-
-/* allocate initial stack or double stack size, up to YYMAXDEPTH */
-static int yygrowstack(YYSTACKDATA *data)
-{
- int i;
- unsigned newsize;
- short *newss;
- YYSTYPE *newvs;
-
- if ((newsize = data->stacksize) == 0)
- newsize = YYINITSTACKSIZE;
- else if (newsize >= YYMAXDEPTH)
- return -1;
- else if ((newsize *= 2) > YYMAXDEPTH)
- newsize = YYMAXDEPTH;
-
- i = (int) (data->s_mark - data->s_base);
- newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
- if (newss == 0)
- return -1;
-
- data->s_base = newss;
- data->s_mark = newss + i;
-
- newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
- if (newvs == 0)
- return -1;
-
- data->l_base = newvs;
- data->l_mark = newvs + i;
-
- data->stacksize = newsize;
- data->s_last = data->s_base + newsize - 1;
- return 0;
-}
-
-#if YYPURE || defined(YY_NO_LEAKS)
-static void yyfreestack(YYSTACKDATA *data)
-{
- free(data->s_base);
- free(data->l_base);
- memset(data, 0, sizeof(*data));
-}
-#else
-#define yyfreestack(data) /* nothing */
-#endif
-
-#define YYABORT goto yyabort
-#define YYREJECT goto yyabort
-#define YYACCEPT goto yyaccept
-#define YYERROR goto yyerrlab
-
-int
-YYPARSE_DECL()
-{
- int yym, yyn, yystate;
-#if YYDEBUG
- const char *yys;
-
- if ((yys = getenv("YYDEBUG")) != 0)
- {
- yyn = *yys;
- if (yyn >= '0' && yyn <= '9')
- yydebug = yyn - '0';
- }
-#endif
-
- yynerrs = 0;
- yyerrflag = 0;
- yychar = YYEMPTY;
- yystate = 0;
-
-#if YYPURE
- memset(&yystack, 0, sizeof(yystack));
-#endif
-
- if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
- yystack.s_mark = yystack.s_base;
- yystack.l_mark = yystack.l_base;
- yystate = 0;
- *yystack.s_mark = 0;
-
-yyloop:
- if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
- if (yychar < 0)
- {
- if ((yychar = YYLEX) < 0) yychar = 0;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, reading %d (%s)\n",
- YYPREFIX, yystate, yychar, yys);
- }
-#endif
- }
- if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, shifting to state %d\n",
- YYPREFIX, yystate, yytable[yyn]);
-#endif
- if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
- {
- goto yyoverflow;
- }
- yystate = yytable[yyn];
- *++yystack.s_mark = yytable[yyn];
- *++yystack.l_mark = yylval;
- yychar = YYEMPTY;
- if (yyerrflag > 0) --yyerrflag;
- goto yyloop;
- }
- if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
- {
- yyn = yytable[yyn];
- goto yyreduce;
- }
- if (yyerrflag) goto yyinrecovery;
-
- yyerror("syntax error");
-
- goto yyerrlab;
-
-yyerrlab:
- ++yynerrs;
-
-yyinrecovery:
- if (yyerrflag < 3)
- {
- yyerrflag = 3;
- for (;;)
- {
- if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, error recovery shifting\
- to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
-#endif
- if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
- {
- goto yyoverflow;
- }
- yystate = yytable[yyn];
- *++yystack.s_mark = yytable[yyn];
- *++yystack.l_mark = yylval;
- goto yyloop;
- }
- else
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: error recovery discarding state %d\n",
- YYPREFIX, *yystack.s_mark);
-#endif
- if (yystack.s_mark <= yystack.s_base) goto yyabort;
- --yystack.s_mark;
- --yystack.l_mark;
- }
- }
- }
- else
- {
- if (yychar == 0) goto yyabort;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
- YYPREFIX, yystate, yychar, yys);
- }
-#endif
- yychar = YYEMPTY;
- goto yyloop;
- }
-
-yyreduce:
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: state %d, reducing by rule %d (%s)\n",
- YYPREFIX, yystate, yyn, yyrule[yyn]);
-#endif
- yym = yylen[yyn];
- if (yym)
- yyval = yystack.l_mark[1-yym];
- else
- memset(&yyval, 0, sizeof yyval);
- switch (yyn)
- {
-case 8:
-#line 118 "util/configparser.y"
- {
- OUTYY(("\nP(server:)\n"));
- }
-break;
-case 109:
-#line 167 "util/configparser.y"
- {
- struct config_stub* s;
- OUTYY(("\nP(stub_zone:)\n"));
- s = (struct config_stub*)calloc(1, sizeof(struct config_stub));
- if(s) {
- s->next = cfg_parser->cfg->stubs;
- cfg_parser->cfg->stubs = s;
- } else
- yyerror("out of memory");
- }
-break;
-case 117:
-#line 183 "util/configparser.y"
- {
- struct config_stub* s;
- OUTYY(("\nP(forward_zone:)\n"));
- s = (struct config_stub*)calloc(1, sizeof(struct config_stub));
- if(s) {
- s->next = cfg_parser->cfg->forwards;
- cfg_parser->cfg->forwards = s;
- } else
- yyerror("out of memory");
- }
-break;
-case 124:
-#line 199 "util/configparser.y"
- {
- OUTYY(("P(server_num_threads:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->num_threads = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 125:
-#line 208 "util/configparser.y"
- {
- OUTYY(("P(server_verbosity:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->verbosity = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 126:
-#line 217 "util/configparser.y"
- {
- OUTYY(("P(server_statistics_interval:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "") == 0 || strcmp(yystack.l_mark[0].str, "0") == 0)
- cfg_parser->cfg->stat_interval = 0;
- else if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else cfg_parser->cfg->stat_interval = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 127:
-#line 228 "util/configparser.y"
- {
- OUTYY(("P(server_statistics_cumulative:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->stat_cumulative = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 128:
-#line 237 "util/configparser.y"
- {
- OUTYY(("P(server_extended_statistics:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->stat_extended = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 129:
-#line 246 "util/configparser.y"
- {
- OUTYY(("P(server_port:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("port number expected");
- else cfg_parser->cfg->port = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 130:
-#line 255 "util/configparser.y"
- {
- OUTYY(("P(server_interface:%s)\n", yystack.l_mark[0].str));
- if(cfg_parser->cfg->num_ifs == 0)
- cfg_parser->cfg->ifs = calloc(1, sizeof(char*));
- else cfg_parser->cfg->ifs = realloc(cfg_parser->cfg->ifs,
- (cfg_parser->cfg->num_ifs+1)*sizeof(char*));
- if(!cfg_parser->cfg->ifs)
- yyerror("out of memory");
- else
- cfg_parser->cfg->ifs[cfg_parser->cfg->num_ifs++] = yystack.l_mark[0].str;
- }
-break;
-case 131:
-#line 268 "util/configparser.y"
- {
- OUTYY(("P(server_outgoing_interface:%s)\n", yystack.l_mark[0].str));
- if(cfg_parser->cfg->num_out_ifs == 0)
- cfg_parser->cfg->out_ifs = calloc(1, sizeof(char*));
- else cfg_parser->cfg->out_ifs = realloc(
- cfg_parser->cfg->out_ifs,
- (cfg_parser->cfg->num_out_ifs+1)*sizeof(char*));
- if(!cfg_parser->cfg->out_ifs)
- yyerror("out of memory");
- else
- cfg_parser->cfg->out_ifs[
- cfg_parser->cfg->num_out_ifs++] = yystack.l_mark[0].str;
- }
-break;
-case 132:
-#line 283 "util/configparser.y"
- {
- OUTYY(("P(server_outgoing_range:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else cfg_parser->cfg->outgoing_num_ports = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 133:
-#line 292 "util/configparser.y"
- {
- OUTYY(("P(server_outgoing_port_permit:%s)\n", yystack.l_mark[0].str));
- if(!cfg_mark_ports(yystack.l_mark[0].str, 1,
- cfg_parser->cfg->outgoing_avail_ports, 65536))
- yyerror("port number or range (\"low-high\") expected");
- free(yystack.l_mark[0].str);
- }
-break;
-case 134:
-#line 301 "util/configparser.y"
- {
- OUTYY(("P(server_outgoing_port_avoid:%s)\n", yystack.l_mark[0].str));
- if(!cfg_mark_ports(yystack.l_mark[0].str, 0,
- cfg_parser->cfg->outgoing_avail_ports, 65536))
- yyerror("port number or range (\"low-high\") expected");
- free(yystack.l_mark[0].str);
- }
-break;
-case 135:
-#line 310 "util/configparser.y"
- {
- OUTYY(("P(server_outgoing_num_tcp:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->outgoing_num_tcp = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 136:
-#line 319 "util/configparser.y"
- {
- OUTYY(("P(server_incoming_num_tcp:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->incoming_num_tcp = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 137:
-#line 328 "util/configparser.y"
- {
- OUTYY(("P(server_interface_automatic:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->if_automatic = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 138:
-#line 337 "util/configparser.y"
- {
- OUTYY(("P(server_do_ip4:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->do_ip4 = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 139:
-#line 346 "util/configparser.y"
- {
- OUTYY(("P(server_do_ip6:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->do_ip6 = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 140:
-#line 355 "util/configparser.y"
- {
- OUTYY(("P(server_do_udp:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->do_udp = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 141:
-#line 364 "util/configparser.y"
- {
- OUTYY(("P(server_do_tcp:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->do_tcp = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 142:
-#line 373 "util/configparser.y"
- {
- OUTYY(("P(server_tcp_upstream:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->tcp_upstream = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 143:
-#line 382 "util/configparser.y"
- {
- OUTYY(("P(server_ssl_upstream:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->ssl_upstream = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 144:
-#line 391 "util/configparser.y"
- {
- OUTYY(("P(server_ssl_service_key:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->ssl_service_key);
- cfg_parser->cfg->ssl_service_key = yystack.l_mark[0].str;
- }
-break;
-case 145:
-#line 398 "util/configparser.y"
- {
- OUTYY(("P(server_ssl_service_pem:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->ssl_service_pem);
- cfg_parser->cfg->ssl_service_pem = yystack.l_mark[0].str;
- }
-break;
-case 146:
-#line 405 "util/configparser.y"
- {
- OUTYY(("P(server_ssl_port:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("port number expected");
- else cfg_parser->cfg->ssl_port = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 147:
-#line 414 "util/configparser.y"
- {
- OUTYY(("P(server_do_daemonize:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->do_daemonize = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 148:
-#line 423 "util/configparser.y"
- {
- OUTYY(("P(server_use_syslog:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->use_syslog = (strcmp(yystack.l_mark[0].str, "yes")==0);
-#if !defined(HAVE_SYSLOG_H) && !defined(UB_ON_WINDOWS)
- if(strcmp(yystack.l_mark[0].str, "yes") == 0)
- yyerror("no syslog services are available. "
- "(reconfigure and compile to add)");
-#endif
- free(yystack.l_mark[0].str);
- }
-break;
-case 149:
-#line 437 "util/configparser.y"
- {
- OUTYY(("P(server_log_time_ascii:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->log_time_ascii = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 150:
-#line 446 "util/configparser.y"
- {
- OUTYY(("P(server_log_queries:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->log_queries = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 151:
-#line 455 "util/configparser.y"
- {
- OUTYY(("P(server_chroot:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->chrootdir);
- cfg_parser->cfg->chrootdir = yystack.l_mark[0].str;
- }
-break;
-case 152:
-#line 462 "util/configparser.y"
- {
- OUTYY(("P(server_username:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->username);
- cfg_parser->cfg->username = yystack.l_mark[0].str;
- }
-break;
-case 153:
-#line 469 "util/configparser.y"
- {
- OUTYY(("P(server_directory:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->directory);
- cfg_parser->cfg->directory = yystack.l_mark[0].str;
- }
-break;
-case 154:
-#line 476 "util/configparser.y"
- {
- OUTYY(("P(server_logfile:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->logfile);
- cfg_parser->cfg->logfile = yystack.l_mark[0].str;
- cfg_parser->cfg->use_syslog = 0;
- }
-break;
-case 155:
-#line 484 "util/configparser.y"
- {
- OUTYY(("P(server_pidfile:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->pidfile);
- cfg_parser->cfg->pidfile = yystack.l_mark[0].str;
- }
-break;
-case 156:
-#line 491 "util/configparser.y"
- {
- OUTYY(("P(server_root_hints:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->root_hints, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 157:
-#line 498 "util/configparser.y"
- {
- OUTYY(("P(server_dlv_anchor_file:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->dlv_anchor_file);
- cfg_parser->cfg->dlv_anchor_file = yystack.l_mark[0].str;
- }
-break;
-case 158:
-#line 505 "util/configparser.y"
- {
- OUTYY(("P(server_dlv_anchor:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->dlv_anchor_list, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 159:
-#line 512 "util/configparser.y"
- {
- OUTYY(("P(server_auto_trust_anchor_file:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->
- auto_trust_anchor_file_list, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 160:
-#line 520 "util/configparser.y"
- {
- OUTYY(("P(server_trust_anchor_file:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->
- trust_anchor_file_list, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 161:
-#line 528 "util/configparser.y"
- {
- OUTYY(("P(server_trusted_keys_file:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->
- trusted_keys_file_list, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 162:
-#line 536 "util/configparser.y"
- {
- OUTYY(("P(server_trust_anchor:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->trust_anchor_list, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 163:
-#line 543 "util/configparser.y"
- {
- OUTYY(("P(server_domain_insecure:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->domain_insecure, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 164:
-#line 550 "util/configparser.y"
- {
- OUTYY(("P(server_hide_identity:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->hide_identity = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 165:
-#line 559 "util/configparser.y"
- {
- OUTYY(("P(server_hide_version:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->hide_version = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 166:
-#line 568 "util/configparser.y"
- {
- OUTYY(("P(server_identity:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->identity);
- cfg_parser->cfg->identity = yystack.l_mark[0].str;
- }
-break;
-case 167:
-#line 575 "util/configparser.y"
- {
- OUTYY(("P(server_version:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->version);
- cfg_parser->cfg->version = yystack.l_mark[0].str;
- }
-break;
-case 168:
-#line 582 "util/configparser.y"
- {
- OUTYY(("P(server_so_rcvbuf:%s)\n", yystack.l_mark[0].str));
- if(!cfg_parse_memsize(yystack.l_mark[0].str, &cfg_parser->cfg->so_rcvbuf))
- yyerror("buffer size expected");
- free(yystack.l_mark[0].str);
- }
-break;
-case 169:
-#line 590 "util/configparser.y"
- {
- OUTYY(("P(server_so_sndbuf:%s)\n", yystack.l_mark[0].str));
- if(!cfg_parse_memsize(yystack.l_mark[0].str, &cfg_parser->cfg->so_sndbuf))
- yyerror("buffer size expected");
- free(yystack.l_mark[0].str);
- }
-break;
-case 170:
-#line 598 "util/configparser.y"
- {
- OUTYY(("P(server_edns_buffer_size:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else if (atoi(yystack.l_mark[0].str) < 12)
- yyerror("edns buffer size too small");
- else if (atoi(yystack.l_mark[0].str) > 65535)
- cfg_parser->cfg->edns_buffer_size = 65535;
- else cfg_parser->cfg->edns_buffer_size = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 171:
-#line 611 "util/configparser.y"
- {
- OUTYY(("P(server_msg_buffer_size:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else if (atoi(yystack.l_mark[0].str) < 4096)
- yyerror("message buffer size too small (use 4096)");
- else cfg_parser->cfg->msg_buffer_size = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 172:
-#line 622 "util/configparser.y"
- {
- OUTYY(("P(server_msg_cache_size:%s)\n", yystack.l_mark[0].str));
- if(!cfg_parse_memsize(yystack.l_mark[0].str, &cfg_parser->cfg->msg_cache_size))
- yyerror("memory size expected");
- free(yystack.l_mark[0].str);
- }
-break;
-case 173:
-#line 630 "util/configparser.y"
- {
- OUTYY(("P(server_msg_cache_slabs:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else {
- cfg_parser->cfg->msg_cache_slabs = atoi(yystack.l_mark[0].str);
- if(!is_pow2(cfg_parser->cfg->msg_cache_slabs))
- yyerror("must be a power of 2");
- }
- free(yystack.l_mark[0].str);
- }
-break;
-case 174:
-#line 643 "util/configparser.y"
- {
- OUTYY(("P(server_num_queries_per_thread:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else cfg_parser->cfg->num_queries_per_thread = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 175:
-#line 652 "util/configparser.y"
- {
- OUTYY(("P(server_jostle_timeout:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->jostle_time = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 176:
-#line 661 "util/configparser.y"
- {
- OUTYY(("P(server_rrset_cache_size:%s)\n", yystack.l_mark[0].str));
- if(!cfg_parse_memsize(yystack.l_mark[0].str, &cfg_parser->cfg->rrset_cache_size))
- yyerror("memory size expected");
- free(yystack.l_mark[0].str);
- }
-break;
-case 177:
-#line 669 "util/configparser.y"
- {
- OUTYY(("P(server_rrset_cache_slabs:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else {
- cfg_parser->cfg->rrset_cache_slabs = atoi(yystack.l_mark[0].str);
- if(!is_pow2(cfg_parser->cfg->rrset_cache_slabs))
- yyerror("must be a power of 2");
- }
- free(yystack.l_mark[0].str);
- }
-break;
-case 178:
-#line 682 "util/configparser.y"
- {
- OUTYY(("P(server_infra_host_ttl:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->host_ttl = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 179:
-#line 691 "util/configparser.y"
- {
- OUTYY(("P(server_infra_lame_ttl:%s)\n", yystack.l_mark[0].str));
- verbose(VERB_DETAIL, "ignored infra-lame-ttl: %s (option "
- "removed, use infra-host-ttl)", yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 180:
-#line 699 "util/configparser.y"
- {
- OUTYY(("P(server_infra_cache_numhosts:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else cfg_parser->cfg->infra_cache_numhosts = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 181:
-#line 708 "util/configparser.y"
- {
- OUTYY(("P(server_infra_cache_lame_size:%s)\n", yystack.l_mark[0].str));
- verbose(VERB_DETAIL, "ignored infra-cache-lame-size: %s "
- "(option removed, use infra-cache-numhosts)", yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 182:
-#line 716 "util/configparser.y"
- {
- OUTYY(("P(server_infra_cache_slabs:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else {
- cfg_parser->cfg->infra_cache_slabs = atoi(yystack.l_mark[0].str);
- if(!is_pow2(cfg_parser->cfg->infra_cache_slabs))
- yyerror("must be a power of 2");
- }
- free(yystack.l_mark[0].str);
- }
-break;
-case 183:
-#line 729 "util/configparser.y"
- {
- OUTYY(("P(server_target_fetch_policy:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->target_fetch_policy);
- cfg_parser->cfg->target_fetch_policy = yystack.l_mark[0].str;
- }
-break;
-case 184:
-#line 736 "util/configparser.y"
- {
- OUTYY(("P(server_harden_short_bufsize:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->harden_short_bufsize =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 185:
-#line 746 "util/configparser.y"
- {
- OUTYY(("P(server_harden_large_queries:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->harden_large_queries =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 186:
-#line 756 "util/configparser.y"
- {
- OUTYY(("P(server_harden_glue:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->harden_glue =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 187:
-#line 766 "util/configparser.y"
- {
- OUTYY(("P(server_harden_dnssec_stripped:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->harden_dnssec_stripped =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 188:
-#line 776 "util/configparser.y"
- {
- OUTYY(("P(server_harden_below_nxdomain:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->harden_below_nxdomain =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 189:
-#line 786 "util/configparser.y"
- {
- OUTYY(("P(server_harden_referral_path:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->harden_referral_path =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 190:
-#line 796 "util/configparser.y"
- {
- OUTYY(("P(server_use_caps_for_id:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->use_caps_bits_for_id =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 191:
-#line 806 "util/configparser.y"
- {
- OUTYY(("P(server_private_address:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->private_address, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 192:
-#line 813 "util/configparser.y"
- {
- OUTYY(("P(server_private_domain:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->private_domain, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 193:
-#line 820 "util/configparser.y"
- {
- OUTYY(("P(server_prefetch:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->prefetch = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 194:
-#line 829 "util/configparser.y"
- {
- OUTYY(("P(server_prefetch_key:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->prefetch_key = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 195:
-#line 838 "util/configparser.y"
- {
- OUTYY(("P(server_unwanted_reply_threshold:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->unwanted_threshold = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 196:
-#line 847 "util/configparser.y"
- {
- OUTYY(("P(server_do_not_query_address:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->donotqueryaddrs, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 197:
-#line 854 "util/configparser.y"
- {
- OUTYY(("P(server_do_not_query_localhost:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->donotquery_localhost =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 198:
-#line 864 "util/configparser.y"
- {
- OUTYY(("P(server_access_control:%s %s)\n", yystack.l_mark[-1].str, yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "deny")!=0 && strcmp(yystack.l_mark[0].str, "refuse")!=0 &&
- strcmp(yystack.l_mark[0].str, "allow")!=0 &&
- strcmp(yystack.l_mark[0].str, "allow_snoop")!=0) {
- yyerror("expected deny, refuse, allow or allow_snoop "
- "in access control action");
- } else {
- if(!cfg_str2list_insert(&cfg_parser->cfg->acls, yystack.l_mark[-1].str, yystack.l_mark[0].str))
- fatal_exit("out of memory adding acl");
- }
- }
-break;
-case 199:
-#line 878 "util/configparser.y"
- {
- OUTYY(("P(server_module_conf:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->module_conf);
- cfg_parser->cfg->module_conf = yystack.l_mark[0].str;
- }
-break;
-case 200:
-#line 885 "util/configparser.y"
- {
- OUTYY(("P(server_val_override_date:%s)\n", yystack.l_mark[0].str));
- if(strlen(yystack.l_mark[0].str) == 0 || strcmp(yystack.l_mark[0].str, "0") == 0) {
- cfg_parser->cfg->val_date_override = 0;
- } else if(strlen(yystack.l_mark[0].str) == 14) {
- cfg_parser->cfg->val_date_override =
- cfg_convert_timeval(yystack.l_mark[0].str);
- if(!cfg_parser->cfg->val_date_override)
- yyerror("bad date/time specification");
- } else {
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- cfg_parser->cfg->val_date_override = atoi(yystack.l_mark[0].str);
- }
- free(yystack.l_mark[0].str);
- }
-break;
-case 201:
-#line 903 "util/configparser.y"
- {
- OUTYY(("P(server_val_sig_skew_min:%s)\n", yystack.l_mark[0].str));
- if(strlen(yystack.l_mark[0].str) == 0 || strcmp(yystack.l_mark[0].str, "0") == 0) {
- cfg_parser->cfg->val_sig_skew_min = 0;
- } else {
- cfg_parser->cfg->val_sig_skew_min = atoi(yystack.l_mark[0].str);
- if(!cfg_parser->cfg->val_sig_skew_min)
- yyerror("number expected");
- }
- free(yystack.l_mark[0].str);
- }
-break;
-case 202:
-#line 916 "util/configparser.y"
- {
- OUTYY(("P(server_val_sig_skew_max:%s)\n", yystack.l_mark[0].str));
- if(strlen(yystack.l_mark[0].str) == 0 || strcmp(yystack.l_mark[0].str, "0") == 0) {
- cfg_parser->cfg->val_sig_skew_max = 0;
- } else {
- cfg_parser->cfg->val_sig_skew_max = atoi(yystack.l_mark[0].str);
- if(!cfg_parser->cfg->val_sig_skew_max)
- yyerror("number expected");
- }
- free(yystack.l_mark[0].str);
- }
-break;
-case 203:
-#line 929 "util/configparser.y"
- {
- OUTYY(("P(server_cache_max_ttl:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->max_ttl = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 204:
-#line 938 "util/configparser.y"
- {
- OUTYY(("P(server_cache_min_ttl:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->min_ttl = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 205:
-#line 947 "util/configparser.y"
- {
- OUTYY(("P(server_bogus_ttl:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->bogus_ttl = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 206:
-#line 956 "util/configparser.y"
- {
- OUTYY(("P(server_val_clean_additional:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->val_clean_additional =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 207:
-#line 966 "util/configparser.y"
- {
- OUTYY(("P(server_val_permissive_mode:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->val_permissive_mode =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 208:
-#line 976 "util/configparser.y"
- {
- OUTYY(("P(server_ignore_cd_flag:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->ignore_cd = (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 209:
-#line 985 "util/configparser.y"
- {
- OUTYY(("P(server_val_log_level:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->val_log_level = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 210:
-#line 994 "util/configparser.y"
- {
- OUTYY(("P(server_val_nsec3_keysize_iterations:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->val_nsec3_key_iterations);
- cfg_parser->cfg->val_nsec3_key_iterations = yystack.l_mark[0].str;
- }
-break;
-case 211:
-#line 1001 "util/configparser.y"
- {
- OUTYY(("P(server_add_holddown:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->add_holddown = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 212:
-#line 1010 "util/configparser.y"
- {
- OUTYY(("P(server_del_holddown:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->del_holddown = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 213:
-#line 1019 "util/configparser.y"
- {
- OUTYY(("P(server_keep_missing:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0 && strcmp(yystack.l_mark[0].str, "0") != 0)
- yyerror("number expected");
- else cfg_parser->cfg->keep_missing = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 214:
-#line 1028 "util/configparser.y"
- {
- OUTYY(("P(server_key_cache_size:%s)\n", yystack.l_mark[0].str));
- if(!cfg_parse_memsize(yystack.l_mark[0].str, &cfg_parser->cfg->key_cache_size))
- yyerror("memory size expected");
- free(yystack.l_mark[0].str);
- }
-break;
-case 215:
-#line 1036 "util/configparser.y"
- {
- OUTYY(("P(server_key_cache_slabs:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("number expected");
- else {
- cfg_parser->cfg->key_cache_slabs = atoi(yystack.l_mark[0].str);
- if(!is_pow2(cfg_parser->cfg->key_cache_slabs))
- yyerror("must be a power of 2");
- }
- free(yystack.l_mark[0].str);
- }
-break;
-case 216:
-#line 1049 "util/configparser.y"
- {
- OUTYY(("P(server_neg_cache_size:%s)\n", yystack.l_mark[0].str));
- if(!cfg_parse_memsize(yystack.l_mark[0].str, &cfg_parser->cfg->neg_cache_size))
- yyerror("memory size expected");
- free(yystack.l_mark[0].str);
- }
-break;
-case 217:
-#line 1057 "util/configparser.y"
- {
- OUTYY(("P(server_local_zone:%s %s)\n", yystack.l_mark[-1].str, yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "static")!=0 && strcmp(yystack.l_mark[0].str, "deny")!=0 &&
- strcmp(yystack.l_mark[0].str, "refuse")!=0 && strcmp(yystack.l_mark[0].str, "redirect")!=0 &&
- strcmp(yystack.l_mark[0].str, "transparent")!=0 && strcmp(yystack.l_mark[0].str, "nodefault")!=0
- && strcmp(yystack.l_mark[0].str, "typetransparent")!=0)
- yyerror("local-zone type: expected static, deny, "
- "refuse, redirect, transparent, "
- "typetransparent or nodefault");
- else if(strcmp(yystack.l_mark[0].str, "nodefault")==0) {
- if(!cfg_strlist_insert(&cfg_parser->cfg->
- local_zones_nodefault, yystack.l_mark[-1].str))
- fatal_exit("out of memory adding local-zone");
- free(yystack.l_mark[0].str);
- } else {
- if(!cfg_str2list_insert(&cfg_parser->cfg->local_zones,
- yystack.l_mark[-1].str, yystack.l_mark[0].str))
- fatal_exit("out of memory adding local-zone");
- }
- }
-break;
-case 218:
-#line 1079 "util/configparser.y"
- {
- OUTYY(("P(server_local_data:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->local_data, yystack.l_mark[0].str))
- fatal_exit("out of memory adding local-data");
- }
-break;
-case 219:
-#line 1086 "util/configparser.y"
- {
- char* ptr;
- OUTYY(("P(server_local_data_ptr:%s)\n", yystack.l_mark[0].str));
- ptr = cfg_ptr_reverse(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- if(ptr) {
- if(!cfg_strlist_insert(&cfg_parser->cfg->
- local_data, ptr))
- fatal_exit("out of memory adding local-data");
- } else {
- yyerror("local-data-ptr could not be reversed");
- }
- }
-break;
-case 220:
-#line 1101 "util/configparser.y"
- {
- OUTYY(("P(server_minimal_responses:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->minimal_responses =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 221:
-#line 1111 "util/configparser.y"
- {
- OUTYY(("P(server_rrset_roundrobin:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->rrset_roundrobin =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 222:
-#line 1121 "util/configparser.y"
- {
- OUTYY(("P(name:%s)\n", yystack.l_mark[0].str));
- if(cfg_parser->cfg->stubs->name)
- yyerror("stub name override, there must be one name "
- "for one stub-zone");
- free(cfg_parser->cfg->stubs->name);
- cfg_parser->cfg->stubs->name = yystack.l_mark[0].str;
- }
-break;
-case 223:
-#line 1131 "util/configparser.y"
- {
- OUTYY(("P(stub-host:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->hosts, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 224:
-#line 1138 "util/configparser.y"
- {
- OUTYY(("P(stub-addr:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->stubs->addrs, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 225:
-#line 1145 "util/configparser.y"
- {
- OUTYY(("P(stub-first:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->stubs->isfirst=(strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 226:
-#line 1154 "util/configparser.y"
- {
- OUTYY(("P(stub-prime:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->stubs->isprime =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 227:
-#line 1164 "util/configparser.y"
- {
- OUTYY(("P(name:%s)\n", yystack.l_mark[0].str));
- if(cfg_parser->cfg->forwards->name)
- yyerror("forward name override, there must be one "
- "name for one forward-zone");
- free(cfg_parser->cfg->forwards->name);
- cfg_parser->cfg->forwards->name = yystack.l_mark[0].str;
- }
-break;
-case 228:
-#line 1174 "util/configparser.y"
- {
- OUTYY(("P(forward-host:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->hosts, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 229:
-#line 1181 "util/configparser.y"
- {
- OUTYY(("P(forward-addr:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->forwards->addrs, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 230:
-#line 1188 "util/configparser.y"
- {
- OUTYY(("P(forward-first:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->forwards->isfirst=(strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 231:
-#line 1197 "util/configparser.y"
- {
- OUTYY(("\nP(remote-control:)\n"));
- }
-break;
-case 241:
-#line 1208 "util/configparser.y"
- {
- OUTYY(("P(control_enable:%s)\n", yystack.l_mark[0].str));
- if(strcmp(yystack.l_mark[0].str, "yes") != 0 && strcmp(yystack.l_mark[0].str, "no") != 0)
- yyerror("expected yes or no.");
- else cfg_parser->cfg->remote_control_enable =
- (strcmp(yystack.l_mark[0].str, "yes")==0);
- free(yystack.l_mark[0].str);
- }
-break;
-case 242:
-#line 1218 "util/configparser.y"
- {
- OUTYY(("P(control_port:%s)\n", yystack.l_mark[0].str));
- if(atoi(yystack.l_mark[0].str) == 0)
- yyerror("control port number expected");
- else cfg_parser->cfg->control_port = atoi(yystack.l_mark[0].str);
- free(yystack.l_mark[0].str);
- }
-break;
-case 243:
-#line 1227 "util/configparser.y"
- {
- OUTYY(("P(control_interface:%s)\n", yystack.l_mark[0].str));
- if(!cfg_strlist_insert(&cfg_parser->cfg->control_ifs, yystack.l_mark[0].str))
- yyerror("out of memory");
- }
-break;
-case 244:
-#line 1234 "util/configparser.y"
- {
- OUTYY(("P(rc_server_key_file:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->server_key_file);
- cfg_parser->cfg->server_key_file = yystack.l_mark[0].str;
- }
-break;
-case 245:
-#line 1241 "util/configparser.y"
- {
- OUTYY(("P(rc_server_cert_file:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->server_cert_file);
- cfg_parser->cfg->server_cert_file = yystack.l_mark[0].str;
- }
-break;
-case 246:
-#line 1248 "util/configparser.y"
- {
- OUTYY(("P(rc_control_key_file:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->control_key_file);
- cfg_parser->cfg->control_key_file = yystack.l_mark[0].str;
- }
-break;
-case 247:
-#line 1255 "util/configparser.y"
- {
- OUTYY(("P(rc_control_cert_file:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->control_cert_file);
- cfg_parser->cfg->control_cert_file = yystack.l_mark[0].str;
- }
-break;
-case 248:
-#line 1262 "util/configparser.y"
- {
- OUTYY(("\nP(python:)\n"));
- }
-break;
-case 252:
-#line 1271 "util/configparser.y"
- {
- OUTYY(("P(python-script:%s)\n", yystack.l_mark[0].str));
- free(cfg_parser->cfg->python_script);
- cfg_parser->cfg->python_script = yystack.l_mark[0].str;
- }
-break;
-#line 2269 "util/configparser.c"
- }
- yystack.s_mark -= yym;
- yystate = *yystack.s_mark;
- yystack.l_mark -= yym;
- yym = yylhs[yyn];
- if (yystate == 0 && yym == 0)
- {
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: after reduction, shifting from state 0 to\
- state %d\n", YYPREFIX, YYFINAL);
-#endif
- yystate = YYFINAL;
- *++yystack.s_mark = YYFINAL;
- *++yystack.l_mark = yyval;
- if (yychar < 0)
- {
- if ((yychar = YYLEX) < 0) yychar = 0;
-#if YYDEBUG
- if (yydebug)
- {
- yys = 0;
- if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
- if (!yys) yys = "illegal-symbol";
- printf("%sdebug: state %d, reading %d (%s)\n",
- YYPREFIX, YYFINAL, yychar, yys);
- }
-#endif
- }
- if (yychar == 0) goto yyaccept;
- goto yyloop;
- }
- if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
- yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
- yystate = yytable[yyn];
- else
- yystate = yydgoto[yym];
-#if YYDEBUG
- if (yydebug)
- printf("%sdebug: after reduction, shifting from state %d \
-to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
-#endif
- if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
- {
- goto yyoverflow;
- }
- *++yystack.s_mark = (short) yystate;
- *++yystack.l_mark = yyval;
- goto yyloop;
-
-yyoverflow:
- yyerror("yacc stack overflow");
-
-yyabort:
- yyfreestack(&yystack);
- return (1);
-
-yyaccept:
- yyfreestack(&yystack);
- return (0);
-}
diff --git a/contrib/unbound/util/configparser.h b/contrib/unbound/util/configparser.h
deleted file mode 100644
index 7bf4235..0000000
--- a/contrib/unbound/util/configparser.h
+++ /dev/null
@@ -1,138 +0,0 @@
-#define SPACE 257
-#define LETTER 258
-#define NEWLINE 259
-#define COMMENT 260
-#define COLON 261
-#define ANY 262
-#define ZONESTR 263
-#define STRING_ARG 264
-#define VAR_SERVER 265
-#define VAR_VERBOSITY 266
-#define VAR_NUM_THREADS 267
-#define VAR_PORT 268
-#define VAR_OUTGOING_RANGE 269
-#define VAR_INTERFACE 270
-#define VAR_DO_IP4 271
-#define VAR_DO_IP6 272
-#define VAR_DO_UDP 273
-#define VAR_DO_TCP 274
-#define VAR_CHROOT 275
-#define VAR_USERNAME 276
-#define VAR_DIRECTORY 277
-#define VAR_LOGFILE 278
-#define VAR_PIDFILE 279
-#define VAR_MSG_CACHE_SIZE 280
-#define VAR_MSG_CACHE_SLABS 281
-#define VAR_NUM_QUERIES_PER_THREAD 282
-#define VAR_RRSET_CACHE_SIZE 283
-#define VAR_RRSET_CACHE_SLABS 284
-#define VAR_OUTGOING_NUM_TCP 285
-#define VAR_INFRA_HOST_TTL 286
-#define VAR_INFRA_LAME_TTL 287
-#define VAR_INFRA_CACHE_SLABS 288
-#define VAR_INFRA_CACHE_NUMHOSTS 289
-#define VAR_INFRA_CACHE_LAME_SIZE 290
-#define VAR_NAME 291
-#define VAR_STUB_ZONE 292
-#define VAR_STUB_HOST 293
-#define VAR_STUB_ADDR 294
-#define VAR_TARGET_FETCH_POLICY 295
-#define VAR_HARDEN_SHORT_BUFSIZE 296
-#define VAR_HARDEN_LARGE_QUERIES 297
-#define VAR_FORWARD_ZONE 298
-#define VAR_FORWARD_HOST 299
-#define VAR_FORWARD_ADDR 300
-#define VAR_DO_NOT_QUERY_ADDRESS 301
-#define VAR_HIDE_IDENTITY 302
-#define VAR_HIDE_VERSION 303
-#define VAR_IDENTITY 304
-#define VAR_VERSION 305
-#define VAR_HARDEN_GLUE 306
-#define VAR_MODULE_CONF 307
-#define VAR_TRUST_ANCHOR_FILE 308
-#define VAR_TRUST_ANCHOR 309
-#define VAR_VAL_OVERRIDE_DATE 310
-#define VAR_BOGUS_TTL 311
-#define VAR_VAL_CLEAN_ADDITIONAL 312
-#define VAR_VAL_PERMISSIVE_MODE 313
-#define VAR_INCOMING_NUM_TCP 314
-#define VAR_MSG_BUFFER_SIZE 315
-#define VAR_KEY_CACHE_SIZE 316
-#define VAR_KEY_CACHE_SLABS 317
-#define VAR_TRUSTED_KEYS_FILE 318
-#define VAR_VAL_NSEC3_KEYSIZE_ITERATIONS 319
-#define VAR_USE_SYSLOG 320
-#define VAR_OUTGOING_INTERFACE 321
-#define VAR_ROOT_HINTS 322
-#define VAR_DO_NOT_QUERY_LOCALHOST 323
-#define VAR_CACHE_MAX_TTL 324
-#define VAR_HARDEN_DNSSEC_STRIPPED 325
-#define VAR_ACCESS_CONTROL 326
-#define VAR_LOCAL_ZONE 327
-#define VAR_LOCAL_DATA 328
-#define VAR_INTERFACE_AUTOMATIC 329
-#define VAR_STATISTICS_INTERVAL 330
-#define VAR_DO_DAEMONIZE 331
-#define VAR_USE_CAPS_FOR_ID 332
-#define VAR_STATISTICS_CUMULATIVE 333
-#define VAR_OUTGOING_PORT_PERMIT 334
-#define VAR_OUTGOING_PORT_AVOID 335
-#define VAR_DLV_ANCHOR_FILE 336
-#define VAR_DLV_ANCHOR 337
-#define VAR_NEG_CACHE_SIZE 338
-#define VAR_HARDEN_REFERRAL_PATH 339
-#define VAR_PRIVATE_ADDRESS 340
-#define VAR_PRIVATE_DOMAIN 341
-#define VAR_REMOTE_CONTROL 342
-#define VAR_CONTROL_ENABLE 343
-#define VAR_CONTROL_INTERFACE 344
-#define VAR_CONTROL_PORT 345
-#define VAR_SERVER_KEY_FILE 346
-#define VAR_SERVER_CERT_FILE 347
-#define VAR_CONTROL_KEY_FILE 348
-#define VAR_CONTROL_CERT_FILE 349
-#define VAR_EXTENDED_STATISTICS 350
-#define VAR_LOCAL_DATA_PTR 351
-#define VAR_JOSTLE_TIMEOUT 352
-#define VAR_STUB_PRIME 353
-#define VAR_UNWANTED_REPLY_THRESHOLD 354
-#define VAR_LOG_TIME_ASCII 355
-#define VAR_DOMAIN_INSECURE 356
-#define VAR_PYTHON 357
-#define VAR_PYTHON_SCRIPT 358
-#define VAR_VAL_SIG_SKEW_MIN 359
-#define VAR_VAL_SIG_SKEW_MAX 360
-#define VAR_CACHE_MIN_TTL 361
-#define VAR_VAL_LOG_LEVEL 362
-#define VAR_AUTO_TRUST_ANCHOR_FILE 363
-#define VAR_KEEP_MISSING 364
-#define VAR_ADD_HOLDDOWN 365
-#define VAR_DEL_HOLDDOWN 366
-#define VAR_SO_RCVBUF 367
-#define VAR_EDNS_BUFFER_SIZE 368
-#define VAR_PREFETCH 369
-#define VAR_PREFETCH_KEY 370
-#define VAR_SO_SNDBUF 371
-#define VAR_HARDEN_BELOW_NXDOMAIN 372
-#define VAR_IGNORE_CD_FLAG 373
-#define VAR_LOG_QUERIES 374
-#define VAR_TCP_UPSTREAM 375
-#define VAR_SSL_UPSTREAM 376
-#define VAR_SSL_SERVICE_KEY 377
-#define VAR_SSL_SERVICE_PEM 378
-#define VAR_SSL_PORT 379
-#define VAR_FORWARD_FIRST 380
-#define VAR_STUB_FIRST 381
-#define VAR_MINIMAL_RESPONSES 382
-#define VAR_RRSET_ROUNDROBIN 383
-#ifdef YYSTYPE
-#undef YYSTYPE_IS_DECLARED
-#define YYSTYPE_IS_DECLARED 1
-#endif
-#ifndef YYSTYPE_IS_DECLARED
-#define YYSTYPE_IS_DECLARED 1
-typedef union {
- char* str;
-} YYSTYPE;
-#endif /* !YYSTYPE_IS_DECLARED */
-extern YYSTYPE yylval;
diff --git a/contrib/unbound/util/configparser.y b/contrib/unbound/util/configparser.y
index 0dbee2b..f119507 100644
--- a/contrib/unbound/util/configparser.y
+++ b/contrib/unbound/util/configparser.y
@@ -23,16 +23,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
%{
@@ -44,7 +44,6 @@
#include <stdlib.h>
#include <assert.h>
-#include "util/configyyrename.h"
#include "util/config_file.h"
#include "util/net_help.h"
@@ -101,10 +100,11 @@ extern struct config_parser_state* cfg_parser;
%token VAR_VAL_SIG_SKEW_MAX VAR_CACHE_MIN_TTL VAR_VAL_LOG_LEVEL
%token VAR_AUTO_TRUST_ANCHOR_FILE VAR_KEEP_MISSING VAR_ADD_HOLDDOWN
%token VAR_DEL_HOLDDOWN VAR_SO_RCVBUF VAR_EDNS_BUFFER_SIZE VAR_PREFETCH
-%token VAR_PREFETCH_KEY VAR_SO_SNDBUF VAR_HARDEN_BELOW_NXDOMAIN
+%token VAR_PREFETCH_KEY VAR_SO_SNDBUF VAR_SO_REUSEPORT VAR_HARDEN_BELOW_NXDOMAIN
%token VAR_IGNORE_CD_FLAG VAR_LOG_QUERIES VAR_TCP_UPSTREAM VAR_SSL_UPSTREAM
%token VAR_SSL_SERVICE_KEY VAR_SSL_SERVICE_PEM VAR_SSL_PORT VAR_FORWARD_FIRST
%token VAR_STUB_FIRST VAR_MINIMAL_RESPONSES VAR_RRSET_ROUNDROBIN
+%token VAR_MAX_UDP_SIZE VAR_DELAY_CLOSE VAR_UNBLOCK_LAN_ZONES
%%
toplevelvars: /* empty */ | toplevelvars toplevelvar ;
@@ -161,7 +161,8 @@ content_server: server_num_threads | server_verbosity | server_port |
server_so_sndbuf | server_harden_below_nxdomain | server_ignore_cd_flag |
server_log_queries | server_tcp_upstream | server_ssl_upstream |
server_ssl_service_key | server_ssl_service_pem | server_ssl_port |
- server_minimal_responses | server_rrset_roundrobin
+ server_minimal_responses | server_rrset_roundrobin | server_max_udp_size |
+ server_so_reuseport | server_delay_close | server_unblock_lan_zones
;
stubstart: VAR_STUB_ZONE
{
@@ -594,6 +595,16 @@ server_so_sndbuf: VAR_SO_SNDBUF STRING_ARG
free($2);
}
;
+server_so_reuseport: VAR_SO_REUSEPORT STRING_ARG
+ {
+ OUTYY(("P(server_so_reuseport:%s)\n", $2));
+ if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
+ yyerror("expected yes or no.");
+ else cfg_parser->cfg->so_reuseport =
+ (strcmp($2, "yes")==0);
+ free($2);
+ }
+ ;
server_edns_buffer_size: VAR_EDNS_BUFFER_SIZE STRING_ARG
{
OUTYY(("P(server_edns_buffer_size:%s)\n", $2));
@@ -657,6 +668,25 @@ server_jostle_timeout: VAR_JOSTLE_TIMEOUT STRING_ARG
free($2);
}
;
+server_delay_close: VAR_DELAY_CLOSE STRING_ARG
+ {
+ OUTYY(("P(server_delay_close:%s)\n", $2));
+ if(atoi($2) == 0 && strcmp($2, "0") != 0)
+ yyerror("number expected");
+ else cfg_parser->cfg->delay_close = atoi($2);
+ free($2);
+ }
+ ;
+server_unblock_lan_zones: VAR_UNBLOCK_LAN_ZONES STRING_ARG
+ {
+ OUTYY(("P(server_unblock_lan_zones:%s)\n", $2));
+ if(strcmp($2, "yes") != 0 && strcmp($2, "no") != 0)
+ yyerror("expected yes or no.");
+ else cfg_parser->cfg->unblock_lan_zones =
+ (strcmp($2, "yes")==0);
+ free($2);
+ }
+ ;
server_rrset_cache_size: VAR_RRSET_CACHE_SIZE STRING_ARG
{
OUTYY(("P(server_rrset_cache_size:%s)\n", $2));
@@ -864,9 +894,12 @@ server_access_control: VAR_ACCESS_CONTROL STRING_ARG STRING_ARG
{
OUTYY(("P(server_access_control:%s %s)\n", $2, $3));
if(strcmp($3, "deny")!=0 && strcmp($3, "refuse")!=0 &&
+ strcmp($3, "deny_non_local")!=0 &&
+ strcmp($3, "refuse_non_local")!=0 &&
strcmp($3, "allow")!=0 &&
strcmp($3, "allow_snoop")!=0) {
- yyerror("expected deny, refuse, allow or allow_snoop "
+ yyerror("expected deny, refuse, deny_non_local, "
+ "refuse_non_local, allow or allow_snoop "
"in access control action");
} else {
if(!cfg_str2list_insert(&cfg_parser->cfg->acls, $2, $3))
@@ -1117,6 +1150,13 @@ server_rrset_roundrobin: VAR_RRSET_ROUNDROBIN STRING_ARG
free($2);
}
;
+server_max_udp_size: VAR_MAX_UDP_SIZE STRING_ARG
+ {
+ OUTYY(("P(server_max_udp_size:%s)\n", $2));
+ cfg_parser->cfg->max_udp_size = atoi($2);
+ free($2);
+ }
+ ;
stub_name: VAR_NAME STRING_ARG
{
OUTYY(("P(name:%s)\n", $2));
diff --git a/contrib/unbound/util/data/dname.c b/contrib/unbound/util/data/dname.c
index d2b2997..76f2e64 100644
--- a/contrib/unbound/util/data/dname.c
+++ b/contrib/unbound/util/data/dname.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -45,17 +45,18 @@
#include "util/data/msgparse.h"
#include "util/log.h"
#include "util/storage/lookup3.h"
+#include "ldns/sbuffer.h"
/* determine length of a dname in buffer, no compression pointers allowed */
size_t
-query_dname_len(ldns_buffer* query)
+query_dname_len(sldns_buffer* query)
{
size_t len = 0;
size_t labellen;
while(1) {
- if(ldns_buffer_remaining(query) < 1)
+ if(sldns_buffer_remaining(query) < 1)
return 0; /* parse error, need label len */
- labellen = ldns_buffer_read_u8(query);
+ labellen = sldns_buffer_read_u8(query);
if(labellen&0xc0)
return 0; /* no compression allowed in queries */
len += labellen + 1;
@@ -63,9 +64,9 @@ query_dname_len(ldns_buffer* query)
return 0; /* too long */
if(labellen == 0)
return len;
- if(ldns_buffer_remaining(query) < labellen)
+ if(sldns_buffer_remaining(query) < labellen)
return 0; /* parse error, need content */
- ldns_buffer_skip(query, (ssize_t)labellen);
+ sldns_buffer_skip(query, (ssize_t)labellen);
}
}
@@ -145,31 +146,31 @@ query_dname_tolower(uint8_t* dname)
}
void
-pkt_dname_tolower(ldns_buffer* pkt, uint8_t* dname)
+pkt_dname_tolower(sldns_buffer* pkt, uint8_t* dname)
{
uint8_t lablen;
int count = 0;
- if(dname >= ldns_buffer_end(pkt))
+ if(dname >= sldns_buffer_end(pkt))
return;
lablen = *dname++;
while(lablen) {
if(LABEL_IS_PTR(lablen)) {
if((size_t)PTR_OFFSET(lablen, *dname)
- >= ldns_buffer_limit(pkt))
+ >= sldns_buffer_limit(pkt))
return;
- dname = ldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
+ dname = sldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
lablen = *dname++;
if(count++ > MAX_COMPRESS_PTRS)
return;
continue;
}
- if(dname+lablen >= ldns_buffer_end(pkt))
+ if(dname+lablen >= sldns_buffer_end(pkt))
return;
while(lablen--) {
*dname = (uint8_t)tolower((int)*dname);
dname++;
}
- if(dname >= ldns_buffer_end(pkt))
+ if(dname >= sldns_buffer_end(pkt))
return;
lablen = *dname++;
}
@@ -177,7 +178,7 @@ pkt_dname_tolower(ldns_buffer* pkt, uint8_t* dname)
size_t
-pkt_dname_len(ldns_buffer* pkt)
+pkt_dname_len(sldns_buffer* pkt)
{
size_t len = 0;
int ptrcount = 0;
@@ -188,22 +189,22 @@ pkt_dname_len(ldns_buffer* pkt)
/* check compression pointers, loops, out of bounds */
while(1) {
/* read next label */
- if(ldns_buffer_remaining(pkt) < 1)
+ if(sldns_buffer_remaining(pkt) < 1)
return 0;
- labellen = ldns_buffer_read_u8(pkt);
+ labellen = sldns_buffer_read_u8(pkt);
if(LABEL_IS_PTR(labellen)) {
/* compression ptr */
uint16_t ptr;
- if(ldns_buffer_remaining(pkt) < 1)
+ if(sldns_buffer_remaining(pkt) < 1)
return 0;
- ptr = PTR_OFFSET(labellen, ldns_buffer_read_u8(pkt));
+ ptr = PTR_OFFSET(labellen, sldns_buffer_read_u8(pkt));
if(ptrcount++ > MAX_COMPRESS_PTRS)
return 0; /* loop! */
- if(ldns_buffer_limit(pkt) <= ptr)
+ if(sldns_buffer_limit(pkt) <= ptr)
return 0; /* out of bounds! */
if(!endpos)
- endpos = ldns_buffer_position(pkt);
- ldns_buffer_set_position(pkt, ptr);
+ endpos = sldns_buffer_position(pkt);
+ sldns_buffer_set_position(pkt, ptr);
} else {
/* label contents */
if(labellen > 0x3f)
@@ -215,19 +216,19 @@ pkt_dname_len(ldns_buffer* pkt)
/* end of dname */
break;
}
- if(ldns_buffer_remaining(pkt) < labellen)
+ if(sldns_buffer_remaining(pkt) < labellen)
return 0;
- ldns_buffer_skip(pkt, (ssize_t)labellen);
+ sldns_buffer_skip(pkt, (ssize_t)labellen);
}
}
if(endpos)
- ldns_buffer_set_position(pkt, endpos);
+ sldns_buffer_set_position(pkt, endpos);
return len;
}
int
-dname_pkt_compare(ldns_buffer* pkt, uint8_t* d1, uint8_t* d2)
+dname_pkt_compare(sldns_buffer* pkt, uint8_t* d1, uint8_t* d2)
{
uint8_t len1, len2;
log_assert(pkt && d1 && d2);
@@ -236,12 +237,12 @@ dname_pkt_compare(ldns_buffer* pkt, uint8_t* d1, uint8_t* d2)
while( len1 != 0 || len2 != 0 ) {
/* resolve ptrs */
if(LABEL_IS_PTR(len1)) {
- d1 = ldns_buffer_at(pkt, PTR_OFFSET(len1, *d1));
+ d1 = sldns_buffer_at(pkt, PTR_OFFSET(len1, *d1));
len1 = *d1++;
continue;
}
if(LABEL_IS_PTR(len2)) {
- d2 = ldns_buffer_at(pkt, PTR_OFFSET(len2, *d2));
+ d2 = sldns_buffer_at(pkt, PTR_OFFSET(len2, *d2));
len2 = *d2++;
continue;
}
@@ -290,7 +291,7 @@ dname_query_hash(uint8_t* dname, hashvalue_t h)
}
hashvalue_t
-dname_pkt_hash(ldns_buffer* pkt, uint8_t* dname, hashvalue_t h)
+dname_pkt_hash(sldns_buffer* pkt, uint8_t* dname, hashvalue_t h)
{
uint8_t labuf[LDNS_MAX_LABELLEN+1];
uint8_t lablen;
@@ -301,7 +302,7 @@ dname_pkt_hash(ldns_buffer* pkt, uint8_t* dname, hashvalue_t h)
while(lablen) {
if(LABEL_IS_PTR(lablen)) {
/* follow pointer */
- dname = ldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
+ dname = sldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
lablen = *dname++;
continue;
}
@@ -317,7 +318,7 @@ dname_pkt_hash(ldns_buffer* pkt, uint8_t* dname, hashvalue_t h)
return h;
}
-void dname_pkt_copy(ldns_buffer* pkt, uint8_t* to, uint8_t* dname)
+void dname_pkt_copy(sldns_buffer* pkt, uint8_t* to, uint8_t* dname)
{
/* copy over the dname and decompress it at the same time */
size_t len = 0;
@@ -326,7 +327,7 @@ void dname_pkt_copy(ldns_buffer* pkt, uint8_t* to, uint8_t* dname)
while(lablen) {
if(LABEL_IS_PTR(lablen)) {
/* follow pointer */
- dname = ldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
+ dname = sldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
lablen = *dname++;
continue;
}
@@ -347,7 +348,7 @@ void dname_pkt_copy(ldns_buffer* pkt, uint8_t* to, uint8_t* dname)
*to = 0;
}
-void dname_print(FILE* out, ldns_buffer* pkt, uint8_t* dname)
+void dname_print(FILE* out, struct sldns_buffer* pkt, uint8_t* dname)
{
uint8_t lablen;
if(!out) out = stdout;
@@ -363,7 +364,7 @@ void dname_print(FILE* out, ldns_buffer* pkt, uint8_t* dname)
fputs("??compressionptr??", out);
return;
}
- dname = ldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
+ dname = sldns_buffer_at(pkt, PTR_OFFSET(lablen, *dname));
lablen = *dname++;
continue;
}
@@ -517,21 +518,21 @@ dname_lab_cmp(uint8_t* d1, int labs1, uint8_t* d2, int labs2, int* mlabs)
}
int
-dname_buffer_write(ldns_buffer* pkt, uint8_t* dname)
+dname_buffer_write(sldns_buffer* pkt, uint8_t* dname)
{
uint8_t lablen;
- if(ldns_buffer_remaining(pkt) < 1)
+ if(sldns_buffer_remaining(pkt) < 1)
return 0;
lablen = *dname++;
- ldns_buffer_write_u8(pkt, lablen);
+ sldns_buffer_write_u8(pkt, lablen);
while(lablen) {
- if(ldns_buffer_remaining(pkt) < (size_t)lablen+1)
+ if(sldns_buffer_remaining(pkt) < (size_t)lablen+1)
return 0;
- ldns_buffer_write(pkt, dname, lablen);
+ sldns_buffer_write(pkt, dname, lablen);
dname += lablen;
lablen = *dname++;
- ldns_buffer_write_u8(pkt, lablen);
+ sldns_buffer_write_u8(pkt, lablen);
}
return 1;
}
diff --git a/contrib/unbound/util/data/dname.h b/contrib/unbound/util/data/dname.h
index b942848..ae2fbad 100644
--- a/contrib/unbound/util/data/dname.h
+++ b/contrib/unbound/util/data/dname.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -45,6 +45,7 @@
#ifndef UTIL_DATA_DNAME_H
#define UTIL_DATA_DNAME_H
#include "util/storage/lruhash.h"
+struct sldns_buffer;
/** max number of compression ptrs to follow */
#define MAX_COMPRESS_PTRS 256
@@ -55,7 +56,7 @@
* at end, position is at end of the dname.
* @return: 0 on parse failure, or length including ending 0 of dname.
*/
-size_t query_dname_len(ldns_buffer* query);
+size_t query_dname_len(struct sldns_buffer* query);
/**
* Determine if dname in memory is correct. no compression ptrs allowed.
@@ -74,7 +75,7 @@ void query_dname_tolower(uint8_t* dname);
* is unchanged.
* @param dname: start of dname in packet.
*/
-void pkt_dname_tolower(ldns_buffer* pkt, uint8_t* dname);
+void pkt_dname_tolower(struct sldns_buffer* pkt, uint8_t* dname);
/**
* Compare query dnames (uncompressed storage). The Dnames passed do not
@@ -106,7 +107,7 @@ int query_dname_compare(uint8_t* d1, uint8_t* d2);
* Compression pointers are followed and checked for loops.
* The uncompressed wireformat length is returned.
*/
-size_t pkt_dname_len(ldns_buffer* pkt);
+size_t pkt_dname_len(struct sldns_buffer* pkt);
/**
* Compare dnames in packet (compressed). Dnames must be valid.
@@ -117,7 +118,7 @@ size_t pkt_dname_len(ldns_buffer* pkt);
* @return: -1, 0, or +1 depending on comparison results.
* Sort order is first difference found. not the canonical ordering.
*/
-int dname_pkt_compare(ldns_buffer* pkt, uint8_t* d1, uint8_t* d2);
+int dname_pkt_compare(struct sldns_buffer* pkt, uint8_t* d1, uint8_t* d2);
/**
* Hash dname, label by label, lowercasing, into hashvalue.
@@ -138,7 +139,7 @@ hashvalue_t dname_query_hash(uint8_t* dname, hashvalue_t h);
* @return: result hash value.
* Result is the same as dname_query_hash, even if compression is used.
*/
-hashvalue_t dname_pkt_hash(ldns_buffer* pkt, uint8_t* dname, hashvalue_t h);
+hashvalue_t dname_pkt_hash(struct sldns_buffer* pkt, uint8_t* dname, hashvalue_t h);
/**
* Copy over a valid dname and decompress it.
@@ -146,7 +147,7 @@ hashvalue_t dname_pkt_hash(ldns_buffer* pkt, uint8_t* dname, hashvalue_t h);
* @param to: buffer of size from pkt_len function to hold result.
* @param dname: pointer into packet where dname starts.
*/
-void dname_pkt_copy(ldns_buffer* pkt, uint8_t* to, uint8_t* dname);
+void dname_pkt_copy(struct sldns_buffer* pkt, uint8_t* to, uint8_t* dname);
/**
* Copy over a valid dname to a packet.
@@ -154,7 +155,7 @@ void dname_pkt_copy(ldns_buffer* pkt, uint8_t* to, uint8_t* dname);
* @param dname: dname to copy.
* @return: 0 if not enough space in buffer.
*/
-int dname_buffer_write(ldns_buffer* pkt, uint8_t* dname);
+int dname_buffer_write(struct sldns_buffer* pkt, uint8_t* dname);
/**
* Count the number of labels in an uncompressed dname in memory.
@@ -216,7 +217,7 @@ int dname_subdomain_c(uint8_t* d1, uint8_t* d2);
* @param pkt: if not NULL, the packet for resolving compression ptrs.
* @param dname: pointer to (start of) dname.
*/
-void dname_print(FILE* out, ldns_buffer* pkt, uint8_t* dname);
+void dname_print(FILE* out, struct sldns_buffer* pkt, uint8_t* dname);
/**
* Debug helper. Print dname to given string buffer (string buffer must
diff --git a/contrib/unbound/util/data/msgencode.c b/contrib/unbound/util/data/msgencode.c
index 157796d..26b5dea 100644
--- a/contrib/unbound/util/data/msgencode.c
+++ b/contrib/unbound/util/data/msgencode.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,7 +40,6 @@
*/
#include "config.h"
-#include <ldns/wire2host.h>
#include "util/data/msgencode.h"
#include "util/data/msgreply.h"
#include "util/data/msgparse.h"
@@ -48,6 +47,7 @@
#include "util/log.h"
#include "util/regional.h"
#include "util/net_help.h"
+#include "ldns/sbuffer.h"
/** return code that means the function ran out of memory. negative so it does
* not conflict with DNS rcodes. */
@@ -243,7 +243,7 @@ compress_tree_store(uint8_t* dname, int labs, size_t offset,
/** compress a domain name */
static int
-write_compressed_dname(ldns_buffer* pkt, uint8_t* dname, int labs,
+write_compressed_dname(sldns_buffer* pkt, uint8_t* dname, int labs,
struct compress_tree_node* p)
{
/* compress it */
@@ -253,32 +253,32 @@ write_compressed_dname(ldns_buffer* pkt, uint8_t* dname, int labs,
if(labs == 1) {
/* write root label */
- if(ldns_buffer_remaining(pkt) < 1)
+ if(sldns_buffer_remaining(pkt) < 1)
return 0;
- ldns_buffer_write_u8(pkt, 0);
+ sldns_buffer_write_u8(pkt, 0);
return 1;
}
/* copy the first couple of labels */
while(labcopy--) {
lablen = *dname++;
- if(ldns_buffer_remaining(pkt) < (size_t)lablen+1)
+ if(sldns_buffer_remaining(pkt) < (size_t)lablen+1)
return 0;
- ldns_buffer_write_u8(pkt, lablen);
- ldns_buffer_write(pkt, dname, lablen);
+ sldns_buffer_write_u8(pkt, lablen);
+ sldns_buffer_write(pkt, dname, lablen);
dname += lablen;
}
/* insert compression ptr */
- if(ldns_buffer_remaining(pkt) < 2)
+ if(sldns_buffer_remaining(pkt) < 2)
return 0;
ptr = PTR_CREATE(p->offset);
- ldns_buffer_write_u16(pkt, ptr);
+ sldns_buffer_write_u16(pkt, ptr);
return 1;
}
/** compress owner name of RR, return RETVAL_OUTMEM RETVAL_TRUNC */
static int
-compress_owner(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
+compress_owner(struct ub_packed_rrset_key* key, sldns_buffer* pkt,
struct regional* region, struct compress_tree_node** tree,
size_t owner_pos, uint16_t* owner_ptr, int owner_labs)
{
@@ -296,13 +296,13 @@ compress_owner(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
owner_labs, p))
return RETVAL_TRUNC;
/* check if typeclass+4 ttl + rdatalen is available */
- if(ldns_buffer_remaining(pkt) < 4+4+2)
+ if(sldns_buffer_remaining(pkt) < 4+4+2)
return RETVAL_TRUNC;
} else {
/* no compress */
- if(ldns_buffer_remaining(pkt) < key->rk.dname_len+4+4+2)
+ if(sldns_buffer_remaining(pkt) < key->rk.dname_len+4+4+2)
return RETVAL_TRUNC;
- ldns_buffer_write(pkt, key->rk.dname,
+ sldns_buffer_write(pkt, key->rk.dname,
key->rk.dname_len);
if(owner_pos <= PTR_MAX_OFFSET)
*owner_ptr = htons(PTR_CREATE(owner_pos));
@@ -313,13 +313,13 @@ compress_owner(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
} else {
/* always compress 2nd-further RRs in RRset */
if(owner_labs == 1) {
- if(ldns_buffer_remaining(pkt) < 1+4+4+2)
+ if(sldns_buffer_remaining(pkt) < 1+4+4+2)
return RETVAL_TRUNC;
- ldns_buffer_write_u8(pkt, 0);
+ sldns_buffer_write_u8(pkt, 0);
} else {
- if(ldns_buffer_remaining(pkt) < 2+4+4+2)
+ if(sldns_buffer_remaining(pkt) < 2+4+4+2)
return RETVAL_TRUNC;
- ldns_buffer_write(pkt, owner_ptr, 2);
+ sldns_buffer_write(pkt, owner_ptr, 2);
}
}
return RETVAL_OK;
@@ -327,12 +327,12 @@ compress_owner(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
/** compress any domain name to the packet, return RETVAL_* */
static int
-compress_any_dname(uint8_t* dname, ldns_buffer* pkt, int labs,
+compress_any_dname(uint8_t* dname, sldns_buffer* pkt, int labs,
struct regional* region, struct compress_tree_node** tree)
{
struct compress_tree_node* p;
struct compress_tree_node** insertpt = NULL;
- size_t pos = ldns_buffer_position(pkt);
+ size_t pos = sldns_buffer_position(pkt);
if((p = compress_tree_lookup(tree, dname, labs, &insertpt))) {
if(!write_compressed_dname(pkt, dname, labs, p))
return RETVAL_TRUNC;
@@ -346,27 +346,27 @@ compress_any_dname(uint8_t* dname, ldns_buffer* pkt, int labs,
}
/** return true if type needs domain name compression in rdata */
-static const ldns_rr_descriptor*
+static const sldns_rr_descriptor*
type_rdata_compressable(struct ub_packed_rrset_key* key)
{
uint16_t t = ntohs(key->rk.type);
- if(ldns_rr_descript(t) &&
- ldns_rr_descript(t)->_compress == LDNS_RR_COMPRESS)
- return ldns_rr_descript(t);
+ if(sldns_rr_descript(t) &&
+ sldns_rr_descript(t)->_compress == LDNS_RR_COMPRESS)
+ return sldns_rr_descript(t);
return 0;
}
/** compress domain names in rdata, return RETVAL_* */
static int
-compress_rdata(ldns_buffer* pkt, uint8_t* rdata, size_t todolen,
+compress_rdata(sldns_buffer* pkt, uint8_t* rdata, size_t todolen,
struct regional* region, struct compress_tree_node** tree,
- const ldns_rr_descriptor* desc)
+ const sldns_rr_descriptor* desc)
{
int labs, r, rdf = 0;
- size_t dname_len, len, pos = ldns_buffer_position(pkt);
+ size_t dname_len, len, pos = sldns_buffer_position(pkt);
uint8_t count = desc->_dname_count;
- ldns_buffer_skip(pkt, 2); /* rdata len fill in later */
+ sldns_buffer_skip(pkt, 2); /* rdata len fill in later */
/* space for rdatalen checked for already */
rdata += 2;
todolen -= 2;
@@ -390,9 +390,9 @@ compress_rdata(ldns_buffer* pkt, uint8_t* rdata, size_t todolen,
}
if(len) {
/* copy over */
- if(ldns_buffer_remaining(pkt) < len)
+ if(sldns_buffer_remaining(pkt) < len)
return RETVAL_TRUNC;
- ldns_buffer_write(pkt, rdata, len);
+ sldns_buffer_write(pkt, rdata, len);
todolen -= len;
rdata += len;
}
@@ -400,19 +400,19 @@ compress_rdata(ldns_buffer* pkt, uint8_t* rdata, size_t todolen,
}
/* copy remainder */
if(todolen > 0) {
- if(ldns_buffer_remaining(pkt) < todolen)
+ if(sldns_buffer_remaining(pkt) < todolen)
return RETVAL_TRUNC;
- ldns_buffer_write(pkt, rdata, todolen);
+ sldns_buffer_write(pkt, rdata, todolen);
}
/* set rdata len */
- ldns_buffer_write_u16_at(pkt, pos, ldns_buffer_position(pkt)-pos-2);
+ sldns_buffer_write_u16_at(pkt, pos, sldns_buffer_position(pkt)-pos-2);
return RETVAL_OK;
}
/** Returns true if RR type should be included */
static int
-rrset_belongs_in_reply(ldns_pkt_section s, uint16_t rrtype, uint16_t qtype,
+rrset_belongs_in_reply(sldns_pkt_section s, uint16_t rrtype, uint16_t qtype,
int dnssec)
{
if(dnssec)
@@ -440,10 +440,10 @@ rrset_belongs_in_reply(ldns_pkt_section s, uint16_t rrtype, uint16_t qtype,
/** store rrset in buffer in wireformat, return RETVAL_* */
static int
-packed_rrset_encode(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
- uint16_t* num_rrs, uint32_t timenow, struct regional* region,
+packed_rrset_encode(struct ub_packed_rrset_key* key, sldns_buffer* pkt,
+ uint16_t* num_rrs, time_t timenow, struct regional* region,
int do_data, int do_sig, struct compress_tree_node** tree,
- ldns_pkt_section s, uint16_t qtype, int dnssec, size_t rr_offset)
+ sldns_pkt_section s, uint16_t qtype, int dnssec, size_t rr_offset)
{
size_t i, j, owner_pos;
int r, owner_labs;
@@ -456,10 +456,10 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
return RETVAL_OK;
owner_labs = dname_count_labels(key->rk.dname);
- owner_pos = ldns_buffer_position(pkt);
+ owner_pos = sldns_buffer_position(pkt);
if(do_data) {
- const ldns_rr_descriptor* c = type_rdata_compressable(key);
+ const sldns_rr_descriptor* c = type_rdata_compressable(key);
for(i=0; i<data->count; i++) {
/* rrset roundrobin */
j = (i + rr_offset) % data->count;
@@ -467,11 +467,11 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
owner_pos, &owner_ptr, owner_labs))
!= RETVAL_OK)
return r;
- ldns_buffer_write(pkt, &key->rk.type, 2);
- ldns_buffer_write(pkt, &key->rk.rrset_class, 2);
+ sldns_buffer_write(pkt, &key->rk.type, 2);
+ sldns_buffer_write(pkt, &key->rk.rrset_class, 2);
if(data->rr_ttl[j] < timenow)
- ldns_buffer_write_u32(pkt, 0);
- else ldns_buffer_write_u32(pkt,
+ sldns_buffer_write_u32(pkt, 0);
+ else sldns_buffer_write_u32(pkt,
data->rr_ttl[j]-timenow);
if(c) {
if((r=compress_rdata(pkt, data->rr_data[j],
@@ -479,9 +479,9 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
!= RETVAL_OK)
return r;
} else {
- if(ldns_buffer_remaining(pkt) < data->rr_len[j])
+ if(sldns_buffer_remaining(pkt) < data->rr_len[j])
return RETVAL_TRUNC;
- ldns_buffer_write(pkt, data->rr_data[j],
+ sldns_buffer_write(pkt, data->rr_data[j],
data->rr_len[j]);
}
}
@@ -491,28 +491,28 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
size_t total = data->count+data->rrsig_count;
for(i=data->count; i<total; i++) {
if(owner_ptr && owner_labs != 1) {
- if(ldns_buffer_remaining(pkt) <
+ if(sldns_buffer_remaining(pkt) <
2+4+4+data->rr_len[i])
return RETVAL_TRUNC;
- ldns_buffer_write(pkt, &owner_ptr, 2);
+ sldns_buffer_write(pkt, &owner_ptr, 2);
} else {
if((r=compress_any_dname(key->rk.dname,
pkt, owner_labs, region, tree))
!= RETVAL_OK)
return r;
- if(ldns_buffer_remaining(pkt) <
+ if(sldns_buffer_remaining(pkt) <
4+4+data->rr_len[i])
return RETVAL_TRUNC;
}
- ldns_buffer_write_u16(pkt, LDNS_RR_TYPE_RRSIG);
- ldns_buffer_write(pkt, &key->rk.rrset_class, 2);
+ sldns_buffer_write_u16(pkt, LDNS_RR_TYPE_RRSIG);
+ sldns_buffer_write(pkt, &key->rk.rrset_class, 2);
if(data->rr_ttl[i] < timenow)
- ldns_buffer_write_u32(pkt, 0);
- else ldns_buffer_write_u32(pkt,
+ sldns_buffer_write_u32(pkt, 0);
+ else sldns_buffer_write_u32(pkt,
data->rr_ttl[i]-timenow);
/* rrsig rdata cannot be compressed, perform 100+ byte
* memcopy. */
- ldns_buffer_write(pkt, data->rr_data[i],
+ sldns_buffer_write(pkt, data->rr_data[i],
data->rr_len[i]);
}
}
@@ -528,9 +528,9 @@ packed_rrset_encode(struct ub_packed_rrset_key* key, ldns_buffer* pkt,
/** store msg section in wireformat buffer, return RETVAL_* */
static int
insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs,
- ldns_buffer* pkt, size_t rrsets_before, uint32_t timenow,
+ sldns_buffer* pkt, size_t rrsets_before, time_t timenow,
struct regional* region, struct compress_tree_node** tree,
- ldns_pkt_section s, uint16_t qtype, int dnssec, size_t rr_offset)
+ sldns_pkt_section s, uint16_t qtype, int dnssec, size_t rr_offset)
{
int r;
size_t i, setstart;
@@ -539,36 +539,36 @@ insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs,
if(s == LDNS_SECTION_ANSWER && qtype == LDNS_RR_TYPE_ANY)
dnssec = 1; /* include all types in ANY answer */
for(i=0; i<num_rrsets; i++) {
- setstart = ldns_buffer_position(pkt);
+ setstart = sldns_buffer_position(pkt);
if((r=packed_rrset_encode(rep->rrsets[rrsets_before+i],
pkt, num_rrs, timenow, region, 1, 1, tree,
s, qtype, dnssec, rr_offset))
!= RETVAL_OK) {
/* Bad, but if due to size must set TC bit */
/* trim off the rrset neatly. */
- ldns_buffer_set_position(pkt, setstart);
+ sldns_buffer_set_position(pkt, setstart);
return r;
}
}
} else {
for(i=0; i<num_rrsets; i++) {
- setstart = ldns_buffer_position(pkt);
+ setstart = sldns_buffer_position(pkt);
if((r=packed_rrset_encode(rep->rrsets[rrsets_before+i],
pkt, num_rrs, timenow, region, 1, 0, tree,
s, qtype, dnssec, rr_offset))
!= RETVAL_OK) {
- ldns_buffer_set_position(pkt, setstart);
+ sldns_buffer_set_position(pkt, setstart);
return r;
}
}
if(dnssec)
for(i=0; i<num_rrsets; i++) {
- setstart = ldns_buffer_position(pkt);
+ setstart = sldns_buffer_position(pkt);
if((r=packed_rrset_encode(rep->rrsets[rrsets_before+i],
pkt, num_rrs, timenow, region, 0, 1, tree,
s, qtype, dnssec, rr_offset))
!= RETVAL_OK) {
- ldns_buffer_set_position(pkt, setstart);
+ sldns_buffer_set_position(pkt, setstart);
return r;
}
}
@@ -579,21 +579,21 @@ insert_section(struct reply_info* rep, size_t num_rrsets, uint16_t* num_rrs,
/** store query section in wireformat buffer, return RETVAL */
static int
insert_query(struct query_info* qinfo, struct compress_tree_node** tree,
- ldns_buffer* buffer, struct regional* region)
+ sldns_buffer* buffer, struct regional* region)
{
- if(ldns_buffer_remaining(buffer) <
+ if(sldns_buffer_remaining(buffer) <
qinfo->qname_len+sizeof(uint16_t)*2)
return RETVAL_TRUNC; /* buffer too small */
/* the query is the first name inserted into the tree */
if(!compress_tree_store(qinfo->qname,
dname_count_labels(qinfo->qname),
- ldns_buffer_position(buffer), region, NULL, tree))
+ sldns_buffer_position(buffer), region, NULL, tree))
return RETVAL_OUTMEM;
- if(ldns_buffer_current(buffer) == qinfo->qname)
- ldns_buffer_skip(buffer, (ssize_t)qinfo->qname_len);
- else ldns_buffer_write(buffer, qinfo->qname, qinfo->qname_len);
- ldns_buffer_write_u16(buffer, qinfo->qtype);
- ldns_buffer_write_u16(buffer, qinfo->qclass);
+ if(sldns_buffer_current(buffer) == qinfo->qname)
+ sldns_buffer_skip(buffer, (ssize_t)qinfo->qname_len);
+ else sldns_buffer_write(buffer, qinfo->qname, qinfo->qname_len);
+ sldns_buffer_write_u16(buffer, qinfo->qtype);
+ sldns_buffer_write_u16(buffer, qinfo->qclass);
return RETVAL_OK;
}
@@ -624,7 +624,7 @@ positive_answer(struct reply_info* rep, uint16_t qtype) {
int
reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
- uint16_t id, uint16_t flags, ldns_buffer* buffer, uint32_t timenow,
+ uint16_t id, uint16_t flags, sldns_buffer* buffer, time_t timenow,
struct regional* region, uint16_t udpsize, int dnssec)
{
uint16_t ancount=0, nscount=0, arcount=0;
@@ -632,17 +632,17 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
int r;
size_t rr_offset;
- ldns_buffer_clear(buffer);
- if(udpsize < ldns_buffer_limit(buffer))
- ldns_buffer_set_limit(buffer, udpsize);
- if(ldns_buffer_remaining(buffer) < LDNS_HEADER_SIZE)
+ sldns_buffer_clear(buffer);
+ if(udpsize < sldns_buffer_limit(buffer))
+ sldns_buffer_set_limit(buffer, udpsize);
+ if(sldns_buffer_remaining(buffer) < LDNS_HEADER_SIZE)
return 0;
- ldns_buffer_write(buffer, &id, sizeof(uint16_t));
- ldns_buffer_write_u16(buffer, flags);
- ldns_buffer_write_u16(buffer, rep->qdcount);
+ sldns_buffer_write(buffer, &id, sizeof(uint16_t));
+ sldns_buffer_write_u16(buffer, flags);
+ sldns_buffer_write_u16(buffer, rep->qdcount);
/* set an, ns, ar counts to zero in case of small packets */
- ldns_buffer_write(buffer, "\000\000\000\000\000\000", 6);
+ sldns_buffer_write(buffer, "\000\000\000\000\000\000", 6);
/* insert query section */
if(rep->qdcount) {
@@ -650,16 +650,17 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
RETVAL_OK) {
if(r == RETVAL_TRUNC) {
/* create truncated message */
- ldns_buffer_write_u16_at(buffer, 4, 0);
- LDNS_TC_SET(ldns_buffer_begin(buffer));
- ldns_buffer_flip(buffer);
+ sldns_buffer_write_u16_at(buffer, 4, 0);
+ LDNS_TC_SET(sldns_buffer_begin(buffer));
+ sldns_buffer_flip(buffer);
return 1;
}
return 0;
}
}
- /* roundrobin offset. using query id for random number */
- rr_offset = RRSET_ROUNDROBIN?id:0;
+ /* roundrobin offset. using query id for random number. With ntohs
+ * for different roundrobins for sequential id client senders. */
+ rr_offset = RRSET_ROUNDROBIN?ntohs(id):0;
/* insert answer section */
if((r=insert_section(rep, rep->an_numrrsets, &ancount, buffer,
@@ -667,14 +668,14 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
dnssec, rr_offset)) != RETVAL_OK) {
if(r == RETVAL_TRUNC) {
/* create truncated message */
- ldns_buffer_write_u16_at(buffer, 6, ancount);
- LDNS_TC_SET(ldns_buffer_begin(buffer));
- ldns_buffer_flip(buffer);
+ sldns_buffer_write_u16_at(buffer, 6, ancount);
+ LDNS_TC_SET(sldns_buffer_begin(buffer));
+ sldns_buffer_flip(buffer);
return 1;
}
return 0;
}
- ldns_buffer_write_u16_at(buffer, 6, ancount);
+ sldns_buffer_write_u16_at(buffer, 6, ancount);
/* if response is positive answer, auth/add sections are not required */
if( ! (MINIMAL_RESPONSES && positive_answer(rep, qinfo->qtype)) ) {
@@ -685,14 +686,14 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
dnssec, rr_offset)) != RETVAL_OK) {
if(r == RETVAL_TRUNC) {
/* create truncated message */
- ldns_buffer_write_u16_at(buffer, 8, nscount);
- LDNS_TC_SET(ldns_buffer_begin(buffer));
- ldns_buffer_flip(buffer);
+ sldns_buffer_write_u16_at(buffer, 8, nscount);
+ LDNS_TC_SET(sldns_buffer_begin(buffer));
+ sldns_buffer_flip(buffer);
return 1;
}
return 0;
}
- ldns_buffer_write_u16_at(buffer, 8, nscount);
+ sldns_buffer_write_u16_at(buffer, 8, nscount);
/* insert add section */
if((r=insert_section(rep, rep->ar_numrrsets, &arcount, buffer,
@@ -701,18 +702,15 @@ reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
dnssec, rr_offset)) != RETVAL_OK) {
if(r == RETVAL_TRUNC) {
/* no need to set TC bit, this is the additional */
- ldns_buffer_write_u16_at(buffer, 10, arcount);
- ldns_buffer_flip(buffer);
+ sldns_buffer_write_u16_at(buffer, 10, arcount);
+ sldns_buffer_flip(buffer);
return 1;
}
return 0;
}
- ldns_buffer_write_u16_at(buffer, 10, arcount);
- } else {
- ldns_buffer_write_u16_at(buffer, 8, nscount);
- ldns_buffer_write_u16_at(buffer, 10, arcount);
+ sldns_buffer_write_u16_at(buffer, 10, arcount);
}
- ldns_buffer_flip(buffer);
+ sldns_buffer_flip(buffer);
return 1;
}
@@ -726,31 +724,31 @@ calc_edns_field_size(struct edns_data* edns)
}
void
-attach_edns_record(ldns_buffer* pkt, struct edns_data* edns)
+attach_edns_record(sldns_buffer* pkt, struct edns_data* edns)
{
size_t len;
if(!edns || !edns->edns_present)
return;
/* inc additional count */
- ldns_buffer_write_u16_at(pkt, 10,
- ldns_buffer_read_u16_at(pkt, 10) + 1);
- len = ldns_buffer_limit(pkt);
- ldns_buffer_clear(pkt);
- ldns_buffer_set_position(pkt, len);
+ sldns_buffer_write_u16_at(pkt, 10,
+ sldns_buffer_read_u16_at(pkt, 10) + 1);
+ len = sldns_buffer_limit(pkt);
+ sldns_buffer_clear(pkt);
+ sldns_buffer_set_position(pkt, len);
/* write EDNS record */
- ldns_buffer_write_u8(pkt, 0); /* '.' label */
- ldns_buffer_write_u16(pkt, LDNS_RR_TYPE_OPT); /* type */
- ldns_buffer_write_u16(pkt, edns->udp_size); /* class */
- ldns_buffer_write_u8(pkt, edns->ext_rcode); /* ttl */
- ldns_buffer_write_u8(pkt, edns->edns_version);
- ldns_buffer_write_u16(pkt, edns->bits);
- ldns_buffer_write_u16(pkt, 0); /* rdatalen */
- ldns_buffer_flip(pkt);
+ sldns_buffer_write_u8(pkt, 0); /* '.' label */
+ sldns_buffer_write_u16(pkt, LDNS_RR_TYPE_OPT); /* type */
+ sldns_buffer_write_u16(pkt, edns->udp_size); /* class */
+ sldns_buffer_write_u8(pkt, edns->ext_rcode); /* ttl */
+ sldns_buffer_write_u8(pkt, edns->edns_version);
+ sldns_buffer_write_u16(pkt, edns->bits);
+ sldns_buffer_write_u16(pkt, 0); /* rdatalen */
+ sldns_buffer_flip(pkt);
}
int
reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep,
- uint16_t id, uint16_t qflags, ldns_buffer* pkt, uint32_t timenow,
+ uint16_t id, uint16_t qflags, sldns_buffer* pkt, time_t timenow,
int cached, struct regional* region, uint16_t udpsize,
struct edns_data* edns, int dnssec, int secure)
{
@@ -788,54 +786,54 @@ reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep,
}
void
-qinfo_query_encode(ldns_buffer* pkt, struct query_info* qinfo)
+qinfo_query_encode(sldns_buffer* pkt, struct query_info* qinfo)
{
uint16_t flags = 0; /* QUERY, NOERROR */
- ldns_buffer_clear(pkt);
- log_assert(ldns_buffer_remaining(pkt) >= 12+255+4/*max query*/);
- ldns_buffer_skip(pkt, 2); /* id done later */
- ldns_buffer_write_u16(pkt, flags);
- ldns_buffer_write_u16(pkt, 1); /* query count */
- ldns_buffer_write(pkt, "\000\000\000\000\000\000", 6); /* counts */
- ldns_buffer_write(pkt, qinfo->qname, qinfo->qname_len);
- ldns_buffer_write_u16(pkt, qinfo->qtype);
- ldns_buffer_write_u16(pkt, qinfo->qclass);
- ldns_buffer_flip(pkt);
+ sldns_buffer_clear(pkt);
+ log_assert(sldns_buffer_remaining(pkt) >= 12+255+4/*max query*/);
+ sldns_buffer_skip(pkt, 2); /* id done later */
+ sldns_buffer_write_u16(pkt, flags);
+ sldns_buffer_write_u16(pkt, 1); /* query count */
+ sldns_buffer_write(pkt, "\000\000\000\000\000\000", 6); /* counts */
+ sldns_buffer_write(pkt, qinfo->qname, qinfo->qname_len);
+ sldns_buffer_write_u16(pkt, qinfo->qtype);
+ sldns_buffer_write_u16(pkt, qinfo->qclass);
+ sldns_buffer_flip(pkt);
}
void
-error_encode(ldns_buffer* buf, int r, struct query_info* qinfo,
+error_encode(sldns_buffer* buf, int r, struct query_info* qinfo,
uint16_t qid, uint16_t qflags, struct edns_data* edns)
{
uint16_t flags;
- ldns_buffer_clear(buf);
- ldns_buffer_write(buf, &qid, sizeof(uint16_t));
+ sldns_buffer_clear(buf);
+ sldns_buffer_write(buf, &qid, sizeof(uint16_t));
flags = (uint16_t)(BIT_QR | BIT_RA | r); /* QR and retcode*/
flags |= (qflags & (BIT_RD|BIT_CD)); /* copy RD and CD bit */
- ldns_buffer_write_u16(buf, flags);
+ sldns_buffer_write_u16(buf, flags);
if(qinfo) flags = 1;
else flags = 0;
- ldns_buffer_write_u16(buf, flags);
+ sldns_buffer_write_u16(buf, flags);
flags = 0;
- ldns_buffer_write(buf, &flags, sizeof(uint16_t));
- ldns_buffer_write(buf, &flags, sizeof(uint16_t));
- ldns_buffer_write(buf, &flags, sizeof(uint16_t));
+ sldns_buffer_write(buf, &flags, sizeof(uint16_t));
+ sldns_buffer_write(buf, &flags, sizeof(uint16_t));
+ sldns_buffer_write(buf, &flags, sizeof(uint16_t));
if(qinfo) {
- if(ldns_buffer_current(buf) == qinfo->qname)
- ldns_buffer_skip(buf, (ssize_t)qinfo->qname_len);
- else ldns_buffer_write(buf, qinfo->qname, qinfo->qname_len);
- ldns_buffer_write_u16(buf, qinfo->qtype);
- ldns_buffer_write_u16(buf, qinfo->qclass);
+ if(sldns_buffer_current(buf) == qinfo->qname)
+ sldns_buffer_skip(buf, (ssize_t)qinfo->qname_len);
+ else sldns_buffer_write(buf, qinfo->qname, qinfo->qname_len);
+ sldns_buffer_write_u16(buf, qinfo->qtype);
+ sldns_buffer_write_u16(buf, qinfo->qclass);
}
- ldns_buffer_flip(buf);
+ sldns_buffer_flip(buf);
if(edns) {
struct edns_data es = *edns;
es.edns_version = EDNS_ADVERTISED_VERSION;
es.udp_size = EDNS_ADVERTISED_SIZE;
es.ext_rcode = 0;
es.bits &= EDNS_DO;
- if(ldns_buffer_limit(buf) + calc_edns_field_size(&es) >
+ if(sldns_buffer_limit(buf) + calc_edns_field_size(&es) >
edns->udp_size)
return;
attach_edns_record(buf, &es);
diff --git a/contrib/unbound/util/data/msgencode.h b/contrib/unbound/util/data/msgencode.h
index 74d6c1f..eea129d 100644
--- a/contrib/unbound/util/data/msgencode.h
+++ b/contrib/unbound/util/data/msgencode.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -42,6 +42,7 @@
#ifndef UTIL_DATA_MSGENCODE_H
#define UTIL_DATA_MSGENCODE_H
+struct sldns_buffer;
struct query_info;
struct reply_info;
struct regional;
@@ -66,7 +67,7 @@ struct edns_data;
* @return: 0 on error (server failure).
*/
int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep,
- uint16_t id, uint16_t qflags, ldns_buffer* dest, uint32_t timenow,
+ uint16_t id, uint16_t qflags, struct sldns_buffer* dest, time_t timenow,
int cached, struct regional* region, uint16_t udpsize,
struct edns_data* edns, int dnssec, int secure);
@@ -88,7 +89,7 @@ int reply_info_answer_encode(struct query_info* qinf, struct reply_info* rep,
* 0 on error: malloc failure (no log_err has been done).
*/
int reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
- uint16_t id, uint16_t flags, ldns_buffer* buffer, uint32_t timenow,
+ uint16_t id, uint16_t flags, struct sldns_buffer* buffer, time_t timenow,
struct regional* region, uint16_t udpsize, int dnssec);
/**
@@ -96,7 +97,7 @@ int reply_info_encode(struct query_info* qinfo, struct reply_info* rep,
* @param pkt: where to store the packet.
* @param qinfo: query info.
*/
-void qinfo_query_encode(ldns_buffer* pkt, struct query_info* qinfo);
+void qinfo_query_encode(struct sldns_buffer* pkt, struct query_info* qinfo);
/**
* Estimate size of EDNS record in packet. EDNS record will be no larger.
@@ -111,7 +112,7 @@ uint16_t calc_edns_field_size(struct edns_data* edns);
* @param pkt: packet added to.
* @param edns: if NULL or present=0, nothing is added to the packet.
*/
-void attach_edns_record(ldns_buffer* pkt, struct edns_data* edns);
+void attach_edns_record(struct sldns_buffer* pkt, struct edns_data* edns);
/**
* Encode an error. With QR and RA set.
@@ -124,7 +125,7 @@ void attach_edns_record(ldns_buffer* pkt, struct edns_data* edns);
* @param edns: if not NULL, this is the query edns info,
* and an edns reply is attached. Only attached if EDNS record fits reply.
*/
-void error_encode(ldns_buffer* pkt, int r, struct query_info* qinfo,
+void error_encode(struct sldns_buffer* pkt, int r, struct query_info* qinfo,
uint16_t qid, uint16_t qflags, struct edns_data* edns);
#endif /* UTIL_DATA_MSGENCODE_H */
diff --git a/contrib/unbound/util/data/msgparse.c b/contrib/unbound/util/data/msgparse.c
index 2791ae5..abe778a 100644
--- a/contrib/unbound/util/data/msgparse.c
+++ b/contrib/unbound/util/data/msgparse.c
@@ -21,37 +21,40 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
* Routines for message parsing a packet buffer to a descriptive structure.
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "util/data/msgparse.h"
#include "util/data/dname.h"
#include "util/data/packed_rrset.h"
#include "util/storage/lookup3.h"
#include "util/regional.h"
+#include "ldns/rrdef.h"
+#include "ldns/sbuffer.h"
+#include "ldns/parseutil.h"
+#include "ldns/wire2str.h"
/** smart comparison of (compressed, valid) dnames from packet */
static int
-smart_compare(ldns_buffer* pkt, uint8_t* dnow,
+smart_compare(sldns_buffer* pkt, uint8_t* dnow,
uint8_t* dprfirst, uint8_t* dprlast)
{
if(LABEL_IS_PTR(*dnow)) {
/* ptr points to a previous dname */
- uint8_t* p = ldns_buffer_at(pkt, PTR_OFFSET(dnow[0], dnow[1]));
+ uint8_t* p = sldns_buffer_at(pkt, PTR_OFFSET(dnow[0], dnow[1]));
if( p == dprfirst || p == dprlast )
return 0;
/* prev dname is also a ptr, both ptrs are the same. */
@@ -68,7 +71,7 @@ smart_compare(ldns_buffer* pkt, uint8_t* dnow,
static struct rrset_parse*
new_rrset(struct msg_parse* msg, uint8_t* dname, size_t dnamelen,
uint16_t type, uint16_t dclass, hashvalue_t hash,
- uint32_t rrset_flags, ldns_pkt_section section,
+ uint32_t rrset_flags, sldns_pkt_section section,
struct regional* region)
{
struct rrset_parse* p = regional_alloc(region, sizeof(*p));
@@ -99,52 +102,52 @@ new_rrset(struct msg_parse* msg, uint8_t* dname, size_t dnamelen,
/** See if next rrset is nsec at zone apex */
static int
-nsec_at_apex(ldns_buffer* pkt)
+nsec_at_apex(sldns_buffer* pkt)
{
/* we are at ttl position in packet. */
- size_t pos = ldns_buffer_position(pkt);
+ size_t pos = sldns_buffer_position(pkt);
uint16_t rdatalen;
- if(ldns_buffer_remaining(pkt) < 7) /* ttl+len+root */
+ if(sldns_buffer_remaining(pkt) < 7) /* ttl+len+root */
return 0; /* eek! */
- ldns_buffer_skip(pkt, 4); /* ttl */;
- rdatalen = ldns_buffer_read_u16(pkt);
- if(ldns_buffer_remaining(pkt) < rdatalen) {
- ldns_buffer_set_position(pkt, pos);
+ sldns_buffer_skip(pkt, 4); /* ttl */;
+ rdatalen = sldns_buffer_read_u16(pkt);
+ if(sldns_buffer_remaining(pkt) < rdatalen) {
+ sldns_buffer_set_position(pkt, pos);
return 0; /* parse error happens later */
}
/* must validate the nsec next domain name format */
if(pkt_dname_len(pkt) == 0) {
- ldns_buffer_set_position(pkt, pos);
+ sldns_buffer_set_position(pkt, pos);
return 0; /* parse error */
}
/* see if SOA bit is set. */
- if(ldns_buffer_position(pkt) < pos+4+rdatalen) {
+ if(sldns_buffer_position(pkt) < pos+4+rdatalen) {
/* nsec type bitmap contains items */
uint8_t win, blen, bits;
/* need: windownum, bitmap len, firstbyte */
- if(ldns_buffer_position(pkt)+3 > pos+4+rdatalen) {
- ldns_buffer_set_position(pkt, pos);
+ if(sldns_buffer_position(pkt)+3 > pos+4+rdatalen) {
+ sldns_buffer_set_position(pkt, pos);
return 0; /* malformed nsec */
}
- win = ldns_buffer_read_u8(pkt);
- blen = ldns_buffer_read_u8(pkt);
- bits = ldns_buffer_read_u8(pkt);
+ win = sldns_buffer_read_u8(pkt);
+ blen = sldns_buffer_read_u8(pkt);
+ bits = sldns_buffer_read_u8(pkt);
/* 0window always first window. bitlen >=1 or parse
error really. bit 0x2 is SOA. */
if(win == 0 && blen >= 1 && (bits & 0x02)) {
- ldns_buffer_set_position(pkt, pos);
+ sldns_buffer_set_position(pkt, pos);
return 1;
}
}
- ldns_buffer_set_position(pkt, pos);
+ sldns_buffer_set_position(pkt, pos);
return 0;
}
/** Calculate rrset flags */
static uint32_t
-pkt_rrset_flags(ldns_buffer* pkt, uint16_t type, ldns_pkt_section sec)
+pkt_rrset_flags(sldns_buffer* pkt, uint16_t type, sldns_pkt_section sec)
{
uint32_t f = 0;
if(type == LDNS_RR_TYPE_NSEC && nsec_at_apex(pkt)) {
@@ -156,7 +159,7 @@ pkt_rrset_flags(ldns_buffer* pkt, uint16_t type, ldns_pkt_section sec)
}
hashvalue_t
-pkt_hash_rrset(ldns_buffer* pkt, uint8_t* dname, uint16_t type,
+pkt_hash_rrset(sldns_buffer* pkt, uint8_t* dname, uint16_t type,
uint16_t dclass, uint32_t rrset_flags)
{
/* note this MUST be identical to rrset_key_hash in packed_rrset.c */
@@ -171,7 +174,7 @@ pkt_hash_rrset(ldns_buffer* pkt, uint8_t* dname, uint16_t type,
/** create partial dname hash for rrset hash */
static hashvalue_t
-pkt_hash_rrset_first(ldns_buffer* pkt, uint8_t* dname)
+pkt_hash_rrset_first(sldns_buffer* pkt, uint8_t* dname)
{
/* works together with pkt_hash_rrset_rest */
/* note this MUST be identical to rrset_key_hash in packed_rrset.c */
@@ -197,7 +200,7 @@ pkt_hash_rrset_rest(hashvalue_t dname_h, uint16_t type, uint16_t dclass,
/** compare rrset_parse with data */
static int
-rrset_parse_equals(struct rrset_parse* p, ldns_buffer* pkt, hashvalue_t h,
+rrset_parse_equals(struct rrset_parse* p, sldns_buffer* pkt, hashvalue_t h,
uint32_t rrset_flags, uint8_t* dname, size_t dnamelen,
uint16_t type, uint16_t dclass)
{
@@ -210,7 +213,7 @@ rrset_parse_equals(struct rrset_parse* p, ldns_buffer* pkt, hashvalue_t h,
struct rrset_parse*
-msgparse_hashtable_lookup(struct msg_parse* msg, ldns_buffer* pkt,
+msgparse_hashtable_lookup(struct msg_parse* msg, sldns_buffer* pkt,
hashvalue_t h, uint32_t rrset_flags, uint8_t* dname, size_t dnamelen,
uint16_t type, uint16_t dclass)
{
@@ -226,26 +229,26 @@ msgparse_hashtable_lookup(struct msg_parse* msg, ldns_buffer* pkt,
/** return type networkformat that rrsig in packet covers */
static int
-pkt_rrsig_covered(ldns_buffer* pkt, uint8_t* here, uint16_t* type)
+pkt_rrsig_covered(sldns_buffer* pkt, uint8_t* here, uint16_t* type)
{
- size_t pos = ldns_buffer_position(pkt);
- ldns_buffer_set_position(pkt, (size_t)(here-ldns_buffer_begin(pkt)));
+ size_t pos = sldns_buffer_position(pkt);
+ sldns_buffer_set_position(pkt, (size_t)(here-sldns_buffer_begin(pkt)));
/* ttl + len + size of small rrsig(rootlabel, no signature) */
- if(ldns_buffer_remaining(pkt) < 4+2+19)
+ if(sldns_buffer_remaining(pkt) < 4+2+19)
return 0;
- ldns_buffer_skip(pkt, 4); /* ttl */
- if(ldns_buffer_read_u16(pkt) < 19) /* too short */ {
- ldns_buffer_set_position(pkt, pos);
+ sldns_buffer_skip(pkt, 4); /* ttl */
+ if(sldns_buffer_read_u16(pkt) < 19) /* too short */ {
+ sldns_buffer_set_position(pkt, pos);
return 0;
}
- *type = ldns_buffer_read_u16(pkt);
- ldns_buffer_set_position(pkt, pos);
+ *type = sldns_buffer_read_u16(pkt);
+ sldns_buffer_set_position(pkt, pos);
return 1;
}
/** true if covered type equals prevtype */
static int
-pkt_rrsig_covered_equals(ldns_buffer* pkt, uint8_t* here, uint16_t type)
+pkt_rrsig_covered_equals(sldns_buffer* pkt, uint8_t* here, uint16_t type)
{
uint16_t t;
if(pkt_rrsig_covered(pkt, here, &t) && t == type)
@@ -270,7 +273,7 @@ msgparse_bucket_remove(struct msg_parse* msg, struct rrset_parse* rrset)
/** change section of rrset from previous to current section */
static void
change_section(struct msg_parse* msg, struct rrset_parse* rrset,
- ldns_pkt_section section)
+ sldns_pkt_section section)
{
struct rrset_parse *p, *prev;
/* remove from list */
@@ -313,7 +316,7 @@ change_section(struct msg_parse* msg, struct rrset_parse* rrset,
/** see if rrset of type RRSIG contains sig over given type */
static int
-rrset_has_sigover(ldns_buffer* pkt, struct rrset_parse* rrset, uint16_t type,
+rrset_has_sigover(sldns_buffer* pkt, struct rrset_parse* rrset, uint16_t type,
int* hasother)
{
int res = 0;
@@ -330,7 +333,7 @@ rrset_has_sigover(ldns_buffer* pkt, struct rrset_parse* rrset, uint16_t type,
/** move rrsigs from sigset to dataset */
static int
-moveover_rrsigs(ldns_buffer* pkt, struct regional* region,
+moveover_rrsigs(sldns_buffer* pkt, struct regional* region,
struct rrset_parse* sigset, struct rrset_parse* dataset, int duplicate)
{
struct rr_parse* sig = sigset->rr_first;
@@ -380,8 +383,8 @@ moveover_rrsigs(ldns_buffer* pkt, struct regional* region,
/** change an rrsig rrset for use as data rrset */
static struct rrset_parse*
change_rrsig_rrset(struct rrset_parse* sigset, struct msg_parse* msg,
- ldns_buffer* pkt, uint16_t datatype, uint32_t rrset_flags,
- int hasother, ldns_pkt_section section, struct regional* region)
+ sldns_buffer* pkt, uint16_t datatype, uint32_t rrset_flags,
+ int hasother, sldns_pkt_section section, struct regional* region)
{
struct rrset_parse* dataset = sigset;
hashvalue_t hash = pkt_hash_rrset(pkt, sigset->dname, datatype,
@@ -450,13 +453,13 @@ change_rrsig_rrset(struct rrset_parse* sigset, struct msg_parse* msg,
* @return 0 on out of memory.
*/
static int
-find_rrset(struct msg_parse* msg, ldns_buffer* pkt, uint8_t* dname,
+find_rrset(struct msg_parse* msg, sldns_buffer* pkt, uint8_t* dname,
size_t dnamelen, uint16_t type, uint16_t dclass, hashvalue_t* hash,
uint32_t* rrset_flags,
uint8_t** prev_dname_first, uint8_t** prev_dname_last,
size_t* prev_dnamelen, uint16_t* prev_type,
uint16_t* prev_dclass, struct rrset_parse** rrset_prev,
- ldns_pkt_section section, struct regional* region)
+ sldns_pkt_section section, struct regional* region)
{
hashvalue_t dname_h = pkt_hash_rrset_first(pkt, dname);
uint16_t covtype;
@@ -473,7 +476,7 @@ find_rrset(struct msg_parse* msg, ldns_buffer* pkt, uint8_t* dname,
}
/* check if rrsig over previous item */
if(type == LDNS_RR_TYPE_RRSIG && dclass == *prev_dclass &&
- pkt_rrsig_covered_equals(pkt, ldns_buffer_current(pkt),
+ pkt_rrsig_covered_equals(pkt, sldns_buffer_current(pkt),
*prev_type) &&
smart_compare(pkt, dname, *prev_dname_first,
*prev_dname_last) == 0) {
@@ -487,7 +490,7 @@ find_rrset(struct msg_parse* msg, ldns_buffer* pkt, uint8_t* dname,
/* if rrsig - try to lookup matching data set first */
if(type == LDNS_RR_TYPE_RRSIG && pkt_rrsig_covered(pkt,
- ldns_buffer_current(pkt), &covtype)) {
+ sldns_buffer_current(pkt), &covtype)) {
*hash = pkt_hash_rrset_rest(dname_h, covtype, dclass,
*rrset_flags);
*rrset_prev = msgparse_hashtable_lookup(msg, pkt, *hash,
@@ -568,27 +571,27 @@ find_rrset(struct msg_parse* msg, ldns_buffer* pkt, uint8_t* dname,
* @return: 0 if OK, or rcode on error.
*/
static int
-parse_query_section(ldns_buffer* pkt, struct msg_parse* msg)
+parse_query_section(sldns_buffer* pkt, struct msg_parse* msg)
{
if(msg->qdcount == 0)
return 0;
if(msg->qdcount > 1)
return LDNS_RCODE_FORMERR;
log_assert(msg->qdcount == 1);
- if(ldns_buffer_remaining(pkt) <= 0)
+ if(sldns_buffer_remaining(pkt) <= 0)
return LDNS_RCODE_FORMERR;
- msg->qname = ldns_buffer_current(pkt);
+ msg->qname = sldns_buffer_current(pkt);
if((msg->qname_len = pkt_dname_len(pkt)) == 0)
return LDNS_RCODE_FORMERR;
- if(ldns_buffer_remaining(pkt) < sizeof(uint16_t)*2)
+ if(sldns_buffer_remaining(pkt) < sizeof(uint16_t)*2)
return LDNS_RCODE_FORMERR;
- msg->qtype = ldns_buffer_read_u16(pkt);
- msg->qclass = ldns_buffer_read_u16(pkt);
+ msg->qtype = sldns_buffer_read_u16(pkt);
+ msg->qclass = sldns_buffer_read_u16(pkt);
return 0;
}
size_t
-get_rdf_size(ldns_rdf_type rdf)
+get_rdf_size(sldns_rdf_type rdf)
{
switch(rdf) {
case LDNS_RDF_TYPE_CLASS:
@@ -614,7 +617,7 @@ get_rdf_size(ldns_rdf_type rdf)
return 16;
break;
default:
- log_assert(false); /* add type above */
+ log_assert(0); /* add type above */
/* only types that appear before a domain *
* name are needed. rest is simply copied. */
}
@@ -623,16 +626,16 @@ get_rdf_size(ldns_rdf_type rdf)
/** calculate the size of one rr */
static int
-calc_size(ldns_buffer* pkt, uint16_t type, struct rr_parse* rr)
+calc_size(sldns_buffer* pkt, uint16_t type, struct rr_parse* rr)
{
- const ldns_rr_descriptor* desc;
+ const sldns_rr_descriptor* desc;
uint16_t pkt_len; /* length of rr inside the packet */
rr->size = sizeof(uint16_t); /* the rdatalen */
- ldns_buffer_skip(pkt, 4); /* skip ttl */
- pkt_len = ldns_buffer_read_u16(pkt);
- if(ldns_buffer_remaining(pkt) < pkt_len)
+ sldns_buffer_skip(pkt, 4); /* skip ttl */
+ pkt_len = sldns_buffer_read_u16(pkt);
+ if(sldns_buffer_remaining(pkt) < pkt_len)
return 0;
- desc = ldns_rr_descript(type);
+ desc = sldns_rr_descript(type);
if(pkt_len > 0 && desc && desc->_dname_count > 0) {
int count = (int)desc->_dname_count;
int rdf = 0;
@@ -643,12 +646,12 @@ calc_size(ldns_buffer* pkt, uint16_t type, struct rr_parse* rr)
switch(desc->_wireformat[rdf]) {
case LDNS_RDF_TYPE_DNAME:
/* decompress every domain name */
- oldpos = ldns_buffer_position(pkt);
+ oldpos = sldns_buffer_position(pkt);
if((len = pkt_dname_len(pkt)) == 0)
return 0; /* malformed dname */
- if(ldns_buffer_position(pkt)-oldpos > pkt_len)
+ if(sldns_buffer_position(pkt)-oldpos > pkt_len)
return 0; /* dname exceeds rdata */
- pkt_len -= ldns_buffer_position(pkt)-oldpos;
+ pkt_len -= sldns_buffer_position(pkt)-oldpos;
rr->size += len;
count--;
len = 0;
@@ -658,7 +661,7 @@ calc_size(ldns_buffer* pkt, uint16_t type, struct rr_parse* rr)
/* NOTREACHED, due to 'while(>0)' */
return 0; /* len byte exceeds rdata */
}
- len = ldns_buffer_current(pkt)[0] + 1;
+ len = sldns_buffer_current(pkt)[0] + 1;
break;
default:
len = get_rdf_size(desc->_wireformat[rdf]);
@@ -667,7 +670,7 @@ calc_size(ldns_buffer* pkt, uint16_t type, struct rr_parse* rr)
if(pkt_len < len)
return 0; /* exceeds rdata */
pkt_len -= len;
- ldns_buffer_skip(pkt, (ssize_t)len);
+ sldns_buffer_skip(pkt, (ssize_t)len);
rr->size += len;
}
rdf++;
@@ -675,41 +678,41 @@ calc_size(ldns_buffer* pkt, uint16_t type, struct rr_parse* rr)
}
/* remaining rdata */
rr->size += pkt_len;
- ldns_buffer_skip(pkt, (ssize_t)pkt_len);
+ sldns_buffer_skip(pkt, (ssize_t)pkt_len);
return 1;
}
/** skip rr ttl and rdata */
static int
-skip_ttl_rdata(ldns_buffer* pkt)
+skip_ttl_rdata(sldns_buffer* pkt)
{
uint16_t rdatalen;
- if(ldns_buffer_remaining(pkt) < 6) /* ttl + rdatalen */
+ if(sldns_buffer_remaining(pkt) < 6) /* ttl + rdatalen */
return 0;
- ldns_buffer_skip(pkt, 4); /* ttl */
- rdatalen = ldns_buffer_read_u16(pkt);
- if(ldns_buffer_remaining(pkt) < rdatalen)
+ sldns_buffer_skip(pkt, 4); /* ttl */
+ rdatalen = sldns_buffer_read_u16(pkt);
+ if(sldns_buffer_remaining(pkt) < rdatalen)
return 0;
- ldns_buffer_skip(pkt, (ssize_t)rdatalen);
+ sldns_buffer_skip(pkt, (ssize_t)rdatalen);
return 1;
}
/** see if RRSIG is a duplicate of another */
static int
-sig_is_double(ldns_buffer* pkt, struct rrset_parse* rrset, uint8_t* ttldata)
+sig_is_double(sldns_buffer* pkt, struct rrset_parse* rrset, uint8_t* ttldata)
{
uint16_t rlen, siglen;
- size_t pos = ldns_buffer_position(pkt);
+ size_t pos = sldns_buffer_position(pkt);
struct rr_parse* sig;
- if(ldns_buffer_remaining(pkt) < 6)
+ if(sldns_buffer_remaining(pkt) < 6)
return 0;
- ldns_buffer_skip(pkt, 4); /* ttl */
- rlen = ldns_buffer_read_u16(pkt);
- if(ldns_buffer_remaining(pkt) < rlen) {
- ldns_buffer_set_position(pkt, pos);
+ sldns_buffer_skip(pkt, 4); /* ttl */
+ rlen = sldns_buffer_read_u16(pkt);
+ if(sldns_buffer_remaining(pkt) < rlen) {
+ sldns_buffer_set_position(pkt, pos);
return 0;
}
- ldns_buffer_set_position(pkt, pos);
+ sldns_buffer_set_position(pkt, pos);
sig = rrset->rrsig_first;
while(sig) {
@@ -738,9 +741,9 @@ sig_is_double(ldns_buffer* pkt, struct rrset_parse* rrset, uint8_t* ttldata)
/** Add rr (from packet here) to rrset, skips rr */
static int
-add_rr_to_rrset(struct rrset_parse* rrset, ldns_buffer* pkt,
+add_rr_to_rrset(struct rrset_parse* rrset, sldns_buffer* pkt,
struct msg_parse* msg, struct regional* region,
- ldns_pkt_section section, uint16_t type)
+ sldns_pkt_section section, uint16_t type)
{
struct rr_parse* rr;
/* check section of rrset. */
@@ -764,7 +767,7 @@ add_rr_to_rrset(struct rrset_parse* rrset, ldns_buffer* pkt,
if( (msg->qtype == LDNS_RR_TYPE_RRSIG ||
msg->qtype == LDNS_RR_TYPE_ANY)
- && sig_is_double(pkt, rrset, ldns_buffer_current(pkt))) {
+ && sig_is_double(pkt, rrset, sldns_buffer_current(pkt))) {
if(!skip_ttl_rdata(pkt))
return LDNS_RCODE_FORMERR;
return 0;
@@ -774,7 +777,7 @@ add_rr_to_rrset(struct rrset_parse* rrset, ldns_buffer* pkt,
if(!(rr = (struct rr_parse*)regional_alloc(region, sizeof(*rr))))
return LDNS_RCODE_SERVFAIL;
rr->outside_packet = 0;
- rr->ttl_data = ldns_buffer_current(pkt);
+ rr->ttl_data = sldns_buffer_current(pkt);
rr->next = 0;
if(type == LDNS_RR_TYPE_RRSIG && rrset->type != LDNS_RR_TYPE_RRSIG) {
if(rrset->rrsig_last)
@@ -810,8 +813,8 @@ add_rr_to_rrset(struct rrset_parse* rrset, ldns_buffer* pkt,
* @return: 0 if OK, or rcode on error.
*/
static int
-parse_section(ldns_buffer* pkt, struct msg_parse* msg,
- struct regional* region, ldns_pkt_section section,
+parse_section(sldns_buffer* pkt, struct msg_parse* msg,
+ struct regional* region, sldns_pkt_section section,
uint16_t num_rrs, size_t* num_rrsets)
{
uint16_t i;
@@ -826,39 +829,39 @@ parse_section(ldns_buffer* pkt, struct msg_parse* msg,
if(num_rrs == 0)
return 0;
- if(ldns_buffer_remaining(pkt) <= 0)
+ if(sldns_buffer_remaining(pkt) <= 0)
return LDNS_RCODE_FORMERR;
for(i=0; i<num_rrs; i++) {
/* parse this RR. */
- dname = ldns_buffer_current(pkt);
+ dname = sldns_buffer_current(pkt);
if((dnamelen = pkt_dname_len(pkt)) == 0)
return LDNS_RCODE_FORMERR;
- if(ldns_buffer_remaining(pkt) < 10) /* type, class, ttl, len */
+ if(sldns_buffer_remaining(pkt) < 10) /* type, class, ttl, len */
return LDNS_RCODE_FORMERR;
- type = ldns_buffer_read_u16(pkt);
- ldns_buffer_read(pkt, &dclass, sizeof(dclass));
+ type = sldns_buffer_read_u16(pkt);
+ sldns_buffer_read(pkt, &dclass, sizeof(dclass));
if(0) { /* debug show what is being parsed. */
if(type == LDNS_RR_TYPE_RRSIG) {
uint16_t t;
if(pkt_rrsig_covered(pkt,
- ldns_buffer_current(pkt), &t))
+ sldns_buffer_current(pkt), &t))
fprintf(stderr, "parse of %s(%d) [%s(%d)]",
- ldns_rr_descript(type)?
- ldns_rr_descript(type)->_name: "??",
+ sldns_rr_descript(type)?
+ sldns_rr_descript(type)->_name: "??",
(int)type,
- ldns_rr_descript(t)?
- ldns_rr_descript(t)->_name: "??",
+ sldns_rr_descript(t)?
+ sldns_rr_descript(t)->_name: "??",
(int)t);
} else
fprintf(stderr, "parse of %s(%d)",
- ldns_rr_descript(type)?
- ldns_rr_descript(type)->_name: "??",
+ sldns_rr_descript(type)?
+ sldns_rr_descript(type)->_name: "??",
(int)type);
fprintf(stderr, " %s(%d) ",
- ldns_lookup_by_id(ldns_rr_classes,
- (int)ntohs(dclass))?ldns_lookup_by_id(
- ldns_rr_classes, (int)ntohs(dclass))->name:
+ sldns_lookup_by_id(sldns_rr_classes,
+ (int)ntohs(dclass))?sldns_lookup_by_id(
+ sldns_rr_classes, (int)ntohs(dclass))->name:
"??", (int)ntohs(dclass));
dname_print(stderr, pkt, dname);
fprintf(stderr, "\n");
@@ -882,8 +885,8 @@ parse_section(ldns_buffer* pkt, struct msg_parse* msg,
fprintf(stderr, "is part of existing: ");
dname_print(stderr, pkt, rrset->dname);
fprintf(stderr, " type %s(%d)\n",
- ldns_rr_descript(rrset->type)?
- ldns_rr_descript(rrset->type)->_name: "??",
+ sldns_rr_descript(rrset->type)?
+ sldns_rr_descript(rrset->type)->_name: "??",
(int)rrset->type);
}
/* add to rrset. */
@@ -895,18 +898,18 @@ parse_section(ldns_buffer* pkt, struct msg_parse* msg,
}
int
-parse_packet(ldns_buffer* pkt, struct msg_parse* msg, struct regional* region)
+parse_packet(sldns_buffer* pkt, struct msg_parse* msg, struct regional* region)
{
int ret;
- if(ldns_buffer_remaining(pkt) < LDNS_HEADER_SIZE)
+ if(sldns_buffer_remaining(pkt) < LDNS_HEADER_SIZE)
return LDNS_RCODE_FORMERR;
/* read the header */
- ldns_buffer_read(pkt, &msg->id, sizeof(uint16_t));
- msg->flags = ldns_buffer_read_u16(pkt);
- msg->qdcount = ldns_buffer_read_u16(pkt);
- msg->ancount = ldns_buffer_read_u16(pkt);
- msg->nscount = ldns_buffer_read_u16(pkt);
- msg->arcount = ldns_buffer_read_u16(pkt);
+ sldns_buffer_read(pkt, &msg->id, sizeof(uint16_t));
+ msg->flags = sldns_buffer_read_u16(pkt);
+ msg->qdcount = sldns_buffer_read_u16(pkt);
+ msg->ancount = sldns_buffer_read_u16(pkt);
+ msg->nscount = sldns_buffer_read_u16(pkt);
+ msg->arcount = sldns_buffer_read_u16(pkt);
if(msg->qdcount > 1)
return LDNS_RCODE_FORMERR;
if((ret = parse_query_section(pkt, msg)) != 0)
@@ -917,13 +920,13 @@ parse_packet(ldns_buffer* pkt, struct msg_parse* msg, struct regional* region)
if((ret = parse_section(pkt, msg, region, LDNS_SECTION_AUTHORITY,
msg->nscount, &msg->ns_rrsets)) != 0)
return ret;
- if(ldns_buffer_remaining(pkt) == 0 && msg->arcount == 1) {
+ if(sldns_buffer_remaining(pkt) == 0 && msg->arcount == 1) {
/* BIND accepts leniently that an EDNS record is missing.
* so, we do too. */
} else if((ret = parse_section(pkt, msg, region,
LDNS_SECTION_ADDITIONAL, msg->arcount, &msg->ar_rrsets)) != 0)
return ret;
- /* if(ldns_buffer_remaining(pkt) > 0) { */
+ /* if(sldns_buffer_remaining(pkt) > 0) { */
/* there is spurious data at end of packet. ignore */
/* } */
msg->rrset_count = msg->an_rrsets + msg->ns_rrsets + msg->ar_rrsets;
@@ -981,23 +984,23 @@ parse_extract_edns(struct msg_parse* msg, struct edns_data* edns)
edns->edns_present = 1;
edns->ext_rcode = found->rr_last->ttl_data[0];
edns->edns_version = found->rr_last->ttl_data[1];
- edns->bits = ldns_read_uint16(&found->rr_last->ttl_data[2]);
+ edns->bits = sldns_read_uint16(&found->rr_last->ttl_data[2]);
edns->udp_size = ntohs(found->rrset_class);
/* ignore rdata and rrsigs */
return 0;
}
int
-parse_edns_from_pkt(ldns_buffer* pkt, struct edns_data* edns)
+parse_edns_from_pkt(sldns_buffer* pkt, struct edns_data* edns)
{
- log_assert(LDNS_QDCOUNT(ldns_buffer_begin(pkt)) == 1);
- log_assert(LDNS_ANCOUNT(ldns_buffer_begin(pkt)) == 0);
- log_assert(LDNS_NSCOUNT(ldns_buffer_begin(pkt)) == 0);
+ log_assert(LDNS_QDCOUNT(sldns_buffer_begin(pkt)) == 1);
+ log_assert(LDNS_ANCOUNT(sldns_buffer_begin(pkt)) == 0);
+ log_assert(LDNS_NSCOUNT(sldns_buffer_begin(pkt)) == 0);
/* check edns section is present */
- if(LDNS_ARCOUNT(ldns_buffer_begin(pkt)) > 1) {
+ if(LDNS_ARCOUNT(sldns_buffer_begin(pkt)) > 1) {
return LDNS_RCODE_FORMERR;
}
- if(LDNS_ARCOUNT(ldns_buffer_begin(pkt)) == 0) {
+ if(LDNS_ARCOUNT(sldns_buffer_begin(pkt)) == 0) {
memset(edns, 0, sizeof(*edns));
edns->udp_size = 512;
return 0;
@@ -1005,15 +1008,15 @@ parse_edns_from_pkt(ldns_buffer* pkt, struct edns_data* edns)
/* domain name must be the root of length 1. */
if(pkt_dname_len(pkt) != 1)
return LDNS_RCODE_FORMERR;
- if(ldns_buffer_remaining(pkt) < 10) /* type, class, ttl, rdatalen */
+ if(sldns_buffer_remaining(pkt) < 10) /* type, class, ttl, rdatalen */
return LDNS_RCODE_FORMERR;
- if(ldns_buffer_read_u16(pkt) != LDNS_RR_TYPE_OPT)
+ if(sldns_buffer_read_u16(pkt) != LDNS_RR_TYPE_OPT)
return LDNS_RCODE_FORMERR;
edns->edns_present = 1;
- edns->udp_size = ldns_buffer_read_u16(pkt); /* class is udp size */
- edns->ext_rcode = ldns_buffer_read_u8(pkt); /* ttl used for bits */
- edns->edns_version = ldns_buffer_read_u8(pkt);
- edns->bits = ldns_buffer_read_u16(pkt);
+ edns->udp_size = sldns_buffer_read_u16(pkt); /* class is udp size */
+ edns->ext_rcode = sldns_buffer_read_u8(pkt); /* ttl used for bits */
+ edns->edns_version = sldns_buffer_read_u8(pkt);
+ edns->bits = sldns_buffer_read_u16(pkt);
/* ignore rdata and rrsigs */
return 0;
}
diff --git a/contrib/unbound/util/data/msgparse.h b/contrib/unbound/util/data/msgparse.h
index 830d68e..221a45a 100644
--- a/contrib/unbound/util/data/msgparse.h
+++ b/contrib/unbound/util/data/msgparse.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
@@ -63,7 +63,9 @@
#ifndef UTIL_DATA_MSGPARSE_H
#define UTIL_DATA_MSGPARSE_H
#include "util/storage/lruhash.h"
-#include <ldns/packet.h>
+#include "ldns/pkthdr.h"
+#include "ldns/rrdef.h"
+struct sldns_buffer;
struct rrset_parse;
struct rr_parse;
struct regional;
@@ -71,9 +73,9 @@ struct regional;
/** number of buckets in parse rrset hash table. Must be power of 2. */
#define PARSE_TABLE_SIZE 32
/** Maximum TTL that is allowed. */
-extern uint32_t MAX_TTL;
+extern time_t MAX_TTL;
/** Minimum TTL that is allowed. */
-extern uint32_t MIN_TTL;
+extern time_t MIN_TTL;
/** Negative cache time (for entries without any RRs.) */
#define NORR_TTL 5 /* seconds */
@@ -137,7 +139,7 @@ struct rrset_parse {
/** which section was it found in: one of
* LDNS_SECTION_ANSWER, LDNS_SECTION_AUTHORITY, LDNS_SECTION_ADDITIONAL
*/
- ldns_pkt_section section;
+ sldns_pkt_section section;
/** start of (possibly compressed) dname in packet */
uint8_t* dname;
/** length of the dname uncompressed wireformat */
@@ -219,7 +221,7 @@ struct edns_data {
* @param rdf: the rdf type from the descriptor.
* @return: size in octets. 0 on failure.
*/
-size_t get_rdf_size(ldns_rdf_type rdf);
+size_t get_rdf_size(sldns_rdf_type rdf);
/**
* Parse the packet.
@@ -229,7 +231,7 @@ size_t get_rdf_size(ldns_rdf_type rdf);
* @param region: how to alloc results.
* @return: 0 if OK, or rcode on error.
*/
-int parse_packet(ldns_buffer* pkt, struct msg_parse* msg,
+int parse_packet(struct sldns_buffer* pkt, struct msg_parse* msg,
struct regional* region);
/**
@@ -259,7 +261,7 @@ int parse_extract_edns(struct msg_parse* msg, struct edns_data* edns);
* @return: 0 on success, or an RCODE on error.
* RCODE formerr if OPT is badly formatted and so on.
*/
-int parse_edns_from_pkt(ldns_buffer* pkt, struct edns_data* edns);
+int parse_edns_from_pkt(struct sldns_buffer* pkt, struct edns_data* edns);
/**
* Calculate hash value for rrset in packet.
@@ -270,7 +272,7 @@ int parse_edns_from_pkt(ldns_buffer* pkt, struct edns_data* edns);
* @param rrset_flags: rrset flags (same as packed_rrset flags).
* @return hash value
*/
-hashvalue_t pkt_hash_rrset(ldns_buffer* pkt, uint8_t* dname, uint16_t type,
+hashvalue_t pkt_hash_rrset(struct sldns_buffer* pkt, uint8_t* dname, uint16_t type,
uint16_t dclass, uint32_t rrset_flags);
/**
@@ -286,7 +288,7 @@ hashvalue_t pkt_hash_rrset(ldns_buffer* pkt, uint8_t* dname, uint16_t type,
* @return NULL or the rrset_parse if found.
*/
struct rrset_parse* msgparse_hashtable_lookup(struct msg_parse* msg,
- ldns_buffer* pkt, hashvalue_t h, uint32_t rrset_flags,
+ struct sldns_buffer* pkt, hashvalue_t h, uint32_t rrset_flags,
uint8_t* dname, size_t dnamelen, uint16_t type, uint16_t dclass);
/**
diff --git a/contrib/unbound/util/data/msgreply.c b/contrib/unbound/util/data/msgreply.c
index 6d711ff..cfdf3fe 100644
--- a/contrib/unbound/util/data/msgreply.c
+++ b/contrib/unbound/util/data/msgreply.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,7 +40,6 @@
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "util/data/msgreply.h"
#include "util/storage/lookup3.h"
#include "util/log.h"
@@ -51,15 +50,17 @@
#include "util/regional.h"
#include "util/data/msgparse.h"
#include "util/data/msgencode.h"
+#include "ldns/sbuffer.h"
+#include "ldns/wire2str.h"
/** MAX TTL default for messages and rrsets */
-uint32_t MAX_TTL = 3600 * 24 * 10; /* ten days */
+time_t MAX_TTL = 3600 * 24 * 10; /* ten days */
/** MIN TTL default for messages and rrsets */
-uint32_t MIN_TTL = 0;
+time_t MIN_TTL = 0;
/** allocate qinfo, return 0 on error */
static int
-parse_create_qinfo(ldns_buffer* pkt, struct msg_parse* msg,
+parse_create_qinfo(sldns_buffer* pkt, struct msg_parse* msg,
struct query_info* qinf, struct regional* region)
{
if(msg->qname) {
@@ -79,7 +80,7 @@ parse_create_qinfo(ldns_buffer* pkt, struct msg_parse* msg,
/** constructor for replyinfo */
static struct reply_info*
construct_reply_info_base(struct regional* region, uint16_t flags, size_t qd,
- uint32_t ttl, uint32_t prettl, size_t an, size_t ns, size_t ar,
+ time_t ttl, time_t prettl, size_t an, size_t ns, size_t ar,
size_t total, enum sec_status sec)
{
struct reply_info* rep;
@@ -153,13 +154,13 @@ repinfo_alloc_rrset_keys(struct reply_info* rep, struct alloc_cache* alloc,
/** do the rdata copy */
static int
-rdata_copy(ldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to,
- struct rr_parse* rr, uint32_t* rr_ttl, uint16_t type)
+rdata_copy(sldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to,
+ struct rr_parse* rr, time_t* rr_ttl, uint16_t type)
{
uint16_t pkt_len;
- const ldns_rr_descriptor* desc;
+ const sldns_rr_descriptor* desc;
- *rr_ttl = ldns_read_uint32(rr->ttl_data);
+ *rr_ttl = sldns_read_uint32(rr->ttl_data);
/* RFC 2181 Section 8. if msb of ttl is set treat as if zero. */
if(*rr_ttl & 0x80000000U)
*rr_ttl = 0;
@@ -174,18 +175,18 @@ rdata_copy(ldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to,
return 1;
}
- ldns_buffer_set_position(pkt, (size_t)
- (rr->ttl_data - ldns_buffer_begin(pkt) + sizeof(uint32_t)));
+ sldns_buffer_set_position(pkt, (size_t)
+ (rr->ttl_data - sldns_buffer_begin(pkt) + sizeof(uint32_t)));
/* insert decompressed size into rdata len stored in memory */
/* -2 because rdatalen bytes are not included. */
pkt_len = htons(rr->size - 2);
memmove(to, &pkt_len, sizeof(uint16_t));
to += 2;
/* read packet rdata len */
- pkt_len = ldns_buffer_read_u16(pkt);
- if(ldns_buffer_remaining(pkt) < pkt_len)
+ pkt_len = sldns_buffer_read_u16(pkt);
+ if(sldns_buffer_remaining(pkt) < pkt_len)
return 0;
- desc = ldns_rr_descript(type);
+ desc = sldns_rr_descript(type);
if(pkt_len > 0 && desc && desc->_dname_count > 0) {
int count = (int)desc->_dname_count;
int rdf = 0;
@@ -195,25 +196,25 @@ rdata_copy(ldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to,
while(pkt_len > 0 && count) {
switch(desc->_wireformat[rdf]) {
case LDNS_RDF_TYPE_DNAME:
- oldpos = ldns_buffer_position(pkt);
+ oldpos = sldns_buffer_position(pkt);
dname_pkt_copy(pkt, to,
- ldns_buffer_current(pkt));
+ sldns_buffer_current(pkt));
to += pkt_dname_len(pkt);
- pkt_len -= ldns_buffer_position(pkt)-oldpos;
+ pkt_len -= sldns_buffer_position(pkt)-oldpos;
count--;
len = 0;
break;
case LDNS_RDF_TYPE_STR:
- len = ldns_buffer_current(pkt)[0] + 1;
+ len = sldns_buffer_current(pkt)[0] + 1;
break;
default:
len = get_rdf_size(desc->_wireformat[rdf]);
break;
}
if(len) {
- memmove(to, ldns_buffer_current(pkt), len);
+ memmove(to, sldns_buffer_current(pkt), len);
to += len;
- ldns_buffer_skip(pkt, (ssize_t)len);
+ sldns_buffer_skip(pkt, (ssize_t)len);
log_assert(len <= pkt_len);
pkt_len -= len;
}
@@ -222,14 +223,14 @@ rdata_copy(ldns_buffer* pkt, struct packed_rrset_data* data, uint8_t* to,
}
/* copy remaining rdata */
if(pkt_len > 0)
- memmove(to, ldns_buffer_current(pkt), pkt_len);
+ memmove(to, sldns_buffer_current(pkt), pkt_len);
return 1;
}
/** copy over the data into packed rrset */
static int
-parse_rr_copy(ldns_buffer* pkt, struct rrset_parse* pset,
+parse_rr_copy(sldns_buffer* pkt, struct rrset_parse* pset,
struct packed_rrset_data* data)
{
size_t i;
@@ -245,7 +246,7 @@ parse_rr_copy(ldns_buffer* pkt, struct rrset_parse* pset,
data->rr_len = (size_t*)((uint8_t*)data +
sizeof(struct packed_rrset_data));
data->rr_data = (uint8_t**)&(data->rr_len[total]);
- data->rr_ttl = (uint32_t*)&(data->rr_data[total]);
+ data->rr_ttl = (time_t*)&(data->rr_data[total]);
nextrdata = (uint8_t*)&(data->rr_ttl[total]);
for(i=0; i<data->count; i++) {
data->rr_len[i] = rr->size;
@@ -272,13 +273,13 @@ parse_rr_copy(ldns_buffer* pkt, struct rrset_parse* pset,
/** create rrset return 0 on failure */
static int
-parse_create_rrset(ldns_buffer* pkt, struct rrset_parse* pset,
+parse_create_rrset(sldns_buffer* pkt, struct rrset_parse* pset,
struct packed_rrset_data** data, struct regional* region)
{
/* allocate */
size_t s = sizeof(struct packed_rrset_data) +
(pset->rr_count + pset->rrsig_count) *
- (sizeof(size_t)+sizeof(uint8_t*)+sizeof(uint32_t)) +
+ (sizeof(size_t)+sizeof(uint8_t*)+sizeof(time_t)) +
pset->size;
if(region)
*data = regional_alloc(region, s);
@@ -332,7 +333,7 @@ get_rrset_trust(struct msg_parse* msg, struct rrset_parse* rrset)
}
int
-parse_copy_decompress_rrset(ldns_buffer* pkt, struct msg_parse* msg,
+parse_copy_decompress_rrset(sldns_buffer* pkt, struct msg_parse* msg,
struct rrset_parse *pset, struct regional* region,
struct ub_packed_rrset_key* pk)
{
@@ -370,7 +371,7 @@ parse_copy_decompress_rrset(ldns_buffer* pkt, struct msg_parse* msg,
* @return 0 on failure.
*/
static int
-parse_copy_decompress(ldns_buffer* pkt, struct msg_parse* msg,
+parse_copy_decompress(sldns_buffer* pkt, struct msg_parse* msg,
struct reply_info* rep, struct regional* region)
{
size_t i;
@@ -397,7 +398,7 @@ parse_copy_decompress(ldns_buffer* pkt, struct msg_parse* msg,
}
int
-parse_create_msg(ldns_buffer* pkt, struct msg_parse* msg,
+parse_create_msg(sldns_buffer* pkt, struct msg_parse* msg,
struct alloc_cache* alloc, struct query_info* qinf,
struct reply_info** rep, struct regional* region)
{
@@ -413,7 +414,7 @@ parse_create_msg(ldns_buffer* pkt, struct msg_parse* msg,
return 1;
}
-int reply_info_parse(ldns_buffer* pkt, struct alloc_cache* alloc,
+int reply_info_parse(sldns_buffer* pkt, struct alloc_cache* alloc,
struct query_info* qinf, struct reply_info** rep,
struct regional* region, struct edns_data* edns)
{
@@ -428,7 +429,7 @@ int reply_info_parse(ldns_buffer* pkt, struct alloc_cache* alloc,
}
memset(msg, 0, sizeof(*msg));
- ldns_buffer_set_position(pkt, 0);
+ sldns_buffer_set_position(pkt, 0);
if((ret = parse_packet(pkt, msg, region)) != 0) {
return ret;
}
@@ -465,7 +466,7 @@ reply_info_sortref(struct reply_info* rep)
}
void
-reply_info_set_ttls(struct reply_info* rep, uint32_t timenow)
+reply_info_set_ttls(struct reply_info* rep, time_t timenow)
{
size_t i, j;
rep->ttl += timenow;
@@ -496,23 +497,23 @@ reply_info_parsedelete(struct reply_info* rep, struct alloc_cache* alloc)
}
int
-query_info_parse(struct query_info* m, ldns_buffer* query)
+query_info_parse(struct query_info* m, sldns_buffer* query)
{
- uint8_t* q = ldns_buffer_begin(query);
+ uint8_t* q = sldns_buffer_begin(query);
/* minimum size: header + \0 + qtype + qclass */
- if(ldns_buffer_limit(query) < LDNS_HEADER_SIZE + 5)
+ if(sldns_buffer_limit(query) < LDNS_HEADER_SIZE + 5)
return 0;
if(LDNS_OPCODE_WIRE(q) != LDNS_PACKET_QUERY ||
- LDNS_QDCOUNT(q) != 1 || ldns_buffer_position(query) != 0)
+ LDNS_QDCOUNT(q) != 1 || sldns_buffer_position(query) != 0)
return 0;
- ldns_buffer_skip(query, LDNS_HEADER_SIZE);
- m->qname = ldns_buffer_current(query);
+ sldns_buffer_skip(query, LDNS_HEADER_SIZE);
+ m->qname = sldns_buffer_current(query);
if((m->qname_len = query_dname_len(query)) == 0)
return 0; /* parse error */
- if(ldns_buffer_remaining(query) < 4)
+ if(sldns_buffer_remaining(query) < 4)
return 0; /* need qtype, qclass */
- m->qtype = ldns_buffer_read_u16(query);
- m->qclass = ldns_buffer_read_u16(query);
+ m->qtype = sldns_buffer_read_u16(query);
+ m->qclass = sldns_buffer_read_u16(query);
return 1;
}
@@ -764,32 +765,23 @@ void
log_dns_msg(const char* str, struct query_info* qinfo, struct reply_info* rep)
{
/* not particularly fast but flexible, make wireformat and print */
- ldns_buffer* buf = ldns_buffer_new(65535);
+ sldns_buffer* buf = sldns_buffer_new(65535);
struct regional* region = regional_create();
if(!reply_info_encode(qinfo, rep, 0, rep->flags, buf, 0,
region, 65535, 1)) {
log_info("%s: log_dns_msg: out of memory", str);
} else {
- ldns_status s;
- ldns_pkt* pkt = NULL;
- s = ldns_buffer2pkt_wire(&pkt, buf);
- if(s != LDNS_STATUS_OK) {
- log_info("%s: log_dns_msg: ldns parse gave: %s",
- str, ldns_get_errorstr_by_id(s));
+ char* str = sldns_wire2str_pkt(sldns_buffer_begin(buf),
+ sldns_buffer_limit(buf));
+ if(!str) {
+ log_info("%s: log_dns_msg: ldns tostr failed", str);
} else {
- ldns_buffer_clear(buf);
- s = ldns_pkt2buffer_str(buf, pkt);
- if(s != LDNS_STATUS_OK) {
- log_info("%s: log_dns_msg: ldns tostr gave: %s",
- str, ldns_get_errorstr_by_id(s));
- } else {
- log_info("%s %s",
- str, (char*)ldns_buffer_begin(buf));
- }
+ log_info("%s %s",
+ str, (char*)sldns_buffer_begin(buf));
}
- ldns_pkt_free(pkt);
+ free(str);
}
- ldns_buffer_free(buf);
+ sldns_buffer_free(buf);
regional_destroy(region);
}
diff --git a/contrib/unbound/util/data/msgreply.h b/contrib/unbound/util/data/msgreply.h
index a32f2b1..f920108 100644
--- a/contrib/unbound/util/data/msgreply.h
+++ b/contrib/unbound/util/data/msgreply.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -43,6 +43,7 @@
#define UTIL_DATA_MSGREPLY_H
#include "util/storage/lruhash.h"
#include "util/data/packed_rrset.h"
+struct sldns_buffer;
struct comm_reply;
struct alloc_cache;
struct iovec;
@@ -116,21 +117,21 @@ struct reply_info {
*/
uint8_t qdcount;
+ /** 32 bit padding to pad struct member alignment to 64 bits. */
+ uint32_t padding;
+
/**
* TTL of the entire reply (for negative caching).
* only for use when there are 0 RRsets in this message.
* if there are RRsets, check those instead.
*/
- uint32_t ttl;
+ time_t ttl;
/**
* TTL for prefetch. After it has expired, a prefetch is suitable.
* Smaller than the TTL, otherwise the prefetch would not happen.
*/
- uint32_t prefetch_ttl;
-
- /** 32 bit padding to pad struct member alignment to 64 bits. */
- uint32_t padding;
+ time_t prefetch_ttl;
/**
* The security status from DNSSEC validation of this message.
@@ -201,7 +202,7 @@ struct msgreply_entry {
* @param query: the wireformat packet query. starts with ID.
* @return: 0 on format error.
*/
-int query_info_parse(struct query_info* m, ldns_buffer* query);
+int query_info_parse(struct query_info* m, struct sldns_buffer* query);
/**
* Parse query reply.
@@ -218,7 +219,7 @@ int query_info_parse(struct query_info* m, ldns_buffer* query);
* o FORMERR for parse errors.
* o SERVFAIL for memory allocation errors.
*/
-int reply_info_parse(ldns_buffer* pkt, struct alloc_cache* alloc,
+int reply_info_parse(struct sldns_buffer* pkt, struct alloc_cache* alloc,
struct query_info* qinf, struct reply_info** rep,
struct regional* region, struct edns_data* edns);
@@ -237,7 +238,7 @@ int reply_info_parse(ldns_buffer* pkt, struct alloc_cache* alloc,
* and no rrset_ref array in the reply is built up.
* @return 0 if allocation failed.
*/
-int parse_create_msg(ldns_buffer* pkt, struct msg_parse* msg,
+int parse_create_msg(struct sldns_buffer* pkt, struct msg_parse* msg,
struct alloc_cache* alloc, struct query_info* qinf,
struct reply_info** rep, struct regional* region);
@@ -253,7 +254,7 @@ void reply_info_sortref(struct reply_info* rep);
* Also refs must be filled in.
* @param timenow: the current time.
*/
-void reply_info_set_ttls(struct reply_info* rep, uint32_t timenow);
+void reply_info_set_ttls(struct reply_info* rep, time_t timenow);
/**
* Delete reply_info and packed_rrsets (while they are not yet added to the
@@ -322,7 +323,7 @@ struct reply_info* reply_info_copy(struct reply_info* rep,
* Note that TTL will still be relative on return.
* @return false on alloc failure.
*/
-int parse_copy_decompress_rrset(ldns_buffer* pkt, struct msg_parse* msg,
+int parse_copy_decompress_rrset(struct sldns_buffer* pkt, struct msg_parse* msg,
struct rrset_parse *pset, struct regional* region,
struct ub_packed_rrset_key* pk);
diff --git a/contrib/unbound/util/data/packed_rrset.c b/contrib/unbound/util/data/packed_rrset.c
index e1fc2e5..8074685 100644
--- a/contrib/unbound/util/data/packed_rrset.c
+++ b/contrib/unbound/util/data/packed_rrset.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,7 +40,6 @@
*/
#include "config.h"
-#include <ldns/wire2host.h>
#include "util/data/packed_rrset.h"
#include "util/data/dname.h"
#include "util/storage/lookup3.h"
@@ -48,6 +47,9 @@
#include "util/alloc.h"
#include "util/regional.h"
#include "util/net_help.h"
+#include "ldns/rrdef.h"
+#include "ldns/sbuffer.h"
+#include "ldns/wire2str.h"
void
ub_packed_rrset_parsedelete(struct ub_packed_rrset_key* pkey,
@@ -183,7 +185,7 @@ packed_rrset_ptr_fixup(struct packed_rrset_data* data)
data->rr_len = (size_t*)((uint8_t*)data +
sizeof(struct packed_rrset_data));
data->rr_data = (uint8_t**)&(data->rr_len[total]);
- data->rr_ttl = (uint32_t*)&(data->rr_data[total]);
+ data->rr_ttl = (time_t*)&(data->rr_data[total]);
nextrdata = (uint8_t*)&(data->rr_ttl[total]);
for(i=0; i<total; i++) {
data->rr_data[i] = nextrdata;
@@ -205,7 +207,7 @@ get_cname_target(struct ub_packed_rrset_key* rrset, uint8_t** dname,
return;
if(d->rr_len[0] < 3) /* at least rdatalen + 0byte root label */
return;
- len = ldns_read_uint16(d->rr_data[0]);
+ len = sldns_read_uint16(d->rr_data[0]);
if(len != d->rr_len[0] - sizeof(uint16_t))
return;
if(dname_valid(d->rr_data[0]+sizeof(uint16_t), len) != len)
@@ -215,7 +217,7 @@ get_cname_target(struct ub_packed_rrset_key* rrset, uint8_t** dname,
}
void
-packed_rrset_ttl_add(struct packed_rrset_data* data, uint32_t add)
+packed_rrset_ttl_add(struct packed_rrset_data* data, time_t add)
{
size_t i;
size_t total = data->count + data->rrsig_count;
@@ -266,7 +268,53 @@ void log_rrset_key(enum verbosity_value v, const char* str,
ntohs(rrset->rk.type), ntohs(rrset->rk.rrset_class));
}
-uint32_t
+int packed_rr_to_string(struct ub_packed_rrset_key* rrset, size_t i,
+ time_t now, char* dest, size_t dest_len)
+{
+ struct packed_rrset_data* d = (struct packed_rrset_data*)rrset->
+ entry.data;
+ uint8_t rr[65535];
+ size_t rlen = rrset->rk.dname_len + 2 + 2 + 4 + d->rr_len[i];
+ log_assert(dest_len > 0 && dest);
+ if(rlen > dest_len) {
+ dest[0] = 0;
+ return 0;
+ }
+ memmove(rr, rrset->rk.dname, rrset->rk.dname_len);
+ if(i < d->count)
+ memmove(rr+rrset->rk.dname_len, &rrset->rk.type, 2);
+ else sldns_write_uint16(rr+rrset->rk.dname_len, LDNS_RR_TYPE_RRSIG);
+ memmove(rr+rrset->rk.dname_len+2, &rrset->rk.rrset_class, 2);
+ sldns_write_uint32(rr+rrset->rk.dname_len+4,
+ (uint32_t)(d->rr_ttl[i]-now));
+ memmove(rr+rrset->rk.dname_len+8, d->rr_data[i], d->rr_len[i]);
+ if(sldns_wire2str_rr_buf(rr, rlen, dest, dest_len) == -1) {
+ log_info("rrbuf failure %d %s", (int)d->rr_len[i], dest);
+ dest[0] = 0;
+ return 0;
+ }
+ return 1;
+}
+
+void log_packed_rrset(enum verbosity_value v, const char* str,
+ struct ub_packed_rrset_key* rrset)
+{
+ struct packed_rrset_data* d = (struct packed_rrset_data*)rrset->
+ entry.data;
+ char buf[65535];
+ size_t i;
+ if(verbosity < v)
+ return;
+ for(i=0; i<d->count+d->rrsig_count; i++) {
+ if(!packed_rr_to_string(rrset, i, 0, buf, sizeof(buf))) {
+ log_info("%s: rr %d wire2str-error", str, (int)i);
+ } else {
+ log_info("%s: %s", str, buf);
+ }
+ }
+}
+
+time_t
ub_packed_rrset_ttl(struct ub_packed_rrset_key* key)
{
struct packed_rrset_data* d = (struct packed_rrset_data*)key->
@@ -276,7 +324,7 @@ ub_packed_rrset_ttl(struct ub_packed_rrset_key* key)
struct ub_packed_rrset_key*
packed_rrset_copy_region(struct ub_packed_rrset_key* key,
- struct regional* region, uint32_t now)
+ struct regional* region, time_t now)
{
struct ub_packed_rrset_key* ck = regional_alloc(region,
sizeof(struct ub_packed_rrset_key));
@@ -315,7 +363,7 @@ packed_rrset_copy_region(struct ub_packed_rrset_key* key,
struct ub_packed_rrset_key*
packed_rrset_copy_alloc(struct ub_packed_rrset_key* key,
- struct alloc_cache* alloc, uint32_t now)
+ struct alloc_cache* alloc, time_t now)
{
struct packed_rrset_data* fd, *dd;
struct ub_packed_rrset_key* dk = alloc_special_obtain(alloc);
@@ -339,150 +387,3 @@ packed_rrset_copy_alloc(struct ub_packed_rrset_key* key,
packed_rrset_ttl_add(dd, now);
return dk;
}
-
-struct ub_packed_rrset_key*
-ub_packed_rrset_heap_key(ldns_rr_list* rrset)
-{
- struct ub_packed_rrset_key* k;
- ldns_rr* rr;
- if(!rrset)
- return NULL;
- rr = ldns_rr_list_rr(rrset, 0);
- if(!rr)
- return NULL;
- k = (struct ub_packed_rrset_key*)calloc(1, sizeof(*k));
- if(!k)
- return NULL;
- k->rk.type = htons(ldns_rr_get_type(rr));
- k->rk.rrset_class = htons(ldns_rr_get_class(rr));
- k->rk.dname_len = ldns_rdf_size(ldns_rr_owner(rr));
- k->rk.dname = memdup(ldns_rdf_data(ldns_rr_owner(rr)),
- ldns_rdf_size(ldns_rr_owner(rr)));
- if(!k->rk.dname) {
- free(k);
- return NULL;
- }
- return k;
-}
-
-struct packed_rrset_data*
-packed_rrset_heap_data(ldns_rr_list* rrset)
-{
- struct packed_rrset_data* data;
- size_t count=0, rrsig_count=0, len=0, i, j, total;
- uint8_t* nextrdata;
- if(!rrset || ldns_rr_list_rr_count(rrset)==0)
- return NULL;
- /* count sizes */
- for(i=0; i<ldns_rr_list_rr_count(rrset); i++) {
- ldns_rr* rr = ldns_rr_list_rr(rrset, i);
- if(ldns_rr_get_type(rr) == LDNS_RR_TYPE_RRSIG)
- rrsig_count++;
- else count++;
- for(j=0; j<ldns_rr_rd_count(rr); j++)
- len += ldns_rdf_size(ldns_rr_rdf(rr, j));
- len += 2; /* sizeof the rdlength */
- }
-
- /* allocate */
- total = count + rrsig_count;
- len += sizeof(*data) + total*(sizeof(size_t) + sizeof(uint32_t) +
- sizeof(uint8_t*));
- data = (struct packed_rrset_data*)calloc(1, len);
- if(!data)
- return NULL;
-
- /* fill it */
- data->ttl = ldns_rr_ttl(ldns_rr_list_rr(rrset, 0));
- data->count = count;
- data->rrsig_count = rrsig_count;
- data->rr_len = (size_t*)((uint8_t*)data +
- sizeof(struct packed_rrset_data));
- data->rr_data = (uint8_t**)&(data->rr_len[total]);
- data->rr_ttl = (uint32_t*)&(data->rr_data[total]);
- nextrdata = (uint8_t*)&(data->rr_ttl[total]);
-
- /* fill out len, ttl, fields */
- for(i=0; i<total; i++) {
- ldns_rr* rr = ldns_rr_list_rr(rrset, i);
- data->rr_ttl[i] = ldns_rr_ttl(rr);
- if(data->rr_ttl[i] < data->ttl)
- data->ttl = data->rr_ttl[i];
- data->rr_len[i] = 2; /* the rdlength */
- for(j=0; j<ldns_rr_rd_count(rr); j++)
- data->rr_len[i] += ldns_rdf_size(ldns_rr_rdf(rr, j));
- }
-
- /* fixup rest of ptrs */
- for(i=0; i<total; i++) {
- data->rr_data[i] = nextrdata;
- nextrdata += data->rr_len[i];
- }
-
- /* copy data in there */
- for(i=0; i<total; i++) {
- ldns_rr* rr = ldns_rr_list_rr(rrset, i);
- uint16_t rdlen = htons(data->rr_len[i]-2);
- size_t p = sizeof(rdlen);
- memmove(data->rr_data[i], &rdlen, p);
- for(j=0; j<ldns_rr_rd_count(rr); j++) {
- ldns_rdf* rd = ldns_rr_rdf(rr, j);
- memmove(data->rr_data[i]+p, ldns_rdf_data(rd),
- ldns_rdf_size(rd));
- p += ldns_rdf_size(rd);
- }
- }
-
- if(data->rrsig_count && data->count == 0) {
- data->count = data->rrsig_count; /* rrset type is RRSIG */
- data->rrsig_count = 0;
- }
- return data;
-}
-
-/** convert i'th rr to ldns_rr */
-static ldns_rr*
-torr(struct ub_packed_rrset_key* k, ldns_buffer* buf, size_t i)
-{
- struct packed_rrset_data* d = (struct packed_rrset_data*)k->entry.data;
- ldns_rr* rr = NULL;
- size_t pos = 0;
- ldns_status s;
- ldns_buffer_clear(buf);
- ldns_buffer_write(buf, k->rk.dname, k->rk.dname_len);
- if(i < d->count)
- ldns_buffer_write(buf, &k->rk.type, sizeof(uint16_t));
- else ldns_buffer_write_u16(buf, LDNS_RR_TYPE_RRSIG);
- ldns_buffer_write(buf, &k->rk.rrset_class, sizeof(uint16_t));
- ldns_buffer_write_u32(buf, d->rr_ttl[i]);
- ldns_buffer_write(buf, d->rr_data[i], d->rr_len[i]);
- ldns_buffer_flip(buf);
- s = ldns_wire2rr(&rr, ldns_buffer_begin(buf), ldns_buffer_limit(buf),
- &pos, LDNS_SECTION_ANSWER);
- if(s == LDNS_STATUS_OK)
- return rr;
- return NULL;
-}
-
-ldns_rr_list*
-packed_rrset_to_rr_list(struct ub_packed_rrset_key* k, ldns_buffer* buf)
-{
- struct packed_rrset_data* d = (struct packed_rrset_data*)k->entry.data;
- ldns_rr_list* r = ldns_rr_list_new();
- size_t i;
- if(!r)
- return NULL;
- for(i=0; i<d->count+d->rrsig_count; i++) {
- ldns_rr* rr = torr(k, buf, i);
- if(!rr) {
- ldns_rr_list_deep_free(r);
- return NULL;
- }
- if(!ldns_rr_list_push_rr(r, rr)) {
- ldns_rr_free(rr);
- ldns_rr_list_deep_free(r);
- return NULL;
- }
- }
- return r;
-}
diff --git a/contrib/unbound/util/data/packed_rrset.h b/contrib/unbound/util/data/packed_rrset.h
index ad11a80..4b0ef80 100644
--- a/contrib/unbound/util/data/packed_rrset.h
+++ b/contrib/unbound/util/data/packed_rrset.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -42,7 +42,6 @@
#ifndef UTIL_DATA_PACKED_RRSET_H
#define UTIL_DATA_PACKED_RRSET_H
#include "util/storage/lruhash.h"
-#include <ldns/rr.h>
struct alloc_cache;
struct regional;
@@ -215,7 +214,7 @@ enum sec_status {
struct packed_rrset_data {
/** TTL (in seconds like time()) of the rrset.
* Same for all RRs see rfc2181(5.2). */
- uint32_t ttl;
+ time_t ttl;
/** number of rrs. */
size_t count;
/** number of rrsigs, if 0 no rrsigs */
@@ -227,7 +226,7 @@ struct packed_rrset_data {
/** length of every rr's rdata, rr_len[i] is size of rr_data[i]. */
size_t* rr_len;
/** ttl of every rr. rr_ttl[i] ttl of rr i. */
- uint32_t *rr_ttl;
+ time_t *rr_ttl;
/**
* Array of pointers to every rr's rdata.
* The rr_data[i] rdata is stored in uncompressed wireformat.
@@ -281,7 +280,7 @@ size_t packed_rrset_sizeof(struct packed_rrset_data* data);
* @param key: rrset key, with data to examine.
* @return ttl value.
*/
-uint32_t ub_packed_rrset_ttl(struct ub_packed_rrset_key* key);
+time_t ub_packed_rrset_ttl(struct ub_packed_rrset_key* key);
/**
* Calculate memory size of rrset entry. For hash table usage.
@@ -343,7 +342,7 @@ void packed_rrset_ptr_fixup(struct packed_rrset_data* data);
* @param data: rrset data structure. Otherwise correctly filled in.
* @param add: how many seconds to add, pass time(0) for example.
*/
-void packed_rrset_ttl_add(struct packed_rrset_data* data, uint32_t add);
+void packed_rrset_ttl_add(struct packed_rrset_data* data, time_t add);
/**
* Utility procedure to extract CNAME target name from its rdata.
@@ -382,6 +381,27 @@ const char* sec_status_to_string(enum sec_status s);
void log_rrset_key(enum verbosity_value v, const char* str,
struct ub_packed_rrset_key* rrset);
+/**
+ * Convert RR from RRset to string.
+ * @param rrset: structure with data.
+ * @param i: index of rr or RRSIG.
+ * @param now: time that is subtracted from ttl before printout. Can be 0.
+ * @param dest: destination string buffer. Must be nonNULL.
+ * @param dest_len: length of dest buffer (>0).
+ * @return false on failure.
+ */
+int packed_rr_to_string(struct ub_packed_rrset_key* rrset, size_t i,
+ time_t now, char* dest, size_t dest_len);
+
+/**
+ * Print the string with prefix, one rr per line.
+ * @param v: at what verbosity level to print this.
+ * @param str: string of message.
+ * @param rrset: with name, and rdata, and rrsigs.
+ */
+void log_packed_rrset(enum verbosity_value v, const char* str,
+ struct ub_packed_rrset_key* rrset);
+
/**
* Allocate rrset in region - no more locks needed
* @param key: a (just from rrset cache looked up) rrset key + valid,
@@ -392,7 +412,7 @@ void log_rrset_key(enum verbosity_value v, const char* str,
*/
struct ub_packed_rrset_key* packed_rrset_copy_region(
struct ub_packed_rrset_key* key, struct regional* region,
- uint32_t now);
+ time_t now);
/**
* Allocate rrset with malloc (from region or you are holding the lock).
@@ -403,32 +423,6 @@ struct ub_packed_rrset_key* packed_rrset_copy_region(
*/
struct ub_packed_rrset_key* packed_rrset_copy_alloc(
struct ub_packed_rrset_key* key, struct alloc_cache* alloc,
- uint32_t now);
-
-/**
- * Create a ub_packed_rrset_key allocated on the heap.
- * It therefore does not have the correct ID value, and cannot be used
- * inside the cache. It can be used in storage outside of the cache.
- * Keys for the cache have to be obtained from alloc.h .
- * @param rrset: the ldns rr set.
- * @return key allocated or NULL on failure.
- */
-struct ub_packed_rrset_key* ub_packed_rrset_heap_key(ldns_rr_list* rrset);
-
-/**
- * Create packed_rrset data on the heap.
- * @param rrset: the ldns rr set with the data to copy.
- * @return data allocated or NULL on failure.
- */
-struct packed_rrset_data* packed_rrset_heap_data(ldns_rr_list* rrset);
-
-/**
- * Convert packed rrset to ldns rr list.
- * @param rrset: packed rrset.
- * @param buf: scratch buffer.
- * @return rr list or NULL on failure.
- */
-ldns_rr_list* packed_rrset_to_rr_list(struct ub_packed_rrset_key* rrset,
- ldns_buffer* buf);
+ time_t now);
#endif /* UTIL_DATA_PACKED_RRSET_H */
diff --git a/contrib/unbound/util/fptr_wlist.c b/contrib/unbound/util/fptr_wlist.c
index 2d5ba5c..7aa7736 100644
--- a/contrib/unbound/util/fptr_wlist.c
+++ b/contrib/unbound/util/fptr_wlist.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -103,6 +103,7 @@ fptr_whitelist_comm_timer(void (*fptr)(void*))
{
if(fptr == &pending_udp_timer_cb) return 1;
else if(fptr == &outnet_tcptimer) return 1;
+ else if(fptr == &pending_udp_timer_delay_cb) return 1;
else if(fptr == &worker_stat_timer_cb) return 1;
else if(fptr == &worker_probe_timer_cb) return 1;
#ifdef UB_ON_WINDOWS
@@ -387,6 +388,7 @@ int fptr_whitelist_mesh_cb(mesh_cb_func_t fptr)
{
if(fptr == &libworker_fg_done_cb) return 1;
else if(fptr == &libworker_bg_done_cb) return 1;
+ else if(fptr == &libworker_event_done_cb) return 1;
else if(fptr == &probe_answer_cb) return 1;
return 0;
}
diff --git a/contrib/unbound/util/fptr_wlist.h b/contrib/unbound/util/fptr_wlist.h
index d204e92..b2925d6 100644
--- a/contrib/unbound/util/fptr_wlist.h
+++ b/contrib/unbound/util/fptr_wlist.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/iana_ports.inc b/contrib/unbound/util/iana_ports.inc
index c2c7a21..2522030 100644
--- a/contrib/unbound/util/iana_ports.inc
+++ b/contrib/unbound/util/iana_ports.inc
@@ -33,7 +33,6 @@
48,
49,
50,
-51,
52,
53,
54,
@@ -694,9 +693,6 @@
1026,
1027,
1029,
-1030,
-1031,
-1032,
1033,
1034,
1035,
@@ -3968,6 +3964,7 @@
4753,
4784,
4785,
+4789,
4800,
4801,
4802,
@@ -4095,6 +4092,7 @@
5111,
5112,
5116,
+5120,
5133,
5136,
5137,
@@ -4173,6 +4171,7 @@
5361,
5362,
5363,
+5364,
5397,
5398,
5399,
@@ -4276,6 +4275,7 @@
5681,
5682,
5683,
+5684,
5688,
5689,
5713,
@@ -4418,6 +4418,7 @@
6350,
6355,
6360,
+6363,
6370,
6382,
6389,
@@ -4479,6 +4480,8 @@
6627,
6628,
6633,
+6634,
+6653,
6657,
6670,
6671,
@@ -4573,9 +4576,11 @@
7170,
7171,
7174,
+7181,
7200,
7201,
7227,
+7235,
7262,
7272,
7273,
@@ -4599,6 +4604,7 @@
7401,
7402,
7410,
+7411,
7421,
7426,
7427,
@@ -4794,7 +4800,6 @@
8614,
8675,
8686,
-8699,
8732,
8733,
8763,
@@ -4985,6 +4990,7 @@
10007,
10008,
10009,
+10023,
10050,
10051,
10080,
@@ -5025,7 +5031,9 @@
10990,
11000,
11001,
+11095,
11106,
+11108,
11111,
11112,
11161,
@@ -5044,6 +5052,7 @@
11371,
11600,
11720,
+11723,
11751,
11796,
11876,
@@ -5285,7 +5294,10 @@
29167,
30001,
30002,
+30003,
+30004,
30260,
+30832,
30999,
31029,
31416,
@@ -5324,6 +5336,8 @@
34963,
34964,
34980,
+35001,
+35004,
35355,
36001,
36865,
@@ -5371,6 +5385,7 @@
47624,
47806,
47808,
+47809,
48000,
48001,
48002,
@@ -5379,3 +5394,4 @@
48129,
48556,
48619,
+48653,
diff --git a/contrib/unbound/util/locks.c b/contrib/unbound/util/locks.c
index 425f9b9..509895d 100644
--- a/contrib/unbound/util/locks.c
+++ b/contrib/unbound/util/locks.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/locks.h b/contrib/unbound/util/locks.h
index 91be5c3..d63e5f0 100644
--- a/contrib/unbound/util/locks.h
+++ b/contrib/unbound/util/locks.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UTIL_LOCKS_H
diff --git a/contrib/unbound/util/log.c b/contrib/unbound/util/log.c
index 8c09c7c..39d3118 100644
--- a/contrib/unbound/util/log.c
+++ b/contrib/unbound/util/log.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
@@ -40,6 +40,8 @@
#include "config.h"
#include "util/log.h"
#include "util/locks.h"
+#include "ldns/sbuffer.h"
+#include <stdarg.h>
#ifdef HAVE_TIME_H
#include <time.h>
#endif
@@ -73,7 +75,7 @@ static const char* ident="unbound";
static int logging_to_syslog = 0;
#endif /* HAVE_SYSLOG_H */
/** time to print in log, if NULL, use time(2) */
-static uint32_t* log_now = NULL;
+static time_t* log_now = NULL;
/** print time in UTC or in secondsfrom1970 */
static int log_time_asc = 0;
@@ -151,7 +153,7 @@ void log_ident_set(const char* id)
ident = id;
}
-void log_set_time(uint32_t* t)
+void log_set_time(time_t* t)
{
log_now = t;
}
@@ -228,7 +230,7 @@ log_vmsg(int pri, const char* type,
ident, (int)getpid(), tid?*tid:0, type, message);
} else
#endif
- fprintf(logfile, "[%u] %s[%d:%x] %s: %s\n", (unsigned)now,
+ fprintf(logfile, "[" ARG_LL "d] %s[%d:%x] %s: %s\n", (long long)now,
ident, (int)getpid(), tid?*tid:0, type, message);
#ifdef UB_ON_WINDOWS
/* line buffering does not work on windows */
@@ -345,11 +347,11 @@ log_hex(const char* msg, void* data, size_t length)
log_hex_f(verbosity, msg, data, length);
}
-void log_buf(enum verbosity_value level, const char* msg, ldns_buffer* buf)
+void log_buf(enum verbosity_value level, const char* msg, sldns_buffer* buf)
{
if(verbosity < level)
return;
- log_hex_f(level, msg, ldns_buffer_begin(buf), ldns_buffer_limit(buf));
+ log_hex_f(level, msg, sldns_buffer_begin(buf), sldns_buffer_limit(buf));
}
#ifdef USE_WINSOCK
diff --git a/contrib/unbound/util/log.h b/contrib/unbound/util/log.h
index 270ffc5..ea283da 100644
--- a/contrib/unbound/util/log.h
+++ b/contrib/unbound/util/log.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -41,7 +41,7 @@
#ifndef UTIL_LOG_H
#define UTIL_LOG_H
-#include <ldns/buffer.h>
+struct sldns_buffer;
/**
* verbosity value:
@@ -108,7 +108,7 @@ void log_ident_set(const char* id);
* @param t: the point is copied and used to find the time.
* if NULL, time(2) is used.
*/
-void log_set_time(uint32_t* t);
+void log_set_time(time_t* t);
/**
* Set if the time value is printed ascii or decimal in log entries.
@@ -149,13 +149,13 @@ void log_warn(const char* format, ...) ATTR_FORMAT(printf, 1, 2);
void log_hex(const char* msg, void* data, size_t length);
/**
- * Easy alternative for log_hex, takes a ldns_buffer.
+ * Easy alternative for log_hex, takes a sldns_buffer.
* @param level: verbosity level for this message, compared to global
* verbosity setting.
* @param msg: string desc to print
* @param buf: the buffer.
*/
-void log_buf(enum verbosity_value level, const char* msg, ldns_buffer* buf);
+void log_buf(enum verbosity_value level, const char* msg, struct sldns_buffer* buf);
/**
* Log fatal error message, and exit the current process.
diff --git a/contrib/unbound/util/mini_event.c b/contrib/unbound/util/mini_event.c
index f66214d..40dca37 100644
--- a/contrib/unbound/util/mini_event.c
+++ b/contrib/unbound/util/mini_event.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
@@ -79,13 +79,13 @@ settime(struct event_base* base)
return -1;
}
#ifndef S_SPLINT_S
- *base->time_secs = (uint32_t)base->time_tv->tv_sec;
+ *base->time_secs = (time_t)base->time_tv->tv_sec;
#endif
return 0;
}
/** create event base */
-void *event_init(uint32_t* time_secs, struct timeval* time_tv)
+void *event_init(time_t* time_secs, struct timeval* time_tv)
{
struct event_base* base = (struct event_base*)malloc(
sizeof(struct event_base));
diff --git a/contrib/unbound/util/mini_event.h b/contrib/unbound/util/mini_event.h
index 248468a..58bbc80 100644
--- a/contrib/unbound/util/mini_event.h
+++ b/contrib/unbound/util/mini_event.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -103,7 +103,7 @@ struct event_base
/** if we need to exit */
int need_to_exit;
/** where to store time in seconds */
- uint32_t* time_secs;
+ time_t* time_secs;
/** where to store time in microseconds */
struct timeval* time_tv;
};
@@ -134,7 +134,7 @@ struct event {
/* function prototypes (some are as they appear in event.h) */
/** create event base */
-void *event_init(uint32_t* time_secs, struct timeval* time_tv);
+void *event_init(time_t* time_secs, struct timeval* time_tv);
/** get version */
const char *event_get_version(void);
/** get polling method, select */
diff --git a/contrib/unbound/util/module.c b/contrib/unbound/util/module.c
index b45ec6f..09e276c 100644
--- a/contrib/unbound/util/module.c
+++ b/contrib/unbound/util/module.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
diff --git a/contrib/unbound/util/module.h b/contrib/unbound/util/module.h
index 8fa4ec2..dace1cf 100644
--- a/contrib/unbound/util/module.h
+++ b/contrib/unbound/util/module.h
@@ -21,22 +21,134 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
*
* This file contains the interface for DNS handling modules.
+ *
+ * The module interface uses the DNS modules as state machines. The
+ * state machines are activated in sequence to operate on queries. Once
+ * they are done, the reply is passed back. In the usual setup the mesh
+ * is the caller of the state machines and once things are done sends replies
+ * and invokes result callbacks.
+ *
+ * The module provides a number of functions, listed in the module_func_block.
+ * The module is inited and destroyed and memory usage queries, for the
+ * module as a whole, for entire-module state (such as a cache). And per-query
+ * functions are called, operate to move the state machine and cleanup of
+ * the per-query state.
+ *
+ * Most per-query state should simply be allocated in the query region.
+ * This is destroyed at the end of the query.
+ *
+ * The module environment contains services and information and caches
+ * shared by the modules and the rest of the system. It also contains
+ * function pointers for module-specific tasks (like sending queries).
+ *
+ * *** Example module calls for a normal query
+ *
+ * In this example, the query does not need recursion, all the other data
+ * can be found in the cache. This makes the example shorter.
+ *
+ * At the start of the program the iterator module is initialised.
+ * The iterator module sets up its global state, such as donotquery lists
+ * and private address trees.
+ *
+ * A query comes in, and a mesh entry is created for it. The mesh
+ * starts the resolution process. The validator module is the first
+ * in the list of modules, and it is started on this new query. The
+ * operate() function is called. The validator decides it needs not do
+ * anything yet until there is a result and returns wait_module, that
+ * causes the next module in the list to be started.
+ *
+ * The next module is the iterator. It is started on the passed query and
+ * decides to perform a lookup. For this simple example, the delegation
+ * point information is available, and all the iterator wants to do is
+ * send a UDP query. The iterator uses env.send_query() to send the
+ * query. Then the iterator suspends (returns from the operate call).
+ *
+ * When the UDP reply comes back (and on errors and timeouts), the
+ * operate function is called for the query, on the iterator module,
+ * with the event that there is a reply. The iterator decides that this
+ * is enough, the work is done. It returns the value finished from the
+ * operate call, which causes the previous module to be started.
+ *
+ * The previous module, the validator module, is started with the event
+ * that the iterator module is done. The validator decides to validate
+ * the query. Once it is done (which could take recursive lookups, but
+ * in this example no recursive lookups are needed), it returns from the
+ * operate function with finished.
+ *
+ * There is no previous module from the validator module, and the mesh
+ * takes this to mean that the query is finally done. The mesh invokes
+ * callbacks and sends packets to queriers.
+ *
+ * If other modules had been waiting (recursively) on the answer to this
+ * query, then the mesh will tell them about it. It calls the inform_super
+ * routine on all the waiting modules, and once that is done it calls all of
+ * them with the operate() call. During inform_super the query that is done
+ * still exists and information can be copied from it (but the module should
+ * not really re-entry codepoints and services). During the operate call
+ * the modules can use stored state to continue operation with the results.
+ * (network buffers are used to contain the answer packet during the
+ * inform_super phase, but after that the network buffers will be cleared
+ * of their contents so that other tasks can be performed).
+ *
+ * *** Example module calls for recursion
+ *
+ * A module is called in operate, and it decides that it wants to perform
+ * recursion. That is, it wants the full state-machine-list to operate on
+ * a different query. It calls env.attach_sub() to create a new query state.
+ * The routine returns the newly created state, and potentially the module
+ * can edit the module-states for the newly created query (i.e. pass along
+ * some information, like delegation points). The module then suspends,
+ * returns from the operate routine.
+ *
+ * The mesh meanwhile will have the newly created query (or queries) on
+ * a waiting list, and will call operate() on this query (or queries).
+ * It starts again at the start of the module list for them. The query
+ * (or queries) continue to operate their state machines, until they are
+ * done. When they are done the mesh calls inform_super on the module that
+ * wanted the recursion. After that the mesh calls operate() on the module
+ * that wanted to do the recursion, and during this phase the module could,
+ * for example, decide to create more recursions.
+ *
+ * If the module decides it no longer wants the recursive information
+ * it can call detach_subs. Those queries will still run to completion,
+ * potentially filling the cache with information. Inform_super is not
+ * called any more.
+ *
+ * The iterator module will fetch items from the cache, so a recursion
+ * attempt may complete very quickly if the item is in cache. The calling
+ * module has to wait for completion or eventual timeout. A recursive query
+ * that times out returns a servfail rcode (servfail is also returned for
+ * other errors during the lookup).
+ *
+ * Results are passed in the qstate, the rcode member is used to pass
+ * errors without requiring memory allocation, so that the code can continue
+ * in out-of-memory conditions. If the rcode member is 0 (NOERROR) then
+ * the dns_msg entry contains a filled out message. This message may
+ * also contain an rcode that is nonzero, but in this case additional
+ * information (query, additional) can be passed along.
+ *
+ * The rcode and dns_msg are used to pass the result from the the rightmost
+ * module towards the leftmost modules and then towards the user.
+ *
+ * If you want to avoid recursion-cycles where queries need other queries
+ * that need the first one, use detect_cycle() to see if that will happen.
+ *
*/
#ifndef UTIL_MODULE_H
@@ -44,6 +156,7 @@
#include "util/storage/lruhash.h"
#include "util/data/msgreply.h"
#include "util/data/msgparse.h"
+struct sldns_buffer;
struct alloc_cache;
struct rrset_cache;
struct key_cache;
@@ -176,7 +289,7 @@ struct module_env {
/** region for temporary usage. May be cleared after operate() call. */
struct regional* scratch;
/** buffer for temporary usage. May be cleared after operate() call. */
- ldns_buffer* scratch_buffer;
+ struct sldns_buffer* scratch_buffer;
/** internal data for daemon - worker thread. */
struct worker* worker;
/** mesh area with query state dependencies */
@@ -186,7 +299,7 @@ struct module_env {
/** random table to generate random numbers */
struct ub_randstate* rnd;
/** time in seconds, converted to integer */
- uint32_t* now;
+ time_t* now;
/** time in microseconds. Relatively recent. */
struct timeval* now_tv;
/** is validation required for messages, controls client-facing
@@ -309,7 +422,7 @@ struct module_qstate {
/** mesh related information for this query */
struct mesh_state* mesh_info;
/** how many seconds before expiry is this prefetched (0 if not) */
- uint32_t prefetch_leeway;
+ time_t prefetch_leeway;
};
/**
diff --git a/contrib/unbound/util/net_help.c b/contrib/unbound/util/net_help.c
index 64bd876..7f6daab 100644
--- a/contrib/unbound/util/net_help.c
+++ b/contrib/unbound/util/net_help.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
@@ -38,12 +38,13 @@
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "util/net_help.h"
#include "util/log.h"
#include "util/data/dname.h"
#include "util/module.h"
#include "util/regional.h"
+#include "ldns/parseutil.h"
+#include "ldns/wire2str.h"
#include <fcntl.h>
#ifdef HAVE_OPENSSL_SSL_H
#include <openssl/ssl.h>
@@ -159,7 +160,7 @@ log_addr(enum verbosity_value v, const char* str,
default: break;
}
if(inet_ntop(af, sinaddr, dest, (socklen_t)sizeof(dest)) == 0) {
- strncpy(dest, "(inet_ntop error)", sizeof(dest));
+ (void)strlcpy(dest, "(inet_ntop error)", sizeof(dest));
}
dest[sizeof(dest)-1] = 0;
port = ntohs(((struct sockaddr_in*)addr)->sin_port);
@@ -180,7 +181,7 @@ extstrtoaddr(const char* str, struct sockaddr_storage* addr,
if(s-str >= MAX_ADDR_STRLEN) {
return 0;
}
- strncpy(buf, str, MAX_ADDR_STRLEN);
+ (void)strlcpy(buf, str, sizeof(buf));
buf[s-str] = 0;
port = atoi(s+1);
if(port == 0 && strcmp(s+1,"0")!=0) {
@@ -210,7 +211,7 @@ ipstrtoaddr(const char* ip, int port, struct sockaddr_storage* addr,
if((s=strchr(ip, '%'))) { /* ip6%interface, rfc 4007 */
if(s-ip >= MAX_ADDR_STRLEN)
return 0;
- strncpy(buf, ip, MAX_ADDR_STRLEN);
+ (void)strlcpy(buf, ip, sizeof(buf));
buf[s-ip]=0;
sa->sin6_scope_id = (uint32_t)atoi(s+1);
ip = buf;
@@ -280,15 +281,15 @@ log_nametypeclass(enum verbosity_value v, const char* str, uint8_t* name,
else if(type == LDNS_RR_TYPE_MAILB) ts = "MAILB";
else if(type == LDNS_RR_TYPE_MAILA) ts = "MAILA";
else if(type == LDNS_RR_TYPE_ANY) ts = "ANY";
- else if(ldns_rr_descript(type) && ldns_rr_descript(type)->_name)
- ts = ldns_rr_descript(type)->_name;
+ else if(sldns_rr_descript(type) && sldns_rr_descript(type)->_name)
+ ts = sldns_rr_descript(type)->_name;
else {
snprintf(t, sizeof(t), "TYPE%d", (int)type);
ts = t;
}
- if(ldns_lookup_by_id(ldns_rr_classes, (int)dclass) &&
- ldns_lookup_by_id(ldns_rr_classes, (int)dclass)->name)
- cs = ldns_lookup_by_id(ldns_rr_classes, (int)dclass)->name;
+ if(sldns_lookup_by_id(sldns_rr_classes, (int)dclass) &&
+ sldns_lookup_by_id(sldns_rr_classes, (int)dclass)->name)
+ cs = sldns_lookup_by_id(sldns_rr_classes, (int)dclass)->name;
else {
snprintf(c, sizeof(c), "CLASS%d", (int)dclass);
cs = c;
@@ -316,7 +317,7 @@ void log_name_addr(enum verbosity_value v, const char* str, uint8_t* zone,
default: break;
}
if(inet_ntop(af, sinaddr, dest, (socklen_t)sizeof(dest)) == 0) {
- strncpy(dest, "(inet_ntop error)", sizeof(dest));
+ (void)strlcpy(dest, "(inet_ntop error)", sizeof(dest));
}
dest[sizeof(dest)-1] = 0;
port = ntohs(((struct sockaddr_in*)addr)->sin_port);
diff --git a/contrib/unbound/util/net_help.h b/contrib/unbound/util/net_help.h
index 05b5087..b92dd40 100644
--- a/contrib/unbound/util/net_help.h
+++ b/contrib/unbound/util/net_help.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/netevent.c b/contrib/unbound/util/netevent.c
index c5a7d80..189aaa4 100644
--- a/contrib/unbound/util/netevent.c
+++ b/contrib/unbound/util/netevent.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -39,11 +39,12 @@
* This file contains event notification functions.
*/
#include "config.h"
-#include <ldns/wire2host.h>
#include "util/netevent.h"
#include "util/log.h"
#include "util/net_help.h"
#include "util/fptr_wlist.h"
+#include "ldns/pkthdr.h"
+#include "ldns/sbuffer.h"
#ifdef HAVE_OPENSSL_SSL_H
#include <openssl/ssl.h>
#endif
@@ -122,7 +123,7 @@ struct internal_base {
/** libevent event_base type. */
struct event_base* base;
/** seconds time pointer points here */
- uint32_t secs;
+ time_t secs;
/** timeval with current time */
struct timeval now;
/** the event used for slow_accept timeouts */
@@ -171,7 +172,7 @@ comm_base_now(struct comm_base* b)
if(gettimeofday(&b->eb->now, NULL) < 0) {
log_err("gettimeofday: %s", strerror(errno));
}
- b->eb->secs = (uint32_t)b->eb->now.tv_sec;
+ b->eb->secs = (time_t)b->eb->now.tv_sec;
}
#endif /* USE_MINI_EVENT */
@@ -234,6 +235,23 @@ comm_base_create(int sigs)
return b;
}
+struct comm_base*
+comm_base_create_event(struct event_base* base)
+{
+ struct comm_base* b = (struct comm_base*)calloc(1,
+ sizeof(struct comm_base));
+ if(!b)
+ return NULL;
+ b->eb = (struct internal_base*)calloc(1, sizeof(struct internal_base));
+ if(!b->eb) {
+ free(b);
+ return NULL;
+ }
+ b->eb->base = base;
+ comm_base_now(b);
+ return b;
+}
+
void
comm_base_delete(struct comm_base* b)
{
@@ -258,7 +276,22 @@ comm_base_delete(struct comm_base* b)
}
void
-comm_base_timept(struct comm_base* b, uint32_t** tt, struct timeval** tv)
+comm_base_delete_no_base(struct comm_base* b)
+{
+ if(!b)
+ return;
+ if(b->eb->slow_accept_enabled) {
+ if(event_del(&b->eb->slow_accept) != 0) {
+ log_err("could not event_del slow_accept");
+ }
+ }
+ b->eb->base = NULL;
+ free(b->eb);
+ free(b);
+}
+
+void
+comm_base_timept(struct comm_base* b, time_t** tt, struct timeval** tv)
{
*tt = &b->eb->secs;
*tv = &b->eb->now;
@@ -320,6 +353,10 @@ udp_send_errno_needs_log(struct sockaddr* addr, socklen_t addrlen)
break;
}
#endif
+ /* permission denied is gotten for every send if the
+ * network is disconnected (on some OS), squelch it */
+ if(errno == EPERM && verbosity < VERB_DETAIL)
+ return 0;
/* squelch errors where people deploy AAAA ::ffff:bla for
* authority servers, which we try for intranets. */
if(errno == EINVAL && addr_is_ip4mapped(
@@ -342,18 +379,18 @@ int tcp_connect_errno_needs_log(struct sockaddr* addr, socklen_t addrlen)
/* send a UDP reply */
int
-comm_point_send_udp_msg(struct comm_point *c, ldns_buffer* packet,
+comm_point_send_udp_msg(struct comm_point *c, sldns_buffer* packet,
struct sockaddr* addr, socklen_t addrlen)
{
ssize_t sent;
log_assert(c->fd != -1);
#ifdef UNBOUND_DEBUG
- if(ldns_buffer_remaining(packet) == 0)
+ if(sldns_buffer_remaining(packet) == 0)
log_err("error: send empty UDP packet");
#endif
log_assert(addr && addrlen > 0);
- sent = sendto(c->fd, (void*)ldns_buffer_begin(packet),
- ldns_buffer_remaining(packet), 0,
+ sent = sendto(c->fd, (void*)sldns_buffer_begin(packet),
+ sldns_buffer_remaining(packet), 0,
addr, addrlen);
if(sent == -1) {
if(!udp_send_errno_needs_log(addr, addrlen))
@@ -367,9 +404,9 @@ comm_point_send_udp_msg(struct comm_point *c, ldns_buffer* packet,
log_addr(VERB_OPS, "remote address is",
(struct sockaddr_storage*)addr, addrlen);
return 0;
- } else if((size_t)sent != ldns_buffer_remaining(packet)) {
+ } else if((size_t)sent != sldns_buffer_remaining(packet)) {
log_err("sent %d in place of %d bytes",
- (int)sent, (int)ldns_buffer_remaining(packet));
+ (int)sent, (int)sldns_buffer_remaining(packet));
return 0;
}
return 1;
@@ -387,7 +424,7 @@ static void p_ancil(const char* str, struct comm_reply* r)
char buf[1024];
if(inet_ntop(AF_INET6, &r->pktinfo.v6info.ipi6_addr,
buf, (socklen_t)sizeof(buf)) == 0) {
- strncpy(buf, "(inet_ntop error)", sizeof(buf));
+ (void)strlcpy(buf, "(inet_ntop error)", sizeof(buf));
}
buf[sizeof(buf)-1]=0;
log_info("%s: %s %d", str, buf, r->pktinfo.v6info.ipi6_ifindex);
@@ -396,13 +433,13 @@ static void p_ancil(const char* str, struct comm_reply* r)
char buf1[1024], buf2[1024];
if(inet_ntop(AF_INET, &r->pktinfo.v4info.ipi_addr,
buf1, (socklen_t)sizeof(buf1)) == 0) {
- strncpy(buf1, "(inet_ntop error)", sizeof(buf1));
+ (void)strlcpy(buf1, "(inet_ntop error)", sizeof(buf1));
}
buf1[sizeof(buf1)-1]=0;
#ifdef HAVE_STRUCT_IN_PKTINFO_IPI_SPEC_DST
if(inet_ntop(AF_INET, &r->pktinfo.v4info.ipi_spec_dst,
buf2, (socklen_t)sizeof(buf2)) == 0) {
- strncpy(buf2, "(inet_ntop error)", sizeof(buf2));
+ (void)strlcpy(buf2, "(inet_ntop error)", sizeof(buf2));
}
buf2[sizeof(buf2)-1]=0;
#else
@@ -414,7 +451,7 @@ static void p_ancil(const char* str, struct comm_reply* r)
char buf1[1024];
if(inet_ntop(AF_INET, &r->pktinfo.v4addr,
buf1, (socklen_t)sizeof(buf1)) == 0) {
- strncpy(buf1, "(inet_ntop error)", sizeof(buf1));
+ (void)strlcpy(buf1, "(inet_ntop error)", sizeof(buf1));
}
buf1[sizeof(buf1)-1]=0;
log_info("%s: %s", str, buf1);
@@ -425,7 +462,7 @@ static void p_ancil(const char* str, struct comm_reply* r)
/** send a UDP reply over specified interface*/
static int
-comm_point_send_udp_msg_if(struct comm_point *c, ldns_buffer* packet,
+comm_point_send_udp_msg_if(struct comm_point *c, sldns_buffer* packet,
struct sockaddr* addr, socklen_t addrlen, struct comm_reply* r)
{
#if defined(AF_INET6) && defined(IPV6_PKTINFO) && defined(HAVE_SENDMSG)
@@ -439,15 +476,15 @@ comm_point_send_udp_msg_if(struct comm_point *c, ldns_buffer* packet,
log_assert(c->fd != -1);
#ifdef UNBOUND_DEBUG
- if(ldns_buffer_remaining(packet) == 0)
+ if(sldns_buffer_remaining(packet) == 0)
log_err("error: send empty UDP packet");
#endif
log_assert(addr && addrlen > 0);
msg.msg_name = addr;
msg.msg_namelen = addrlen;
- iov[0].iov_base = ldns_buffer_begin(packet);
- iov[0].iov_len = ldns_buffer_remaining(packet);
+ iov[0].iov_base = sldns_buffer_begin(packet);
+ iov[0].iov_len = sldns_buffer_remaining(packet);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_control = control;
@@ -507,9 +544,9 @@ comm_point_send_udp_msg_if(struct comm_point *c, ldns_buffer* packet,
log_addr(VERB_OPS, "remote address is",
(struct sockaddr_storage*)addr, addrlen);
return 0;
- } else if((size_t)sent != ldns_buffer_remaining(packet)) {
+ } else if((size_t)sent != sldns_buffer_remaining(packet)) {
log_err("sent %d in place of %d bytes",
- (int)sent, (int)ldns_buffer_remaining(packet));
+ (int)sent, (int)sldns_buffer_remaining(packet));
return 0;
}
return 1;
@@ -546,14 +583,14 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg)
log_assert(rep.c && rep.c->buffer && rep.c->fd == fd);
comm_base_now(rep.c->ev->base);
for(i=0; i<NUM_UDP_PER_SELECT; i++) {
- ldns_buffer_clear(rep.c->buffer);
+ sldns_buffer_clear(rep.c->buffer);
rep.addrlen = (socklen_t)sizeof(rep.addr);
log_assert(fd != -1);
- log_assert(ldns_buffer_remaining(rep.c->buffer) > 0);
+ log_assert(sldns_buffer_remaining(rep.c->buffer) > 0);
msg.msg_name = &rep.addr;
msg.msg_namelen = (socklen_t)sizeof(rep.addr);
- iov[0].iov_base = ldns_buffer_begin(rep.c->buffer);
- iov[0].iov_len = ldns_buffer_remaining(rep.c->buffer);
+ iov[0].iov_base = sldns_buffer_begin(rep.c->buffer);
+ iov[0].iov_len = sldns_buffer_remaining(rep.c->buffer);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
msg.msg_control = ancil;
@@ -569,8 +606,8 @@ comm_point_udp_ancil_callback(int fd, short event, void* arg)
return;
}
rep.addrlen = msg.msg_namelen;
- ldns_buffer_skip(rep.c->buffer, rcv);
- ldns_buffer_flip(rep.c->buffer);
+ sldns_buffer_skip(rep.c->buffer, rcv);
+ sldns_buffer_flip(rep.c->buffer);
rep.srctype = 0;
#ifndef S_SPLINT_S
for(cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
@@ -634,12 +671,12 @@ comm_point_udp_callback(int fd, short event, void* arg)
log_assert(rep.c && rep.c->buffer && rep.c->fd == fd);
comm_base_now(rep.c->ev->base);
for(i=0; i<NUM_UDP_PER_SELECT; i++) {
- ldns_buffer_clear(rep.c->buffer);
+ sldns_buffer_clear(rep.c->buffer);
rep.addrlen = (socklen_t)sizeof(rep.addr);
log_assert(fd != -1);
- log_assert(ldns_buffer_remaining(rep.c->buffer) > 0);
- rcv = recvfrom(fd, (void*)ldns_buffer_begin(rep.c->buffer),
- ldns_buffer_remaining(rep.c->buffer), 0,
+ log_assert(sldns_buffer_remaining(rep.c->buffer) > 0);
+ rcv = recvfrom(fd, (void*)sldns_buffer_begin(rep.c->buffer),
+ sldns_buffer_remaining(rep.c->buffer), 0,
(struct sockaddr*)&rep.addr, &rep.addrlen);
if(rcv == -1) {
#ifndef USE_WINSOCK
@@ -655,8 +692,8 @@ comm_point_udp_callback(int fd, short event, void* arg)
#endif
return;
}
- ldns_buffer_skip(rep.c->buffer, rcv);
- ldns_buffer_flip(rep.c->buffer);
+ sldns_buffer_skip(rep.c->buffer, rcv);
+ sldns_buffer_flip(rep.c->buffer);
rep.srctype = 0;
fptr_ok(fptr_whitelist_comm_point(rep.c->callback));
if((*rep.c->callback)(rep.c, rep.c->cb_arg, NETEVENT_NOERROR, &rep)) {
@@ -676,7 +713,7 @@ setup_tcp_handler(struct comm_point* c, int fd)
{
log_assert(c->type == comm_tcp);
log_assert(c->fd == -1);
- ldns_buffer_clear(c->buffer);
+ sldns_buffer_clear(c->buffer);
c->tcp_is_reading = 1;
c->tcp_byte_count = 0;
comm_point_start_listening(c, fd, TCP_QUERY_TIMEOUT);
@@ -878,7 +915,7 @@ static void
tcp_callback_writer(struct comm_point* c)
{
log_assert(c->type == comm_tcp);
- ldns_buffer_clear(c->buffer);
+ sldns_buffer_clear(c->buffer);
if(c->tcp_do_toggle_rw)
c->tcp_is_reading = 1;
c->tcp_byte_count = 0;
@@ -892,7 +929,7 @@ static void
tcp_callback_reader(struct comm_point* c)
{
log_assert(c->type == comm_tcp || c->type == comm_local);
- ldns_buffer_flip(c->buffer);
+ sldns_buffer_flip(c->buffer);
if(c->tcp_do_toggle_rw)
c->tcp_is_reading = 0;
c->tcp_byte_count = 0;
@@ -985,7 +1022,7 @@ ssl_handle_read(struct comm_point* c)
if(c->tcp_byte_count < sizeof(uint16_t)) {
/* read length bytes */
ERR_clear_error();
- if((r=SSL_read(c->ssl, (void*)ldns_buffer_at(c->buffer,
+ if((r=SSL_read(c->ssl, (void*)sldns_buffer_at(c->buffer,
c->tcp_byte_count), (int)(sizeof(uint16_t) -
c->tcp_byte_count))) <= 0) {
int want = SSL_get_error(c->ssl, r);
@@ -1009,24 +1046,24 @@ ssl_handle_read(struct comm_point* c)
c->tcp_byte_count += r;
if(c->tcp_byte_count != sizeof(uint16_t))
return 1;
- if(ldns_buffer_read_u16_at(c->buffer, 0) >
- ldns_buffer_capacity(c->buffer)) {
+ if(sldns_buffer_read_u16_at(c->buffer, 0) >
+ sldns_buffer_capacity(c->buffer)) {
verbose(VERB_QUERY, "ssl: dropped larger than buffer");
return 0;
}
- ldns_buffer_set_limit(c->buffer,
- ldns_buffer_read_u16_at(c->buffer, 0));
- if(ldns_buffer_limit(c->buffer) < LDNS_HEADER_SIZE) {
+ sldns_buffer_set_limit(c->buffer,
+ sldns_buffer_read_u16_at(c->buffer, 0));
+ if(sldns_buffer_limit(c->buffer) < LDNS_HEADER_SIZE) {
verbose(VERB_QUERY, "ssl: dropped bogus too short.");
return 0;
}
verbose(VERB_ALGO, "Reading ssl tcp query of length %d",
- (int)ldns_buffer_limit(c->buffer));
+ (int)sldns_buffer_limit(c->buffer));
}
- log_assert(ldns_buffer_remaining(c->buffer) > 0);
+ log_assert(sldns_buffer_remaining(c->buffer) > 0);
ERR_clear_error();
- r = SSL_read(c->ssl, (void*)ldns_buffer_current(c->buffer),
- (int)ldns_buffer_remaining(c->buffer));
+ r = SSL_read(c->ssl, (void*)sldns_buffer_current(c->buffer),
+ (int)sldns_buffer_remaining(c->buffer));
if(r <= 0) {
int want = SSL_get_error(c->ssl, r);
if(want == SSL_ERROR_ZERO_RETURN) {
@@ -1046,8 +1083,8 @@ ssl_handle_read(struct comm_point* c)
log_crypto_err("could not SSL_read");
return 0;
}
- ldns_buffer_skip(c->buffer, (ssize_t)r);
- if(ldns_buffer_remaining(c->buffer) <= 0) {
+ sldns_buffer_skip(c->buffer, (ssize_t)r);
+ if(sldns_buffer_remaining(c->buffer) <= 0) {
tcp_callback_reader(c);
}
return 1;
@@ -1072,7 +1109,7 @@ ssl_handle_write(struct comm_point* c)
/* ignore return, if fails we may simply block */
(void)SSL_set_mode(c->ssl, SSL_MODE_ENABLE_PARTIAL_WRITE);
if(c->tcp_byte_count < sizeof(uint16_t)) {
- uint16_t len = htons(ldns_buffer_limit(c->buffer));
+ uint16_t len = htons(sldns_buffer_limit(c->buffer));
ERR_clear_error();
r = SSL_write(c->ssl,
(void*)(((uint8_t*)&len)+c->tcp_byte_count),
@@ -1099,17 +1136,17 @@ ssl_handle_write(struct comm_point* c)
c->tcp_byte_count += r;
if(c->tcp_byte_count < sizeof(uint16_t))
return 1;
- ldns_buffer_set_position(c->buffer, c->tcp_byte_count -
+ sldns_buffer_set_position(c->buffer, c->tcp_byte_count -
sizeof(uint16_t));
- if(ldns_buffer_remaining(c->buffer) == 0) {
+ if(sldns_buffer_remaining(c->buffer) == 0) {
tcp_callback_writer(c);
return 1;
}
}
- log_assert(ldns_buffer_remaining(c->buffer) > 0);
+ log_assert(sldns_buffer_remaining(c->buffer) > 0);
ERR_clear_error();
- r = SSL_write(c->ssl, (void*)ldns_buffer_current(c->buffer),
- (int)ldns_buffer_remaining(c->buffer));
+ r = SSL_write(c->ssl, (void*)sldns_buffer_current(c->buffer),
+ (int)sldns_buffer_remaining(c->buffer));
if(r <= 0) {
int want = SSL_get_error(c->ssl, r);
if(want == SSL_ERROR_ZERO_RETURN) {
@@ -1129,9 +1166,9 @@ ssl_handle_write(struct comm_point* c)
log_crypto_err("could not SSL_write");
return 0;
}
- ldns_buffer_skip(c->buffer, (ssize_t)r);
+ sldns_buffer_skip(c->buffer, (ssize_t)r);
- if(ldns_buffer_remaining(c->buffer) == 0) {
+ if(sldns_buffer_remaining(c->buffer) == 0) {
tcp_callback_writer(c);
}
return 1;
@@ -1169,7 +1206,7 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c, int short_ok)
log_assert(fd != -1);
if(c->tcp_byte_count < sizeof(uint16_t)) {
/* read length bytes */
- r = recv(fd,(void*)ldns_buffer_at(c->buffer,c->tcp_byte_count),
+ r = recv(fd,(void*)sldns_buffer_at(c->buffer,c->tcp_byte_count),
sizeof(uint16_t)-c->tcp_byte_count, 0);
if(r == 0)
return 0;
@@ -1201,25 +1238,25 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c, int short_ok)
c->tcp_byte_count += r;
if(c->tcp_byte_count != sizeof(uint16_t))
return 1;
- if(ldns_buffer_read_u16_at(c->buffer, 0) >
- ldns_buffer_capacity(c->buffer)) {
+ if(sldns_buffer_read_u16_at(c->buffer, 0) >
+ sldns_buffer_capacity(c->buffer)) {
verbose(VERB_QUERY, "tcp: dropped larger than buffer");
return 0;
}
- ldns_buffer_set_limit(c->buffer,
- ldns_buffer_read_u16_at(c->buffer, 0));
+ sldns_buffer_set_limit(c->buffer,
+ sldns_buffer_read_u16_at(c->buffer, 0));
if(!short_ok &&
- ldns_buffer_limit(c->buffer) < LDNS_HEADER_SIZE) {
+ sldns_buffer_limit(c->buffer) < LDNS_HEADER_SIZE) {
verbose(VERB_QUERY, "tcp: dropped bogus too short.");
return 0;
}
verbose(VERB_ALGO, "Reading tcp query of length %d",
- (int)ldns_buffer_limit(c->buffer));
+ (int)sldns_buffer_limit(c->buffer));
}
- log_assert(ldns_buffer_remaining(c->buffer) > 0);
- r = recv(fd, (void*)ldns_buffer_current(c->buffer),
- ldns_buffer_remaining(c->buffer), 0);
+ log_assert(sldns_buffer_remaining(c->buffer) > 0);
+ r = recv(fd, (void*)sldns_buffer_current(c->buffer),
+ sldns_buffer_remaining(c->buffer), 0);
if(r == 0) {
return 0;
} else if(r == -1) {
@@ -1243,8 +1280,8 @@ comm_point_tcp_handle_read(int fd, struct comm_point* c, int short_ok)
c->repinfo.addrlen);
return 0;
}
- ldns_buffer_skip(c->buffer, r);
- if(ldns_buffer_remaining(c->buffer) <= 0) {
+ sldns_buffer_skip(c->buffer, r);
+ if(sldns_buffer_remaining(c->buffer) <= 0) {
tcp_callback_reader(c);
}
return 1;
@@ -1308,13 +1345,13 @@ comm_point_tcp_handle_write(int fd, struct comm_point* c)
return ssl_handle_it(c);
if(c->tcp_byte_count < sizeof(uint16_t)) {
- uint16_t len = htons(ldns_buffer_limit(c->buffer));
+ uint16_t len = htons(sldns_buffer_limit(c->buffer));
#ifdef HAVE_WRITEV
struct iovec iov[2];
iov[0].iov_base = (uint8_t*)&len + c->tcp_byte_count;
iov[0].iov_len = sizeof(uint16_t) - c->tcp_byte_count;
- iov[1].iov_base = ldns_buffer_begin(c->buffer);
- iov[1].iov_len = ldns_buffer_limit(c->buffer);
+ iov[1].iov_base = sldns_buffer_begin(c->buffer);
+ iov[1].iov_len = sldns_buffer_limit(c->buffer);
log_assert(iov[0].iov_len > 0);
log_assert(iov[1].iov_len > 0);
r = writev(fd, iov, 2);
@@ -1350,16 +1387,16 @@ comm_point_tcp_handle_write(int fd, struct comm_point* c)
c->tcp_byte_count += r;
if(c->tcp_byte_count < sizeof(uint16_t))
return 1;
- ldns_buffer_set_position(c->buffer, c->tcp_byte_count -
+ sldns_buffer_set_position(c->buffer, c->tcp_byte_count -
sizeof(uint16_t));
- if(ldns_buffer_remaining(c->buffer) == 0) {
+ if(sldns_buffer_remaining(c->buffer) == 0) {
tcp_callback_writer(c);
return 1;
}
}
- log_assert(ldns_buffer_remaining(c->buffer) > 0);
- r = send(fd, (void*)ldns_buffer_current(c->buffer),
- ldns_buffer_remaining(c->buffer), 0);
+ log_assert(sldns_buffer_remaining(c->buffer) > 0);
+ r = send(fd, (void*)sldns_buffer_current(c->buffer),
+ sldns_buffer_remaining(c->buffer), 0);
if(r == -1) {
#ifndef USE_WINSOCK
if(errno == EINTR || errno == EAGAIN)
@@ -1379,9 +1416,9 @@ comm_point_tcp_handle_write(int fd, struct comm_point* c)
c->repinfo.addrlen);
return 0;
}
- ldns_buffer_skip(c->buffer, r);
+ sldns_buffer_skip(c->buffer, r);
- if(ldns_buffer_remaining(c->buffer) == 0) {
+ if(sldns_buffer_remaining(c->buffer) == 0) {
tcp_callback_writer(c);
}
@@ -1464,7 +1501,7 @@ void comm_point_raw_handle_callback(int ATTR_UNUSED(fd),
}
struct comm_point*
-comm_point_create_udp(struct comm_base *base, int fd, ldns_buffer* buffer,
+comm_point_create_udp(struct comm_base *base, int fd, sldns_buffer* buffer,
comm_point_callback_t* callback, void* callback_arg)
{
struct comm_point* c = (struct comm_point*)calloc(1,
@@ -1514,7 +1551,7 @@ comm_point_create_udp(struct comm_base *base, int fd, ldns_buffer* buffer,
struct comm_point*
comm_point_create_udp_ancil(struct comm_base *base, int fd,
- ldns_buffer* buffer,
+ sldns_buffer* buffer,
comm_point_callback_t* callback, void* callback_arg)
{
struct comm_point* c = (struct comm_point*)calloc(1,
@@ -1580,7 +1617,7 @@ comm_point_create_tcp_handler(struct comm_base *base,
}
c->ev->base = base;
c->fd = -1;
- c->buffer = ldns_buffer_new(bufsize);
+ c->buffer = sldns_buffer_new(bufsize);
if(!c->buffer) {
free(c->ev);
free(c);
@@ -1588,7 +1625,7 @@ comm_point_create_tcp_handler(struct comm_base *base,
}
c->timeout = (struct timeval*)malloc(sizeof(struct timeval));
if(!c->timeout) {
- ldns_buffer_free(c->buffer);
+ sldns_buffer_free(c->buffer);
free(c->ev);
free(c);
return NULL;
@@ -1705,7 +1742,7 @@ comm_point_create_tcp_out(struct comm_base *base, size_t bufsize,
}
c->ev->base = base;
c->fd = -1;
- c->buffer = ldns_buffer_new(bufsize);
+ c->buffer = sldns_buffer_new(bufsize);
if(!c->buffer) {
free(c->ev);
free(c);
@@ -1731,7 +1768,7 @@ comm_point_create_tcp_out(struct comm_base *base, size_t bufsize,
if(event_base_set(base->eb->base, &c->ev->ev) != 0)
{
log_err("could not basetset tcpout event");
- ldns_buffer_free(c->buffer);
+ sldns_buffer_free(c->buffer);
free(c->ev);
free(c);
return NULL;
@@ -1757,7 +1794,7 @@ comm_point_create_local(struct comm_base *base, int fd, size_t bufsize,
}
c->ev->base = base;
c->fd = fd;
- c->buffer = ldns_buffer_new(bufsize);
+ c->buffer = sldns_buffer_new(bufsize);
if(!c->buffer) {
free(c->ev);
free(c);
@@ -1882,7 +1919,7 @@ comm_point_delete(struct comm_point* c)
}
free(c->timeout);
if(c->type == comm_tcp || c->type == comm_local)
- ldns_buffer_free(c->buffer);
+ sldns_buffer_free(c->buffer);
free(c->ev);
free(c);
}
@@ -1994,7 +2031,7 @@ size_t comm_point_get_mem(struct comm_point* c)
if(c->timeout)
s += sizeof(*c->timeout);
if(c->type == comm_tcp || c->type == comm_local)
- s += sizeof(*c->buffer) + ldns_buffer_capacity(c->buffer);
+ s += sizeof(*c->buffer) + sldns_buffer_capacity(c->buffer);
if(c->type == comm_tcp_accept) {
int i;
for(i=0; i<c->max_tcp_count; i++)
diff --git a/contrib/unbound/util/netevent.h b/contrib/unbound/util/netevent.h
index 0ea4cf0..fe28ca5 100644
--- a/contrib/unbound/util/netevent.h
+++ b/contrib/unbound/util/netevent.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -60,7 +60,7 @@
#ifndef NET_EVENT_H
#define NET_EVENT_H
-#include <ldns/buffer.h>
+struct sldns_buffer;
struct comm_point;
struct comm_reply;
struct event_base;
@@ -149,7 +149,7 @@ struct comm_point {
struct timeval* timeout;
/** buffer pointer. Either to perthread, or own buffer or NULL */
- ldns_buffer* buffer;
+ struct sldns_buffer* buffer;
/* -------- TCP Handler -------- */
/** Read/Write state for TCP */
@@ -295,6 +295,21 @@ struct comm_signal {
struct comm_base* comm_base_create(int sigs);
/**
+ * Create comm base that uses the given event_base (underlying event
+ * mechanism pointer).
+ * @param base: underlying lib event base.
+ * @return: the new comm base. NULL on error.
+ */
+struct comm_base* comm_base_create_event(struct event_base* base);
+
+/**
+ * Delete comm base structure but not the underlying lib event base.
+ * All comm points must have been deleted.
+ * @param b: the base to delete.
+ */
+void comm_base_delete_no_base(struct comm_base* b);
+
+/**
* Destroy a comm base.
* All comm points must have been deleted.
* @param b: the base to delete.
@@ -308,7 +323,7 @@ void comm_base_delete(struct comm_base* b);
* @param tt: pointer to time in seconds is returned.
* @param tv: pointer to time in microseconds is returned.
*/
-void comm_base_timept(struct comm_base* b, uint32_t** tt, struct timeval** tv);
+void comm_base_timept(struct comm_base* b, time_t** tt, struct timeval** tv);
/**
* Dispatch the comm base events.
@@ -352,7 +367,7 @@ struct event_base* comm_base_internal(struct comm_base* b);
* Sets timeout to NULL. Turns off TCP options.
*/
struct comm_point* comm_point_create_udp(struct comm_base* base,
- int fd, ldns_buffer* buffer,
+ int fd, struct sldns_buffer* buffer,
comm_point_callback_t* callback, void* callback_arg);
/**
@@ -368,7 +383,7 @@ struct comm_point* comm_point_create_udp(struct comm_base* base,
* Sets timeout to NULL. Turns off TCP options.
*/
struct comm_point* comm_point_create_udp_ancil(struct comm_base* base,
- int fd, ldns_buffer* buffer,
+ int fd, struct sldns_buffer* buffer,
comm_point_callback_t* callback, void* callback_arg);
/**
@@ -462,7 +477,7 @@ void comm_point_drop_reply(struct comm_reply* repinfo);
* @param addrlen: length of addr.
* @return: false on a failure.
*/
-int comm_point_send_udp_msg(struct comm_point* c, ldns_buffer* packet,
+int comm_point_send_udp_msg(struct comm_point* c, struct sldns_buffer* packet,
struct sockaddr* addr, socklen_t addrlen);
/**
diff --git a/contrib/unbound/util/random.c b/contrib/unbound/util/random.c
index 5d71fcf..8a24ff0 100644
--- a/contrib/unbound/util/random.c
+++ b/contrib/unbound/util/random.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -60,6 +60,7 @@
#include "config.h"
#include "util/random.h"
#include "util/log.h"
+#include <time.h>
#ifdef HAVE_SSL
#include <openssl/rand.h>
#include <openssl/rc4.h>
diff --git a/contrib/unbound/util/random.h b/contrib/unbound/util/random.h
index 99879dc..a05a994 100644
--- a/contrib/unbound/util/random.h
+++ b/contrib/unbound/util/random.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef UTIL_RANDOM_H
diff --git a/contrib/unbound/util/rbtree.c b/contrib/unbound/util/rbtree.c
index d31afd9..a898f13 100644
--- a/contrib/unbound/util/rbtree.c
+++ b/contrib/unbound/util/rbtree.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
diff --git a/contrib/unbound/util/rbtree.h b/contrib/unbound/util/rbtree.h
index 879804d..50c84bb 100644
--- a/contrib/unbound/util/rbtree.h
+++ b/contrib/unbound/util/rbtree.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
diff --git a/contrib/unbound/util/regional.c b/contrib/unbound/util/regional.c
index 8b1fcdb..899a54e 100644
--- a/contrib/unbound/util/regional.c
+++ b/contrib/unbound/util/regional.c
@@ -23,16 +23,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/regional.h b/contrib/unbound/util/regional.h
index 250523a..e8b2cb8 100644
--- a/contrib/unbound/util/regional.h
+++ b/contrib/unbound/util/regional.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/rtt.c b/contrib/unbound/util/rtt.c
index c888b08..4b44fca 100644
--- a/contrib/unbound/util/rtt.c
+++ b/contrib/unbound/util/rtt.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/rtt.h b/contrib/unbound/util/rtt.h
index 1af5484..57e904d 100644
--- a/contrib/unbound/util/rtt.h
+++ b/contrib/unbound/util/rtt.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/storage/dnstree.c b/contrib/unbound/util/storage/dnstree.c
index 003e8af..0df490e 100644
--- a/contrib/unbound/util/storage/dnstree.c
+++ b/contrib/unbound/util/storage/dnstree.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/storage/dnstree.h b/contrib/unbound/util/storage/dnstree.h
index 3ecbd12..ec81891 100644
--- a/contrib/unbound/util/storage/dnstree.h
+++ b/contrib/unbound/util/storage/dnstree.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/storage/lookup3.c b/contrib/unbound/util/storage/lookup3.c
index 845cc38..7596033 100644
--- a/contrib/unbound/util/storage/lookup3.c
+++ b/contrib/unbound/util/storage/lookup3.c
@@ -50,6 +50,9 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
#include <time.h> /* defines time_t for timings in the test */
/*#include <stdint.h> defines uint32_t etc (from config.h) */
#include <sys/param.h> /* attempt to define endianness */
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h> /* attempt to define endianness (solaris) */
+#endif
#ifdef linux
# include <endian.h> /* attempt to define endianness */
#endif
@@ -61,7 +64,7 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
#endif
/* random initial value */
-static uint32_t raninit = 0xdeadbeef;
+static uint32_t raninit = (uint32_t)0xdeadbeef;
void
hash_set_raninit(uint32_t v)
@@ -75,22 +78,25 @@ hash_set_raninit(uint32_t v)
*/
#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
__BYTE_ORDER == __LITTLE_ENDIAN) || \
- (defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && \
- _BYTE_ORDER == _LITTLE_ENDIAN) || \
(defined(i386) || defined(__i386__) || defined(__i486__) || \
- defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL))
+ defined(__i586__) || defined(__i686__) || defined(vax) || defined(MIPSEL) || defined(__x86))
# define HASH_LITTLE_ENDIAN 1
# define HASH_BIG_ENDIAN 0
-#elif (!defined(_BYTE_ORDER) && !defined(__BYTE_ORDER) && defined(_BIG_ENDIAN))
-# define HASH_LITTLE_ENDIAN 0
-# define HASH_BIG_ENDIAN 1
#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && \
__BYTE_ORDER == __BIG_ENDIAN) || \
- (defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && \
- _BYTE_ORDER == _BIG_ENDIAN) || \
- (defined(sparc) || defined(POWERPC) || defined(mc68000) || defined(sel))
+ (defined(sparc) || defined(__sparc) || defined(__sparc__) || defined(POWERPC) || defined(mc68000) || defined(sel))
# define HASH_LITTLE_ENDIAN 0
# define HASH_BIG_ENDIAN 1
+#elif defined(_MACHINE_ENDIAN_H_)
+/* test for machine_endian_h protects failure if some are empty strings */
+# if defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && _BYTE_ORDER == _BIG_ENDIAN
+# define HASH_LITTLE_ENDIAN 0
+# define HASH_BIG_ENDIAN 1
+# endif
+# if defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && _BYTE_ORDER == _LITTLE_ENDIAN
+# define HASH_LITTLE_ENDIAN 1
+# define HASH_BIG_ENDIAN 0
+# endif /* _MACHINE_ENDIAN_H_ */
#else
# define HASH_LITTLE_ENDIAN 0
# define HASH_BIG_ENDIAN 0
diff --git a/contrib/unbound/util/storage/lookup3.h b/contrib/unbound/util/storage/lookup3.h
index 06211fd..59dad7c 100644
--- a/contrib/unbound/util/storage/lookup3.h
+++ b/contrib/unbound/util/storage/lookup3.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/storage/lruhash.c b/contrib/unbound/util/storage/lruhash.c
index c22278d..2c987a2 100644
--- a/contrib/unbound/util/storage/lruhash.c
+++ b/contrib/unbound/util/storage/lruhash.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/storage/lruhash.h b/contrib/unbound/util/storage/lruhash.h
index d0efe2d..30377d8 100644
--- a/contrib/unbound/util/storage/lruhash.h
+++ b/contrib/unbound/util/storage/lruhash.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/storage/slabhash.c b/contrib/unbound/util/storage/slabhash.c
index 9c0c507..128edd8 100644
--- a/contrib/unbound/util/storage/slabhash.c
+++ b/contrib/unbound/util/storage/slabhash.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/storage/slabhash.h b/contrib/unbound/util/storage/slabhash.h
index 93228fe..cf968f9 100644
--- a/contrib/unbound/util/storage/slabhash.h
+++ b/contrib/unbound/util/storage/slabhash.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/timehist.c b/contrib/unbound/util/timehist.c
index 98d8db1..dbf5b98 100644
--- a/contrib/unbound/util/timehist.c
+++ b/contrib/unbound/util/timehist.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -43,6 +43,7 @@
#include <time.h>
#endif
#include <sys/time.h>
+#include <sys/types.h>
#include "util/timehist.h"
#include "util/log.h"
diff --git a/contrib/unbound/util/timehist.h b/contrib/unbound/util/timehist.h
index d594483..5c65048 100644
--- a/contrib/unbound/util/timehist.h
+++ b/contrib/unbound/util/timehist.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/tube.c b/contrib/unbound/util/tube.c
index 28c51d7..2106a078 100644
--- a/contrib/unbound/util/tube.c
+++ b/contrib/unbound/util/tube.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -368,7 +368,7 @@ int tube_read_msg(struct tube* tube, uint8_t** buf, uint32_t* len,
return 0;
}
d = 0;
- while(d != (ssize_t)*len) {
+ while(d < (ssize_t)*len) {
if((r=read(fd, (*buf)+d, (size_t)((ssize_t)*len)-d)) == -1) {
log_err("tube msg read failed: %s", strerror(errno));
(void)fd_set_nonblock(fd);
diff --git a/contrib/unbound/util/tube.h b/contrib/unbound/util/tube.h
index 2e70411..9ec50af 100644
--- a/contrib/unbound/util/tube.h
+++ b/contrib/unbound/util/tube.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/util/winsock_event.c b/contrib/unbound/util/winsock_event.c
index ff5c9b0..38661a5e 100644
--- a/contrib/unbound/util/winsock_event.c
+++ b/contrib/unbound/util/winsock_event.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \file
@@ -41,6 +41,10 @@
#include "config.h"
#ifdef USE_WINSOCK
#include <signal.h>
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#include <sys/time.h>
#include "util/winsock_event.h"
#include "util/fptr_wlist.h"
@@ -71,7 +75,7 @@ settime(struct event_base* base)
return -1;
}
#ifndef S_SPLINT_S
- *base->time_secs = (uint32_t)base->time_tv->tv_sec;
+ *base->time_secs = (time_t)base->time_tv->tv_sec;
#endif
return 0;
}
@@ -108,7 +112,7 @@ zero_waitfor(WSAEVENT waitfor[], WSAEVENT x)
}
}
-void *event_init(uint32_t* time_secs, struct timeval* time_tv)
+void *event_init(time_t* time_secs, struct timeval* time_tv)
{
struct event_base* base = (struct event_base*)malloc(
sizeof(struct event_base));
@@ -181,8 +185,8 @@ static void handle_timeouts(struct event_base* base, struct timeval* now,
wait->tv_usec = p->ev_timeout.tv_usec
- now->tv_usec;
}
- verbose(VERB_CLIENT, "winsock_event wait=%d.%6.6d",
- (int)wait->tv_sec, (int)wait->tv_usec);
+ verbose(VERB_CLIENT, "winsock_event wait=" ARG_LL "d.%6.6d",
+ (long long)wait->tv_sec, (int)wait->tv_usec);
return;
}
#endif
@@ -488,9 +492,9 @@ int event_base_set(struct event_base *base, struct event *ev)
int event_add(struct event *ev, struct timeval *tv)
{
- verbose(VERB_ALGO, "event_add %p added=%d fd=%d tv=%d %s%s%s",
+ verbose(VERB_ALGO, "event_add %p added=%d fd=%d tv=" ARG_LL "d %s%s%s",
ev, ev->added, ev->ev_fd,
- (tv?(int)tv->tv_sec*1000+(int)tv->tv_usec/1000:-1),
+ (tv?(long long)tv->tv_sec*1000+(long long)tv->tv_usec/1000:-1),
(ev->ev_events&EV_READ)?" EV_READ":"",
(ev->ev_events&EV_WRITE)?" EV_WRITE":"",
(ev->ev_events&EV_TIMEOUT)?" EV_TIMEOUT":"");
@@ -569,10 +573,10 @@ int event_add(struct event *ev, struct timeval *tv)
int event_del(struct event *ev)
{
- verbose(VERB_ALGO, "event_del %p added=%d fd=%d tv=%d %s%s%s",
+ verbose(VERB_ALGO, "event_del %p added=%d fd=%d tv=" ARG_LL "d %s%s%s",
ev, ev->added, ev->ev_fd,
- (ev->ev_events&EV_TIMEOUT)?(int)ev->ev_timeout.tv_sec*1000+
- (int)ev->ev_timeout.tv_usec/1000:-1,
+ (ev->ev_events&EV_TIMEOUT)?(long long)ev->ev_timeout.tv_sec*1000+
+ (long long)ev->ev_timeout.tv_usec/1000:-1,
(ev->ev_events&EV_READ)?" EV_READ":"",
(ev->ev_events&EV_WRITE)?" EV_WRITE":"",
(ev->ev_events&EV_TIMEOUT)?" EV_TIMEOUT":"");
diff --git a/contrib/unbound/util/winsock_event.h b/contrib/unbound/util/winsock_event.h
index 088283e..40892c1 100644
--- a/contrib/unbound/util/winsock_event.h
+++ b/contrib/unbound/util/winsock_event.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -129,7 +129,7 @@ struct event_base
/** if we need to exit */
int need_to_exit;
/** where to store time in seconds */
- uint32_t* time_secs;
+ time_t* time_secs;
/** where to store time in microseconds */
struct timeval* time_tv;
/**
@@ -194,7 +194,7 @@ struct event {
};
/** create event base */
-void *event_init(uint32_t* time_secs, struct timeval* time_tv);
+void *event_init(time_t* time_secs, struct timeval* time_tv);
/** get version */
const char *event_get_version(void);
/** get polling method (select,epoll) */
diff --git a/contrib/unbound/validator/autotrust.c b/contrib/unbound/validator/autotrust.c
index 99537d1..a597633 100644
--- a/contrib/unbound/validator/autotrust.c
+++ b/contrib/unbound/validator/autotrust.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -41,7 +41,6 @@
* It was modified to fit into unbound. The state table process is the same.
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "validator/autotrust.h"
#include "validator/val_anchor.h"
#include "validator/val_utils.h"
@@ -58,6 +57,13 @@
#include "services/mesh.h"
#include "services/cache/rrset.h"
#include "validator/val_kcache.h"
+#include "ldns/sbuffer.h"
+#include "ldns/wire2str.h"
+#include "ldns/str2wire.h"
+#include "ldns/keyraw.h"
+#include "ldns/rrdef.h"
+#include <stdarg.h>
+#include <ctype.h>
/** number of times a key must be seen before it can become valid */
#define MIN_PENDINGCOUNT 2
@@ -138,8 +144,11 @@ verbose_key(struct autr_ta* ta, enum verbosity_value level,
va_list args;
va_start(args, format);
if(verbosity >= level) {
- char* str = ldns_rdf2str(ldns_rr_owner(ta->rr));
- int keytag = (int)ldns_calc_keytag(ta->rr);
+ char* str = sldns_wire2str_dname(ta->rr, ta->dname_len);
+ int keytag = (int)sldns_calc_keytag_raw(sldns_wirerr_get_rdata(
+ ta->rr, ta->rr_len, ta->dname_len),
+ sldns_wirerr_get_rdatalen(ta->rr, ta->rr_len,
+ ta->dname_len));
char msg[MAXSYSLOGMSGLEN];
vsnprintf(msg, sizeof(msg), format, args);
verbose(level, "%s key %d %s", str?str:"??", keytag, msg);
@@ -242,7 +251,7 @@ parse_comments(char* str, struct autr_ta* ta)
if (pos < 0 || !timestamp)
ta->last_change = 0;
else
- ta->last_change = (uint32_t)timestamp;
+ ta->last_change = (time_t)timestamp;
free(comment);
return 1;
@@ -262,55 +271,76 @@ str_contains_data(char* str, char comment)
return 0;
}
-/** Get DNSKEY flags */
+/** Get DNSKEY flags
+ * rdata without rdatalen in front of it. */
static int
-dnskey_flags(ldns_rr* rr)
+dnskey_flags(uint16_t t, uint8_t* rdata, size_t len)
{
- if(ldns_rr_get_type(rr) != LDNS_RR_TYPE_DNSKEY)
+ uint16_t f;
+ if(t != LDNS_RR_TYPE_DNSKEY)
return 0;
- return (int)ldns_read_uint16(ldns_rdf_data(ldns_rr_dnskey_flags(rr)));
+ if(len < 2)
+ return 0;
+ memmove(&f, rdata, 2);
+ f = ntohs(f);
+ return (int)f;
}
+/** Check if KSK DNSKEY.
+ * pass rdata without rdatalen in front of it */
+static int
+rr_is_dnskey_sep(uint16_t t, uint8_t* rdata, size_t len)
+{
+ return (dnskey_flags(t, rdata, len)&DNSKEY_BIT_SEP);
+}
-/** Check if KSK DNSKEY */
+/** Check if TA is KSK DNSKEY */
static int
-rr_is_dnskey_sep(ldns_rr* rr)
+ta_is_dnskey_sep(struct autr_ta* ta)
{
- return (dnskey_flags(rr)&DNSKEY_BIT_SEP);
+ return (dnskey_flags(
+ sldns_wirerr_get_type(ta->rr, ta->rr_len, ta->dname_len),
+ sldns_wirerr_get_rdata(ta->rr, ta->rr_len, ta->dname_len),
+ sldns_wirerr_get_rdatalen(ta->rr, ta->rr_len, ta->dname_len)
+ ) & DNSKEY_BIT_SEP);
}
-/** Check if REVOKED DNSKEY */
+/** Check if REVOKED DNSKEY
+ * pass rdata without rdatalen in front of it */
static int
-rr_is_dnskey_revoked(ldns_rr* rr)
+rr_is_dnskey_revoked(uint16_t t, uint8_t* rdata, size_t len)
{
- return (dnskey_flags(rr)&LDNS_KEY_REVOKE_KEY);
+ return (dnskey_flags(t, rdata, len)&LDNS_KEY_REVOKE_KEY);
}
/** create ta */
static struct autr_ta*
-autr_ta_create(ldns_rr* rr)
+autr_ta_create(uint8_t* rr, size_t rr_len, size_t dname_len)
{
struct autr_ta* ta = (struct autr_ta*)calloc(1, sizeof(*ta));
if(!ta) {
- ldns_rr_free(rr);
+ free(rr);
return NULL;
}
ta->rr = rr;
+ ta->rr_len = rr_len;
+ ta->dname_len = dname_len;
return ta;
}
/** create tp */
static struct trust_anchor*
-autr_tp_create(struct val_anchors* anchors, ldns_rdf* own, uint16_t dc)
+autr_tp_create(struct val_anchors* anchors, uint8_t* own, size_t own_len,
+ uint16_t dc)
{
struct trust_anchor* tp = (struct trust_anchor*)calloc(1, sizeof(*tp));
if(!tp) return NULL;
- tp->name = memdup(ldns_rdf_data(own), ldns_rdf_size(own));
+ tp->name = memdup(own, own_len);
if(!tp->name) {
free(tp);
return NULL;
}
- tp->namelen = ldns_rdf_size(own);
+ tp->namelen = own_len;
tp->namelabs = dname_count_labels(tp->name);
tp->node.key = tp;
tp->dclass = dc;
@@ -371,7 +401,7 @@ void autr_point_delete(struct trust_anchor* tp)
struct autr_ta* p = tp->autr->keys, *np;
while(p) {
np = p->next;
- ldns_rr_free(p->rr);
+ free(p->rr);
free(p);
p = np;
}
@@ -384,13 +414,12 @@ void autr_point_delete(struct trust_anchor* tp)
/** find or add a new trust point for autotrust */
static struct trust_anchor*
-find_add_tp(struct val_anchors* anchors, ldns_rr* rr)
+find_add_tp(struct val_anchors* anchors, uint8_t* rr, size_t rr_len,
+ size_t dname_len)
{
struct trust_anchor* tp;
- ldns_rdf* own = ldns_rr_owner(rr);
- tp = anchor_find(anchors, ldns_rdf_data(own),
- dname_count_labels(ldns_rdf_data(own)),
- ldns_rdf_size(own), ldns_rr_get_class(rr));
+ tp = anchor_find(anchors, rr, dname_count_labels(rr), dname_len,
+ sldns_wirerr_get_class(rr, rr_len, dname_len));
if(tp) {
if(!tp->autr) {
log_err("anchor cannot be with and without autotrust");
@@ -399,22 +428,23 @@ find_add_tp(struct val_anchors* anchors, ldns_rr* rr)
}
return tp;
}
- tp = autr_tp_create(anchors, ldns_rr_owner(rr), ldns_rr_get_class(rr));
+ tp = autr_tp_create(anchors, rr, dname_len, sldns_wirerr_get_class(rr,
+ rr_len, dname_len));
lock_basic_lock(&tp->lock);
return tp;
}
/** Add trust anchor from RR */
static struct autr_ta*
-add_trustanchor_frm_rr(struct val_anchors* anchors, ldns_rr* rr,
- struct trust_anchor** tp)
+add_trustanchor_frm_rr(struct val_anchors* anchors, uint8_t* rr, size_t rr_len,
+ size_t dname_len, struct trust_anchor** tp)
{
- struct autr_ta* ta = autr_ta_create(rr);
+ struct autr_ta* ta = autr_ta_create(rr, rr_len, dname_len);
if(!ta)
return NULL;
- *tp = find_add_tp(anchors, rr);
+ *tp = find_add_tp(anchors, rr, rr_len, dname_len);
if(!*tp) {
- ldns_rr_free(ta->rr);
+ free(ta->rr);
free(ta);
return NULL;
}
@@ -431,34 +461,51 @@ add_trustanchor_frm_rr(struct val_anchors* anchors, ldns_rr* rr,
* @param str: string with anchor and comments, if any comments.
* @param tp: trust point returned.
* @param origin: what to use for @
+ * @param origin_len: length of origin
* @param prev: previous rr name
+ * @param prev_len: length of prev
* @param skip: if true, the result is NULL, but not an error, skip it.
* @return new key in trust point.
*/
static struct autr_ta*
add_trustanchor_frm_str(struct val_anchors* anchors, char* str,
- struct trust_anchor** tp, ldns_rdf* origin, ldns_rdf** prev, int* skip)
+ struct trust_anchor** tp, uint8_t* origin, size_t origin_len,
+ uint8_t** prev, size_t* prev_len, int* skip)
{
- ldns_rr* rr;
- ldns_status lstatus;
+ uint8_t rr[LDNS_RR_BUF_SIZE];
+ size_t rr_len = sizeof(rr), dname_len;
+ uint8_t* drr;
+ int lstatus;
if (!str_contains_data(str, ';')) {
*skip = 1;
return NULL; /* empty line */
}
- if (LDNS_STATUS_OK !=
- (lstatus = ldns_rr_new_frm_str(&rr, str, 0, origin, prev)))
- {
- log_err("ldns error while converting string to RR: %s",
- ldns_get_errorstr_by_id(lstatus));
- return NULL;
- }
- if(ldns_rr_get_type(rr) != LDNS_RR_TYPE_DNSKEY &&
- ldns_rr_get_type(rr) != LDNS_RR_TYPE_DS) {
- ldns_rr_free(rr);
+ if(0 != (lstatus = sldns_str2wire_rr_buf(str, rr, &rr_len, &dname_len,
+ 0, origin, origin_len, *prev, *prev_len)))
+ {
+ log_err("ldns error while converting string to RR at%d: %s: %s",
+ LDNS_WIREPARSE_OFFSET(lstatus),
+ sldns_get_errorstr_parse(lstatus), str);
+ return NULL;
+ }
+ free(*prev);
+ *prev = memdup(rr, dname_len);
+ *prev_len = dname_len;
+ if(!*prev) {
+ log_err("malloc failure in add_trustanchor");
+ return NULL;
+ }
+ if(sldns_wirerr_get_type(rr, rr_len, dname_len)!=LDNS_RR_TYPE_DNSKEY &&
+ sldns_wirerr_get_type(rr, rr_len, dname_len)!=LDNS_RR_TYPE_DS) {
*skip = 1;
return NULL; /* only DS and DNSKEY allowed */
}
- return add_trustanchor_frm_rr(anchors, rr, tp);
+ drr = memdup(rr, rr_len);
+ if(!drr) {
+ log_err("malloc failure in add trustanchor");
+ return NULL;
+ }
+ return add_trustanchor_frm_rr(anchors, drr, rr_len, dname_len, tp);
}
/**
@@ -467,18 +514,22 @@ add_trustanchor_frm_str(struct val_anchors* anchors, char* str,
* @param str: comments line
* @param fname: filename
* @param origin: the $ORIGIN.
+ * @param origin_len: length of origin
* @param prev: passed to ldns.
+ * @param prev_len: length of prev
* @param skip: if true, the result is NULL, but not an error, skip it.
* @return false on failure, otherwise the tp read.
*/
static struct trust_anchor*
load_trustanchor(struct val_anchors* anchors, char* str, const char* fname,
- ldns_rdf* origin, ldns_rdf** prev, int* skip)
+ uint8_t* origin, size_t origin_len, uint8_t** prev, size_t* prev_len,
+ int* skip)
{
- struct autr_ta* ta = NULL;
- struct trust_anchor* tp = NULL;
+ struct autr_ta* ta = NULL;
+ struct trust_anchor* tp = NULL;
- ta = add_trustanchor_frm_str(anchors, str, &tp, origin, prev, skip);
+ ta = add_trustanchor_frm_str(anchors, str, &tp, origin, origin_len,
+ prev, prev_len, skip);
if(!ta)
return NULL;
lock_basic_lock(&tp->lock);
@@ -498,70 +549,228 @@ load_trustanchor(struct val_anchors* anchors, char* str, const char* fname,
return tp;
}
+/** iterator for DSes from keylist. return true if a next element exists */
+static int
+assemble_iterate_ds(struct autr_ta** list, uint8_t** rr, size_t* rr_len,
+ size_t* dname_len)
+{
+ while(*list) {
+ if(sldns_wirerr_get_type((*list)->rr, (*list)->rr_len,
+ (*list)->dname_len) == LDNS_RR_TYPE_DS) {
+ *rr = (*list)->rr;
+ *rr_len = (*list)->rr_len;
+ *dname_len = (*list)->dname_len;
+ *list = (*list)->next;
+ return 1;
+ }
+ *list = (*list)->next;
+ }
+ return 0;
+}
+
+/** iterator for DNSKEYs from keylist. return true if a next element exists */
+static int
+assemble_iterate_dnskey(struct autr_ta** list, uint8_t** rr, size_t* rr_len,
+ size_t* dname_len)
+{
+ while(*list) {
+ if(sldns_wirerr_get_type((*list)->rr, (*list)->rr_len,
+ (*list)->dname_len) != LDNS_RR_TYPE_DS &&
+ ((*list)->s == AUTR_STATE_VALID ||
+ (*list)->s == AUTR_STATE_MISSING)) {
+ *rr = (*list)->rr;
+ *rr_len = (*list)->rr_len;
+ *dname_len = (*list)->dname_len;
+ *list = (*list)->next;
+ return 1;
+ }
+ *list = (*list)->next;
+ }
+ return 0;
+}
+
+/** see if iterator-list has any elements in it, or it is empty */
+static int
+assemble_iterate_hasfirst(int iter(struct autr_ta**, uint8_t**, size_t*,
+ size_t*), struct autr_ta* list)
+{
+ uint8_t* rr = NULL;
+ size_t rr_len = 0, dname_len = 0;
+ return iter(&list, &rr, &rr_len, &dname_len);
+}
+
+/** number of elements in iterator list */
+static size_t
+assemble_iterate_count(int iter(struct autr_ta**, uint8_t**, size_t*,
+ size_t*), struct autr_ta* list)
+{
+ uint8_t* rr = NULL;
+ size_t i = 0, rr_len = 0, dname_len = 0;
+ while(iter(&list, &rr, &rr_len, &dname_len)) {
+ i++;
+ }
+ return i;
+}
+
+/**
+ * Create a ub_packed_rrset_key allocated on the heap.
+ * It therefore does not have the correct ID value, and cannot be used
+ * inside the cache. It can be used in storage outside of the cache.
+ * Keys for the cache have to be obtained from alloc.h .
+ * @param iter: iterator over the elements in the list. It filters elements.
+ * @param list: the list.
+ * @return key allocated or NULL on failure.
+ */
+static struct ub_packed_rrset_key*
+ub_packed_rrset_heap_key(int iter(struct autr_ta**, uint8_t**, size_t*,
+ size_t*), struct autr_ta* list)
+{
+ uint8_t* rr = NULL;
+ size_t rr_len = 0, dname_len = 0;
+ struct ub_packed_rrset_key* k;
+ if(!iter(&list, &rr, &rr_len, &dname_len))
+ return NULL;
+ k = (struct ub_packed_rrset_key*)calloc(1, sizeof(*k));
+ if(!k)
+ return NULL;
+ k->rk.type = htons(sldns_wirerr_get_type(rr, rr_len, dname_len));
+ k->rk.rrset_class = htons(sldns_wirerr_get_class(rr, rr_len, dname_len));
+ k->rk.dname_len = dname_len;
+ k->rk.dname = memdup(rr, dname_len);
+ if(!k->rk.dname) {
+ free(k);
+ return NULL;
+ }
+ return k;
+}
+
+/**
+ * Create packed_rrset data on the heap.
+ * @param iter: iterator over the elements in the list. It filters elements.
+ * @param list: the list.
+ * @return data allocated or NULL on failure.
+ */
+static struct packed_rrset_data*
+packed_rrset_heap_data(int iter(struct autr_ta**, uint8_t**, size_t*,
+ size_t*), struct autr_ta* list)
+{
+ uint8_t* rr = NULL;
+ size_t rr_len = 0, dname_len = 0;
+ struct packed_rrset_data* data;
+ size_t count=0, rrsig_count=0, len=0, i, total;
+ uint8_t* nextrdata;
+ struct autr_ta* list_i;
+ time_t ttl = 0;
+
+ list_i = list;
+ while(iter(&list_i, &rr, &rr_len, &dname_len)) {
+ if(sldns_wirerr_get_type(rr, rr_len, dname_len) ==
+ LDNS_RR_TYPE_RRSIG)
+ rrsig_count++;
+ else count++;
+ /* sizeof the rdlength + rdatalen */
+ len += 2 + sldns_wirerr_get_rdatalen(rr, rr_len, dname_len);
+ ttl = (time_t)sldns_wirerr_get_ttl(rr, rr_len, dname_len);
+ }
+ if(count == 0 && rrsig_count == 0)
+ return NULL;
+
+ /* allocate */
+ total = count + rrsig_count;
+ len += sizeof(*data) + total*(sizeof(size_t) + sizeof(time_t) +
+ sizeof(uint8_t*));
+ data = (struct packed_rrset_data*)calloc(1, len);
+ if(!data)
+ return NULL;
+
+ /* fill it */
+ data->ttl = ttl;
+ data->count = count;
+ data->rrsig_count = rrsig_count;
+ data->rr_len = (size_t*)((uint8_t*)data +
+ sizeof(struct packed_rrset_data));
+ data->rr_data = (uint8_t**)&(data->rr_len[total]);
+ data->rr_ttl = (time_t*)&(data->rr_data[total]);
+ nextrdata = (uint8_t*)&(data->rr_ttl[total]);
+
+ /* fill out len, ttl, fields */
+ list_i = list;
+ i = 0;
+ while(iter(&list_i, &rr, &rr_len, &dname_len)) {
+ data->rr_ttl[i] = (time_t)sldns_wirerr_get_ttl(rr, rr_len,
+ dname_len);
+ if(data->rr_ttl[i] < data->ttl)
+ data->ttl = data->rr_ttl[i];
+ data->rr_len[i] = 2 /* the rdlength */ +
+ sldns_wirerr_get_rdatalen(rr, rr_len, dname_len);
+ i++;
+ }
+
+ /* fixup rest of ptrs */
+ for(i=0; i<total; i++) {
+ data->rr_data[i] = nextrdata;
+ nextrdata += data->rr_len[i];
+ }
+
+ /* copy data in there */
+ list_i = list;
+ i = 0;
+ while(iter(&list_i, &rr, &rr_len, &dname_len)) {
+ memmove(data->rr_data[i],
+ sldns_wirerr_get_rdatawl(rr, rr_len, dname_len),
+ data->rr_len[i]);
+ i++;
+ }
+
+ if(data->rrsig_count && data->count == 0) {
+ data->count = data->rrsig_count; /* rrset type is RRSIG */
+ data->rrsig_count = 0;
+ }
+ return data;
+}
+
/**
* Assemble the trust anchors into DS and DNSKEY packed rrsets.
* Uses only VALID and MISSING DNSKEYs.
- * Read the ldns_rrs and builds packed rrsets
+ * Read the sldns_rrs and builds packed rrsets
* @param tp: the trust point. Must be locked.
* @return false on malloc failure.
*/
static int
autr_assemble(struct trust_anchor* tp)
{
- ldns_rr_list* ds, *dnskey;
- struct autr_ta* ta;
struct ub_packed_rrset_key* ubds=NULL, *ubdnskey=NULL;
- ds = ldns_rr_list_new();
- dnskey = ldns_rr_list_new();
- if(!ds || !dnskey) {
- ldns_rr_list_free(ds);
- ldns_rr_list_free(dnskey);
- return 0;
- }
- for(ta = tp->autr->keys; ta; ta = ta->next) {
- if(ldns_rr_get_type(ta->rr) == LDNS_RR_TYPE_DS) {
- if(!ldns_rr_list_push_rr(ds, ta->rr)) {
- ldns_rr_list_free(ds);
- ldns_rr_list_free(dnskey);
- return 0;
- }
- } else if(ta->s == AUTR_STATE_VALID ||
- ta->s == AUTR_STATE_MISSING) {
- if(!ldns_rr_list_push_rr(dnskey, ta->rr)) {
- ldns_rr_list_free(ds);
- ldns_rr_list_free(dnskey);
- return 0;
- }
- }
- }
-
/* make packed rrset keys - malloced with no ID number, they
* are not in the cache */
/* make packed rrset data (if there is a key) */
-
- if(ldns_rr_list_rr_count(ds) > 0) {
- ubds = ub_packed_rrset_heap_key(ds);
- if(!ubds)
+ if(assemble_iterate_hasfirst(assemble_iterate_ds, tp->autr->keys)) {
+ ubds = ub_packed_rrset_heap_key(
+ assemble_iterate_ds, tp->autr->keys);
+ if(!ubds)
goto error_cleanup;
- ubds->entry.data = packed_rrset_heap_data(ds);
+ ubds->entry.data = packed_rrset_heap_data(
+ assemble_iterate_ds, tp->autr->keys);
if(!ubds->entry.data)
goto error_cleanup;
}
- if(ldns_rr_list_rr_count(dnskey) > 0) {
- ubdnskey = ub_packed_rrset_heap_key(dnskey);
+
+ /* make packed DNSKEY data */
+ if(assemble_iterate_hasfirst(assemble_iterate_dnskey, tp->autr->keys)) {
+ ubdnskey = ub_packed_rrset_heap_key(
+ assemble_iterate_dnskey, tp->autr->keys);
if(!ubdnskey)
goto error_cleanup;
- ubdnskey->entry.data = packed_rrset_heap_data(dnskey);
+ ubdnskey->entry.data = packed_rrset_heap_data(
+ assemble_iterate_dnskey, tp->autr->keys);
if(!ubdnskey->entry.data) {
error_cleanup:
autr_rrset_delete(ubds);
autr_rrset_delete(ubdnskey);
- ldns_rr_list_free(ds);
- ldns_rr_list_free(dnskey);
return 0;
}
}
+
/* we have prepared the new keys so nothing can go wrong any more.
* And we are sure we cannot be left without trustanchor after
* any errors. Put in the new keys and remove old ones. */
@@ -573,11 +782,10 @@ autr_assemble(struct trust_anchor* tp)
/* assign the data to replace the old */
tp->ds_rrset = ubds;
tp->dnskey_rrset = ubdnskey;
- tp->numDS = ldns_rr_list_rr_count(ds);
- tp->numDNSKEY = ldns_rr_list_rr_count(dnskey);
-
- ldns_rr_list_free(ds);
- ldns_rr_list_free(dnskey);
+ tp->numDS = assemble_iterate_count(assemble_iterate_ds,
+ tp->autr->keys);
+ tp->numDNSKEY = assemble_iterate_count(assemble_iterate_dnskey,
+ tp->autr->keys);
return 1;
}
@@ -601,27 +809,28 @@ parse_id(struct val_anchors* anchors, char* line)
{
struct trust_anchor *tp;
int r;
- ldns_rdf* rdf;
uint16_t dclass;
+ uint8_t* dname;
+ size_t dname_len;
/* read the owner name */
char* next = strchr(line, ' ');
if(!next)
return NULL;
next[0] = 0;
- rdf = ldns_dname_new_frm_str(line);
- if(!rdf)
+ dname = sldns_str2wire_dname(line, &dname_len);
+ if(!dname)
return NULL;
/* read the class */
dclass = parse_int(next+1, &r);
if(r == -1) {
- ldns_rdf_deep_free(rdf);
+ free(dname);
return NULL;
}
/* find the trust point */
- tp = autr_tp_create(anchors, rdf, dclass);
- ldns_rdf_deep_free(rdf);
+ tp = autr_tp_create(anchors, dname, dname_len, dclass);
+ free(dname);
return tp;
}
@@ -677,12 +886,12 @@ parse_var_line(char* line, struct val_anchors* anchors,
} else if(strncmp(line, ";;query_interval: ", 18) == 0) {
if(!tp) return -1;
lock_basic_lock(&tp->lock);
- tp->autr->query_interval = (uint32_t)parse_int(line+18, &r);
+ tp->autr->query_interval = (time_t)parse_int(line+18, &r);
lock_basic_unlock(&tp->lock);
} else if(strncmp(line, ";;retry_time: ", 14) == 0) {
if(!tp) return -1;
lock_basic_lock(&tp->lock);
- tp->autr->retry_time = (uint32_t)parse_int(line+14, &r);
+ tp->autr->retry_time = (time_t)parse_int(line+14, &r);
lock_basic_unlock(&tp->lock);
}
return r;
@@ -690,17 +899,19 @@ parse_var_line(char* line, struct val_anchors* anchors,
/** handle origin lines */
static int
-handle_origin(char* line, ldns_rdf** origin)
+handle_origin(char* line, uint8_t** origin, size_t* origin_len)
{
+ size_t len = 0;
while(isspace((int)*line))
line++;
if(strncmp(line, "$ORIGIN", 7) != 0)
return 0;
- ldns_rdf_deep_free(*origin);
+ free(*origin);
line += 7;
while(isspace((int)*line))
line++;
- *origin = ldns_dname_new_frm_str(line);
+ *origin = sldns_str2wire_dname(line, &len);
+ *origin_len = len;
if(!*origin)
log_warn("malloc failure or parse error in $ORIGIN");
return 1;
@@ -781,7 +992,8 @@ int autr_read_file(struct val_anchors* anchors, const char* nm)
struct trust_anchor *tp = NULL, *tp2;
int r;
/* for $ORIGIN parsing */
- ldns_rdf *origin=NULL, *prev=NULL;
+ uint8_t *origin=NULL, *prev=NULL;
+ size_t origin_len=0, prev_len=0;
if (!(fd = fopen(nm, "r"))) {
log_err("unable to open %s for reading: %s",
@@ -794,25 +1006,25 @@ int autr_read_file(struct val_anchors* anchors, const char* nm)
log_err("could not parse auto-trust-anchor-file "
"%s line %d", nm, line_nr);
fclose(fd);
- ldns_rdf_deep_free(origin);
- ldns_rdf_deep_free(prev);
+ free(origin);
+ free(prev);
return 0;
} else if(r == 1) {
continue;
} else if(r == 2) {
log_warn("trust anchor %s has been revoked", nm);
fclose(fd);
- ldns_rdf_deep_free(origin);
- ldns_rdf_deep_free(prev);
+ free(origin);
+ free(prev);
return 1;
}
if (!str_contains_data(line, ';'))
continue; /* empty lines allowed */
- if(handle_origin(line, &origin))
+ if(handle_origin(line, &origin, &origin_len))
continue;
r = 0;
- if(!(tp2=load_trustanchor(anchors, line, nm, origin, &prev,
- &r))) {
+ if(!(tp2=load_trustanchor(anchors, line, nm, origin,
+ origin_len, &prev, &prev_len, &r))) {
if(!r) log_err("failed to load trust anchor from %s "
"at line %i, skipping", nm, line_nr);
/* try to do the rest */
@@ -823,15 +1035,15 @@ int autr_read_file(struct val_anchors* anchors, const char* nm)
"the file may only contain keys for one name, "
"remove keys for other domain names", nm);
fclose(fd);
- ldns_rdf_deep_free(origin);
- ldns_rdf_deep_free(prev);
+ free(origin);
+ free(prev);
return 0;
}
tp = tp2;
}
fclose(fd);
- ldns_rdf_deep_free(origin);
- ldns_rdf_deep_free(prev);
+ free(origin);
+ free(prev);
if(!tp) {
log_err("failed to read %s", nm);
return 0;
@@ -865,39 +1077,24 @@ trustanchor_state2str(autr_state_t s)
/** print ID to file */
static int
-print_id(FILE* out, char* fname, struct module_env* env,
- uint8_t* nm, size_t nmlen, uint16_t dclass)
+print_id(FILE* out, char* fname, uint8_t* nm, size_t nmlen, uint16_t dclass)
{
- ldns_rdf rdf;
-#ifdef UNBOUND_DEBUG
- ldns_status s;
-#endif
-
- memset(&rdf, 0, sizeof(rdf));
- ldns_rdf_set_data(&rdf, nm);
- ldns_rdf_set_size(&rdf, nmlen);
- ldns_rdf_set_type(&rdf, LDNS_RDF_TYPE_DNAME);
-
- ldns_buffer_clear(env->scratch_buffer);
-#ifdef UNBOUND_DEBUG
- s =
-#endif
- ldns_rdf2buffer_str_dname(env->scratch_buffer, &rdf);
- log_assert(s == LDNS_STATUS_OK);
- ldns_buffer_write_u8(env->scratch_buffer, 0);
- ldns_buffer_flip(env->scratch_buffer);
- if(fprintf(out, ";;id: %s %d\n",
- (char*)ldns_buffer_begin(env->scratch_buffer),
- (int)dclass) < 0) {
+ char* s = sldns_wire2str_dname(nm, nmlen);
+ if(!s) {
+ log_err("malloc failure in write to %s", fname);
+ return 0;
+ }
+ if(fprintf(out, ";;id: %s %d\n", s, (int)dclass) < 0) {
log_err("could not write to %s: %s", fname, strerror(errno));
+ free(s);
return 0;
}
+ free(s);
return 1;
}
static int
-autr_write_contents(FILE* out, char* fn, struct module_env* env,
- struct trust_anchor* tp)
+autr_write_contents(FILE* out, char* fn, struct trust_anchor* tp)
{
char tmi[32];
struct autr_ta* ta;
@@ -919,7 +1116,7 @@ autr_write_contents(FILE* out, char* fn, struct module_env* env,
return 0;
}
}
- if(!print_id(out, fn, env, tp->name, tp->namelen, tp->dclass)) {
+ if(!print_id(out, fn, tp->name, tp->namelen, tp->dclass)) {
return 0;
}
if(fprintf(out, ";;last_queried: %u ;;%s",
@@ -947,9 +1144,10 @@ autr_write_contents(FILE* out, char* fn, struct module_env* env,
if(ta->s == AUTR_STATE_REMOVED)
continue;
/* only store keys */
- if(ldns_rr_get_type(ta->rr) != LDNS_RR_TYPE_DNSKEY)
+ if(sldns_wirerr_get_type(ta->rr, ta->rr_len, ta->dname_len)
+ != LDNS_RR_TYPE_DNSKEY)
continue;
- str = ldns_rr2str(ta->rr);
+ str = sldns_wire2str_rr(ta->rr, ta->rr_len);
if(!str || !str[0]) {
free(str);
log_err("malloc failure writing %s", fn);
@@ -976,9 +1174,13 @@ void autr_write_file(struct module_env* env, struct trust_anchor* tp)
char* fname = tp->autr->file;
char tempf[2048];
log_assert(tp->autr);
+ if(!env) {
+ log_err("autr_write_file: Module environment is NULL.");
+ return;
+ }
/* unique name with pid number and thread number */
snprintf(tempf, sizeof(tempf), "%s.%d-%d", fname, (int)getpid(),
- env&&env->worker?*(int*)env->worker:0);
+ env->worker?*(int*)env->worker:0);
verbose(VERB_ALGO, "autotrust: write to disk: %s", tempf);
out = fopen(tempf, "w");
if(!out) {
@@ -986,15 +1188,20 @@ void autr_write_file(struct module_env* env, struct trust_anchor* tp)
tempf, strerror(errno));
return;
}
- if(!autr_write_contents(out, tempf, env, tp)) {
+ if(!autr_write_contents(out, tempf, tp)) {
/* failed to write contents (completely) */
fclose(out);
unlink(tempf);
log_err("could not completely write: %s", fname);
return;
}
+ if(fclose(out) != 0) {
+ log_err("could not complete write: %s: %s",
+ fname, strerror(errno));
+ unlink(tempf);
+ return;
+ }
/* success; overwrite actual file */
- fclose(out);
verbose(VERB_ALGO, "autotrust: replaced %s", fname);
#ifdef UB_ON_WINDOWS
(void)unlink(fname); /* windows does not replace file with rename() */
@@ -1030,24 +1237,30 @@ verify_dnskey(struct module_env* env, struct val_env* ve,
return sec == sec_status_secure;
}
+static int32_t
+rrsig_get_expiry(uint8_t* d, size_t len)
+{
+ /* rrsig: 2(rdlen), 2(type) 1(alg) 1(v) 4(origttl), then 4(expi), (4)incep) */
+ if(len < 2+8+4)
+ return 0;
+ return sldns_read_uint32(d+2+8);
+}
+
/** Find minimum expiration interval from signatures */
-static uint32_t
-min_expiry(struct module_env* env, ldns_rr_list* rrset)
+static time_t
+min_expiry(struct module_env* env, struct packed_rrset_data* dd)
{
size_t i;
- uint32_t t, r = 15 * 24 * 3600; /* 15 days max */
- for(i=0; i<ldns_rr_list_rr_count(rrset); i++) {
- ldns_rr* rr = ldns_rr_list_rr(rrset, i);
- if(ldns_rr_get_type(rr) != LDNS_RR_TYPE_RRSIG)
- continue;
- t = ldns_rdf2native_int32(ldns_rr_rrsig_expiration(rr));
- if(t - *env->now > 0) {
- t -= *env->now;
+ int32_t t, r = 15 * 24 * 3600; /* 15 days max */
+ for(i=dd->count; i<dd->count+dd->rrsig_count; i++) {
+ t = rrsig_get_expiry(dd->rr_data[i], dd->rr_len[i]);
+ if((int32_t)t - (int32_t)*env->now > 0) {
+ t -= (int32_t)*env->now;
if(t < r)
r = t;
}
}
- return r;
+ return (time_t)r;
}
/** Is rr self-signed revoked key */
@@ -1086,131 +1299,92 @@ seen_revoked_trustanchor(struct autr_ta* ta, uint8_t revoked)
static void
revoke_dnskey(struct autr_ta* ta, int off)
{
- ldns_rdf* rdf;
- uint16_t flags;
- log_assert(ta && ta->rr);
- if(ldns_rr_get_type(ta->rr) != LDNS_RR_TYPE_DNSKEY)
+ uint16_t flags;
+ uint8_t* data;
+ if(sldns_wirerr_get_type(ta->rr, ta->rr_len, ta->dname_len) !=
+ LDNS_RR_TYPE_DNSKEY)
return;
- rdf = ldns_rr_dnskey_flags(ta->rr);
- flags = ldns_read_uint16(ldns_rdf_data(rdf));
-
+ if(sldns_wirerr_get_rdatalen(ta->rr, ta->rr_len, ta->dname_len) < 2)
+ return;
+ data = sldns_wirerr_get_rdata(ta->rr, ta->rr_len, ta->dname_len);
+ flags = sldns_read_uint16(data);
if (off && (flags&LDNS_KEY_REVOKE_KEY))
flags ^= LDNS_KEY_REVOKE_KEY; /* flip */
else
flags |= LDNS_KEY_REVOKE_KEY;
- ldns_write_uint16(ldns_rdf_data(rdf), flags);
+ sldns_write_uint16(data, flags);
}
-/** Compare two RR buffers skipping the REVOKED bit */
+/** Compare two RRs skipping the REVOKED bit. Pass rdata(no len) */
static int
-ldns_rr_compare_wire_skip_revbit(ldns_buffer* rr1_buf, ldns_buffer* rr2_buf)
-{
- size_t rr1_len, rr2_len, min_len, i, offset;
- rr1_len = ldns_buffer_capacity(rr1_buf);
- rr2_len = ldns_buffer_capacity(rr2_buf);
- /* jump past dname (checked in earlier part) and especially past TTL */
- offset = 0;
- while (offset < rr1_len && *ldns_buffer_at(rr1_buf, offset) != 0)
- offset += *ldns_buffer_at(rr1_buf, offset) + 1;
- /* jump to rdata section (PAST the rdata length field) */
- offset += 11; /* 0-dname-end + type + class + ttl + rdatalen */
- min_len = (rr1_len < rr2_len) ? rr1_len : rr2_len;
+dnskey_compare_skip_revbit(uint8_t* a, size_t a_len, uint8_t* b, size_t b_len)
+{
+ size_t i;
+ if(a_len != b_len)
+ return -1;
/* compare RRs RDATA byte for byte. */
- for(i = offset; i < min_len; i++)
+ for(i = 0; i < a_len; i++)
{
- uint8_t *rdf1, *rdf2;
- rdf1 = ldns_buffer_at(rr1_buf, i);
- rdf2 = ldns_buffer_at(rr2_buf, i);
- if (i==(offset+1))
- {
+ uint8_t rdf1, rdf2;
+ rdf1 = a[i];
+ rdf2 = b[i];
+ if(i==1) {
/* this is the second part of the flags field */
- *rdf1 = *rdf1 | LDNS_KEY_REVOKE_KEY;
- *rdf2 = *rdf2 | LDNS_KEY_REVOKE_KEY;
+ rdf1 |= LDNS_KEY_REVOKE_KEY;
+ rdf2 |= LDNS_KEY_REVOKE_KEY;
}
- if (*rdf1 < *rdf2) return -1;
- else if (*rdf1 > *rdf2) return 1;
+ if (rdf1 < rdf2) return -1;
+ else if (rdf1 > rdf2) return 1;
}
return 0;
}
-/** Compare two RRs skipping the REVOKED bit */
-static int
-ldns_rr_compare_skip_revbit(const ldns_rr* rr1, const ldns_rr* rr2, int* result)
-{
- size_t rr1_len, rr2_len;
- ldns_buffer* rr1_buf;
- ldns_buffer* rr2_buf;
- *result = ldns_rr_compare_no_rdata(rr1, rr2);
- if (*result == 0)
- {
- rr1_len = ldns_rr_uncompressed_size(rr1);
- rr2_len = ldns_rr_uncompressed_size(rr2);
- rr1_buf = ldns_buffer_new(rr1_len);
- rr2_buf = ldns_buffer_new(rr2_len);
- if(!rr1_buf || !rr2_buf) {
- ldns_buffer_free(rr1_buf);
- ldns_buffer_free(rr2_buf);
- return 0;
- }
- if (ldns_rr2buffer_wire_canonical(rr1_buf, rr1,
- LDNS_SECTION_ANY) != LDNS_STATUS_OK)
- {
- ldns_buffer_free(rr1_buf);
- ldns_buffer_free(rr2_buf);
- return 0;
- }
- if (ldns_rr2buffer_wire_canonical(rr2_buf, rr2,
- LDNS_SECTION_ANY) != LDNS_STATUS_OK) {
- ldns_buffer_free(rr1_buf);
- ldns_buffer_free(rr2_buf);
- return 0;
- }
- *result = ldns_rr_compare_wire_skip_revbit(rr1_buf, rr2_buf);
- ldns_buffer_free(rr1_buf);
- ldns_buffer_free(rr2_buf);
- }
- return 1;
-}
-
-
-/** compare two trust anchors */
+/** compare trust anchor with rdata, 0 if equal. Pass rdata(no len) */
static int
-ta_compare(ldns_rr* a, ldns_rr* b, int* result)
-{
- if (!a && !b) *result = 0;
- else if (!a) *result = -1;
- else if (!b) *result = 1;
- else if (ldns_rr_get_type(a) != ldns_rr_get_type(b))
- *result = (int)ldns_rr_get_type(a) - (int)ldns_rr_get_type(b);
- else if (ldns_rr_get_type(a) == LDNS_RR_TYPE_DNSKEY) {
- if(!ldns_rr_compare_skip_revbit(a, b, result))
- return 0;
+ta_compare(struct autr_ta* a, uint16_t t, uint8_t* b, size_t b_len)
+{
+ if(!a) return -1;
+ else if(!b) return -1;
+ else if(sldns_wirerr_get_type(a->rr, a->rr_len, a->dname_len) != t)
+ return (int)sldns_wirerr_get_type(a->rr, a->rr_len,
+ a->dname_len) - (int)t;
+ else if(t == LDNS_RR_TYPE_DNSKEY) {
+ return dnskey_compare_skip_revbit(
+ sldns_wirerr_get_rdata(a->rr, a->rr_len, a->dname_len),
+ sldns_wirerr_get_rdatalen(a->rr, a->rr_len,
+ a->dname_len), b, b_len);
+ }
+ else if(t == LDNS_RR_TYPE_DS) {
+ if(sldns_wirerr_get_rdatalen(a->rr, a->rr_len, a->dname_len) !=
+ b_len)
+ return -1;
+ return memcmp(sldns_wirerr_get_rdata(a->rr,
+ a->rr_len, a->dname_len), b, b_len);
}
- else if (ldns_rr_get_type(a) == LDNS_RR_TYPE_DS)
- *result = ldns_rr_compare(a, b);
- else *result = -1;
- return 1;
+ return -1;
}
/**
* Find key
* @param tp: to search in
- * @param rr: to look for
+ * @param t: rr type of the rdata.
+ * @param rdata: to look for (no rdatalen in it)
+ * @param rdata_len: length of rdata
* @param result: returns NULL or the ta key looked for.
* @return false on malloc failure during search. if true examine result.
*/
static int
-find_key(struct trust_anchor* tp, ldns_rr* rr, struct autr_ta** result)
+find_key(struct trust_anchor* tp, uint16_t t, uint8_t* rdata, size_t rdata_len,
+ struct autr_ta** result)
{
struct autr_ta* ta;
- int ret;
- if(!tp || !rr)
+ if(!tp || !rdata) {
+ *result = NULL;
return 0;
+ }
for(ta=tp->autr->keys; ta; ta=ta->next) {
- if(!ta_compare(ta->rr, rr, &ret))
- return 0;
- if(ret == 0) {
+ if(ta_compare(ta, t, rdata, rdata_len) == 0) {
*result = ta;
return 1;
}
@@ -1219,17 +1393,30 @@ find_key(struct trust_anchor* tp, ldns_rr* rr, struct autr_ta** result)
return 1;
}
-/** add key and clone RR and tp already locked */
+/** add key and clone RR and tp already locked. rdata without rdlen. */
static struct autr_ta*
-add_key(struct trust_anchor* tp, ldns_rr* rr)
+add_key(struct trust_anchor* tp, uint32_t ttl, uint8_t* rdata, size_t rdata_len)
{
- ldns_rr* c;
struct autr_ta* ta;
- c = ldns_rr_clone(rr);
- if(!c) return NULL;
- ta = autr_ta_create(c);
+ uint8_t* rr;
+ size_t rr_len, dname_len;
+ uint16_t rrtype = htons(LDNS_RR_TYPE_DNSKEY);
+ uint16_t rrclass = htons(LDNS_RR_CLASS_IN);
+ uint16_t rdlen = htons(rdata_len);
+ dname_len = tp->namelen;
+ ttl = htonl(ttl);
+ rr_len = dname_len + 10 /* type,class,ttl,rdatalen */ + rdata_len;
+ rr = (uint8_t*)malloc(rr_len);
+ if(!rr) return NULL;
+ memmove(rr, tp->name, tp->namelen);
+ memmove(rr+dname_len, &rrtype, 2);
+ memmove(rr+dname_len+2, &rrclass, 2);
+ memmove(rr+dname_len+4, &ttl, 4);
+ memmove(rr+dname_len+8, &rdlen, 2);
+ memmove(rr+dname_len+10, rdata, rdata_len);
+ ta = autr_ta_create(rr, rr_len, dname_len);
if(!ta) {
- ldns_rr_free(c);
+ /* rr freed in autr_ta_create */
return NULL;
}
/* link in, tp already locked */
@@ -1239,7 +1426,7 @@ add_key(struct trust_anchor* tp, ldns_rr* rr)
}
/** get TTL from DNSKEY rrset */
-static uint32_t
+static time_t
key_ttl(struct ub_packed_rrset_key* k)
{
struct packed_rrset_data* d = (struct packed_rrset_data*)k->entry.data;
@@ -1248,10 +1435,10 @@ key_ttl(struct ub_packed_rrset_key* k)
/** update the time values for the trustpoint */
static void
-set_tp_times(struct trust_anchor* tp, uint32_t rrsig_exp_interval,
- uint32_t origttl, int* changed)
+set_tp_times(struct trust_anchor* tp, time_t rrsig_exp_interval,
+ time_t origttl, int* changed)
{
- uint32_t x, qi = tp->autr->query_interval, rt = tp->autr->retry_time;
+ time_t x, qi = tp->autr->query_interval, rt = tp->autr->retry_time;
/* x = MIN(15days, ttl/2, expire/2) */
x = 15 * 24 * 3600;
@@ -1302,21 +1489,19 @@ check_contains_revoked(struct module_env* env, struct val_env* ve,
struct trust_anchor* tp, struct ub_packed_rrset_key* dnskey_rrset,
int* changed)
{
- ldns_rr_list* r = packed_rrset_to_rr_list(dnskey_rrset,
- env->scratch_buffer);
+ struct packed_rrset_data* dd = (struct packed_rrset_data*)
+ dnskey_rrset->entry.data;
size_t i;
- if(!r) {
- log_err("malloc failure");
- return;
- }
- for(i=0; i<ldns_rr_list_rr_count(r); i++) {
- ldns_rr* rr = ldns_rr_list_rr(r, i);
+ log_assert(ntohs(dnskey_rrset->rk.type) == LDNS_RR_TYPE_DNSKEY);
+ for(i=0; i<dd->count; i++) {
struct autr_ta* ta = NULL;
- if(ldns_rr_get_type(rr) != LDNS_RR_TYPE_DNSKEY)
- continue;
- if(!rr_is_dnskey_sep(rr) || !rr_is_dnskey_revoked(rr))
+ if(!rr_is_dnskey_sep(ntohs(dnskey_rrset->rk.type),
+ dd->rr_data[i]+2, dd->rr_len[i]-2) ||
+ !rr_is_dnskey_revoked(ntohs(dnskey_rrset->rk.type),
+ dd->rr_data[i]+2, dd->rr_len[i]-2))
continue; /* not a revoked KSK */
- if(!find_key(tp, rr, &ta)) {
+ if(!find_key(tp, ntohs(dnskey_rrset->rk.type),
+ dd->rr_data[i]+2, dd->rr_len[i]-2, &ta)) {
log_err("malloc failure");
continue; /* malloc fail in compare*/
}
@@ -1324,8 +1509,18 @@ check_contains_revoked(struct module_env* env, struct val_env* ve,
continue; /* key not found */
if(rr_is_selfsigned_revoked(env, ve, dnskey_rrset, i)) {
/* checked if there is an rrsig signed by this key. */
- log_assert(dnskey_calc_keytag(dnskey_rrset, i) ==
- ldns_calc_keytag(rr)); /* checks conversion*/
+ /* same keytag, but stored can be revoked already, so
+ * compare keytags, with +0 or +128(REVOKE flag) */
+ log_assert(dnskey_calc_keytag(dnskey_rrset, i)-128 ==
+ sldns_calc_keytag_raw(sldns_wirerr_get_rdata(
+ ta->rr, ta->rr_len, ta->dname_len),
+ sldns_wirerr_get_rdatalen(ta->rr, ta->rr_len,
+ ta->dname_len)) ||
+ dnskey_calc_keytag(dnskey_rrset, i) ==
+ sldns_calc_keytag_raw(sldns_wirerr_get_rdata(
+ ta->rr, ta->rr_len, ta->dname_len),
+ sldns_wirerr_get_rdatalen(ta->rr, ta->rr_len,
+ ta->dname_len))); /* checks conversion*/
verbose_key(ta, VERB_ALGO, "is self-signed revoked");
if(!ta->revoked)
*changed = 1;
@@ -1333,7 +1528,6 @@ check_contains_revoked(struct module_env* env, struct val_env* ve,
do_revoked(env, ta, changed);
}
}
- ldns_rr_list_deep_free(r);
}
/** See if a DNSKEY is verified by one of the DSes */
@@ -1380,20 +1574,18 @@ update_events(struct module_env* env, struct val_env* ve,
struct trust_anchor* tp, struct ub_packed_rrset_key* dnskey_rrset,
int* changed)
{
- ldns_rr_list* r = packed_rrset_to_rr_list(dnskey_rrset,
- env->scratch_buffer);
+ struct packed_rrset_data* dd = (struct packed_rrset_data*)
+ dnskey_rrset->entry.data;
size_t i;
- if(!r)
- return 0;
+ log_assert(ntohs(dnskey_rrset->rk.type) == LDNS_RR_TYPE_DNSKEY);
init_events(tp);
- for(i=0; i<ldns_rr_list_rr_count(r); i++) {
- ldns_rr* rr = ldns_rr_list_rr(r, i);
+ for(i=0; i<dd->count; i++) {
struct autr_ta* ta = NULL;
- if(ldns_rr_get_type(rr) != LDNS_RR_TYPE_DNSKEY)
- continue;
- if(!rr_is_dnskey_sep(rr))
+ if(!rr_is_dnskey_sep(ntohs(dnskey_rrset->rk.type),
+ dd->rr_data[i]+2, dd->rr_len[i]-2))
continue;
- if(rr_is_dnskey_revoked(rr)) {
+ if(rr_is_dnskey_revoked(ntohs(dnskey_rrset->rk.type),
+ dd->rr_data[i]+2, dd->rr_len[i]-2)) {
/* self-signed revoked keys already detected before,
* other revoked keys are not 'added' again */
continue;
@@ -1409,12 +1601,13 @@ update_events(struct module_env* env, struct val_env* ve,
}
/* is it new? if revocation bit set, find the unrevoked key */
- if(!find_key(tp, rr, &ta)) {
- ldns_rr_list_deep_free(r); /* malloc fail in compare*/
+ if(!find_key(tp, ntohs(dnskey_rrset->rk.type),
+ dd->rr_data[i]+2, dd->rr_len[i]-2, &ta)) {
return 0;
}
if(!ta) {
- ta = add_key(tp, rr);
+ ta = add_key(tp, (uint32_t)dd->rr_ttl[i],
+ dd->rr_data[i]+2, dd->rr_len[i]-2);
*changed = 1;
/* first time seen, do we have DSes? if match: VALID */
if(ta && tp->ds_rrset && key_matches_a_ds(env, ve,
@@ -1424,14 +1617,12 @@ update_events(struct module_env* env, struct val_env* ve,
}
}
if(!ta) {
- ldns_rr_list_deep_free(r);
return 0;
}
seen_trustanchor(ta, 1);
verbose_key(ta, VERB_ALGO, "in DNS response");
}
- set_tp_times(tp, min_expiry(env, r), key_ttl(dnskey_rrset), changed);
- ldns_rr_list_deep_free(r);
+ set_tp_times(tp, min_expiry(env, dd), key_ttl(dnskey_rrset), changed);
return 1;
}
@@ -1444,21 +1635,21 @@ update_events(struct module_env* env, struct val_env* ve,
* @param holddown: the timer value
* @return number of seconds the holddown has passed.
*/
-static int
-check_holddown(struct module_env* env, struct autr_ta* ta,
+static time_t
+check_holddown(struct module_env* env, struct autr_ta* ta,
unsigned int holddown)
{
- unsigned int elapsed;
- if((unsigned)*env->now < (unsigned)ta->last_change) {
+ time_t elapsed;
+ if(*env->now < ta->last_change) {
log_warn("time goes backwards. delaying key holddown");
return 0;
}
- elapsed = (unsigned)*env->now - (unsigned)ta->last_change;
- if (elapsed > holddown) {
- return (int) (elapsed-holddown);
+ elapsed = *env->now - ta->last_change;
+ if (elapsed > (time_t)holddown) {
+ return elapsed-(time_t)holddown;
}
- verbose_key(ta, VERB_ALGO, "holddown time %d seconds to go",
- (int) (holddown-elapsed));
+ verbose_key(ta, VERB_ALGO, "holddown time " ARG_LL "d seconds to go",
+ (long long) ((time_t)holddown-elapsed));
return 0;
}
@@ -1498,11 +1689,11 @@ do_addtime(struct module_env* env, struct autr_ta* anchor, int* c)
/* This not according to RFC, this is 30 days, but the RFC demands
* MAX(30days, TTL expire time of first DNSKEY set with this key),
* The value may be too small if a very large TTL was used. */
- int exceeded = check_holddown(env, anchor, env->cfg->add_holddown);
+ time_t exceeded = check_holddown(env, anchor, env->cfg->add_holddown);
if (exceeded && anchor->s == AUTR_STATE_ADDPEND) {
verbose_key(anchor, VERB_ALGO, "add-holddown time exceeded "
- "%d seconds ago, and pending-count %d", exceeded,
- anchor->pending_count);
+ ARG_LL "d seconds ago, and pending-count %d",
+ (long long)exceeded, anchor->pending_count);
if(anchor->pending_count >= MIN_PENDINGCOUNT) {
set_trustanchor_state(env, anchor, c, AUTR_STATE_VALID);
anchor->pending_count = 0;
@@ -1517,10 +1708,10 @@ do_addtime(struct module_env* env, struct autr_ta* anchor, int* c)
static void
do_remtime(struct module_env* env, struct autr_ta* anchor, int* c)
{
- int exceeded = check_holddown(env, anchor, env->cfg->del_holddown);
+ time_t exceeded = check_holddown(env, anchor, env->cfg->del_holddown);
if(exceeded && anchor->s == AUTR_STATE_REVOKED) {
verbose_key(anchor, VERB_ALGO, "del-holddown time exceeded "
- "%d seconds ago", exceeded);
+ ARG_LL "d seconds ago", (long long)exceeded);
set_trustanchor_state(env, anchor, c, AUTR_STATE_REMOVED);
}
}
@@ -1622,16 +1813,17 @@ init_zsk_to_ksk(struct module_env* env, struct trust_anchor* tp, int* changed)
int validksk = 0;
for(anchor = tp->autr->keys; anchor; anchor = anchor->next) {
/* last_change test makes sure it was manually configured */
- if (ldns_rr_get_type(anchor->rr) == LDNS_RR_TYPE_DNSKEY &&
+ if(sldns_wirerr_get_type(anchor->rr, anchor->rr_len,
+ anchor->dname_len) == LDNS_RR_TYPE_DNSKEY &&
anchor->last_change == 0 &&
- !rr_is_dnskey_sep(anchor->rr) &&
+ !ta_is_dnskey_sep(anchor) &&
anchor->s == AUTR_STATE_VALID)
validzsk++;
}
if(validzsk == 0)
return 0;
for(anchor = tp->autr->keys; anchor; anchor = anchor->next) {
- if (rr_is_dnskey_sep(anchor->rr) &&
+ if (ta_is_dnskey_sep(anchor) &&
anchor->s == AUTR_STATE_ADDPEND) {
verbose_key(anchor, VERB_ALGO, "trust KSK from "
"ZSK(config)");
@@ -1649,12 +1841,12 @@ remove_missing_trustanchors(struct module_env* env, struct trust_anchor* tp,
int* changed)
{
struct autr_ta* anchor;
- int exceeded;
+ time_t exceeded;
int valid = 0;
/* see if we have anchors that are valid */
for(anchor = tp->autr->keys; anchor; anchor = anchor->next) {
/* Only do KSKs */
- if (!rr_is_dnskey_sep(anchor->rr))
+ if (!ta_is_dnskey_sep(anchor))
continue;
if (anchor->s == AUTR_STATE_VALID)
valid++;
@@ -1677,7 +1869,7 @@ remove_missing_trustanchors(struct module_env* env, struct trust_anchor* tp,
if(anchor->s == AUTR_STATE_START)
continue;
/* remove ZSKs if a KSK is present */
- if (!rr_is_dnskey_sep(anchor->rr)) {
+ if (!ta_is_dnskey_sep(anchor)) {
if(valid > 0) {
verbose_key(anchor, VERB_ALGO, "remove ZSK "
"[%d key(s) VALID]", valid);
@@ -1697,8 +1889,8 @@ remove_missing_trustanchors(struct module_env* env, struct trust_anchor* tp,
* one valid KSK: remove missing trust anchor */
if (exceeded && valid > 0) {
verbose_key(anchor, VERB_ALGO, "keep-missing time "
- "exceeded %d seconds ago, [%d key(s) VALID]",
- exceeded, valid);
+ "exceeded " ARG_LL "d seconds ago, [%d key(s) VALID]",
+ (long long)exceeded, valid);
set_trustanchor_state(env, anchor, changed,
AUTR_STATE_REMOVED);
}
@@ -1712,7 +1904,7 @@ do_statetable(struct module_env* env, struct trust_anchor* tp, int* changed)
struct autr_ta* anchor;
for(anchor = tp->autr->keys; anchor; anchor = anchor->next) {
/* Only do KSKs */
- if(!rr_is_dnskey_sep(anchor->rr))
+ if(!ta_is_dnskey_sep(anchor))
continue;
anchor_state_update(env, anchor, changed);
}
@@ -1726,7 +1918,7 @@ autr_holddown_exceed(struct module_env* env, struct trust_anchor* tp, int* c)
{
struct autr_ta* anchor;
for(anchor = tp->autr->keys; anchor; anchor = anchor->next) {
- if(rr_is_dnskey_sep(anchor->rr) &&
+ if(ta_is_dnskey_sep(anchor) &&
anchor->s == AUTR_STATE_ADDPEND)
do_addtime(env, anchor, c);
}
@@ -1742,10 +1934,11 @@ autr_cleanup_keys(struct trust_anchor* tp)
while(p) {
/* do we want to remove this key? */
if(p->s == AUTR_STATE_START || p->s == AUTR_STATE_REMOVED ||
- ldns_rr_get_type(p->rr) != LDNS_RR_TYPE_DNSKEY) {
+ sldns_wirerr_get_type(p->rr, p->rr_len, p->dname_len)
+ != LDNS_RR_TYPE_DNSKEY) {
struct autr_ta* np = p->next;
/* remove */
- ldns_rr_free(p->rr);
+ free(p->rr);
free(p);
/* snip and go to next item */
*prevp = np;
@@ -1762,15 +1955,15 @@ autr_cleanup_keys(struct trust_anchor* tp)
/** calculate next probe time */
static time_t
-calc_next_probe(struct module_env* env, uint32_t wait)
+calc_next_probe(struct module_env* env, time_t wait)
{
/* make it random, 90-100% */
- uint32_t rnd, rest;
+ time_t rnd, rest;
if(wait < 3600)
wait = 3600;
rnd = wait/10;
rest = wait-rnd;
- rnd = (uint32_t)ub_random_max(env->rnd, (long int)rnd);
+ rnd = (time_t)ub_random_max(env->rnd, (long int)rnd);
return (time_t)(*env->now + rest + rnd);
}
@@ -1790,7 +1983,7 @@ reset_worker_timer(struct module_env* env)
{
struct timeval tv;
#ifndef S_SPLINT_S
- uint32_t next = (uint32_t)wait_probe_time(env->anchors);
+ time_t next = (time_t)wait_probe_time(env->anchors);
/* in case this is libunbound, no timer */
if(!env->probe_timer)
return;
@@ -1800,7 +1993,7 @@ reset_worker_timer(struct module_env* env)
#endif
tv.tv_usec = 0;
comm_timer_set(env->probe_timer, &tv);
- verbose(VERB_ALGO, "scheduled next probe in %d sec", (int)tv.tv_sec);
+ verbose(VERB_ALGO, "scheduled next probe in " ARG_LL "d sec", (long long)tv.tv_sec);
}
/** set next probe for trust anchor */
@@ -2017,7 +2210,7 @@ static void
autr_debug_print_ta(struct autr_ta* ta)
{
char buf[32];
- char* str = ldns_rr2str(ta->rr);
+ char* str = sldns_wire2str_rr(ta->rr, ta->rr_len);
if(!str) {
log_info("out of memory in debug_print_ta");
return;
@@ -2043,20 +2236,11 @@ autr_debug_print_tp(struct trust_anchor* tp)
log_info("trust point %s : %d", buf, (int)tp->dclass);
log_info("assembled %d DS and %d DNSKEYs",
(int)tp->numDS, (int)tp->numDNSKEY);
- if(0) { /* turned off because it prints to stderr */
- ldns_buffer* bf = ldns_buffer_new(70000);
- ldns_rr_list* list;
- if(tp->ds_rrset) {
- list = packed_rrset_to_rr_list(tp->ds_rrset, bf);
- ldns_rr_list_print(stderr, list);
- ldns_rr_list_deep_free(list);
- }
- if(tp->dnskey_rrset) {
- list = packed_rrset_to_rr_list(tp->dnskey_rrset, bf);
- ldns_rr_list_print(stderr, list);
- ldns_rr_list_deep_free(list);
- }
- ldns_buffer_free(bf);
+ if(tp->ds_rrset) {
+ log_packed_rrset(0, "DS:", tp->ds_rrset);
+ }
+ if(tp->dnskey_rrset) {
+ log_packed_rrset(0, "DNSKEY:", tp->dnskey_rrset);
}
log_info("file %s", tp->autr->file);
ctime_r(&tp->autr->last_queried, buf);
@@ -2092,7 +2276,7 @@ autr_debug_print(struct val_anchors* anchors)
}
void probe_answer_cb(void* arg, int ATTR_UNUSED(rcode),
- ldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(sec),
+ sldns_buffer* ATTR_UNUSED(buf), enum sec_status ATTR_UNUSED(sec),
char* ATTR_UNUSED(why_bogus))
{
/* retry was set before the query was done,
@@ -2117,7 +2301,7 @@ probe_anchor(struct module_env* env, struct trust_anchor* tp)
struct query_info qinfo;
uint16_t qflags = BIT_RD;
struct edns_data edns;
- ldns_buffer* buf = env->scratch_buffer;
+ sldns_buffer* buf = env->scratch_buffer;
qinfo.qname = regional_alloc_init(env->scratch, tp->name, tp->namelen);
if(!qinfo.qname) {
log_err("out of memory making 5011 probe");
@@ -2133,8 +2317,8 @@ probe_anchor(struct module_env* env, struct trust_anchor* tp)
edns.ext_rcode = 0;
edns.edns_version = 0;
edns.bits = EDNS_DO;
- if(ldns_buffer_capacity(buf) < 65535)
- edns.udp_size = (uint16_t)ldns_buffer_capacity(buf);
+ if(sldns_buffer_capacity(buf) < 65535)
+ edns.udp_size = (uint16_t)sldns_buffer_capacity(buf);
else edns.udp_size = 65535;
/* can't hold the lock while mesh_run is processing */
@@ -2156,7 +2340,7 @@ probe_anchor(struct module_env* env, struct trust_anchor* tp)
/** fetch first to-probe trust-anchor and lock it and set retrytime */
static struct trust_anchor*
-todo_probe(struct module_env* env, uint32_t* next)
+todo_probe(struct module_env* env, time_t* next)
{
struct trust_anchor* tp;
rbnode_t* el;
@@ -2171,9 +2355,9 @@ todo_probe(struct module_env* env, uint32_t* next)
lock_basic_lock(&tp->lock);
/* is it eligible? */
- if((uint32_t)tp->autr->next_probe_time > *env->now) {
+ if((time_t)tp->autr->next_probe_time > *env->now) {
/* no more to probe */
- *next = (uint32_t)tp->autr->next_probe_time - *env->now;
+ *next = (time_t)tp->autr->next_probe_time - *env->now;
lock_basic_unlock(&tp->lock);
lock_basic_unlock(&env->anchors->lock);
return NULL;
@@ -2188,11 +2372,11 @@ todo_probe(struct module_env* env, uint32_t* next)
return tp;
}
-uint32_t
+time_t
autr_probe_timer(struct module_env* env)
{
struct trust_anchor* tp;
- uint32_t next_probe = 3600;
+ time_t next_probe = 3600;
int num = 0;
verbose(VERB_ALGO, "autotrust probe timer callback");
/* while there are still anchors to probe */
diff --git a/contrib/unbound/validator/autotrust.h b/contrib/unbound/validator/autotrust.h
index 4e88ed3..ae61f8a 100644
--- a/contrib/unbound/validator/autotrust.h
+++ b/contrib/unbound/validator/autotrust.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -48,6 +48,7 @@ struct trust_anchor;
struct ub_packed_rrset_key;
struct module_env;
struct val_env;
+struct sldns_buffer;
/** Autotrust anchor states */
typedef enum {
@@ -66,7 +67,9 @@ struct autr_ta {
/** next key */
struct autr_ta* next;
/** the RR */
- ldns_rr* rr;
+ uint8_t* rr;
+ /** length of rr */
+ size_t rr_len, dname_len;
/** last update of key state (new pending count keeps date the same) */
time_t last_change;
/** 5011 state */
@@ -104,9 +107,9 @@ struct autr_point_data {
time_t next_probe_time;
/** when to query if !failed */
- uint32_t query_interval;
+ time_t query_interval;
/** when to retry if failed */
- uint32_t retry_time;
+ time_t retry_time;
/**
* How many times did it fail. diagnostic only (has no effect).
@@ -151,7 +154,7 @@ size_t autr_get_num_anchors(struct val_anchors* anchors);
* @return time of next probe (in seconds from now).
* If 0, then there is no next probe anymore (trust points deleted).
*/
-uint32_t autr_probe_timer(struct module_env* env);
+time_t autr_probe_timer(struct module_env* env);
/** probe tree compare function */
int probetree_cmp(const void* x, const void* y);
@@ -199,7 +202,7 @@ int autr_process_prime(struct module_env* env, struct val_env* ve,
void autr_debug_print(struct val_anchors* anchors);
/** callback for query answer to 5011 probe */
-void probe_answer_cb(void* arg, int rcode, ldns_buffer* buf,
+void probe_answer_cb(void* arg, int rcode, struct sldns_buffer* buf,
enum sec_status sec, char* errinf);
#endif /* VALIDATOR_AUTOTRUST_H */
diff --git a/contrib/unbound/validator/val_anchor.c b/contrib/unbound/validator/val_anchor.c
index cc551f8..a4adfe2 100644
--- a/contrib/unbound/validator/val_anchor.c
+++ b/contrib/unbound/validator/val_anchor.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,8 +40,6 @@
*/
#include "config.h"
#include <ctype.h>
-#include <ldns/dname.h>
-#include <ldns/host2wire.h>
#include "validator/val_anchor.h"
#include "validator/val_sigcrypt.h"
#include "validator/autotrust.h"
@@ -50,6 +48,9 @@
#include "util/log.h"
#include "util/net_help.h"
#include "util/config_file.h"
+#include "ldns/sbuffer.h"
+#include "ldns/rrdef.h"
+#include "ldns/str2wire.h"
#ifdef HAVE_GLOB_H
#include <glob.h>
#endif
@@ -242,6 +243,8 @@ anchor_new_ta(struct val_anchors* anchors, uint8_t* name, int namelabs,
}
#ifdef UNBOUND_DEBUG
r =
+#else
+ (void)
#endif
rbtree_insert(anchors->tree, &ta->node);
if(lockit) {
@@ -344,36 +347,26 @@ anchor_store_new_key(struct val_anchors* anchors, uint8_t* name, uint16_t type,
/**
* Add new RR. It converts ldns RR to wire format.
* @param anchors: anchor storage.
- * @param buffer: parsing buffer.
- * @param rr: the rr (allocated by caller).
+ * @param rr: the wirerr.
+ * @param rl: length of rr.
+ * @param dl: length of dname.
* @return NULL on error, else the trust anchor.
*/
static struct trust_anchor*
-anchor_store_new_rr(struct val_anchors* anchors, ldns_buffer* buffer,
- ldns_rr* rr)
+anchor_store_new_rr(struct val_anchors* anchors, uint8_t* rr, size_t rl,
+ size_t dl)
{
struct trust_anchor* ta;
- ldns_rdf* owner = ldns_rr_owner(rr);
- ldns_status status;
- ldns_buffer_clear(buffer);
- ldns_buffer_skip(buffer, 2); /* skip rdatalen */
- status = ldns_rr_rdata2buffer_wire(buffer, rr);
- if(status != LDNS_STATUS_OK) {
- log_err("error converting trustanchor to wireformat: %s",
- ldns_get_errorstr_by_id(status));
- return NULL;
- }
- ldns_buffer_flip(buffer);
- ldns_buffer_write_u16_at(buffer, 0, ldns_buffer_limit(buffer) - 2);
-
- if(!(ta=anchor_store_new_key(anchors, ldns_rdf_data(owner),
- ldns_rr_get_type(rr), ldns_rr_get_class(rr),
- ldns_buffer_begin(buffer), ldns_buffer_limit(buffer)))) {
+ if(!(ta=anchor_store_new_key(anchors, rr,
+ sldns_wirerr_get_type(rr, rl, dl),
+ sldns_wirerr_get_class(rr, rl, dl),
+ sldns_wirerr_get_rdatawl(rr, rl, dl),
+ sldns_wirerr_get_rdatalen(rr, rl, dl)+2))) {
return NULL;
}
log_nametypeclass(VERB_QUERY, "adding trusted key",
- ldns_rdf_data(owner),
- ldns_rr_get_type(rr), ldns_rr_get_class(rr));
+ rr, sldns_wirerr_get_type(rr, rl, dl),
+ sldns_wirerr_get_class(rr, rl, dl));
return ta;
}
@@ -387,36 +380,37 @@ static struct trust_anchor*
anchor_insert_insecure(struct val_anchors* anchors, const char* str)
{
struct trust_anchor* ta;
- ldns_rdf* nm = ldns_dname_new_frm_str(str);
+ size_t dname_len = 0;
+ uint8_t* nm = sldns_str2wire_dname(str, &dname_len);
if(!nm) {
log_err("parse error in domain name '%s'", str);
return NULL;
}
- ta = anchor_store_new_key(anchors, ldns_rdf_data(nm), LDNS_RR_TYPE_DS,
+ ta = anchor_store_new_key(anchors, nm, LDNS_RR_TYPE_DS,
LDNS_RR_CLASS_IN, NULL, 0);
- ldns_rdf_deep_free(nm);
+ free(nm);
return ta;
}
struct trust_anchor*
-anchor_store_str(struct val_anchors* anchors, ldns_buffer* buffer,
+anchor_store_str(struct val_anchors* anchors, sldns_buffer* buffer,
const char* str)
{
struct trust_anchor* ta;
- ldns_rr* rr = NULL;
- ldns_status status = ldns_rr_new_frm_str(&rr, str, 0, NULL, NULL);
- if(status != LDNS_STATUS_OK) {
- log_err("error parsing trust anchor: %s",
- ldns_get_errorstr_by_id(status));
- ldns_rr_free(rr);
+ uint8_t* rr = sldns_buffer_begin(buffer);
+ size_t len = sldns_buffer_capacity(buffer), dname_len = 0;
+ int status = sldns_str2wire_rr_buf(str, rr, &len, &dname_len,
+ 0, NULL, 0, NULL, 0);
+ if(status != 0) {
+ log_err("error parsing trust anchor %s: at %d: %s",
+ str, LDNS_WIREPARSE_OFFSET(status),
+ sldns_get_errorstr_parse(status));
return NULL;
}
- if(!(ta=anchor_store_new_rr(anchors, buffer, rr))) {
+ if(!(ta=anchor_store_new_rr(anchors, rr, len, dname_len))) {
log_err("out of memory");
- ldns_rr_free(rr);
return NULL;
}
- ldns_rr_free(rr);
return ta;
}
@@ -429,44 +423,43 @@ anchor_store_str(struct val_anchors* anchors, ldns_buffer* buffer,
* @return NULL on error. Else last trust-anchor point.
*/
static struct trust_anchor*
-anchor_read_file(struct val_anchors* anchors, ldns_buffer* buffer,
+anchor_read_file(struct val_anchors* anchors, sldns_buffer* buffer,
const char* fname, int onlyone)
{
struct trust_anchor* ta = NULL, *tanew;
- uint32_t default_ttl = 3600;
- ldns_rdf* origin = NULL, *prev = NULL;
- int line_nr = 1;
- ldns_status status;
- ldns_rr* rr;
+ struct sldns_file_parse_state pst;
+ int status;
+ size_t len, dname_len;
+ uint8_t* rr = sldns_buffer_begin(buffer);
int ok = 1;
FILE* in = fopen(fname, "r");
if(!in) {
log_err("error opening file %s: %s", fname, strerror(errno));
return 0;
}
+ memset(&pst, 0, sizeof(pst));
+ pst.default_ttl = 3600;
+ pst.lineno = 1;
while(!feof(in)) {
- rr = NULL;
- status = ldns_rr_new_frm_fp_l(&rr, in, &default_ttl, &origin,
- &prev, &line_nr);
- if(status == LDNS_STATUS_SYNTAX_EMPTY /* empty line */
- || status == LDNS_STATUS_SYNTAX_TTL /* $TTL */
- || status == LDNS_STATUS_SYNTAX_ORIGIN /* $ORIGIN */)
+ len = sldns_buffer_capacity(buffer);
+ dname_len = 0;
+ status = sldns_fp2wire_rr_buf(in, rr, &len, &dname_len, &pst);
+ if(len == 0) /* empty, $TTL, $ORIGIN */
continue;
- if(status != LDNS_STATUS_OK) {
- log_err("parse error in %s:%d : %s", fname, line_nr,
- ldns_get_errorstr_by_id(status));
- ldns_rr_free(rr);
+ if(status != 0) {
+ log_err("parse error in %s:%d:%d : %s", fname,
+ pst.lineno, LDNS_WIREPARSE_OFFSET(status),
+ sldns_get_errorstr_parse(status));
ok = 0;
break;
}
- if(ldns_rr_get_type(rr) != LDNS_RR_TYPE_DS &&
- ldns_rr_get_type(rr) != LDNS_RR_TYPE_DNSKEY) {
- ldns_rr_free(rr);
+ if(sldns_wirerr_get_type(rr, len, dname_len) !=
+ LDNS_RR_TYPE_DS && sldns_wirerr_get_type(rr, len,
+ dname_len) != LDNS_RR_TYPE_DNSKEY) {
continue;
}
- if(!(tanew=anchor_store_new_rr(anchors, buffer, rr))) {
- log_err("error at %s line %d", fname, line_nr);
- ldns_rr_free(rr);
+ if(!(tanew=anchor_store_new_rr(anchors, rr, len, dname_len))) {
+ log_err("mem error at %s line %d", fname, pst.lineno);
ok = 0;
break;
}
@@ -474,16 +467,12 @@ anchor_read_file(struct val_anchors* anchors, ldns_buffer* buffer,
log_err("error at %s line %d: no multiple anchor "
"domains allowed (you can have multiple "
"keys, but they must have the same name).",
- fname, line_nr);
- ldns_rr_free(rr);
+ fname, pst.lineno);
ok = 0;
break;
}
ta = tanew;
- ldns_rr_free(rr);
}
- ldns_rdf_deep_free(origin);
- ldns_rdf_deep_free(prev);
fclose(in);
if(!ok) return NULL;
/* empty file is OK when multiple anchors are allowed */
@@ -538,7 +527,7 @@ is_bind_special(int c)
* 0 on end of file.
*/
static int
-readkeyword_bindfile(FILE* in, ldns_buffer* buf, int* line, int comments)
+readkeyword_bindfile(FILE* in, sldns_buffer* buf, int* line, int comments)
{
int c;
int numdone = 0;
@@ -548,17 +537,17 @@ readkeyword_bindfile(FILE* in, ldns_buffer* buf, int* line, int comments)
(*line)++;
continue;
} else if(comments && c=='/' && numdone>0 && /* /_/ bla*/
- ldns_buffer_read_u8_at(buf,
- ldns_buffer_position(buf)-1) == '/') {
- ldns_buffer_skip(buf, -1);
+ sldns_buffer_read_u8_at(buf,
+ sldns_buffer_position(buf)-1) == '/') {
+ sldns_buffer_skip(buf, -1);
numdone--;
skip_to_eol(in);
(*line)++;
continue;
} else if(comments && c=='*' && numdone>0 && /* /_* bla *_/ */
- ldns_buffer_read_u8_at(buf,
- ldns_buffer_position(buf)-1) == '/') {
- ldns_buffer_skip(buf, -1);
+ sldns_buffer_read_u8_at(buf,
+ sldns_buffer_position(buf)-1) == '/') {
+ sldns_buffer_skip(buf, -1);
numdone--;
/* skip to end of comment */
while(c != EOF && (c=getc(in)) != EOF ) {
@@ -588,10 +577,10 @@ readkeyword_bindfile(FILE* in, ldns_buffer* buf, int* line, int comments)
(*line)++;
}
/* space for 1 char + 0 string terminator */
- if(ldns_buffer_remaining(buf) < 2) {
+ if(sldns_buffer_remaining(buf) < 2) {
fatal_exit("trusted-keys, %d, string too long", *line);
}
- ldns_buffer_write_u8(buf, (uint8_t)c);
+ sldns_buffer_write_u8(buf, (uint8_t)c);
numdone++;
if(isspace(c)) {
/* collate whitespace into ' ' */
@@ -613,17 +602,17 @@ readkeyword_bindfile(FILE* in, ldns_buffer* buf, int* line, int comments)
/** skip through file to { or ; */
static int
-skip_to_special(FILE* in, ldns_buffer* buf, int* line, int spec)
+skip_to_special(FILE* in, sldns_buffer* buf, int* line, int spec)
{
int rdlen;
- ldns_buffer_clear(buf);
+ sldns_buffer_clear(buf);
while((rdlen=readkeyword_bindfile(in, buf, line, 1))) {
- if(rdlen == 1 && isspace((int)*ldns_buffer_begin(buf))) {
- ldns_buffer_clear(buf);
+ if(rdlen == 1 && isspace((int)*sldns_buffer_begin(buf))) {
+ sldns_buffer_clear(buf);
continue;
}
- if(rdlen != 1 || *ldns_buffer_begin(buf) != (uint8_t)spec) {
- ldns_buffer_write_u8(buf, 0);
+ if(rdlen != 1 || *sldns_buffer_begin(buf) != (uint8_t)spec) {
+ sldns_buffer_write_u8(buf, 0);
log_err("trusted-keys, line %d, expected %c",
*line, spec);
return 0;
@@ -643,7 +632,7 @@ skip_to_special(FILE* in, ldns_buffer* buf, int* line, int spec)
* @return 0 on error.
*/
static int
-process_bind_contents(struct val_anchors* anchors, ldns_buffer* buf,
+process_bind_contents(struct val_anchors* anchors, sldns_buffer* buf,
int* line, FILE* in)
{
/* loop over contents, collate strings before ; */
@@ -656,41 +645,41 @@ process_bind_contents(struct val_anchors* anchors, ldns_buffer* buf,
int comments = 1;
int rdlen;
char* str = 0;
- ldns_buffer_clear(buf);
+ sldns_buffer_clear(buf);
while((rdlen=readkeyword_bindfile(in, buf, line, comments))) {
- if(rdlen == 1 && ldns_buffer_position(buf) == 1
- && isspace((int)*ldns_buffer_begin(buf))) {
+ if(rdlen == 1 && sldns_buffer_position(buf) == 1
+ && isspace((int)*sldns_buffer_begin(buf))) {
/* starting whitespace is removed */
- ldns_buffer_clear(buf);
+ sldns_buffer_clear(buf);
continue;
- } else if(rdlen == 1 && ldns_buffer_current(buf)[-1] == '"') {
+ } else if(rdlen == 1 && sldns_buffer_current(buf)[-1] == '"') {
/* remove " from the string */
if(contnum == 0) {
quoted = 1;
comments = 0;
}
- ldns_buffer_skip(buf, -1);
+ sldns_buffer_skip(buf, -1);
if(contnum > 0 && quoted) {
- if(ldns_buffer_remaining(buf) < 8+1) {
+ if(sldns_buffer_remaining(buf) < 8+1) {
log_err("line %d, too long", *line);
return 0;
}
- ldns_buffer_write(buf, " DNSKEY ", 8);
+ sldns_buffer_write(buf, " DNSKEY ", 8);
quoted = 0;
comments = 1;
} else if(contnum > 0)
comments = !comments;
continue;
- } else if(rdlen == 1 && ldns_buffer_current(buf)[-1] == ';') {
+ } else if(rdlen == 1 && sldns_buffer_current(buf)[-1] == ';') {
if(contnum < 5) {
- ldns_buffer_write_u8(buf, 0);
+ sldns_buffer_write_u8(buf, 0);
log_err("line %d, bad key", *line);
return 0;
}
- ldns_buffer_skip(buf, -1);
- ldns_buffer_write_u8(buf, 0);
- str = strdup((char*)ldns_buffer_begin(buf));
+ sldns_buffer_skip(buf, -1);
+ sldns_buffer_write_u8(buf, 0);
+ str = strdup((char*)sldns_buffer_begin(buf));
if(!str) {
log_err("line %d, allocation failure", *line);
return 0;
@@ -701,30 +690,30 @@ process_bind_contents(struct val_anchors* anchors, ldns_buffer* buf,
return 0;
}
free(str);
- ldns_buffer_clear(buf);
+ sldns_buffer_clear(buf);
contnum = 0;
quoted = 0;
comments = 1;
continue;
- } else if(rdlen == 1 && ldns_buffer_current(buf)[-1] == '}') {
+ } else if(rdlen == 1 && sldns_buffer_current(buf)[-1] == '}') {
if(contnum > 0) {
- ldns_buffer_write_u8(buf, 0);
+ sldns_buffer_write_u8(buf, 0);
log_err("line %d, bad key before }", *line);
return 0;
}
return 1;
} else if(rdlen == 1 &&
- isspace((int)ldns_buffer_current(buf)[-1])) {
+ isspace((int)sldns_buffer_current(buf)[-1])) {
/* leave whitespace here */
} else {
/* not space or whatnot, so actual content */
contnum ++;
if(contnum == 1 && !quoted) {
- if(ldns_buffer_remaining(buf) < 8+1) {
+ if(sldns_buffer_remaining(buf) < 8+1) {
log_err("line %d, too long", *line);
return 0;
}
- ldns_buffer_write(buf, " DNSKEY ", 8);
+ sldns_buffer_write(buf, " DNSKEY ", 8);
}
}
}
@@ -741,7 +730,7 @@ process_bind_contents(struct val_anchors* anchors, ldns_buffer* buf,
* @return false on error.
*/
static int
-anchor_read_bind_file(struct val_anchors* anchors, ldns_buffer* buffer,
+anchor_read_bind_file(struct val_anchors* anchors, sldns_buffer* buffer,
const char* fname)
{
int line_nr = 1;
@@ -753,11 +742,11 @@ anchor_read_bind_file(struct val_anchors* anchors, ldns_buffer* buffer,
}
verbose(VERB_QUERY, "reading in bind-compat-mode: '%s'", fname);
/* scan for trusted-keys keyword, ignore everything else */
- ldns_buffer_clear(buffer);
+ sldns_buffer_clear(buffer);
while((rdlen=readkeyword_bindfile(in, buffer, &line_nr, 1)) != 0) {
- if(rdlen != 12 || strncmp((char*)ldns_buffer_begin(buffer),
+ if(rdlen != 12 || strncmp((char*)sldns_buffer_begin(buffer),
"trusted-keys", 12) != 0) {
- ldns_buffer_clear(buffer);
+ sldns_buffer_clear(buffer);
/* ignore everything but trusted-keys */
continue;
}
@@ -777,7 +766,7 @@ anchor_read_bind_file(struct val_anchors* anchors, ldns_buffer* buffer,
fclose(in);
return 0;
}
- ldns_buffer_clear(buffer);
+ sldns_buffer_clear(buffer);
}
fclose(in);
return 1;
@@ -792,7 +781,7 @@ anchor_read_bind_file(struct val_anchors* anchors, ldns_buffer* buffer,
* @return false on error.
*/
static int
-anchor_read_bind_file_wild(struct val_anchors* anchors, ldns_buffer* buffer,
+anchor_read_bind_file_wild(struct val_anchors* anchors, sldns_buffer* buffer,
const char* pat)
{
#ifdef HAVE_GLOB
@@ -900,7 +889,7 @@ assemble_it(struct trust_anchor* ta, size_t num, uint16_t type)
free(pkey);
return NULL;
}
- pd->rr_ttl = (uint32_t*)malloc(num*sizeof(uint32_t));
+ pd->rr_ttl = (time_t*)malloc(num*sizeof(time_t));
if(!pd->rr_ttl) {
free(pd->rr_len);
free(pd);
@@ -1050,13 +1039,13 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg)
{
struct config_strlist* f;
char* nm;
- ldns_buffer* parsebuf = ldns_buffer_new(65535);
+ sldns_buffer* parsebuf = sldns_buffer_new(65535);
for(f = cfg->domain_insecure; f; f = f->next) {
if(!f->str || f->str[0] == 0) /* empty "" */
continue;
if(!anchor_insert_insecure(anchors, f->str)) {
log_err("error in domain-insecure: %s", f->str);
- ldns_buffer_free(parsebuf);
+ sldns_buffer_free(parsebuf);
return 0;
}
}
@@ -1069,7 +1058,7 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg)
nm += strlen(cfg->chrootdir);
if(!anchor_read_file(anchors, parsebuf, nm, 0)) {
log_err("error reading trust-anchor-file: %s", f->str);
- ldns_buffer_free(parsebuf);
+ sldns_buffer_free(parsebuf);
return 0;
}
}
@@ -1082,7 +1071,7 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg)
nm += strlen(cfg->chrootdir);
if(!anchor_read_bind_file_wild(anchors, parsebuf, nm)) {
log_err("error reading trusted-keys-file: %s", f->str);
- ldns_buffer_free(parsebuf);
+ sldns_buffer_free(parsebuf);
return 0;
}
}
@@ -1091,7 +1080,7 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg)
continue;
if(!anchor_store_str(anchors, parsebuf, f->str)) {
log_err("error in trust-anchor: \"%s\"", f->str);
- ldns_buffer_free(parsebuf);
+ sldns_buffer_free(parsebuf);
return 0;
}
}
@@ -1105,7 +1094,7 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg)
nm, 1))) {
log_err("error reading dlv-anchor-file: %s",
cfg->dlv_anchor_file);
- ldns_buffer_free(parsebuf);
+ sldns_buffer_free(parsebuf);
return 0;
}
lock_basic_lock(&anchors->lock);
@@ -1119,7 +1108,7 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg)
if(!(dlva = anchor_store_str(
anchors, parsebuf, f->str))) {
log_err("error in dlv-anchor: \"%s\"", f->str);
- ldns_buffer_free(parsebuf);
+ sldns_buffer_free(parsebuf);
return 0;
}
lock_basic_lock(&anchors->lock);
@@ -1138,14 +1127,14 @@ anchors_apply_cfg(struct val_anchors* anchors, struct config_file* cfg)
if(!autr_read_file(anchors, nm)) {
log_err("error reading auto-trust-anchor-file: %s",
f->str);
- ldns_buffer_free(parsebuf);
+ sldns_buffer_free(parsebuf);
return 0;
}
}
/* first assemble, since it may delete useless anchors */
anchors_assemble_rrsets(anchors);
init_parents(anchors);
- ldns_buffer_free(parsebuf);
+ sldns_buffer_free(parsebuf);
if(verbosity >= VERB_ALGO) autr_debug_print(anchors);
return 1;
}
@@ -1195,6 +1184,8 @@ anchors_get_mem(struct val_anchors* anchors)
{
struct trust_anchor *ta;
size_t s = sizeof(*anchors);
+ if(!anchors)
+ return 0;
RBTREE_FOR(ta, struct trust_anchor*, anchors->tree) {
s += sizeof(*ta) + ta->namelen;
/* keys and so on */
diff --git a/contrib/unbound/validator/val_anchor.h b/contrib/unbound/validator/val_anchor.h
index 5a3ad40..4951b99 100644
--- a/contrib/unbound/validator/val_anchor.h
+++ b/contrib/unbound/validator/val_anchor.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -48,6 +48,7 @@ struct config_file;
struct ub_packed_rrset_key;
struct autr_point_data;
struct autr_global_data;
+struct sldns_buffer;
/**
* Trust anchor store.
@@ -184,7 +185,7 @@ struct trust_anchor* anchor_find(struct val_anchors* anchors,
* @return NULL on error.
*/
struct trust_anchor* anchor_store_str(struct val_anchors* anchors,
- ldns_buffer* buffer, const char* str);
+ struct sldns_buffer* buffer, const char* str);
/**
* Get memory in use by the trust anchor storage
diff --git a/contrib/unbound/validator/val_kcache.c b/contrib/unbound/validator/val_kcache.c
index 68e8c3f..22070cc 100644
--- a/contrib/unbound/validator/val_kcache.c
+++ b/contrib/unbound/validator/val_kcache.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -126,7 +126,7 @@ key_cache_search(struct key_cache* kcache, uint8_t* name, size_t namelen,
struct key_entry_key*
key_cache_obtain(struct key_cache* kcache, uint8_t* name, size_t namelen,
- uint16_t key_class, struct regional* region, uint32_t now)
+ uint16_t key_class, struct regional* region, time_t now)
{
/* keep looking until we find a nonexpired entry */
while(1) {
diff --git a/contrib/unbound/validator/val_kcache.h b/contrib/unbound/validator/val_kcache.h
index c37cf1e..76c9dd0 100644
--- a/contrib/unbound/validator/val_kcache.h
+++ b/contrib/unbound/validator/val_kcache.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -106,7 +106,7 @@ void key_cache_remove(struct key_cache* kcache,
*/
struct key_entry_key* key_cache_obtain(struct key_cache* kcache,
uint8_t* name, size_t namelen, uint16_t key_class,
- struct regional* region, uint32_t now);
+ struct regional* region, time_t now);
/**
* Get memory in use by the key cache.
diff --git a/contrib/unbound/validator/val_kentry.c b/contrib/unbound/validator/val_kentry.c
index ddac140..f99f18e 100644
--- a/contrib/unbound/validator/val_kentry.c
+++ b/contrib/unbound/validator/val_kentry.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -39,13 +39,14 @@
* This file contains functions for dealing with validator key entries.
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "validator/val_kentry.h"
#include "util/data/packed_rrset.h"
#include "util/data/dname.h"
#include "util/storage/lookup3.h"
#include "util/regional.h"
#include "util/net_help.h"
+#include "ldns/rrdef.h"
+#include "ldns/keyraw.h"
size_t
key_entry_sizefunc(void* key, void* data)
@@ -275,8 +276,8 @@ key_entry_setup(struct regional* region,
struct key_entry_key*
key_entry_create_null(struct regional* region,
- uint8_t* name, size_t namelen, uint16_t dclass, uint32_t ttl,
- uint32_t now)
+ uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl,
+ time_t now)
{
struct key_entry_key* k;
struct key_entry_data* d;
@@ -294,7 +295,7 @@ key_entry_create_null(struct regional* region,
struct key_entry_key*
key_entry_create_rrset(struct regional* region,
uint8_t* name, size_t namelen, uint16_t dclass,
- struct ub_packed_rrset_key* rrset, uint8_t* sigalg, uint32_t now)
+ struct ub_packed_rrset_key* rrset, uint8_t* sigalg, time_t now)
{
struct key_entry_key* k;
struct key_entry_data* d;
@@ -321,8 +322,8 @@ key_entry_create_rrset(struct regional* region,
struct key_entry_key*
key_entry_create_bad(struct regional* region,
- uint8_t* name, size_t namelen, uint16_t dclass, uint32_t ttl,
- uint32_t now)
+ uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl,
+ time_t now)
{
struct key_entry_key* k;
struct key_entry_data* d;
@@ -377,7 +378,7 @@ dnskey_get_keysize(struct packed_rrset_data* data, size_t idx)
algo = (int)data->rr_data[idx][2+3];
pk = (unsigned char*)data->rr_data[idx]+2+4;
pklen = (unsigned)data->rr_len[idx]-2-4;
- return ldns_rr_dnskey_key_size_raw(pk, pklen, algo);
+ return sldns_rr_dnskey_key_size_raw(pk, pklen, algo);
}
/** get dnskey flags from data */
diff --git a/contrib/unbound/validator/val_kentry.h b/contrib/unbound/validator/val_kentry.h
index d14ffe5..ade6557 100644
--- a/contrib/unbound/validator/val_kentry.h
+++ b/contrib/unbound/validator/val_kentry.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -75,7 +75,7 @@ struct key_entry_key {
*/
struct key_entry_data {
/** the TTL of this entry (absolute time) */
- uint32_t ttl;
+ time_t ttl;
/** the key rrdata. can be NULL to signal keyless name. */
struct packed_rrset_data* rrset_data;
/** not NULL sometimes to give reason why bogus */
@@ -169,8 +169,8 @@ char* key_entry_get_reason(struct key_entry_key* kkey);
* @return new key entry or NULL on alloc failure
*/
struct key_entry_key* key_entry_create_null(struct regional* region,
- uint8_t* name, size_t namelen, uint16_t dclass, uint32_t ttl,
- uint32_t now);
+ uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl,
+ time_t now);
/**
* Create a key entry from an rrset, in the given region.
@@ -185,7 +185,7 @@ struct key_entry_key* key_entry_create_null(struct regional* region,
*/
struct key_entry_key* key_entry_create_rrset(struct regional* region,
uint8_t* name, size_t namelen, uint16_t dclass,
- struct ub_packed_rrset_key* rrset, uint8_t* sigalg, uint32_t now);
+ struct ub_packed_rrset_key* rrset, uint8_t* sigalg, time_t now);
/**
* Create a bad entry, in the given region.
@@ -198,8 +198,8 @@ struct key_entry_key* key_entry_create_rrset(struct regional* region,
* @return new key entry or NULL on alloc failure
*/
struct key_entry_key* key_entry_create_bad(struct regional* region,
- uint8_t* name, size_t namelen, uint16_t dclass, uint32_t ttl,
- uint32_t now);
+ uint8_t* name, size_t namelen, uint16_t dclass, time_t ttl,
+ time_t now);
/**
* Obtain rrset from a key entry, allocated in region.
diff --git a/contrib/unbound/validator/val_neg.c b/contrib/unbound/validator/val_neg.c
index eec2eb1..1d7a5c5 100644
--- a/contrib/unbound/validator/val_neg.c
+++ b/contrib/unbound/validator/val_neg.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -59,6 +59,8 @@
#include "util/config_file.h"
#include "services/cache/rrset.h"
#include "services/cache/dns.h"
+#include "ldns/rrdef.h"
+#include "ldns/sbuffer.h"
int val_neg_data_compare(const void* a, const void* b)
{
@@ -494,8 +496,8 @@ static struct val_neg_zone* neg_zone_chain(
struct val_neg_zone* p=first, *np;
while(p) {
np = p->parent;
- free(p);
free(p->name);
+ free(p);
p = np;
}
return NULL;
@@ -640,8 +642,8 @@ static struct val_neg_data* neg_data_chain(
struct val_neg_data* p = first, *np;
while(p) {
np = p->parent;
- free(p);
free(p->name);
+ free(p);
p = np;
}
return NULL;
@@ -917,7 +919,7 @@ static int neg_closest_data(struct val_neg_zone* zone,
}
int val_neg_dlvlookup(struct val_neg_cache* neg, uint8_t* qname, size_t len,
- uint16_t qclass, struct rrset_cache* rrset_cache, uint32_t now)
+ uint16_t qclass, struct rrset_cache* rrset_cache, time_t now)
{
/* lookup closest zone */
struct val_neg_zone* zone;
@@ -1138,7 +1140,7 @@ static struct ub_packed_rrset_key*
grab_nsec(struct rrset_cache* rrset_cache, uint8_t* qname, size_t qname_len,
uint16_t qtype, uint16_t qclass, uint32_t flags,
struct regional* region, int checkbit, uint16_t checktype,
- uint32_t now)
+ time_t now)
{
struct ub_packed_rrset_key* r, *k = rrset_cache_lookup(rrset_cache,
qname, qname_len, qtype, qclass, flags, now, 0);
@@ -1174,7 +1176,7 @@ grab_nsec(struct rrset_cache* rrset_cache, uint8_t* qname, size_t qname_len,
/** find nsec3 closest encloser in neg cache */
static struct val_neg_data*
neg_find_nsec3_ce(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len,
- int qlabs, ldns_buffer* buf, uint8_t* hashnc, size_t* nclen)
+ int qlabs, sldns_buffer* buf, uint8_t* hashnc, size_t* nclen)
{
struct val_neg_data* data;
uint8_t hashce[NSEC3_SHA_LEN];
@@ -1225,7 +1227,7 @@ neg_params_ok(struct val_neg_zone* zone, struct ub_packed_rrset_key* rrset)
static struct ub_packed_rrset_key*
neg_nsec3_getnc(struct val_neg_zone* zone, uint8_t* hashnc, size_t nclen,
struct rrset_cache* rrset_cache, struct regional* region,
- uint32_t now, uint8_t* b32, size_t maxb32)
+ time_t now, uint8_t* b32, size_t maxb32)
{
struct ub_packed_rrset_key* nc_rrset;
struct val_neg_data* data;
@@ -1257,8 +1259,8 @@ neg_nsec3_getnc(struct val_neg_zone* zone, uint8_t* hashnc, size_t nclen,
/** neg cache nsec3 proof procedure*/
static struct dns_msg*
neg_nsec3_proof_ds(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len,
- int qlabs, ldns_buffer* buf, struct rrset_cache* rrset_cache,
- struct regional* region, uint32_t now, uint8_t* topname)
+ int qlabs, sldns_buffer* buf, struct rrset_cache* rrset_cache,
+ struct regional* region, time_t now, uint8_t* topname)
{
struct dns_msg* msg;
struct val_neg_data* data;
@@ -1356,7 +1358,7 @@ neg_nsec3_proof_ds(struct val_neg_zone* zone, uint8_t* qname, size_t qname_len,
* @param zone: val_neg_zone if we have one.
* @return false on lookup or alloc failure.
*/
-static int add_soa(struct rrset_cache* rrset_cache, uint32_t now,
+static int add_soa(struct rrset_cache* rrset_cache, time_t now,
struct regional* region, struct dns_msg* msg, struct val_neg_zone* zone)
{
struct ub_packed_rrset_key* soa;
@@ -1388,7 +1390,7 @@ static int add_soa(struct rrset_cache* rrset_cache, uint32_t now,
struct dns_msg*
val_neg_getmsg(struct val_neg_cache* neg, struct query_info* qinfo,
struct regional* region, struct rrset_cache* rrset_cache,
- ldns_buffer* buf, uint32_t now, int addsoa, uint8_t* topname)
+ sldns_buffer* buf, time_t now, int addsoa, uint8_t* topname)
{
struct dns_msg* msg;
struct ub_packed_rrset_key* rrset;
diff --git a/contrib/unbound/validator/val_neg.h b/contrib/unbound/validator/val_neg.h
index 01b423e..967d1a7 100644
--- a/contrib/unbound/validator/val_neg.h
+++ b/contrib/unbound/validator/val_neg.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -46,6 +46,7 @@
#define VALIDATOR_VAL_NEG_H
#include "util/locks.h"
#include "util/rbtree.h"
+struct sldns_buffer;
struct val_neg_data;
struct config_file;
struct reply_info;
@@ -229,7 +230,7 @@ void val_neg_addreferral(struct val_neg_cache* neg, struct reply_info* rep,
* thus, qname DLV qclass does not exist.
*/
int val_neg_dlvlookup(struct val_neg_cache* neg, uint8_t* qname, size_t len,
- uint16_t qclass, struct rrset_cache* rrset_cache, uint32_t now);
+ uint16_t qclass, struct rrset_cache* rrset_cache, time_t now);
/**
* For the given query, try to get a reply out of the negative cache.
@@ -255,7 +256,7 @@ int val_neg_dlvlookup(struct val_neg_cache* neg, uint8_t* qname, size_t len,
*/
struct dns_msg* val_neg_getmsg(struct val_neg_cache* neg,
struct query_info* qinfo, struct regional* region,
- struct rrset_cache* rrset_cache, ldns_buffer* buf, uint32_t now,
+ struct rrset_cache* rrset_cache, struct sldns_buffer* buf, time_t now,
int addsoa, uint8_t* topname);
diff --git a/contrib/unbound/validator/val_nsec.c b/contrib/unbound/validator/val_nsec.c
index 8bda8da..bdfe3c8 100644
--- a/contrib/unbound/validator/val_nsec.c
+++ b/contrib/unbound/validator/val_nsec.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -41,7 +41,6 @@
* for denial of existance, and proofs for presence of types.
*/
#include "config.h"
-#include <ldns/packet.h>
#include "validator/val_nsec.h"
#include "validator/val_utils.h"
#include "util/data/msgreply.h"
@@ -197,7 +196,7 @@ nsec_verify_rrset(struct module_env* env, struct val_env* ve,
enum sec_status
val_nsec_prove_nodata_dsreply(struct module_env* env, struct val_env* ve,
struct query_info* qinfo, struct reply_info* rep,
- struct key_entry_key* kkey, uint32_t* proof_ttl, char** reason)
+ struct key_entry_key* kkey, time_t* proof_ttl, char** reason)
{
struct ub_packed_rrset_key* nsec = reply_find_rrset_section_ns(
rep, qinfo->qname, qinfo->qname_len, LDNS_RR_TYPE_NSEC,
diff --git a/contrib/unbound/validator/val_nsec.h b/contrib/unbound/validator/val_nsec.h
index 34f7f63..f680d08 100644
--- a/contrib/unbound/validator/val_nsec.h
+++ b/contrib/unbound/validator/val_nsec.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -73,7 +73,7 @@ struct key_entry_key;
enum sec_status val_nsec_prove_nodata_dsreply(struct module_env* env,
struct val_env* ve, struct query_info* qinfo,
struct reply_info* rep, struct key_entry_key* kkey,
- uint32_t* proof_ttl, char** reason);
+ time_t* proof_ttl, char** reason);
/**
* nsec typemap check, takes an NSEC-type bitmap as argument, checks for type.
diff --git a/contrib/unbound/validator/val_nsec3.c b/contrib/unbound/validator/val_nsec3.c
index 4b48e7b..fe5091c 100644
--- a/contrib/unbound/validator/val_nsec3.c
+++ b/contrib/unbound/validator/val_nsec3.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -62,18 +62,19 @@
#include "util/data/msgreply.h"
/* we include nsec.h for the bitmap_has_type function */
#include "validator/val_nsec.h"
+#include "ldns/sbuffer.h"
/**
* This function we get from ldns-compat or from base system
* it returns the number of data bytes stored at the target, or <0 on error.
*/
-int ldns_b32_ntop_extended_hex(uint8_t const *src, size_t srclength,
+int sldns_b32_ntop_extended_hex(uint8_t const *src, size_t srclength,
char *target, size_t targsize);
/**
* This function we get from ldns-compat or from base system
* it returns the number of data bytes stored at the target, or <0 on error.
*/
-int ldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len,
+int sldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len,
uint8_t *target, size_t targsize);
/**
@@ -259,7 +260,7 @@ size_t nsec3_hash_to_b32(uint8_t* hash, size_t hashlen, uint8_t* zone,
int ret;
if(max < hashlen*2+1) /* quick approx of b32, as if hexb16 */
return 0;
- ret = ldns_b32_ntop_extended_hex(hash, hashlen, (char*)buf+1, max-1);
+ ret = sldns_b32_ntop_extended_hex(hash, hashlen, (char*)buf+1, max-1);
if(ret < 1)
return 0;
buf[0] = (uint8_t)ret; /* length of b32 label */
@@ -534,16 +535,16 @@ nsec3_hash_cmp(const void* c1, const void* c2)
}
size_t
-nsec3_get_hashed(ldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo,
+nsec3_get_hashed(sldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo,
size_t iter, uint8_t* salt, size_t saltlen, uint8_t* res, size_t max)
{
size_t i, hash_len;
/* prepare buffer for first iteration */
- ldns_buffer_clear(buf);
- ldns_buffer_write(buf, nm, nmlen);
- query_dname_tolower(ldns_buffer_begin(buf));
- ldns_buffer_write(buf, salt, saltlen);
- ldns_buffer_flip(buf);
+ sldns_buffer_clear(buf);
+ sldns_buffer_write(buf, nm, nmlen);
+ query_dname_tolower(sldns_buffer_begin(buf));
+ sldns_buffer_write(buf, salt, saltlen);
+ sldns_buffer_flip(buf);
switch(algo) {
#if defined(HAVE_EVP_SHA1) || defined(HAVE_NSS)
case NSEC3_HASH_SHA1:
@@ -555,29 +556,29 @@ nsec3_get_hashed(ldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo,
if(hash_len > max)
return 0;
# ifdef HAVE_SSL
- (void)SHA1((unsigned char*)ldns_buffer_begin(buf),
- (unsigned long)ldns_buffer_limit(buf),
+ (void)SHA1((unsigned char*)sldns_buffer_begin(buf),
+ (unsigned long)sldns_buffer_limit(buf),
(unsigned char*)res);
# else
(void)HASH_HashBuf(HASH_AlgSHA1, (unsigned char*)res,
- (unsigned char*)ldns_buffer_begin(buf),
- (unsigned long)ldns_buffer_limit(buf));
+ (unsigned char*)sldns_buffer_begin(buf),
+ (unsigned long)sldns_buffer_limit(buf));
# endif
for(i=0; i<iter; i++) {
- ldns_buffer_clear(buf);
- ldns_buffer_write(buf, res, hash_len);
- ldns_buffer_write(buf, salt, saltlen);
- ldns_buffer_flip(buf);
+ sldns_buffer_clear(buf);
+ sldns_buffer_write(buf, res, hash_len);
+ sldns_buffer_write(buf, salt, saltlen);
+ sldns_buffer_flip(buf);
# ifdef HAVE_SSL
(void)SHA1(
- (unsigned char*)ldns_buffer_begin(buf),
- (unsigned long)ldns_buffer_limit(buf),
+ (unsigned char*)sldns_buffer_begin(buf),
+ (unsigned long)sldns_buffer_limit(buf),
(unsigned char*)res);
# else
(void)HASH_HashBuf(HASH_AlgSHA1,
(unsigned char*)res,
- (unsigned char*)ldns_buffer_begin(buf),
- (unsigned long)ldns_buffer_limit(buf));
+ (unsigned char*)sldns_buffer_begin(buf),
+ (unsigned long)sldns_buffer_limit(buf));
# endif
}
break;
@@ -591,7 +592,7 @@ nsec3_get_hashed(ldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo,
/** perform hash of name */
static int
-nsec3_calc_hash(struct regional* region, ldns_buffer* buf,
+nsec3_calc_hash(struct regional* region, sldns_buffer* buf,
struct nsec3_cached_hash* c)
{
int algo = nsec3_get_algo(c->nsec3, c->rr);
@@ -601,11 +602,11 @@ nsec3_calc_hash(struct regional* region, ldns_buffer* buf,
if(!nsec3_get_salt(c->nsec3, c->rr, &salt, &saltlen))
return -1;
/* prepare buffer for first iteration */
- ldns_buffer_clear(buf);
- ldns_buffer_write(buf, c->dname, c->dname_len);
- query_dname_tolower(ldns_buffer_begin(buf));
- ldns_buffer_write(buf, salt, saltlen);
- ldns_buffer_flip(buf);
+ sldns_buffer_clear(buf);
+ sldns_buffer_write(buf, c->dname, c->dname_len);
+ query_dname_tolower(sldns_buffer_begin(buf));
+ sldns_buffer_write(buf, salt, saltlen);
+ sldns_buffer_flip(buf);
switch(algo) {
#if defined(HAVE_EVP_SHA1) || defined(HAVE_NSS)
case NSEC3_HASH_SHA1:
@@ -619,30 +620,30 @@ nsec3_calc_hash(struct regional* region, ldns_buffer* buf,
if(!c->hash)
return 0;
# ifdef HAVE_SSL
- (void)SHA1((unsigned char*)ldns_buffer_begin(buf),
- (unsigned long)ldns_buffer_limit(buf),
+ (void)SHA1((unsigned char*)sldns_buffer_begin(buf),
+ (unsigned long)sldns_buffer_limit(buf),
(unsigned char*)c->hash);
# else
(void)HASH_HashBuf(HASH_AlgSHA1,
(unsigned char*)c->hash,
- (unsigned char*)ldns_buffer_begin(buf),
- (unsigned long)ldns_buffer_limit(buf));
+ (unsigned char*)sldns_buffer_begin(buf),
+ (unsigned long)sldns_buffer_limit(buf));
# endif
for(i=0; i<iter; i++) {
- ldns_buffer_clear(buf);
- ldns_buffer_write(buf, c->hash, c->hash_len);
- ldns_buffer_write(buf, salt, saltlen);
- ldns_buffer_flip(buf);
+ sldns_buffer_clear(buf);
+ sldns_buffer_write(buf, c->hash, c->hash_len);
+ sldns_buffer_write(buf, salt, saltlen);
+ sldns_buffer_flip(buf);
# ifdef HAVE_SSL
(void)SHA1(
- (unsigned char*)ldns_buffer_begin(buf),
- (unsigned long)ldns_buffer_limit(buf),
+ (unsigned char*)sldns_buffer_begin(buf),
+ (unsigned long)sldns_buffer_limit(buf),
(unsigned char*)c->hash);
# else
(void)HASH_HashBuf(HASH_AlgSHA1,
(unsigned char*)c->hash,
- (unsigned char*)ldns_buffer_begin(buf),
- (unsigned long)ldns_buffer_limit(buf));
+ (unsigned char*)sldns_buffer_begin(buf),
+ (unsigned long)sldns_buffer_limit(buf));
# endif
}
break;
@@ -656,19 +657,19 @@ nsec3_calc_hash(struct regional* region, ldns_buffer* buf,
/** perform b32 encoding of hash */
static int
-nsec3_calc_b32(struct regional* region, ldns_buffer* buf,
+nsec3_calc_b32(struct regional* region, sldns_buffer* buf,
struct nsec3_cached_hash* c)
{
int r;
- ldns_buffer_clear(buf);
- r = ldns_b32_ntop_extended_hex(c->hash, c->hash_len,
- (char*)ldns_buffer_begin(buf), ldns_buffer_limit(buf));
+ sldns_buffer_clear(buf);
+ r = sldns_b32_ntop_extended_hex(c->hash, c->hash_len,
+ (char*)sldns_buffer_begin(buf), sldns_buffer_limit(buf));
if(r < 1) {
log_err("b32_ntop_extended_hex: error in encoding: %d", r);
return 0;
}
c->b32_len = (size_t)r;
- c->b32 = regional_alloc_init(region, ldns_buffer_begin(buf),
+ c->b32 = regional_alloc_init(region, sldns_buffer_begin(buf),
c->b32_len);
if(!c->b32)
return 0;
@@ -676,7 +677,7 @@ nsec3_calc_b32(struct regional* region, ldns_buffer* buf,
}
int
-nsec3_hash_name(rbtree_t* table, struct regional* region, ldns_buffer* buf,
+nsec3_hash_name(rbtree_t* table, struct regional* region, sldns_buffer* buf,
struct ub_packed_rrset_key* nsec3, int rr, uint8_t* dname,
size_t dname_len, struct nsec3_cached_hash** hash)
{
@@ -713,6 +714,8 @@ nsec3_hash_name(rbtree_t* table, struct regional* region, ldns_buffer* buf,
return r;
#ifdef UNBOUND_DEBUG
n =
+#else
+ (void)
#endif
rbtree_insert(table, &c->node);
log_assert(n); /* cannot be duplicate, just did lookup */
@@ -814,7 +817,7 @@ find_matching_nsec3(struct module_env* env, struct nsec3_filter* flt,
int
nsec3_covers(uint8_t* zone, struct nsec3_cached_hash* hash,
- struct ub_packed_rrset_key* rrset, int rr, ldns_buffer* buf)
+ struct ub_packed_rrset_key* rrset, int rr, sldns_buffer* buf)
{
uint8_t* next, *owner;
size_t nextlen;
@@ -838,10 +841,10 @@ nsec3_covers(uint8_t* zone, struct nsec3_cached_hash* hash,
return 1;
/* convert owner name from text to binary */
- ldns_buffer_clear(buf);
- owner = ldns_buffer_begin(buf);
- len = ldns_b32_pton_extended_hex((char*)rrset->rk.dname+1,
- hash->b32_len, owner, ldns_buffer_limit(buf));
+ sldns_buffer_clear(buf);
+ owner = sldns_buffer_begin(buf);
+ len = sldns_b32_pton_extended_hex((char*)rrset->rk.dname+1,
+ hash->b32_len, owner, sldns_buffer_limit(buf));
if(len<1)
return 0; /* bad owner name in some way */
if((size_t)len != hash->hash_len || (size_t)len != nextlen)
diff --git a/contrib/unbound/validator/val_nsec3.h b/contrib/unbound/validator/val_nsec3.h
index ae4326d..d619d67 100644
--- a/contrib/unbound/validator/val_nsec3.h
+++ b/contrib/unbound/validator/val_nsec3.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -75,6 +75,7 @@ struct ub_packed_rrset_key;
struct reply_info;
struct query_info;
struct key_entry_key;
+struct sldns_buffer;
/**
* 0 1 2 3 4 5 6 7
@@ -270,9 +271,9 @@ int nsec3_hash_cmp(const void* c1, const void* c2);
* 0 on a malloc failure.
* -1 if the NSEC3 rr was badly formatted (i.e. formerr).
*/
-int nsec3_hash_name(rbtree_t* table, struct regional* region, ldns_buffer* buf,
- struct ub_packed_rrset_key* nsec3, int rr, uint8_t* dname,
- size_t dname_len, struct nsec3_cached_hash** hash);
+int nsec3_hash_name(rbtree_t* table, struct regional* region,
+ struct sldns_buffer* buf, struct ub_packed_rrset_key* nsec3, int rr,
+ uint8_t* dname, size_t dname_len, struct nsec3_cached_hash** hash);
/**
* Get next owner name, converted to base32 encoding and with the
@@ -328,8 +329,9 @@ int nsec3_get_params(struct ub_packed_rrset_key* rrset, int r,
* @param max: maximum space for result.
* @return 0 on failure, otherwise bytelength stored.
*/
-size_t nsec3_get_hashed(ldns_buffer* buf, uint8_t* nm, size_t nmlen, int algo,
- size_t iter, uint8_t* salt, size_t saltlen, uint8_t* res, size_t max);
+size_t nsec3_get_hashed(struct sldns_buffer* buf, uint8_t* nm, size_t nmlen,
+ int algo, size_t iter, uint8_t* salt, size_t saltlen, uint8_t* res,
+ size_t max);
/**
* see if NSEC3 RR contains given type
@@ -373,6 +375,6 @@ int nsec3_get_nextowner(struct ub_packed_rrset_key* rrset, int r,
* @return true if covers, false if not.
*/
int nsec3_covers(uint8_t* zone, struct nsec3_cached_hash* hash,
- struct ub_packed_rrset_key* rrset, int rr, ldns_buffer* buf);
+ struct ub_packed_rrset_key* rrset, int rr, struct sldns_buffer* buf);
#endif /* VALIDATOR_VAL_NSEC3_H */
diff --git a/contrib/unbound/validator/val_secalgo.c b/contrib/unbound/validator/val_secalgo.c
index 5cca578..d89675f 100644
--- a/contrib/unbound/validator/val_secalgo.c
+++ b/contrib/unbound/validator/val_secalgo.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -41,10 +41,12 @@
* and do the library calls (for the crypto library in use).
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "validator/val_secalgo.h"
#include "util/data/packed_rrset.h"
#include "util/log.h"
+#include "ldns/rrdef.h"
+#include "ldns/keyraw.h"
+#include "ldns/sbuffer.h"
#if !defined(HAVE_SSL) && !defined(HAVE_NSS)
#error "Need crypto library to do digital signature cryptography"
@@ -108,7 +110,7 @@ do_gost94(unsigned char* data, size_t len, unsigned char* dest)
const EVP_MD* md = EVP_get_digestbyname("md_gost94");
if(!md)
return 0;
- return ldns_digest_evp(data, (unsigned int)len, dest, md);
+ return sldns_digest_evp(data, (unsigned int)len, dest, md);
}
#endif
@@ -172,7 +174,7 @@ dnskey_algo_id_is_supported(int id)
#ifdef USE_GOST
case LDNS_ECC_GOST:
/* we support GOST if it can be loaded */
- return ldns_key_EVP_load_gost_id();
+ return sldns_key_EVP_load_gost_id();
#endif
default:
return 0;
@@ -304,10 +306,10 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type,
log_err("verify: malloc failure in crypto");
return 0;
}
- dsa = ldns_key_buf2dsa_raw(key, keylen);
+ dsa = sldns_key_buf2dsa_raw(key, keylen);
if(!dsa) {
verbose(VERB_QUERY, "verify: "
- "ldns_key_buf2dsa_raw failed");
+ "sldns_key_buf2dsa_raw failed");
return 0;
}
if(EVP_PKEY_assign_DSA(*evp_key, dsa) == 0) {
@@ -331,10 +333,10 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type,
log_err("verify: malloc failure in crypto");
return 0;
}
- rsa = ldns_key_buf2rsa_raw(key, keylen);
+ rsa = sldns_key_buf2rsa_raw(key, keylen);
if(!rsa) {
verbose(VERB_QUERY, "verify: "
- "ldns_key_buf2rsa_raw SHA failed");
+ "sldns_key_buf2rsa_raw SHA failed");
return 0;
}
if(EVP_PKEY_assign_RSA(*evp_key, rsa) == 0) {
@@ -363,10 +365,10 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type,
log_err("verify: malloc failure in crypto");
return 0;
}
- rsa = ldns_key_buf2rsa_raw(key, keylen);
+ rsa = sldns_key_buf2rsa_raw(key, keylen);
if(!rsa) {
verbose(VERB_QUERY, "verify: "
- "ldns_key_buf2rsa_raw MD5 failed");
+ "sldns_key_buf2rsa_raw MD5 failed");
return 0;
}
if(EVP_PKEY_assign_RSA(*evp_key, rsa) == 0) {
@@ -379,10 +381,10 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type,
break;
#ifdef USE_GOST
case LDNS_ECC_GOST:
- *evp_key = ldns_gost2pkey_raw(key, keylen);
+ *evp_key = sldns_gost2pkey_raw(key, keylen);
if(!*evp_key) {
verbose(VERB_QUERY, "verify: "
- "ldns_gost2pkey_raw failed");
+ "sldns_gost2pkey_raw failed");
return 0;
}
*digest_type = EVP_get_digestbyname("md_gost94");
@@ -395,11 +397,11 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type,
#endif
#ifdef USE_ECDSA
case LDNS_ECDSAP256SHA256:
- *evp_key = ldns_ecdsa2pkey_raw(key, keylen,
+ *evp_key = sldns_ecdsa2pkey_raw(key, keylen,
LDNS_ECDSAP256SHA256);
if(!*evp_key) {
verbose(VERB_QUERY, "verify: "
- "ldns_ecdsa2pkey_raw failed");
+ "sldns_ecdsa2pkey_raw failed");
return 0;
}
#ifdef USE_ECDSA_EVP_WORKAROUND
@@ -422,11 +424,11 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type,
#endif
break;
case LDNS_ECDSAP384SHA384:
- *evp_key = ldns_ecdsa2pkey_raw(key, keylen,
+ *evp_key = sldns_ecdsa2pkey_raw(key, keylen,
LDNS_ECDSAP384SHA384);
if(!*evp_key) {
verbose(VERB_QUERY, "verify: "
- "ldns_ecdsa2pkey_raw failed");
+ "sldns_ecdsa2pkey_raw failed");
return 0;
}
#ifdef USE_ECDSA_EVP_WORKAROUND
@@ -471,7 +473,7 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type,
* unchecked on format errors and alloc failures.
*/
enum sec_status
-verify_canonrrset(ldns_buffer* buf, int algo, unsigned char* sigblock,
+verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock,
unsigned int sigblock_len, unsigned char* key, unsigned int keylen,
char** reason)
{
@@ -518,8 +520,8 @@ verify_canonrrset(ldns_buffer* buf, int algo, unsigned char* sigblock,
if(dofree) free(sigblock);
return sec_status_unchecked;
}
- if(EVP_VerifyUpdate(&ctx, (unsigned char*)ldns_buffer_begin(buf),
- (unsigned int)ldns_buffer_limit(buf)) == 0) {
+ if(EVP_VerifyUpdate(&ctx, (unsigned char*)sldns_buffer_begin(buf),
+ (unsigned int)sldns_buffer_limit(buf)) == 0) {
verbose(VERB_QUERY, "verify: EVP_VerifyUpdate failed");
EVP_PKEY_free(evp_key);
if(dofree) free(sigblock);
@@ -669,12 +671,12 @@ static SECKEYPublicKey* nss_buf2ecdsa(unsigned char* key, size_t len, int algo)
SECKEYPublicKey* pk;
SECItem pub = {siBuffer, NULL, 0};
SECItem params = {siBuffer, NULL, 0};
- unsigned char param256[] = {
+ static unsigned char param256[] = {
/* OBJECTIDENTIFIER 1.2.840.10045.3.1.7 (P-256)
* {iso(1) member-body(2) us(840) ansi-x962(10045) curves(3) prime(1) prime256v1(7)} */
0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07
};
- unsigned char param384[] = {
+ static unsigned char param384[] = {
/* OBJECTIDENTIFIER 1.3.132.0.34 (P-384)
* {iso(1) identified-organization(3) certicom(132) curve(0) ansip384r1(34)} */
0x06, 0x05, 0x2b, 0x81, 0x04, 0x00, 0x22
@@ -845,19 +847,19 @@ nss_setup_key_digest(int algo, SECKEYPublicKey** pubkey, HASH_HashType* htype,
/* uses libNSS */
/* hash prefix for md5, RFC2537 */
- unsigned char p_md5[] = {0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a,
+ static unsigned char p_md5[] = {0x30, 0x20, 0x30, 0x0c, 0x06, 0x08, 0x2a,
0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05, 0x05, 0x00, 0x04, 0x10};
/* hash prefix to prepend to hash output, from RFC3110 */
- unsigned char p_sha1[] = {0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B,
+ static unsigned char p_sha1[] = {0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B,
0x0E, 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14};
/* from RFC5702 */
- unsigned char p_sha256[] = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60,
+ static unsigned char p_sha256[] = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60,
0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20};
- unsigned char p_sha512[] = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60,
+ static unsigned char p_sha512[] = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60,
0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40};
/* from RFC6234 */
/* for future RSASHA384 ..
- unsigned char p_sha384[] = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60,
+ static unsigned char p_sha384[] = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60,
0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30};
*/
@@ -963,7 +965,7 @@ nss_setup_key_digest(int algo, SECKEYPublicKey** pubkey, HASH_HashType* htype,
* unchecked on format errors and alloc failures.
*/
enum sec_status
-verify_canonrrset(ldns_buffer* buf, int algo, unsigned char* sigblock,
+verify_canonrrset(sldns_buffer* buf, int algo, unsigned char* sigblock,
unsigned int sigblock_len, unsigned char* key, unsigned int keylen,
char** reason)
{
@@ -1019,8 +1021,8 @@ verify_canonrrset(ldns_buffer* buf, int algo, unsigned char* sigblock,
SECKEY_DestroyPublicKey(pubkey);
return sec_status_unchecked;
}
- if(HASH_HashBuf(htype, hash, (unsigned char*)ldns_buffer_begin(buf),
- (unsigned int)ldns_buffer_limit(buf)) != SECSuccess) {
+ if(HASH_HashBuf(htype, hash, (unsigned char*)sldns_buffer_begin(buf),
+ (unsigned int)sldns_buffer_limit(buf)) != SECSuccess) {
verbose(VERB_QUERY, "verify: HASH_HashBuf failed");
SECKEY_DestroyPublicKey(pubkey);
return sec_status_unchecked;
diff --git a/contrib/unbound/validator/val_secalgo.h b/contrib/unbound/validator/val_secalgo.h
index a5832af..085fbc5 100644
--- a/contrib/unbound/validator/val_secalgo.h
+++ b/contrib/unbound/validator/val_secalgo.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -42,6 +42,7 @@
#ifndef VALIDATOR_VAL_SECALGO_H
#define VALIDATOR_VAL_SECALGO_H
+struct sldns_buffer;
/**
* Return size of DS digest according to its hash algorithm.
@@ -76,7 +77,7 @@ int dnskey_algo_id_is_supported(int id);
* @return secure if verification succeeded, bogus on crypto failure,
* unchecked on format errors and alloc failures.
*/
-enum sec_status verify_canonrrset(ldns_buffer* buf, int algo,
+enum sec_status verify_canonrrset(struct sldns_buffer* buf, int algo,
unsigned char* sigblock, unsigned int sigblock_len,
unsigned char* key, unsigned int keylen, char** reason);
diff --git a/contrib/unbound/validator/val_sigcrypt.c b/contrib/unbound/validator/val_sigcrypt.c
index 79d5e45..5a4d0f4 100644
--- a/contrib/unbound/validator/val_sigcrypt.c
+++ b/contrib/unbound/validator/val_sigcrypt.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -41,7 +41,6 @@
* bridging between RR wireformat data and crypto calls.
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "validator/val_sigcrypt.h"
#include "validator/val_secalgo.h"
#include "validator/validator.h"
@@ -52,7 +51,12 @@
#include "util/module.h"
#include "util/net_help.h"
#include "util/regional.h"
+#include "ldns/keyraw.h"
+#include "ldns/sbuffer.h"
+#include "ldns/parseutil.h"
+#include "ldns/wire2str.h"
+#include <ctype.h>
#if !defined(HAVE_SSL) && !defined(HAVE_NSS)
#error "Need crypto library to do digital signature cryptography"
#endif
@@ -286,7 +290,7 @@ ds_create_dnskey_digest(struct module_env* env,
struct ub_packed_rrset_key* ds_rrset, size_t ds_idx,
uint8_t* digest)
{
- ldns_buffer* b = env->scratch_buffer;
+ sldns_buffer* b = env->scratch_buffer;
uint8_t* dnskey_rdata;
size_t dnskey_len;
rrset_get_rdata(dnskey_rrset, dnskey_idx, &dnskey_rdata, &dnskey_len);
@@ -294,15 +298,15 @@ ds_create_dnskey_digest(struct module_env* env,
/* create digest source material in buffer
* digest = digest_algorithm( DNSKEY owner name | DNSKEY RDATA);
* DNSKEY RDATA = Flags | Protocol | Algorithm | Public Key. */
- ldns_buffer_clear(b);
- ldns_buffer_write(b, dnskey_rrset->rk.dname,
+ sldns_buffer_clear(b);
+ sldns_buffer_write(b, dnskey_rrset->rk.dname,
dnskey_rrset->rk.dname_len);
- query_dname_tolower(ldns_buffer_begin(b));
- ldns_buffer_write(b, dnskey_rdata+2, dnskey_len-2); /* skip rdatalen*/
- ldns_buffer_flip(b);
+ query_dname_tolower(sldns_buffer_begin(b));
+ sldns_buffer_write(b, dnskey_rdata+2, dnskey_len-2); /* skip rdatalen*/
+ sldns_buffer_flip(b);
return secalgo_ds_digest(ds_get_digest_algo(ds_rrset, ds_idx),
- (unsigned char*)ldns_buffer_begin(b), ldns_buffer_limit(b),
+ (unsigned char*)sldns_buffer_begin(b), sldns_buffer_limit(b),
(unsigned char*)digest);
}
@@ -366,7 +370,7 @@ dnskey_calc_keytag(struct ub_packed_rrset_key* dnskey_rrset, size_t dnskey_idx)
size_t len;
rrset_get_rdata(dnskey_rrset, dnskey_idx, &data, &len);
/* do not pass rdatalen to ldns */
- return ldns_calc_keytag_raw(data+2, len-2);
+ return sldns_calc_keytag_raw(data+2, len-2);
}
int dnskey_algo_is_supported(struct ub_packed_rrset_key* dnskey_rrset,
@@ -530,7 +534,7 @@ dnskeyset_verify_rrset(struct module_env* env, struct val_env* ve,
void algo_needs_reason(struct module_env* env, int alg, char** reason, char* s)
{
char buf[256];
- ldns_lookup_table *t = ldns_lookup_by_id(ldns_algorithms, alg);
+ sldns_lookup_table *t = sldns_lookup_by_id(sldns_algorithms, alg);
if(t&&t->name)
snprintf(buf, sizeof(buf), "%s with algorithm %s", s, t->name);
else snprintf(buf, sizeof(buf), "%s with algorithm ALG%u", s,
@@ -579,7 +583,7 @@ dnskey_verify_rrset(struct module_env* env, struct val_env* ve,
enum sec_status
dnskeyset_verify_rrset_sig(struct module_env* env, struct val_env* ve,
- uint32_t now, struct ub_packed_rrset_key* rrset,
+ time_t now, struct ub_packed_rrset_key* rrset,
struct ub_packed_rrset_key* dnskey, size_t sig_idx,
struct rbtree_t** sortree, char** reason)
{
@@ -640,7 +644,7 @@ struct canon_rr {
*/
static int
canonical_compare_byfield(struct packed_rrset_data* d,
- const ldns_rr_descriptor* desc, size_t i, size_t j)
+ const sldns_rr_descriptor* desc, size_t i, size_t j)
{
/* sweep across rdata, keep track of some state:
* which rr field, and bytes left in field.
@@ -784,7 +788,7 @@ canonical_compare(struct ub_packed_rrset_key* rrset, size_t i, size_t j)
{
struct packed_rrset_data* d = (struct packed_rrset_data*)
rrset->entry.data;
- const ldns_rr_descriptor* desc;
+ const sldns_rr_descriptor* desc;
uint16_t type = ntohs(rrset->rk.type);
size_t minlen;
int c;
@@ -808,7 +812,12 @@ canonical_compare(struct ub_packed_rrset_key* rrset, size_t i, size_t j)
case LDNS_RR_TYPE_MR:
case LDNS_RR_TYPE_PTR:
case LDNS_RR_TYPE_DNAME:
- return query_dname_compare(d->rr_data[i]+2,
+ /* the wireread function has already checked these
+ * dname's for correctness, and this double checks */
+ if(!dname_valid(d->rr_data[i]+2, d->rr_len[i]-2) ||
+ !dname_valid(d->rr_data[j]+2, d->rr_len[j]-2))
+ return 0;
+ return query_dname_compare(d->rr_data[i]+2,
d->rr_data[j]+2);
/* These RR types have STR and fixed size rdata fields
@@ -831,7 +840,7 @@ canonical_compare(struct ub_packed_rrset_key* rrset, size_t i, size_t j)
case LDNS_RR_TYPE_PX:
case LDNS_RR_TYPE_NAPTR:
case LDNS_RR_TYPE_SRV:
- desc = ldns_rr_descript(type);
+ desc = sldns_rr_descript(type);
log_assert(desc);
/* this holds for the types that need canonicalizing */
log_assert(desc->_minimum == desc->_maximum);
@@ -904,15 +913,15 @@ canonical_sort(struct ub_packed_rrset_key* rrset, struct packed_rrset_data* d,
* @param can_owner_len: length of canonical owner name.
*/
static void
-insert_can_owner(ldns_buffer* buf, struct ub_packed_rrset_key* k,
+insert_can_owner(sldns_buffer* buf, struct ub_packed_rrset_key* k,
uint8_t* sig, uint8_t** can_owner, size_t* can_owner_len)
{
int rrsig_labels = (int)sig[3];
int fqdn_labels = dname_signame_label_count(k->rk.dname);
- *can_owner = ldns_buffer_current(buf);
+ *can_owner = sldns_buffer_current(buf);
if(rrsig_labels == fqdn_labels) {
/* no change */
- ldns_buffer_write(buf, k->rk.dname, k->rk.dname_len);
+ sldns_buffer_write(buf, k->rk.dname, k->rk.dname_len);
query_dname_tolower(*can_owner);
*can_owner_len = k->rk.dname_len;
return;
@@ -928,8 +937,8 @@ insert_can_owner(ldns_buffer* buf, struct ub_packed_rrset_key* k,
dname_remove_label(&nm, &len);
}
*can_owner_len = len+2;
- ldns_buffer_write(buf, (uint8_t*)"\001*", 2);
- ldns_buffer_write(buf, nm, len);
+ sldns_buffer_write(buf, (uint8_t*)"\001*", 2);
+ sldns_buffer_write(buf, nm, len);
query_dname_tolower(*can_owner);
}
}
@@ -941,10 +950,10 @@ insert_can_owner(ldns_buffer* buf, struct ub_packed_rrset_key* k,
* @param len: length of the rdata (including rdatalen uint16).
*/
static void
-canonicalize_rdata(ldns_buffer* buf, struct ub_packed_rrset_key* rrset,
+canonicalize_rdata(sldns_buffer* buf, struct ub_packed_rrset_key* rrset,
size_t len)
{
- uint8_t* datstart = ldns_buffer_current(buf)-len+2;
+ uint8_t* datstart = sldns_buffer_current(buf)-len+2;
switch(ntohs(rrset->rk.type)) {
case LDNS_RR_TYPE_NXT:
case LDNS_RR_TYPE_NS:
@@ -1035,6 +1044,69 @@ canonicalize_rdata(ldns_buffer* buf, struct ub_packed_rrset_key* rrset,
}
}
+int rrset_canonical_equal(struct regional* region,
+ struct ub_packed_rrset_key* k1, struct ub_packed_rrset_key* k2)
+{
+ struct rbtree_t sortree1, sortree2;
+ struct canon_rr *rrs1, *rrs2, *p1, *p2;
+ struct packed_rrset_data* d1=(struct packed_rrset_data*)k1->entry.data;
+ struct packed_rrset_data* d2=(struct packed_rrset_data*)k2->entry.data;
+ struct ub_packed_rrset_key fk;
+ struct packed_rrset_data fd;
+ size_t flen[2];
+ uint8_t* fdata[2];
+
+ /* basic compare */
+ if(k1->rk.dname_len != k2->rk.dname_len ||
+ k1->rk.flags != k2->rk.flags ||
+ k1->rk.type != k2->rk.type ||
+ k1->rk.rrset_class != k2->rk.rrset_class ||
+ query_dname_compare(k1->rk.dname, k2->rk.dname) != 0)
+ return 0;
+ if(d1->ttl != d2->ttl ||
+ d1->count != d2->count ||
+ d1->rrsig_count != d2->rrsig_count ||
+ d1->trust != d2->trust ||
+ d1->security != d2->security)
+ return 0;
+
+ /* init */
+ memset(&fk, 0, sizeof(fk));
+ memset(&fd, 0, sizeof(fd));
+ fk.entry.data = &fd;
+ fd.count = 2;
+ fd.rr_len = flen;
+ fd.rr_data = fdata;
+ rbtree_init(&sortree1, &canonical_tree_compare);
+ rbtree_init(&sortree2, &canonical_tree_compare);
+ rrs1 = regional_alloc(region, sizeof(struct canon_rr)*d1->count);
+ rrs2 = regional_alloc(region, sizeof(struct canon_rr)*d2->count);
+ if(!rrs1 || !rrs2) return 1; /* alloc failure */
+
+ /* sort */
+ canonical_sort(k1, d1, &sortree1, rrs1);
+ canonical_sort(k2, d2, &sortree2, rrs2);
+
+ /* compare canonical-sorted RRs for canonical-equality */
+ if(sortree1.count != sortree2.count)
+ return 0;
+ p1 = (struct canon_rr*)rbtree_first(&sortree1);
+ p2 = (struct canon_rr*)rbtree_first(&sortree2);
+ while(p1 != (struct canon_rr*)RBTREE_NULL &&
+ p2 != (struct canon_rr*)RBTREE_NULL) {
+ flen[0] = d1->rr_len[p1->rr_idx];
+ flen[1] = d2->rr_len[p2->rr_idx];
+ fdata[0] = d1->rr_data[p1->rr_idx];
+ fdata[1] = d2->rr_data[p2->rr_idx];
+
+ if(canonical_compare(&fk, 0, 1) != 0)
+ return 0;
+ p1 = (struct canon_rr*)rbtree_next(&p1->node);
+ p2 = (struct canon_rr*)rbtree_next(&p2->node);
+ }
+ return 1;
+}
+
/**
* Create canonical form of rrset in the scratch buffer.
* @param region: temporary region.
@@ -1048,7 +1120,7 @@ canonicalize_rdata(ldns_buffer* buf, struct ub_packed_rrset_key* rrset,
* @return false on alloc error.
*/
static int
-rrset_canonical(struct regional* region, ldns_buffer* buf,
+rrset_canonical(struct regional* region, sldns_buffer* buf,
struct ub_packed_rrset_key* k, uint8_t* sig, size_t siglen,
struct rbtree_t** sortree)
{
@@ -1072,13 +1144,13 @@ rrset_canonical(struct regional* region, ldns_buffer* buf,
canonical_sort(k, d, *sortree, rrs);
}
- ldns_buffer_clear(buf);
- ldns_buffer_write(buf, sig, siglen);
+ sldns_buffer_clear(buf);
+ sldns_buffer_write(buf, sig, siglen);
/* canonicalize signer name */
- query_dname_tolower(ldns_buffer_begin(buf)+18);
+ query_dname_tolower(sldns_buffer_begin(buf)+18);
RBTREE_FOR(walk, struct canon_rr*, (*sortree)) {
/* see if there is enough space left in the buffer */
- if(ldns_buffer_remaining(buf) < can_owner_len + 2 + 2 + 4
+ if(sldns_buffer_remaining(buf) < can_owner_len + 2 + 2 + 4
+ d->rr_len[walk->rr_idx]) {
log_err("verify: failed to canonicalize, "
"rrset too big");
@@ -1086,17 +1158,17 @@ rrset_canonical(struct regional* region, ldns_buffer* buf,
}
/* determine canonical owner name */
if(can_owner)
- ldns_buffer_write(buf, can_owner, can_owner_len);
+ sldns_buffer_write(buf, can_owner, can_owner_len);
else insert_can_owner(buf, k, sig, &can_owner,
&can_owner_len);
- ldns_buffer_write(buf, &k->rk.type, 2);
- ldns_buffer_write(buf, &k->rk.rrset_class, 2);
- ldns_buffer_write(buf, sig+4, 4);
- ldns_buffer_write(buf, d->rr_data[walk->rr_idx],
+ sldns_buffer_write(buf, &k->rk.type, 2);
+ sldns_buffer_write(buf, &k->rk.rrset_class, 2);
+ sldns_buffer_write(buf, sig+4, 4);
+ sldns_buffer_write(buf, d->rr_data[walk->rr_idx],
d->rr_len[walk->rr_idx]);
canonicalize_rdata(buf, k, d->rr_len[walk->rr_idx]);
}
- ldns_buffer_flip(buf);
+ sldns_buffer_flip(buf);
return 1;
}
@@ -1215,12 +1287,12 @@ adjust_ttl(struct val_env* ve, uint32_t unow,
*
* Use the smallest of these.
*/
- if(d->ttl > (uint32_t)origttl) {
+ if(d->ttl > (time_t)origttl) {
verbose(VERB_QUERY, "rrset TTL larger than original TTL,"
" adjusting TTL downwards");
d->ttl = origttl;
}
- if(expittl > 0 && d->ttl > (uint32_t)expittl) {
+ if(expittl > 0 && d->ttl > (time_t)expittl) {
verbose(VERB_ALGO, "rrset TTL larger than sig expiration ttl,"
" adjusting TTL downwards");
d->ttl = expittl;
@@ -1228,8 +1300,8 @@ adjust_ttl(struct val_env* ve, uint32_t unow,
}
enum sec_status
-dnskey_verify_rrset_sig(struct regional* region, ldns_buffer* buf,
- struct val_env* ve, uint32_t now,
+dnskey_verify_rrset_sig(struct regional* region, sldns_buffer* buf,
+ struct val_env* ve, time_t now,
struct ub_packed_rrset_key* rrset, struct ub_packed_rrset_key* dnskey,
size_t dnskey_idx, size_t sig_idx,
struct rbtree_t** sortree, int* buf_canon, char** reason)
diff --git a/contrib/unbound/validator/val_sigcrypt.h b/contrib/unbound/validator/val_sigcrypt.h
index c220b00..68aa9a4 100644
--- a/contrib/unbound/validator/val_sigcrypt.h
+++ b/contrib/unbound/validator/val_sigcrypt.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -49,6 +49,7 @@ struct module_env;
struct ub_packed_rrset_key;
struct rbtree_t;
struct regional;
+struct sldns_buffer;
/** number of entries in algorithm needs array */
#define ALGO_NEEDS_MAX 256
@@ -274,7 +275,7 @@ enum sec_status dnskey_verify_rrset(struct module_env* env,
* or unchecked on error.
*/
enum sec_status dnskeyset_verify_rrset_sig(struct module_env* env,
- struct val_env* ve, uint32_t now, struct ub_packed_rrset_key* rrset,
+ struct val_env* ve, time_t now, struct ub_packed_rrset_key* rrset,
struct ub_packed_rrset_key* dnskey, size_t sig_idx,
struct rbtree_t** sortree, char** reason);
@@ -298,7 +299,7 @@ enum sec_status dnskeyset_verify_rrset_sig(struct module_env* env,
* bogus if it did not validate.
*/
enum sec_status dnskey_verify_rrset_sig(struct regional* region,
- ldns_buffer* buf, struct val_env* ve, uint32_t now,
+ struct sldns_buffer* buf, struct val_env* ve, time_t now,
struct ub_packed_rrset_key* rrset, struct ub_packed_rrset_key* dnskey,
size_t dnskey_idx, size_t sig_idx,
struct rbtree_t** sortree, int* buf_canon, char** reason);
@@ -308,4 +309,15 @@ enum sec_status dnskey_verify_rrset_sig(struct regional* region,
*/
int canonical_tree_compare(const void* k1, const void* k2);
+/**
+ * Compare two rrsets and see if they are the same, canonicalised.
+ * The rrsets are not altered.
+ * @param region: temporary region.
+ * @param k1: rrset1
+ * @param k2: rrset2
+ * @return true if equal.
+ */
+int rrset_canonical_equal(struct regional* region,
+ struct ub_packed_rrset_key* k1, struct ub_packed_rrset_key* k2);
+
#endif /* VALIDATOR_VAL_SIGCRYPT_H */
diff --git a/contrib/unbound/validator/val_utils.c b/contrib/unbound/validator/val_utils.c
index d4a6446..ecf2dfa 100644
--- a/contrib/unbound/validator/val_utils.c
+++ b/contrib/unbound/validator/val_utils.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -486,7 +486,7 @@ val_verify_DNSKEY_with_DS(struct module_env* env, struct val_env* ve,
/* Once we see a single DS with a known digestID and
* algorithm, we cannot return INSECURE (with a
* "null" KeyEntry). */
- has_useful_ds = true;
+ has_useful_ds = 1;
sec = verify_dnskeys_with_ds_rr(env, ve, dnskey_rrset,
ds_rrset, i, reason);
@@ -596,7 +596,7 @@ val_verify_DNSKEY_with_TA(struct module_env* env, struct val_env* ve,
/* Once we see a single DS with a known digestID and
* algorithm, we cannot return INSECURE (with a
* "null" KeyEntry). */
- has_useful_ta = true;
+ has_useful_ta = 1;
sec = verify_dnskeys_with_ds_rr(env, ve, dnskey_rrset,
ta_ds, i, reason);
@@ -622,7 +622,7 @@ val_verify_DNSKEY_with_TA(struct module_env* env, struct val_env* ve,
continue;
/* we saw a useful TA */
- has_useful_ta = true;
+ has_useful_ta = 1;
sec = dnskey_verify_rrset(env, ve, dnskey_rrset,
ta_dnskey, i, reason);
@@ -773,6 +773,8 @@ rrset_has_signer(struct ub_packed_rrset_key* rrset, uint8_t* name, size_t len)
for(i = d->count; i< d->count+d->rrsig_count; i++) {
if(d->rr_len[i] > 2+18+len) {
/* at least rdatalen + signature + signame (+1 sig)*/
+ if(!dname_valid(d->rr_data[i]+2+18, d->rr_len[i]-2-18))
+ continue;
if(query_dname_compare(name, d->rr_data[i]+2+18) == 0)
{
return 1;
diff --git a/contrib/unbound/validator/val_utils.h b/contrib/unbound/validator/val_utils.h
index f0afc37..b0344ef 100644
--- a/contrib/unbound/validator/val_utils.h
+++ b/contrib/unbound/validator/val_utils.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
diff --git a/contrib/unbound/validator/validator.c b/contrib/unbound/validator/validator.c
index 10b0a24..aefa26a 100644
--- a/contrib/unbound/validator/validator.c
+++ b/contrib/unbound/validator/validator.c
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
@@ -40,7 +40,6 @@
* According to RFC 4034.
*/
#include "config.h"
-#include <ldns/ldns.h>
#include "validator/validator.h"
#include "validator/val_anchor.h"
#include "validator/val_kcache.h"
@@ -59,6 +58,8 @@
#include "util/regional.h"
#include "util/config_file.h"
#include "util/fptr_wlist.h"
+#include "ldns/rrdef.h"
+#include "ldns/wire2str.h"
/* forward decl for cache response and normal super inform calls of a DS */
static void process_ds_response(struct module_qstate* qstate,
@@ -294,9 +295,12 @@ needs_validation(struct module_qstate* qstate, int ret_rc,
else rcode = (int)FLAGS_GET_RCODE(ret_msg->rep->flags);
if(rcode != LDNS_RCODE_NOERROR && rcode != LDNS_RCODE_NXDOMAIN) {
- verbose(VERB_ALGO, "cannot validate non-answer, rcode %s",
- ldns_lookup_by_id(ldns_rcodes, rcode)?
- ldns_lookup_by_id(ldns_rcodes, rcode)->name:"??");
+ if(verbosity >= VERB_ALGO) {
+ char rc[16];
+ rc[0]=0;
+ (void)sldns_wire2str_rcode_buf(rcode, rc, sizeof(rc));
+ verbose(VERB_ALGO, "cannot validate non-answer, rcode %s", rc);
+ }
return 0;
}
@@ -758,11 +762,12 @@ validate_nodata_response(struct module_env* env, struct val_env* ve,
* @param chase_reply: answer to that query to validate.
* @param kkey: the key entry, which is trusted, and which matches
* the signer of the answer. The key entry isgood().
+ * @param rcode: adjusted RCODE, in case of RCODE/proof mismatch leniency.
*/
static void
validate_nameerror_response(struct module_env* env, struct val_env* ve,
struct query_info* qchase, struct reply_info* chase_reply,
- struct key_entry_key* kkey)
+ struct key_entry_key* kkey, int* rcode)
{
int has_valid_nsec = 0;
int has_valid_wnsec = 0;
@@ -809,6 +814,10 @@ validate_nameerror_response(struct module_env* env, struct val_env* ve,
verbose(VERB_QUERY, "NameError response has failed to prove: "
"qname does not exist");
chase_reply->security = sec_status_bogus;
+ /* Be lenient with RCODE in NSEC NameError responses */
+ validate_nodata_response(env, ve, qchase, chase_reply, kkey);
+ if (chase_reply->security == sec_status_secure)
+ *rcode = LDNS_RCODE_NOERROR;
return;
}
@@ -816,6 +825,10 @@ validate_nameerror_response(struct module_env* env, struct val_env* ve,
verbose(VERB_QUERY, "NameError response has failed to prove: "
"covering wildcard does not exist");
chase_reply->security = sec_status_bogus;
+ /* Be lenient with RCODE in NSEC NameError responses */
+ validate_nodata_response(env, ve, qchase, chase_reply, kkey);
+ if (chase_reply->security == sec_status_secure)
+ *rcode = LDNS_RCODE_NOERROR;
return;
}
@@ -1564,6 +1577,7 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq,
struct val_env* ve, int id)
{
enum val_classification subtype;
+ int rcode;
if(!vq->key_entry) {
verbose(VERB_ALGO, "validate: no key entry, failed");
@@ -1647,7 +1661,7 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq,
sec_status_to_string(
vq->chase_reply->security));
break;
-
+
case VAL_CLASS_NODATA:
verbose(VERB_ALGO, "Validating a nodata response");
validate_nodata_response(qstate->env, ve,
@@ -1658,12 +1672,15 @@ processValidate(struct module_qstate* qstate, struct val_qstate* vq,
break;
case VAL_CLASS_NAMEERROR:
+ rcode = (int)FLAGS_GET_RCODE(vq->orig_msg->rep->flags);
verbose(VERB_ALGO, "Validating a nxdomain response");
validate_nameerror_response(qstate->env, ve,
- &vq->qchase, vq->chase_reply, vq->key_entry);
+ &vq->qchase, vq->chase_reply, vq->key_entry, &rcode);
verbose(VERB_DETAIL, "validate(nxdomain): %s",
sec_status_to_string(
vq->chase_reply->security));
+ FLAGS_SET_RCODE(vq->orig_msg->rep->flags, rcode);
+ FLAGS_SET_RCODE(vq->chase_reply->flags, rcode);
break;
case VAL_CLASS_CNAME:
@@ -2344,12 +2361,13 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq,
char* reason = NULL;
enum val_classification subtype;
if(rcode != LDNS_RCODE_NOERROR) {
- char* rc = ldns_pkt_rcode2str(rcode);
+ char rc[16];
+ rc[0]=0;
+ (void)sldns_wire2str_rcode_buf(rcode, rc, sizeof(rc));
/* errors here pretty much break validation */
verbose(VERB_DETAIL, "DS response was error, thus bogus");
errinf(qstate, rc);
errinf(qstate, "no DS");
- free(rc);
goto return_bogus;
}
@@ -2398,7 +2416,7 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq,
subtype == VAL_CLASS_NAMEERROR) {
/* NODATA means that the qname exists, but that there was
* no DS. This is a pretty normal case. */
- uint32_t proof_ttl = 0;
+ time_t proof_ttl = 0;
enum sec_status sec;
/* make sure there are NSECs or NSEC3s with signatures */
@@ -2521,10 +2539,11 @@ ds_response_to_ke(struct module_qstate* qstate, struct val_qstate* vq,
"DS response, thus bogus.");
errinf(qstate, "no DS and");
if(FLAGS_GET_RCODE(msg->rep->flags) != LDNS_RCODE_NOERROR) {
- char* rc = ldns_pkt_rcode2str(
- FLAGS_GET_RCODE(msg->rep->flags));
+ char rc[16];
+ rc[0]=0;
+ (void)sldns_wire2str_rcode_buf((int)FLAGS_GET_RCODE(
+ msg->rep->flags), rc, sizeof(rc));
errinf(qstate, rc);
- free(rc);
} else errinf(qstate, val_classification_to_string(subtype));
errinf(qstate, "message fails to prove that");
goto return_bogus;
diff --git a/contrib/unbound/validator/validator.h b/contrib/unbound/validator/validator.h
index 1a29c16..20f806a 100644
--- a/contrib/unbound/validator/validator.h
+++ b/contrib/unbound/validator/validator.h
@@ -21,16 +21,16 @@
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
OpenPOWER on IntegriCloud