summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWillem Toorop <willem@nlnetlabs.nl>2014-01-10 21:54:44 +0100
committerWillem Toorop <willem@nlnetlabs.nl>2014-01-10 21:54:44 +0100
commitcdb6e3dc6563b96d906622d3b466ff4e8a3a0ff8 (patch)
tree1e48e18b351e02d0138e8f96084a425f331c4ab4
parenta13c772243940045b1cc3ddd827268c0a0f765c7 (diff)
parent27d878c4edf4924394a902cee149932eba2c11a9 (diff)
downloadldns-release-1.6.x.tar.gz
Merge branch 'release-1.6.17' into release-1.6.xrelease-1.6.x
Conflicts: Changelog configure.ac contrib/python/Changelog contrib/python/ldns_packet.i dnssec.c drill/configure.ac examples/configure.ac examples/ldns-dane.c examples/ldns-testpkts.h examples/nsd-test/configure.ac ldns/resolver.h lua/configure.ac pcat/configure.ac
-rw-r--r--.gitignore236
-rw-r--r--.gitmodules6
-rw-r--r--Changelog58
-rw-r--r--Makefile.in270
-rw-r--r--README40
-rw-r--r--README.git (renamed from README.svn)10
-rw-r--r--acx_nlnetlabs.m444
-rw-r--r--ax_python_devel.m461
-rw-r--r--compat/b32_ntop.c333
-rw-r--r--compat/b32_pton.c387
-rw-r--r--compat/b64_ntop.c31
-rw-r--r--compat/b64_pton.c17
-rw-r--r--compat/snprintf.c1750
-rw-r--r--configure.ac135
m---------contrib/DNS-LDNS0
-rw-r--r--contrib/ldnsx/ldnsx.py7
-rw-r--r--contrib/python/Changelog28
-rw-r--r--contrib/python/Makefile6
-rw-r--r--contrib/python/docs/source/conf.py4
-rw-r--r--contrib/python/docs/source/modules/ldns_rdf.rst2
-rwxr-xr-xcontrib/python/examples/test_buffer.py16
-rwxr-xr-xcontrib/python/examples/test_dname.py2
-rwxr-xr-xcontrib/python/examples/test_pkt.py1937
-rwxr-xr-xcontrib/python/examples/test_rdf.py23
-rwxr-xr-xcontrib/python/examples/test_resolver.py1751
-rwxr-xr-x[-rw-r--r--]contrib/python/examples/test_rr.py20
-rw-r--r--contrib/python/ldns_packet.i1348
-rw-r--r--contrib/python/ldns_rdf.i42
-rw-r--r--contrib/python/ldns_resolver.i1278
-rw-r--r--dane.c14
-rw-r--r--dnssec.c308
-rw-r--r--dnssec_sign.c81
-rw-r--r--dnssec_verify.c20
-rw-r--r--dnssec_zone.c205
-rw-r--r--doc/API.xml2
-rw-r--r--drill/chasetrace.c2
-rw-r--r--drill/configure.ac2
-rw-r--r--drill/drill.1.in11
-rw-r--r--drill/drill.c55
-rw-r--r--drill/drill_util.c6
-rw-r--r--drill/securetrace.c28
-rw-r--r--drill/work.c1
-rw-r--r--error.c18
-rw-r--r--examples/configure.ac40
-rw-r--r--examples/ldns-compare-zones.c2
-rw-r--r--examples/ldns-dane.1.in3
-rw-r--r--examples/ldns-dane.c104
-rw-r--r--examples/ldns-dpa.c4
-rw-r--r--examples/ldns-key2ds.14
-rw-r--r--examples/ldns-key2ds.c3
-rw-r--r--examples/ldns-keyfetcher.c2
-rw-r--r--examples/ldns-keygen.c4
-rw-r--r--examples/ldns-read-zone.121
-rw-r--r--examples/ldns-read-zone.c126
-rw-r--r--examples/ldns-signzone.c22
-rw-r--r--examples/ldns-testns.c2
-rw-r--r--examples/ldns-testpkts.c61
-rw-r--r--examples/ldns-testpkts.h13
-rw-r--r--examples/ldns-update.c2
-rw-r--r--examples/ldns-verify-zone.c79
-rw-r--r--examples/ldns-walk.112
-rw-r--r--examples/ldns-zcat.14
-rw-r--r--examples/ldns-zcat.c4
-rw-r--r--examples/ldns-zsplit.14
-rw-r--r--examples/ldnsd.c10
-rw-r--r--examples/nsd-test/configure.ac2
-rw-r--r--higher.c48
-rw-r--r--host2str.c685
-rw-r--r--host2wire.c20
-rwxr-xr-xinstall-sh14
-rw-r--r--keys.c22
-rw-r--r--ldns/common.h.in3
-rw-r--r--ldns/dane.h2
-rw-r--r--ldns/dnssec.h28
-rw-r--r--ldns/dnssec_sign.h4
-rw-r--r--ldns/dnssec_verify.h4
-rw-r--r--ldns/dnssec_zone.h18
-rw-r--r--ldns/error.h11
-rw-r--r--ldns/host2str.h168
-rw-r--r--ldns/keys.h4
-rw-r--r--ldns/ldns.h7
-rw-r--r--ldns/net.h.in1
-rw-r--r--ldns/packet.h36
-rw-r--r--ldns/radix.h240
-rw-r--r--ldns/rdata.h62
-rw-r--r--ldns/resolver.h55
-rw-r--r--ldns/rr.h52
-rw-r--r--ldns/str2host.h60
-rw-r--r--ldns/util.h.in70
-rw-r--r--lua/configure.ac2
-rw-r--r--lua/rns-lib.lua38
-rwxr-xr-xmakedist.sh32
-rw-r--r--masterdont/config_file.h2
-rw-r--r--masterdont/server.c19
-rw-r--r--masterdont/zones.h2
-rw-r--r--net.c796
-rw-r--r--packaging/ldns-config.16
-rwxr-xr-xpackaging/ldns-config.in5
-rw-r--r--packet.c110
-rw-r--r--parse.c22
-rw-r--r--pcat/configure.ac2
-rw-r--r--pcat/pcat-diff.c6
-rwxr-xr-xpcat/pcat-grep.pl2
-rw-r--r--pcat/pcat-print.12
-rw-r--r--radix.c1590
-rw-r--r--rdata.c91
-rw-r--r--resolver.c184
-rw-r--r--rr.c933
-rw-r--r--sha1.c2
-rw-r--r--sha2.c15
-rw-r--r--str2host.c382
-rw-r--r--test/05-iana-rr-types.tpkgbin0 -> 1333 bytes
-rw-r--r--test/08-zonereader.tpkgbin60635 -> 58187 bytes
-rw-r--r--test/12-unit-tests-dnssec.tpkgbin0 -> 5603 bytes
-rw-r--r--test/12.unit-tests-dnssec.tpkgbin5647 -> 0 bytes
-rw-r--r--test/15-unit-tests-rrtypes.tpkgbin0 -> 4444 bytes
-rw-r--r--test/15.unit-tests-rrtypes.tpkgbin4473 -> 0 bytes
-rw-r--r--test/32-unbound-regression.tpkgbin0 -> 1820 bytes
-rw-r--r--test/33-test-unbound-latest.tpkgbin0 -> 1878 bytes
-rwxr-xr-xtest/test_all.sh7
-rwxr-xr-xtest/test_ci.sh110
-rw-r--r--tsig.c12
-rw-r--r--util.c348
-rw-r--r--wire2host.c55
-rw-r--r--zone.c113
125 files changed, 13157 insertions, 4468 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..b2d6c5f1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,236 @@
+/.libs/
+/_ldns.la
+/Makefile
+/aclocal.m4
+/autom4te.cache/
+/buffer.lo
+/buffer.o
+/compat/.libs/
+/compat/b64_ntop.lo
+/compat/b64_ntop.o
+/compat/b64_pton.lo
+/compat/b64_pton.o
+/config.guess
+/config.h
+/config.log
+/config.status
+/config.sub
+/configure
+/contrib/python/ldns.py
+/contrib/python/ldns_wrapper.c
+/dane.lo
+/dane.o
+/dname.lo
+/dname.o
+/dnssec.lo
+/dnssec.o
+/dnssec_sign.lo
+/dnssec_sign.o
+/dnssec_verify.lo
+/dnssec_verify.o
+/dnssec_zone.lo
+/dnssec_zone.o
+/doc/ldns_manpages
+/doc/man/
+/drill/.libs/
+/drill/chasetrace.lo
+/drill/chasetrace.o
+/drill/dnssec.lo
+/drill/dnssec.o
+/drill/drill
+/drill/drill.1
+/drill/drill.lo
+/drill/drill.o
+/drill/drill_util.lo
+/drill/drill_util.o
+/drill/error.lo
+/drill/error.o
+/drill/root.lo
+/drill/root.o
+/drill/securetrace.lo
+/drill/securetrace.o
+/drill/work.lo
+/drill/work.o
+/duration.lo
+/duration.o
+/error.lo
+/error.o
+/examples/.libs/
+/examples/ldns-chaos
+/examples/ldns-chaos.lo
+/examples/ldns-chaos.o
+/examples/ldns-compare-zones
+/examples/ldns-compare-zones.lo
+/examples/ldns-compare-zones.o
+/examples/ldns-dane
+/examples/ldns-dane.1
+/examples/ldns-dane.lo
+/examples/ldns-dane.o
+/examples/ldns-dpa
+/examples/ldns-dpa.lo
+/examples/ldns-dpa.o
+/examples/ldns-gen-zone
+/examples/ldns-gen-zone.lo
+/examples/ldns-gen-zone.o
+/examples/ldns-key2ds
+/examples/ldns-key2ds.lo
+/examples/ldns-key2ds.o
+/examples/ldns-keyfetcher
+/examples/ldns-keyfetcher.lo
+/examples/ldns-keyfetcher.o
+/examples/ldns-keygen
+/examples/ldns-keygen.lo
+/examples/ldns-keygen.o
+/examples/ldns-mx
+/examples/ldns-mx.lo
+/examples/ldns-mx.o
+/examples/ldns-notify
+/examples/ldns-notify.lo
+/examples/ldns-notify.o
+/examples/ldns-nsec3-hash
+/examples/ldns-nsec3-hash.lo
+/examples/ldns-nsec3-hash.o
+/examples/ldns-read-zone
+/examples/ldns-read-zone.lo
+/examples/ldns-read-zone.o
+/examples/ldns-resolver
+/examples/ldns-resolver.lo
+/examples/ldns-resolver.o
+/examples/ldns-revoke
+/examples/ldns-revoke.lo
+/examples/ldns-revoke.o
+/examples/ldns-rrsig
+/examples/ldns-rrsig.lo
+/examples/ldns-rrsig.o
+/examples/ldns-signzone
+/examples/ldns-signzone.lo
+/examples/ldns-signzone.o
+/examples/ldns-test-edns
+/examples/ldns-test-edns.lo
+/examples/ldns-test-edns.o
+/examples/ldns-testns
+/examples/ldns-testns.lo
+/examples/ldns-testns.o
+/examples/ldns-testpkts.lo
+/examples/ldns-testpkts.o
+/examples/ldns-update
+/examples/ldns-update.lo
+/examples/ldns-update.o
+/examples/ldns-verify-zone
+/examples/ldns-verify-zone.1
+/examples/ldns-verify-zone.lo
+/examples/ldns-verify-zone.o
+/examples/ldns-version
+/examples/ldns-version.lo
+/examples/ldns-version.o
+/examples/ldns-walk
+/examples/ldns-walk.lo
+/examples/ldns-walk.o
+/examples/ldns-zcat
+/examples/ldns-zcat.lo
+/examples/ldns-zcat.o
+/examples/ldns-zsplit
+/examples/ldns-zsplit.lo
+/examples/ldns-zsplit.o
+/examples/ldnsd
+/examples/ldnsd.lo
+/examples/ldnsd.o
+/higher.lo
+/higher.o
+/host2str.lo
+/host2str.o
+/host2wire.lo
+/host2wire.o
+/include/
+/keys.lo
+/keys.o
+/ldns/common.h
+/ldns/config.h
+/ldns/config.h.in
+/ldns/config.h.in~
+/ldns/net.h
+/ldns/util.h
+/ldns_wrapper.lo
+/ldns_wrapper.o
+/lib
+/libldns.la
+/libtool
+/linktest
+/linktest.lo
+/linktest.o
+/ltmain.sh
+/m4/
+/net.lo
+/net.o
+/packaging/ldns-config
+/packaging/libldns.pc
+/packet.lo
+/packet.o
+/parse.lo
+/parse.o
+/radix.lo
+/radix.o
+/rbtree.lo
+/rbtree.o
+/rdata.lo
+/rdata.o
+/resolver.lo
+/resolver.o
+/rr.lo
+/rr.o
+/rr_functions.lo
+/rr_functions.o
+/sha1.lo
+/sha1.o
+/sha2.lo
+/sha2.o
+/str2host.lo
+/str2host.o
+/test/.done-01-compile
+/test/.done-02-lint
+/test/.done-03-run
+/test/.done-04-run-normal
+/test/.done-05-iana-rr-types
+/test/.done-07-compile-examples
+/test/.done-08-zonereader
+/test/.done-09-doc-check
+/test/.done-12-unit-tests-dnssec
+/test/.done-13-unit-tests-base
+/test/.done-14-read-zone
+/test/.done-15-unit-tests-rrtypes
+/test/.done-16-compile-builddir
+/test/.done-17-stub-resolver
+/test/.done-18-drill-tests1
+/test/.done-19-keygen
+/test/.done-20-sign-zone
+/test/.done-30-load-pyldns
+/test/.done-31-load-pyldnsx
+/test/.done-32-unbound-1.4.20-regression
+/test/.done-33-wget-compile-test-unbound-latest
+/test/.done-999-compile-nossl
+/test/.done-codingstyle
+/test/result.02-lint
+/test/result.03-run
+/test/result.04-run-normal
+/test/result.05-iana-rr-types
+/test/result.08-zonereader
+/test/result.09-doc-check
+/test/result.12-unit-tests-dnssec
+/test/result.13-unit-tests-base
+/test/result.14-read-zone
+/test/result.15-unit-tests-rrtypes
+/test/result.17-stub-resolver
+/test/result.18-drill-tests1
+/test/result.19-keygen
+/test/result.20-sign-zone
+/test/result.codingstyle
+/tsig.lo
+/tsig.o
+/update.lo
+/update.o
+/util.lo
+/util.o
+/wire2host.lo
+/wire2host.o
+/zone.lo
+/zone.o
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 00000000..df684f29
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "contrib/Net-LDNS"]
+ path = contrib/Net-LDNS
+ url = https://github.com/erikoest/Net-LDNS
+[submodule "contrib/DNS-LDNS"]
+ path = contrib/DNS-LDNS
+ url = https://github.com/erikoest/DNS-LDNS
diff --git a/Changelog b/Changelog
index 845d5b8a..48ea9bbd 100644
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,61 @@
+1.6.17 2014-01-10
+ * Fix ldns_dnssec_zone_new_frm_fp_l to allow the last parsed line of a
+ zone to be an NSEC3 (or its RRSIG) covering an empty non terminal.
+ * Add --disable-dane option to configure and check availability of the
+ for dane needed X509_check_ca function in openssl.
+ * bugfix #490: Get rid of type-punned pointer warnings.
+ Thanks Adam Tkac.
+ * Make sure executables are linked against libcrypto with the
+ LIBSSL_LDFLAGS. Thanks Leo Baltus.
+ * Miscellaneous prototype fixes. Thanks Dag-Erling Smørgrav.
+ * README now shows preferred way to configure for examples and drill.
+ * Bind to source address for resolvers. drill binds to source with -I.
+ Thanks Bryan Duff.
+ * -T option for ldns-dane that has specific exit status for PKIX
+ validated connections without (secure) TLSA records.
+ * Fix b{32,64}_{ntop,pton} detection and handling.
+ * New RR type TKEY, but without operational practice.
+ * New RR types HIP, NINFO, RKEY, CDS, EUI48, EUI64, URI, CAA and TA.
+ * New output format flag (and accompanying functions) to print certain
+ RR's as unknown type
+ * -u and -U parameter for ldns-read-zone to mark/unmark a RR type
+ for printing as unknown type
+ * bugfix #504: GPOS RR has three rdata fields. Thanks Jelte Jansen.
+ * bugfix #497: Properly test for EOF when reading key files with drill.
+ * New functions: ldns_pkt_ixfr_request_new and
+ ldns_pkt_ixfr_request_new_frm_str.
+ * Use SNI with ldns-dane
+ * bugfix #507: ldnsx Fix use of non-existent variables and not
+ properly referring to instance variable. Patch from shussain.
+ * bugfix #508: ldnsx Adding NSEC3PARAM to known/allowable RR type
+ dictionary. Patch from shussain.
+ * bugfix #517: ldns_resolver_new_frm_fp error when invoked using a NULL
+ file pointer.
+ * Fix memory leak in contrib/python: ldns_pkt.new_query.
+ * Fix buffer overflow in fget_token and bget_token.
+ * ldns-verify-zone NSEC3 checking from quadratic to linear performance.
+ Thanks NIC MX (nicmexico.mx)
+ * ldns-dane setup new ssl session for each new connect to prevent hangs
+ * bugfix #521: drill trace continue on empty non-terminals with NSEC3
+ * bugfix #525: Fix documentation of ldns_resolver_set_retry
+ * Remove unused LDNS_RDF_TYPE_TSIG and associated functions.
+ * Fix ldns_nsec_covers_name for zones with an apex only. Thanks Miek.
+ * Configure option to build perl bindings: --with-p5-dns-ldns
+ (DNS::LDNS is a contribution from Erik Ostlyngen)
+ * bugfix #527: Move -lssl before -lcrypto when linking
+ * Optimize TSIG digest function name comparison (Thanks Marc Buijsman)
+ * Compare names case insensitive with ldns_pkt_rr_list_by_name and
+ ldns_pkt_rr_list_by_name_and_type (thanks Johannes Naab)
+ * A separate --enable for each draft RR type: --enable-rrtype-ninfo,
+ --enable-rrtype-rkey, --enable-rrtype-cds, --enable-rrtype-uri and
+ --enable-rrtype-ta
+ * bugfix #530: Don't sign and verify duplicate RRs (Thanks Jelte Jansen)
+ * bugfix #505: Manpage and usage output fixes (Thanks Tomas Hozza)
+ * Adjust ldns_sha1() so that the input data is not modified (Thanks
+ Marc Buijsman)
+ * Messages to stderr are now off by default and can be reenabled with
+ the --enable-stderr-msgs configure option.
+
1.6.16 2012-11-13
* Fix Makefile to build pyldns with BSD make
* Fix typo in exporting b32_* symbols to make pyldns load again
diff --git a/Makefile.in b/Makefile.in
index 908f4738..7a1c2414 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2,7 +2,7 @@
# See the file LICENSE for the license
SHELL = @SHELL@
VERSION = @PACKAGE_VERSION@
-version_info = @LIBTOOL_VERSION_INFO@
+version_info = @VERSION_INFO@
srcdir = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
@@ -13,8 +13,10 @@ datadir = @datadir@
libdir = @libdir@
includedir = @includedir@
doxygen = @doxygen@
-pywrapdir = ${srcdir}/contrib/python
-pyldnsxwrapdir = ${srcdir}/contrib/ldnsx
+pywrapdir = $(srcdir)/contrib/python
+pyldnsxwrapdir = $(srcdir)/contrib/ldnsx
+p5_dns_ldns_dir = $(srcdir)/contrib/DNS-LDNS
+PERL = @PERL@
swig = @swig@
swigpy_flags = -python @SWIGPY3@
python_site = @PYTHON_SITE_PKG@
@@ -57,17 +59,19 @@ LINTFLAGS += "-Dsigset_t=long"
LINTFLAGS += "-D__uint16_t=uint16_t" -D"__pure2=" -D"__wchar_t=wchar_t" -D"__packed=" -D"__aligned(x)="
# Ubuntu oneiric"
LINTFLAGS += -D"__BEGIN_DECLS=" -D"__ssize_t=ssize_t" -D"__intptr_t=intptr_t" -D"__nonnull(x)=" -D"__THROW=" -D"__wur=" -D"__off_t=unsigned" -D"__off64_t=unsigned" -D"__useconds_t=unsigned" -D"__uid_t=unsigned" -D"__gid_t=unsigned" -D"__attribute_deprecated__=" -D"__pid_t=unsigned" -D"__restrict=" -D"__END_DECLS=" -D"__BEGIN_NAMESPACE_STD=" -D"__END_NAMESPACE_STD=" -D"__BEGIN_NAMESPACE_C99=" -D"__END_NAMESPACE_C99=" -D"__socklen_t=unsigned" -D"sa_family_t=unsigned " -D"__mode_t=unsigned" -D"u_int16_t=uint16_t" -D"u_int32_t=uint32_t" -D"u_int8_t=uint8_t" -D"u_short=unsigned short" -D"__u16=uint16_t" -D"__u32=uint32_t" -D"__u64=uint64_t"
+# FreeBSD 9
+LINTFLAGS += -D"_RuneLocale=int"
DEPFLAG = @DEPFLAG@
INSTALL = $(srcdir)/install-sh
LIBLOBJS = $(LIBOBJS:.o=.lo)
-LDNS_LOBJS = buffer.lo dane.lo dname.lo dnssec.lo dnssec_sign.lo dnssec_verify.lo dnssec_zone.lo duration.lo error.lo higher.lo host2str.lo host2wire.lo keys.lo net.lo packet.lo parse.lo rbtree.lo rdata.lo resolver.lo rr.lo rr_functions.lo sha1.lo sha2.lo str2host.lo tsig.lo update.lo util.lo wire2host.lo zone.lo
+LDNS_LOBJS = buffer.lo dane.lo dname.lo dnssec.lo dnssec_sign.lo dnssec_verify.lo dnssec_zone.lo duration.lo error.lo higher.lo host2str.lo host2wire.lo keys.lo net.lo packet.lo parse.lo radix.lo rbtree.lo rdata.lo resolver.lo rr.lo rr_functions.lo sha1.lo sha2.lo str2host.lo tsig.lo update.lo util.lo wire2host.lo zone.lo
LDNS_LOBJS_EX = ^linktest\.c$$
LDNS_ALL_LOBJS = $(LDNS_LOBJS) $(LIBLOBJS)
LIB = libldns.la
-LDNS_HEADERS = buffer.h dane.h dname.h dnssec.h dnssec_sign.h dnssec_verify.h dnssec_zone.h duration.h error.h higher.h host2str.h host2wire.h keys.h ldns.h packet.h parse.h rbtree.h rdata.h resolver.h rr_functions.h rr.h sha1.h sha2.h str2host.h tsig.h update.h wire2host.h zone.h
+LDNS_HEADERS = buffer.h dane.h dname.h dnssec.h dnssec_sign.h dnssec_verify.h dnssec_zone.h duration.h error.h higher.h host2str.h host2wire.h keys.h ldns.h packet.h parse.h radix.h rbtree.h rdata.h resolver.h rr_functions.h rr.h sha1.h sha2.h str2host.h tsig.h update.h wire2host.h zone.h
LDNS_HEADERS_EX = ^config\.h|common\.h|util\.h|net\.h$$
LDNS_HEADERS_GEN= common.h util.h net.h
@@ -92,16 +96,14 @@ EX_SSL_LOBJS = examples/ldns-nsec3-hash.lo examples/ldns-revoke.lo examples/ldns
COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS)
COMP_LIB = $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS)
-LINK_LIB = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) \
- $(LIBS) -version-number $(version_info) -no-undefined
-LINK_EXE = $(LIBTOOL) --mode=link $(CC) $(CPPFLAGS) \
- $(LIBSSL_CPPFLAGS) $(CFLAGS) $(LDFLAGS)
+LINK_LIB = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) -version-number $(version_info) -no-undefined
+LINK_EXE = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LIBSSL_LDFLAGS)
.PHONY: clean realclean docclean manpages doc lint all lib pyldns test
.PHONY: install uninstall install-doc uninstall-doc uninstall-pyldns
.PHONY: install-h uninstall-h install-lib uninstall-lib install-pyldns
-all: setup-builddir lib linktest manpages @PYLDNS@ @DRILL@ @EXAMPLES@
+all: setup-builddir lib linktest manpages @P5_DNS_LDNS@ @PYLDNS@ @DRILL@ @EXAMPLES@
.SUFFIXES: .c .o .a .lo .h .i
@@ -205,7 +207,8 @@ clean-examples:
$(LIBTOOL) --mode clean rm -f $(EXAMPLE_LOBJS)
linktest: $(srcdir)/linktest.c libldns.la
- $(LIBTOOL) --mode=link $(CC) $(srcdir)/linktest.c $(CPPFLAGS) $(LIBSSL_CPPFLAGS) $(CFLAGS) -lldns $(LIBS) -o linktest
+ $(COMP_LIB) $(LIBSSL_CPPFLAGS) -c $(srcdir)/linktest.c -o linktest.lo
+ $(LINK_EXE) linktest.lo $(LIBS) $(LIBSSL_LIBS) -lldns -o linktest
lib: libldns.la
@@ -242,14 +245,34 @@ $(pywrapdir)/ldns_wrapper.c: $(PYLDNS_I_FILES) ldns/config.h
$(swig) $(swigpy_flags) -o $@ $(CPPFLAGS) $(PYTHON_CPPFLAGS) $(pywrapdir)/ldns.i
ldns_wrapper.lo: $(pywrapdir)/ldns_wrapper.c ldns/config.h
- $(COMP_LIB) -I./include/ldns $(PYTHON_CPPFLAGS) $(PYTHON_X_CFLAGS) -c $< -o $@
+ $(COMP_LIB) -I./include/ldns $(PYTHON_CPPFLAGS) $(PYTHON_X_CFLAGS) -c $(pywrapdir)/ldns_wrapper.c -o $@
_ldns.la: ldns_wrapper.lo libldns.la
$(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(PYTHON_CFLAGS) $(LDFLAGS) $(PYTHON_LDFLAGS) -module -version-number $(version_info) -no-undefined -o $@ ldns_wrapper.lo -rpath $(python_site) -L. -L.libs -lldns $(LIBS)
-install: install-h install-lib @INSTALL_CONFIG@ install-manpages $(pyldns_inst) $(pyldnsx_inst) @INSTALL_DRILL@ @INSTALL_EXAMPLES@
+$(p5_dns_ldns_dir)/Makefile: $(p5_dns_ldns_dir)/Makefile.PL
+ BUILDDIR=`pwd`; cd $(p5_dns_ldns_dir); $(PERL) Makefile.PL PREFIX="$(prefix)" LIBS="-L$$BUILDDIR/.libs -lldns" INC="-I$$BUILDDIR"
-uninstall: uninstall-manpages @UNINSTALL_CONFIG@ uninstall-h uninstall-lib $(pyldns_uninst) $(pyldnsx_uninst) @UNINSTALL_DRILL@ @UNINSTALL_EXAMPLES@
+$(p5_dns_ldns_dir)/blib/arch/auto/DNS/LDNS/LDNS.so: $(p5_dns_ldns_dir)/Makefile
+ cd $(p5_dns_ldns_dir); $(MAKE)
+
+p5-dns-ldns: $(p5_dns_ldns_dir)/blib/arch/auto/DNS/LDNS/LDNS.so
+
+install-p5-dns-ldns: $(p5_dns_ldns_dir)/Makefile
+ cd $(p5_dns_ldns_dir); $(MAKE) install
+
+uninstall-p5-dns-ldns: $(p5_dns_ldns_dir)/Makefile
+ cd $(p5_dns_ldns_dir); $(MAKE) uninstall
+
+clean-p5-dns-ldns: $(p5_dns_ldns_dir)/Makefile
+ cd $(p5_dns_ldns_dir); $(MAKE) clean
+
+test-p5-dns-ldns: $(p5_dns_ldns_dir)/Makefile
+ cd $(p5_dns_ldns_dir); $(MAKE) test
+
+install: install-h install-lib @INSTALL_CONFIG@ install-manpages $(pyldns_inst) $(pyldnsx_inst) @INSTALL_P5_DNS_LDNS@ @INSTALL_DRILL@ @INSTALL_EXAMPLES@
+
+uninstall: uninstall-manpages @UNINSTALL_CONFIG@ uninstall-h uninstall-lib $(pyldns_uninst) $(pyldnsx_uninst) @UNINSTALL_P5_DNS_LDNS@ @UNINSTALL_DRILL@ @UNINSTALL_EXAMPLES@
destclean: uninstall
@@ -331,7 +354,7 @@ clean-lib:
$(LIBTOOL) --mode clean rm -f $(pywrapdir)/ldns_wrapper.c
$(LIBTOOL) --mode clean rm -f $(pywrapdir)/ldns.py
-clean: @CLEAN_DRILL@ @CLEAN_EXAMPLES@ clean-manpages clean-lib putdown-builddir
+clean: @CLEAN_DRILL@ @CLEAN_EXAMPLES@ @CLEAN_P5_DNS_LDNS@ clean-manpages clean-lib putdown-builddir
realclean: clean docclean
rm -f config.status
@@ -396,7 +419,7 @@ allclean: test-clean clean
test-clean:
tpkg -b test clean
-test:
+test: @TEST_P5_DNS_LDNS@
if test -x "`which bash`"; then bash test/test_all.sh; else sh test/test_all.sh; fi
@@ -481,56 +504,56 @@ buffer.lo buffer.o: $(srcdir)/buffer.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
dane.lo dane.o: $(srcdir)/dane.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
dname.lo dname.o: $(srcdir)/dname.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
dnssec.lo dnssec.o: $(srcdir)/dnssec.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
dnssec_sign.lo dnssec_sign.o: $(srcdir)/dnssec_sign.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
dnssec_verify.lo dnssec_verify.o: $(srcdir)/dnssec_verify.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
dnssec_zone.lo dnssec_zone.o: $(srcdir)/dnssec_zone.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
duration.lo duration.o: $(srcdir)/duration.c ldns/config.h $(srcdir)/ldns/duration.h
error.lo error.o: $(srcdir)/error.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
@@ -538,72 +561,74 @@ error.lo error.o: $(srcdir)/error.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/uti
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
higher.lo higher.o: $(srcdir)/higher.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
host2str.lo host2str.o: $(srcdir)/host2str.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
host2wire.lo host2wire.o: $(srcdir)/host2wire.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
keys.lo keys.o: $(srcdir)/keys.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
linktest.lo linktest.o: $(srcdir)/linktest.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
net.lo net.o: $(srcdir)/net.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
packet.lo packet.o: $(srcdir)/packet.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
parse.lo parse.o: $(srcdir)/parse.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+radix.lo radix.o: $(srcdir)/radix.c ldns/config.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/error.h ldns/util.h \
+ ldns/common.h
rbtree.lo rbtree.o: $(srcdir)/rbtree.c ldns/config.h $(srcdir)/ldns/rbtree.h ldns/util.h ldns/common.h
rdata.lo rdata.o: $(srcdir)/rdata.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
@@ -611,40 +636,40 @@ rdata.lo rdata.o: $(srcdir)/rdata.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/uti
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
resolver.lo resolver.o: $(srcdir)/resolver.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
rr.lo rr.o: $(srcdir)/rr.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
rr_functions.lo rr_functions.o: $(srcdir)/rr_functions.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
sha1.lo sha1.o: $(srcdir)/sha1.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
sha2.lo sha2.o: $(srcdir)/sha2.c ldns/config.h $(srcdir)/ldns/sha2.h
str2host.lo str2host.o: $(srcdir)/str2host.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
@@ -652,24 +677,24 @@ str2host.lo str2host.o: $(srcdir)/str2host.c ldns/config.h $(srcdir)/ldns/ldns.h
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
tsig.lo tsig.o: $(srcdir)/tsig.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
update.lo update.o: $(srcdir)/update.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
util.lo util.o: $(srcdir)/util.c ldns/config.h $(srcdir)/ldns/rdata.h ldns/common.h $(srcdir)/ldns/error.h \
ldns/util.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/buffer.h
wire2host.lo wire2host.o: $(srcdir)/wire2host.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
@@ -678,18 +703,16 @@ wire2host.lo wire2host.o: $(srcdir)/wire2host.c ldns/config.h $(srcdir)/ldns/ldn
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
zone.lo zone.o: $(srcdir)/zone.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
-compat/b32_ntop.lo compat/b32_ntop.o: $(srcdir)/compat/b32_ntop.c ldns/config.h
-compat/b32_pton.lo compat/b32_pton.o: $(srcdir)/compat/b32_pton.c ldns/config.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
compat/b64_ntop.lo compat/b64_ntop.o: $(srcdir)/compat/b64_ntop.c ldns/config.h
compat/b64_pton.lo compat/b64_pton.o: $(srcdir)/compat/b64_pton.c ldns/config.h
compat/calloc.lo compat/calloc.o: $(srcdir)/compat/calloc.c ldns/config.h
@@ -715,8 +738,8 @@ examples/ldns-chaos.lo examples/ldns-chaos.o: $(srcdir)/examples/ldns-chaos.c ld
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-compare-zones.lo examples/ldns-compare-zones.o: $(srcdir)/examples/ldns-compare-zones.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -724,31 +747,31 @@ examples/ldns-compare-zones.lo examples/ldns-compare-zones.o: $(srcdir)/examples
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-dane.lo examples/ldns-dane.o: $(srcdir)/examples/ldns-dane.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldnsd.lo examples/ldnsd.o: $(srcdir)/examples/ldnsd.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h \
$(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h \
$(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h $(srcdir)/ldns/zone.h \
$(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-dpa.lo examples/ldns-dpa.o: $(srcdir)/examples/ldns-dpa.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h $(srcdir)/examples/ldns-dpa.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h $(srcdir)/examples/ldns-dpa.h
examples/ldns-gen-zone.lo examples/ldns-gen-zone.o: $(srcdir)/examples/ldns-gen-zone.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -756,15 +779,15 @@ examples/ldns-gen-zone.lo examples/ldns-gen-zone.o: $(srcdir)/examples/ldns-gen-
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-key2ds.lo examples/ldns-key2ds.o: $(srcdir)/examples/ldns-key2ds.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-keyfetcher.lo examples/ldns-keyfetcher.o: $(srcdir)/examples/ldns-keyfetcher.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -772,31 +795,31 @@ examples/ldns-keyfetcher.lo examples/ldns-keyfetcher.o: $(srcdir)/examples/ldns-
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-keygen.lo examples/ldns-keygen.o: $(srcdir)/examples/ldns-keygen.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-mx.lo examples/ldns-mx.o: $(srcdir)/examples/ldns-mx.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-notify.lo examples/ldns-notify.o: $(srcdir)/examples/ldns-notify.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-nsec3-hash.lo examples/ldns-nsec3-hash.o: $(srcdir)/examples/ldns-nsec3-hash.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -804,7 +827,7 @@ examples/ldns-nsec3-hash.lo examples/ldns-nsec3-hash.o: $(srcdir)/examples/ldns-
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-read-zone.lo examples/ldns-read-zone.o: $(srcdir)/examples/ldns-read-zone.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -812,7 +835,7 @@ examples/ldns-read-zone.lo examples/ldns-read-zone.o: $(srcdir)/examples/ldns-re
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-resolver.lo examples/ldns-resolver.o: $(srcdir)/examples/ldns-resolver.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -820,23 +843,23 @@ examples/ldns-resolver.lo examples/ldns-resolver.o: $(srcdir)/examples/ldns-reso
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-revoke.lo examples/ldns-revoke.o: $(srcdir)/examples/ldns-revoke.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-rrsig.lo examples/ldns-rrsig.o: $(srcdir)/examples/ldns-rrsig.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-signzone.lo examples/ldns-signzone.o: $(srcdir)/examples/ldns-signzone.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -844,7 +867,7 @@ examples/ldns-signzone.lo examples/ldns-signzone.o: $(srcdir)/examples/ldns-sign
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-test-edns.lo examples/ldns-test-edns.o: $(srcdir)/examples/ldns-test-edns.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -852,15 +875,15 @@ examples/ldns-test-edns.lo examples/ldns-test-edns.o: $(srcdir)/examples/ldns-te
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-testns.lo examples/ldns-testns.o: $(srcdir)/examples/ldns-testns.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h $(srcdir)/examples/ldns-testpkts.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h $(srcdir)/examples/ldns-testpkts.h
examples/ldns-testpkts.lo examples/ldns-testpkts.o: $(srcdir)/examples/ldns-testpkts.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -868,15 +891,16 @@ examples/ldns-testpkts.lo examples/ldns-testpkts.o: $(srcdir)/examples/ldns-test
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h $(srcdir)/examples/ldns-testpkts.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h \
+ $(srcdir)/examples/ldns-testpkts.h
examples/ldns-update.lo examples/ldns-update.o: $(srcdir)/examples/ldns-update.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-verify-zone.lo examples/ldns-verify-zone.o: $(srcdir)/examples/ldns-verify-zone.c ldns/config.h $(srcdir)/ldns/ldns.h \
ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h \
$(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h \
@@ -884,39 +908,39 @@ examples/ldns-verify-zone.lo examples/ldns-verify-zone.o: $(srcdir)/examples/ldn
$(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h \
$(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h \
$(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h \
- $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-version.lo examples/ldns-version.o: $(srcdir)/examples/ldns-version.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-walk.lo examples/ldns-walk.o: $(srcdir)/examples/ldns-walk.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-zcat.lo examples/ldns-zcat.o: $(srcdir)/examples/ldns-zcat.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-zsplit.lo examples/ldns-zsplit.o: $(srcdir)/examples/ldns-zsplit.c ldns/config.h $(srcdir)/ldns/ldns.h ldns/util.h \
ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h \
$(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h $(srcdir)/ldns/packet.h $(srcdir)/ldns/keys.h \
$(srcdir)/ldns/zone.h $(srcdir)/ldns/resolver.h $(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h \
$(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h \
$(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
drill/chasetrace.lo drill/chasetrace.o: $(srcdir)/drill/chasetrace.c $(srcdir)/drill/drill.h ldns/config.h \
$(srcdir)/drill/drill_util.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h \
$(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h \
@@ -924,8 +948,8 @@ drill/chasetrace.lo drill/chasetrace.o: $(srcdir)/drill/chasetrace.c $(srcdir)/d
$(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h \
$(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h \
$(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
drill/dnssec.lo drill/dnssec.o: $(srcdir)/drill/dnssec.c $(srcdir)/drill/drill.h ldns/config.h $(srcdir)/drill/drill_util.h \
$(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h \
$(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h \
@@ -933,7 +957,7 @@ drill/dnssec.lo drill/dnssec.o: $(srcdir)/drill/dnssec.c $(srcdir)/drill/drill.h
$(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h \
$(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h \
ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h \
- $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
drill/drill.lo drill/drill.o: $(srcdir)/drill/drill.c $(srcdir)/drill/drill.h ldns/config.h $(srcdir)/drill/drill_util.h \
$(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h \
$(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h \
@@ -941,7 +965,7 @@ drill/drill.lo drill/drill.o: $(srcdir)/drill/drill.c $(srcdir)/drill/drill.h ld
$(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h \
$(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h \
ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h \
- $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
drill/drill_util.lo drill/drill_util.o: $(srcdir)/drill/drill_util.c $(srcdir)/drill/drill.h ldns/config.h \
$(srcdir)/drill/drill_util.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h \
$(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h \
@@ -949,8 +973,8 @@ drill/drill_util.lo drill/drill_util.o: $(srcdir)/drill/drill_util.c $(srcdir)/d
$(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h \
$(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h \
$(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
drill/error.lo drill/error.o: $(srcdir)/drill/error.c $(srcdir)/drill/drill.h ldns/config.h $(srcdir)/drill/drill_util.h \
$(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h \
$(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h \
@@ -958,7 +982,7 @@ drill/error.lo drill/error.o: $(srcdir)/drill/error.c $(srcdir)/drill/drill.h ld
$(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h \
$(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h \
ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h \
- $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
drill/root.lo drill/root.o: $(srcdir)/drill/root.c $(srcdir)/drill/drill.h ldns/config.h $(srcdir)/drill/drill_util.h \
$(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h \
$(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h \
@@ -966,7 +990,7 @@ drill/root.lo drill/root.o: $(srcdir)/drill/root.c $(srcdir)/drill/drill.h ldns/
$(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h \
$(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h \
ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h \
- $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
drill/securetrace.lo drill/securetrace.o: $(srcdir)/drill/securetrace.c $(srcdir)/drill/drill.h ldns/config.h \
$(srcdir)/drill/drill_util.h $(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h \
$(srcdir)/ldns/error.h $(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h \
@@ -974,8 +998,8 @@ drill/securetrace.lo drill/securetrace.o: $(srcdir)/drill/securetrace.c $(srcdir
$(srcdir)/ldns/tsig.h $(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h \
$(srcdir)/ldns/dnssec_verify.h $(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h \
$(srcdir)/ldns/host2wire.h ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h \
- $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h \
- $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/wire2host.h $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h \
+ $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
drill/work.lo drill/work.o: $(srcdir)/drill/work.c $(srcdir)/drill/drill.h ldns/config.h $(srcdir)/drill/drill_util.h \
$(srcdir)/ldns/ldns.h ldns/util.h ldns/common.h $(srcdir)/ldns/buffer.h $(srcdir)/ldns/error.h \
$(srcdir)/ldns/dane.h $(srcdir)/ldns/rdata.h $(srcdir)/ldns/rr.h $(srcdir)/ldns/dname.h $(srcdir)/ldns/dnssec.h \
@@ -983,7 +1007,7 @@ drill/work.lo drill/work.o: $(srcdir)/drill/work.c $(srcdir)/drill/drill.h ldns/
$(srcdir)/ldns/dnssec_zone.h $(srcdir)/ldns/rbtree.h $(srcdir)/ldns/host2str.h $(srcdir)/ldns/dnssec_verify.h \
$(srcdir)/ldns/dnssec_sign.h $(srcdir)/ldns/duration.h $(srcdir)/ldns/higher.h $(srcdir)/ldns/host2wire.h \
ldns/net.h $(srcdir)/ldns/str2host.h $(srcdir)/ldns/update.h $(srcdir)/ldns/wire2host.h \
- $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
+ $(srcdir)/ldns/rr_functions.h $(srcdir)/ldns/parse.h $(srcdir)/ldns/radix.h $(srcdir)/ldns/sha1.h $(srcdir)/ldns/sha2.h
examples/ldns-chaos: examples/ldns-chaos.lo examples/ldns-chaos.o $(LIB)
examples/ldns-compare-zones: examples/ldns-compare-zones.lo examples/ldns-compare-zones.o $(LIB)
examples/ldnsd: examples/ldnsd.lo examples/ldnsd.o $(LIB)
diff --git a/README b/README
index 70eb3dc0..6319c6f5 100644
--- a/README
+++ b/README
@@ -22,6 +22,8 @@ compile on other systems like Solaris and Mac OS X.
REQUIREMENTS
- OpenSSL (Optional, but needed for features like DNSSEC)
+ - OpenSSL >= 0.9.7f for DANE support
+ - OpenSSL >= 1.0.0 for ECDSA and GOST support
- libpcap (Optional, but needed for examples/ldns-dpa)
- (GNU) libtool (in OSX, that's glibtool, not libtool)
- GNU make
@@ -29,39 +31,17 @@ REQUIREMENTS
INSTALLATION
1. Unpack the tarball
2. cd ldns-<VERSION>
-3. ./configure
-4. gmake (it needs gnu make to compile, on systems where GNU make is the
- default you can just use 'make')
-5. sudo gmake install
-6. Optional. (cd examples; ./configure; gmake), make example programs included.
-7. Optional. (cd drill; ./configure; gmake; gmake install), to build drill.
+3. ./configure --with-examples --with-drill
+ (optionally compile python bindings too with: --with-pyldns)
+4. make
+5. make install
-You can configure and compile it in a separate build directory.
-* Examples
-There are some examples and dns related tools in the examples/ directory.
-These can be built with:
-1. cd examples/
-2. ./configure [--with-ldns=<path to ldns installation or build>]
-3. gmake
-
-* Drill
-Drill can be built with:
-1. cd drill/
-2. ./configure [--with-ldns=<path to ldns installation or build>]
-3. gmake
-
-Note that you need to set LD_LIBRARY_PATH if you want to run the binaries
-and you have not installed the library to a system directory. You can use
-the make target all-static for the examples to run them if you don't want to
-install the library.
-
-
-* Building from subversion repository
+* Building from repository
If you are building from the repository you will need to have (gnu)
autotools like libtool and autoreconf installed. A list of all the commands
-needed to build everything can be found in README.svn. Note that the actual
+needed to build everything can be found in README.git. Note that the actual
commands may be a little bit different on your machine. Most notable, you'll need to run libtoolize (or glibtoolize), if you skip this step, you'll get an error about missing config.sub.
* Developers
@@ -84,6 +64,10 @@ We have received patches from the following people, thanks!
o Paul Wouters
o Simon Vallet
o Ondřej Surý
+ o Karel Slany
+ o Havard Eidnes
+ o Leo Baltus
+ o Dag-Erling Smørgrav
INFORMATION FOR SPECIFIC OPERATING SYSTEMS
diff --git a/README.svn b/README.git
index 10f7cb41..34c9ae54 100644
--- a/README.svn
+++ b/README.git
@@ -1,6 +1,5 @@
-
-# The ldns subversion repository can found at:
-# www.nlnetlabs.nl/ldns/svn/
+# The ldns git repository can found at:
+# git.nlnetlabs.nl/ldns/
# small list of commands to build all on a linux system
# libtoolize is needed for most other targets
@@ -10,17 +9,14 @@
# the correct versions may need to be set. On those
# systems, the 'autoreconf' line should be changed to:
# AUTOMAKE=automake-1.10 ACLOCAL=aclocal-1.10 autoreconf
-# (and these systems probably need gmake instead of make)
# older versions of libtoolize do not support --install
# so you might need to remove that (with newer versions
# it is needed)
libtoolize -c --install
autoreconf --install
-./configure
+./configure --with-examples --with-drill # --with-pyldns --with-p5-dns-ldns
make
make doc # needs doxygen for the html pages
-(cd examples && autoreconf && ./configure && make)
-(cd drill && autoreconf && ./configure && make)
(cd pcat && autoreconf && ./configure && make)
(cd examples/nsd-test && autoreconf && ./configure && make)
diff --git a/acx_nlnetlabs.m4 b/acx_nlnetlabs.m4
index e90c81ea..a4047332 100644
--- a/acx_nlnetlabs.m4
+++ b/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.
@@ -17,7 +22,7 @@
# 2010-07-02 Add check for ss_family (for minix).
# 2010-04-26 Fix to use CPPFLAGS for CHECK_COMPILER_FLAGS.
# 2010-03-01 Fix RPATH using CONFIG_COMMANDS to run at the very end.
-# 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS seperate, -ldl
+# 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS separate, -ldl
# 2010-02-01 added ACX_CHECK_MEMCMP_SIGNED, AHX_MEMCMP_BROKEN
# 2010-01-20 added AHX_COONFIG_STRLCAT
# 2009-07-14 U_CHAR detection improved for windows crosscompile.
@@ -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/ax_python_devel.m4 b/ax_python_devel.m4
index 2ce6afe8..87e7c8c2 100644
--- a/ax_python_devel.m4
+++ b/ax_python_devel.m4
@@ -34,11 +34,12 @@
# LICENSE
#
# Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de>
-# Copyright (c) 2009 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
+# Copyright (c) 2009 Alan W. Irwin
# Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net>
-# Copyright (c) 2009 Andrew Collier <colliera@ukzn.ac.za>
+# Copyright (c) 2009 Andrew Collier
# Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org>
# Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org>
+# Copyright (c) 2013 Daniel Mullner <muellner@math.stanford.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
@@ -66,7 +67,7 @@
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 8
+#serial 16
AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
AC_DEFUN([AX_PYTHON_DEVEL],[
@@ -153,8 +154,14 @@ $ac_distutils_result])
if test -z "$PYTHON_CPPFLAGS"; then
python_path=`$PYTHON -c "import distutils.sysconfig; \
print (distutils.sysconfig.get_python_inc ());"`
+ plat_python_path=`$PYTHON -c "import distutils.sysconfig; \
+ print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
if test -n "${python_path}"; then
- python_path="-I$python_path"
+ if test "${plat_python_path}" != "${python_path}"; then
+ python_path="-I$python_path -I$plat_python_path"
+ else
+ python_path="-I$python_path"
+ fi
fi
PYTHON_CPPFLAGS=$python_path
fi
@@ -173,13 +180,10 @@ $ac_distutils_result])
# join all versioning strings, on some systems
# major/minor numbers could be in different list elements
from distutils.sysconfig import *
-ret = ''
-for e in get_config_vars ('VERSION'):
- if (e != None):
- ret += e
-print (ret)
-EOD
-`
+e = get_config_var('VERSION')
+if e is not None:
+ print(e)
+EOD`
if test -z "$ac_python_version"; then
if test -n "$PYTHON_VERSION"; then
@@ -199,34 +203,27 @@ EOD
# There should be only one
import distutils.sysconfig
-for e in distutils.sysconfig.get_config_vars ('LIBDIR'):
- if e != None:
- print (e)
- break
-EOD
-`
-
- # Before checking for libpythonX.Y, we need to know
- # the extension the OS we're on uses for libraries
- # (we take the first one, if there's more than one fix me!):
- ac_python_soext=`$PYTHON -c \
- "import distutils.sysconfig; \
- print (distutils.sysconfig.get_config_vars('SO')[[0]])"`
+e = distutils.sysconfig.get_config_var('LIBDIR')
+if e is not None:
+ print (e)
+EOD`
# Now, for the library:
- ac_python_soname=`$PYTHON -c \
- "import distutils.sysconfig; \
- print (distutils.sysconfig.get_config_vars('LDLIBRARY')[[0]])"`
+ ac_python_library=`cat<<EOD | $PYTHON -
- # Strip away extension from the end to canonicalize its name:
- ac_python_library=`echo "$ac_python_soname" | sed "s/${ac_python_soext}$//"`
+import distutils.sysconfig
+c = distutils.sysconfig.get_config_vars()
+if 'LDVERSION' in c:
+ print ('python'+c[['LDVERSION']])
+else:
+ print ('python'+c[['VERSION']])
+EOD`
# This small piece shamelessly adapted from PostgreSQL python macro;
# credits goes to momjian, I think. I'd like to put the right name
# in the credits, if someone can point me in the right direction... ?
#
- if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
- -a x"$ac_python_library" != x"$ac_python_soname"
+ if test -n "$ac_python_libdir" -a -n "$ac_python_library"
then
# use the official shared library
ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
@@ -268,7 +265,7 @@ EOD
if test -z "$PYTHON_EXTRA_LIBS"; then
PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
conf = distutils.sysconfig.get_config_var; \
- print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"`
+ print (conf('LIBS'))"`
fi
AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
AC_SUBST(PYTHON_EXTRA_LIBS)
diff --git a/compat/b32_ntop.c b/compat/b32_ntop.c
deleted file mode 100644
index 038ebdc9..00000000
--- a/compat/b32_ntop.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/*
- * Copyright (c) 1996, 1998 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * Portions Copyright (c) 1995 by International Business Machines, Inc.
- *
- * International Business Machines, Inc. (hereinafter called IBM) grants
- * permission under its copyrights to use, copy, modify, and distribute this
- * Software with or without fee, provided that the above copyright notice and
- * all paragraphs of this notice appear in all copies, and that the name of IBM
- * not be used in connection with the marketing of any product incorporating
- * the Software or modifications thereof, without specific, written prior
- * permission.
- *
- * To the extent it has a right to do so, IBM grants an immunity from suit
- * under its patents, if any, for the use, sale or manufacture of products to
- * the extent that such products are used for performing Domain Name System
- * dynamic updates in TCP/IP networks by means of the Software. No immunity is
- * granted for any product per se or for any other function of any product.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
- * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
- * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-#include <ldns/config.h>
-
-#include <sys/types.h>
-#include <sys/param.h>
-#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
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <assert.h>
-
-static const char Base32[] =
- "abcdefghijklmnopqrstuvwxyz234567";
-/* "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";*/
-/* 00000000001111111111222222222233
- 01234567890123456789012345678901*/
-static const char Base32_extended_hex[] =
-/* "0123456789ABCDEFGHIJKLMNOPQRSTUV";*/
- "0123456789abcdefghijklmnopqrstuv";
-static const char Pad32 = '=';
-
-/* (From RFC3548 and draft-josefsson-rfc3548bis-00.txt)
-5. Base 32 Encoding
-
- The Base 32 encoding is designed to represent arbitrary sequences of
- octets in a form that needs to be case insensitive but need not be
- humanly readable.
-
- A 33-character subset of US-ASCII is used, enabling 5 bits to be
- represented per printable character. (The extra 33rd character, "=",
- is used to signify a special processing function.)
-
- The encoding process represents 40-bit groups of input bits as output
- strings of 8 encoded characters. Proceeding from left to right, a
- 40-bit input group is formed by concatenating 5 8bit input groups.
- These 40 bits are then treated as 8 concatenated 5-bit groups, each
- of which is translated into a single digit in the base 32 alphabet.
- When encoding a bit stream via the base 32 encoding, the bit stream
- must be presumed to be ordered with the most-significant-bit first.
- That is, the first bit in the stream will be the high-order bit in
- the first 8bit byte, and the eighth bit will be the low-order bit in
- the first 8bit byte, and so on.
-
- Each 5-bit group is used as an index into an array of 32 printable
- characters. The character referenced by the index is placed in the
- output string. These characters, identified in Table 3, below, are
- selected from US-ASCII digits and uppercase letters.
-
- Table 3: The Base 32 Alphabet
-
- Value Encoding Value Encoding Value Encoding Value Encoding
- 0 A 9 J 18 S 27 3
- 1 B 10 K 19 T 28 4
- 2 C 11 L 20 U 29 5
- 3 D 12 M 21 V 30 6
- 4 E 13 N 22 W 31 7
- 5 F 14 O 23 X
- 6 G 15 P 24 Y (pad) =
- 7 H 16 Q 25 Z
- 8 I 17 R 26 2
-
-
- Special processing is performed if fewer than 40 bits are available
- at the end of the data being encoded. A full encoding quantum is
- always completed at the end of a body. When fewer than 40 input bits
- are available in an input group, zero bits are added (on the right)
- to form an integral number of 5-bit groups. Padding at the end of
- the data is performed using the "=" character. Since all base 32
- input is an integral number of octets, only the following cases can
- arise:
-
- (1) the final quantum of encoding input is an integral multiple of 40
- bits; here, the final unit of encoded output will be an integral
- multiple of 8 characters with no "=" padding,
-
- (2) the final quantum of encoding input is exactly 8 bits; here, the
- final unit of encoded output will be two characters followed by six
- "=" padding characters,
-
- (3) the final quantum of encoding input is exactly 16 bits; here, the
- final unit of encoded output will be four characters followed by four
- "=" padding characters,
-
- (4) the final quantum of encoding input is exactly 24 bits; here, the
- final unit of encoded output will be five characters followed by
- three "=" padding characters, or
-
- (5) the final quantum of encoding input is exactly 32 bits; here, the
- final unit of encoded output will be seven characters followed by one
- "=" padding character.
-
-
-6. Base 32 Encoding with Extended Hex Alphabet
-
- The following description of base 32 is due to [7]. This encoding
- should not be regarded as the same as the "base32" encoding, and
- should not be referred to as only "base32".
-
- One property with this alphabet, that the base64 and base32 alphabet
- lack, is that encoded data maintain its sort order when the encoded
- data is compared bit-wise.
-
- This encoding is identical to the previous one, except for the
- alphabet. The new alphabet is found in table 4.
-
- Table 4: The "Extended Hex" Base 32 Alphabet
-
- Value Encoding Value Encoding Value Encoding Value Encoding
- 0 0 9 9 18 I 27 R
- 1 1 10 A 19 J 28 S
- 2 2 11 B 20 K 29 T
- 3 3 12 C 21 L 30 U
- 4 4 13 D 22 M 31 V
- 5 5 14 E 23 N
- 6 6 15 F 24 O (pad) =
- 7 7 16 G 25 P
- 8 8 17 H 26 Q
-
-*/
-
-
-int
-ldns_b32_ntop_ar(uint8_t const *src, size_t srclength, char *target, size_t targsize, const char B32_ar[]) {
- size_t datalength = 0;
- uint8_t input[5];
- uint8_t output[8];
- size_t i;
- memset(output, 0, 8);
-
- while (4 < srclength) {
- input[0] = *src++;
- input[1] = *src++;
- input[2] = *src++;
- input[3] = *src++;
- input[4] = *src++;
- srclength -= 5;
-
- output[0] = (input[0] & 0xf8) >> 3;
- output[1] = ((input[0] & 0x07) << 2) + ((input[1] & 0xc0) >> 6);
- output[2] = (input[1] & 0x3e) >> 1;
- output[3] = ((input[1] & 0x01) << 4) + ((input[2] & 0xf0) >> 4);
- output[4] = ((input[2] & 0x0f) << 1) + ((input[3] & 0x80) >> 7);
- output[5] = (input[3] & 0x7c) >> 2;
- output[6] = ((input[3] & 0x03) << 3) + ((input[4] & 0xe0) >> 5);
- output[7] = (input[4] & 0x1f);
-
- assert(output[0] < 32);
- assert(output[1] < 32);
- assert(output[2] < 32);
- assert(output[3] < 32);
- assert(output[4] < 32);
- assert(output[5] < 32);
- assert(output[6] < 32);
- assert(output[7] < 32);
-
- if (datalength + 8 > targsize) {
- return (-1);
- }
- target[datalength++] = B32_ar[output[0]];
- target[datalength++] = B32_ar[output[1]];
- target[datalength++] = B32_ar[output[2]];
- target[datalength++] = B32_ar[output[3]];
- target[datalength++] = B32_ar[output[4]];
- target[datalength++] = B32_ar[output[5]];
- target[datalength++] = B32_ar[output[6]];
- target[datalength++] = B32_ar[output[7]];
- }
-
- /* Now we worry about padding. */
- if (0 != srclength) {
- /* Get what's left. */
- input[0] = input[1] = input[2] = input[3] = input[4] = (uint8_t) '\0';
- for (i = 0; i < srclength; i++)
- input[i] = *src++;
-
- output[0] = (input[0] & 0xf8) >> 3;
- assert(output[0] < 32);
- if (srclength >= 1) {
- output[1] = ((input[0] & 0x07) << 2) + ((input[1] & 0xc0) >> 6);
- assert(output[1] < 32);
- output[2] = (input[1] & 0x3e) >> 1;
- assert(output[2] < 32);
- }
- if (srclength >= 2) {
- output[3] = ((input[1] & 0x01) << 4) + ((input[2] & 0xf0) >> 4);
- assert(output[3] < 32);
- }
- if (srclength >= 3) {
- output[4] = ((input[2] & 0x0f) << 1) + ((input[3] & 0x80) >> 7);
- assert(output[4] < 32);
- output[5] = (input[3] & 0x7c) >> 2;
- assert(output[5] < 32);
- }
- if (srclength >= 4) {
- output[6] = ((input[3] & 0x03) << 3) + ((input[4] & 0xe0) >> 5);
- assert(output[6] < 32);
- }
-
-
- if (datalength + 1 > targsize) {
- return (-2);
- }
- target[datalength++] = B32_ar[output[0]];
- if (srclength >= 1) {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = B32_ar[output[1]];
- if (srclength == 1 && output[2] == 0) {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- } else {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = B32_ar[output[2]];
- }
- } else {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- }
- if (srclength >= 2) {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = B32_ar[output[3]];
- } else {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- }
- if (srclength >= 3) {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = B32_ar[output[4]];
- if (srclength == 3 && output[5] == 0) {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- } else {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = B32_ar[output[5]];
- }
- } else {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- }
- if (srclength >= 4) {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = B32_ar[output[6]];
- } else {
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- }
- if (datalength + 1 > targsize) { return (-2); }
- target[datalength++] = Pad32;
- }
- if (datalength+1 > targsize) {
- return (int) (datalength);
- }
- target[datalength] = '\0'; /* Returned value doesn't count \0. */
- return (int) (datalength);
-}
-
-int
-ldns_b32_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
- return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32);
-}
-
-/* deprecated, here for backwards compatibility */
-int
-b32_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
- return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32);
-}
-
-int
-ldns_b32_ntop_extended_hex(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
- return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32_extended_hex);
-}
-
-/* deprecated, here for backwards compatibility */
-int
-b32_ntop_extended_hex(uint8_t const *src, size_t srclength, char *target, size_t targsize) {
- return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32_extended_hex);
-}
-
diff --git a/compat/b32_pton.c b/compat/b32_pton.c
deleted file mode 100644
index 9c261e61..00000000
--- a/compat/b32_pton.c
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (c) 1996, 1998 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-/*
- * Portions Copyright (c) 1995 by International Business Machines, Inc.
- *
- * International Business Machines, Inc. (hereinafter called IBM) grants
- * permission under its copyrights to use, copy, modify, and distribute this
- * Software with or without fee, provided that the above copyright notice and
- * all paragraphs of this notice appear in all copies, and that the name of IBM
- * not be used in connection with the marketing of any product incorporating
- * the Software or modifications thereof, without specific, written prior
- * permission.
- *
- * To the extent it has a right to do so, IBM grants an immunity from suit
- * under its patents, if any, for the use, sale or manufacture of products to
- * the extent that such products are used for performing Domain Name System
- * dynamic updates in TCP/IP networks by means of the Software. No immunity is
- * granted for any product per se or for any other function of any product.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
- * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
- * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
- */
-#include <ldns/config.h>
-
-#include <sys/types.h>
-#include <sys/param.h>
-#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
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";*/
-static const char Base32[] =
- "abcdefghijklmnopqrstuvwxyz234567";
-/* "0123456789ABCDEFGHIJKLMNOPQRSTUV";*/
-static const char Base32_extended_hex[] =
- "0123456789abcdefghijklmnopqrstuv";
-static const char Pad32 = '=';
-
-/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt)
-5. Base 32 Encoding
-
- The Base 32 encoding is designed to represent arbitrary sequences of
- octets in a form that needs to be case insensitive but need not be
- humanly readable.
-
- A 33-character subset of US-ASCII is used, enabling 5 bits to be
- represented per printable character. (The extra 33rd character, "=",
- is used to signify a special processing function.)
-
- The encoding process represents 40-bit groups of input bits as output
- strings of 8 encoded characters. Proceeding from left to right, a
- 40-bit input group is formed by concatenating 5 8bit input groups.
- These 40 bits are then treated as 8 concatenated 5-bit groups, each
- of which is translated into a single digit in the base 32 alphabet.
- When encoding a bit stream via the base 32 encoding, the bit stream
- must be presumed to be ordered with the most-significant-bit first.
- That is, the first bit in the stream will be the high-order bit in
- the first 8bit byte, and the eighth bit will be the low-order bit in
- the first 8bit byte, and so on.
-
- Each 5-bit group is used as an index into an array of 32 printable
- characters. The character referenced by the index is placed in the
- output string. These characters, identified in Table 3, below, are
- selected from US-ASCII digits and uppercase letters.
-
- Table 3: The Base 32 Alphabet
-
- Value Encoding Value Encoding Value Encoding Value Encoding
- 0 A 9 J 18 S 27 3
- 1 B 10 K 19 T 28 4
- 2 C 11 L 20 U 29 5
- 3 D 12 M 21 V 30 6
- 4 E 13 N 22 W 31 7
- 5 F 14 O 23 X
- 6 G 15 P 24 Y (pad) =
- 7 H 16 Q 25 Z
- 8 I 17 R 26 2
-
-
- Special processing is performed if fewer than 40 bits are available
- at the end of the data being encoded. A full encoding quantum is
- always completed at the end of a body. When fewer than 40 input bits
- are available in an input group, zero bits are added (on the right)
- to form an integral number of 5-bit groups. Padding at the end of
- the data is performed using the "=" character. Since all base 32
- input is an integral number of octets, only the following cases can
- arise:
-
- (1) the final quantum of encoding input is an integral multiple of 40
- bits; here, the final unit of encoded output will be an integral
- multiple of 8 characters with no "=" padding,
-
- (2) the final quantum of encoding input is exactly 8 bits; here, the
- final unit of encoded output will be two characters followed by six
- "=" padding characters,
-
- (3) the final quantum of encoding input is exactly 16 bits; here, the
- final unit of encoded output will be four characters followed by four
- "=" padding characters,
-
- (4) the final quantum of encoding input is exactly 24 bits; here, the
- final unit of encoded output will be five characters followed by
- three "=" padding characters, or
-
- (5) the final quantum of encoding input is exactly 32 bits; here, the
- final unit of encoded output will be seven characters followed by one
- "=" padding character.
-
-
-6. Base 32 Encoding with Extended Hex Alphabet
-
- The following description of base 32 is due to [7]. This encoding
- should not be regarded as the same as the "base32" encoding, and
- should not be referred to as only "base32".
-
- One property with this alphabet, that the base32 and base32 alphabet
- lack, is that encoded data maintain its sort order when the encoded
- data is compared bit-wise.
-
- This encoding is identical to the previous one, except for the
- alphabet. The new alphabet is found in table 4.
-
- Table 4: The "Extended Hex" Base 32 Alphabet
-
- Value Encoding Value Encoding Value Encoding Value Encoding
- 0 0 9 9 18 I 27 R
- 1 1 10 A 19 J 28 S
- 2 2 11 B 20 K 29 T
- 3 3 12 C 21 L 30 U
- 4 4 13 D 22 M 31 V
- 5 5 14 E 23 N
- 6 6 15 F 24 O (pad) =
- 7 7 16 G 25 P
- 8 8 17 H 26 Q
-
-
-
-
-*/
-/* skips all whitespace anywhere.
- converts characters, four at a time, starting at (or after)
- src from base - 32 numbers into three 8 bit bytes in the target area.
- it returns the number of data bytes stored at the target, or -1 on error.
- */
-
-int
-ldns_b32_pton_ar(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize, const char B32_ar[])
-{
- int tarindex, state, ch;
- char *pos;
- int i = 0;
-
- state = 0;
- tarindex = 0;
-
- while ((ch = *src++) != '\0' && (i == 0 || i < (int) hashed_owner_str_len)) {
- i++;
- ch = tolower(ch);
- if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */
- continue;
-
- if (ch == Pad32)
- break;
-
- pos = strchr(B32_ar, ch);
- if (pos == 0) {
- /* A non-base32 character. */
- return (-ch);
- }
-
- switch (state) {
- case 0:
- if (target) {
- if ((size_t)tarindex >= targsize) {
- return (-2);
- }
- target[tarindex] = (pos - B32_ar) << 3;
- }
- state = 1;
- break;
- case 1:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize) {
- return (-3);
- }
- target[tarindex] |= (pos - B32_ar) >> 2;
- target[tarindex+1] = ((pos - B32_ar) & 0x03)
- << 6 ;
- }
- tarindex++;
- state = 2;
- break;
- case 2:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize) {
- return (-4);
- }
- target[tarindex] |= (pos - B32_ar) << 1;
- }
- /*tarindex++;*/
- state = 3;
- break;
- case 3:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize) {
- return (-5);
- }
- target[tarindex] |= (pos - B32_ar) >> 4;
- target[tarindex+1] = ((pos - B32_ar) & 0x0f) << 4 ;
- }
- tarindex++;
- state = 4;
- break;
- case 4:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize) {
- return (-6);
- }
- target[tarindex] |= (pos - B32_ar) >> 1;
- target[tarindex+1] = ((pos - B32_ar) & 0x01)
- << 7 ;
- }
- tarindex++;
- state = 5;
- break;
- case 5:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize) {
- return (-7);
- }
- target[tarindex] |= (pos - B32_ar) << 2;
- }
- state = 6;
- break;
- case 6:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize) {
- return (-8);
- }
- target[tarindex] |= (pos - B32_ar) >> 3;
- target[tarindex+1] = ((pos - B32_ar) & 0x07)
- << 5 ;
- }
- tarindex++;
- state = 7;
- break;
- case 7:
- if (target) {
- if ((size_t)tarindex + 1 >= targsize) {
- return (-9);
- }
- target[tarindex] |= (pos - B32_ar);
- }
- tarindex++;
- state = 0;
- break;
- default:
- abort();
- }
- }
-
- /*
- * We are done decoding Base-32 chars. Let's see if we ended
- * on a byte boundary, and/or with erroneous trailing characters.
- */
-
- if (ch == Pad32) { /* We got a pad char. */
- ch = *src++; /* Skip it, get next. */
- switch (state) {
- case 0: /* Invalid = in first position */
- case 1: /* Invalid = in second position */
- return (-10);
-
- case 2: /* Valid, means one byte of info */
- case 3:
- /* Skip any number of spaces. */
- for ((void)NULL; ch != '\0'; ch = *src++)
- if (!isspace((unsigned char)ch))
- break;
- /* Make sure there is another trailing = sign. */
- if (ch != Pad32) {
- return (-11);
- }
- ch = *src++; /* Skip the = */
- /* Fall through to "single trailing =" case. */
- /* FALLTHROUGH */
-
- case 4: /* Valid, means two bytes of info */
- case 5:
- case 6:
- /*
- * We know this char is an =. Is there anything but
- * whitespace after it?
- */
- for ((void)NULL; ch != '\0'; ch = *src++)
- if (!(isspace((unsigned char)ch) || ch == '=')) {
- return (-12);
- }
-
- case 7: /* Valid, means three bytes of info */
- /*
- * We know this char is an =. Is there anything but
- * whitespace after it?
- */
- for ((void)NULL; ch != '\0'; ch = *src++)
- if (!isspace((unsigned char)ch)) {
- return (-13);
- }
-
- /*
- * Now make sure for cases 2 and 3 that the "extra"
- * bits that slopped past the last full byte were
- * zeros. If we don't check them, they become a
- * subliminal channel.
- */
- if (target && target[tarindex] != 0) {
- return (-14);
- }
- }
- } else {
- /*
- * We ended by seeing the end of the string. Make sure we
- * have no partial bytes lying around.
- */
- if (state != 0)
- return (-15);
- }
-
- return (tarindex);
-}
-
-int
-ldns_b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
-{
- return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32);
-}
-
-/* deprecated, here for backwards compatibility */
-int
-b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
-{
- return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32);
-}
-
-int
-ldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
-{
- return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32_extended_hex);
-}
-
-/* deprecated, here for backwards compatibility */
-int
-b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize)
-{
- return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32_extended_hex);
-}
diff --git a/compat/b64_ntop.c b/compat/b64_ntop.c
index d0b52b51..6895acaf 100644
--- a/compat/b64_ntop.c
+++ b/compat/b64_ntop.c
@@ -40,27 +40,10 @@
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <ldns/config.h>
-
-#include <sys/types.h>
-#include <sys/param.h>
-#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
-
#include <ctype.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#define Assert(Cond) if (!(Cond)) abort()
-
static const char Base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Pad64 = '=';
@@ -154,10 +137,10 @@ ldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsiz
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
output[3] = input[2] & 0x3f;
- Assert(output[0] < 64);
- Assert(output[1] < 64);
- Assert(output[2] < 64);
- Assert(output[3] < 64);
+ assert(output[0] < 64);
+ assert(output[1] < 64);
+ assert(output[2] < 64);
+ assert(output[3] < 64);
if (datalength + 4 > targsize) {
return (-1);
@@ -178,9 +161,9 @@ ldns_b64_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsiz
output[0] = input[0] >> 2;
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
- Assert(output[0] < 64);
- Assert(output[1] < 64);
- Assert(output[2] < 64);
+ assert(output[0] < 64);
+ assert(output[1] < 64);
+ assert(output[2] < 64);
if (datalength + 4 > targsize) {
return (-2);
diff --git a/compat/b64_pton.c b/compat/b64_pton.c
index aa637d22..abe32819 100644
--- a/compat/b64_pton.c
+++ b/compat/b64_pton.c
@@ -40,27 +40,10 @@
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
#include <ldns/config.h>
-
-#include <sys/types.h>
-#include <sys/param.h>
-#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
-
#include <ctype.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#define Assert(Cond) if (!(Cond)) abort()
-
static const char Base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static const char Pad64 = '=';
diff --git a/compat/snprintf.c b/compat/snprintf.c
index b7445111..d869ba5e 100644
--- a/compat/snprintf.c
+++ b/compat/snprintf.c
@@ -1,770 +1,1036 @@
-#include <ldns/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 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.
+ */
+#include <ldns/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.
- *
- * The other functions are there to prevent NULL pointers from
- * causing nast effects.
+/**
+ * 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.
*
- * 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.
- *
- **************************************************************/
+ * %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;
+}
+
+/** 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;
+}
+
+/** 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;
+}
+
+/** print hex into buffer, returns length */
+static int
+print_hex(char* buf, int max, unsigned int 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 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);
+}
-int snprintf (char *str, size_t count, const char *fmt, ...);
-int vsnprintf (char *str, size_t count, const char *fmt, va_list arg);
+/** 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);
+}
-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);
-static void dopr_outch (char *buffer, size_t *currlen, size_t maxlen, char c );
+/** 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);
+}
-int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
+/** 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)
{
- str[0] = 0;
- dopr(str, count, fmt, args);
- return(strlen(str));
+ 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);
}
-/* VARARGS3 */
-#ifdef HAVE_STDARGS
-int snprintf (char *str,size_t count,const char *fmt,...)
+/** 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')
-#define MAX(p,q) ((p >= q) ? p : q)
-
-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((int) 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((int) 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);
- 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);
- 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 = (char *) "<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
+/** 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;
+}
- /* 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 double pow10 (double exp)
-{
- long double result = 1;
-
- while (exp)
- {
- result *= 10;
- exp--;
- }
-
- return result;
-}
-
-static double round (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 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
+/** 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);
+}
- intpart = ufvalue;
+/* 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;
+}
- /*
- * Sorry, we only support 9 digits past the decimal because of our
- * conversion method
- */
- if (max > 9)
- max = 9;
- /* We "cheat" by converting the fractional part to integer by
- * multiplying by a factor of 10
- */
- fracpart = round ((pow10 (max)) * (ufvalue - intpart));
+/** 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);
+}
- if (fracpart >= pow10 (max))
- {
- intpart++;
- fracpart -= pow10 (max);
- }
-#ifdef DEBUG_SNPRINTF
- dprint (1, (debugfile, "fmtfp: %f =? %d.%d\n", fvalue, intpart, fracpart));
-#endif
+/** 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;
+}
- /* 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);
- } while(fracpart && (fplace < 20));
- if (fplace == 20) fplace--;
- fconvert[fplace] = 0;
-
- /* -1 for decimal point, another -1 if we are printing a sign */
- padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
- zpadlen = max - 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]);
-
- /*
- * 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 %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);
+}
+
+/** 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/configure.ac b/configure.ac
index fae43271..5f25c7dc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,20 +6,23 @@ sinclude(acx_nlnetlabs.m4)
# must be numbers. ac_defun because of later processing.
m4_define([VERSION_MAJOR],[1])
m4_define([VERSION_MINOR],[6])
-m4_define([VERSION_MICRO],[16])
+m4_define([VERSION_MICRO],[17])
AC_INIT(ldns, m4_defn([VERSION_MAJOR]).m4_defn([VERSION_MINOR]).m4_defn([VERSION_MICRO]), libdns@nlnetlabs.nl, libdns)
AC_CONFIG_SRCDIR([packet.c])
# needed to build correct soname
-AC_SUBST(LIBTOOL_VERSION_INFO, VERSION_MAJOR:VERSION_MINOR:VERSION_MICRO)
AC_SUBST(LDNS_VERSION_MAJOR, [VERSION_MAJOR])
AC_SUBST(LDNS_VERSION_MINOR, [VERSION_MINOR])
AC_SUBST(LDNS_VERSION_MICRO, [VERSION_MICRO])
+AC_SUBST(VERSION_INFO, [VERSION_MAJOR:VERSION_MINOR:VERSION_MICRO])
+
+AC_AIX
+LT_INIT
+AC_CONFIG_MACRO_DIR([m4])
OURCPPFLAGS=''
CPPFLAGS=${CPPFLAGS:-${OURCPPFLAGS}}
CFLAGS="$CFLAGS"
-AC_AIX
# Checks for programs.
AC_PROG_CC
ACX_DEPFLAG
@@ -70,6 +73,7 @@ fi
ACX_CHECK_COMPILER_FLAG(Wall, [CFLAGS="-Wall $CFLAGS"])
ACX_CHECK_COMPILER_FLAG(W, [CFLAGS="-W $CFLAGS"])
ACX_CHECK_COMPILER_FLAG(Wwrite-strings, [CFLAGS="-Wwrite-strings $CFLAGS"])
+ACX_CHECK_COMPILER_FLAG(Wstrict-prototypes, [CFLAGS="-Wstrict-prototypes $CFLAGS"])
AC_CHECK_HEADERS([getopt.h time.h],,, [AC_INCLUDES_DEFAULT])
@@ -152,7 +156,7 @@ else
fi
# add option to disable installation of ldns-config script
-AC_ARG_ENABLE(ldns-config, [ --disable-ldns-config disable installation of ldns-config (default=enabled)],
+AC_ARG_ENABLE(ldns-config, AC_HELP_STRING([--disable-ldns-config], [disable installation of ldns-config (default=enabled)]),
enable_ldns_config=$enableval, enable_ldns_config=yes)
if test "x$enable_ldns_config" = xyes; then
AC_SUBST(INSTALL_CONFIG, [install-config])
@@ -166,6 +170,16 @@ else
AC_SUBST(UNINSTALL_CONFIG_MANPAGE, [""])
fi
+# add option to disable library printing to stderr
+AC_ARG_ENABLE(stderr-msgs, AC_HELP_STRING([--enable-stderr-msgs], [Enable printing to stderr (default=disabled)]), enable_stderr_msgs=$enableval, enable_stderr_msgs=no)
+case "$enable_stderr_msgs" in
+ no) dnl default
+ ;;
+ *)
+ AC_DEFINE_UNQUOTED([STDERR_MSGS], [1], [Define this to enable messages to stderr.])
+ ;;
+esac
+
# check for python
PYTHON_X_CFLAGS=""
ldns_with_pyldns=no
@@ -255,6 +269,30 @@ else
AC_SUBST(PYLDNSXUNINST, "")
fi
+# check for perl
+ldns_with_p5_dns_ldns=no
+AC_ARG_WITH(p5-dns-ldns, AC_HELP_STRING([--with-p5-dns-ldns],
+ [generate DNS::LDNS perl bindings]),
+ [],[ withval="no" ])
+ldns_have_perl=no
+if test x_$withval != x_no; then
+ AC_PATH_PROG([PERL], [perl])
+ if test -z "$PERL"; then
+ AC_MSG_ERROR([Cannot find perl in your system path])
+ fi
+ AC_SUBST(P5_DNS_LDNS, "p5-dns-ldns")dnl
+ AC_SUBST(TEST_P5_DNS_LDNS, "test-p5-dns-ldns")dnl
+ AC_SUBST(INSTALL_P5_DNS_LDNS, "install-p5-dns-ldns")dnl
+ AC_SUBST(UNINSTALL_P5_DNS_LDNS, "uninstall-p5-dns-ldns")dnl
+ AC_SUBST(CLEAN_P5_DNS_LDNS, "clean-p5-dns-ldns")
+else
+ AC_SUBST(P5_DNS_LDNS, "")dnl
+ AC_SUBST(TEST_P5_DNS_LDNS, "")dnl
+ AC_SUBST(INSTALL_P5_DNS_LDNS, "")dnl
+ AC_SUBST(UNINSTALL_P5_DNS_LDNS, "")dnl
+ AC_SUBST(CLEAN_P5_DNS_LDNS, "")
+fi
+
# Use libtool
ACX_LIBTOOL_C_ONLY
@@ -320,11 +358,67 @@ case "$enable_ecdsa" in
;;
esac
+AC_ARG_ENABLE(dane, AC_HELP_STRING([--disable-dane], [Disable DANE support]))
+case "$enable_dane" in
+ no)
+ AC_SUBST(ldns_build_config_use_dane, 0)
+ ;;
+ *) dnl default
+ if test "x$HAVE_SSL" != "xyes"; then
+ AC_MSG_ERROR([DANE enabled, but no SSL support])
+ fi
+ AC_CHECK_FUNC(X509_check_ca, [], [AC_MSG_ERROR([OpenSSL does not support DANE: please upgrade OpenSSL or rerun with --disable-dane])])
+ AC_DEFINE_UNQUOTED([USE_DANE], [1], [Define this to enable DANE support.])
+ AC_SUBST(ldns_build_config_use_dane, 1)
+ ;;
+esac
+
+AC_ARG_ENABLE(rrtype-ninfo, AC_HELP_STRING([--enable-rrtype-ninfo], [Enable draft RR type ninfo.]))
+case "$enable_rrtype_ninfo" in
+ yes)
+ AC_DEFINE_UNQUOTED([RRTYPE_NINFO], [], [Define this to enable RR type NINFO.])
+ ;;
+ no|*)
+ ;;
+esac
+AC_ARG_ENABLE(rrtype-rkey, AC_HELP_STRING([--enable-rrtype-rkey], [Enable draft RR type rkey.]))
+case "$enable_rrtype_rkey" in
+ yes)
+ AC_DEFINE_UNQUOTED([RRTYPE_RKEY], [], [Define this to enable RR type RKEY.])
+ ;;
+ no|*)
+ ;;
+esac
+AC_ARG_ENABLE(rrtype-cds, AC_HELP_STRING([--enable-rrtype-cds], [Enable draft RR type cds.]))
+case "$enable_rrtype_cds" in
+ yes)
+ AC_DEFINE_UNQUOTED([RRTYPE_CDS], [], [Define this to enable RR type CDS.])
+ ;;
+ no|*)
+ ;;
+esac
+AC_ARG_ENABLE(rrtype-uri, AC_HELP_STRING([--enable-rrtype-uri], [Enable draft RR type uri.]))
+case "$enable_rrtype_uri" in
+ yes)
+ AC_DEFINE_UNQUOTED([RRTYPE_URI], [], [Define this to enable RR type URI.])
+ ;;
+ no|*)
+ ;;
+esac
+AC_ARG_ENABLE(rrtype-ta, AC_HELP_STRING([--enable-rrtype-ta], [Enable draft RR type ta.]))
+case "$enable_rrtype_ta" in
+ yes)
+ AC_DEFINE_UNQUOTED([RRTYPE_TA], [], [Define this to enable RR type TA.])
+ ;;
+ no|*)
+ ;;
+esac
+
AC_SUBST(LIBSSL_CPPFLAGS)
AC_SUBST(LIBSSL_LDFLAGS)
AC_SUBST(LIBSSL_LIBS)
if test "x$HAVE_SSL" = "xyes"; then
-AC_SUBST(LIBSSL_SSL_LIBS, ["$LIBSSL_LIBS -lssl"])
+AC_SUBST(LIBSSL_SSL_LIBS, ["-lssl $LIBSSL_LIBS"])
fi
CPPFLAGS=$tmp_CPPFLAGS
LDFLAGS=$tmp_LDFLAGS
@@ -426,7 +520,7 @@ AC_INCLUDES_DEFAULT
])
if test x_$with_examples != x_no; then
-AC_CHECK_HEADERS([pcap.h],, [AC_INCLUDES_DEFAULT])
+AC_CHECK_HEADERS([pcap.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_LIB(pcap, pcap_open_offline, [
AC_DEFINE([HAVE_LIBPCAP], [1], [Define to 1 if you have the `pcap' library (-lpcap).])dnl`
AC_SUBST([LIBPCAP_LIBS], [-lpcap])
@@ -458,8 +552,9 @@ else
AC_SUBST(ldns_build_config_have_socklen_t, 0)
fi
AC_TYPE_SIZE_T
-AC_TYPE_SSIZE_T
-AC_TYPE_INTPTR_T
+AC_CHECK_TYPE(ssize_t, int)
+dnl AC_TYPE_INTPTR_T does not work on all platforms (autoconf)
+AC_CHECK_TYPE(intptr_t, size_t)
AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
@@ -481,8 +576,6 @@ AC_FUNC_REALLOC
AC_REPLACE_FUNCS(b64_pton)
AC_REPLACE_FUNCS(b64_ntop)
-AC_REPLACE_FUNCS(b32_pton)
-AC_REPLACE_FUNCS(b32_ntop)
AC_REPLACE_FUNCS(calloc)
AC_REPLACE_FUNCS(timegm)
AC_REPLACE_FUNCS(gmtime_r)
@@ -497,7 +590,17 @@ AC_REPLACE_FUNCS(snprintf)
AC_REPLACE_FUNCS(strlcpy)
AC_REPLACE_FUNCS(memmove)
AC_FUNC_FORK
-AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset])
+AC_CHECK_FUNCS([endprotoent endservent sleep random fcntl strtoul bzero memset b32_ntop b32_pton])
+if test "x$HAVE_B32_NTOP" = "xyes"; then
+ AC_SUBST(ldns_build_config_have_b32_ntop, 1)
+else
+ AC_SUBST(ldns_build_config_have_b32_ntop, 0)
+fi
+if test "x$HAVE_B32_PTON" = "xyes"; then
+ AC_SUBST(ldns_build_config_have_b32_pton, 1)
+else
+ AC_SUBST(ldns_build_config_have_b32_pton, 0)
+fi
ACX_CHECK_GETADDRINFO_WITH_INCLUDES
if test $ac_cv_func_getaddrinfo = no; then
@@ -618,7 +721,6 @@ AH_BOTTOM([
extern "C" {
#endif
-#ifndef B64_PTON
int ldns_b64_ntop(uint8_t const *src, size_t srclength,
char *target, size_t targsize);
/**
@@ -629,8 +731,6 @@ static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize)
{
return ((((srcsize + 2) / 3) * 4) + 1);
}
-#endif /* !B64_PTON */
-#ifndef B64_NTOP
int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize);
/**
* calculates the size needed to store the result of ldns_b64_pton
@@ -640,7 +740,12 @@ static inline size_t ldns_b64_pton_calculate_size(size_t srcsize)
{
return (((((srcsize + 3) / 4) * 3)) + 1);
}
-#endif /* !B64_NTOP */
+
+/**
+ * Given in dnssec_zone.c, also used in dnssec_sign.c:w
+
+ */
+int ldns_dname_compare_v(const void *a, const void *b);
#ifndef HAVE_SLEEP
/* use windows sleep, in millisecs, instead */
diff --git a/contrib/DNS-LDNS b/contrib/DNS-LDNS
new file mode 160000
+Subproject f1705d6e7e6a653136e3d8fd2d8a1efc22d2f99
diff --git a/contrib/ldnsx/ldnsx.py b/contrib/ldnsx/ldnsx.py
index ee81b2fd..3ae9424f 100644
--- a/contrib/ldnsx/ldnsx.py
+++ b/contrib/ldnsx/ldnsx.py
@@ -132,9 +132,9 @@ def secure_query(name, rr_type, rr_class="IN", flags=["RD"], tries = 1, flex=Fal
raise Exception("%s lookup failed (server error or dnssec validation failed)" % name)
if pkt.rcode() == "NXDOMAIN":
if "AD" in pkt.flags():
- raise Exception("%s lookup failed (non-existence proven by DNSSEC)" % hostname )
+ raise Exception("%s lookup failed (non-existence proven by DNSSEC)" % name )
else:
- raise Exception("%s lookup failed" % hostname )
+ raise Exception("%s lookup failed" % name )
if pkt.rcode() == "NOERROR":
if "AD" not in pkt.flags():
if not flex:
@@ -698,7 +698,7 @@ class resource_record:
def __len__(self):
try:
- return len(_rdfs)
+ return len(self._rdfs)
except:
return 0
@@ -891,6 +891,7 @@ _rr_types={
"NSAP_PTR" : ldns.LDNS_RR_TYPE_NSAP_PTR,
"NSEC" : ldns.LDNS_RR_TYPE_NSEC,
"NSEC3": ldns.LDNS_RR_TYPE_NSEC3,
+ "NSEC3PARAM" : ldns.LDNS_RR_TYPE_NSEC3PARAM,
"NSEC3PARAMS" : ldns.LDNS_RR_TYPE_NSEC3PARAMS,
"NULL" : ldns.LDNS_RR_TYPE_NULL,
"NXT" : ldns.LDNS_RR_TYPE_NXT,
diff --git a/contrib/python/Changelog b/contrib/python/Changelog
index 1e1af92a..7c4ccd11 100644
--- a/contrib/python/Changelog
+++ b/contrib/python/Changelog
@@ -1,4 +1,30 @@
-1.6.16
+1.6.17 2014-01-10
+ * Added ldns_rdf.data_as_bytearray(). The method returns a bytearray object
+ containing rdf data.
+ * Changed the behaviour of ldns_resolver.trusted_key() in order to prevent
+ memory corrupotion and leaks.
+ * Fixed memory leaks when destroying ldns_resolver.
+ * Removed ldns_pkt.section_count(), ldns_resolver.set_searchlist_count()
+ because it is marked static in the library.
+ * Added ldns_pkt.new(), ldns_resolver.new().
+ * Marked as returning new object ldns_pkt.get_section_clone(),
+ ldns_resolver.get_addr_by_name(), ldns_resolver.get_name_by_addr(),
+ ldns_resolver.search().
+ * Added push cloning for ldns_pkt.safe_push_rr(),
+ ldns_pkt.safe_push_rr_list(), ldns_pkt.set_additional(),
+ ldns_pkt.set_answer(), ldns_pkt.set_answerfrom(),
+ ldns_pkt.set_authority(), ldns_pkt.set_edns_data(),
+ ldns_pkt.set_question(), ldns_pkt.set_tsig(),
+ ldns_resolver.set_dnssec_anchors(), ldns_resolver.set_domain().
+ * Added pull cloning for ldns_pkt.answerfrom(), ldns_pkt.edns_data(),
+ ldns_pkt.tsig(), ldns_resolver.axfr_last_pkt(),
+ ldns_resolver.dnssec_anchors(), ldns_resolver.domain(),
+ ldns_resolver.tsig_algorithm(), ldns_resolver.tsig_keydata(),
+ ldns_resolver.tsig_keyname().
+ * Method ldns_rdf.reverse() now throws an exception when not applied
+ on dname rdfs. This is to prevent assertion fails in ldns' C code.
+
+1.6.16 2012-11-13
* Fix typo in ldns_struct_pkt.opcode2str
1.6.14 2012-10-23
diff --git a/contrib/python/Makefile b/contrib/python/Makefile
index 92768576..debc7d04 100644
--- a/contrib/python/Makefile
+++ b/contrib/python/Makefile
@@ -41,7 +41,7 @@ help:
../../Makefile: ../../configure
cd ../.. && ./configure --with-python
-_ldns.so: ../../Makefile
+_ldns.so: ../../Makefile
$(MAKE) -C ../..
../../.libs/libldns.so.1: ../../Makefile
@@ -59,13 +59,15 @@ testenv: ../../.libs/libldns.so.1 _ldns.so
cd examples && LD_LIBRARY_PATH=ldns bash
rm -rf examples/ldns
-test: ../../.libs/libldns.so.1 _ldns.so examples/test_buffer.py examples/test_rdf.py examples/test_dname.py examples/test_rr.py
+test: ../../.libs/libldns.so.1 _ldns.so examples/test_buffer.py examples/test_rdf.py examples/test_dname.py examples/test_rr.py examples/test_pkt.py examples/test_resolver.py
@rm -rf examples/ldns
@cd examples && mkdir ldns && ln -s ../../ldns.py ldns/__init__.py && ln -s ../../../../.libs/_ldns.so ldns/_ldns.so && ln -s ../../../../.libs/libldns.so.1 ldns/libldns.so.1
@cd examples && LD_LIBRARY_PATH=ldns ./test_buffer.py 2>/dev/null
@cd examples && LD_LIBRARY_PATH=ldns ./test_rdf.py 2>/dev/null
@cd examples && LD_LIBRARY_PATH=ldns ./test_dname.py 2>/dev/null
@cd examples && LD_LIBRARY_PATH=ldns ./test_rr.py 2>/dev/null
+ @cd examples && LD_LIBRARY_PATH=ldns ./test_pkt.py 2>/dev/null
+ @cd examples && LD_LIBRARY_PATH=ldns ./test_resolver.py 2>/dev/null
@rm -rf examples/ldns
doc: ../../.libs/libldns.so.1 _ldns.so
diff --git a/contrib/python/docs/source/conf.py b/contrib/python/docs/source/conf.py
index f8821e09..468b827d 100644
--- a/contrib/python/docs/source/conf.py
+++ b/contrib/python/docs/source/conf.py
@@ -37,7 +37,7 @@ master_doc = 'index'
# General substitutions.
project = 'pyLDNS'
-copyright = '2009, Karel Slany, Zdenek Vasicek'
+copyright = '2009-2013, Karel Slany, Zdenek Vasicek'
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
@@ -45,7 +45,7 @@ copyright = '2009, Karel Slany, Zdenek Vasicek'
# The short X.Y version.
version = '1.6'
# The full version, including alpha/beta/rc tags.
-release = '1.6.14'
+release = '1.6.17'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
diff --git a/contrib/python/docs/source/modules/ldns_rdf.rst b/contrib/python/docs/source/modules/ldns_rdf.rst
index 5ed1799b..4a482e44 100644
--- a/contrib/python/docs/source/modules/ldns_rdf.rst
+++ b/contrib/python/docs/source/modules/ldns_rdf.rst
@@ -35,7 +35,7 @@ Predefined constants
* LDNS_RDF_TYPE_TIME,
* LDNS_RDF_TYPE_PERIOD,
* LDNS_RDF_TYPE_TSIGTIME,
- * LDNS_RDF_TYPE_TSIG,
+ * LDNS_RDF_TYPE_HIP,
* LDNS_RDF_TYPE_INT16_DATA,
* LDNS_RDF_TYPE_SERVICE,
* LDNS_RDF_TYPE_LOC,
diff --git a/contrib/python/examples/test_buffer.py b/contrib/python/examples/test_buffer.py
index 0baf76f6..472bd6fd 100755
--- a/contrib/python/examples/test_buffer.py
+++ b/contrib/python/examples/test_buffer.py
@@ -174,7 +174,7 @@ if True:
ret = buf.capacity()
except:
set_error()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
# Should be int.
set_error()
@@ -284,7 +284,7 @@ if True:
ret = buf.position()
except:
set_error()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
@@ -328,7 +328,7 @@ if True:
ret = buf.read_u16()
except:
set_error()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != (ord("a") * 0x0101):
set_error()
@@ -343,7 +343,7 @@ if True:
ret = buf.read_u16_at(1)
except:
set_error()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != (ord("b") * 0x0101):
set_error()
@@ -418,7 +418,7 @@ if True:
ret = buf.read_u8()
except:
set_error()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != ord("a"):
set_error()
@@ -433,7 +433,7 @@ if True:
ret = buf.read_u8_at(1)
except:
set_error()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != ord("b"):
set_error()
@@ -462,7 +462,7 @@ if True:
ret = buf.remaining()
except:
set_error()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != (capacity - 6):
set_error()
@@ -477,7 +477,7 @@ if True:
ret = buf.remaining_at(1)
except:
set_error()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != (capacity - 1):
set_error()
diff --git a/contrib/python/examples/test_dname.py b/contrib/python/examples/test_dname.py
index d6917073..07e0a850 100755
--- a/contrib/python/examples/test_dname.py
+++ b/contrib/python/examples/test_dname.py
@@ -388,7 +388,7 @@ if True:
dn = ldns.ldns_dname("www.nic.cz.")
try:
ret = dn.label_count()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 3:
set_error()
diff --git a/contrib/python/examples/test_pkt.py b/contrib/python/examples/test_pkt.py
new file mode 100755
index 00000000..7ecb7bd8
--- /dev/null
+++ b/contrib/python/examples/test_pkt.py
@@ -0,0 +1,1937 @@
+#!/usr/bin/env python
+
+#
+# ldns_pkt testing script.
+#
+# Do not use constructs that differ between Python 2 and 3.
+# Use write on stdout or stderr.
+#
+
+
+import ldns
+import sys
+import os
+import inspect
+
+
+class_name = "ldns_pkt"
+method_name = None
+error_detected = False
+temp_fname = "tmp_pkt.txt"
+
+
+def set_error():
+ """
+ Writes an error message and sets error flag.
+ """
+ global class_name
+ global method_name
+ global error_detected
+ error_detected = True
+ sys.stderr.write("(line %d): malfunctioning method %s.\n" % \
+ (inspect.currentframe().f_back.f_lineno, method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".aa()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA)
+ try:
+ ret = pkt.aa()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR)
+ try:
+ ret = pkt.aa()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".ad()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.ad()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR)
+ try:
+ ret = pkt.ad()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".additional()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.additional()
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ if ret.rr_count() != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".algorithm2str()"
+ try:
+ ret = ldns.ldns_pkt.algorithm2str(ldns.LDNS_DSA)
+ if not isinstance(ret, str):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".all()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.all()
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ if ret.rr_count() != 1:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".all_noquestion()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.all_noquestion()
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ if ret.rr_count() != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".ancount()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.ancount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".answer()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.answer()
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ if ret.rr_count() != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".answerfrom()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.answerfrom()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
+ try:
+ ret = pkt.answerfrom()
+ if not isinstance(ret, ldns.ldns_rdf):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".arcount()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.arcount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".authority()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.authority()
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ if ret.rr_count() != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".cd()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_CD)
+ try:
+ ret = pkt.cd()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR)
+ try:
+ ret = pkt.cd()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".cert_algorithm2str()"
+ try:
+ ret = ldns.ldns_pkt.cert_algorithm2str(ldns.LDNS_CERT_PGP)
+ if not isinstance(ret, str):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".clone()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.clone()
+ if not isinstance(ret, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".ends()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.edns()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_dnssec(True)
+ pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
+ try:
+ ret = pkt.edns()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".ends_data()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.edns_data()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ #resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ #resolver.set_dnssec(True)
+ #pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
+ #try:
+ # ret = pkt.edns_data()
+ # print ret
+ # if not isinstance(ret, ldns.ldns_rdf):
+ # set_error()
+ # if ret != True:
+ # set_error()
+ #except:
+ # set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".edns_do()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.edns_do()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".edns_extended_rcode()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.edns_extended_rcode()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+ #resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ #resolver.set_dnssec(True)
+ #pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
+ #try:
+ # ret = pkt.edns_extended_rcode()
+ # if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ # set_error()
+ # if ret != 0:
+ # set_error()
+ #except:
+ # set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".edns_udp_size()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.edns_udp_size()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_dnssec(True)
+ pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
+ try:
+ ret = pkt.edns_udp_size()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret == 0: # Don't know the actual size, but must be greater than 0.
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".edns_version()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.edns_version()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+ #resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ #resolver.set_dnssec(True)
+ #pkt = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
+ #try:
+ # ret = pkt.edns_version()
+ # if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ # set_error()
+ # if ret != 0:
+ # set_error()
+ #except:
+ # set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".edns_z()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.edns_z()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".empty()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.empty()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".get_opcode()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.get_opcode()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != ldns.LDNS_PACKET_QUERY:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".get_rcode()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.get_rcode()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != ldns.LDNS_RCODE_NOERROR:
+ set_error()
+ except:
+ set_error()
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_dnssec(True)
+ pkt = resolver.query("nonexistent_domain.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN)
+ try:
+ ret = pkt.get_rcode()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != ldns.LDNS_RCODE_NXDOMAIN:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".get_section_clone()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.get_section_clone(ldns.LDNS_SECTION_ANY)
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.get_section_clone(ldns.LDNS_SECTION_ANSWER)
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.get_section_clone("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".id()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.id()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".new()"
+ try:
+ pkt = ldns.ldns_pkt.new()
+ if not isinstance(pkt, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".new_query()"
+ dname = ldns.ldns_dname("test.nic.cz.")
+ try:
+ pkt = ldns.ldns_pkt.new_query(dname, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ if not isinstance(pkt, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+ rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test.nic.cz.")
+ try:
+ pkt = ldns.ldns_pkt.new_query(rdf, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ if not isinstance(pkt, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt = ldns.ldns_pkt.new_query("bad argument", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ pkt = ldns.ldns_pkt.new_query(dname, "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ pkt = ldns.ldns_pkt.new_query(dname, ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_QR | ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ pkt = ldns.ldns_pkt.new_query(dname, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".new_query_frm_str()"
+ try:
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA)
+ except:
+ set_error()
+ try:
+ pkt = ldns.ldns_pkt.new_query_frm_str(pkt, ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_ANY, "bad argument", ldns.LDNS_QR | ldns.LDNS_AA)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".nscount()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.nscount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".opcode2str()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ ret = pkt.opcode2str()
+ if not isinstance(ret, str):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".print_to_file()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ f = open(temp_fname, "w")
+ try:
+ pkt.print_to_file(f)
+ except:
+ set_error()
+ f.close()
+ f = open(temp_fname, "r")
+ if len(f.readlines()) != 14:
+ set_error()
+ f.close()
+ os.remove(temp_fname)
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".push_rr()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ try:
+ ret = pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.push_rr("bad argument", rr)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = pkt.push_rr(ldns.LDNS_SECTION_ANSWER, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".push_rr_list()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ rrl.push_rr(rr)
+ rrl.push_rr(rr)
+ try:
+ ret = pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, rrl)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.push_rr_list("bad argument", rrl)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = pkt.push_rr_list(ldns.LDNS_SECTION_ANSWER, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".qdcount()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.qdcount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 1:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".qr()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA)
+ try:
+ ret = pkt.qr()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_AA)
+ try:
+ ret = pkt.qr()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".querytime()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.querytime()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".question()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AD)
+ try:
+ ret = pkt.question()
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ if ret.rr_count() != 1:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".ra()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RA)
+ try:
+ ret = pkt.ra()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR)
+ try:
+ ret = pkt.ra()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".rcode2str()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RA)
+ try:
+ ret = pkt.rcode2str()
+ if not isinstance(ret, str):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".rd()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ try:
+ ret = pkt.rd()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR)
+ try:
+ ret = pkt.rd()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".reply_type()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ try:
+ ret = pkt.reply_type()
+ if ret != ldns.LDNS_PACKET_ANSWER:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".rr()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr)
+ try:
+ ret = pkt.rr(ldns.LDNS_SECTION_ANSWER, rr)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.rr(ldns.LDNS_SECTION_QUESTION, rr)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.rr("bad argument", rr)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = pkt.rr(ldns.LDNS_SECTION_QUESTION, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".rr_list_by_name()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr)
+ rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test1")
+ try:
+ ret = pkt.rr_list_by_name(rdf, ldns.LDNS_SECTION_ANSWER)
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.rr_list_by_name(rdf, ldns.LDNS_SECTION_QUESTION)
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.rr_list_by_name("bad argument", ldns.LDNS_SECTION_ANSWER)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = pkt.rr_list_by_name(rdf, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".rr_list_by_name_and_type()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr)
+ rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "test1")
+ try:
+ ret = pkt.rr_list_by_name_and_type(rdf, ldns.LDNS_RR_TYPE_A, ldns.LDNS_SECTION_ANSWER)
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.rr_list_by_name_and_type(rdf, ldns.LDNS_RR_TYPE_AAAA, ldns.LDNS_SECTION_ANSWER)
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ #try:
+ # ret = pkt.rr_list_by_name_and_type("bad argument", ldns.LDNS_RR_TYPE_A, ldns.LDNS_SECTION_ANSWER)
+ # set_error()
+ #except TypeError as e:
+ # pass
+ #except:
+ # set_error()
+ try:
+ ret = pkt.rr_list_by_name_and_type(rdf, "bad argument", ldns.LDNS_SECTION_ANSWER)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = pkt.rr_list_by_name_and_type(rdf, ldns.LDNS_RR_TYPE_A, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".rr_list_by_type()"
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_RD)
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ pkt.push_rr(ldns.LDNS_SECTION_ANSWER, rr)
+ try:
+ ret = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_A, ldns.LDNS_SECTION_ANSWER)
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_AAAA, ldns.LDNS_SECTION_ANSWER)
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.rr_list_by_type("bad argument", ldns.LDNS_SECTION_ANSWER)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = pkt.rr_list_by_type(ldns.LDNS_RR_TYPE_A, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".safe_push_rr()"
+ pkt = ldns.ldns_pkt.new()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ try:
+ ret = pkt.safe_push_rr(ldns.LDNS_SECTION_ANSWER, rr)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.safe_push_rr(ldns.LDNS_SECTION_ANSWER, rr)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.safe_push_rr("bad argument", rr)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = pkt.safe_push_rr(ldns.LDNS_SECTION_ANSWER, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".safe_push_rr_list()"
+ pkt = ldns.ldns_pkt.new()
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ rrl.push_rr(rr)
+ try:
+ ret = pkt.safe_push_rr_list(ldns.LDNS_SECTION_ANSWER, rrl)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.safe_push_rr_list(ldns.LDNS_SECTION_ANSWER, rrl)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.safe_push_rr_list("bad argument", rrl)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = pkt.safe_push_rr_list(ldns.LDNS_SECTION_ANSWER, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_aa()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_aa(True)
+ if pkt.aa() != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_aa(False)
+ if pkt.aa() != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_ad()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_ad(True)
+ if pkt.ad() != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_ad(False)
+ if pkt.ad() != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_additional()"
+ pkt = ldns.ldns_pkt.new()
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ rrl.push_rr(rr)
+ try:
+ pkt.set_additional(rrl)
+ if not isinstance(pkt.additional() , ldns.ldns_rr_list):
+ set_error()
+ if pkt.additional() != rrl:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_additional("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_ancount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_ancount(1)
+ ret = pkt.ancount()
+ if ret != 1:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_ancount("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_answer()"
+ pkt = ldns.ldns_pkt.new()
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ rrl.push_rr(rr)
+ try:
+ pkt.set_answer(rrl)
+ if not isinstance(pkt.additional() , ldns.ldns_rr_list):
+ set_error()
+ if pkt.answer() != rrl:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_answer("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_answerfrom()"
+ pkt = ldns.ldns_pkt.new()
+ rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1")
+ try:
+ pkt.set_answerfrom(rdf)
+ ret = pkt.answerfrom()
+ if ret != rdf:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_answerfrom("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_arcount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_arcount(1)
+ ret = pkt.arcount()
+ if ret != 1:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_arcount("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_authority()"
+ pkt = ldns.ldns_pkt.new()
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ rrl.push_rr(rr)
+ try:
+ pkt.set_authority(rrl)
+ if not isinstance(pkt.additional() , ldns.ldns_rr_list):
+ set_error()
+ if pkt.authority() != rrl:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_authority("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_cd()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_cd(True)
+ if pkt.cd() != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_cd(False)
+ if pkt.cd() != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_edns_data()"
+ pkt = ldns.ldns_pkt.new()
+ rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1")
+ try:
+ pkt.set_edns_data(rdf)
+ ret = pkt.edns_data()
+ if ret != rdf:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_edns_data("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_edns_do()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_edns_do(True)
+ if pkt.edns_do() != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_edns_do(False)
+ if pkt.edns_do() != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_edns_extended_rcode()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_edns_extended_rcode(8)
+ ret = pkt.edns_extended_rcode()
+ if ret != 8:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_edns_extended_rcode("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_edns_udp_size()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_edns_udp_size(4096)
+ ret = pkt.edns_udp_size()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_edns_udp_size("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_edns_version()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_edns_version(8)
+ ret = pkt.edns_version()
+ if ret != 8:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_edns_version("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_edns_z()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_edns_z(4096)
+ ret = pkt.edns_z()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_edns_z("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_flags()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ ret = pkt.set_flags(ldns.LDNS_AA | ldns.LDNS_AD)
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_flags("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_id()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_id(4096)
+ ret = pkt.id()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_id("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_nscount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_nscount(1)
+ ret = pkt.nscount()
+ if ret != 1:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_nscount("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_opcode()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_opcode(ldns.LDNS_PACKET_QUERY)
+ ret = pkt.get_opcode()
+ if ret != ldns.LDNS_PACKET_QUERY:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_opcode("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_qdcount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_qdcount(10)
+ ret = pkt.qdcount()
+ if ret != 10:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_qdcount("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_qr()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_qr(True)
+ if pkt.qr() != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_qr(False)
+ if pkt.qr() != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_querytime()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_querytime(65536)
+ ret = pkt.querytime()
+ if ret != 65536:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_querytime("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_question()"
+ pkt = ldns.ldns_pkt.new()
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ rrl.push_rr(rr)
+ try:
+ pkt.set_question(rrl)
+ if not isinstance(pkt.additional() , ldns.ldns_rr_list):
+ set_error()
+ if pkt.question() != rrl:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_question("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_ra()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_ra(True)
+ if pkt.ra() != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_ra(False)
+ if pkt.ra() != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_random_id()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_random_id()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_rcode()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_rcode(127)
+ ret = pkt.get_rcode()
+ if ret != 127:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_rcode("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_rd()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_rd(True)
+ if pkt.rd() != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_rd(False)
+ if pkt.rd() != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_section_count()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_section_count(ldns.LDNS_PACKET_QUESTION, 4096)
+ ret = pkt.qdcount()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_section_count("bad argument", 4096)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ pkt.set_section_count(ldns.LDNS_PACKET_QUESTION, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_size()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_size(512)
+ ret = pkt.size()
+ if ret != 512:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_size("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_tc()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.set_tc(True)
+ if pkt.tc() != True:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_tc(False)
+ if pkt.tc() != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_timestamp()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_tsig()"
+ pkt = ldns.ldns_pkt.new()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ try:
+ pkt.set_tsig(rr)
+ ret = pkt.tsig()
+ if ret != rr:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.set_tsig("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".size()"
+ pkt = ldns.ldns_pkt.new()
+ pkt.set_size(512)
+ try:
+ ret = pkt.size()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 512:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".tc()"
+ pkt = ldns.ldns_pkt.new()
+ pkt.set_tc(True)
+ try:
+ ret = pkt.tc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+ pkt.set_tc(False)
+ try:
+ ret = pkt.tc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".timestamp()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".tsig()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ ret = pkt.tsig()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ pkt.set_tsig(rr)
+ try:
+ ret = pkt.tsig()
+ if not isinstance(ret, ldns.ldns_rr):
+ set_error()
+ if ret != rr:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".update_pkt_tsig_add()"
+ pkt = ldns.ldns_pkt.new()
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = pkt.update_pkt_tsig_add(resolver)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = pkt.update_pkt_tsig_add("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".update_prcount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ ret = pkt.update_prcount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+ pkt.update_set_prcount(127)
+ try:
+ ret = pkt.update_prcount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 127:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".update_set_adcount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.update_set_adcount(4096)
+ ret = pkt.update_ad()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.update_set_adcount("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".update_set_prcount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.update_set_prcount(4096)
+ ret = pkt.update_prcount()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.update_set_prcount("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".update_set_upcount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.update_set_upcount(4096)
+ ret = pkt.update_upcount()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.update_set_upcount("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".update_set_zo()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ pkt.update_set_zo(4096)
+ ret = pkt.update_zocount()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ pkt.update_set_zo("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".update_upcount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ ret = pkt.update_upcount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+ pkt.update_set_upcount(127)
+ try:
+ ret = pkt.update_upcount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 127:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".update_zocount()"
+ pkt = ldns.ldns_pkt.new()
+ try:
+ ret = pkt.update_zocount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+ pkt.update_set_zo(127)
+ try:
+ ret = pkt.update_zocount()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 127:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".write_to_buffer()"
+ pkt = pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_QR | ldns.LDNS_AA)
+ buf = buf = ldns.ldns_buffer(4096)
+ try:
+ ret = pkt.write_to_buffer(buf)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+
+
+if not error_detected:
+ sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__)))
+else:
+ sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__)))
+ sys.exit(1)
diff --git a/contrib/python/examples/test_rdf.py b/contrib/python/examples/test_rdf.py
index 4991288c..2e2b73b6 100755
--- a/contrib/python/examples/test_rdf.py
+++ b/contrib/python/examples/test_rdf.py
@@ -408,6 +408,20 @@ if True:
#if not error_detected:
if True:
+ method_name = "ldns_rdf.data_as_bytearray()"
+ rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.")
+ try:
+ ret = rdf.data_as_bytearray()
+ if not isinstance(ret, bytearray):
+ set_error()
+ if len(ret) != 12:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
method_name = "ldns_rdf.dname_compare()"
rdf1 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.")
rdf2 = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "nic.cz.")
@@ -602,7 +616,7 @@ if True:
rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_DNAME, "www.nic.cz.")
try:
ret = rdf.label_count()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 3:
set_error()
@@ -611,7 +625,7 @@ if True:
rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1")
try:
ret = rdf.label_count()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 0:
set_error()
@@ -720,8 +734,9 @@ if True:
rdf = ldns.ldns_rdf_new_frm_str(ldns.LDNS_RDF_TYPE_A, "127.0.0.1")
try:
ret = rdf.reverse()
- if not isinstance(ret, ldns.ldns_rdf):
- set_error()
+ set_error()
+ except Exception:
+ pass
except:
set_error()
diff --git a/contrib/python/examples/test_resolver.py b/contrib/python/examples/test_resolver.py
new file mode 100755
index 00000000..274a4d87
--- /dev/null
+++ b/contrib/python/examples/test_resolver.py
@@ -0,0 +1,1751 @@
+#!/usr/bin/env python
+
+#
+# ldns_resolver testing script.
+#
+# Do not use constructs that differ between Python 2 and 3.
+# Use write on stdout or stderr.
+#
+
+
+import ldns
+import sys
+import os
+import inspect
+
+
+class_name = "ldns_resolver"
+method_name = None
+error_detected = False
+temp_fname = "tmp_resolver.txt"
+
+
+def set_error():
+ """
+ Writes an error message and sets error flag.
+ """
+ global class_name
+ global method_name
+ global error_detected
+ error_detected = True
+ sys.stderr.write("(line %d): malfunctioning method %s.\n" % \
+ (inspect.currentframe().f_back.f_lineno, method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".axfr_complete()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".axfr_last_pkt()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".axfr_next()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".axfr_start()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".debug()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_debug(False)
+ try:
+ ret = resolver.debug()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_debug(True)
+ try:
+ ret = resolver.debug()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".dec_nameserver_count()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ cnt = resolver.nameserver_count()
+ try:
+ resolver.dec_nameserver_count()
+ except:
+ set_error()
+ if cnt != (resolver.nameserver_count() + 1):
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".defnames()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_defnames(False)
+ try:
+ ret = resolver.defnames()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_defnames(True)
+ try:
+ ret = resolver.defnames()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".dnsrch()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_dnsrch(False)
+ try:
+ ret = resolver.dnsrch()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_dnsrch(True)
+ try:
+ ret = resolver.dnsrch()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".dnssec()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_dnssec(False)
+ try:
+ ret = resolver.dnssec()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_dnssec(True)
+ try:
+ ret = resolver.dnssec()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".dnssec_anchors()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ rrl = ldns.ldns_rr_list.new()
+ try:
+ ret = resolver.dnssec_anchors()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ resolver.set_dnssec_anchors(rrl)
+ try:
+ ret = resolver.dnssec_anchors()
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".dnssec_cd()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_dnssec_cd(False)
+ try:
+ ret = resolver.dnssec_cd()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_dnssec_cd(True)
+ try:
+ ret = resolver.dnssec_cd()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".domain()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_domain(None)
+ try:
+ ret = resolver.domain()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ dname = ldns.ldns_dname("example.com.")
+ resolver.set_domain(dname)
+ try:
+ ret = resolver.domain()
+ if not isinstance(ret, ldns.ldns_dname):
+ set_error()
+ if ret != dname:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".edns_udp_size()"
+ try:
+ resolver = ldns.ldns_resolver.new()
+ if not isinstance(resolver, ldns.ldns_resolver):
+ set_error()
+ except:
+ set_error()
+
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".edns_udp_size()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_edns_udp_size(4096)
+ try:
+ ret = resolver.edns_udp_size()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".fail()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_fail(False)
+ try:
+ ret = resolver.fail()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_fail(True)
+ try:
+ ret = resolver.fail()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".fallback()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_fallback(False)
+ try:
+ ret = resolver.fallback()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_fallback(True)
+ try:
+ ret = resolver.fallback()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".get_addr_by_name()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.get_addr_by_name("www.google.com", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.get_addr_by_name(1, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.get_addr_by_name("www.google.com", "bad argument", ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.get_addr_by_name("www.google.com", ldns.LDNS_RR_CLASS_IN, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".get_name_by_addr()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ addr = resolver.get_name_by_addr("8.8.8.8", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ if not isinstance(addr, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+ try:
+ addr = resolver.get_name_by_addr(1, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ addr = resolver.get_name_by_addr("8.8.8.8", "bad argument", ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ addr = resolver.get_name_by_addr("8.8.8.8", ldns.LDNS_RR_CLASS_IN, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".igntc()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_igntc(False)
+ try:
+ ret = resolver.igntc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_igntc(True)
+ try:
+ ret = resolver.igntc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".incr_nameserver_count()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ cnt = resolver.nameserver_count()
+ try:
+ resolver.incr_nameserver_count()
+ except:
+ set_error()
+ if (cnt + 1) != resolver.nameserver_count():
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".ip6()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_ip6(0)
+ try:
+ ret = resolver.ip6()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".nameserver_count()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_nameserver_count(1)
+ try:
+ ret = resolver.nameserver_count()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 1:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".nameserver_rtt()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ num = resolver.nameserver_count()
+ for i in range(0, num):
+ resolver.set_nameserver_rtt(i, i + 1)
+ try:
+ for i in range(0, num):
+ ret = resolver.nameserver_rtt(i)
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if (i + 1) != ret:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.nameserver_rtt("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".nameservers()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".nameservers_randomize()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.nameservers_randomize()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".new_frm_file()"
+ try:
+ ret = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf", raiseException=True)
+ if not isinstance(ret, ldns.ldns_resolver):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = ldns.ldns_resolver.new_frm_file(1, raiseException=True)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".new_frm_fp()"
+ fi = open("/etc/resolv.conf")
+ try:
+ ret = ldns.ldns_resolver.new_frm_fp(fi, raiseException=True)
+ if not isinstance(ret, ldns.ldns_resolver):
+ set_error()
+ except:
+ set_error()
+ fi.close()
+ try:
+ ret = ldns.ldns_resolver.new_frm_fp(1, raiseException=True)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".new_frm_fp_l()"
+ fi = open("/etc/resolv.conf")
+ try:
+ ret, line = ldns.ldns_resolver.new_frm_fp_l(fi, raiseException=True)
+ if not isinstance(ret, ldns.ldns_resolver):
+ set_error()
+ if (not isinstance(line, int)) and (not isinstance(line, long)):
+ set_error()
+ except:
+ set_error()
+ fi.close()
+ try:
+ ret, line = ldns.ldns_resolver.new_frm_fp_l(1, raiseException=True)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".pop_nameserver()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ cnt = resolver.nameserver_count()
+ try:
+ for i in range(0, cnt):
+ ret = resolver.pop_nameserver()
+ if not isinstance(ret, ldns.ldns_rdf):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.pop_nameserver()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".port()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_port(12345)
+ try:
+ ret = resolver.port()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 12345:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".prepare_query_pkt()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.prepare_query_pkt("example.com.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD, raiseException=True)
+ if not isinstance(ret, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.prepare_query_pkt(1, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD, raiseException=True)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.prepare_query_pkt("example.com.", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD, raiseException=True)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.prepare_query_pkt("example.com.", ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_RD, raiseException=True)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.prepare_query_pkt("example.com.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument", raiseException=True)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".push_dnssec_anchor()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ key = ldns.ldns_key.new_frm_algorithm(ldns.LDNS_SIGN_DSA, 512)
+ domain = ldns.ldns_dname("example.")
+ key.set_pubkey_owner(domain)
+ pubkey = key.key_to_rr()
+ ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1)
+ try:
+ ret = resolver.push_dnssec_anchor(ds)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ rr = ldns.ldns_rr.new_frm_str("test1 600 IN A 0.0.0.0")
+ try:
+ ret = resolver.push_dnssec_anchor(rr)
+ if ret == ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.push_dnssec_anchor("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".push_nameserver()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ rdf = ldns.ldns_rdf.new_frm_str("127.0.0.1", ldns.LDNS_RDF_TYPE_A)
+ try:
+ ret = resolver.push_nameserver(rdf)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ rdf = ldns.ldns_rdf.new_frm_str("::1", ldns.LDNS_RDF_TYPE_AAAA)
+ try:
+ ret = resolver.push_nameserver(rdf)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ rdf = ldns.ldns_rdf.new_frm_str("example.com.", ldns.LDNS_RDF_TYPE_DNAME)
+ try:
+ ret = resolver.push_nameserver(rdf)
+ if ret == ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.push_nameserver("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".push_nameserver_rr()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ rr = ldns.ldns_rr.new_frm_str("test 600 IN A 127.0.0.1")
+ try:
+ ret = resolver.push_nameserver_rr(rr)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ rr = ldns.ldns_rr.new_frm_str("test 600 IN AAAA ::1")
+ try:
+ ret = resolver.push_nameserver_rr(rr)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ rr = ldns.ldns_rr.new_frm_str("test 600 IN NS 8.8.8.8")
+ try:
+ ret = resolver.push_nameserver_rr(rr)
+ if ret == ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.push_nameserver_rr("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".push_nameserver_rr_list()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test 600 IN A 127.0.0.1")
+ rrl.push_rr(rr)
+ try:
+ ret = resolver.push_nameserver_rr_list(rrl)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test 600 IN AAAA ::1")
+ rrl.push_rr(rr)
+ try:
+ ret = resolver.push_nameserver_rr_list(rrl)
+ if ret != ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ rrl = ldns.ldns_rr_list.new()
+ rr = ldns.ldns_rr.new_frm_str("test 600 IN NS 8.8.8.8")
+ rrl.push_rr(rr)
+ try:
+ ret = resolver.push_nameserver_rr_list(rrl)
+ if ret == ldns.LDNS_STATUS_OK:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.push_nameserver_rr_list("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".push_searchlist()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.push_searchlist("example.com.")
+ try:
+ resolver.push_searchlist("example.com.")
+ except:
+ set_error()
+ try:
+ resolver.push_searchlist(1)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".query()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ if not isinstance(ret, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.query(1, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.query("www.nic.cz", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.query("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".random()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_random(False)
+ try:
+ ret = resolver.random()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_random(True)
+ try:
+ ret = resolver.random()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".recursive()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_recursive(False)
+ try:
+ ret = resolver.recursive()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_recursive(True)
+ try:
+ ret = resolver.recursive()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".retrans()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_retrans(127)
+ try:
+ ret = resolver.retrans()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 127:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".retry()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_retry(4)
+ try:
+ ret = resolver.retry()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 4:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".rtt()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".search()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.search("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ if not isinstance(ret, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.search(1, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.search("www.nic.cz", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.search("www.nic.cz", ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.search("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".searchlist()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".searchlist_count()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.searchlist_count()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 0:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".send()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.send("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ if not isinstance(ret, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.send(1, ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.send("www.nic.cz", "bad argument", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.send("www.nic.cz", ldns.LDNS_RR_TYPE_A, "bad argument", ldns.LDNS_RD)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.send("www.nic.cz", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".send_pkt()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ pkt = ldns.ldns_pkt.new_query_frm_str("test.nic.cz",ldns.LDNS_RR_TYPE_ANY, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD | ldns.LDNS_AD)
+ try:
+ status, ret = resolver.send_pkt(pkt)
+ if status != ldns.LDNS_STATUS_OK:
+ ste_error()
+ if not isinstance(ret, ldns.ldns_pkt):
+ set_error()
+ except:
+ set_error()
+ try:
+ status, ret = resolver.send_pkt("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_debug()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_debug(False)
+ ret = resolver.debug()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_debug(True)
+ ret = resolver.debug()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_defnames()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_defnames(False)
+ ret = resolver.defnames()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_defnames(True)
+ ret = resolver.defnames()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_dnsrch()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_dnsrch(False)
+ ret = resolver.dnsrch()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_dnsrch(True)
+ ret = resolver.dnsrch()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_dnssec()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_dnssec(False)
+ ret = resolver.dnssec()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_dnssec(True)
+ ret = resolver.dnssec()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_dnssec_anchors()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ rrl = ldns.ldns_rr_list.new()
+ try:
+ resolver.set_dnssec_anchors(rrl)
+ ret = resolver.dnssec_anchors()
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_dnssec_anchors("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_dnssec_cd()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_dnssec_cd(False)
+ ret = resolver.dnssec_cd()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_dnssec_cd(True)
+ ret = resolver.dnssec_cd()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_domain()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_domain(None)
+ ret = resolver.domain()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ dname = ldns.ldns_dname("example.com.")
+ try:
+ resolver.set_domain(dname)
+ ret = resolver.domain()
+ if not isinstance(ret, ldns.ldns_dname):
+ set_error()
+ if ret != dname:
+ set_error()
+ except:
+ set_error()
+ rdf = ldns.ldns_rdf.new_frm_str("example.com.", ldns.LDNS_RDF_TYPE_DNAME)
+ try:
+ resolver.set_domain(rdf)
+ ret = resolver.domain()
+ if not isinstance(ret, ldns.ldns_rdf):
+ set_error()
+ if ret != dname:
+ set_error()
+ except:
+ set_error()
+ resolver.set_domain("example.com.")
+ try:
+ resolver.set_domain("example.com.")
+ ret = resolver.domain()
+ if not isinstance(ret, ldns.ldns_dname):
+ set_error()
+ if ret != dname:
+ set_error()
+ except:
+ set_error()
+ rdf = ldns.ldns_rdf.new_frm_str("127.0.0.1", ldns.LDNS_RDF_TYPE_A)
+ try:
+ resolver.set_domain(rdf)
+ set_error()
+ except Exception as e:
+ pass
+ except:
+ set_error()
+ try:
+ resolver.set_domain(1)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_edns_udp_size()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_edns_udp_size(4096)
+ ret = resolver.edns_udp_size()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 4096:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_edns_udp_size("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ ste_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_fail()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_fail(False)
+ ret = resolver.fail()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_fail(True)
+ ret = resolver.fail()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_fallback()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_fallback(False)
+ ret = resolver.fallback()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_fallback(True)
+ ret = resolver.fallback()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_igntc()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_igntc(False)
+ ret = resolver.igntc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_igntc(True)
+ ret = resolver.igntc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_ip6()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_ip6(1)
+ ret = resolver.ip6()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 1:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_ip6("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ ste_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_nameserver_count()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_nameserver_count(2)
+ ret = resolver.nameserver_count()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 2:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_nameserver_count("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_nameserver_rtt()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ num = resolver.nameserver_count()
+ try:
+ for i in range(0, num):
+ resolver.set_nameserver_rtt(i, i + 1)
+ ret = resolver.nameserver_rtt(i)
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if (i + 1) != ret:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.set_nameserver_rtt("bad argument", 0)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+ try:
+ ret = resolver.set_nameserver_rtt(0, "bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_nameservers()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_port()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_port(12345)
+ ret = resolver.port()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 12345:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_port("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_random()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_random(False)
+ ret = resolver.random()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_random(True)
+ ret = resolver.random()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_recursive()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_recursive(False)
+ ret = resolver.recursive()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_recursive(True)
+ ret = resolver.recursive()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_retrans()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_retrans(127)
+ ret = resolver.retrans()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 127:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_retrans("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_retry()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_retry(4)
+ ret = resolver.retry()
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
+ set_error()
+ if ret != 4:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_retry("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_rtt()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_timeout()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_tsig_algorithm()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ tsigstr = "hmac-md5.sig-alg.reg.int."
+ try:
+ resolver.set_tsig_algorithm(tsigstr)
+ ret = resolver.tsig_algorithm()
+ if not isinstance(ret, str):
+ set_error()
+ if ret != tsigstr:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_tsig_algorithm(1)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_tsig_keydata()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ tkdstr = "Humpty Dumpty sat on a wall, Humpty Dumpty had a great fall, All the King's horses and all the King's men, Couldn't put Humpty together again."
+ try:
+ resolver.set_tsig_keydata(tkdstr)
+ ret = resolver.tsig_keydata()
+ if not isinstance(ret, str):
+ set_error()
+ if ret != tkdstr:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_tsig_keydata(1)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_tsig_keyname()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ tknstr = "key 1"
+ try:
+ resolver.set_tsig_keyname(tknstr)
+ ret = resolver.tsig_keyname()
+ if not isinstance(ret, str):
+ set_error()
+ if ret != tknstr:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_tsig_keyname(1)
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".set_usevc()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ resolver.set_usevc(False)
+ ret = resolver.usevc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ try:
+ resolver.set_usevc(True)
+ ret = resolver.usevc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".timeout()"
+ sys.stderr.write("%s not tested.\n" % (method_name))
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".trusted_key()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ key = ldns.ldns_key.new_frm_algorithm(ldns.LDNS_SIGN_DSA, 512)
+ domain = ldns.ldns_dname("example.")
+ key.set_pubkey_owner(domain)
+ pubkey = key.key_to_rr()
+ ds = ldns.ldns_key_rr2ds(pubkey, ldns.LDNS_SHA1)
+ resolver.push_dnssec_anchor(ds)
+ rrl = ldns.ldns_rr_list.new()
+ try:
+ ret = resolver.trusted_key(rrl)
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ rrl.push_rr(ds)
+ ret = resolver.trusted_key(rrl)
+ try:
+ ret = resolver.trusted_key(rrl)
+ if not isinstance(ret, ldns.ldns_rr_list):
+ set_error()
+ if ret.rr_count() != 1:
+ set_error()
+ except:
+ set_error()
+ try:
+ ret = resolver.trusted_key("bad argument")
+ set_error()
+ except TypeError as e:
+ pass
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".tsig_algorithm()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.tsig_algorithm()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ tsigstr = "hmac-md5.sig-alg.reg.int."
+ resolver.set_tsig_algorithm(tsigstr)
+ try:
+ ret = resolver.tsig_algorithm()
+ if not isinstance(ret, str):
+ set_error()
+ if ret != tsigstr:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".tsig_keydata()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.tsig_keydata()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ tkdstr = "Twas brillig, and the slithy toves Did gyre and gimble in the wabe; All mimsy were the borogoves, And the mome raths outgrabe."
+ resolver.set_tsig_keydata(tkdstr)
+ try:
+ ret = resolver.tsig_keydata()
+ if not isinstance(ret, str):
+ set_error()
+ if ret != tkdstr:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".tsig_keyname()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ try:
+ ret = resolver.tsig_keyname()
+ if ret != None:
+ set_error()
+ except:
+ set_error()
+ tknstr = "key 2"
+ resolver.set_tsig_keyname(tknstr)
+ try:
+ ret = resolver.tsig_keyname()
+ if not isinstance(ret, str):
+ set_error()
+ if ret != tknstr:
+ set_error()
+ except:
+ set_error()
+
+
+#if not error_detected:
+if True:
+ method_name = class_name + ".usevc()"
+ resolver = ldns.ldns_resolver.new_frm_file("/etc/resolv.conf")
+ resolver.set_usevc(False)
+ try:
+ ret = resolver.usevc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != False:
+ set_error()
+ except:
+ set_error()
+ resolver.set_usevc(True)
+ try:
+ ret = resolver.usevc()
+ if not isinstance(ret, bool):
+ set_error()
+ if ret != True:
+ set_error()
+ except:
+ set_error()
+
+
+if not error_detected:
+ sys.stdout.write("%s: passed.\n" % (os.path.basename(__file__)))
+else:
+ sys.stdout.write("%s: errors detected.\n" % (os.path.basename(__file__)))
+ sys.exit(1)
diff --git a/contrib/python/examples/test_rr.py b/contrib/python/examples/test_rr.py
index b7bc1e0d..07ba0e74 100644..100755
--- a/contrib/python/examples/test_rr.py
+++ b/contrib/python/examples/test_rr.py
@@ -385,7 +385,7 @@ if True:
pubkey = ldns.ldns_rr.new_frm_str("example1. 3600 IN DNSKEY 256 3 3 APw7tG8Nf7MYXjt2Y6DmyWUVxVy73bRKvKbKoGXhAXJx2vbcGGxfXsScT0i4FIC2wsJ/8zy/otB5vymm3JHBf2+7cQvRdp12UMLAnzlfrbgZUpvV36D+q6ch7kbmFzaBfwRjOKhnZkRLCcMYPAdX1SrgKVNXaOzAl9KytbzGQs5MKEHU+a0PAwKfIvEsS/+pW6gKgBnL0uy4Gr5cYJ5rk48iwFXOlZ/B30gUS5dD+rNRJuR0ZgEkxtVIPVxxhQPtEI53JhlJ2nEy0CqNW88nYLmX402b ;{id = 34898 (zsk), size = 512b}")
try:
ret = pubkey.dnskey_key_size()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 512:
set_error()
@@ -394,7 +394,7 @@ if True:
rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0")
try:
ret = rr.dnskey_key_size()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 0:
set_error()
@@ -638,7 +638,7 @@ if True:
rr = ldns.ldns_rr.new_frm_str("test.dom. IN A 0.0.0.0", 600)
try:
ret = rr.label_count()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 2:
set_error()
@@ -647,7 +647,7 @@ if True:
rr = ldns.ldns_rr.new_frm_str(". IN A 0.0.0.0", 600)
try:
ret = rr.label_count()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error(string)
if ret != 0:
set_error()
@@ -951,7 +951,7 @@ if True:
rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0")
try:
ret = rr.rd_count()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 1:
set_error()
@@ -1643,7 +1643,7 @@ if True:
rr = ldns.ldns_rr.new_frm_str("test 600 IN A 0.0.0.0")
try:
ret = rr.uncompressed_size()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 20:
set_error()
@@ -1723,7 +1723,7 @@ if True:
desc_a = ldns.ldns_rr_descriptor.ldns_rr_descriptor(ldns.LDNS_RR_TYPE_A)
try:
ret = desc_a.maximum()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 1:
set_error()
@@ -1737,7 +1737,7 @@ if True:
desc_a = ldns.ldns_rr_descriptor.ldns_rr_descriptor(ldns.LDNS_RR_TYPE_A)
try:
ret = desc_a.minimum()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 1:
set_error()
@@ -2203,7 +2203,7 @@ if True:
rrl = ldns.ldns_rr_list.new()
try:
ret = rrl.rr_count()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 0:
set_error()
@@ -2213,7 +2213,7 @@ if True:
rrl.push_rr(rr)
try:
ret = rrl.rr_count()
- if not isinstance(ret, int):
+ if (not isinstance(ret, int)) and (not isinstance(ret, long)):
set_error()
if ret != 1:
set_error()
diff --git a/contrib/python/ldns_packet.i b/contrib/python/ldns_packet.i
index 9316479f..eeff4aa2 100644
--- a/contrib/python/ldns_packet.i
+++ b/contrib/python/ldns_packet.i
@@ -14,8 +14,8 @@
* 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 organization nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * 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
@@ -28,17 +28,26 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- ******************************************************************************/
+ *****************************************************************************/
+
+
+/* ========================================================================= */
+/* SWIG setting and definitions. */
+/* ========================================================================= */
+
+/* Creates a temporary instance of (ldns_pkt *). */
%typemap(in,numinputs=0,noblock=1) (ldns_pkt **)
{
- ldns_pkt *$1_pkt;
- $1 = &$1_pkt;
+ ldns_pkt *$1_pkt;
+ $1 = &$1_pkt;
}
-/* result generation */
+/* Result generation, appends (ldns_pkt *) after the result. */
%typemap(argout,noblock=1) (ldns_pkt **)
{
- $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_pkt), SWIGTYPE_p_ldns_struct_pkt, SWIG_POINTER_OWN | 0 ));
+ $result = SWIG_Python_AppendOutput($result,
+ SWIG_NewPointerObj(SWIG_as_voidptr($1_pkt),
+ SWIGTYPE_p_ldns_struct_pkt, SWIG_POINTER_OWN | 0 ));
}
%newobject ldns_pkt_new;
@@ -49,83 +58,322 @@
%newobject ldns_update_pkt_new;
-%nodefaultctor ldns_struct_pkt; //no default constructor & destructor
-%nodefaultdtor ldns_struct_pkt;
+%nodefaultctor ldns_struct_pkt; /* No default constructor. */
+%nodefaultdtor ldns_struct_pkt; /* No default destructor. */
%rename(ldns_pkt) ldns_struct_pkt;
-#ifdef LDNS_DEBUG
-%rename(__ldns_pkt_free) ldns_pkt_free;
-%inline %{
-void _ldns_pkt_free (ldns_pkt* p) {
- printf("******** LDNS_PKT free 0x%lX ************\n", (long unsigned int)p);
- ldns_pkt_free(p);
-}
-%}
-#else
-%rename(_ldns_pkt_free) ldns_pkt_free;
-#endif
%newobject ldns_pkt2str;
%newobject ldns_pkt_opcode2str;
%newobject ldns_pkt_rcode2str;
%newobject ldns_pkt_algorithm2str;
%newobject ldns_pkt_cert_algorithm2str;
+%newobject ldns_pkt_get_section_clone;
-/* cloning of packet_lists to make them independent of the original packet */
+/* Clone data on pull. */
-%newobject _ldns_pkt_additional;
-%newobject _ldns_pkt_answer;
-%newobject _ldns_pkt_authority;
-%newobject _ldns_pkt_question;
+%newobject _ldns_pkt_additional;
%rename(__ldns_pkt_additional) ldns_pkt_additional;
-%inline %{
-ldns_rr_list* _ldns_pkt_additional(ldns_pkt* p) {
- return ldns_rr_list_clone(ldns_pkt_additional(p));
-}
+%inline
+%{
+ ldns_rr_list * _ldns_pkt_additional(ldns_pkt *p)
+ {
+ return ldns_rr_list_clone(ldns_pkt_additional(p));
+ }
%}
+%newobject _ldns_pkt_answer;
%rename(__ldns_pkt_answer) ldns_pkt_answer;
-%inline %{
-ldns_rr_list* _ldns_pkt_answer(ldns_pkt* p) {
- return ldns_rr_list_clone(ldns_pkt_answer(p));
-}
+%inline
+%{
+ ldns_rr_list * _ldns_pkt_answer(ldns_pkt *p)
+ {
+ return ldns_rr_list_clone(ldns_pkt_answer(p));
+ }
%}
+%newobject _ldns_pkt_answerfrom;
+%rename(__ldns_pkt_answerfrom) ldns_pkt_answerfrom;
+%inline
+%{
+ ldns_rdf * _ldns_pkt_answerfrom(ldns_pkt *p)
+ {
+ ldns_rdf *rdf;
+
+ rdf = ldns_pkt_answerfrom(p);
+ if (rdf != NULL) {
+ rdf = ldns_rdf_clone(rdf);
+ }
+ return rdf;
+ }
+%}
+
+%newobject _ldns_pkt_authority;
%rename(__ldns_pkt_authority) ldns_pkt_authority;
-%inline %{
-ldns_rr_list* _ldns_pkt_authority(ldns_pkt* p) {
- return ldns_rr_list_clone(ldns_pkt_authority(p));
-}
+%inline
+%{
+ ldns_rr_list * _ldns_pkt_authority(ldns_pkt *p)
+ {
+ return ldns_rr_list_clone(ldns_pkt_authority(p));
+ }
+%}
+
+%newobject _ldns_pkt_edns_data;
+%rename(__ldns_pkt_edns_data) ldns_pkt_edns_data;
+%inline
+%{
+ ldns_rdf * _ldns_pkt_edns_data(ldns_pkt *p)
+ {
+ ldns_rdf *rdf;
+
+ rdf = ldns_pkt_edns_data(p);
+ if (rdf != NULL) {
+ rdf = ldns_rdf_clone(rdf);
+ }
+ return rdf;
+ }
%}
+%newobject _ldns_pkt_tsig;
+%rename(__ldns_pkt_tsig) ldns_pkt_tsig;
+%inline
+%{
+ ldns_rr * _ldns_pkt_tsig(const ldns_pkt *pkt)
+ {
+ return ldns_rr_clone(ldns_pkt_tsig(pkt));
+ }
+%}
+
+%newobject _ldns_pkt_question;
%rename(__ldns_pkt_question) ldns_pkt_question;
-%inline %{
-ldns_rr_list* _ldns_pkt_question(ldns_pkt* p) {
- return ldns_rr_list_clone(ldns_pkt_question(p));
-}
+%inline
+%{
+ ldns_rr_list * _ldns_pkt_question(ldns_pkt *p)
+ {
+ return ldns_rr_list_clone(ldns_pkt_question(p));
+ }
%}
-/* clone data when pushed in */
+/* End of pull cloning. */
+
+/* Clone data on push. */
+
+%newobject _ldns_pkt_query_new;
+%rename(__ldns_pkt_query_new) ldns_pkt_query_new;
+%inline
+%{
+ ldns_pkt * _ldns_pkt_query_new(ldns_rdf *rr_name, ldns_rr_type rr_type,
+ ldns_rr_class rr_class, uint16_t flags)
+ {
+ return ldns_pkt_query_new(ldns_rdf_clone(rr_name), rr_type, rr_class,
+ flags);
+ }
+%}
%rename(__ldns_pkt_push_rr) ldns_pkt_push_rr;
-%inline %{
-bool _ldns_pkt_push_rr(ldns_pkt* p, ldns_pkt_section sec, ldns_rr *rr) {
- return ldns_pkt_push_rr(p, sec, ldns_rr_clone(rr));
-}
+%inline
+%{
+ bool _ldns_pkt_push_rr(ldns_pkt *p, ldns_pkt_section sec, ldns_rr *rr)
+ {
+ return ldns_pkt_push_rr(p, sec, ldns_rr_clone(rr));
+ }
+%}
+
+%rename(__ldns_pkt_safe_push_rr) ldns_pkt_safe_push_rr;
+%inline
+%{
+ bool _ldns_pkt_safe_push_rr(ldns_pkt *pkt, ldns_pkt_section sec,
+ ldns_rr *rr)
+ {
+ /* Prevents memory leaks when fails. */
+ ldns_rr *rr_clone = NULL;
+ bool ret;
+
+ if (rr != NULL) {
+ rr_clone = ldns_rr_clone(rr);
+ }
+ ret = ldns_pkt_safe_push_rr(pkt, sec, rr_clone);
+ if (!ret) {
+ ldns_rr_free(rr_clone);
+ }
+
+ return ret;
+ }
%}
%rename(__ldns_pkt_push_rr_list) ldns_pkt_push_rr_list;
-%inline %{
-bool _ldns_pkt_push_rr_list(ldns_pkt* p, ldns_pkt_section sec, ldns_rr_list *rrl) {
- return ldns_pkt_push_rr_list(p, sec, ldns_rr_list_clone(rrl));
-}
+%inline
+%{
+ bool _ldns_pkt_push_rr_list(ldns_pkt *p, ldns_pkt_section sec,
+ ldns_rr_list *rrl)
+ {
+ return ldns_pkt_push_rr_list(p, sec, ldns_rr_list_clone(rrl));
+ }
+%}
+
+%rename(__ldns_pkt_safe_push_rr_list) ldns_pkt_safe_push_rr_list;
+%inline
+%{
+ bool _ldns_pkt_safe_push_rr_list(ldns_pkt *p, ldns_pkt_section s,
+ ldns_rr_list *rrl)
+ {
+ /* Prevents memory leaks when fails. */
+ ldns_rr_list *rrl_clone = NULL;
+ bool ret;
+
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ ret = ldns_pkt_safe_push_rr_list(p, s, rrl_clone);
+ if (!ret) {
+ ldns_rr_list_free(rrl_clone);
+ }
+
+ return ret;
+ }
+%}
+
+%rename(__ldns_pkt_set_additional) ldns_pkt_set_additional;
+%inline
+%{
+ void _ldns_pkt_set_additional(ldns_pkt *p, ldns_rr_list *rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_additional(p, rrl_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_answer) ldns_pkt_set_answer;
+%inline
+%{
+ void _ldns_pkt_set_answer(ldns_pkt *p, ldns_rr_list *rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_answer(p, rrl_clone);
+ }
+%}
+
+%rename (__ldns_pkt_set_answerfrom) ldns_pkt_set_answerfrom;
+%inline
+%{
+ void _ldns_pkt_set_answerfrom(ldns_pkt *packet, ldns_rdf *rdf)
+ {
+ ldns_rdf *rdf_clone = NULL;
+ if (rdf != NULL) {
+ rdf_clone = ldns_rdf_clone(rdf);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_answerfrom(packet, rdf_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_authority) ldns_pkt_set_authority;
+%inline
+%{
+ void _ldns_pkt_set_authority(ldns_pkt *p, ldns_rr_list *rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_authority(p, rrl_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_edns_data) ldns_pkt_set_edns_data;
+%inline
+%{
+ void _ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *rdf)
+ {
+ ldns_rdf *rdf_clone = NULL;
+ if (rdf != NULL) {
+ rdf_clone = ldns_rdf_clone(rdf);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_edns_data(packet, rdf_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_question) ldns_pkt_set_question;
+%inline
+%{
+ void _ldns_pkt_set_question(ldns_pkt *p, ldns_rr_list *rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_question(p, rrl_clone);
+ }
+%}
+
+%rename(__ldns_pkt_set_tsig) ldns_pkt_set_tsig;
+%inline
+%{
+ void _ldns_pkt_set_tsig(ldns_pkt *pkt, ldns_rr *rr)
+ {
+ ldns_rr *rr_clone = NULL;
+ if (rr != NULL) {
+ rr_clone = ldns_rr_clone(rr);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_pkt_set_tsig(pkt, rr_clone);
+ }
+%}
+
+/* End of push cloning. */
+
+
+/* ========================================================================= */
+/* Debugging related code. */
+/* ========================================================================= */
+
+#ifdef LDNS_DEBUG
+%rename(__ldns_pkt_free) ldns_pkt_free;
+%inline
+%{
+ /*!
+ * @brief Prints information about deallocated pkt and deallocates.
+ */
+ void _ldns_pkt_free (ldns_pkt* p) {
+ printf("******** LDNS_PKT free 0x%lX ************\n",
+ (long unsigned int) p);
+ ldns_pkt_free(p);
+ }
%}
+#else /* !LDNS_DEBUG */
+%rename(_ldns_pkt_free) ldns_pkt_free;
+#endif /* LDNS_DEBUG */
+
+
+/* ========================================================================= */
+/* Added C code. */
+/* ========================================================================= */
+
+/* None. */
+
+
+/* ========================================================================= */
+/* Encapsulating Python code. */
+/* ========================================================================= */
%feature("docstring") ldns_struct_pkt "LDNS packet object.
-The ldns_pkt object contains DNS packed (either a query or an answer). It is the complete representation of what you actually send to a nameserver, and what you get back (see :class:`ldns.ldns_resolver`).
+The :class:`ldns_pkt` object contains DNS packed (either a query or an answer).
+It is the complete representation of what you actually send to a name server,
+and what you get back (see :class:`ldns.ldns_resolver`).
**Usage**
@@ -148,40 +396,91 @@ nic.cz. 758 IN NS e.ns.nic.cz.
;; WHEN: Thu Jan 11 12:54:33 2009
;; MSG SIZE rcvd: 75
-This simple example instances a resolver in order to resolve NS for nic.cz.
-"
+This simple example instances a resolver in order to resolve NS for nic.cz."
%extend ldns_struct_pkt {
- %pythoncode %{
+ %pythoncode
+ %{
def __init__(self):
- raise Exception("This class can't be created directly. Please use: ldns_pkt_new(), ldns_pkt_query_new() or ldns_pkt_query_new_frm_str()")
+ """
+ Cannot be created directly from Python.
+ """
+ raise Exception("This class can't be created directly. " +
+ "Please use: ldns_pkt_new, ldns_pkt_query_new " +
+ "or ldns_pkt_query_new_frm_str")
__swig_destroy__ = _ldns._ldns_pkt_free
- #LDNS_PKT_CONSTRUCTORS_#
+ #
+ # LDNS_PKT_CONSTRUCTORS_
+ #
+
+ @staticmethod
+ def new():
+ """
+ Creates new empty packet structure.
+
+ :return: (:class:`ldns_pkt` ) New empty packet.
+ """
+ return _ldns.ldns_pkt_new()
+
@staticmethod
def new_query(rr_name, rr_type, rr_class, flags):
- """Creates a packet with a query in it for the given name, type and class.
-
- :param rr_name: the name to query for
- :param rr_type: the type to query for
- :param rr_class: the class to query for
- :param flags: packet flags
- :returns: new ldns_pkt object
"""
- return _ldns.ldns_pkt_query_new(rr_name, rr_type, rr_class, flags)
+ Creates a packet with a query in it for the given name,
+ type and class.
+
+ :param rr_name: The name to query for.
+ :type rr_name: :class:`ldns_dname`
+ :param rr_type: The type to query for.
+ :type rr_type: ldns_rr_type
+ :param rr_class: The class to query for.
+ :type rr_class: ldns_rr_class
+ :param flags: Packet flags.
+ :type flags: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_pkt`) New object.
+
+ .. note::
+ The type checking of parameter `rr_name` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
+ """
+ if (not isinstance(rr_name, ldns_dname)) and \
+ isinstance(rr_name, ldns_rdf) and \
+ rr_name.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_pkt.new_query() method will" +
+ " drop the possibility to accept ldns_rdf." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
+ if not isinstance(rr_name, ldns_rdf):
+ raise TypeError("Parameter must be derived from ldns_rdf.")
+ if (rr_name.get_type() != _ldns.LDNS_RDF_TYPE_DNAME):
+ raise Exception("Operands must be ldns_dname.")
+ return _ldns._ldns_pkt_query_new(rr_name, rr_type, rr_class, flags)
@staticmethod
def new_query_frm_str(rr_name, rr_type, rr_class, flags, raiseException = True):
- """Creates a query packet for the given name, type, class.
-
- :param rr_name: the name to query for
- :param rr_type: the type to query for
- :param rr_class: the class to query for
- :param flags: packet flags
- :param raiseException: if True, an exception occurs in case a resolver object can't be created
- :returns: query packet object or None. If the object can't be created and raiseException is True, an exception occurs.
+ """
+ Creates a query packet for the given name, type, class.
+
+ :param rr_name: The name to query for.
+ :type rr_name: str
+ :param rr_type: The type to query for.
+ :type rr_type: ldns_rr_type
+ :param rr_class: The class to query for.
+ :type rr_class: ldns_rr_class
+ :param flags: Packet flags.
+ :type flags: uint16_t
+ :param raiseException: If True, an exception occurs in case a
+ packet object can't be created.
+ :throws TypeError: When arguments of inappropriate types.
+ :throws Exception: When raiseException set and packet couldn't
+ be created.
+ :return: (:class:`ldns_pkt`) Query packet object or None.
+ If the object can't be created and raiseException is True,
+ an exception occurs.
**Usage**
@@ -209,30 +508,57 @@ This simple example instances a resolver in order to resolve NS for nic.cz.
if (raiseException): raise Exception("Can't create query packet, error: %d" % status)
return None
return pkt
- #_LDNS_PKT_CONSTRUCTORS#
+
+ #
+ # _LDNS_PKT_CONSTRUCTORS
+ #
def __str__(self):
- """Converts the data in the DNS packet to presentation format"""
+ """
+ Converts the data in the DNS packet to presentation format.
+
+ :return: (str)
+ """
return _ldns.ldns_pkt2str(self)
def opcode2str(self):
- """Converts a packet opcode to its mnemonic and returns that as an allocated null-terminated string."""
+ """
+ Converts a packet opcode to its mnemonic and returns that as an
+ allocated null-terminated string.
+
+ :return: (str)
+ """
return _ldns.ldns_pkt_opcode2str(self.get_opcode())
def rcode2str(self):
- """Converts a packet rcode to its mnemonic and returns that as an allocated null-terminated string."""
+ """
+ Converts a packet rcode to its mnemonic and returns that as an
+ allocated null-terminated string.
+
+ :return: (str)
+ """
return _ldns.ldns_pkt_rcode2str(self.get_rcode())
- def print_to_file(self,output):
- """Prints the data in the DNS packet to the given file stream (in presentation format)."""
- _ldns.ldns_pkt_print(output,self)
+ def print_to_file(self, output):
+ """
+ Prints the data in the DNS packet to the given file stream
+ (in presentation format).
+
+ :param output: Opened file to write to.
+ :type output: file
+ :throws TypeError: When arguments of inappropriate types.
+ """
+ _ldns.ldns_pkt_print(output, self)
#parameters: FILE *,const ldns_pkt *,
def write_to_buffer(self, buffer):
- """Copies the packet data to the buffer in wire format.
+ """
+ Copies the packet data to the buffer in wire format.
- :param buffer: buffer to append the result to
- :returns: (ldns_status) ldns_status
+ :param buffer: Buffer to append the result to.
+ :type buffer: :class:`ldns_buffer`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) ldns_status
"""
return _ldns.ldns_pkt2buffer_wire(buffer, self)
#parameters: ldns_buffer *,const ldns_pkt *,
@@ -240,847 +566,1023 @@ This simple example instances a resolver in order to resolve NS for nic.cz.
@staticmethod
def algorithm2str(alg):
- """Converts a signing algorithms to its mnemonic and returns that as an allocated null-terminated string."""
+ """
+ Converts a signing algorithms to its mnemonic and returns that
+ as an allocated null-terminated string.
+
+ :param alg: The algorithm to convert to text.
+ :type alg: ldns_algorithm
+ :return: (str)
+ """
return _ldns.ldns_pkt_algorithm2str(alg)
#parameters: ldns_algorithm,
@staticmethod
def cert_algorithm2str(alg):
- """Converts a cert algorithm to its mnemonic and returns that as an allocated null-terminated string."""
+ """
+ Converts a cert algorithm to its mnemonic and returns that as an
+ allocated null-terminated string.
+
+ :param alg: Cert algorithm to convert to text.
+ :type alg: ldns_cert_algorithm
+ :return: (str)
+ """
return _ldns.ldns_pkt_cert_algorithm2str(alg)
#parameters: ldns_algorithm,
- #LDNS_PKT_METHODS_#
+ #
+ # LDNS_PKT_METHODS_
+ #
+
def aa(self):
- """Read the packet's aa bit.
+ """
+ Read the packet's aa bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_aa(self)
#parameters: const ldns_pkt *,
#retvals: bool
def ad(self):
- """Read the packet's ad bit.
+ """
+ Read the packet's ad bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_ad(self)
#parameters: const ldns_pkt *,
#retvals: bool
def additional(self):
- """Return the packet's additional section.
+ """
+ Return the packet's additional section.
- :returns: (ldns_rr_list \*) the section
+ :return: (:class:`ldns_rr_list`) The additional section.
"""
return _ldns._ldns_pkt_additional(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def all(self):
+ """
+ Return the packet's question, answer, authority and additional
+ sections concatenated.
+
+ :return: (:class:`ldns_rr_list`) Concatenated sections.
+ """
return _ldns.ldns_pkt_all(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def all_noquestion(self):
+ """
+ Return the packet's answer, authority and additional sections
+ concatenated.
+ Like :meth:`all` but without the questions.
+
+ :return: (:class:`ldns_rr_list`) Concatenated sections except
+ questions.
+ """
return _ldns.ldns_pkt_all_noquestion(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def ancount(self):
- """Return the packet's an count.
+ """
+ Return the packet's an count.
- :returns: (uint16_t) the an count
+ :return: (int) The an count.
"""
return _ldns.ldns_pkt_ancount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def answer(self):
- """Return the packet's answer section.
+ """
+ Return the packet's answer section.
- :returns: (ldns_rr_list \*) the section
+ :return: (:class:`ldns_rr_list`) The answer section.
"""
return _ldns._ldns_pkt_answer(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def answerfrom(self):
- """Return the packet's answerfrom.
+ """
+ Return the packet's answerfrom.
- :returns: (ldns_rdf \*) the name of the server
+ :return: (:class:`ldns_rdf`) The name of the server.
"""
- return _ldns.ldns_pkt_answerfrom(self)
+ return _ldns._ldns_pkt_answerfrom(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rdf *
def arcount(self):
- """Return the packet's ar count.
+ """
+ Return the packet's ar count.
- :returns: (uint16_t) the ar count
+ :return: (int) The ar count.
"""
return _ldns.ldns_pkt_arcount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def authority(self):
- """Return the packet's authority section.
+ """
+ Return the packet's authority section.
- :returns: (ldns_rr_list \*) the section
+ :return: (:class:`ldns_rr_list`) The authority section.
"""
return _ldns._ldns_pkt_authority(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def cd(self):
- """Read the packet's cd bit.
+ """
+ Read the packet's cd bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_cd(self)
#parameters: const ldns_pkt *,
#retvals: bool
def clone(self):
- """clones the given packet, creating a fully allocated copy
+ """
+ Clones the packet, creating a fully allocated copy.
- :returns: (ldns_pkt \*) ldns_pkt* pointer to the new packet
+ :return: (:class:`ldns_pkt`) New packet clone.
"""
return _ldns.ldns_pkt_clone(self)
#parameters: ldns_pkt *,
#retvals: ldns_pkt *
def edns(self):
- """returns true if this packet needs and EDNS rr to be sent.
+ """
+ Returns True if this packet needs and EDNS rr to be sent.
- At the moment the only reason is an expected packet size larger than 512 bytes, but for instance dnssec would be a good reason too.
+ At the moment the only reason is an expected packet size larger
+ than 512 bytes, but for instance DNSSEC would be a good reason
+ too.
- :returns: (bool) true if packet needs edns rr
+ :return: (bool) True if packet needs EDNS rr.
"""
return _ldns.ldns_pkt_edns(self)
#parameters: const ldns_pkt *,
#retvals: bool
def edns_data(self):
- """return the packet's edns data
+ """
+ Return the packet's edns data.
- :returns: (ldns_rdf \*) the data
+ :return: (:class:`ldns_rdf`) The ensd data.
"""
- return _ldns.ldns_pkt_edns_data(self)
+ return _ldns._ldns_pkt_edns_data(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rdf *
def edns_do(self):
- """return the packet's edns do bit
+ """
+ Return the packet's edns do bit
- :returns: (bool) the bit's value
+ :return: (bool) The bit's value.
"""
return _ldns.ldns_pkt_edns_do(self)
#parameters: const ldns_pkt *,
#retvals: bool
def edns_extended_rcode(self):
- """return the packet's edns extended rcode
+ """
+ Return the packet's edns extended rcode.
- :returns: (uint8_t) the rcode
+ :return: (uint8_t) The rcode.
"""
return _ldns.ldns_pkt_edns_extended_rcode(self)
#parameters: const ldns_pkt *,
#retvals: uint8_t
def edns_udp_size(self):
- """return the packet's edns udp size
+ """
+ Return the packet's edns udp size.
- :returns: (uint16_t) the size
+ :return: (uint16_t) The udp size.
"""
return _ldns.ldns_pkt_edns_udp_size(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def edns_version(self):
- """return the packet's edns version
+ """
+ Return the packet's edns version.
- :returns: (uint8_t) the version
+ :return: (uint8_t) The edns version.
"""
return _ldns.ldns_pkt_edns_version(self)
#parameters: const ldns_pkt *,
#retvals: uint8_t
def edns_z(self):
- """return the packet's edns z value
+ """
+ Return the packet's edns z value.
- :returns: (uint16_t) the z value
+ :return: (uint16_t) The z value.
"""
return _ldns.ldns_pkt_edns_z(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def empty(self):
- """check if a packet is empty
+ """
+ Check if a packet is empty.
- :returns: (bool) true: empty, false: empty
+ :return: (bool) True: empty, False: not empty
"""
return _ldns.ldns_pkt_empty(self)
#parameters: ldns_pkt *,
#retvals: bool
def get_opcode(self):
- """Read the packet's code.
+ """
+ Read the packet's code.
- :returns: (ldns_pkt_opcode) the opcode
+ :return: (ldns_pkt_opcode) the opcode
"""
return _ldns.ldns_pkt_get_opcode(self)
#parameters: const ldns_pkt *,
#retvals: ldns_pkt_opcode
def get_rcode(self):
- """Return the packet's respons code.
+ """
+ Return the packet's response code.
- :returns: (ldns_pkt_rcode) the respons code
+ :return: (ldns_pkt_rcode) The response code.
"""
return _ldns.ldns_pkt_get_rcode(self)
#parameters: const ldns_pkt *,
#retvals: ldns_pkt_rcode
- def get_section_clone(self,s):
- """return all the rr_list's in the packet.
-
- Clone the lists, instead of returning pointers.
+ def get_section_clone(self, s):
+ """
+ Return the selected rr_list's in the packet.
- :param s:
- what section(s) to return
- :returns: (ldns_rr_list \*) ldns_rr_list with the rr's or NULL if none were found
+ :param s: What section(s) to return.
+ :type s: ldns_pkt_section
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) RR list with the rr's or None
+ if none were found.
"""
- return _ldns.ldns_pkt_get_section_clone(self,s)
+ return _ldns.ldns_pkt_get_section_clone(self, s)
#parameters: const ldns_pkt *,ldns_pkt_section,
#retvals: ldns_rr_list *
def id(self):
- """Read the packet id.
+ """
+ Read the packet id.
- :returns: (uint16_t) the packet id
+ :return: (uint16_t) The packet id.
"""
return _ldns.ldns_pkt_id(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def nscount(self):
- """Return the packet's ns count.
+ """
+ Return the packet's ns count.
- :returns: (uint16_t) the ns count
+ :return: (uint16_t) The ns count.
"""
return _ldns.ldns_pkt_nscount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
- def push_rr(self,section,rr):
- """push an rr on a packet
+ def push_rr(self, section, rr):
+ """
+ Push an rr on a packet.
- :param section:
- where to put it
- :param rr:
- rr to push
- :returns: (bool) a boolean which is true when the rr was added
+ :param section: Where to put it.
+ :type section: ldns_pkt_section
+ :param rr: RR to push.
+ :type rr: :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) A boolean which is True when the rr was added.
"""
return _ldns._ldns_pkt_push_rr(self,section,rr)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *,
#retvals: bool
- def push_rr_list(self,section,list):
- """push a rr_list on a packet
+ def push_rr_list(self, section, list):
+ """
+ Push a rr_list on a packet.
- :param section:
- where to put it
- :param list:
- the rr_list to push
- :returns: (bool) a boolean which is true when the rr was added
+ :param section: Where to put it.
+ :type section: ldns_pkt_section
+ :param list: The rr_list to push.
+ :type list: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) A boolean which is True when the rr was added.
"""
return _ldns._ldns_pkt_push_rr_list(self,section,list)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr_list *,
#retvals: bool
def qdcount(self):
- """Return the packet's qd count.
+ """
+ Return the packet's qd count.
- :returns: (uint16_t) the qd count
+ :return: (uint16_t) The qd count.
"""
return _ldns.ldns_pkt_qdcount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def qr(self):
- """Read the packet's qr bit.
+ """
+ Read the packet's qr bit.
- :returns: (bool) value of the bit
+ :return: (bool) value of the bit
"""
return _ldns.ldns_pkt_qr(self)
#parameters: const ldns_pkt *,
#retvals: bool
def querytime(self):
- """Return the packet's querytime.
+ """
+ Return the packet's query time.
- :returns: (uint32_t) the querytime
+ :return: (uint32_t) The query time.
"""
return _ldns.ldns_pkt_querytime(self)
#parameters: const ldns_pkt *,
#retvals: uint32_t
def question(self):
- """Return the packet's question section.
+ """
+ Return the packet's question section.
- :returns: (ldns_rr_list \*) the section
+ :return: (:class:`ldns_rr_list`) The question section.
"""
return _ldns._ldns_pkt_question(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr_list *
def ra(self):
- """Read the packet's ra bit.
+ """
+ Read the packet's ra bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_ra(self)
#parameters: const ldns_pkt *,
#retvals: bool
def rd(self):
- """Read the packet's rd bit.
+ """
+ Read the packet's rd bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_rd(self)
#parameters: const ldns_pkt *,
#retvals: bool
def reply_type(self):
- """looks inside the packet to determine what kind of packet it is, AUTH, NXDOMAIN, REFERRAL, etc.
+ """
+ Looks inside the packet to determine what kind of packet it is,
+ AUTH, NXDOMAIN, REFERRAL, etc.
- :returns: (ldns_pkt_type) the type of packet
+ :return: (ldns_pkt_type) The type of packet.
"""
return _ldns.ldns_pkt_reply_type(self)
#parameters: ldns_pkt *,
#retvals: ldns_pkt_type
- def rr(self,sec,rr):
- """check to see if an rr exist in the packet
+ def rr(self, sec, rr):
+ """
+ Check to see if an rr exist in the packet.
- :param sec:
- in which section to look
- :param rr:
- the rr to look for
- :returns: (bool)
+ :param sec: In which section to look.
+ :type sec: ldns_pkt_section
+ :param rr: The rr to look for.
+ :type rr: :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) Return True is exists.
"""
- return _ldns.ldns_pkt_rr(self,sec,rr)
+ return _ldns.ldns_pkt_rr(self, sec, rr)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *,
#retvals: bool
- def rr_list_by_name(self,r,s):
- """return all the rr with a specific name from a packet.
-
- Optionally specify from which section in the packet
+ def rr_list_by_name(self, r, s):
+ """
+ Return all the rr with a specific name from a packet.
- :param r:
- the name
- :param s:
- the packet's section
- :returns: (ldns_rr_list \*) a list with the rr's or NULL if none were found
+ :param r: The name.
+ :type r: :class:`ldns_rdf`
+ :param s: The packet's section.
+ :type s: ldns_pkt_section
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) A list with the rr's or None
+ if none were found.
"""
return _ldns.ldns_pkt_rr_list_by_name(self,r,s)
#parameters: ldns_pkt *,ldns_rdf *,ldns_pkt_section,
#retvals: ldns_rr_list *
- def rr_list_by_name_and_type(self,ownername,atype,sec):
- """return all the rr with a specific type and type from a packet.
-
- Optionally specify from which section in the packet
+ def rr_list_by_name_and_type(self, ownername, atype, sec):
+ """
+ Return all the rr with a specific type and type from a packet.
- :param ownername:
- the name
- :param atype:
- :param sec:
- the packet's section
- :returns: (ldns_rr_list \*) a list with the rr's or NULL if none were found
+ :param ownername: The name.
+ :type ownername: :class:`ldns_rdf`
+ :param atype: The type.
+ :type atype: ldns_rr_type
+ :param sec: The packet's section.
+ :type sec: ldns_pkt_section
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) A list with the rr's or None
+ if none were found.
"""
- return _ldns.ldns_pkt_rr_list_by_name_and_type(self,ownername,atype,sec)
+ return _ldns.ldns_pkt_rr_list_by_name_and_type(self, ownername, atype, sec)
#parameters: const ldns_pkt *,const ldns_rdf *,ldns_rr_type,ldns_pkt_section,
#retvals: ldns_rr_list *
- def rr_list_by_type(self,t,s):
- """return all the rr with a specific type from a packet.
-
- Optionally specify from which section in the packet
+ def rr_list_by_type(self, t, s):
+ """
+ Return all the rr with a specific type from a packet.
- :param t:
- the type
- :param s:
- the packet's section
- :returns: (ldns_rr_list \*) a list with the rr's or NULL if none were found
+ :param t: The type.
+ :type t: ldns_rr_type
+ :param s: The packet's section.
+ :type s: ldns_pkt_section
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) A list with the rr's or None
+ if none were found.
"""
- return _ldns.ldns_pkt_rr_list_by_type(self,t,s)
+ return _ldns.ldns_pkt_rr_list_by_type(self, t, s)
#parameters: const ldns_pkt *,ldns_rr_type,ldns_pkt_section,
#retvals: ldns_rr_list *
- def safe_push_rr(self,sec,rr):
- """push an rr on a packet, provided the RR is not there.
+ def safe_push_rr(self, sec, rr):
+ """
+ Push an rr on a packet, provided the RR is not there.
- :param sec:
- where to put it
- :param rr:
- rr to push
- :returns: (bool) a boolean which is true when the rr was added
+ :param sec: Where to put it.
+ :type sec: ldns_pkt_section
+ :param rr: RR to push.
+ :type rr: :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) A boolean which is True when the rr was added.
"""
- return _ldns.ldns_pkt_safe_push_rr(self,sec,rr)
+ return _ldns._ldns_pkt_safe_push_rr(self,sec,rr)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr *,
#retvals: bool
- def safe_push_rr_list(self,sec,list):
- """push an rr_list to a packet, provided the RRs are not already there.
+ def safe_push_rr_list(self, sec, list):
+ """
+ Push an rr_list to a packet, provided the RRs are not already
+ there.
- :param sec:
- where to put it
- :param list:
- the rr_list to push
- :returns: (bool) a boolean which is true when the rr was added
+ :param sec: Where to put it.
+ :type sec: ldns_pkt_section
+ :param list: The rr_list to push.
+ :type list: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) A boolean which is True when the list was added.
"""
- return _ldns.ldns_pkt_safe_push_rr_list(self,sec,list)
+ return _ldns._ldns_pkt_safe_push_rr_list(self, sec, list)
#parameters: ldns_pkt *,ldns_pkt_section,ldns_rr_list *,
#retvals: bool
- def section_count(self,s):
- return _ldns.ldns_pkt_section_count(self,s)
- #parameters: const ldns_pkt *,ldns_pkt_section,
- #retvals: uint16_t
-
- def set_aa(self,b):
- """Set the packet's aa bit.
+ def set_aa(self, b):
+ """
+ Set the packet's aa bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_aa(self,b)
+ _ldns.ldns_pkt_set_aa(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_ad(self,b):
- """Set the packet's ad bit.
+ def set_ad(self, b):
+ """
+ Set the packet's ad bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_ad(self,b)
+ _ldns.ldns_pkt_set_ad(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_additional(self,rr):
- """directly set the additional section
+ def set_additional(self, rr):
+ """
+ Directly set the additional section.
- :param rr:
- rrlist to set
+ :param rr: The rr list to set.
+ :type rr: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_additional(self,rr)
+ _ldns._ldns_pkt_set_additional(self, rr)
#parameters: ldns_pkt *,ldns_rr_list *,
#retvals:
- def set_ancount(self,c):
- """Set the packet's an count.
+ def set_ancount(self, c):
+ """
+ Set the packet's an count.
- :param c:
- the count
+ :param c: The count.
+ :type c: int
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_ancount(self,c)
+ _ldns.ldns_pkt_set_ancount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_answer(self,rr):
- """directly set the answer section
+ def set_answer(self, rr):
+ """
+ Directly set the answer section.
- :param rr:
- rrlist to set
+ :param rr: The rr list to set.
+ :type rr: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_answer(self,rr)
+ _ldns._ldns_pkt_set_answer(self, rr)
#parameters: ldns_pkt *,ldns_rr_list *,
#retvals:
- def set_answerfrom(self,r):
- """Set the packet's answering server.
+ def set_answerfrom(self, r):
+ """
+ Set the packet's answering server.
- :param r:
- the address
+ :param r: The address.
+ :type r: :class:`ldns_rdf`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_answerfrom(self,r)
+ _ldns._ldns_pkt_set_answerfrom(self, r)
#parameters: ldns_pkt *,ldns_rdf *,
#retvals:
- def set_arcount(self,c):
- """Set the packet's arcount.
+ def set_arcount(self, c):
+ """
+ Set the packet's arcount.
- :param c:
- the count
+ :param c: The count.
+ :type c: int
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_pkt_set_arcount(self,c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_authority(self,rr):
- """directly set the auhority section
+ def set_authority(self, rr):
+ """
+ Directly set the authority section.
- :param rr:
- rrlist to set
+ :param rr: The rr list to set.
+ :type rr: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_authority(self,rr)
+ _ldns._ldns_pkt_set_authority(self, rr)
#parameters: ldns_pkt *,ldns_rr_list *,
#retvals:
- def set_cd(self,b):
- """Set the packet's cd bit.
+ def set_cd(self, b):
+ """
+ Set the packet's cd bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_cd(self,b)
+ _ldns.ldns_pkt_set_cd(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_edns_data(self,data):
- """Set the packet's edns data.
+ def set_edns_data(self, data):
+ """
+ Set the packet's edns data.
- :param data:
- the data
+ :param data: The data.
+ :type data: :class:`ldns_rdf`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_data(self,data)
+ _ldns._ldns_pkt_set_edns_data(self, data)
#parameters: ldns_pkt *,ldns_rdf *,
#retvals:
- def set_edns_do(self,value):
- """Set the packet's edns do bit.
+ def set_edns_do(self, value):
+ """
+ Set the packet's edns do bit.
- :param value:
- the bit's new value
+ :param value: The bit's new value.
+ :type value: bool
"""
- _ldns.ldns_pkt_set_edns_do(self,value)
+ _ldns.ldns_pkt_set_edns_do(self, value)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_edns_extended_rcode(self,c):
- """Set the packet's edns extended rcode.
+ def set_edns_extended_rcode(self, c):
+ """
+ Set the packet's edns extended rcode.
- :param c:
- the code
+ :param c: The code.
+ :type c: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_extended_rcode(self,c)
+ _ldns.ldns_pkt_set_edns_extended_rcode(self, c)
#parameters: ldns_pkt *,uint8_t,
#retvals:
- def set_edns_udp_size(self,s):
- """Set the packet's edns udp size.
+ def set_edns_udp_size(self, s):
+ """
+ Set the packet's edns udp size.
- :param s:
- the size
+ :param s: The size.
+ :type s: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_udp_size(self,s)
+ _ldns.ldns_pkt_set_edns_udp_size(self, s)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_edns_version(self,v):
- """Set the packet's edns version.
+ def set_edns_version(self, v):
+ """
+ Set the packet's edns version.
- :param v:
- the version
+ :param v: The version.
+ :type v: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_version(self,v)
+ _ldns.ldns_pkt_set_edns_version(self, v)
#parameters: ldns_pkt *,uint8_t,
#retvals:
- def set_edns_z(self,z):
- """Set the packet's edns z value.
+ def set_edns_z(self, z):
+ """
+ Set the packet's edns z value.
- :param z:
- the value
+ :param z: The value.
+ :type z: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_edns_z(self,z)
+ _ldns.ldns_pkt_set_edns_z(self, z)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_flags(self,flags):
- """sets the flags in a packet.
+ def set_flags(self, flags):
+ """
+ Sets the flags in a packet.
- :param flags:
- ORed values: LDNS_QR| LDNS_AR for instance
- :returns: (bool) true on success otherwise false
+ :param flags: ORed values: LDNS_QR| LDNS_AR for instance.
+ :type flags: int
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (bool) True on success, False otherwise.
"""
- return _ldns.ldns_pkt_set_flags(self,flags)
+ return _ldns.ldns_pkt_set_flags(self, flags)
#parameters: ldns_pkt *,uint16_t,
#retvals: bool
- def set_id(self,id):
- """Set the packet's id.
+ def set_id(self, id):
+ """
+ Set the packet's id.
- :param id:
- the id to set
+ :param id: The id to set.
+ :type id: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_id(self,id)
+ _ldns.ldns_pkt_set_id(self, id)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_nscount(self,c):
- """Set the packet's ns count.
+ def set_nscount(self, c):
+ """
+ Set the packet's ns count.
- :param c:
- the count
+ :param c: The count.
+ :type c: int
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_nscount(self,c)
+ _ldns.ldns_pkt_set_nscount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_opcode(self,c):
- """Set the packet's opcode.
+ def set_opcode(self, c):
+ """
+ Set the packet's opcode.
- :param c:
- the opcode
+ :param c: The opcode.
+ :type c: ldns_pkt_opcode
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_opcode(self,c)
+ _ldns.ldns_pkt_set_opcode(self, c)
#parameters: ldns_pkt *,ldns_pkt_opcode,
#retvals:
- def set_qdcount(self,c):
- """Set the packet's qd count.
+ def set_qdcount(self, c):
+ """
+ Set the packet's qd count.
- :param c:
- the count
+ :param c: The count.
+ :type c: int
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_qdcount(self,c)
+ _ldns.ldns_pkt_set_qdcount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def set_qr(self,b):
- """Set the packet's qr bit.
+ def set_qr(self, b):
+ """
+ Set the packet's qr bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_qr(self,b)
+ _ldns.ldns_pkt_set_qr(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_querytime(self,t):
- """Set the packet's query time.
+ def set_querytime(self, t):
+ """
+ Set the packet's query time.
- :param t:
- the querytime in msec
+ :param t: The query time in msec.
+ :type t: uint32_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_querytime(self,t)
+ _ldns.ldns_pkt_set_querytime(self, t)
#parameters: ldns_pkt *,uint32_t,
#retvals:
- def set_question(self,rr):
- """directly set the question section
+ def set_question(self, rr):
+ """
+ Directly set the question section.
- :param rr:
- rrlist to set
+ :param rr: The rr list to set.
+ :type rr: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_question(self,rr)
+ _ldns._ldns_pkt_set_question(self, rr)
#parameters: ldns_pkt *,ldns_rr_list *,
#retvals:
- def set_ra(self,b):
- """Set the packet's ra bit.
+ def set_ra(self, b):
+ """
+ Set the packet's ra bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_ra(self,b)
+ _ldns.ldns_pkt_set_ra(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
def set_random_id(self):
- """Set the packet's id to a random value.
+ """
+ Set the packet's id to a random value.
"""
_ldns.ldns_pkt_set_random_id(self)
#parameters: ldns_pkt *,
#retvals:
- def set_rcode(self,c):
- """Set the packet's respons code.
+ def set_rcode(self, c):
+ """
+ Set the packet's respons code.
- :param c:
- the rcode
+ :param c: The rcode.
+ :type c: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_rcode(self,c)
+ _ldns.ldns_pkt_set_rcode(self, c)
#parameters: ldns_pkt *,uint8_t,
#retvals:
- def set_rd(self,b):
- """Set the packet's rd bit.
+ def set_rd(self, b):
+ """
+ Set the packet's rd bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_rd(self,b)
+ _ldns.ldns_pkt_set_rd(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_section_count(self,s,x):
- """Set a packet's section count to x.
+ def set_section_count(self, s, x):
+ """
+ Set a packet's section count to x.
- :param s:
- the section
- :param x:
- the section count
+ :param s: The section.
+ :type s: ldns_pkt_section
+ :param x: The section count.
+ :type x: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_section_count(self,s,x)
+ _ldns.ldns_pkt_set_section_count(self, s, x)
#parameters: ldns_pkt *,ldns_pkt_section,uint16_t,
#retvals:
- def set_size(self,s):
- """Set the packet's size.
+ def set_size(self, s):
+ """
+ Set the packet's size.
- :param s:
- the size
+ :param s: The size.
+ :type s: int
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_pkt_set_size(self,s)
#parameters: ldns_pkt *,size_t,
#retvals:
- def set_tc(self,b):
- """Set the packet's tc bit.
+ def set_tc(self, b):
+ """
+ Set the packet's tc bit.
- :param b:
- the value to set (boolean)
+ :param b: The value to set.
+ :type b: bool
"""
- _ldns.ldns_pkt_set_tc(self,b)
+ _ldns.ldns_pkt_set_tc(self, b)
#parameters: ldns_pkt *,bool,
#retvals:
- def set_timestamp(self,timeval):
- _ldns.ldns_pkt_set_timestamp(self,timeval)
+ def set_timestamp(self, timeval):
+ """
+ Set the packet's time stamp.
+
+ :param timestamp: The time stamp.
+ :type timestamp: struct timeval
+ :throws TypeError: When arguments of inappropriate types.
+ """
+ _ldns.ldns_pkt_set_timestamp(self, timeval)
#parameters: ldns_pkt *,struct timeval,
#retvals:
- def set_tsig(self,t):
- """Set the packet's tsig rr.
+ def set_tsig(self, t):
+ """
+ Set the packet's tsig rr.
- :param t:
- the tsig rr
+ :param t: The tsig rr.
+ :type t: :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_pkt_set_tsig(self,t)
+ _ldns._ldns_pkt_set_tsig(self, t)
#parameters: ldns_pkt *,ldns_rr *,
#retvals:
def size(self):
- """Return the packet's size in bytes.
+ """
+ Return the packet's size in bytes.
- :returns: (size_t) the size
+ :return: (size_t) The size.
"""
return _ldns.ldns_pkt_size(self)
#parameters: const ldns_pkt *,
#retvals: size_t
def tc(self):
- """Read the packet's tc bit.
+ """
+ Read the packet's tc bit.
- :returns: (bool) value of the bit
+ :return: (bool) Value of the bit.
"""
return _ldns.ldns_pkt_tc(self)
#parameters: const ldns_pkt *,
#retvals: bool
def timestamp(self):
- """Return the packet's timestamp.
+ """
+ Return the packet's time stamp.
- :returns: (struct timeval) the timestamp
+ :return: (struct timeval) The time stamp.
"""
return _ldns.ldns_pkt_timestamp(self)
#parameters: const ldns_pkt *,
#retvals: struct timeval
def tsig(self):
- """Return the packet's tsig pseudo rr's.
+ """
+ Return the packet's tsig pseudo rr's.
- :returns: (ldns_rr \*) the tsig rr
+ :return: (:class:`ldns_rr`) The tsig rr.
"""
- return _ldns.ldns_pkt_tsig(self)
+ return _ldns._ldns_pkt_tsig(self)
#parameters: const ldns_pkt *,
#retvals: ldns_rr *
- #_LDNS_PKT_METHODS#
+ #
+ # _LDNS_PKT_METHODS#
+ #
+
+ #
+ # LDNS update methods
+ #
+
+ #
+ # LDNS_METHODS_
+ #
- #LDNS update methods
- #LDNS_METHODS_#
- def update_pkt_tsig_add(self,r):
- """add tsig credentials to a packet from a resolver
+ def update_ad(self):
+ """
+ Get the ad count.
+
+ :return: (uint16_t) The ad count.
+ """
+ return _ldns.ldns_update_ad(self)
+ #parameters: ldns_pkt *
+ #retvals: uint16_t
+
+ def update_pkt_tsig_add(self, r):
+ """
+ Add tsig credentials to a packet from a resolver.
- :param r:
- resolver to copy from
- :returns: (ldns_status) status wether successfull or not
+ :param r: Resolver to copy from.
+ :type r: :class:`ldns_resolver`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) Status whether successful or not.
"""
- return _ldns.ldns_update_pkt_tsig_add(self,r)
+ return _ldns.ldns_update_pkt_tsig_add(self, r)
#parameters: ldns_pkt *,ldns_resolver *,
#retvals: ldns_status
def update_prcount(self):
- """Get the zo count.
+ """
+ Get the pr count.
- :returns: (uint16_t) the pr count
+ :return: (uint16_t) The pr count.
"""
return _ldns.ldns_update_prcount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
- def update_set_adcount(self,c):
- """Set the ad count.
+ def update_set_adcount(self, c):
+ """
+ Set the ad count.
- :param c:
- the ad count to set
+ :param c: The ad count to set.
+ :type c: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_update_set_adcount(self,c)
+ _ldns.ldns_update_set_adcount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def update_set_prcount(self,c):
- """Set the pr count.
+ def update_set_prcount(self, c):
+ """
+ Set the pr count.
- :param c:
- the pr count to set
+ :param c: The pr count to set.
+ :type c: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_update_set_prcount(self,c)
+ _ldns.ldns_update_set_prcount(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def update_set_upcount(self,c):
- """Set the up count.
+ def update_set_upcount(self, c):
+ """
+ Set the up count.
- :param c:
- the up count to set
+ :param c: The up count to set.
+ :type c: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_update_set_upcount(self,c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
- def update_set_zo(self,v):
- _ldns.ldns_update_set_zo(self,v)
+ def update_set_zo(self, c):
+ """
+ Set the zo count.
+
+ :param c: The zo count to set.
+ :type c: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ """
+ _ldns.ldns_update_set_zo(self, c)
#parameters: ldns_pkt *,uint16_t,
#retvals:
def update_upcount(self):
- """Get the zo count.
+ """
+ Get the up count.
- :returns: (uint16_t) the up count
+ :return: (uint16_t) The up count.
"""
return _ldns.ldns_update_upcount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
def update_zocount(self):
- """Get the zo count.
+ """
+ Get the zo count.
- :returns: (uint16_t) the zo count
+ :return: (uint16_t) The zo count.
"""
return _ldns.ldns_update_zocount(self)
#parameters: const ldns_pkt *,
#retvals: uint16_t
- #_LDNS_METHODS#
- %}
+ #
+ # _LDNS_METHODS
+ #
+ %}
}
diff --git a/contrib/python/ldns_rdf.i b/contrib/python/ldns_rdf.i
index edff4d62..7b69d8b2 100644
--- a/contrib/python/ldns_rdf.i
+++ b/contrib/python/ldns_rdf.i
@@ -205,7 +205,7 @@
case LDNS_RDF_TYPE_TIME: return "TIME";
case LDNS_RDF_TYPE_PERIOD: return "PERIOD";
case LDNS_RDF_TYPE_TSIGTIME: return "TSIGTIME";
- case LDNS_RDF_TYPE_TSIG: return "TSIG";
+ case LDNS_RDF_TYPE_HIP: return "HIP";
case LDNS_RDF_TYPE_INT16_DATA: return "INT16_DATA";
case LDNS_RDF_TYPE_SERVICE: return "SERVICE";
case LDNS_RDF_TYPE_LOC: return "LOC";
@@ -216,6 +216,11 @@
case LDNS_RDF_TYPE_NSEC3_SALT: return "NSEC3_SALT";
case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
return "NSEC3_NEXT_OWNER";
+ case LDNS_RDF_TYPE_ILNP64: return "ILNP64";
+ case LDNS_RDF_TYPE_EUI48: return "EUI48";
+ case LDNS_RDF_TYPE_EUI64: return "EUI64";
+ case LDNS_RDF_TYPE_TAG: return "TAG";
+ case LDNS_RDF_TYPE_LONG_STR: return "LONG_STR";
}
}
return 0;
@@ -223,6 +228,26 @@
%}
+%inline
+%{
+ /*!
+ * @brief Returns the rdf data organised into a list of bytes.
+ */
+ PyObject * ldns_rdf_data_as_bytearray(const ldns_rdf *rdf)
+ {
+ Py_ssize_t len;
+ uint8_t *data;
+
+ assert(rdf != NULL);
+
+ len = ldns_rdf_size(rdf);
+ data = ldns_rdf_data(rdf);
+
+ return PyByteArray_FromStringAndSize((char *) data, len);
+ }
+%}
+
+
/* ========================================================================= */
/* Encapsulating Python code. */
/* ========================================================================= */
@@ -463,6 +488,16 @@ specified in the (16-bit) type field with a value from ldns_rdf_type."
#parameters: const ldns_rdf *,
#retvals: uint8_t *
+ def data_as_bytearray(self):
+ """
+ Returns the data of the rdf as a bytearray.
+
+ :return: (bytearray) Bytearray containing the rdf data.
+ """
+ return _ldns.ldns_rdf_data_as_bytearray(self)
+ #parameters: const ldns_rdf *,
+ #retvals: bytearray
+
def get_type(self):
"""
Returns the type of the rdf.
@@ -818,7 +853,8 @@ specified in the (16-bit) type field with a value from ldns_rdf_type."
Returns a clone of the given dname with the labels reversed.
When reversing non-dnames a "." (root name) dname is returned.
-
+
+ :throws Exception: When used on non-dname rdfs.
:return: (:class:`ldns_rdf`) Clone of the dname with the labels
reversed or ".".
@@ -831,6 +867,8 @@ specified in the (16-bit) type field with a value from ldns_rdf_type."
" to be deprecated in future releases." +
" Convert the ldns_rdf to ldsn_dname and the use its" +
" methods.", PendingDeprecationWarning, stacklevel=2)
+ if self.get_type() != _ldns.LDNS_RDF_TYPE_DNAME:
+ raise Exception("Operand must be a dname rdf.")
return _ldns.ldns_dname_reverse(self)
#parameters: const ldns_rdf *,
#retvals: ldns_rdf *
diff --git a/contrib/python/ldns_resolver.i b/contrib/python/ldns_resolver.i
index b9640674..b926e65a 100644
--- a/contrib/python/ldns_resolver.i
+++ b/contrib/python/ldns_resolver.i
@@ -14,8 +14,8 @@
* 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 organization nor the names of its
- * contributors may be used to endorse or promote products derived from this
- * software without specific prior written permission.
+ * 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
@@ -28,30 +28,41 @@
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
- ******************************************************************************/
+ *****************************************************************************/
+
+/* ========================================================================= */
+/* SWIG setting and definitions. */
+/* ========================================================================= */
+
+/* Creates temporary instance of (ldns_rersolver *). */
%typemap(in,numinputs=0,noblock=1) (ldns_resolver **r)
{
- ldns_resolver *$1_res;
- $1 = &$1_res;
+ ldns_resolver *$1_res;
+ $1 = &$1_res;
}
-/* result generation */
+/* Result generation, appends (ldns_resolver *) after the result. */
%typemap(argout,noblock=1) (ldns_resolver **r)
{
- $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr($1_res), SWIGTYPE_p_ldns_struct_resolver, SWIG_POINTER_OWN | 0 ));
+ $result = SWIG_Python_AppendOutput($result,
+ SWIG_NewPointerObj(SWIG_as_voidptr($1_res),
+ SWIGTYPE_p_ldns_struct_resolver, SWIG_POINTER_OWN | 0 ));
}
-//TODO: pop_nameserver a podobne funkce musi predat objekt do spravy PYTHONU!!
+%newobject ldns_resolver_new;
%newobject ldns_resolver_pop_nameserver;
%newobject ldns_resolver_query;
+%newobject ldns_resolver_search;
%newobject ldns_axfr_next;
+%newobject ldns_get_rr_list_addr_by_name;
+%newobject ldns_get_rr_list_name_by_addr;
%delobject ldns_resolver_deep_free;
%delobject ldns_resolver_free;
-%nodefaultctor ldns_struct_resolver; //no default constructor & destructor
-%nodefaultdtor ldns_struct_resolver;
+%nodefaultctor ldns_struct_resolver; /* No default constructor. */
+%nodefaultdtor ldns_struct_resolver; /* No default destructor. */
%ignore ldns_struct_resolver::_searchlist;
%ignore ldns_struct_resolver::_nameservers;
@@ -59,23 +70,225 @@
%rename(ldns_resolver) ldns_struct_resolver;
+
+/* Clone data on pull. */
+
+%newobject _ldns_axfr_last_pkt;
+%rename(__ldns_axfr_last_pkt) ldns_axfr_last_pkt;
+%inline
+%{
+ ldns_pkt * _ldns_axfr_last_pkt(const ldns_resolver *res)
+ {
+ return ldns_pkt_clone(ldns_axfr_last_pkt(res));
+ }
+%}
+
+%newobject _ldns_resolver_dnssec_anchors;
+%rename(__ldns_resolver_dnssec_anchors) ldns_resolver_dnssec_anchors;
+%inline
+%{
+ ldns_rr_list * _ldns_resolver_dnssec_anchors(const ldns_resolver *res)
+ {
+ return ldns_rr_list_clone(ldns_resolver_dnssec_anchors(res));
+ }
+%}
+
+%newobject _ldns_resolver_domain;
+%rename(__ldns_resolver_domain) ldns_resolver_domain;
+%inline
+%{
+ ldns_rdf * _ldns_resolver_domain(const ldns_resolver *res)
+ {
+ /* Prevents assertion failures. */
+ ldns_rdf *rdf;
+ rdf = ldns_resolver_domain(res);
+ if (rdf != NULL) {
+ rdf = ldns_rdf_clone(rdf);
+ }
+ return rdf;
+ }
+%}
+
+%newobject _ldns_resolver_tsig_algorithm;
+%rename(__ldns_resolver_tsig_algorithm) ldns_resolver_tsig_algorithm;
+%inline
+%{
+ char * _ldns_resolver_tsig_algorithm(const ldns_resolver *res)
+ {
+ char *str;
+ str = ldns_resolver_tsig_algorithm(res);
+ if (str != NULL) {
+ str = strdup(str);
+ }
+ return str;
+ }
+%}
+
+%newobject _ldns_resolver_tsig_keydata;
+%rename(__ldns_resolver_tsig_keydata) ldns_resolver_tsig_keydata;
+%inline
+%{
+ char * _ldns_resolver_tsig_keydata(const ldns_resolver *res)
+ {
+ char *str;
+ str = ldns_resolver_tsig_keydata(res);
+ if (str != NULL) {
+ str = strdup(str);
+ }
+ return str;
+ }
+%}
+
+%newobject _ldns_resolver_tsig_keyname;
+%rename(__ldns_resolver_tsig_keyname) ldns_resolver_tsig_keyname;
+%inline
+%{
+ char * _ldns_resolver_tsig_keyname(const ldns_resolver *res)
+ {
+ char *str;
+ str = ldns_resolver_tsig_keyname(res);
+ if (str != NULL) {
+ str = strdup(str);
+ }
+ return str;
+ }
+%}
+
+/* End of pull cloning. */
+
+/* Clone data on push. */
+
+%rename(__ldns_resolver_set_dnssec_anchors) ldns_resolver_set_dnssec_anchors;
+%inline
+%{
+ void _ldns_resolver_set_dnssec_anchors(ldns_resolver *res,
+ ldns_rr_list * rrl)
+ {
+ ldns_rr_list *rrl_clone = NULL;
+ if (rrl != NULL) {
+ rrl_clone = ldns_rr_list_clone(rrl);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_resolver_set_dnssec_anchors(res, rrl_clone);
+ }
+%}
+
+%rename(__ldns_resolver_set_domain) ldns_resolver_set_domain;
+%inline
+%{
+ void _ldns_resolver_set_domain(ldns_resolver *res, ldns_rdf *rdf)
+ {
+ ldns_rdf *rdf_clone = NULL;
+ if (rdf != NULL) {
+ rdf_clone = ldns_rdf_clone(rdf);
+ }
+ /* May leak memory, when overwriting pointer value. */
+ ldns_resolver_set_domain(res, rdf_clone);
+ }
+%}
+
+/* End of push cloning. */
+
+
+/* ========================================================================= */
+/* Debugging related code. */
+/* ========================================================================= */
+
#ifdef LDNS_DEBUG
%rename(__ldns_resolver_deep_free) ldns_resolver_deep_free;
%rename(__ldns_resolver_free) ldns_resolver_free;
-%inline %{
-void _ldns_resolver_free (ldns_resolver* r) {
- printf("******** LDNS_RESOLVER deep free 0x%lX ************\n", (long unsigned int)r);
- ldns_resolver_deep_free(r);
-}
+%inline
+%{
+ /*!
+ * @brief Prints information about deallocated resolver and deallocates.
+ */
+ void _ldns_resolver_deep_free(ldns_resolver *r)
+ {
+ printf("******** LDNS_RESOLVER deep free 0x%lX ************\n",
+ (long unsigned int) r);
+ ldns_resolver_deep_free(r);
+ }
+
+ /*!
+ * @brief Prints information about deallocated resolver and deallocates.
+ *
+ * @note There should be no need to use this function in the wrapper code, as
+ * it is likely to leak memory.
+ */
+ void _ldns_resolver_free(ldns_resolver *r)
+ {
+ printf("******** LDNS_RESOLVER free 0x%lX ************\n",
+ (long unsigned int) r);
+ ldns_resolver_free(r);
+ }
%}
-#else
+#else /* !LDNS_DEBUG */
%rename(_ldns_resolver_deep_free) ldns_resolver_deep_free;
%rename(_ldns_resolver_free) ldns_resolver_free;
-#endif
+#endif /* LDNS_DEBUG */
+
+
+/* ========================================================================= */
+/* Added C code. */
+/* ========================================================================= */
+
+%newobject _replacement_ldns_resolver_trusted_key;
+%inline
+%{
+ /*!
+ * @brief Replaces the rrs in the list with their clones.
+ *
+ * Prevents memory corruption when automatically deallocating list content.
+ */
+ void _rr_list_replace_content_with_clones(ldns_rr_list *rrl)
+ {
+ size_t count;
+ unsigned int i;
+
+ if (rrl == NULL) {
+ return;
+ }
+
+ count = ldns_rr_list_rr_count(rrl);
+ for (i = 0; i < count; ++i) {
+ ldns_rr_list_set_rr(rrl,
+ ldns_rr_clone(ldns_rr_list_rr(rrl, i)),
+ i);
+ }
+ }
+
+ /*
+ * @brief Behaves similarly to ldns_resolver_trusted_key().
+ *
+ * Prevents memory leakage by controlling the usage of content cloning.
+ *
+ * @return Newly allocated list of trusted key clones if any found,
+ * NULL else.
+ */
+ ldns_rr_list * _replacement_ldns_resolver_trusted_key(
+ const ldns_resolver *res, ldns_rr_list *keys)
+ {
+ ldns_rr_list *trusted_keys = ldns_rr_list_new();
+
+ if (ldns_resolver_trusted_key(res, keys, trusted_keys)) {
+ _rr_list_replace_content_with_clones(trusted_keys);
+ } else {
+ ldns_rr_list_deep_free(trusted_keys); trusted_keys = NULL;
+ }
+
+ return trusted_keys;
+ }
+%}
+
+
+/* ========================================================================= */
+/* Encapsulating Python code. */
+/* ========================================================================= */
%feature("docstring") ldns_struct_resolver "LDNS resolver object.
-The ldns_resolver object keeps a list of nameservers and can perform queries.
+The :class:`ldns_resolver` object keeps a list of name servers and can perform
+queries.
**Usage**
@@ -86,74 +299,146 @@ The ldns_resolver object keeps a list of nameservers and can perform queries.
>>> print pkt.answer()
www.nic.cz. 1757 IN A 217.31.205.50
-This simple example instances a resolver in order to resolve www.nic.cz record of A type.
-"
+This simple example instances a resolver in order to resolve www.nic.cz A type
+record."
%extend ldns_struct_resolver {
- %pythoncode %{
+ %pythoncode
+ %{
def __init__(self):
- raise Exception("This class can't be created directly. Please use: new_frm_file(filename), new_frm_fp(file) or new_frm_fp_l(file,line)")
+ """
+ Cannot be created directly from Python.
+ """
+ raise Exception("This class can't be created directly. " +
+ "Please use: new_frm_file(filename), new_frm_fp(file) " +
+ "or new_frm_fp_l(file, line)")
- __swig_destroy__ = _ldns._ldns_resolver_free
+ __swig_destroy__ = _ldns._ldns_resolver_deep_free
+
+ #
+ # LDNS_RESOLVER_CONSTRUCTORS_
+ #
+
+ @staticmethod
+ def new():
+ """
+ Creates a new resolver object.
+
+ :return: (:class:`ldns_resolver`) New resolver object or None.
+
+ .. note::
+ The returned resolver object is unusable unless some
+ name servers are added.
+
+ **Usage**
+ >>> resolver = ldns.ldns_resolver.new()
+ >>> ns_addr = ldns.ldns_rdf.new_frm_str("8.8.8.8", ldns.LDNS_RDF_TYPE_A)
+ >>> if not ns_addr: raise Exception("Can't create resolver address.")
+ >>> status = resolver.push_nameserver(ns_addr)
+ >>> if status != ldns.LDNS_STATUS_OK: raise Exception("Can't push resolver address.")
+ >>> pkt = resolver.query("www.nic.cz.", ldns.LDNS_RR_TYPE_A, ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
+ >>> if (pkt) and (pkt.answer()):
+ >>> print pkt.answer()
+ www.nic.cz. 1265 IN A 217.31.205.50
+ """
+ return _ldns.ldns_resolver_new()
- #LDNS_RESOLVER_CONSTRUCTORS_#
@staticmethod
def new_frm_file(filename = "/etc/resolv.conf", raiseException=True):
- """Creates a resolver object from given filename
-
- :param filename: name of file which contains informations (usually /etc/resolv.conf)
- :param raiseException: if True, an exception occurs in case a resolver object can't be created
- :returns: resolver object or None. If the object can't be created and raiseException is True, an exception occurs.
+ """
+ Creates a resolver object from given file name
+
+ :param filename: Name of file which contains resolver
+ informations (usually /etc/resolv.conf).
+ :type filename: str
+ :param raiseException: If True, an exception occurs in case a
+ resolver object can't be created.
+ :type raiseException: bool
+ :throws TypeError: When arguments of inappropriate types.
+ :throws Exception: When `raiseException` set and resolver
+ couldn't be created.
+ :return: (:class:`ldns_resolver`) Resolver object or None.
+ An exception occurs if the object can't be created and
+ 'raiseException' is True.
"""
status, resolver = _ldns.ldns_resolver_new_frm_file(filename)
if status != LDNS_STATUS_OK:
- if (raiseException): raise Exception("Can't create resolver, error: %d" % status)
+ if (raiseException):
+ raise Exception("Can't create resolver, error: %d" % status)
return None
return resolver
@staticmethod
def new_frm_fp(file, raiseException=True):
- """Creates a resolver object from file
+ """
+ Creates a resolver object from file
- :param file: a file object
- :param raiseException: if True, an exception occurs in case a resolver object can't be created
- :returns: resolver object or None. If the object can't be created and raiseException is True, an exception occurs.
+ :param file: A file object.
+ :type file: file
+ :param raiseException: If True, an exception occurs in case a
+ resolver object can't be created.
+ :type raiseException: bool
+ :throws TypeError: When arguments of inappropriate types.
+ :throws Exception: When `raiseException` set and resolver
+ couldn't be created.
+ :return: (:class:`ldns_resolver`) Resolver object or None.
+ An exception occurs if the object can't be created and
+ `raiseException` is True.
"""
status, resolver = _ldns.ldns_resolver_new_frm_fp(file)
if status != LDNS_STATUS_OK:
- if (raiseException): raise Exception("Can't create resolver, error: %d" % status)
+ if (raiseException):
+ raise Exception("Can't create resolver, error: %d" % status)
return None
return resolver
@staticmethod
def new_frm_fp_l(file, raiseException=True):
- """Creates a resolver object from file
+ """
+ Creates a resolver object from file
- :param file: a file object
- :param raiseException: if True, an exception occurs in case a resolver instance can't be created
- :returns:
- * resolver - resolver instance or None. If an instance can't be created and raiseException is True, an exception occurs.
+ :param file: A file object.
+ :type file: file
+ :param raiseException: If True, an exception occurs in case a
+ resolver instance can't be created.
+ :type raiseException: bool
+ :throws TypeError: When arguments of inappropriate types.
+ :throws Exception: When `raiseException` set and resolver
+ couldn't be created.
+ :return:
+ * (:class:`ldns_resolver`) Resolver instance or None.
+ An exception occurs if an instance can't be created and
+ `raiseException` is True.
- * line - the line number (for debugging)
+ * (int) - The line number. (e.g., for debugging)
"""
status, resolver, line = _ldns.ldns_resolver_new_frm_fp_l(file)
if status != LDNS_STATUS_OK:
- if (raiseException): raise Exception("Can't create resolver, error: %d" % status)
+ if (raiseException):
+ raise Exception("Can't create resolver, error: %d" % status)
return None
return resolver, line
- #_LDNS_RESOLVER_CONSTRUCTORS#
+ #
+ # _LDNS_RESOLVER_CONSTRUCTORS
+ #
# High level functions
- def get_addr_by_name(self, name, aclass = _ldns.LDNS_RR_CLASS_IN, flags = _ldns.LDNS_RD):
- """Ask the resolver about name and return all address records
- :param name: (ldns_rdf) the name to look for
- :param aclass: the class to use
- :param flags: give some optional flags to the query
+ def get_addr_by_name(self, name, aclass = _ldns.LDNS_RR_CLASS_IN, flags = _ldns.LDNS_RD):
+ """
+ Ask the resolver about name and return all address records.
- :returns: RR List object or None
+ :param name: The name to look for. String is automatically
+ converrted to dname.
+ :type name: :class:`ldns_dname` or str
+ :param aclass: The class to use.
+ :type aclass: ldns_rr_class
+ :param flags: Give some optional flags to the query.
+ :type flags: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) RR List object or None.
**Usage**
>>> addr = resolver.get_addr_by_name("www.google.com", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
@@ -164,7 +449,6 @@ This simple example instances a resolver in order to resolve www.nic.cz record o
www.l.google.com. 300 IN A 74.125.43.103
www.l.google.com. 300 IN A 74.125.43.104
www.l.google.com. 300 IN A 74.125.43.147
-
"""
rdf = name
if isinstance(name, str):
@@ -172,13 +456,19 @@ This simple example instances a resolver in order to resolve www.nic.cz record o
return _ldns.ldns_get_rr_list_addr_by_name(self, rdf, aclass, flags)
def get_name_by_addr(self, addr, aclass = _ldns.LDNS_RR_CLASS_IN, flags = _ldns.LDNS_RD):
- """Ask the resolver about the address and return the name
-
- :param name: (ldns_rdf of A or AAAA type) the addr to look for. If a string is given, A or AAAA type is identified automatically
- :param aclass: the class to use
- :param flags: give some optional flags to the query
+ """
+ Ask the resolver about the address and return the name.
- :returns: RR List object or None
+ :param name: (ldns_rdf of A or AAAA type) the addr to look for.
+ If a string is given, A or AAAA type is identified
+ automatically.
+ :type name: :class:`ldns_rdf` of A or AAAA type
+ :param aclass: The class to use.
+ :type aclass: ldns_rr_class
+ :param flags: Give some optional flags to the query.
+ :type flags: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) RR List object or None.
**Usage**
>>> addr = resolver.get_name_by_addr("74.125.43.99", ldns.LDNS_RR_CLASS_IN, ldns.LDNS_RD)
@@ -191,23 +481,70 @@ This simple example instances a resolver in order to resolve www.nic.cz record o
rdf = addr
if isinstance(addr, str):
if (addr.find("::") >= 0): #IPv6
- rdf = _ldns.ldns_rdf_new_frm_str(_ldns.LDNS_RDF_TYPE_AAAA, addr)
+ rdf = _ldns.ldns_rdf_new_frm_str(_ldns.LDNS_RDF_TYPE_AAAA, addr)
else:
- rdf = _ldns.ldns_rdf_new_frm_str(_ldns.LDNS_RDF_TYPE_A, addr)
+ rdf = _ldns.ldns_rdf_new_frm_str(_ldns.LDNS_RDF_TYPE_A, addr)
return _ldns.ldns_get_rr_list_name_by_addr(self, rdf, aclass, flags)
def print_to_file(self,output):
- """Print a resolver (in sofar that is possible) state to output."""
+ """Print a resolver (in so far that is possible) state to output."""
_ldns.ldns_resolver_print(output,self)
+ def axfr_complete(self):
+ """
+ Returns True if the axfr transfer has completed
+ (i.e., 2 SOA RRs and no errors were encountered).
+
+ :return: (bool)
+ """
+ return _ldns.ldns_axfr_complete(self)
+ #parameters: const ldns_resolver *,
+ #retvals: bool
+
+ def axfr_last_pkt(self):
+ """
+ Returns a last packet that was sent by the server in the AXFR
+ transfer (usable for instance to get the error code on failure).
+
+ :return: (:class:`ldns_pkt`) Last packet of the AXFR transfer.
+ """
+ return _ldns._ldns_axfr_last_pkt(self)
+ #parameters: const ldns_resolver *,
+ #retvals: ldns_pkt *
+
+ def axfr_next(self):
+ """
+ Get the next stream of RRs in a AXFR.
+
+ :return: (:class:`ldns_rr`) The next RR from the AXFR stream.
+ """
+ return _ldns.ldns_axfr_next(self)
+ #parameters: ldns_resolver *,
+ #retvals: ldns_rr *
+
def axfr_start(self, domain, aclass):
- """Prepares the resolver for an axfr query. The query is sent and the answers can be read with axfr_next
+ """
+ Prepares the resolver for an axfr query. The query is sent and
+ the answers can be read with :meth:`axfr_next`.
+
+ :param domain: Domain to axfr.
+ :type domain: :class:`dlsn_dname`
+ :param aclass: The class to use.
+ :type aclass: ldns_rr_class
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) The status of the transfer.
+
+ .. note::
+ The type checking of parameter `domain` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
**Usage**
::
status = resolver.axfr_start("nic.cz", ldns.LDNS_RR_CLASS_IN)
- if (status != ldns.LDNS_STATUS_OK): raise Exception("Can't start AXFR, error: %s" % ldns.ldns_get_errorstr_by_id(status))
+ if (status != ldns.LDNS_STATUS_OK):
+ raise Exception("Can't start AXFR, error: %s" % ldns.ldns_get_errorstr_by_id(status))
#Print the results
while True:
rr = resolver.axfr_next()
@@ -215,8 +552,8 @@ This simple example instances a resolver in order to resolve www.nic.cz record o
break
print rr
-
"""
+ # TODO -- Add checking for ldns_rdf and ldns_dname.
rdf = domain
if isinstance(domain, str):
rdf = _ldns.ldns_dname_new_frm_str(domain)
@@ -224,723 +561,894 @@ This simple example instances a resolver in order to resolve www.nic.cz record o
#parameters: ldns_resolver *resolver, ldns_rdf *domain, ldns_rr_class c
#retvals: int
- def axfr_complete(self):
- """returns true if the axfr transfer has completed (i.e. 2 SOA RRs and no errors were encountered)"""
- return _ldns.ldns_axfr_complete(self)
- #parameters: const ldns_resolver *,
- #retvals: bool
+ #
+ # LDNS_RESOLVER_METHODS_
+ #
- def axfr_last_pkt(self):
- """returns a pointer to the last ldns_pkt that was sent by the server in the AXFR transfer uasable for instance to get the error code on failure"""
- return _ldns.ldns_axfr_last_pkt(self)
- #parameters: const ldns_resolver *,
- #retvals: ldns_pkt *
-
- def axfr_next(self):
- """get the next stream of RRs in a AXFR"""
- return _ldns.ldns_axfr_next(self)
- #parameters: ldns_resolver *,
- #retvals: ldns_rr *
-
- #LDNS_RESOLVER_METHODS_#
def debug(self):
- """Get the debug status of the resolver.
+ """
+ Get the debug status of the resolver.
- :returns: (bool) true if so, otherwise false
+ :return: (bool) True if so, otherwise False.
"""
return _ldns.ldns_resolver_debug(self)
#parameters: const ldns_resolver *,
#retvals: bool
def dec_nameserver_count(self):
- """Decrement the resolver's nameserver count.
+ """
+ Decrement the resolver's name server count.
"""
_ldns.ldns_resolver_dec_nameserver_count(self)
#parameters: ldns_resolver *,
#retvals:
def defnames(self):
+ """
+ Does the resolver apply default domain name.
+
+ :return: (bool)
+ """
return _ldns.ldns_resolver_defnames(self)
#parameters: const ldns_resolver *,
#retvals: bool
def dnsrch(self):
+ """
+ Does the resolver apply search list.
+
+ :return: (bool)
+ """
return _ldns.ldns_resolver_dnsrch(self)
#parameters: const ldns_resolver *,
#retvals: bool
def dnssec(self):
- """Does the resolver do DNSSEC.
+ """
+ Does the resolver do DNSSEC.
- :returns: (bool) true: yes, false: no
+ :return: (bool) True: yes, False: no.
"""
return _ldns.ldns_resolver_dnssec(self)
#parameters: const ldns_resolver *,
#retvals: bool
def dnssec_anchors(self):
- """Get the resolver's DNSSEC anchors.
+ """
+ Get the resolver's DNSSEC anchors.
- :returns: (ldns_rr_list \*) an rr_list containg trusted DNSSEC anchors
+ :return: (:class:`ldns_rr_list`) An rr list containing trusted
+ DNSSEC anchors.
"""
- return _ldns.ldns_resolver_dnssec_anchors(self)
+ return _ldns._ldns_resolver_dnssec_anchors(self)
#parameters: const ldns_resolver *,
#retvals: ldns_rr_list *
def dnssec_cd(self):
- """Does the resolver set the CD bit.
+ """
+ Does the resolver set the CD bit.
- :returns: (bool) true: yes, false: no
+ :return: (bool) True: yes, False: no.
"""
return _ldns.ldns_resolver_dnssec_cd(self)
#parameters: const ldns_resolver *,
#retvals: bool
def domain(self):
- """What is the default dname to add to relative queries.
+ """
+ What is the default dname to add to relative queries.
- :returns: (ldns_rdf \*) the dname which is added
+ :return: (:class:`ldns_dname`) The dname which is added.
"""
- return _ldns.ldns_resolver_domain(self)
+ dname = _ldns._ldns_resolver_domain(self)
+ if dname != None:
+ return ldns_dname(_ldns._ldns_resolver_domain(self), clone=False)
+ else:
+ return dname
#parameters: const ldns_resolver *,
#retvals: ldns_rdf *
def edns_udp_size(self):
- """Get the resolver's udp size.
+ """
+ Get the resolver's udp size.
- :returns: (uint16_t) the udp mesg size
+ :return: (uint16_t) The udp mesg size.
"""
return _ldns.ldns_resolver_edns_udp_size(self)
#parameters: const ldns_resolver *,
#retvals: uint16_t
def fail(self):
- """Does the resolver only try the first nameserver.
+ """
+ Does the resolver only try the first name server.
- :returns: (bool) true: yes, fail, false: no, try the others
+ :return: (bool) True: yes, fail, False: no, try the others.
"""
return _ldns.ldns_resolver_fail(self)
#parameters: const ldns_resolver *,
#retvals: bool
def fallback(self):
- """Get the truncation fallback status.
+ """
+ Get the truncation fall-back status.
- :returns: (bool) whether the truncation fallback mechanism is used
+ :return: (bool) Whether the truncation fall*back mechanism
+ is used.
"""
return _ldns.ldns_resolver_fallback(self)
#parameters: const ldns_resolver *,
#retvals: bool
def igntc(self):
- """Does the resolver ignore the TC bit (truncated).
+ """
+ Does the resolver ignore the TC bit (truncated).
- :returns: (bool) true: yes, false: no
+ :return: (bool) True: yes, False: no.
"""
return _ldns.ldns_resolver_igntc(self)
#parameters: const ldns_resolver *,
#retvals: bool
def incr_nameserver_count(self):
- """Incremental the resolver's nameserver count.
+ """
+ Increment the resolver's name server count.
"""
_ldns.ldns_resolver_incr_nameserver_count(self)
#parameters: ldns_resolver *,
#retvals:
def ip6(self):
- """Does the resolver use ip6 or ip4.
+ """
+ Does the resolver use ip6 or ip4.
- :returns: (uint8_t) 0: both, 1: ip4, 2:ip6
+ :return: (uint8_t) 0: both, 1: ip4, 2:ip6
"""
return _ldns.ldns_resolver_ip6(self)
#parameters: const ldns_resolver *,
#retvals: uint8_t
def nameserver_count(self):
- """How many nameserver are configured in the resolver.
+ """
+ How many name server are configured in the resolver.
- :returns: (size_t) number of nameservers
+ :return: (size_t) Number of name servers.
"""
return _ldns.ldns_resolver_nameserver_count(self)
#parameters: const ldns_resolver *,
#retvals: size_t
- def nameserver_rtt(self,pos):
- """Return the used round trip time for a specific nameserver.
+ def nameserver_rtt(self, pos):
+ """
+ Return the used round trip time for a specific name server.
- :param pos:
- the index to the nameserver
- :returns: (size_t) the rrt, 0: infinite, >0: undefined (as of * yet)
+ :param pos: The index to the name server.
+ :type pos: size_t
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (size_t) The rrt, 0: infinite,
+ >0: undefined (as of * yet).
"""
- return _ldns.ldns_resolver_nameserver_rtt(self,pos)
+ return _ldns.ldns_resolver_nameserver_rtt(self, pos)
#parameters: const ldns_resolver *,size_t,
#retvals: size_t
def nameservers(self):
- """Return the configured nameserver ip address.
+ """
+ Return the configured name server ip address.
- :returns: (ldns_rdf \*\*) a ldns_rdf pointer to a list of the addresses
+ :return: (ldns_rdf \*\*) A ldns_rdf pointer to a list of the
+ addresses.
"""
+ # TODO -- Convert to list of ldns_rdf.
return _ldns.ldns_resolver_nameservers(self)
#parameters: const ldns_resolver *,
#retvals: ldns_rdf **
def nameservers_randomize(self):
- """randomize the nameserver list in the resolver
+ """
+ Randomize the name server list in the resolver.
"""
_ldns.ldns_resolver_nameservers_randomize(self)
#parameters: ldns_resolver *,
#retvals:
def pop_nameserver(self):
- """pop the last nameserver from the resolver.
+ """
+ Pop the last name server from the resolver.
- :returns: (ldns_rdf \*) the popped address or NULL if empty
+ :return: (:class:`ldns_rdf`) The popped address or None if empty.
"""
return _ldns.ldns_resolver_pop_nameserver(self)
#parameters: ldns_resolver *,
#retvals: ldns_rdf *
def port(self):
- """Get the port the resolver should use.
+ """
+ Get the port the resolver should use.
- :returns: (uint16_t) the port number
+ :return: (uint16_t) The port number.
"""
return _ldns.ldns_resolver_port(self)
#parameters: const ldns_resolver *,
#retvals: uint16_t
- def prepare_query_pkt(self,name,t,c,f):
- """Form a query packet from a resolver and name/type/class combo.
-
- :param name:
- :param t:
- query for this type (may be 0, defaults to A)
- :param c:
- query for this class (may be 0, default to IN)
- :param f:
- the query flags
- :returns: * (ldns_status) ldns_pkt* a packet with the reply from the nameserver
- * (ldns_pkt \*\*) query packet class
+ def prepare_query_pkt(self, name, t, c, f, raiseException=True):
+ """
+ Form a query packet from a resolver and name/type/class combo.
+
+ :param name: Query for this name.
+ :type name: :class:`ldns_dname` or str
+ :param t: Query for this type (may be 0, defaults to A).
+ :type t: ldns_rr_type
+ :param c: Query for this class (may be 0, default to IN).
+ :type c: ldns_rr_class
+ :param f: The query flags.
+ :type f: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ :throws Exception: When `raiseException` set and answer
+ couldn't be resolved.
+ :return: (:class:`ldns_pkt`) Query packet or None.
+ An exception occurs if the object can't be created and
+ 'raiseException' is True.
"""
- return _ldns.ldns_resolver_prepare_query_pkt(self,name,t,c,f)
+ rdf = name
+ if isinstance(name, str):
+ rdf = _ldns.ldns_dname_new_frm_str(name)
+ status, pkt = _ldns.ldns_resolver_prepare_query_pkt(self, rdf, t, c, f)
+ if status != LDNS_STATUS_OK:
+ if (raiseException):
+ raise Exception("Can't create resolver, error: %d" % status)
+ return None
+ return pkt
#parameters: ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t,
#retvals: ldns_status,ldns_pkt **
- def push_dnssec_anchor(self,rr):
- """Push a new trust anchor to the resolver.
-
- It must be a DS or DNSKEY rr
+ def push_dnssec_anchor(self, rr):
+ """
+ Push a new trust anchor to the resolver.
+ It must be a DS or DNSKEY rr.
- :param rr:
- the RR to add as a trust anchor.
- :returns: (ldns_status) a status
+ :param rr: The RR to add as a trust anchor.
+ :type rr: DS of DNSKEY :class:`ldns_rr`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) A status.
"""
- return _ldns.ldns_resolver_push_dnssec_anchor(self,rr)
+ return _ldns.ldns_resolver_push_dnssec_anchor(self, rr)
#parameters: ldns_resolver *,ldns_rr *,
#retvals: ldns_status
- def push_nameserver(self,n):
- """push a new nameserver to the resolver.
-
+ def push_nameserver(self, n):
+ """
+ Push a new name server to the resolver.
It must be an IP address v4 or v6.
- :param n:
- the ip address
- :returns: (ldns_status) ldns_status a status
+ :param n: The ip address.
+ :type n: :class:`ldns_rdf` of A or AAAA type.
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) A status.
"""
- return _ldns.ldns_resolver_push_nameserver(self,n)
+ return _ldns.ldns_resolver_push_nameserver(self, n)
#parameters: ldns_resolver *,ldns_rdf *,
#retvals: ldns_status
- def push_nameserver_rr(self,rr):
- """push a new nameserver to the resolver.
-
- It must be an A or AAAA RR record type
+ def push_nameserver_rr(self, rr):
+ """
+ Push a new name server to the resolver.
+ It must be an A or AAAA RR record type.
- :param rr:
- the resource record
- :returns: (ldns_status) ldns_status a status
+ :param rr: The resource record.
+ :type rr: :class:`ldns_rr` of A or AAAA type.
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) A status.
"""
- return _ldns.ldns_resolver_push_nameserver_rr(self,rr)
+ return _ldns.ldns_resolver_push_nameserver_rr(self, rr)
#parameters: ldns_resolver *,ldns_rr *,
#retvals: ldns_status
- def push_nameserver_rr_list(self,rrlist):
- """push a new nameserver rr_list to the resolver.
+ def push_nameserver_rr_list(self, rrlist):
+ """
+ Push a new name server rr_list to the resolver.
- :param rrlist:
- the rr_list to push
- :returns: (ldns_status) ldns_status a status
+ :param rrlist: The rr list to push.
+ :type rrlist: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (ldns_status) A status.
"""
- return _ldns.ldns_resolver_push_nameserver_rr_list(self,rrlist)
+ return _ldns.ldns_resolver_push_nameserver_rr_list(self, rrlist)
#parameters: ldns_resolver *,ldns_rr_list *,
#retvals: ldns_status
- def push_searchlist(self,rd):
- """Push a new rd to the resolver's searchlist.
+ def push_searchlist(self, rd):
+ """
+ Push a new rd to the resolver's search-list.
- :param rd:
- to push
+ :param rd: To push.
+ :param rd: :class:`ldns_dname` or str
+ :throws TypeError: When arguments of inappropriate types.
+
+ .. note:
+ The function does not return any return status,
+ so the caller must ensure the correctness of the passed
+ values.
"""
- _ldns.ldns_resolver_push_searchlist(self,rd)
+ rdf = rd
+ if isinstance(rd, str):
+ rdf = _ldns.ldns_dname_new_frm_str(rd)
+ _ldns.ldns_resolver_push_searchlist(self, rdf)
#parameters: ldns_resolver *,ldns_rdf *,
#retvals:
def query(self,name,atype=_ldns.LDNS_RR_TYPE_A,aclass=_ldns.LDNS_RR_CLASS_IN,flags=_ldns.LDNS_RD):
- """Send a query to a nameserver.
-
- :param name: (ldns_rdf) the name to look for
- :param atype: the RR type to use
- :param aclass: the RR class to use
- :param flags: give some optional flags to the query
- :returns: (ldns_pkt) a packet with the reply from the nameserver if _defnames is true the default domain will be added
"""
- return _ldns.ldns_resolver_query(self,name,atype,aclass,flags)
+ Send a query to a name server.
+
+ :param name: The name to look for.
+ :type name: :class:`ldns_dname` or str
+ :param atype: The RR type to use.
+ :type atype: ldns_rr_type
+ :param aclass: The RR class to use.
+ :type aclass: ldns_rr_class
+ :param flags: Give some optional flags to the query.
+ :type flags: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_pkt`) A packet with the reply from the
+ name server if _defnames is true the default domain will
+ be added.
+ """
+ # Explicit conversion from string to ldns_rdf prevents memory leaks.
+ # TODO -- Find out why.
+ dname = name
+ if isinstance(name, str):
+ dname = _ldns.ldns_dname_new_frm_str(name)
+ return _ldns.ldns_resolver_query(self, dname, atype, aclass, flags)
#parameters: const ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t,
#retvals: ldns_pkt *
def random(self):
- """Does the resolver randomize the nameserver before usage.
+ """
+ Does the resolver randomize the name server before usage?
- :returns: (bool) true: yes, false: no
+ :return: (bool) True: yes, False: no.
"""
return _ldns.ldns_resolver_random(self)
#parameters: const ldns_resolver *,
#retvals: bool
def recursive(self):
- """Is the resolver set to recurse.
+ """
+ Is the resolver set to recurse?
- :returns: (bool) true if so, otherwise false
+ :return: (bool) True if so, otherwise False.
"""
return _ldns.ldns_resolver_recursive(self)
#parameters: const ldns_resolver *,
#retvals: bool
def retrans(self):
- """Get the retransmit interval.
+ """
+ Get the retransmit interval.
- :returns: (uint8_t) the retransmit interval
+ :return: (uint8_t) The retransmit interval.
"""
return _ldns.ldns_resolver_retrans(self)
#parameters: const ldns_resolver *,
#retvals: uint8_t
def retry(self):
- """Get the number of retries.
+ """
+ Get the number of retries.
- :returns: (uint8_t) the number of retries
+ :return: (uint8_t) The number of retries.
"""
return _ldns.ldns_resolver_retry(self)
#parameters: const ldns_resolver *,
#retvals: uint8_t
def rtt(self):
- """Return the used round trip times for the nameservers.
+ """
+ Return the used round trip times for the name servers.
- :returns: (size_t \*) a size_t* pointer to the list. yet)
+ :return: (size_t \*) a size_t* pointer to the list. yet)
"""
return _ldns.ldns_resolver_rtt(self)
#parameters: const ldns_resolver *,
#retvals: size_t *
- def search(self,rdf,t,c,flags):
- """Send the query for using the resolver and take the search list into account The search algorithm is as follows: If the name is absolute, try it as-is, otherwise apply the search list.
-
- :param rdf:
- :param t:
- query for this type (may be 0, defaults to A)
- :param c:
- query for this class (may be 0, default to IN)
- :param flags:
- the query flags
- :returns: (ldns_pkt \*) ldns_pkt* a packet with the reply from the nameserver
- """
- return _ldns.ldns_resolver_search(self,rdf,t,c,flags)
+ def search(self, name, atype=_ldns.LDNS_RR_TYPE_A, aclass=_ldns.LDNS_RR_CLASS_IN, flags=_ldns.LDNS_RD):
+ """
+ Send the query for using the resolver and take the search list
+ into account The search algorithm is as follows: If the name is
+ absolute, try it as-is, otherwise apply the search list.
+
+ :param name: The name to look for.
+ :type name: :class:`ldns_dname` or str
+ :param atype: The RR type to use.
+ :type atype: ldns_rr_type
+ :param aclass: The RR class to use.
+ :type aclass: ldns_rr_class
+ :param flags: Give some optional flags to the query.
+ :type flags: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_pkt`) A packet with the reply from the
+ name server.
+ """
+ # Explicit conversion from string to ldns_rdf prevents memory leaks.
+ # TODO -- Find out why.
+ dname = name
+ if isinstance(name, str):
+ dname = _ldns.ldns_dname_new_frm_str(name)
+ return _ldns.ldns_resolver_search(self, dname, atype, aclass, flags)
#parameters: const ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t,
#retvals: ldns_pkt *
def searchlist(self):
- """What is the searchlist as used by the resolver.
+ """
+ What is the search-list as used by the resolver.
- :returns: (ldns_rdf \*\*) a ldns_rdf pointer to a list of the addresses
+ :return: (ldns_rdf \*\*) A ldns_rdf pointer to a list of the addresses.
"""
return _ldns.ldns_resolver_searchlist(self)
#parameters: const ldns_resolver *,
#retvals: ldns_rdf \*\*
def searchlist_count(self):
- """Return the resolver's searchlist count.
+ """
+ Return the resolver's search-list count.
- :returns: (size_t) the searchlist count
+ :return: (size_t) The search-list count.
"""
return _ldns.ldns_resolver_searchlist_count(self)
#parameters: const ldns_resolver *,
#retvals: size_t
- def send(self,name,t,c,flags):
- """Send the query for name as-is.
-
- :param name:
- :param t:
- query for this type (may be 0, defaults to A)
- :param c:
- query for this class (may be 0, default to IN)
- :param flags:
- the query flags
- :returns: * (ldns_status) ldns_pkt* a packet with the reply from the nameserver
- * (ldns_pkt \*\*)
- """
- return _ldns.ldns_resolver_send(self,name,t,c,flags)
+ def send(self, name, atype, aclass, flags, raiseException=True):
+ """
+ Send the query for name as-is.
+
+ :param name: The name to look for.
+ :type name: :class:`ldns_dname` or str
+ :param atype: The RR type to use.
+ :type atype: ldns_rr_type
+ :param aclass: The RR class to use.
+ :type aclass: ldns_rr_class
+ :param flags: Give some optional flags to the query.
+ :type flags: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
+ :throws Exception: When `raiseException` set and answer
+ couldn't be resolved.
+ :return: (:class:`ldns_pkt`) A packet with the reply from the
+ name server.
+ """
+ # Explicit conversion from string to ldns_rdf prevents memory leaks.
+ # TODO -- Find out why.
+ dname = name
+ if isinstance(name, str):
+ dname = _ldns.ldns_dname_new_frm_str(name)
+ status, pkt = _ldns.ldns_resolver_send(self, dname, atype, aclass, flags)
+ if status != LDNS_STATUS_OK:
+ if (raiseException):
+ raise Exception("Can't create resolver, error: %d" % status)
+ return None
+ return pkt
#parameters: ldns_resolver *,const ldns_rdf *,ldns_rr_type,ldns_rr_class,uint16_t,
#retvals: ldns_status,ldns_pkt **
- def send_pkt(self,query_pkt):
- """Send the given packet to a nameserver.
+ def send_pkt(self, query_pkt):
+ """
+ Send the given packet to a name server.
- :param query_pkt:
- :returns: * (ldns_status)
- * (ldns_pkt \*\*)
+ :param query_pkt: Query packet.
+ :type query_pkt: :class:`ldns_pkt`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: * (ldns_status) Return status.
+ * (:class:`ldns_pkt`) Response packet if returns status ok.
"""
+ status, answer = _ldns.ldns_resolver_send_pkt(self, query_pkt)
return _ldns.ldns_resolver_send_pkt(self,query_pkt)
#parameters: ldns_resolver *,ldns_pkt *,
#retvals: ldns_status,ldns_pkt **
- def set_debug(self,b):
- """Set the resolver debugging.
+ def set_debug(self, b):
+ """
+ Set the resolver debugging.
- :param b:
- true: debug on: false debug off
+ :param b: True: debug on, False: debug off.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_debug(self,b)
+ _ldns.ldns_resolver_set_debug(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_defnames(self,b):
- """Whether the resolver uses the name set with _set_domain.
+ def set_defnames(self, b):
+ """
+ Whether the resolver uses the name set with _set_domain.
- :param b:
- true: use the defaults, false: don't use them
+ :param b: True: use the defaults, False: don't use them.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_defnames(self,b)
+ _ldns.ldns_resolver_set_defnames(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_dnsrch(self,b):
- """Whether the resolver uses the searchlist.
+ def set_dnsrch(self, b):
+ """
+ Whether the resolver uses the search list.
- :param b:
- true: use the list, false: don't use the list
+ :param b: True: use the list, False: don't use the list.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_dnsrch(self,b)
+ _ldns.ldns_resolver_set_dnsrch(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_dnssec(self,b):
- """Whether the resolver uses DNSSEC.
+ def set_dnssec(self, b):
+ """
+ Whether the resolver uses DNSSEC.
- :param b:
- true: use DNSSEC, false: don't use DNSSEC
+ :param b: True: use DNSSEC, False: don't use DNSSEC.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_dnssec(self,b)
+ _ldns.ldns_resolver_set_dnssec(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_dnssec_anchors(self,l):
- """Set the resolver's DNSSEC anchor list directly.
-
+ def set_dnssec_anchors(self, l):
+ """
+ Set the resolver's DNSSEC anchor list directly.
RRs should be of type DS or DNSKEY.
- :param l:
- the list of RRs to use as trust anchors
+ :param l: The list of RRs to use as trust anchors.
+ :type l: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_dnssec_anchors(self,l)
+ _ldns._ldns_resolver_set_dnssec_anchors(self, l)
#parameters: ldns_resolver *,ldns_rr_list *,
#retvals:
- def set_dnssec_cd(self,b):
- """Whether the resolver uses the checking disable bit.
+ def set_dnssec_cd(self, b):
+ """
+ Whether the resolver uses the checking disable bit.
- :param b:
- true: enable , false: don't use TCP
+ :param b: True: enable, False: disable.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_dnssec_cd(self,b)
+ _ldns.ldns_resolver_set_dnssec_cd(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_domain(self,rd):
- """Set the resolver's default domain.
-
- This gets appended when no absolute name is given
-
- :param rd:
- the name to append
- """
- _ldns.ldns_resolver_set_domain(self,rd)
+ def set_domain(self, rd):
+ """
+ Set the resolver's default domain.
+ This gets appended when no absolute name is given.
+
+ :param rd: The name to append.
+ :type rd: :class:`ldns_dname` or str
+ :throws TypeError: When arguments of inappropriate types.
+ :throws Exception: When `rd` a non dname rdf.
+
+ .. note::
+ The type checking of parameter `rd` is benevolent.
+ It allows also to pass a dname :class:`ldns_rdf` object.
+ This will probably change in future.
+ """
+ # Also has to be able to pass None or dame string.
+ if isinstance(rd, str):
+ dname = _ldns.ldns_dname_new_frm_str(rd)
+ elif (not isinstance(rd, ldns_dname)) and \
+ isinstance(rd, ldns_rdf) and \
+ rd.get_type() == _ldns.LDNS_RDF_TYPE_DNAME:
+ warnings.warn("The ldns_resolver.set_domain() method" +
+ " will drop the possibility to accept ldns_rdf." +
+ " Convert argument to ldns_dname.",
+ PendingDeprecationWarning, stacklevel=2)
+ dname = rd
+ else:
+ dname = rd
+ if (not isinstance(dname, ldns_rdf)) and (dname != None):
+ raise TypeError("Parameter must be derived from ldns_rdf.")
+ if (isinstance(dname, ldns_rdf)) and \
+ (dname.get_type() != _ldns.LDNS_RDF_TYPE_DNAME):
+ raise Exception("Operands must be ldns_dname.")
+ _ldns._ldns_resolver_set_domain(self, dname)
#parameters: ldns_resolver *,ldns_rdf *,
#retvals:
- def set_edns_udp_size(self,s):
- """Set maximum udp size.
+ def set_edns_udp_size(self, s):
+ """
+ Set maximum udp size.
- :param s:
- the udp max size
+ :param s: The udp max size.
+ :type s: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_resolver_set_edns_udp_size(self,s)
#parameters: ldns_resolver *,uint16_t,
#retvals:
- def set_fail(self,b):
- """Whether or not to fail after one failed query.
+ def set_fail(self, b):
+ """
+ Whether or not to fail after one failed query.
- :param b:
- true: yes fail, false: continue with next nameserver
+ :param b: True: yes fail, False: continue with next name server.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_fail(self,b)
+ _ldns.ldns_resolver_set_fail(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_fallback(self,fallback):
- """Set whether the resolvers truncation fallback mechanism is used when ldns_resolver_query() is called.
+ def set_fallback(self, fallback):
+ """
+ Set whether the resolvers truncation fall-back mechanism is used
+ when :meth:`query` is called.
- :param fallback:
- whether to use the fallback mechanism
+ :param fallback: Whether to use the fall-back mechanism.
+ :type fallback: bool
"""
- _ldns.ldns_resolver_set_fallback(self,fallback)
+ _ldns.ldns_resolver_set_fallback(self, fallback)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_igntc(self,b):
- """Whether or not to ignore the TC bit.
+ def set_igntc(self, b):
+ """
+ Whether or not to ignore the TC bit.
- :param b:
- true: yes ignore, false: don't ignore
+ :param b: True: yes ignore, False: don't ignore.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_igntc(self,b)
+ _ldns.ldns_resolver_set_igntc(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_ip6(self,i):
- """Whether the resolver uses ip6.
+ def set_ip6(self, i):
+ """
+ Whether the resolver uses ip6.
- :param i:
- 0: no pref, 1: ip4, 2: ip6
+ :param i: 0: no pref, 1: ip4, 2: ip6
+ :type i: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_ip6(self,i)
+ _ldns.ldns_resolver_set_ip6(self, i)
#parameters: ldns_resolver *,uint8_t,
#retvals:
- def set_nameserver_count(self,c):
- """Set the resolver's nameserver count directly.
+ def set_nameserver_count(self, c):
+ """
+ Set the resolver's name server count directly.
- :param c:
- the nameserver count
+ :param c: The name server count.
+ :type c: size_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_nameserver_count(self,c)
+ _ldns.ldns_resolver_set_nameserver_count(self, c)
#parameters: ldns_resolver *,size_t,
#retvals:
- def set_nameserver_rtt(self,pos,value):
- """Set round trip time for a specific nameserver.
-
- Note this currently differentiates between: unreachable and reachable.
+ def set_nameserver_rtt(self, pos, value):
+ """
+ Set round trip time for a specific name server.
+ Note this currently differentiates between: unreachable and
+ reachable.
- :param pos:
- the nameserver position
- :param value:
- the rtt
+ :param pos: The name server position.
+ :type pos: size_t
+ :param value: The rtt.
+ :type value: size_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_nameserver_rtt(self,pos,value)
+ _ldns.ldns_resolver_set_nameserver_rtt(self, pos, value)
#parameters: ldns_resolver *,size_t,size_t,
#retvals:
- def set_nameservers(self,rd):
- """Set the resolver's nameserver count directly by using an rdf list.
+ def set_nameservers(self, rd):
+ """
+ Set the resolver's name server count directly by using an
+ rdf list.
- :param rd:
- the resolver addresses
+ :param rd: The resolver addresses.
+ :type rd: ldns_rdf \*\*
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_nameservers(self,rd)
+ _ldns.ldns_resolver_set_nameservers(self, rd)
#parameters: ldns_resolver *,ldns_rdf **,
#retvals:
- def set_port(self,p):
- """Set the port the resolver should use.
+ def set_port(self, p):
+ """
+ Set the port the resolver should use.
- :param p:
- the port number
+ :param p: The port number.
+ :type p: uint16_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_port(self,p)
+ _ldns.ldns_resolver_set_port(self, p)
#parameters: ldns_resolver *,uint16_t,
#retvals:
- def set_random(self,b):
- """Should the nameserver list be randomized before each use.
+ def set_random(self, b):
+ """
+ Should the name server list be randomized before each use.
- :param b:
- true: randomize, false: don't
+ :param b: True: randomize, False: don't.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_random(self,b)
+ _ldns.ldns_resolver_set_random(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_recursive(self,b):
- """Set the resolver recursion.
+ def set_recursive(self, b):
+ """
+ Set the resolver recursion.
- :param b:
- true: set to recurse, false: unset
+ :param b: True: set to recurse, False: unset.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_recursive(self,b)
+ _ldns.ldns_resolver_set_recursive(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
- def set_retrans(self,re):
- """Set the resolver retrans timeout (in seconds).
+ def set_retrans(self, re):
+ """
+ Set the resolver retrans time-out (in seconds).
- :param re:
- the retransmission interval in seconds
+ :param re: The retransmission interval in seconds.
+ :type re: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_retrans(self,re)
+ _ldns.ldns_resolver_set_retrans(self, re)
#parameters: ldns_resolver *,uint8_t,
#retvals:
- def set_retry(self,re):
- """Set the resolver retry interval (in seconds).
+ def set_retry(self, re):
+ """
+ Set the resolver retry interval (in seconds).
- :param re:
- the retry interval
+ :param re: The retry interval.
+ :type re: uint8_t
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_resolver_set_retry(self,re)
#parameters: ldns_resolver *,uint8_t,
#retvals:
- def set_rtt(self,rtt):
- """Set round trip time for all nameservers.
-
+ def set_rtt(self, rtt):
+ """
+ Set round trip time for all name servers.
Note this currently differentiates between: unreachable and reachable.
- :param rtt:
- a list with the times
+ :param rtt: A list with the times.
+ :type rtt: size \*
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_rtt(self,rtt)
+ _ldns.ldns_resolver_set_rtt(self, rtt)
#parameters: ldns_resolver *,size_t *,
#retvals:
- def set_searchlist_count(self,c):
- _ldns.ldns_resolver_set_searchlist_count(self,c)
- #parameters: ldns_resolver *,size_t,
- #retvals:
-
- def set_timeout(self,timeout):
- """Set the resolver's socket time out when talking to remote hosts.
+ def set_timeout(self, timeout):
+ """
+ Set the resolver's socket time out when talking to remote hosts.
- :param timeout:
- the timeout to use
+ :param timeout: The time-out to use.
+ :param timeout: struct timeval
+ :throws TypeError: When arguments of inappropriate types.
"""
_ldns.ldns_resolver_set_timeout(self,timeout)
#parameters: ldns_resolver *,struct timeval,
#retvals:
- def set_tsig_algorithm(self,tsig_algorithm):
- """Set the tsig algorithm.
+ def set_tsig_algorithm(self, tsig_algorithm):
+ """
+ Set the tsig algorithm.
- :param tsig_algorithm:
- the tsig algorithm
+ :param tsig_algorithm: The tsig algorithm.
+ :param tsig_algorithm: str
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_tsig_algorithm(self,tsig_algorithm)
+ _ldns.ldns_resolver_set_tsig_algorithm(self, tsig_algorithm)
#parameters: ldns_resolver *,char *,
#retvals:
- def set_tsig_keydata(self,tsig_keydata):
- """Set the tsig key data.
+ def set_tsig_keydata(self, tsig_keydata):
+ """
+ Set the tsig key data.
- :param tsig_keydata:
- the key data
+ :param tsig_keydata: The key data.
+ :type tsig_keydata: str
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_tsig_keydata(self,tsig_keydata)
+ _ldns.ldns_resolver_set_tsig_keydata(self, tsig_keydata)
#parameters: ldns_resolver *,char *,
#retvals:
- def set_tsig_keyname(self,tsig_keyname):
- """Set the tsig key name.
+ def set_tsig_keyname(self, tsig_keyname):
+ """
+ Set the tsig key name.
- :param tsig_keyname:
- the tsig key name
+ :param tsig_keyname: The tsig key name.
+ :type tsig_keyname: str
+ :throws TypeError: When arguments of inappropriate types.
"""
- _ldns.ldns_resolver_set_tsig_keyname(self,tsig_keyname)
+ _ldns.ldns_resolver_set_tsig_keyname(self, tsig_keyname)
#parameters: ldns_resolver *,char *,
#retvals:
- def set_usevc(self,b):
- """Whether the resolver uses a virtual circuit (TCP).
+ def set_usevc(self, b):
+ """
+ Whether the resolver uses a virtual circuit (TCP).
- :param b:
- true: use TCP, false: don't use TCP
+ :param b: True: use TCP, False: don't use TCP.
+ :type b: bool
"""
- _ldns.ldns_resolver_set_usevc(self,b)
+ _ldns.ldns_resolver_set_usevc(self, b)
#parameters: ldns_resolver *,bool,
#retvals:
def timeout(self):
- """What is the timeout on socket connections.
+ """
+ What is the time-out on socket connections.
- :returns: (struct timeval) the timeout as struct timeval
+ :return: (struct timeval) The time-out.
"""
return _ldns.ldns_resolver_timeout(self)
#parameters: const ldns_resolver *,
#retvals: struct timeval
- def trusted_key(self,keys,trusted_keys):
- """Returns true if at least one of the provided keys is a trust anchor.
+ def trusted_key(self, keys):
+ """
+ Returns true if at least one of the provided keys is a trust
+ anchor.
- :param keys:
- the keyset to check
- :param trusted_keys:
- the subset of trusted keys in the 'keys' rrset
- :returns: (bool) true if at least one of the provided keys is a configured trust anchor
+ :param keys: The key set to check.
+ :type keys: :class:`ldns_rr_list`
+ :throws TypeError: When arguments of inappropriate types.
+ :return: (:class:`ldns_rr_list`) List of trusted keys if at
+ least one of the provided keys is a configured trust anchor,
+ None else.
"""
- return _ldns.ldns_resolver_trusted_key(self,keys,trusted_keys)
+ return _ldns._replacement_ldns_resolver_trusted_key(self, keys)
#parameters: const ldns_resolver *,ldns_rr_list *,ldns_rr_list *,
#retvals: bool
def tsig_algorithm(self):
- """Return the tsig algorithm as used by the nameserver.
+ """
+ Return the tsig algorithm as used by the name server.
- :returns: (char \*) the algorithm used.
+ :return: (str) The algorithm used.
"""
- return _ldns.ldns_resolver_tsig_algorithm(self)
+ return _ldns._ldns_resolver_tsig_algorithm(self)
#parameters: const ldns_resolver *,
#retvals: char *
def tsig_keydata(self):
- """Return the tsig keydata as used by the nameserver.
+ """
+ Return the tsig key data as used by the name server.
- :returns: (char \*) the keydata used.
+ :return: (str) The key data used.
"""
- return _ldns.ldns_resolver_tsig_keydata(self)
+ return _ldns._ldns_resolver_tsig_keydata(self)
#parameters: const ldns_resolver *,
#retvals: char *
def tsig_keyname(self):
- """Return the tsig keyname as used by the nameserver.
+ """
+ Return the tsig key name as used by the name server.
- :returns: (char \*) the name used.
+ :return: (str) The name used.
"""
- return _ldns.ldns_resolver_tsig_keyname(self)
+ return _ldns._ldns_resolver_tsig_keyname(self)
#parameters: const ldns_resolver *,
#retvals: char *
def usevc(self):
- """Does the resolver use tcp or udp.
+ """
+ Does the resolver use tcp or udp.
- :returns: (bool) true: tcp, false: udp
+ :return: (bool) True: tcp, False: udp.
"""
return _ldns.ldns_resolver_usevc(self)
#parameters: const ldns_resolver *,
#retvals: bool
- #_LDNS_RESOLVER_METHODS#
- %}
+ #
+ # _LDNS_RESOLVER_METHODS
+ #
+ %}
}
diff --git a/dane.c b/dane.c
index 793005dd..675dfa8b 100644
--- a/dane.c
+++ b/dane.c
@@ -8,6 +8,7 @@
*/
#include <ldns/config.h>
+#ifdef USE_DANE
#include <ldns/ldns.h>
#include <ldns/dane.h>
@@ -15,8 +16,12 @@
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
#include <netdb.h>
+#endif
#ifdef HAVE_SSL
#include <openssl/ssl.h>
@@ -119,13 +124,13 @@ ldns_dane_cert2rdf(ldns_rdf** rdf, X509* cert,
case LDNS_TLSA_MATCHING_TYPE_SHA256:
- digest = LDNS_XMALLOC(unsigned char, SHA256_DIGEST_LENGTH);
+ digest = LDNS_XMALLOC(unsigned char, LDNS_SHA256_DIGEST_LENGTH);
if (digest == NULL) {
LDNS_FREE(buf);
return LDNS_STATUS_MEM_ERR;
}
(void) ldns_sha256(buf, (unsigned int)len, digest);
- *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, SHA256_DIGEST_LENGTH,
+ *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, LDNS_SHA256_DIGEST_LENGTH,
digest);
LDNS_FREE(buf);
@@ -134,13 +139,13 @@ ldns_dane_cert2rdf(ldns_rdf** rdf, X509* cert,
case LDNS_TLSA_MATCHING_TYPE_SHA512:
- digest = LDNS_XMALLOC(unsigned char, SHA512_DIGEST_LENGTH);
+ digest = LDNS_XMALLOC(unsigned char, LDNS_SHA512_DIGEST_LENGTH);
if (digest == NULL) {
LDNS_FREE(buf);
return LDNS_STATUS_MEM_ERR;
}
(void) ldns_sha512(buf, (unsigned int)len, digest);
- *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, SHA512_DIGEST_LENGTH,
+ *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, LDNS_SHA512_DIGEST_LENGTH,
digest);
LDNS_FREE(buf);
@@ -740,3 +745,4 @@ ldns_dane_verify(ldns_rr_list* tlsas,
return s;
}
#endif /* HAVE_SSL */
+#endif /* USE_DANE */
diff --git a/dnssec.c b/dnssec.c
index 684d1716..a41a9f63 100644
--- a/dnssec.c
+++ b/dnssec.c
@@ -654,103 +654,113 @@ ldns_key_rr2ds(const ldns_rr *key, ldns_hash h)
return ds;
}
+/* From RFC3845:
+ *
+ * 2.1.2. The List of Type Bit Map(s) Field
+ *
+ * The RR type space is split into 256 window blocks, each representing
+ * the low-order 8 bits of the 16-bit RR type space. Each block that
+ * has at least one active RR type is encoded using a single octet
+ * window number (from 0 to 255), a single octet bitmap length (from 1
+ * to 32) indicating the number of octets used for the window block's
+ * bitmap, and up to 32 octets (256 bits) of bitmap.
+ *
+ * Window blocks are present in the NSEC RR RDATA in increasing
+ * numerical order.
+ *
+ * "|" denotes concatenation
+ *
+ * Type Bit Map(s) Field = ( Window Block # | Bitmap Length | Bitmap ) +
+ *
+ * <cut>
+ *
+ * Blocks with no types present MUST NOT be included. Trailing zero
+ * octets in the bitmap MUST be omitted. The length of each block's
+ * bitmap is determined by the type code with the largest numerical
+ * value within that block, among the set of RR types present at the
+ * NSEC RR's owner name. Trailing zero octets not specified MUST be
+ * interpreted as zero octets.
+ */
ldns_rdf *
ldns_dnssec_create_nsec_bitmap(ldns_rr_type rr_type_list[],
size_t size,
ldns_rr_type nsec_type)
{
- size_t i;
- uint8_t *bitmap;
- uint16_t bm_len = 0;
- uint16_t i_type;
- ldns_rdf *bitmap_rdf;
+ uint8_t window; /* most significant octet of type */
+ uint8_t subtype; /* least significant octet of type */
+ uint16_t windows[256] /* Max subtype per window */
+#ifndef S_SPLINT_S
+ = { 0 } /* Initialize ALL elements with 0 */
+#endif
+ ;
+ ldns_rr_type* d; /* used to traverse rr_type_list*/
+ size_t i; /* used to traverse windows array */
- uint8_t *data = NULL;
- uint8_t cur_data[32];
- uint8_t cur_window = 0;
- uint8_t cur_window_max = 0;
- uint16_t cur_data_size = 0;
+ size_t sz; /* size needed for type bitmap rdf */
+ uint8_t* data = NULL; /* rdf data */
+ uint8_t* dptr; /* used to itraverse rdf data */
+ ldns_rdf* rdf; /* bitmap rdf to return */
if (nsec_type != LDNS_RR_TYPE_NSEC &&
nsec_type != LDNS_RR_TYPE_NSEC3) {
return NULL;
}
- i_type = 0;
- for (i = 0; i < size; i++) {
- if (i_type < rr_type_list[i])
- i_type = rr_type_list[i];
- }
- if (i_type < nsec_type) {
- i_type = nsec_type;
- }
-
- bm_len = i_type / 8 + 2;
- bitmap = LDNS_XMALLOC(uint8_t, bm_len);
- if(!bitmap) return NULL;
- for (i = 0; i < bm_len; i++) {
- bitmap[i] = 0;
- }
-
- for (i = 0; i < size; i++) {
- i_type = rr_type_list[i];
- ldns_set_bit(bitmap + (int) i_type / 8,
- (int) (7 - (i_type % 8)),
- true);
- }
-
- /* fold it into windows TODO: can this be done directly? */
- memset(cur_data, 0, 32);
- for (i = 0; i < bm_len; i++) {
- if (i / 32 > cur_window) {
- /* check, copy, new */
- if (cur_window_max > 0) {
- /* this window has stuff, add it */
- data = LDNS_XREALLOC(data,
- uint8_t,
- cur_data_size + cur_window_max + 3);
- if(!data) {
- LDNS_FREE(bitmap);
- return NULL;
- }
- data[cur_data_size] = cur_window;
- data[cur_data_size + 1] = cur_window_max + 1;
- memcpy(data + cur_data_size + 2,
- cur_data,
- cur_window_max+1);
- cur_data_size += cur_window_max + 3;
- }
- cur_window++;
- cur_window_max = 0;
- memset(cur_data, 0, 32);
+ /* Which other windows need to be in the bitmap rdf?
+ */
+ for (d = rr_type_list; d < rr_type_list + size; d++) {
+ window = *d >> 8;
+ subtype = *d & 0xff;
+ if (windows[window] < subtype) {
+ windows[window] = subtype;
}
- cur_data[i%32] = bitmap[i];
- if (bitmap[i] > 0) {
- cur_window_max = i%32;
+ }
+
+ /* How much space do we need in the rdf for those windows?
+ */
+ sz = 0;
+ for (i = 0; i < 256; i++) {
+ if (windows[i]) {
+ sz += windows[i] / 8 + 3;
}
}
- if (cur_window_max > 0 || cur_data[0] != 0) {
- /* this window has stuff, add it */
- data = LDNS_XREALLOC(data,
- uint8_t,
- cur_data_size + cur_window_max + 3);
- if(!data) {
- LDNS_FREE(bitmap);
- return NULL;
- }
- data[cur_data_size] = cur_window;
- data[cur_data_size + 1] = cur_window_max + 1;
- memcpy(data + cur_data_size + 2, cur_data, cur_window_max+1);
- cur_data_size += cur_window_max + 3;
+ if (sz > 0) {
+ /* Format rdf data according RFC3845 Section 2.1.2 (see above)
+ */
+ dptr = data = LDNS_CALLOC(uint8_t, sz);
+ if (!data) {
+ return NULL;
+ }
+ for (i = 0; i < 256; i++) {
+ if (windows[i]) {
+ *dptr++ = (uint8_t)i;
+ *dptr++ = (uint8_t)(windows[i] / 8 + 1);
+
+ /* Now let windows[i] index the bitmap
+ * within data
+ */
+ windows[i] = (uint16_t)(dptr - data);
+
+ dptr += dptr[-1];
+ }
+ }
}
- bitmap_rdf = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_NSEC,
- cur_data_size,
- data);
- LDNS_FREE(bitmap);
- LDNS_FREE(data);
+ /* Set the bits?
+ */
+ for (d = rr_type_list; d < rr_type_list + size; d++) {
+ subtype = *d & 0xff;
+ data[windows[*d >> 8] + subtype/8] |= (0x80 >> (subtype % 8));
+ }
- return bitmap_rdf;
+ /* Allocate and return rdf structure for the data
+ */
+ rdf = ldns_rdf_new(LDNS_RDF_TYPE_BITMAP, sz, data);
+ if (!rdf) {
+ LDNS_FREE(data);
+ return NULL;
+ }
+ return rdf;
}
int
@@ -987,7 +997,9 @@ ldns_nsec3_hash_name(ldns_rdf *name,
/* prepare the owner name according to the draft section bla */
cann = ldns_rdf_clone(name);
if(!cann) {
+#ifdef STDERR_MSGS
fprintf(stderr, "Memory error\n");
+#endif
return NULL;
}
ldns_dname2canonical(cann);
@@ -1032,11 +1044,13 @@ ldns_nsec3_hash_name(ldns_rdf *name,
hashed_owner_b32,
ldns_b32_ntop_calculate_size(hashed_owner_str_len)+1);
if (hashed_owner_b32_len < 1) {
+#ifdef STDERR_MSGS
fprintf(stderr, "Error in base32 extended hex encoding ");
fprintf(stderr, "of hashed owner name (name: ");
ldns_rdf_print(stderr, name);
fprintf(stderr, ", return code: %u)\n",
(unsigned int) hashed_owner_b32_len);
+#endif
LDNS_FREE(hashed_owner_b32);
return NULL;
}
@@ -1044,7 +1058,9 @@ ldns_nsec3_hash_name(ldns_rdf *name,
status = ldns_str2rdf_dname(&hashed_owner, hashed_owner_b32);
if (status != LDNS_STATUS_OK) {
+#ifdef STDERR_MSGS
fprintf(stderr, "Error creating rdf from %s\n", hashed_owner_b32);
+#endif
LDNS_FREE(hashed_owner_b32);
return NULL;
}
@@ -1338,38 +1354,120 @@ ldns_nsec3_hash_name_frm_nsec3(const ldns_rr *nsec, ldns_rdf *name)
}
bool
-ldns_nsec_bitmap_covers_type(const ldns_rdf *nsec_bitmap, ldns_rr_type type)
+ldns_nsec_bitmap_covers_type(const ldns_rdf* bitmap, ldns_rr_type type)
{
- uint8_t window_block_nr;
- uint8_t bitmap_length;
- uint16_t cur_type;
- uint16_t pos = 0;
- uint16_t bit_pos;
- uint8_t *data;
-
- if (nsec_bitmap == NULL) {
+ uint8_t* dptr;
+ uint8_t* dend;
+
+ /* From RFC3845 Section 2.1.2:
+ *
+ * "The RR type space is split into 256 window blocks, each re-
+ * presenting the low-order 8 bits of the 16-bit RR type space."
+ */
+ uint8_t window = type >> 8;
+ uint8_t subtype = type & 0xff;
+
+ if (! bitmap) {
return false;
}
- data = ldns_rdf_data(nsec_bitmap);
- while(pos < ldns_rdf_size(nsec_bitmap)) {
- window_block_nr = data[pos];
- bitmap_length = data[pos + 1];
- pos += 2;
-
- for (bit_pos = 0; bit_pos < (bitmap_length) * 8; bit_pos++) {
- if (ldns_get_bit(&data[pos], bit_pos)) {
- cur_type = 256 * (uint16_t) window_block_nr + bit_pos;
- if (cur_type == type) {
- return true;
- }
- }
- }
+ assert(ldns_rdf_get_type(bitmap) == LDNS_RDF_TYPE_BITMAP);
+
+ dptr = ldns_rdf_data(bitmap);
+ dend = ldns_rdf_data(bitmap) + ldns_rdf_size(bitmap);
+
+ /* Type Bitmap = ( Window Block # | Bitmap Length | Bitmap ) +
+ * dptr[0] dptr[1] dptr[2:]
+ */
+ while (dptr < dend && dptr[0] <= window) {
+
+ if (dptr[0] == window && subtype / 8 < dptr[1] &&
+ dptr + dptr[1] + 2 <= dend) {
- pos += (uint16_t) bitmap_length;
+ return dptr[2 + subtype / 8] & (0x80 >> (subtype % 8));
+ }
+ dptr += dptr[1] + 2; /* next window */
}
return false;
}
+ldns_status
+ldns_nsec_bitmap_set_type(ldns_rdf* bitmap, ldns_rr_type type)
+{
+ uint8_t* dptr;
+ uint8_t* dend;
+
+ /* From RFC3845 Section 2.1.2:
+ *
+ * "The RR type space is split into 256 window blocks, each re-
+ * presenting the low-order 8 bits of the 16-bit RR type space."
+ */
+ uint8_t window = type >> 8;
+ uint8_t subtype = type & 0xff;
+
+ if (! bitmap) {
+ return false;
+ }
+ assert(ldns_rdf_get_type(bitmap) == LDNS_RDF_TYPE_BITMAP);
+
+ dptr = ldns_rdf_data(bitmap);
+ dend = ldns_rdf_data(bitmap) + ldns_rdf_size(bitmap);
+
+ /* Type Bitmap = ( Window Block # | Bitmap Length | Bitmap ) +
+ * dptr[0] dptr[1] dptr[2:]
+ */
+ while (dptr < dend && dptr[0] <= window) {
+
+ if (dptr[0] == window && subtype / 8 < dptr[1] &&
+ dptr + dptr[1] + 2 <= dend) {
+
+ dptr[2 + subtype / 8] |= (0x80 >> (subtype % 8));
+ return LDNS_STATUS_OK;
+ }
+ dptr += dptr[1] + 2; /* next window */
+ }
+ return LDNS_STATUS_TYPE_NOT_IN_BITMAP;
+}
+
+ldns_status
+ldns_nsec_bitmap_clear_type(ldns_rdf* bitmap, ldns_rr_type type)
+{
+ uint8_t* dptr;
+ uint8_t* dend;
+
+ /* From RFC3845 Section 2.1.2:
+ *
+ * "The RR type space is split into 256 window blocks, each re-
+ * presenting the low-order 8 bits of the 16-bit RR type space."
+ */
+ uint8_t window = type >> 8;
+ uint8_t subtype = type & 0xff;
+
+ if (! bitmap) {
+ return false;
+ }
+
+ assert(ldns_rdf_get_type(bitmap) == LDNS_RDF_TYPE_BITMAP);
+
+ dptr = ldns_rdf_data(bitmap);
+ dend = ldns_rdf_data(bitmap) + ldns_rdf_size(bitmap);
+
+ /* Type Bitmap = ( Window Block # | Bitmap Length | Bitmap ) +
+ * dptr[0] dptr[1] dptr[2:]
+ */
+ while (dptr < dend && dptr[0] <= window) {
+
+ if (dptr[0] == window && subtype / 8 < dptr[1] &&
+ dptr + dptr[1] + 2 <= dend) {
+
+ dptr[2 + subtype / 8] &= ~(0x80 >> (subtype % 8));
+ return LDNS_STATUS_OK;
+ }
+ dptr += dptr[1] + 2; /* next window */
+ }
+ return LDNS_STATUS_TYPE_NOT_IN_BITMAP;
+}
+
+
bool
ldns_nsec_covers_name(const ldns_rr *nsec, const ldns_rdf *name)
{
@@ -1407,9 +1505,11 @@ ldns_nsec_covers_name(const ldns_rr *nsec, const ldns_rdf *name)
if(ldns_dname_compare(nsec_owner, nsec_next) > 0) {
result = (ldns_dname_compare(nsec_owner, name) <= 0 ||
ldns_dname_compare(name, nsec_next) < 0);
- } else {
+ } else if(ldns_dname_compare(nsec_owner, nsec_next) < 0) {
result = (ldns_dname_compare(nsec_owner, name) <= 0 &&
ldns_dname_compare(name, nsec_next) < 0);
+ } else {
+ result = true;
}
ldns_rdf_deep_free(nsec_next);
diff --git a/dnssec_sign.c b/dnssec_sign.c
index f2f9d9dd..4af882a2 100644
--- a/dnssec_sign.c
+++ b/dnssec_sign.c
@@ -566,7 +566,7 @@ ldns_dnssec_addresses_on_glue_list(
* when walking the tree with the ldns_dnssec_name_node_next_nonglue()
* function. But watch out! Names that are partially occluded (like glue with
* the same name as the delegation) will not be marked and should specifically
- * be taken into account seperately.
+ * be taken into account separately.
*
* When glue_list is given (not NULL), in the process of marking the names, all
* glue resource records will be pushed to that list, even glue at delegation names.
@@ -659,7 +659,7 @@ ldns_dnssec_zone_mark_and_get_glue(ldns_dnssec_zone *zone,
* when walking the tree with the ldns_dnssec_name_node_next_nonglue()
* function. But watch out! Names that are partially occluded (like glue with
* the same name as the delegation) will not be marked and should specifically
- * be taken into account seperately.
+ * be taken into account separately.
*
* \param[in] zone the zone in which to mark the names
* \return LDNS_STATUS_OK on success, an error code otherwise
@@ -771,10 +771,13 @@ ldns_dnssec_zone_create_nsecs(ldns_dnssec_zone *zone,
}
#ifdef HAVE_SSL
-/* in dnssec_zone.c */
-extern int ldns_dname_compare_v(const void *a, const void *b);
+static void
+ldns_hashed_names_node_free(ldns_rbnode_t *node, void *arg) {
+ (void) arg;
+ LDNS_FREE(node);
+}
-ldns_status
+static ldns_status
ldns_dnssec_zone_create_nsec3s_mkmap(ldns_dnssec_zone *zone,
ldns_rr_list *new_rrs,
uint8_t algorithm,
@@ -813,21 +816,24 @@ ldns_dnssec_zone_create_nsec3s_mkmap(ldns_dnssec_zone *zone,
nsec_ttl = LDNS_DEFAULT_TTL;
}
- if (map) {
- if ((*map = ldns_rbtree_create(ldns_dname_compare_v))
- == NULL) {
- map = NULL;
- };
+ if (zone->hashed_names) {
+ ldns_traverse_postorder(zone->hashed_names,
+ ldns_hashed_names_node_free, NULL);
+ LDNS_FREE(zone->hashed_names);
+ }
+ zone->hashed_names = ldns_rbtree_create(ldns_dname_compare_v);
+ if (zone->hashed_names && map) {
+ *map = zone->hashed_names;
}
- nsec3_list = ldns_rr_list_new();
first_name_node = ldns_dnssec_name_node_next_nonglue(
ldns_rbtree_first(zone->names));
current_name_node = first_name_node;
- while (current_name_node &&
- current_name_node != LDNS_RBTREE_NULL) {
+ while (current_name_node && current_name_node != LDNS_RBTREE_NULL &&
+ result == LDNS_STATUS_OK) {
+
current_name = (ldns_dnssec_name *) current_name_node->data;
nsec_rr = ldns_dnssec_create_nsec3(current_name,
NULL,
@@ -845,28 +851,49 @@ ldns_dnssec_zone_create_nsec3s_mkmap(ldns_dnssec_zone *zone,
ldns_rr_set_ttl(nsec_rr, nsec_ttl);
result = ldns_dnssec_name_add_rr(current_name, nsec_rr);
ldns_rr_list_push_rr(new_rrs, nsec_rr);
- ldns_rr_list_push_rr(nsec3_list, nsec_rr);
- if (map) {
+ if (ldns_rr_owner(nsec_rr)) {
hashmap_node = LDNS_MALLOC(ldns_rbnode_t);
- if (hashmap_node && ldns_rr_owner(nsec_rr)) {
- hashmap_node->key = ldns_dname_label(
- ldns_rr_owner(nsec_rr), 0);
- if (hashmap_node->key) {
- hashmap_node->data = current_name->name;
- (void) ldns_rbtree_insert(
- *map, hashmap_node);
- }
+ if (hashmap_node == NULL) {
+ return LDNS_STATUS_MEM_ERR;
+ }
+ current_name->hashed_name =
+ ldns_dname_label(ldns_rr_owner(nsec_rr), 0);
+
+ if (current_name->hashed_name == NULL) {
+ LDNS_FREE(hashmap_node);
+ return LDNS_STATUS_MEM_ERR;
+ }
+ hashmap_node->key = current_name->hashed_name;
+ hashmap_node->data = current_name;
+
+ if (! ldns_rbtree_insert(zone->hashed_names
+ , hashmap_node)) {
+ LDNS_FREE(hashmap_node);
}
}
current_name_node = ldns_dnssec_name_node_next_nonglue(
ldns_rbtree_next(current_name_node));
}
if (result != LDNS_STATUS_OK) {
- ldns_rr_list_free(nsec3_list);
return result;
}
- ldns_rr_list_sort_nsec3(nsec3_list);
+ /* Make sorted list of nsec3s (via zone->hashed_names)
+ */
+ nsec3_list = ldns_rr_list_new();
+ if (nsec3_list == NULL) {
+ return LDNS_STATUS_MEM_ERR;
+ }
+ for ( hashmap_node = ldns_rbtree_first(zone->hashed_names)
+ ; hashmap_node != LDNS_RBTREE_NULL
+ ; hashmap_node = ldns_rbtree_next(hashmap_node)
+ ) {
+ current_name = (ldns_dnssec_name *) hashmap_node->data;
+ nsec_rr = ((ldns_dnssec_name *) hashmap_node->data)->nsec;
+ if (nsec_rr) {
+ ldns_rr_list_push_rr(nsec3_list, nsec_rr);
+ }
+ }
result = ldns_dnssec_chain_nsec3_list(nsec3_list);
ldns_rr_list_free(nsec3_list);
@@ -913,7 +940,9 @@ ldns_dnssec_remove_signatures( ldns_dnssec_rrs *signatures
ldns_key_list_set_use(key_list, false);
break;
default:
+#ifdef STDERR_MSGS
fprintf(stderr, "[XX] unknown return value from callback\n");
+#endif
break;
}
return NULL;
@@ -965,7 +994,9 @@ ldns_dnssec_remove_signatures( ldns_dnssec_rrs *signatures
LDNS_FREE(cur_rr);
break;
default:
+#ifdef STDERR_MSGS
fprintf(stderr, "[XX] unknown return value from callback\n");
+#endif
break;
}
cur_rr = next_rr;
diff --git a/dnssec_verify.c b/dnssec_verify.c
index d435eedf..1af6635b 100644
--- a/dnssec_verify.c
+++ b/dnssec_verify.c
@@ -16,7 +16,7 @@
#include <openssl/md5.h>
ldns_dnssec_data_chain *
-ldns_dnssec_data_chain_new()
+ldns_dnssec_data_chain_new(void)
{
ldns_dnssec_data_chain *nc = LDNS_CALLOC(ldns_dnssec_data_chain, 1);
if(!nc) return NULL;
@@ -216,7 +216,7 @@ ldns_dnssec_build_data_chain_other(ldns_resolver *res,
}
}
-ldns_dnssec_data_chain *
+static ldns_dnssec_data_chain *
ldns_dnssec_build_data_chain_nokeyname(ldns_resolver *res,
uint16_t qflags,
ldns_rr *orig_rr,
@@ -439,7 +439,7 @@ ldns_dnssec_build_data_chain(ldns_resolver *res,
}
ldns_dnssec_trust_tree *
-ldns_dnssec_trust_tree_new()
+ldns_dnssec_trust_tree_new(void)
{
ldns_dnssec_trust_tree *new_tree = LDNS_XMALLOC(ldns_dnssec_trust_tree,
1);
@@ -495,7 +495,7 @@ print_tabs(FILE *out, size_t nr, uint8_t *map, size_t treedepth)
}
}
-void
+static void
ldns_dnssec_trust_tree_print_sm_fmt(FILE *out,
const ldns_output_format *fmt,
ldns_dnssec_trust_tree *tree,
@@ -629,18 +629,6 @@ ldns_dnssec_trust_tree_print_sm_fmt(FILE *out,
}
void
-ldns_dnssec_trust_tree_print_sm(FILE *out,
- ldns_dnssec_trust_tree *tree,
- size_t tabs,
- bool extended,
- uint8_t *sibmap,
- size_t treedepth)
-{
- ldns_dnssec_trust_tree_print_sm_fmt(out, ldns_output_format_default,
- tree, tabs, extended, sibmap, treedepth);
-}
-
-void
ldns_dnssec_trust_tree_print_fmt(FILE *out, const ldns_output_format *fmt,
ldns_dnssec_trust_tree *tree,
size_t tabs,
diff --git a/dnssec_zone.c b/dnssec_zone.c
index df71a23c..60d62eae 100644
--- a/dnssec_zone.c
+++ b/dnssec_zone.c
@@ -7,7 +7,7 @@
#include <ldns/ldns.h>
ldns_dnssec_rrs *
-ldns_dnssec_rrs_new()
+ldns_dnssec_rrs_new(void)
{
ldns_dnssec_rrs *new_rrs;
new_rrs = LDNS_MALLOC(ldns_dnssec_rrs);
@@ -54,10 +54,8 @@ ldns_dnssec_rrs_add_rr(ldns_dnssec_rrs *rrs, ldns_rr *rr)
/* this could be done more efficiently; name and type should already
be equal */
- cmp = ldns_rr_compare(rrs->rr,
- rr);
- /* should we error on equal? */
- if (cmp <= 0) {
+ cmp = ldns_rr_compare(rrs->rr, rr);
+ if (cmp < 0) {
if (rrs->next) {
return ldns_dnssec_rrs_add_rr(rrs->next, rr);
} else {
@@ -74,6 +72,7 @@ ldns_dnssec_rrs_add_rr(ldns_dnssec_rrs *rrs, ldns_rr *rr)
rrs->rr = rr;
rrs->next = new_rrs;
}
+ /* Silently ignore equal rr's */
return LDNS_STATUS_OK;
}
@@ -102,7 +101,7 @@ ldns_dnssec_rrs_print(FILE *out, ldns_dnssec_rrs *rrs)
ldns_dnssec_rrsets *
-ldns_dnssec_rrsets_new()
+ldns_dnssec_rrsets_new(void)
{
ldns_dnssec_rrsets *new_rrsets;
new_rrsets = LDNS_MALLOC(ldns_dnssec_rrsets);
@@ -164,7 +163,7 @@ ldns_dnssec_rrsets_set_type(ldns_dnssec_rrsets *rrsets,
return LDNS_STATUS_ERR;
}
-ldns_dnssec_rrsets *
+static ldns_dnssec_rrsets *
ldns_dnssec_rrsets_new_frm_rr(ldns_rr *rr)
{
ldns_dnssec_rrsets *new_rrsets;
@@ -270,7 +269,7 @@ ldns_dnssec_rrsets_add_rr(ldns_dnssec_rrsets *rrsets, ldns_rr *rr)
return result;
}
-void
+static void
ldns_dnssec_rrsets_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
ldns_dnssec_rrsets *rrsets,
bool follow,
@@ -298,16 +297,6 @@ ldns_dnssec_rrsets_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
}
}
-void
-ldns_dnssec_rrsets_print_soa(FILE *out,
- ldns_dnssec_rrsets *rrsets,
- bool follow,
- bool show_soa)
-{
- ldns_dnssec_rrsets_print_soa_fmt(out, ldns_output_format_default,
- rrsets, follow, show_soa);
-}
-
void
ldns_dnssec_rrsets_print_fmt(FILE *out, const ldns_output_format *fmt,
@@ -325,7 +314,7 @@ ldns_dnssec_rrsets_print(FILE *out, ldns_dnssec_rrsets *rrsets, bool follow)
}
ldns_dnssec_name *
-ldns_dnssec_name_new()
+ldns_dnssec_name_new(void)
{
ldns_dnssec_name *new_name;
@@ -428,14 +417,6 @@ ldns_dnssec_name_set_name(ldns_dnssec_name *rrset,
}
}
-ldns_rr *
-ldns_dnssec_name_nsec(ldns_dnssec_name *rrset)
-{
- if (rrset) {
- return rrset->nsec;
- }
- return NULL;
-}
void
ldns_dnssec_name_set_nsec(ldns_dnssec_name *rrset, ldns_rr *nsec)
@@ -468,8 +449,6 @@ ldns_dnssec_name_add_rr(ldns_dnssec_name *name,
ldns_rr *rr)
{
ldns_status result = LDNS_STATUS_OK;
- ldns_rdf *name_name;
- bool hashed_name = false;
ldns_rr_type rr_type;
ldns_rr_type typecovered = 0;
@@ -485,19 +464,6 @@ ldns_dnssec_name_add_rr(ldns_dnssec_name *name,
typecovered = ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(rr));
}
-#ifdef HAVE_SSL
- if (rr_type == LDNS_RR_TYPE_NSEC3 ||
- typecovered == LDNS_RR_TYPE_NSEC3) {
- name_name = ldns_nsec3_hash_name_frm_nsec3(rr,
- ldns_dnssec_name_name(name));
- hashed_name = true;
- } else {
- name_name = ldns_dnssec_name_name(name);
- }
-#else
- name_name = ldns_dnssec_name_name(name);
-#endif /* HAVE_SSL */
-
if (rr_type == LDNS_RR_TYPE_NSEC ||
rr_type == LDNS_RR_TYPE_NSEC3) {
/* XX check if is already set (and error?) */
@@ -519,11 +485,6 @@ ldns_dnssec_name_add_rr(ldns_dnssec_name *name,
result = ldns_dnssec_rrsets_add_rr(name->rrsets, rr);
}
}
-
- if (hashed_name) {
- ldns_rdf_deep_free(name_name);
- }
-
return result;
}
@@ -563,7 +524,7 @@ ldns_dnssec_zone_find_rrset(ldns_dnssec_zone *zone,
}
}
-void
+static void
ldns_dnssec_name_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
ldns_dnssec_name *name,
bool show_soa)
@@ -589,12 +550,6 @@ ldns_dnssec_name_print_soa_fmt(FILE *out, const ldns_output_format *fmt,
}
}
-void
-ldns_dnssec_name_print_soa(FILE *out, ldns_dnssec_name *name, bool show_soa)
-{
- ldns_dnssec_name_print_soa_fmt(out, ldns_output_format_default,
- name, show_soa);
-}
void
ldns_dnssec_name_print_fmt(FILE *out, const ldns_output_format *fmt,
@@ -611,12 +566,14 @@ ldns_dnssec_name_print(FILE *out, ldns_dnssec_name *name)
ldns_dnssec_zone *
-ldns_dnssec_zone_new()
+ldns_dnssec_zone_new(void)
{
ldns_dnssec_zone *zone = LDNS_MALLOC(ldns_dnssec_zone);
if(!zone) return NULL;
zone->soa = NULL;
zone->names = NULL;
+ zone->hashed_names = NULL;
+ zone->_nsec3params = NULL;
return zone;
}
@@ -699,6 +656,8 @@ ldns_dnssec_zone_new_frm_fp_l(ldns_dnssec_zone** z, FILE* fp, ldns_rdf* origin,
ldns_rr_list_push_rr(todo_nsec3s,
cur_rr);
}
+ status = LDNS_STATUS_OK;
+
} else if (status != LDNS_STATUS_OK)
goto error;
@@ -722,18 +681,13 @@ ldns_dnssec_zone_new_frm_fp_l(ldns_dnssec_zone** z, FILE* fp, ldns_rdf* origin,
if (ldns_rr_list_rr_count(todo_nsec3s) > 0) {
(void) ldns_dnssec_zone_add_empty_nonterminals(newzone);
- for (i = 0; status == LDNS_STATUS_OK &&
+ for (i = 0; status == LDNS_STATUS_OK &&
i < ldns_rr_list_rr_count(todo_nsec3s); i++) {
cur_rr = ldns_rr_list_rr(todo_nsec3s, i);
status = ldns_dnssec_zone_add_rr(newzone, cur_rr);
}
- for (i = 0; status == LDNS_STATUS_OK &&
- i < ldns_rr_list_rr_count(todo_nsec3_rrsigs);
- i++){
- cur_rr = ldns_rr_list_rr(todo_nsec3_rrsigs, i);
- status = ldns_dnssec_zone_add_rr(newzone, cur_rr);
- }
- } else if (ldns_rr_list_rr_count(todo_nsec3_rrsigs) > 0) {
+ }
+ if (ldns_rr_list_rr_count(todo_nsec3_rrsigs) > 0) {
for (i = 0; status == LDNS_STATUS_OK &&
i < ldns_rr_list_rr_count(todo_nsec3_rrsigs);
i++){
@@ -777,14 +731,14 @@ ldns_dnssec_zone_new_frm_fp(ldns_dnssec_zone** z, FILE* fp, ldns_rdf* origin,
return ldns_dnssec_zone_new_frm_fp_l(z, fp, origin, ttl, c, NULL);
}
-void
+static void
ldns_dnssec_name_node_free(ldns_rbnode_t *node, void *arg) {
(void) arg;
ldns_dnssec_name_free((ldns_dnssec_name *)node->data);
LDNS_FREE(node);
}
-void
+static void
ldns_dnssec_name_node_deep_free(ldns_rbnode_t *node, void *arg) {
(void) arg;
ldns_dnssec_name_deep_free((ldns_dnssec_name *)node->data);
@@ -827,31 +781,99 @@ ldns_dname_compare_v(const void *a, const void *b) {
return ldns_dname_compare((ldns_rdf *)a, (ldns_rdf *)b);
}
-ldns_rbnode_t *
-ldns_dnssec_zone_find_nsec3_original(ldns_dnssec_zone *zone,
- ldns_rr *rr) {
- ldns_rbnode_t *current_node = ldns_rbtree_first(zone->names);
- ldns_dnssec_name *current_name;
- ldns_rdf *hashed_name;
+static void
+ldns_dnssec_name_make_hashed_name(ldns_dnssec_zone *zone,
+ ldns_dnssec_name* name, ldns_rr* nsec3rr);
- hashed_name = ldns_dname_label(ldns_rr_owner(rr), 0);
+static void
+ldns_hashed_names_node_free(ldns_rbnode_t *node, void *arg) {
+ (void) arg;
+ LDNS_FREE(node);
+}
+
+static void
+ldns_dnssec_zone_hashed_names_from_nsec3(
+ ldns_dnssec_zone* zone, ldns_rr* nsec3rr)
+{
+ ldns_rbnode_t* current_node;
+ ldns_dnssec_name* current_name;
- while (current_node != LDNS_RBTREE_NULL) {
+ assert(zone != NULL);
+ assert(nsec3rr != NULL);
+
+ if (zone->hashed_names) {
+ ldns_traverse_postorder(zone->hashed_names,
+ ldns_hashed_names_node_free, NULL);
+ LDNS_FREE(zone->hashed_names);
+ }
+ zone->_nsec3params = nsec3rr;
+
+ /* So this is a NSEC3 zone.
+ * Calculate hashes for all names already in the zone
+ */
+ zone->hashed_names = ldns_rbtree_create(ldns_dname_compare_v);
+ if (zone->hashed_names == NULL) {
+ return;
+ }
+ for ( current_node = ldns_rbtree_first(zone->names)
+ ; current_node != LDNS_RBTREE_NULL
+ ; current_node = ldns_rbtree_next(current_node)
+ ) {
current_name = (ldns_dnssec_name *) current_node->data;
- if (!current_name->hashed_name) {
- current_name->hashed_name =
- ldns_nsec3_hash_name_frm_nsec3(rr, current_name->name);
+ ldns_dnssec_name_make_hashed_name(zone, current_name, nsec3rr);
+
+ }
+}
+
+static void
+ldns_dnssec_name_make_hashed_name(ldns_dnssec_zone *zone,
+ ldns_dnssec_name* name, ldns_rr* nsec3rr)
+{
+ ldns_rbnode_t* new_node;
+
+ assert(name != NULL);
+ if (! zone->_nsec3params) {
+ if (! nsec3rr) {
+ return;
}
- if (ldns_dname_compare(hashed_name,
- current_name->hashed_name)
- == 0) {
- ldns_rdf_deep_free(hashed_name);
- return current_node;
+ ldns_dnssec_zone_hashed_names_from_nsec3(zone, nsec3rr);
+
+ } else if (! nsec3rr) {
+ nsec3rr = zone->_nsec3params;
+ }
+ name->hashed_name = ldns_nsec3_hash_name_frm_nsec3(nsec3rr, name->name);
+
+ /* Also store in zone->hashed_names */
+ if ((new_node = LDNS_MALLOC(ldns_rbnode_t))) {
+
+ new_node->key = name->hashed_name;
+ new_node->data = name;
+
+ if (ldns_rbtree_insert(zone->hashed_names, new_node) == NULL) {
+
+ LDNS_FREE(new_node);
}
- current_node = ldns_rbtree_next(current_node);
}
- ldns_rdf_deep_free(hashed_name);
- return NULL;
+}
+
+
+static ldns_rbnode_t *
+ldns_dnssec_zone_find_nsec3_original(ldns_dnssec_zone *zone, ldns_rr *rr) {
+ ldns_rdf *hashed_name;
+
+ hashed_name = ldns_dname_label(ldns_rr_owner(rr), 0);
+ if (hashed_name == NULL) {
+ return NULL;
+ }
+ if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_NSEC3 && ! zone->_nsec3params){
+
+ ldns_dnssec_zone_hashed_names_from_nsec3(zone, rr);
+ }
+ if (zone->hashed_names == NULL) {
+ ldns_rdf_deep_free(hashed_name);
+ return NULL;
+ }
+ return ldns_rbtree_search(zone->hashed_names, hashed_name);
}
ldns_status
@@ -878,15 +900,13 @@ ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, ldns_rr *rr)
}
if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_NSEC3 ||
type_covered == LDNS_RR_TYPE_NSEC3) {
- cur_node = ldns_dnssec_zone_find_nsec3_original(zone,
- rr);
+ cur_node = ldns_dnssec_zone_find_nsec3_original(zone, rr);
if (!cur_node) {
return LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND;
}
} else {
cur_node = ldns_rbtree_search(zone->names, ldns_rr_owner(rr));
}
-
if (!cur_node) {
/* add */
cur_name = ldns_dnssec_name_new_frm_rr(rr);
@@ -899,21 +919,14 @@ ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, ldns_rr *rr)
cur_node->key = ldns_rr_owner(rr);
cur_node->data = cur_name;
(void)ldns_rbtree_insert(zone->names, cur_node);
+ ldns_dnssec_name_make_hashed_name(zone, cur_name, NULL);
} else {
cur_name = (ldns_dnssec_name *) cur_node->data;
result = ldns_dnssec_name_add_rr(cur_name, rr);
}
-
- if (result != LDNS_STATUS_OK) {
- fprintf(stderr, "error adding rr: ");
- ldns_rr_print(stderr, rr);
- }
-
- /*TODO ldns_dnssec_name_print_names(stdout, zone->names, 0);*/
if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_SOA) {
zone->soa = cur_name;
}
-
return result;
}
@@ -1059,6 +1072,8 @@ ldns_dnssec_zone_add_empty_nonterminals(ldns_dnssec_zone *zone)
new_node->key = new_name->name;
new_node->data = new_name;
(void)ldns_rbtree_insert(zone->names, new_node);
+ ldns_dnssec_name_make_hashed_name(
+ zone, new_name, NULL);
}
ldns_rdf_deep_free(l1);
ldns_rdf_deep_free(l2);
diff --git a/doc/API.xml b/doc/API.xml
index 07007b9a..554420d1 100644
--- a/doc/API.xml
+++ b/doc/API.xml
@@ -196,7 +196,7 @@ TODO the 'set' functions of the 'get'
<t>
In the DNS the atomic data type is an RRset. This is a list
of RRs with the same ownername, type and class. Net::DNS doesn't
-have rrsets as a seperate object.
+have rrsets as a separate object.
</t>
<t>
In lDNS we have the ldns_rr_list, which just holds a bunch of RR's.
diff --git a/drill/chasetrace.c b/drill/chasetrace.c
index 0a37ff30..370f6276 100644
--- a/drill/chasetrace.c
+++ b/drill/chasetrace.c
@@ -74,6 +74,8 @@ do_trace(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t,
ldns_resolver_usevc(local_res));
ldns_resolver_set_random(res,
ldns_resolver_random(local_res));
+ ldns_resolver_set_source(res,
+ ldns_resolver_source(local_res));
ldns_resolver_set_recursive(res, false);
/* setup the root nameserver in the new resolver */
diff --git a/drill/configure.ac b/drill/configure.ac
index 17d7541c..b7fe2aee 100644
--- a/drill/configure.ac
+++ b/drill/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
-AC_INIT(ldns, 1.6.16, libdns@nlnetlabs.nl,libdns)
+AC_INIT(ldns, 1.6.17, libdns@nlnetlabs.nl,libdns)
AC_CONFIG_SRCDIR([drill.c])
sinclude(../acx_nlnetlabs.m4)
diff --git a/drill/drill.1.in b/drill/drill.1.in
index 15b15a42..b6d74f65 100644
--- a/drill/drill.1.in
+++ b/drill/drill.1.in
@@ -83,6 +83,11 @@ Chase the signature(s) of 'name' to a known key or as high up in
the tree as possible.
.TP
+\fB\-I \fIIPv4 or IPv6 address\fR
+Source address to query from. The source address has to be present
+on an interface of the host running drill.
+
+.TP
\fB\-V \fIlevel\fR
Be more verbose. Set level to 5 to see the actual query that is sent.
@@ -217,6 +222,12 @@ specify named base64 tsig key, and optional an algorithm (defaults to hmac-md5.s
\fB\-z \fR
don't randomize the nameserver list before sending queries.
+.SH "EXIT STATUS"
+The exit status is 0 if the looked up answer is secure and trusted,
+or insecure.
+The exit status is not 0 if the looked up answer is untrusted or bogus,
+or an error occurred while performing the lookup.
+
.SH "FILES"
.TP
@LDNS_TRUST_ANCHOR_FILE@
diff --git a/drill/drill.c b/drill/drill.c
index 574c8b98..b967ad94 100644
--- a/drill/drill.c
+++ b/drill/drill.c
@@ -33,6 +33,7 @@ usage(FILE *stream, const char *progname)
fprintf(stream, "\t-T\t\ttrace from the root down to <name>\n");
fprintf(stream, "\t-S\t\tchase signature(s) from <name> to a know key [*]\n");
#endif /*HAVE_SSL*/
+ fprintf(stream, "\t-I <address>\tsource address to query from\n");
fprintf(stream, "\t-V <number>\tverbosity (0-5)\n");
fprintf(stream, "\t-Q\t\tquiet mode (overrules -V)\n");
fprintf(stream, "\n");
@@ -103,6 +104,7 @@ main(int argc, char *argv[])
ldns_pkt *pkt;
ldns_pkt *qpkt;
char *serv;
+ char *src = NULL;
const char *name;
char *name2;
char *progname;
@@ -110,6 +112,7 @@ main(int argc, char *argv[])
char *answer_file = NULL;
ldns_buffer *query_buffer = NULL;
ldns_rdf *serv_rdf;
+ ldns_rdf *src_rdf = NULL;
ldns_rr_type type;
ldns_rr_class clas;
#if 0
@@ -157,7 +160,7 @@ main(int argc, char *argv[])
int_type = -1; serv = NULL; type = 0;
int_clas = -1; name = NULL; clas = 0;
- qname = NULL;
+ qname = NULL; src = NULL;
progname = strdup(argv[0]);
#ifdef USE_WINSOCK
@@ -195,7 +198,7 @@ main(int argc, char *argv[])
/* global first, query opt next, option with parm's last
* and sorted */ /* "46DITSVQf:i:w:q:achuvxzy:so:p:b:k:" */
- while ((c = getopt(argc, argv, "46ab:c:d:Df:hi:Ik:o:p:q:Qr:sStTuvV:w:xy:z")) != -1) {
+ while ((c = getopt(argc, argv, "46ab:c:d:Df:hi:I:k:o:p:q:Qr:sStTuvV:w:xy:z")) != -1) {
switch(c) {
/* global options */
case '4':
@@ -208,7 +211,7 @@ main(int argc, char *argv[])
qdnssec = true;
break;
case 'I':
- /* reserved for backward compatibility */
+ src = optarg;
break;
case 'T':
if (PURPOSE == DRILL_CHASE) {
@@ -482,6 +485,14 @@ main(int argc, char *argv[])
}
}
+ if (src) {
+ src_rdf = ldns_rdf_new_addr_frm_str(src);
+ if(!src_rdf) {
+ fprintf(stderr, "-I must be (or resolve) to a valid IP[v6] address.\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+
/* set the nameserver to use */
if (!serv) {
/* no server given make a resolver from /etc/resolv.conf */
@@ -513,6 +524,7 @@ main(int argc, char *argv[])
ldns_resolver_set_ip6(cmdline_res, qfamily);
ldns_resolver_set_fallback(cmdline_res, qfallback);
ldns_resolver_set_usevc(cmdline_res, qusevc);
+ ldns_resolver_set_source(cmdline_res, src_rdf);
cmdline_dname = ldns_dname_new_frm_str(serv);
@@ -543,6 +555,7 @@ main(int argc, char *argv[])
}
/* set the resolver options */
ldns_resolver_set_port(res, qport);
+ ldns_resolver_set_source(res, src_rdf);
if (verbosity >= 5) {
ldns_resolver_set_debug(res, true);
} else {
@@ -613,10 +626,17 @@ main(int argc, char *argv[])
ldns_resolver_set_dnssec_cd(res, true);
/* set dnssec implies udp_size of 4096 */
ldns_resolver_set_edns_udp_size(res, 4096);
- pkt = ldns_resolver_query(res, qname, type, clas, qflags);
-
+ pkt = NULL;
+ status = ldns_resolver_query_status(
+ &pkt, res, qname, type, clas, qflags);
+ if (status != LDNS_STATUS_OK) {
+ error("error sending query: %s",
+ ldns_get_errorstr_by_id(status));
+ }
if (!pkt) {
- error("%s", "error pkt sending");
+ if (status == LDNS_STATUS_OK) {
+ error("%s", "error pkt sending");
+ }
result = EXIT_FAILURE;
} else {
if (verbosity >= 3) {
@@ -742,9 +762,17 @@ main(int argc, char *argv[])
}
/* create a packet and set the RD flag on it */
- pkt = ldns_resolver_query(res, qname, type, clas, qflags);
+ pkt = NULL;
+ status = ldns_resolver_query_status(
+ &pkt, res, qname, type, clas, qflags);
+ if (status != LDNS_STATUS_OK) {
+ error("error sending query: %s",
+ ldns_get_errorstr_by_id(status));
+ }
if (!pkt) {
- error("%s", "pkt sending");
+ if (status == LDNS_STATUS_OK) {
+ error("%s", "pkt sending");
+ }
result = EXIT_FAILURE;
} else {
if (verbosity != -1) {
@@ -815,7 +843,15 @@ main(int argc, char *argv[])
goto exit;
} else {
/* create a packet and set the RD flag on it */
- pkt = ldns_resolver_query(res, qname, type, clas, qflags);
+ pkt = NULL;
+ status = ldns_resolver_query_status(
+ &pkt, res, qname,
+ type, clas, qflags);
+ if (status != LDNS_STATUS_OK) {
+ error("error sending query: %s"
+ , ldns_get_errorstr_by_id(
+ status));
+ }
}
}
@@ -926,6 +962,7 @@ main(int argc, char *argv[])
exit:
ldns_rdf_deep_free(qname);
+ ldns_rdf_deep_free(src_rdf);
ldns_resolver_deep_free(res);
ldns_resolver_deep_free(cmdline_res);
ldns_rr_list_deep_free(key_list);
diff --git a/drill/drill_util.c b/drill/drill_util.c
index db0433e7..9cf90a50 100644
--- a/drill/drill_util.c
+++ b/drill/drill_util.c
@@ -17,10 +17,10 @@ static int
read_line(FILE *input, char *line, size_t len)
{
int i;
-
- char c;
+ int c;
+
for (i = 0; i < (int)len-1; i++) {
- c = (char)getc(input);
+ c = getc(input);
if (c == EOF) {
return -1;
} else if (c != '\n') {
diff --git a/drill/securetrace.c b/drill/securetrace.c
index c6e7e588..5fc493a7 100644
--- a/drill/securetrace.c
+++ b/drill/securetrace.c
@@ -138,7 +138,7 @@ do_secure_trace(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t,
size_t j;
size_t k;
size_t l;
- uint8_t labels_count;
+ uint8_t labels_count = 0;
/* dnssec */
ldns_rr_list *key_list;
@@ -156,6 +156,9 @@ do_secure_trace(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t,
/* empty non-terminal check */
bool ent;
+ ldns_rr *nsecrr; /* The nsec that proofs the non-terminal */
+ ldns_rdf *hashed_name; /* The query hashed with nsec3 params */
+ ldns_rdf *label0; /* The first label of an nsec3 owner name */
/* glue handling */
ldns_rr_list *new_ns_addr;
@@ -220,6 +223,8 @@ do_secure_trace(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t,
ldns_resolver_usevc(local_res));
ldns_resolver_set_random(res,
ldns_resolver_random(local_res));
+ ldns_resolver_set_source(res,
+ ldns_resolver_source(local_res));
ldns_resolver_set_recursive(local_res, true);
ldns_resolver_set_recursive(res, false);
@@ -380,8 +385,27 @@ do_secure_trace(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t,
/* there might be an empty non-terminal, in which case we need to continue */
ent = false;
for (j = 0; j < ldns_rr_list_rr_count(nsec_rrs); j++) {
- if (ldns_dname_is_subdomain(ldns_rr_rdf(ldns_rr_list_rr(nsec_rrs, j), 0), labels[i])) {
+ nsecrr = ldns_rr_list_rr(nsec_rrs, j);
+ /* For NSEC when the next name is a subdomain of the question */
+ if (ldns_rr_get_type(nsecrr) == LDNS_RR_TYPE_NSEC &&
+ ldns_dname_is_subdomain(ldns_rr_rdf(nsecrr, 0), labels[i])) {
ent = true;
+
+ /* For NSEC3, the hash matches the name and the type bitmap is empty*/
+ } else if (ldns_rr_get_type(nsecrr) == LDNS_RR_TYPE_NSEC3) {
+ hashed_name = ldns_nsec3_hash_name_frm_nsec3(nsecrr, labels[i]);
+ label0 = ldns_dname_label(ldns_rr_owner(nsecrr), 0);
+ if (hashed_name && label0 &&
+ ldns_dname_compare(hashed_name, label0) == 0 &&
+ ldns_nsec3_bitmap(nsecrr) == NULL) {
+ ent = true;
+ }
+ if (label0) {
+ LDNS_FREE(label0);
+ }
+ if (hashed_name) {
+ LDNS_FREE(hashed_name);
+ }
}
}
if (!ent) {
diff --git a/drill/work.c b/drill/work.c
index 653145fe..370d48b0 100644
--- a/drill/work.c
+++ b/drill/work.c
@@ -235,6 +235,7 @@ dump_hex(const ldns_pkt *pkt, const char *filename)
if (status != LDNS_STATUS_OK) {
error("Unable to convert packet: error code %u", status);
LDNS_FREE(wire);
+ fclose(fp);
return;
}
diff --git a/error.c b/error.c
index 2fc63e9b..dccf47d3 100644
--- a/error.c
+++ b/error.c
@@ -124,6 +124,24 @@ ldns_lookup_table ldns_error_str[] = {
{ LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR,
"The validation path "
"did not end in a self-signed certificate" },
+ { LDNS_STATUS_INVALID_ILNP64,
+ "Conversion error, 4 colon separated hex numbers expected" },
+ { LDNS_STATUS_INVALID_EUI48,
+ "Conversion error, 6 two character hex numbers "
+ "separated by dashes expected (i.e. xx-xx-xx-xx-xx-xx" },
+ { LDNS_STATUS_INVALID_EUI64,
+ "Conversion error, 8 two character hex numbers "
+ "separated by dashes expected (i.e. xx-xx-xx-xx-xx-xx-xx-xx" },
+ { LDNS_STATUS_WIRE_RDATA_ERR, "invalid rdata in wire format" },
+ { LDNS_STATUS_INVALID_TAG,
+ "Conversion error, a non-zero sequence of US-ASCII letters "
+ "and numbers in lower case expected" },
+ { LDNS_STATUS_TYPE_NOT_IN_BITMAP,
+ "The RR type bitmap rdata field did not have "
+ "a bit reserved for the specific RR type" },
+ { LDNS_STATUS_INVALID_RDF_TYPE,
+ "The rdata field was not of the expected type" },
+ { LDNS_STATUS_RDATA_OVERFLOW, "Rdata size overflow" },
{ 0, NULL }
};
diff --git a/examples/configure.ac b/examples/configure.ac
index 9bd74ff4..e33983e7 100644
--- a/examples/configure.ac
+++ b/examples/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.56)
-AC_INIT(ldns, 1.6.16, libdns@nlnetlabs.nl,libdns)
+AC_INIT(ldns, 1.6.17, libdns@nlnetlabs.nl,libdns)
AC_CONFIG_SRCDIR([ldns-read-zone.c])
sinclude(../acx_nlnetlabs.m4)
@@ -137,7 +137,7 @@ AC_SUBST(LIBSSL_CPPFLAGS)
AC_SUBST(LIBSSL_LDFLAGS)
AC_SUBST(LIBSSL_LIBS)
if test "x$HAVE_SSL" = "xyes"; then
-AC_SUBST(LIBSSL_SSL_LIBS, ["$LIBSSL_LIBS -lssl"])
+AC_SUBST(LIBSSL_SSL_LIBS, ["-lssl $LIBSSL_LIBS"])
fi
CPPFLAGS="$tmp_CPPFLAGS"
LDFLAGS="$tmp_LDFLAGS"
@@ -176,18 +176,34 @@ case "$enable_gost" in
;;
esac
-AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--enable-ecdsa], [Enable ECDSA support, experimental]))
+AC_ARG_ENABLE(ecdsa, AC_HELP_STRING([--disable-ecdsa], [Disable ECDSA support]))
case "$enable_ecdsa" in
- yes)
- AC_CHECK_FUNC(ECDSA_sign,,[AC_MSG_ERROR([OpenSSL does not support ECDSA])])
- AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
- AC_WARN([
- *****************************************************************
- *** YOU HAVE ENABLED ECDSA WHICH IS EXPERIMENTAL AT THIS TIME ***
- *** PLEASE DO NOT USE THIS ON THE PUBLIC INTERNET ***
- *****************************************************************])
+ no)
+ ;;
+ *) dnl default
+ if test "x$HAVE_SSL" != "xyes"; then
+ AC_MSG_ERROR([ECDSA enabled, but no SSL support])
+ fi
+ AC_CHECK_FUNC(ECDSA_sign, [], [AC_MSG_ERROR([OpenSSL does not support ECDSA: please upgrade OpenSSL or rerun with --disable-ecdsa])])
+ AC_CHECK_FUNC(SHA384_Init, [], [AC_MSG_ERROR([OpenSSL does not support SHA384: please upgrade OpenSSL or rerun with --disable-ecdsa])])
+ AC_CHECK_DECLS([NID_X9_62_prime256v1, NID_secp384r1], [], [AC_MSG_ERROR([OpenSSL does not support the ECDSA curves: please upgrade OpenSSL or rerun with --disable-ecdsa])], [AC_INCLUDES_DEFAULT
+#include <openssl/evp.h>
+ ])
+ # we now know we have ECDSA and the required curves.
+ AC_DEFINE_UNQUOTED([USE_ECDSA], [1], [Define this to enable ECDSA support.])
+ ;;
+esac
+
+AC_ARG_ENABLE(dane, AC_HELP_STRING([--disable-dane], [Disable DANE support]))
+case "$enable_dane" in
+ no)
;;
- no|*)
+ *) dnl default
+ if test "x$HAVE_SSL" != "xyes"; then
+ AC_MSG_ERROR([DANE enabled, but no SSL support])
+ fi
+ AC_CHECK_FUNC(X509_check_ca, [], [AC_MSG_ERROR([OpenSSL does not support DANE: please upgrade OpenSSL or rerun with --disable-dane])])
+ AC_DEFINE_UNQUOTED([USE_DANE], [1], [Define this to enable DANE support.])
;;
esac
diff --git a/examples/ldns-compare-zones.c b/examples/ldns-compare-zones.c
index 663b744a..a39c4b80 100644
--- a/examples/ldns-compare-zones.c
+++ b/examples/ldns-compare-zones.c
@@ -33,6 +33,8 @@ usage(char *prog)
printf(" -a - print all differences (-i -d -c)\n");
printf(" -s - do not exclude SOA record from comparison\n");
printf(" -z - do not sort zones\n");
+ printf(" -h - show usage and exit\n");
+ printf(" -v - show the version and exit\n");
}
int
diff --git a/examples/ldns-dane.1.in b/examples/ldns-dane.1.in
index 8f05d7f6..b65e64f0 100644
--- a/examples/ldns-dane.1.in
+++ b/examples/ldns-dane.1.in
@@ -151,6 +151,9 @@ Read TLSA record(s) from \fItlsafile\fR. When \fIname\fR and \fIport\fR
are also given, only TLSA records that match the \fIname\fR, \fIport\fR and
\fItransport\fR are used. Otherwise the owner name of the TLSA record(s)
will be used to determine \fIname\fR, \fIport\fR and \fItransport\fR.
+.IP -T
+Return exit status 2 for PKIX validated connections without (secure)
+TLSA records(s)
.IP -u
Use UDP transport instead of TCP.
.IP -v
diff --git a/examples/ldns-dane.c b/examples/ldns-dane.c
index 3ae35881..93c18e54 100644
--- a/examples/ldns-dane.c
+++ b/examples/ldns-dane.c
@@ -15,13 +15,27 @@
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
#include <netdb.h>
+#endif
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h>
+#endif
+#include <sys/time.h>
+#include <errno.h>
+#include <fcntl.h>
#include <ldns/ldns.h>
-
#include <errno.h>
+#ifdef USE_DANE
#ifdef HAVE_SSL
#include <openssl/ssl.h>
#include <openssl/err.h>
@@ -37,6 +51,11 @@
exit(EXIT_FAILURE); } while (false)
#define BUFSIZE 16384
+/* Exit status on a PKIX validated connection but without TLSA records
+ * when the -T option was given:
+ */
+#define NO_TLSAS_EXIT_STATUS 2
+
/* int verbosity = 3; */
void
@@ -106,9 +125,11 @@ print_usage(const char* progname)
printf("\t-t <tlsafile>\tdo not use DNS, "
"but read TLSA record(s) from <tlsafile>\n"
);
+ printf("\t-T\t\tReturn exit status 2 for PKIX validated connections\n"
+ "\t\t\twithout (secure) TLSA records(s)\n");
printf("\t-u\t\tuse UDP transport instead of TCP\n");
printf("\t-v\t\tshow version and exit\n");
- /* printf("\t-V [0-5]\tset verbosity level (defaul 3)\n"); */
+ /* printf("\t-V [0-5]\tset verbosity level (default 3)\n"); */
exit(EXIT_SUCCESS);
}
@@ -197,7 +218,8 @@ ldns_err(const char* s, ldns_status err)
ldns_status
ssl_connect_and_get_cert_chain(
X509** cert, STACK_OF(X509)** extra_certs,
- SSL* ssl, ldns_rdf* address, uint16_t port,
+ SSL* ssl, const char* name_str,
+ ldns_rdf* address, uint16_t port,
ldns_dane_transport transport)
{
struct sockaddr_storage *a = NULL;
@@ -246,6 +268,9 @@ ssl_connect_and_get_cert_chain(
fprintf(stderr, "SSL_clear\n");
return LDNS_STATUS_SSL_ERR;
}
+#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
+ (void) SSL_set_tlsext_host_name(ssl, name_str);
+#endif
SSL_set_connect_state(ssl);
(void) SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
if (! SSL_set_fd(ssl, sock)) {
@@ -359,12 +384,6 @@ ssl_interact(SSL* ssl)
}
-void
-ssl_shutdown(SSL* ssl)
-{
- while (SSL_shutdown(ssl) == 0);
-}
-
ldns_rr_list*
rr_list_filter_rr_type(ldns_rr_list* l, ldns_rr_type t)
{
@@ -715,7 +734,7 @@ dane_lookup_addresses(ldns_resolver* res, ldns_rdf* dname,
} else if (s == LDNS_STATUS_DANE_BOGUS ||
LDNS_STATUS_CRYPTO_BOGUS == s) {
- fprintf(stderr, "Warning! Bogus IPv4 addresses. "
+ fprintf(stderr, "Warning! Bogus IPv6 addresses. "
"Discarding...\n");
ldns_rr_list_deep_free(aaas);
aaas = ldns_rr_list_new();
@@ -1041,7 +1060,8 @@ bool
dane_verify(ldns_rr_list* tlsas, ldns_rdf* address,
X509* cert, STACK_OF(X509)* extra_certs,
X509_STORE* validate_store,
- bool verify_server_name, ldns_rdf* name)
+ bool verify_server_name, ldns_rdf* name,
+ bool assume_pkix_validity)
{
ldns_status s;
char* address_str = NULL;
@@ -1066,6 +1086,11 @@ dane_verify(ldns_rr_list* tlsas, ldns_rdf* address,
}
fprintf(stdout, " dane-validated successfully\n");
return true;
+ } else if (assume_pkix_validity &&
+ s == LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE) {
+ fprintf(stdout, " dane-validated successfully,"
+ " because PKIX is assumed valid\n");
+ return true;
}
fprintf(stdout, " did not dane-validate, because: %s\n",
ldns_get_errorstr_by_id(s));
@@ -1145,12 +1170,15 @@ main(int argc, char* const* argv)
SSL_CTX* ctx = NULL;
SSL* ssl = NULL;
+ int no_tlsas_exit_status = EXIT_SUCCESS;
+ int exit_success = EXIT_SUCCESS;
+
bool success = true;
if (! keys || ! addresses) {
MEMERR("ldns_rr_list_new");
}
- while((c = getopt(argc, argv, "46a:bc:df:hik:no:p:sSt:uvV:")) != -1) {
+ while((c = getopt(argc, argv, "46a:bc:df:hik:no:p:sSt:TuvV:")) != -1){
switch(c) {
case 'h':
print_usage("ldns-dane");
@@ -1242,6 +1270,9 @@ main(int argc, char* const* argv)
case 't':
tlsas_file = optarg;
break;
+ case 'T':
+ no_tlsas_exit_status = NO_TLSAS_EXIT_STATUS;
+ break;
case 'u':
transport = LDNS_DANE_TRANSPORT_UDP;
break;
@@ -1323,7 +1354,7 @@ main(int argc, char* const* argv)
exit(EXIT_FAILURE);
}
s = dane_read_tlsas_from_file(&tlsas, tlsas_file, NULL);
- LDNS_ERR(s, "could not read tlas from file");
+ LDNS_ERR(s, "could not read tlsas from file");
/* extract port, transport and hostname from TLSA owner name */
@@ -1465,7 +1496,9 @@ main(int argc, char* const* argv)
"PKIX validation without DANE will be "
"performed. If you wish to perform DANE\n"
"even though the RR's are insecure, "
- "se the -d option.\n", tlsa_owner_str);
+ "use the -d option.\n", tlsa_owner_str);
+
+ exit_success = no_tlsas_exit_status;
} else if (s != LDNS_STATUS_OK) {
@@ -1478,6 +1511,8 @@ main(int argc, char* const* argv)
"PKIX validation without DANE will be "
"performed.\n", ldns_rdf2str(tlsa_owner));
+ exit_success = no_tlsas_exit_status;
+
} else if (assume_pkix_validity) { /* number of tlsa's > 0 */
/* transform type "CA constraint" to "Trust anchor
@@ -1590,13 +1625,13 @@ main(int argc, char* const* argv)
SSL_CTX_use_certificate_chain_file(ctx, cert_file) != 1) {
ssl_err("error loading certificate");
}
- ssl = SSL_new(ctx);
- if (! ssl) {
- ssl_err("could not SSL_new");
- }
if (cert_file) { /* ssl load certificate */
+ ssl = SSL_new(ctx);
+ if (! ssl) {
+ ssl_err("could not SSL_new");
+ }
cert = SSL_get_certificate(ssl);
if (! cert) {
ssl_err("could not SSL_get_certificate");
@@ -1613,12 +1648,14 @@ main(int argc, char* const* argv)
break;
case VERIFY: if (! dane_verify(tlsas, NULL,
cert, extra_certs, store,
- verify_server_name, name)) {
+ verify_server_name, name,
+ assume_pkix_validity)) {
success = false;
}
break;
default: break; /* suppress warning */
}
+ SSL_free(ssl);
} else {/* No certificate file given, creation/validation via TLS. */
@@ -1639,12 +1676,16 @@ main(int argc, char* const* argv)
/* for all addresses, setup SSL and retrieve certificates */
for (i = 0; i < ldns_rr_list_rr_count(addresses); i++) {
+ ssl = SSL_new(ctx);
+ if (! ssl) {
+ ssl_err("could not SSL_new");
+ }
address = ldns_rr_a_address(
ldns_rr_list_rr(addresses, i));
assert(address != NULL);
s = ssl_connect_and_get_cert_chain(&cert, &extra_certs,
- ssl, address, port, transport);
+ ssl, name_str, address,port, transport);
if (s == LDNS_STATUS_NETWORK_ERR) {
fprintf(stderr, "Could not connect to ");
ldns_rdf_print(stderr, address);
@@ -1666,7 +1707,8 @@ main(int argc, char* const* argv)
case VERIFY: if (! dane_verify(tlsas, address,
cert, extra_certs, store,
- verify_server_name, name)) {
+ verify_server_name, name,
+ assume_pkix_validity)) {
success = false;
} else if (interact) {
@@ -1675,7 +1717,8 @@ main(int argc, char* const* argv)
break;
default: break; /* suppress warning */
}
- ssl_shutdown(ssl);
+ while (SSL_shutdown(ssl) == 0);
+ SSL_free(ssl);
} /* end for all addresses */
} /* end No certification file */
@@ -1689,7 +1732,6 @@ main(int argc, char* const* argv)
ldns_rr_list_deep_free(tlsas);
/* cleanup */
- SSL_free(ssl);
SSL_CTX_free(ctx);
if (store) {
@@ -1705,12 +1747,12 @@ main(int argc, char* const* argv)
ldns_rr_list_deep_free(addresses);
}
if (success) {
- exit(EXIT_SUCCESS);
+ exit(exit_success);
} else {
exit(EXIT_FAILURE);
}
}
-#else
+#else /* HAVE_SSL */
int
main(int argc, char **argv)
@@ -1720,3 +1762,15 @@ main(int argc, char **argv)
return 1;
}
#endif /* HAVE_SSL */
+
+#else /* USE_DANE */
+
+int
+main(int argc, char **argv)
+{
+ fprintf(stderr, "dane support was disabled with this build of ldns, "
+ "and has not been compiled in\n");
+ return 1;
+}
+
+#endif /* USE_DANE */
diff --git a/examples/ldns-dpa.c b/examples/ldns-dpa.c
index c5717b24..0bc8a840 100644
--- a/examples/ldns-dpa.c
+++ b/examples/ldns-dpa.c
@@ -2823,13 +2823,13 @@ int main(int argc, char *argv[]) {
}
#else
-int main() {
+int main(void) {
fprintf(stderr, "ldns-dpa was not built because there is no pcap library on this system, or there was no pcap header file at compilation time. Please install pcap and rebuild.\n");
return 1;
}
#endif
#else
-int main() {
+int main(void) {
fprintf(stderr, "ldns-dpa was not built because there is no pcap library on this system, or there was no pcap header file at compilation time. Please install pcap and rebuild.\n");
return 1;
}
diff --git a/examples/ldns-key2ds.1 b/examples/ldns-key2ds.1
index 6fdbee5f..a20ab96f 100644
--- a/examples/ldns-key2ds.1
+++ b/examples/ldns-key2ds.1
@@ -17,6 +17,10 @@ SHA1 for RSASHA1, and so on.
.SH OPTIONS
.TP
+\fB-f\fR
+Ignore SEP flag (i.e. make DS records for any key)
+
+.TP
\fB-n\fR
Write the result DS Resource Record to stdout instead of a file
diff --git a/examples/ldns-key2ds.c b/examples/ldns-key2ds.c
index a3e54383..9426f685 100644
--- a/examples/ldns-key2ds.c
+++ b/examples/ldns-key2ds.c
@@ -63,8 +63,7 @@ suitable_hash(ldns_signing_algorithm algorithm)
case LDNS_SIGN_ECDSAP384SHA384:
return LDNS_SHA384;
#endif
- default:
- return LDNS_SHA1;
+ default: break;
}
return LDNS_SHA1;
}
diff --git a/examples/ldns-keyfetcher.c b/examples/ldns-keyfetcher.c
index fa78b432..4988bfbb 100644
--- a/examples/ldns-keyfetcher.c
+++ b/examples/ldns-keyfetcher.c
@@ -151,7 +151,7 @@ retrieve_dnskeys(ldns_resolver *local_res, ldns_rdf *name, ldns_rr_type t,
* try to resolve the names we do got
*/
if (verbosity >= 3) {
- printf("Did not get address record for nameserver, doing seperate query.\n");
+ printf("Did not get address record for nameserver, doing separate query.\n");
}
ns_addr = ldns_rr_list_new();
for(i = 0; (size_t) i < ldns_rr_list_rr_count(new_nss); i++) {
diff --git a/examples/ldns-keygen.c b/examples/ldns-keygen.c
index 57654179..316d60d7 100644
--- a/examples/ldns-keygen.c
+++ b/examples/ldns-keygen.c
@@ -71,7 +71,7 @@ main(int argc, char *argv[])
random = NULL;
ksk = false; /* don't create a ksk per default */
- while ((c = getopt(argc, argv, "a:kb:r:v25")) != -1) {
+ while ((c = getopt(argc, argv, "a:kb:r:v")) != -1) {
switch (c) {
case 'a':
if (algorithm != 0) {
@@ -182,7 +182,7 @@ main(int argc, char *argv[])
/* generate a new key */
key = ldns_key_new_frm_algorithm(algorithm, bits);
- /* set the owner name in the key - this is a /seperate/ step */
+ /* set the owner name in the key - this is a /separate/ step */
ldns_key_set_pubkey_owner(key, domain);
/* ksk flag */
diff --git a/examples/ldns-read-zone.1 b/examples/ldns-read-zone.1
index 7d4fd7d9..8652fe9a 100644
--- a/examples/ldns-read-zone.1
+++ b/examples/ldns-read-zone.1
@@ -22,6 +22,10 @@ that is not of type NSEC, NSEC3, RRSIG or DNSKEY. DS records are not
printed.
.TP
+\fB-b\fR
+Include Bubble Babble encoding of DS's.
+
+.TP
\fB-0\fR
Print a (null) for the RRSIG inception, expiry and key data. This option
can be used when comparing different signing systems that use the same
@@ -58,6 +62,23 @@ increased by one.
When updating a serial number, records of type NSEC, NSEC3, RRSIG and DNSKEY
will be skipped when printing the zone.
+.TP
+\fB-u\fR \fIRR type\fR
+Mark \fIRR type\fR for printing in unknown type format.
+
+\fB-u\fR is not meant to be used together with \fB-U\fR.
+
+.TP
+\fB-U\fR \fIRR type\fR
+Mark \fIRR type\fR for \fBnot\fR printing in unknown type format.
+
+The first occurrence of the \fB-U\fR option marks all RR types for printing
+in unknown type format except for the given \fIRR type\fR.
+Subsequent \fB-U\fR options will clear the mark for those \fIRR type\fRs too,
+so that only the given \fIRR type\fRs will be printed in the presentation
+format specific for those \fIRR type\fRs.
+
+\fB-U\fR is not meant to be used together with \fB-u\fR.
.TP
\fB-v\fR
diff --git a/examples/ldns-read-zone.c b/examples/ldns-read-zone.c
index efe187e6..512621d3 100644
--- a/examples/ldns-read-zone.c
+++ b/examples/ldns-read-zone.c
@@ -15,6 +15,52 @@
#include <errno.h>
+void print_usage(const char* progname)
+{
+ printf("Usage: %s [OPTIONS] <zonefile>\n", progname);
+ printf("\tReads the zonefile and prints it.\n");
+ printf("\tThe RR count of the zone is printed to stderr.\n");
+ printf("\t-b include Bubble Babble encoding of DS's.\n");
+ printf("\t-0 zeroize timestamps and signature in RRSIG records.\n");
+ printf("\t-c canonicalize all rrs in the zone.\n");
+ printf("\t-d only show DNSSEC data from the zone\n");
+ printf("\t-h show this text\n");
+ printf("\t-n do not print the SOA record\n");
+ printf("\t-p prepend SOA serial with spaces so"
+ " it takes exactly ten characters.\n");
+ printf("\t-s strip DNSSEC data from the zone\n");
+ printf("\t-S [[+|-]<number> | YYYYMMDDxx | "
+ " unixtime ]\n"
+ "\t\tSet serial number to <number> or,"
+ " when preceded by a sign,\n"
+ "\t\toffset the existing number with "
+ "<number>. With YYYYMMDDxx\n"
+ "\t\tthe serial is formatted as a datecounter"
+ ", and with unixtime as\n"
+ "\t\tthe number of seconds since 1-1-1970."
+ " However, on serial\n"
+ "\t\tnumber decrease, +1 is used in stead"
+ ". (implies -s)\n");
+ printf("\t-u <rr type>\n");
+ printf("\t\tMark <rr type> for printing in unknown type format.\n");
+ printf("\t\tThis option may be given multiple times.\n");
+ printf("\t\t-u is not meant to be used together with -U.\n");
+ printf("\t-U <rr type>\n");
+ printf("\t\tMark <rr type> for not printing in unknown type format.\n");
+ printf("\t\tThis option may be given multiple times.\n");
+ printf(
+ "\t\tThe first occurrence of the -U option marks all RR types for"
+ "\n\t\tprinting in unknown type format except for the given <rr type>."
+ "\n\t\tSubsequent -U options will clear the mark for those <rr type>s"
+ "\n\t\ttoo, so that only the given <rr type>s will be printed in the"
+ "\n\t\tpresentation format specific for those <rr type>s.\n");
+ printf("\t\t-U is not meant to be used together with -u.\n");
+ printf("\t-v shows the version and exits\n");
+ printf("\t-z sort the zone (implies -c).\n");
+ printf("\nif no file is given standard input is read\n");
+ exit(EXIT_SUCCESS);
+}
+
int
main(int argc, char **argv)
{
@@ -33,22 +79,21 @@ main(int argc, char **argv)
ldns_rr_list *stripped_list;
ldns_rr *cur_rr;
ldns_rr_type cur_rr_type;
- ldns_output_format fmt = {
- ldns_output_format_default->flags,
- ldns_output_format_default->data
- };
+ ldns_output_format_storage fmt_storage;
+ ldns_output_format* fmt = ldns_output_format_init(&fmt_storage);
+
ldns_soa_serial_increment_func_t soa_serial_increment_func = NULL;
int soa_serial_increment_func_data = 0;
- while ((c = getopt(argc, argv, "0bcdhnpsvzS:")) != -1) {
+ while ((c = getopt(argc, argv, "0bcdhnpsu:U:vzS:")) != -1) {
switch(c) {
case 'b':
- fmt.flags |=
+ fmt->flags |=
( LDNS_COMMENT_BUBBLEBABBLE |
LDNS_COMMENT_FLAGS );
break;
case '0':
- fmt.flags |= LDNS_FMT_ZEROIZE_RRSIGS;
+ fmt->flags |= LDNS_FMT_ZEROIZE_RRSIGS;
break;
case 'c':
canonicalize = true;
@@ -60,40 +105,13 @@ main(int argc, char **argv)
}
break;
case 'h':
- printf("Usage: %s [OPTIONS] <zonefile>\n", argv[0]);
- printf("\tReads the zonefile and prints it.\n");
- printf("\tThe RR count of the zone is printed to stderr.\n");
- printf("\t-b include bubblebabble of DS's.\n");
- printf("\t-0 zeroize timestamps and signature in RRSIG records.\n");
- printf("\t-c canonicalize all rrs in the zone.\n");
- printf("\t-d only show DNSSEC data from the zone\n");
- printf("\t-h show this text\n");
- printf("\t-n do not print the SOA record\n");
- printf("\t-p prepend SOA serial with spaces so"
- " it takes exactly ten characters.\n");
- printf("\t-s strip DNSSEC data from the zone\n");
- printf("\t-S [[+|-]<number> | YYYYMMDDxx | "
- " unixtime ]\n"
- "\t\tSet serial number to <number> or,"
- " when preceded by a sign,\n"
- "\t\toffset the existing number with "
- "<number>. With YYYYMMDDxx\n"
- "\t\tthe serial is formatted as a datecounter"
- ", and with unixtime as the\n"
- "\t\tnumber of seconds since 1-1-1970."
- " However, on serial number"
- "\n\t\tdecrease, +1 is used in stead"
- ". (implies -s)\n");
- printf("\t-v shows the version and exits\n");
- printf("\t-z sort the zone (implies -c).\n");
- printf("\nif no file is given standard input is read\n");
- exit(EXIT_SUCCESS);
+ print_usage("ldns-read-zone");
break;
case 'n':
print_soa = false;
break;
case 'p':
- fmt.flags |= LDNS_FMT_PAD_SOA_SERIAL;
+ fmt->flags |= LDNS_FMT_PAD_SOA_SERIAL;
break;
case 's':
strip = true;
@@ -101,6 +119,38 @@ main(int argc, char **argv)
fprintf(stderr, "Warning: stripping both DNSSEC and non-DNSSEC records. Output will be sparse.\n");
}
break;
+ case 'u':
+ s = ldns_output_format_set_type(fmt,
+ ldns_get_rr_type_by_name(optarg));
+ if (s != LDNS_STATUS_OK) {
+ fprintf( stderr
+ , "Cannot set rr type %s "
+ "in output format to "
+ "print as unknown type: %s\n"
+ , ldns_rr_descript(
+ ldns_get_rr_type_by_name(optarg)
+ )->_name
+ , ldns_get_errorstr_by_id(s)
+ );
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case 'U':
+ s = ldns_output_format_clear_type(fmt,
+ ldns_get_rr_type_by_name(optarg));
+ if (s != LDNS_STATUS_OK) {
+ fprintf( stderr
+ , "Cannot set rr type %s "
+ "in output format to not "
+ "print as unknown type: %s\n"
+ , ldns_rr_descript(
+ ldns_get_rr_type_by_name(optarg)
+ )->_name
+ , ldns_get_errorstr_by_id(s)
+ );
+ exit(EXIT_FAILURE);
+ }
+ break;
case 'v':
printf("read zone version %s (ldns version %s)\n", LDNS_VERSION, ldns_version());
exit(EXIT_SUCCESS);
@@ -218,9 +268,9 @@ main(int argc, char **argv)
, soa_serial_increment_func_data
);
}
- ldns_rr_print_fmt(stdout, &fmt, ldns_zone_soa(z));
+ ldns_rr_print_fmt(stdout, fmt, ldns_zone_soa(z));
}
- ldns_rr_list_print_fmt(stdout, &fmt, ldns_zone_rrs(z));
+ ldns_rr_list_print_fmt(stdout, fmt, ldns_zone_rrs(z));
ldns_zone_deep_free(z);
diff --git a/examples/ldns-signzone.c b/examples/ldns-signzone.c
index 25ece3a6..ffdd3c03 100644
--- a/examples/ldns-signzone.c
+++ b/examples/ldns-signzone.c
@@ -223,7 +223,7 @@ find_or_create_pubkey(const char *keyfile_name_base, ldns_key *key, ldns_zone *o
}
/* find the public key in the zone, or in a
- * seperate file
+ * separate file
* we 'generate' one anyway,
* then match that to any present in the zone,
* if it matches, we drop our own. If not,
@@ -368,9 +368,8 @@ main(int argc, char *argv[])
char *prog = strdup(argv[0]);
ldns_status result;
- ldns_output_format fmt = { ldns_output_format_default->flags, NULL };
- void **hashmap = NULL;
-
+ ldns_output_format_storage fmt_st;
+ ldns_output_format* fmt = ldns_output_format_init(&fmt_st);
inception = 0;
expiration = 0;
@@ -379,7 +378,7 @@ main(int argc, char *argv[])
OPENSSL_config(NULL);
- while ((c = getopt(argc, argv, "a:bde:f:i:k:lno:ps:t:vAE:K:")) != -1) {
+ while ((c = getopt(argc, argv, "a:bde:f:i:k:no:ps:t:vAE:K:")) != -1) {
switch (c) {
case 'a':
nsec3_algorithm = (uint8_t) atoi(optarg);
@@ -389,11 +388,10 @@ main(int argc, char *argv[])
}
break;
case 'b':
- fmt.flags |= LDNS_COMMENT_BUBBLEBABBLE;
- fmt.flags |= LDNS_COMMENT_FLAGS;
- fmt.flags |= LDNS_COMMENT_NSEC3_CHAIN;
- fmt.flags |= LDNS_COMMENT_LAYOUT;
- hashmap = &fmt.data;
+ ldns_output_format_set(fmt, LDNS_COMMENT_FLAGS
+ | LDNS_COMMENT_LAYOUT
+ | LDNS_COMMENT_NSEC3_CHAIN
+ | LDNS_COMMENT_BUBBLEBABBLE);
break;
case 'd':
add_keys = false;
@@ -767,7 +765,7 @@ main(int argc, char *argv[])
nsec3_salt_length,
nsec3_salt,
signflags,
- (ldns_rbtree_t**) hashmap);
+ &fmt_st.hashmap);
} else {
result = ldns_dnssec_zone_sign_flg(signed_zone,
added_rrs,
@@ -796,7 +794,7 @@ main(int argc, char *argv[])
outputfile_name, strerror(errno));
} else {
ldns_dnssec_zone_print_fmt(
- outputfile, &fmt, signed_zone);
+ outputfile, fmt, signed_zone);
fclose(outputfile);
}
}
diff --git a/examples/ldns-testns.c b/examples/ldns-testns.c
index 86219d60..f9732faa 100644
--- a/examples/ldns-testns.c
+++ b/examples/ldns-testns.c
@@ -155,7 +155,7 @@ static const char* prog_name = "ldns-testns";
static FILE* logfile = 0;
static int do_verbose = 0;
-static void usage()
+static void usage(void)
{
printf("Usage: %s [options] <datafile>\n", prog_name);
printf(" -r listens on random port. Port number is printed.\n");
diff --git a/examples/ldns-testpkts.c b/examples/ldns-testpkts.c
index be94eb2f..ed26285c 100644
--- a/examples/ldns-testpkts.c
+++ b/examples/ldns-testpkts.c
@@ -118,6 +118,8 @@ static void matchline(char* line, struct entry* e)
e->match_do = true;
} else if(str_keyword(&parse, "noedns")) {
e->match_noedns = true;
+ } else if(str_keyword(&parse, "ednsdata")) {
+ e->match_ednsdata_raw = true;
} else if(str_keyword(&parse, "UDP")) {
e->match_transport = transport_udp;
} else if(str_keyword(&parse, "TCP")) {
@@ -228,7 +230,7 @@ static void adjustline(char* line, struct entry* e,
}
/** create new entry */
-static struct entry* new_entry()
+static struct entry* new_entry(void)
{
struct entry* e = LDNS_MALLOC(struct entry);
memset(e, 0, sizeof(*e));
@@ -434,7 +436,9 @@ read_entry(FILE* in, const char* name, int *lineno, uint32_t* default_ttl,
ldns_pkt_section add_section = LDNS_SECTION_QUESTION;
struct reply_packet *cur_reply = NULL;
bool reading_hex = false;
+ bool reading_hex_ednsdata = false;
ldns_buffer* hex_data_buffer = NULL;
+ ldns_buffer* hex_ednsdata_buffer = NULL;
while(fgets(line, (int)sizeof(line), in) != NULL) {
line[MAX_LINE-1] = 0;
@@ -497,12 +501,26 @@ read_entry(FILE* in, const char* name, int *lineno, uint32_t* default_ttl,
cur_reply->reply_from_hex = data_buffer2wire(hex_data_buffer);
ldns_buffer_free(hex_data_buffer);
hex_data_buffer = NULL;
+ } else if(reading_hex) {
+ ldns_buffer_printf(hex_data_buffer, line);
+ } else if(str_keyword(&parse, "HEX_EDNSDATA_BEGIN")) {
+ hex_ednsdata_buffer = ldns_buffer_new(LDNS_MAX_PACKETLEN);
+ reading_hex_ednsdata = true;
+ } else if(str_keyword(&parse, "HEX_EDNSDATA_END")) {
+ if (!reading_hex_ednsdata) {
+ error("%s line %d: HEX_EDNSDATA_END read but no"
+ "HEX_EDNSDATA_BEGIN keyword seen", name, *lineno);
+ }
+ reading_hex_ednsdata = false;
+ cur_reply->raw_ednsdata = data_buffer2wire(hex_ednsdata_buffer);
+ ldns_buffer_free(hex_ednsdata_buffer);
+ hex_ednsdata_buffer = NULL;
+ } else if(reading_hex_ednsdata) {
+ ldns_buffer_printf(hex_ednsdata_buffer, line);
} else if(str_keyword(&parse, "ENTRY_END")) {
if (hex_data_buffer)
ldns_buffer_free(hex_data_buffer);
return current;
- } else if(reading_hex) {
- ldns_buffer_printf(hex_data_buffer, line);
} else {
/* it must be a RR, parse and add to packet. */
ldns_rr* n = NULL;
@@ -674,6 +692,38 @@ match_all(ldns_pkt* q, ldns_pkt* p, bool mttl)
return 1;
}
+/** Convert to hexstring and call verbose(), prepend with header */
+static void
+verbose_hex(int lvl, uint8_t *data, size_t datalen, const char *header)
+{
+ verbose(lvl, "%s", header);
+ while (datalen-- > 0) {
+ verbose(lvl, " %02x", (unsigned int)*data++);
+ }
+ verbose(lvl, "\n");
+}
+
+/** Match q edns data to p raw edns data */
+static int
+match_ednsdata(ldns_pkt* q, struct reply_packet* p)
+{
+ size_t qdlen, pdlen;
+ uint8_t *qd, *pd;
+ if(!ldns_pkt_edns(q) || !ldns_pkt_edns_data(q)) {
+ verbose(3, "No EDNS data\n");
+ return 0;
+ }
+ qdlen = ldns_rdf_size(ldns_pkt_edns_data(q));
+ pdlen = ldns_buffer_limit(p->raw_ednsdata);
+ qd = ldns_rdf_data(ldns_pkt_edns_data(q));
+ pd = ldns_buffer_begin(p->raw_ednsdata);
+ if( qdlen == pdlen && 0 == memcmp(qd, pd, qdlen) ) return 1;
+ verbose(3, "EDNS data does not match.\n");
+ verbose_hex(3, qd, qdlen, "q:");
+ verbose_hex(3, pd, pdlen, "p:");
+ return 0;
+}
+
/* finds entry in list, or returns NULL */
struct entry*
find_match(struct entry* entries, ldns_pkt* query_pkt,
@@ -724,6 +774,11 @@ find_match(struct entry* entries, ldns_pkt* query_pkt,
verbose(3, "bad; EDNS OPT present\n");
continue;
}
+ if(p->match_ednsdata_raw &&
+ !match_ednsdata(query_pkt, p->reply_list)) {
+ verbose(3, "bad EDNS data match.\n");
+ continue;
+ }
if(p->match_transport != transport_any && p->match_transport != transport) {
verbose(3, "bad transport\n");
continue;
diff --git a/examples/ldns-testpkts.h b/examples/ldns-testpkts.h
index 49415252..26a71dad 100644
--- a/examples/ldns-testpkts.h
+++ b/examples/ldns-testpkts.h
@@ -48,6 +48,7 @@
; 'ttl' used with all, rrs in packet must also have matching TTLs.
; 'DO' will match only queries with DO bit set.
; 'noedns' matches queries without EDNS OPT records.
+ ; 'ednsdata' matches queries to HEX_EDNS section.
MATCH [opcode] [qtype] [qname] [serial=<value>] [all] [ttl]
MATCH [UDP|TCP] DO
MATCH ...
@@ -82,6 +83,11 @@
; be parsed, ADJUST rules for the answer packet
; are ignored. Only copy_id is done.
HEX_ANSWER_END
+ HEX_EDNS_BEGIN ; follow with hex data.
+ ; Raw EDNS data to match against. It must be an
+ ; exact match (all options are matched) and will be
+ ; evaluated only when 'MATCH ednsdata' given.
+ HEX_EDNS_END
ENTRY_END
@@ -142,6 +148,8 @@ struct reply_packet {
struct reply_packet* next;
/** the reply pkt */
ldns_pkt* reply;
+ /** Additional EDNS data for matching queries. */
+ ldns_buffer* raw_ednsdata;
/** or reply pkt in hex if not parsable */
ldns_buffer* reply_from_hex;
/** seconds to sleep before giving packet */
@@ -171,6 +179,8 @@ struct entry {
bool match_do;
/** match absence of EDNS OPT record in query */
bool match_noedns;
+ /** match edns data field given in hex */
+ bool match_ednsdata_raw;
/** match query serial with this value. */
uint32_t ixfr_soa_serial;
/** match on UDP/TCP */
@@ -197,7 +207,8 @@ struct entry {
/**
* reads the canned reply file and returns a list of structs
* does an exit on error.
- * @param skip_withespace: skip leftside whitespace.
+ * @param name: name of the file to read.
+ * @param skip_whitespace: skip leftside whitespace.
*/
struct entry* read_datafile(const char* name, int skip_whitespace);
diff --git a/examples/ldns-update.c b/examples/ldns-update.c
index dca4cbe7..af4dd02a 100644
--- a/examples/ldns-update.c
+++ b/examples/ldns-update.c
@@ -17,7 +17,7 @@ ldns_update_resolver_new(const char *fqdn, const char *zone,
ldns_rr_class class, uint16_t port, ldns_tsig_credentials *tsig_cred, ldns_rdf **zone_rdf)
{
ldns_resolver *r1, *r2;
- ldns_pkt *query = NULL, *resp;
+ ldns_pkt *query = NULL, *resp = NULL;
ldns_rr_list *nslist, *iplist;
ldns_rdf *soa_zone, *soa_mname = NULL, *ns_name;
size_t i;
diff --git a/examples/ldns-verify-zone.c b/examples/ldns-verify-zone.c
index 0bbb97f4..156eb649 100644
--- a/examples/ldns-verify-zone.c
+++ b/examples/ldns-verify-zone.c
@@ -11,6 +11,7 @@
#include "config.h"
#include <unistd.h>
#include <stdlib.h>
+#include <sys/time.h>
#include <ldns/ldns.h>
@@ -245,74 +246,25 @@ verify_next_hashed_name(ldns_dnssec_zone* zone, ldns_dnssec_name *name)
{
ldns_rbnode_t *next_node;
ldns_dnssec_name *next_name;
- ldns_dnssec_name *cur_next_name = NULL;
- ldns_dnssec_name *cur_first_name = NULL;
int cmp;
char *next_owner_str;
ldns_rdf *next_owner_dname;
- if (!name->hashed_name) {
- name->hashed_name = ldns_nsec3_hash_name_frm_nsec3(
- name->nsec, name->name);
- }
- next_node = ldns_rbtree_first(zone->names);
- while (next_node != LDNS_RBTREE_NULL) {
- next_name = (ldns_dnssec_name *)next_node->data;
- /* skip over names that have no NSEC3 records (whether it
- * actually should or should not should have been checked
- * already */
- if (!next_name->nsec) {
- next_node = ldns_rbtree_next(next_node);
- continue;
- }
- if (!next_name->hashed_name) {
- next_name->hashed_name =
- ldns_nsec3_hash_name_frm_nsec3(name->nsec,
- next_name->name);
- }
- /* we keep track of what 'so far' is the next hashed name;
- * it must of course be 'larger' than the current name
- * if we find one that is larger, but smaller than what we
- * previously thought was the next one, that one is the next
- */
- cmp = ldns_dname_compare(name->hashed_name,
- next_name->hashed_name);
- if (cmp < 0) {
- if (!cur_next_name) {
- cur_next_name = next_name;
- } else {
- cmp = ldns_dname_compare(
- next_name->hashed_name,
- cur_next_name->hashed_name);
- if (cmp < 0) {
- cur_next_name = next_name;
- }
- }
- }
- /* in case the hashed name of the nsec we are checking is the
- * last one, we need the first hashed name of the zone */
- if (!cur_first_name) {
- cur_first_name = next_name;
- } else {
- cmp = ldns_dname_compare(next_name->hashed_name,
- cur_first_name->hashed_name);
- if (cmp < 0) {
- cur_first_name = next_name;
- }
- }
+ assert(name->hashed_name != NULL);
+
+ next_node = ldns_rbtree_search(zone->hashed_names, name->hashed_name);
+ assert(next_node != NULL);
+ do {
next_node = ldns_rbtree_next(next_node);
- }
- if (!cur_next_name) {
- cur_next_name = cur_first_name;
- }
- assert(cur_next_name != NULL);
- /* Because this function is called on nsec occurrence,
- * there must be a cur_next_name!
- */
+ if (next_node == LDNS_RBTREE_NULL) {
+ next_node = ldns_rbtree_first(zone->hashed_names);
+ }
+ next_name = (ldns_dnssec_name *) next_node->data;
+ } while (! next_name->nsec);
next_owner_str = ldns_rdf2str(ldns_nsec3_next_owner(name->nsec));
next_owner_dname = ldns_dname_new_frm_str(next_owner_str);
- cmp = ldns_dname_compare(next_owner_dname, cur_next_name->hashed_name);
+ cmp = ldns_dname_compare(next_owner_dname, next_name->hashed_name);
ldns_rdf_deep_free(next_owner_dname);
LDNS_FREE(next_owner_str);
if (cmp != 0) {
@@ -321,9 +273,9 @@ verify_next_hashed_name(ldns_dnssec_zone* zone, ldns_dnssec_name *name)
ldns_rdf_print(stdout, name->name);
fprintf(myerr, " points to the wrong next hashed owner"
" name\n\tshould point to ");
- ldns_rdf_print(myerr, cur_next_name->name);
+ ldns_rdf_print(myerr, next_name->name);
fprintf(myerr, ", whose hashed name is ");
- ldns_rdf_print(myerr, cur_next_name->hashed_name);
+ ldns_rdf_print(myerr, next_name->hashed_name);
fprintf(myerr, "\n");
}
return LDNS_STATUS_ERR;
@@ -458,7 +410,7 @@ verify_dnssec_name(ldns_rdf *zone_name, ldns_dnssec_zone* zone,
/* for NSEC chain checks */
name = (ldns_dnssec_name *) cur_node->data;
- if (verbosity >= 3) {
+ if (verbosity >= 5) {
fprintf(myout, "Checking: ");
ldns_rdf_print(myout, name->name);
fprintf(myout, "\n");
@@ -913,7 +865,6 @@ main(int argc, char **argv)
"glue in the zone\n");
}
}
-
if (verbosity >= 5) {
ldns_dnssec_zone_print(myout, dnssec_zone);
}
diff --git a/examples/ldns-walk.1 b/examples/ldns-walk.1
index c8ace40e..d4d1b6e7 100644
--- a/examples/ldns-walk.1
+++ b/examples/ldns-walk.1
@@ -22,6 +22,14 @@ Of course the nameserver that is used must be DNSSEC-aware.
.SH OPTIONS
.TP
+\fB-4\fR
+Use only IPv4.
+
+.TP
+\fB-6\fR
+Use only IPv6.
+
+.TP
\fB-f\fR
Do a 'full' zone walk; by default, ldns-walk will only show the names, and types present at those names. If this option is given, all resource records will be printed.
@@ -31,6 +39,10 @@ Start the walk with this owner name. Useful when continuing the walk for a
large zone.
.TP
+\fB-v\fR \fIverbosity\fR
+Verbosity level [1-5].
+
+.TP
\fB@\fR \fInameserver\fR
Send the queries to this nameserver.
diff --git a/examples/ldns-zcat.1 b/examples/ldns-zcat.1
index 9c4054df..4fd7ba6d 100644
--- a/examples/ldns-zcat.1
+++ b/examples/ldns-zcat.1
@@ -18,6 +18,10 @@ The resulted zone file is printed to standard output.
.B -o ORIGIN
use ORIGIN when reading in the zone
+.TP
+.B -v
+show the version number and exit
+
.SH AUTHOR
Written by the ldns team as an example for ldns usage.
diff --git a/examples/ldns-zcat.c b/examples/ldns-zcat.c
index df4ecbaf..017e632c 100644
--- a/examples/ldns-zcat.c
+++ b/examples/ldns-zcat.c
@@ -54,7 +54,7 @@ main(int argc, char **argv)
progname = strdup(argv[0]);
origin = NULL;
- while ((c = getopt(argc, argv, "n:o:v")) != -1) {
+ while ((c = getopt(argc, argv, "o:v")) != -1) {
switch(c) {
case 'o':
origin = ldns_dname_new_frm_str(strdup(optarg));
@@ -95,7 +95,7 @@ main(int argc, char **argv)
}
zrr = ldns_zone_rrs(z);
- soa = ldns_zone_soa(z); /* SOA is stored seperately */
+ soa = ldns_zone_soa(z); /* SOA is stored separately */
fprintf(stderr, "%s\n", argv[i]);
diff --git a/examples/ldns-zsplit.1 b/examples/ldns-zsplit.1
index 8e64668f..02dce404 100644
--- a/examples/ldns-zsplit.1
+++ b/examples/ldns-zsplit.1
@@ -27,6 +27,10 @@ use ORIGIN as origin when reading the zonefile.
.B -z
Sort the zone before splitting.
+.TP
+.B -v
+Show version number and exit.
+
.SH AUTHOR
Written by the ldns team as an example for ldns usage.
diff --git a/examples/ldnsd.c b/examples/ldnsd.c
index e2a55200..77c5dd5c 100644
--- a/examples/ldnsd.c
+++ b/examples/ldnsd.c
@@ -236,8 +236,10 @@ main(int argc, char **argv)
ldns_rr_list_free(answer_ad);
}
- ldns_rdf_deep_free(origin);
- ldns_zone_deep_free(zone);
-
- return 0;
+ /* No cleanup because of the infinite loop
+ *
+ * ldns_rdf_deep_free(origin);
+ * ldns_zone_deep_free(zone);
+ * return 0;
+ */
}
diff --git a/examples/nsd-test/configure.ac b/examples/nsd-test/configure.ac
index 118d8637..a129a2bd 100644
--- a/examples/nsd-test/configure.ac
+++ b/examples/nsd-test/configure.ac
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
-AC_INIT(ldns, 1.6.16, libdns@nlnetlabs.nl,libdns)
+AC_INIT(ldns, 1.6.17, libdns@nlnetlabs.nl,libdns)
AC_CONFIG_SRCDIR([nsd-ldnsd.c])
OURCPPFLAGS='-D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D__EXTENSIONS__ -D__BSD_VISIBLE'
diff --git a/higher.c b/higher.c
index 990fb6af..8ce86a41 100644
--- a/higher.c
+++ b/higher.c
@@ -131,6 +131,7 @@ ldns_get_rr_list_name_by_addr(ldns_resolver *res, ldns_rdf *addr, ldns_rr_class
/* extract the data we need */
names = ldns_pkt_rr_list_by_type(pkt,
LDNS_RR_TYPE_PTR, LDNS_SECTION_ANSWER);
+ ldns_pkt_free(pkt);
}
return names;
}
@@ -303,39 +304,21 @@ ldns_getaddrinfo(ldns_resolver *res, ldns_rdf *node, ldns_rr_class c,
bool
ldns_nsec_type_check(ldns_rr *nsec, ldns_rr_type t)
{
- /* does the nsec cover the t given? */
- /* copied from host2str.c line 465: ldns_rdf2buffer_str_nsec */
- uint8_t window_block_nr;
- uint8_t bitmap_length;
- uint16_t type;
- uint16_t pos = 0;
- uint16_t bit_pos;
- ldns_rdf *nsec_type_list = ldns_rr_rdf(nsec, 1);
- uint8_t *data;
-
- if (nsec_type_list == NULL) {
- return false;
- }
- data = ldns_rdf_data(nsec_type_list);
-
- while(pos < ldns_rdf_size(nsec_type_list)) {
- window_block_nr = data[pos];
- bitmap_length = data[pos + 1];
- pos += 2;
-
- for (bit_pos = 0; bit_pos < (bitmap_length) * 8; bit_pos++) {
- if (ldns_get_bit(&data[pos], bit_pos)) {
- type = 256 * (uint16_t) window_block_nr + bit_pos;
-
- if ((ldns_rr_type)type == t) {
- /* we have a winner */
- return true;
- }
- }
- }
- pos += (uint16_t) bitmap_length;
+ switch (ldns_rr_get_type(nsec)) {
+ case LDNS_RR_TYPE_NSEC : if (ldns_rr_rd_count(nsec) < 2) {
+ return false;
+ }
+ return ldns_nsec_bitmap_covers_type(
+ ldns_rr_rdf(nsec, 1), t);
+
+ case LDNS_RR_TYPE_NSEC3 : if (ldns_rr_rd_count(nsec) < 6) {
+ return false;
+ }
+ return ldns_nsec_bitmap_covers_type(
+ ldns_rr_rdf(nsec, 5), t);
+
+ default : return false;
}
- return false;
}
void
@@ -358,3 +341,4 @@ ldns_print_rr_rdf(FILE *fp, ldns_rr *r, int rdfnum, ...)
}
va_end(va_rdf);
}
+
diff --git a/host2str.c b/host2str.c
index 521e2468..e2c936ba 100644
--- a/host2str.c
+++ b/host2str.c
@@ -130,6 +130,55 @@ const ldns_output_format ldns_output_format_bubblebabble_record = {
const ldns_output_format *ldns_output_format_bubblebabble
= &ldns_output_format_bubblebabble_record;
+static bool
+ldns_output_format_covers_type(const ldns_output_format* fmt, ldns_rr_type t)
+{
+ return fmt && (fmt->flags & LDNS_FMT_RFC3597) &&
+ ((ldns_output_format_storage*)fmt)->bitmap &&
+ ldns_nsec_bitmap_covers_type(
+ ((ldns_output_format_storage*)fmt)->bitmap, t);
+}
+
+ldns_status
+ldns_output_format_set_type(ldns_output_format* fmt, ldns_rr_type t)
+{
+ ldns_output_format_storage* fmt_st = (ldns_output_format_storage*)fmt;
+ ldns_status s;
+
+ assert(fmt != NULL);
+
+ if (!(fmt_st->flags & LDNS_FMT_RFC3597)) {
+ ldns_output_format_set(fmt, LDNS_FMT_RFC3597);
+ }
+ if (! fmt_st->bitmap) {
+ s = ldns_rdf_bitmap_known_rr_types_space(&fmt_st->bitmap);
+ if (s != LDNS_STATUS_OK) {
+ return s;
+ }
+ }
+ return ldns_nsec_bitmap_set_type(fmt_st->bitmap, t);
+}
+
+ldns_status
+ldns_output_format_clear_type(ldns_output_format* fmt, ldns_rr_type t)
+{
+ ldns_output_format_storage* fmt_st = (ldns_output_format_storage*)fmt;
+ ldns_status s;
+
+ assert(fmt != NULL);
+
+ if (!(fmt_st->flags & LDNS_FMT_RFC3597)) {
+ ldns_output_format_set(fmt, LDNS_FMT_RFC3597);
+ }
+ if (! fmt_st->bitmap) {
+ s = ldns_rdf_bitmap_known_rr_types(&fmt_st->bitmap);
+ if (s != LDNS_STATUS_OK) {
+ return s;
+ }
+ }
+ return ldns_nsec_bitmap_clear_type(fmt_st->bitmap, t);
+}
+
ldns_status
ldns_pkt_opcode2buffer_str(ldns_buffer *output, ldns_pkt_opcode opcode)
{
@@ -381,18 +430,15 @@ ldns_rdf2buffer_str_aaaa(ldns_buffer *output, const ldns_rdf *rdf)
return ldns_buffer_status(output);
}
-ldns_status
-ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf)
+static void
+ldns_characters2buffer_str(ldns_buffer* output,
+ size_t amount, const uint8_t* characters)
{
- const uint8_t *data = ldns_rdf_data(rdf);
- uint8_t length = data[0];
- size_t i;
-
- ldns_buffer_printf(output, "\"");
- for (i = 1; i <= length; ++i) {
- char ch = (char) data[i];
- if (isprint((int)ch) || ch=='\t') {
- if (ch=='\"'||ch=='\\')
+ uint8_t ch;
+ while (amount > 0) {
+ ch = *characters++;
+ if (isprint((int)ch) || ch == '\t') {
+ if (ch == '\"' || ch == '\\')
ldns_buffer_printf(output, "\\%c", ch);
else
ldns_buffer_printf(output, "%c", ch);
@@ -400,7 +446,22 @@ ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf)
ldns_buffer_printf(output, "\\%03u",
(unsigned)(uint8_t) ch);
}
+ amount--;
}
+}
+
+ldns_status
+ldns_rdf2buffer_str_str(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ if(ldns_rdf_size(rdf) < 1) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ if((int)ldns_rdf_size(rdf) < (int)ldns_rdf_data(rdf)[0] + 1) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ ldns_buffer_printf(output, "\"");
+ ldns_characters2buffer_str(output,
+ ldns_rdf_data(rdf)[0], ldns_rdf_data(rdf) + 1);
ldns_buffer_printf(output, "\"");
return ldns_buffer_status(output);
}
@@ -451,18 +512,27 @@ ldns_rdf2buffer_str_hex(ldns_buffer *output, const ldns_rdf *rdf)
}
ldns_status
-ldns_rdf2buffer_str_type(ldns_buffer *output, const ldns_rdf *rdf)
+ldns_rdf2buffer_str_type_fmt(ldns_buffer *output,
+ const ldns_output_format* fmt, const ldns_rdf *rdf)
{
uint16_t data = ldns_read_uint16(ldns_rdf_data(rdf));
- const ldns_rr_descriptor *descriptor;
- descriptor = ldns_rr_descript(data);
- if (descriptor && descriptor->_name) {
- ldns_buffer_printf(output, "%s", descriptor->_name);
+ if (! ldns_output_format_covers_type(fmt, data) &&
+ ldns_rr_descript(data) &&
+ ldns_rr_descript(data)->_name) {
+
+ ldns_buffer_printf(output, "%s",ldns_rr_descript(data)->_name);
} else {
ldns_buffer_printf(output, "TYPE%u", data);
}
- return ldns_buffer_status(output);
+ return ldns_buffer_status(output);
+}
+
+ldns_status
+ldns_rdf2buffer_str_type(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ return ldns_rdf2buffer_str_type_fmt(output,
+ ldns_output_format_default, rdf);
}
ldns_status
@@ -614,7 +684,7 @@ ldns_status
ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf)
{
/* we could do checking (ie degrees < 90 etc)? */
- uint8_t version = ldns_rdf_data(rdf)[0];
+ uint8_t version;
uint8_t size;
uint8_t horizontal_precision;
uint8_t vertical_precision;
@@ -629,7 +699,14 @@ ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf)
uint32_t equator = (uint32_t) ldns_power(2, 31);
+ if(ldns_rdf_size(rdf) < 1) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ version = ldns_rdf_data(rdf)[0];
if (version == 0) {
+ if(ldns_rdf_size(rdf) < 16) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
size = ldns_rdf_data(rdf)[1];
horizontal_precision = ldns_rdf_data(rdf)[2];
vertical_precision = ldns_rdf_data(rdf)[3];
@@ -669,12 +746,12 @@ ldns_rdf2buffer_str_loc(ldns_buffer *output, const ldns_rdf *rdf)
h, m, s, easterness);
- s = ((double) altitude) / 100;
- s -= 100000;
+ s = ((double) altitude) / 100;
+ s -= 100000;
if(altitude%100 != 0)
ldns_buffer_printf(output, "%.2f", s);
- else
+ else
ldns_buffer_printf(output, "%.0f", s);
ldns_buffer_printf(output, "m ");
@@ -726,6 +803,9 @@ ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf)
struct servent *service;
uint16_t current_service;
+ if(ldns_rdf_size(rdf) < 1) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
protocol_nr = ldns_rdf_data(rdf)[0];
protocol = getprotobynumber((int) protocol_nr);
if (protocol && (protocol->p_name != NULL)) {
@@ -758,7 +838,8 @@ ldns_rdf2buffer_str_wks(ldns_buffer *output, const ldns_rdf *rdf)
}
ldns_status
-ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf)
+ldns_rdf2buffer_str_nsec_fmt(ldns_buffer *output,
+ const ldns_output_format* fmt, const ldns_rdf *rdf)
{
/* Note: this code is duplicated in higher.c in
* ldns_nsec_type_check() function
@@ -769,34 +850,43 @@ ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf)
uint16_t pos = 0;
uint16_t bit_pos;
uint8_t *data = ldns_rdf_data(rdf);
- const ldns_rr_descriptor *descriptor;
- while(pos < ldns_rdf_size(rdf)) {
+ while((size_t)(pos + 2) < ldns_rdf_size(rdf)) {
window_block_nr = data[pos];
bitmap_length = data[pos + 1];
pos += 2;
-
+ if (ldns_rdf_size(rdf) < pos + bitmap_length) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
for (bit_pos = 0; bit_pos < (bitmap_length) * 8; bit_pos++) {
- if (ldns_get_bit(&data[pos], bit_pos)) {
- type = 256 * (uint16_t) window_block_nr + bit_pos;
- descriptor = ldns_rr_descript(type);
+ if (! ldns_get_bit(&data[pos], bit_pos)) {
+ continue;
+ }
+ type = 256 * (uint16_t) window_block_nr + bit_pos;
- if (descriptor && descriptor->_name) {
- ldns_buffer_printf(output, "%s ",
- descriptor->_name);
- } else {
- ldns_buffer_printf(output, "TYPE%u ", type);
- }
+ if (! ldns_output_format_covers_type(fmt, type) &&
+ ldns_rr_descript(type) &&
+ ldns_rr_descript(type)->_name){
+
+ ldns_buffer_printf(output, "%s ",
+ ldns_rr_descript(type)->_name);
+ } else {
+ ldns_buffer_printf(output, "TYPE%u ", type);
}
}
-
pos += (uint16_t) bitmap_length;
}
-
return ldns_buffer_status(output);
}
ldns_status
+ldns_rdf2buffer_str_nsec(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ return ldns_rdf2buffer_str_nsec_fmt(output,
+ ldns_output_format_default, rdf);
+}
+
+ldns_status
ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf)
{
uint8_t salt_length;
@@ -804,9 +894,8 @@ ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf)
uint8_t *data = ldns_rdf_data(rdf);
- if(ldns_rdf_size(rdf) == 0) {
- output->_status = LDNS_STATUS_ERR;
- return ldns_buffer_status(output);
+ if(ldns_rdf_size(rdf) < 1) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
}
salt_length = data[0];
/* from now there are variable length entries so remember pos */
@@ -826,8 +915,10 @@ ldns_status
ldns_rdf2buffer_str_period(ldns_buffer *output, const ldns_rdf *rdf)
{
/* period is the number of seconds */
- uint32_t p = ldns_read_uint32(ldns_rdf_data(rdf));
- ldns_buffer_printf(output, "%u", p);
+ if (ldns_rdf_size(rdf) != 4) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ ldns_buffer_printf(output, "%u", ldns_read_uint32(ldns_rdf_data(rdf)));
return ldns_buffer_status(output);
}
@@ -837,17 +928,20 @@ ldns_rdf2buffer_str_tsigtime(ldns_buffer *output,const ldns_rdf *rdf)
/* tsigtime is 48 bits network order unsigned integer */
uint64_t tsigtime = 0;
uint8_t *data = ldns_rdf_data(rdf);
+ uint64_t d0, d1, d2, d3, d4, d5;
- if (ldns_rdf_size(rdf) != 6) {
- return LDNS_STATUS_ERR;
+ if (ldns_rdf_size(rdf) < 6) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
}
+ d0 = data[0]; /* cast to uint64 for shift operations */
+ d1 = data[1];
+ d2 = data[2];
+ d3 = data[3];
+ d4 = data[4];
+ d5 = data[5];
+ tsigtime = (d0<<40) | (d1<<32) | (d2<<24) | (d3<<16) | (d4<<8) | d5;
- tsigtime = ldns_read_uint16(data);
- tsigtime *= 65536;
- tsigtime += ldns_read_uint16(data+2);
- tsigtime *= 65536;
-
- ldns_buffer_printf(output, "%llu ", tsigtime);
+ ldns_buffer_printf(output, "%llu ", (long long)tsigtime);
return ldns_buffer_status(output);
}
@@ -865,7 +959,7 @@ ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)
while (pos < (unsigned int) ldns_rdf_size(rdf)) {
if(pos + 3 >= (unsigned)ldns_rdf_size(rdf))
- return LDNS_STATUS_SYNTAX_RDATA_ERR;
+ return LDNS_STATUS_WIRE_RDATA_ERR;
address_family = ldns_read_uint16(&data[pos]);
prefix = data[pos + 2];
negation = data[pos + 3] & LDNS_APL_NEGATION;
@@ -883,7 +977,7 @@ ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)
}
if (i < (unsigned short) adf_length) {
if(pos+i+4 >= ldns_rdf_size(rdf))
- return LDNS_STATUS_SYNTAX_RDATA_ERR;
+ return LDNS_STATUS_WIRE_RDATA_ERR;
ldns_buffer_printf(output, "%d",
data[pos + i + 4]);
} else {
@@ -904,7 +998,7 @@ ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)
}
if (i < (unsigned short) adf_length) {
if(pos+i+4 >= ldns_rdf_size(rdf))
- return LDNS_STATUS_SYNTAX_RDATA_ERR;
+ return LDNS_STATUS_WIRE_RDATA_ERR;
ldns_buffer_printf(output, "%02x",
data[pos + i + 4]);
} else {
@@ -915,11 +1009,12 @@ ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)
} else {
/* unknown address family */
- ldns_buffer_printf(output, "Unknown address family: %u data: ",
+ ldns_buffer_printf(output,
+ "Unknown address family: %u data: ",
address_family);
for (i = 1; i < (unsigned short) (4 + adf_length); i++) {
if(pos+i >= ldns_rdf_size(rdf))
- return LDNS_STATUS_SYNTAX_RDATA_ERR;
+ return LDNS_STATUS_WIRE_RDATA_ERR;
ldns_buffer_printf(output, "%02x", data[i]);
}
}
@@ -931,21 +1026,27 @@ ldns_rdf2buffer_str_apl(ldns_buffer *output, const ldns_rdf *rdf)
ldns_status
ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *rdf)
{
+ size_t size;
+ char *b64;
+ if (ldns_rdf_size(rdf) < 2) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
/* Subtract the size (2) of the number that specifies the length */
- size_t size = ldns_b64_ntop_calculate_size(ldns_rdf_size(rdf) - 2);
- char *b64 = LDNS_XMALLOC(char, size);
- if(!b64)
- return LDNS_STATUS_MEM_ERR;
-
+ size = ldns_b64_ntop_calculate_size(ldns_rdf_size(rdf) - 2);
ldns_buffer_printf(output, "%u ", ldns_rdf_size(rdf) - 2);
-
- if (ldns_rdf_size(rdf) > 2 &&
- ldns_b64_ntop(ldns_rdf_data(rdf) + 2,
- ldns_rdf_size(rdf) - 2,
- b64, size)) {
- ldns_buffer_printf(output, "%s", b64);
+ if (ldns_rdf_size(rdf) > 2) {
+ b64 = LDNS_XMALLOC(char, size);
+ if(!b64)
+ return LDNS_STATUS_MEM_ERR;
+
+ if (ldns_rdf_size(rdf) > 2 &&
+ ldns_b64_ntop(ldns_rdf_data(rdf) + 2,
+ ldns_rdf_size(rdf) - 2,
+ b64, size)) {
+ ldns_buffer_printf(output, "%s", b64);
+ }
+ LDNS_FREE(b64);
}
- LDNS_FREE(b64);
return ldns_buffer_status(output);
}
@@ -970,6 +1071,9 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
size_t offset = 0;
ldns_status status;
+ if (ldns_rdf_size(rdf) < 3) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
precedence = data[0];
gateway_type = data[1];
algorithm = data[2];
@@ -983,8 +1087,12 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
gateway_data = LDNS_XMALLOC(uint8_t, LDNS_IP4ADDRLEN);
if(!gateway_data)
return LDNS_STATUS_MEM_ERR;
+ if (ldns_rdf_size(rdf) < offset + LDNS_IP4ADDRLEN) {
+ return LDNS_STATUS_ERR;
+ }
memcpy(gateway_data, &data[offset], LDNS_IP4ADDRLEN);
- gateway = ldns_rdf_new(LDNS_RDF_TYPE_A, LDNS_IP4ADDRLEN , gateway_data);
+ gateway = ldns_rdf_new(LDNS_RDF_TYPE_A,
+ LDNS_IP4ADDRLEN , gateway_data);
offset += LDNS_IP4ADDRLEN;
if(!gateway) {
LDNS_FREE(gateway_data);
@@ -995,17 +1103,22 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
gateway_data = LDNS_XMALLOC(uint8_t, LDNS_IP6ADDRLEN);
if(!gateway_data)
return LDNS_STATUS_MEM_ERR;
+ if (ldns_rdf_size(rdf) < offset + LDNS_IP6ADDRLEN) {
+ return LDNS_STATUS_ERR;
+ }
memcpy(gateway_data, &data[offset], LDNS_IP6ADDRLEN);
offset += LDNS_IP6ADDRLEN;
gateway =
- ldns_rdf_new(LDNS_RDF_TYPE_AAAA, LDNS_IP6ADDRLEN, gateway_data);
+ ldns_rdf_new(LDNS_RDF_TYPE_AAAA,
+ LDNS_IP6ADDRLEN, gateway_data);
if(!gateway) {
LDNS_FREE(gateway_data);
return LDNS_STATUS_MEM_ERR;
}
break;
case 3:
- status = ldns_wire2dname(&gateway, data, ldns_rdf_size(rdf), &offset);
+ status = ldns_wire2dname(&gateway, data,
+ ldns_rdf_size(rdf), &offset);
if(status != LDNS_STATUS_OK)
return status;
break;
@@ -1014,6 +1127,9 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
break;
}
+ if (ldns_rdf_size(rdf) <= offset) {
+ return LDNS_STATUS_ERR;
+ }
public_key_size = ldns_rdf_size(rdf) - offset;
public_key_data = LDNS_XMALLOC(uint8_t, public_key_size);
if(!public_key_data) {
@@ -1021,7 +1137,8 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
return LDNS_STATUS_MEM_ERR;
}
memcpy(public_key_data, &data[offset], public_key_size);
- public_key = ldns_rdf_new(LDNS_RDF_TYPE_B64, public_key_size, public_key_data);
+ public_key = ldns_rdf_new(LDNS_RDF_TYPE_B64,
+ public_key_size, public_key_data);
if(!public_key) {
LDNS_FREE(public_key_data);
ldns_rdf_free(gateway);
@@ -1029,7 +1146,7 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
}
ldns_buffer_printf(output, "%u %u %u ", precedence, gateway_type, algorithm);
- if (gateway)
+ if (gateway)
(void) ldns_rdf2buffer_str(output, gateway);
else
ldns_buffer_printf(output, ".");
@@ -1043,15 +1160,129 @@ ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf)
}
ldns_status
-ldns_rdf2buffer_str_tsig(ldns_buffer *output, const ldns_rdf *rdf)
+ldns_rdf2buffer_str_ilnp64(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ if (ldns_rdf_size(rdf) != 8) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ ldns_buffer_printf(output,"%.4x:%.4x:%.4x:%.4x",
+ ldns_read_uint16(ldns_rdf_data(rdf)),
+ ldns_read_uint16(ldns_rdf_data(rdf)+2),
+ ldns_read_uint16(ldns_rdf_data(rdf)+4),
+ ldns_read_uint16(ldns_rdf_data(rdf)+6));
+ return ldns_buffer_status(output);
+}
+
+ldns_status
+ldns_rdf2buffer_str_eui48(ldns_buffer *output, const ldns_rdf *rdf)
{
- /* TSIG RRs have no presentation format, make them #size <data> */
- return ldns_rdf2buffer_str_unknown(output, rdf);
+ if (ldns_rdf_size(rdf) != 6) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ ldns_buffer_printf(output,"%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ ldns_rdf_data(rdf)[0], ldns_rdf_data(rdf)[1],
+ ldns_rdf_data(rdf)[2], ldns_rdf_data(rdf)[3],
+ ldns_rdf_data(rdf)[4], ldns_rdf_data(rdf)[5]);
+ return ldns_buffer_status(output);
}
+ldns_status
+ldns_rdf2buffer_str_eui64(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ if (ldns_rdf_size(rdf) != 8) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ ldns_buffer_printf(output,"%.2x-%.2x-%.2x-%.2x-%.2x-%.2x-%.2x-%.2x",
+ ldns_rdf_data(rdf)[0], ldns_rdf_data(rdf)[1],
+ ldns_rdf_data(rdf)[2], ldns_rdf_data(rdf)[3],
+ ldns_rdf_data(rdf)[4], ldns_rdf_data(rdf)[5],
+ ldns_rdf_data(rdf)[6], ldns_rdf_data(rdf)[7]);
+ return ldns_buffer_status(output);
+}
ldns_status
-ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
+ldns_rdf2buffer_str_tag(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ size_t nchars;
+ const uint8_t* chars;
+ char ch;
+ if (ldns_rdf_size(rdf) < 2) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ nchars = ldns_rdf_data(rdf)[0];
+ if (nchars >= ldns_rdf_size(rdf) || /* should be rdf_size - 1 */
+ nchars < 1) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ chars = ldns_rdf_data(rdf) + 1;
+ while (nchars > 0) {
+ ch = (char)*chars++;
+ if (! isalnum(ch)) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ ldns_buffer_printf(output, "%c", ch);
+ nchars--;
+ }
+ return ldns_buffer_status(output);
+}
+
+ldns_status
+ldns_rdf2buffer_str_long_str(ldns_buffer *output, const ldns_rdf *rdf)
+{
+
+ ldns_buffer_printf(output, "\"");
+ ldns_characters2buffer_str(output,
+ ldns_rdf_size(rdf), ldns_rdf_data(rdf));
+ ldns_buffer_printf(output, "\"");
+ return ldns_buffer_status(output);
+}
+
+ldns_status
+ldns_rdf2buffer_str_hip(ldns_buffer *output, const ldns_rdf *rdf)
+{
+ uint8_t *data = ldns_rdf_data(rdf);
+ size_t rdf_size = ldns_rdf_size(rdf);
+ uint8_t hit_size;
+ uint16_t pk_size;
+ int written;
+
+ if (rdf_size < 6) {
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+ if ((hit_size = data[0]) == 0 ||
+ (pk_size = ldns_read_uint16(data + 2)) == 0 ||
+ rdf_size < (size_t) hit_size + pk_size + 4) {
+
+ return LDNS_STATUS_WIRE_RDATA_ERR;
+ }
+
+ ldns_buffer_printf(output, "%d ", (int) data[1]);
+
+ for (data += 4; hit_size > 0; hit_size--, data++) {
+
+ ldns_buffer_printf(output, "%02x", (int) *data);
+ }
+ ldns_buffer_write_u8(output, (uint8_t) ' ');
+
+ if (ldns_buffer_reserve(output,
+ ldns_b64_ntop_calculate_size(pk_size))) {
+
+ written = ldns_b64_ntop(data, pk_size,
+ (char *) ldns_buffer_current(output),
+ ldns_buffer_remaining(output));
+
+ if (written > 0 &&
+ written < (int) ldns_buffer_remaining(output)) {
+
+ output->_position += written;
+ }
+ }
+ return ldns_buffer_status(output);
+}
+
+ldns_status
+ldns_rdf2buffer_str_fmt(ldns_buffer *buffer,
+ const ldns_output_format* fmt, const ldns_rdf *rdf)
{
ldns_status res = LDNS_STATUS_OK;
@@ -1100,13 +1331,13 @@ ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
res = ldns_rdf2buffer_str_hex(buffer, rdf);
break;
case LDNS_RDF_TYPE_NSEC:
- res = ldns_rdf2buffer_str_nsec(buffer, rdf);
+ res = ldns_rdf2buffer_str_nsec_fmt(buffer, fmt, rdf);
break;
case LDNS_RDF_TYPE_NSEC3_SALT:
res = ldns_rdf2buffer_str_nsec3_salt(buffer, rdf);
break;
case LDNS_RDF_TYPE_TYPE:
- res = ldns_rdf2buffer_str_type(buffer, rdf);
+ res = ldns_rdf2buffer_str_type_fmt(buffer, fmt, rdf);
break;
case LDNS_RDF_TYPE_CLASS:
res = ldns_rdf2buffer_str_class(buffer, rdf);
@@ -1123,6 +1354,9 @@ ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
case LDNS_RDF_TYPE_TIME:
res = ldns_rdf2buffer_str_time(buffer, rdf);
break;
+ case LDNS_RDF_TYPE_HIP:
+ res = ldns_rdf2buffer_str_hip(buffer, rdf);
+ break;
case LDNS_RDF_TYPE_LOC:
res = ldns_rdf2buffer_str_loc(buffer, rdf);
break;
@@ -1139,15 +1373,27 @@ ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
case LDNS_RDF_TYPE_IPSECKEY:
res = ldns_rdf2buffer_str_ipseckey(buffer, rdf);
break;
- case LDNS_RDF_TYPE_TSIG:
- res = ldns_rdf2buffer_str_tsig(buffer, rdf);
- break;
case LDNS_RDF_TYPE_INT16_DATA:
res = ldns_rdf2buffer_str_int16_data(buffer, rdf);
break;
case LDNS_RDF_TYPE_NSEC3_NEXT_OWNER:
res = ldns_rdf2buffer_str_b32_ext(buffer, rdf);
break;
+ case LDNS_RDF_TYPE_ILNP64:
+ res = ldns_rdf2buffer_str_ilnp64(buffer, rdf);
+ break;
+ case LDNS_RDF_TYPE_EUI48:
+ res = ldns_rdf2buffer_str_eui48(buffer, rdf);
+ break;
+ case LDNS_RDF_TYPE_EUI64:
+ res = ldns_rdf2buffer_str_eui64(buffer, rdf);
+ break;
+ case LDNS_RDF_TYPE_TAG:
+ res = ldns_rdf2buffer_str_tag(buffer, rdf);
+ break;
+ case LDNS_RDF_TYPE_LONG_STR:
+ res = ldns_rdf2buffer_str_long_str(buffer, rdf);
+ break;
}
} else {
/** This will write mangled RRs */
@@ -1157,7 +1403,13 @@ ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
return res;
}
-ldns_rdf *
+ldns_status
+ldns_rdf2buffer_str(ldns_buffer *buffer, const ldns_rdf *rdf)
+{
+ return ldns_rdf2buffer_str_fmt(buffer,ldns_output_format_default,rdf);
+}
+
+static ldns_rdf *
ldns_b32_ext2dname(const ldns_rdf *rdf)
{
size_t size;
@@ -1184,18 +1436,45 @@ ldns_b32_ext2dname(const ldns_rdf *rdf)
return NULL;
}
+static ldns_status
+ldns_rr2buffer_str_rfc3597(ldns_buffer *output, const ldns_rr *rr)
+{
+ size_t total_rdfsize = 0;
+ size_t i, j;
+
+ ldns_buffer_printf(output, "TYPE%u\t", ldns_rr_get_type(rr));
+ for (i = 0; i < ldns_rr_rd_count(rr); i++) {
+ total_rdfsize += ldns_rdf_size(ldns_rr_rdf(rr, i));
+ }
+ if (total_rdfsize == 0) {
+ ldns_buffer_printf(output, "\\# 0\n");
+ return ldns_buffer_status(output);
+ }
+ ldns_buffer_printf(output, "\\# %d ", total_rdfsize);
+ for (i = 0; i < ldns_rr_rd_count(rr); i++) {
+ for (j = 0; j < ldns_rdf_size(ldns_rr_rdf(rr, i)); j++) {
+ ldns_buffer_printf(output, "%.2x",
+ ldns_rdf_data(ldns_rr_rdf(rr, i))[j]);
+ }
+ }
+ ldns_buffer_printf(output, "\n");
+ return ldns_buffer_status(output);
+}
+
ldns_status
ldns_rr2buffer_str_fmt(ldns_buffer *output,
const ldns_output_format *fmt, const ldns_rr *rr)
{
uint16_t i, flags;
ldns_status status = LDNS_STATUS_OK;
+ ldns_output_format_storage* fmt_st = (ldns_output_format_storage*)fmt;
- if (fmt == NULL) {
- fmt = ldns_output_format_default;
+ if (fmt_st == NULL) {
+ fmt_st = (ldns_output_format_storage*)
+ ldns_output_format_default;
}
if (!rr) {
- if (LDNS_COMMENT_NULLS & fmt->flags) {
+ if (LDNS_COMMENT_NULLS & fmt_st->flags) {
ldns_buffer_printf(output, "; (null)\n");
}
return ldns_buffer_status(output);
@@ -1219,6 +1498,9 @@ ldns_rr2buffer_str_fmt(ldns_buffer *output,
}
ldns_buffer_printf(output, "\t");
+ if (ldns_output_format_covers_type(fmt, ldns_rr_get_type(rr))) {
+ return ldns_rr2buffer_str_rfc3597(output, rr);
+ }
status = ldns_rr_type2buffer_str(output, ldns_rr_get_type(rr));
if (status != LDNS_STATUS_OK) {
return status;
@@ -1232,7 +1514,7 @@ ldns_rr2buffer_str_fmt(ldns_buffer *output,
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
/* ldns_rdf2buffer_str handles NULL input fine! */
- if ((fmt->flags & LDNS_FMT_ZEROIZE_RRSIGS) &&
+ if ((fmt_st->flags & LDNS_FMT_ZEROIZE_RRSIGS) &&
(ldns_rr_get_type(rr) == LDNS_RR_TYPE_RRSIG) &&
((/* inception */ i == 4 &&
ldns_rdf_get_type(ldns_rr_rdf(rr, 4)) ==
@@ -1246,7 +1528,7 @@ ldns_rr2buffer_str_fmt(ldns_buffer *output,
ldns_buffer_printf(output, "(null)");
status = ldns_buffer_status(output);
- } else if ((fmt->flags & LDNS_FMT_PAD_SOA_SERIAL) &&
+ } else if ((fmt_st->flags & LDNS_FMT_PAD_SOA_SERIAL) &&
(ldns_rr_get_type(rr) == LDNS_RR_TYPE_SOA) &&
/* serial */ i == 2 &&
ldns_rdf_get_type(ldns_rr_rdf(rr, 2)) ==
@@ -1256,8 +1538,8 @@ ldns_rr2buffer_str_fmt(ldns_buffer *output,
ldns_rdf_data(ldns_rr_rdf(rr, 2))));
status = ldns_buffer_status(output);
} else {
- status = ldns_rdf2buffer_str(output,
- ldns_rr_rdf(rr, i));
+ status = ldns_rdf2buffer_str_fmt(output,
+ fmt, ldns_rr_rdf(rr, i));
}
if(status != LDNS_STATUS_OK)
return status;
@@ -1270,137 +1552,126 @@ ldns_rr2buffer_str_fmt(ldns_buffer *output,
* getting here */
if (ldns_rr_rd_count(rr) > 0) {
switch (ldns_rr_get_type(rr)) {
- case LDNS_RR_TYPE_DNSKEY:
- /* if ldns_rr_rd_count(rr) > 0
- then ldns_rr_rdf(rr, 0) exists! */
- if (! (fmt->flags & LDNS_COMMENT_KEY)) {
- break;
- }
- flags = ldns_rdf2native_int16(
- ldns_rr_rdf(rr, 0));
- ldns_buffer_printf(output, " ;{");
- if (fmt->flags & LDNS_COMMENT_KEY_ID) {
- ldns_buffer_printf(output, "id = %u",
- (unsigned int)
- ldns_calc_keytag(rr));
- }
- if ((fmt->flags & LDNS_COMMENT_KEY_TYPE)
- && (flags & LDNS_KEY_ZONE_KEY)){
- if (flags & LDNS_KEY_SEP_KEY) {
- ldns_buffer_printf(
- output, " (ksk)");
- }
- else {
- ldns_buffer_printf(
- output, " (zsk)");
- }
- if (fmt->flags & LDNS_COMMENT_KEY_SIZE){
- ldns_buffer_printf(
- output, ", ");
- }
- } else if (fmt->flags
- & (LDNS_COMMENT_KEY_ID
- |LDNS_COMMENT_KEY_SIZE)) {
- ldns_buffer_printf( output, ", ");
+ case LDNS_RR_TYPE_DNSKEY:
+ /* if ldns_rr_rd_count(rr) > 0
+ then ldns_rr_rdf(rr, 0) exists! */
+ if (! (fmt_st->flags & LDNS_COMMENT_KEY)) {
+ break;
+ }
+ flags = ldns_rdf2native_int16(ldns_rr_rdf(rr, 0));
+ ldns_buffer_printf(output, " ;{");
+ if (fmt_st->flags & LDNS_COMMENT_KEY_ID) {
+ ldns_buffer_printf(output, "id = %u",
+ (unsigned int) ldns_calc_keytag(rr));
+ }
+ if ((fmt_st->flags & LDNS_COMMENT_KEY_TYPE) &&
+ (flags & LDNS_KEY_ZONE_KEY)){
+
+ if (flags & LDNS_KEY_SEP_KEY) {
+ ldns_buffer_printf(output, " (ksk)");
+ } else {
+ ldns_buffer_printf(output, " (zsk)");
}
- if (fmt->flags & LDNS_COMMENT_KEY_SIZE) {
- ldns_buffer_printf(output, "size = %db",
- ldns_rr_dnskey_key_size(rr));
+ if (fmt_st->flags & LDNS_COMMENT_KEY_SIZE){
+ ldns_buffer_printf(output, ", ");
}
- ldns_buffer_printf(output, "}");
- break;
- case LDNS_RR_TYPE_RRSIG:
- if ((fmt->flags & LDNS_COMMENT_KEY)
- && (fmt->flags
- & LDNS_COMMENT_RRSIGS)
- && ldns_rr_rdf(rr, 6) != NULL) {
- ldns_buffer_printf(output
- , " ;{id = %d}"
- , ldns_rdf2native_int16(
+ } else if (fmt_st->flags
+ & (LDNS_COMMENT_KEY_ID
+ |LDNS_COMMENT_KEY_SIZE)) {
+ ldns_buffer_printf( output, ", ");
+ }
+ if (fmt_st->flags & LDNS_COMMENT_KEY_SIZE) {
+ ldns_buffer_printf(output, "size = %db",
+ ldns_rr_dnskey_key_size(rr));
+ }
+ ldns_buffer_printf(output, "}");
+ break;
+ case LDNS_RR_TYPE_RRSIG:
+ if ((fmt_st->flags & LDNS_COMMENT_KEY)
+ && (fmt_st->flags& LDNS_COMMENT_RRSIGS)
+ && ldns_rr_rdf(rr, 6) != NULL) {
+ ldns_buffer_printf(output, " ;{id = %d}",
+ ldns_rdf2native_int16(
ldns_rr_rdf(rr, 6)));
+ }
+ break;
+ case LDNS_RR_TYPE_DS:
+ if ((fmt_st->flags & LDNS_COMMENT_BUBBLEBABBLE) &&
+ ldns_rr_rdf(rr, 3) != NULL) {
+
+ uint8_t *data = ldns_rdf_data(
+ ldns_rr_rdf(rr, 3));
+ size_t len = ldns_rdf_size(ldns_rr_rdf(rr, 3));
+ char *babble = ldns_bubblebabble(data, len);
+ if(babble) {
+ ldns_buffer_printf(output,
+ " ;{%s}", babble);
}
+ LDNS_FREE(babble);
+ }
+ break;
+ case LDNS_RR_TYPE_NSEC3:
+ if (! (fmt_st->flags & LDNS_COMMENT_FLAGS) &&
+ ! (fmt_st->flags & LDNS_COMMENT_NSEC3_CHAIN)) {
break;
- case LDNS_RR_TYPE_DS:
- if ((fmt->flags & LDNS_COMMENT_BUBBLEBABBLE)
- && ldns_rr_rdf(rr, 3) != NULL) {
- uint8_t *data = ldns_rdf_data(
- ldns_rr_rdf(rr, 3));
- size_t len = ldns_rdf_size(
- ldns_rr_rdf(rr, 3));
- char *babble = ldns_bubblebabble(
- data, len);
- if(babble) {
- ldns_buffer_printf(output
- , " ;{%s}", babble);
- }
- LDNS_FREE(babble);
+ }
+ ldns_buffer_printf(output, " ;{");
+ if ((fmt_st->flags & LDNS_COMMENT_FLAGS)) {
+ if (ldns_nsec3_optout(rr)) {
+ ldns_buffer_printf(output,
+ " flags: optout");
+ } else {
+ ldns_buffer_printf(output," flags: -");
}
- break;
- case LDNS_RR_TYPE_NSEC3:
- if (! (fmt->flags & LDNS_COMMENT_FLAGS) &&
- ! (fmt->flags & LDNS_COMMENT_NSEC3_CHAIN)) {
- break;
+ if (fmt_st->flags & LDNS_COMMENT_NSEC3_CHAIN &&
+ fmt_st->hashmap != NULL) {
+ ldns_buffer_printf(output, ", ");
}
- ldns_buffer_printf(output, " ;{");
- if ((fmt->flags & LDNS_COMMENT_FLAGS)) {
- if (ldns_nsec3_optout(rr)) {
- ldns_buffer_printf(output,
- " flags: optout");
- } else {
+ }
+ if (fmt_st->flags & LDNS_COMMENT_NSEC3_CHAIN &&
+ fmt_st->hashmap != NULL) {
+ ldns_rbnode_t *node;
+ ldns_rdf *key = ldns_dname_label(
+ ldns_rr_owner(rr), 0);
+ if (key) {
+ node = ldns_rbtree_search(
+ fmt_st->hashmap,
+ (void *) key);
+ if (node->data) {
ldns_buffer_printf(output,
- " flags: -");
- }
- if (fmt->flags & LDNS_COMMENT_NSEC3_CHAIN
- && fmt->data != NULL) {
- ldns_buffer_printf(output, ", ");
+ "from: ");
+ (void) ldns_rdf2buffer_str(
+ output,
+ ldns_dnssec_name_name(
+ (ldns_dnssec_name*)
+ node->data
+ ));
}
+ ldns_rdf_free(key);
}
- if (fmt->flags & LDNS_COMMENT_NSEC3_CHAIN
- && fmt->data != NULL) {
- ldns_rbnode_t *node;
- ldns_rdf *key = ldns_dname_label(
- ldns_rr_owner(rr), 0);
- if (key) {
- node = ldns_rbtree_search(
- (ldns_rbtree_t *)
- fmt->data,
- (void *) key);
- if (node->data) {
- ldns_buffer_printf(
- output,
- "from: ");
- (void)
- ldns_rdf2buffer_str(
- output,
- (ldns_rdf *)
- node->data);
- }
- ldns_rdf_free(key);
- }
- key = ldns_b32_ext2dname(
+ key = ldns_b32_ext2dname(
ldns_nsec3_next_owner(rr));
- if (key) {
- node = ldns_rbtree_search(
- (ldns_rbtree_t *)
- fmt->data,
- (void *) key);
- if (node->data) {
- ldns_buffer_printf(
- output,
- " to: ");
- (void)
- ldns_rdf2buffer_str(
- output,
- (ldns_rdf *)
- node->data);
- }
- ldns_rdf_free(key);
+ if (key) {
+ node = ldns_rbtree_search(
+ fmt_st->hashmap,
+ (void *) key);
+ if (node->data) {
+ ldns_buffer_printf(output,
+ " to: ");
+ (void) ldns_rdf2buffer_str(
+ output,
+ ldns_dnssec_name_name(
+ (ldns_dnssec_name*)
+ node->data
+ ));
}
+ ldns_rdf_free(key);
}
- ldns_buffer_printf(output, "}");
- break;
- default:
- break;
+ }
+ ldns_buffer_printf(output, "}");
+ break;
+ default:
+ break;
}
}
@@ -1724,10 +1995,12 @@ ldns_key2buffer_str(ldns_buffer *output, const ldns_key *k)
break;
#endif
default:
+#ifdef STDERR_MSGS
fprintf(stderr, "Warning: unknown signature ");
fprintf(stderr,
"algorithm type %u\n",
ldns_key_algorithm(k));
+#endif
ldns_buffer_printf(output,
"Algorithm: %u (Unknown)\n",
ldns_key_algorithm(k));
diff --git a/host2wire.c b/host2wire.c
index de1e01e9..8fb5c3a2 100644
--- a/host2wire.c
+++ b/host2wire.c
@@ -81,6 +81,7 @@ ldns_rr_list2buffer_wire(ldns_buffer *buffer,const ldns_rr_list *rr_list)
return ldns_buffer_status(buffer);
}
+
ldns_status
ldns_rr2buffer_wire_canonical(ldns_buffer *buffer,
const ldns_rr *rr,
@@ -136,17 +137,15 @@ ldns_rr2buffer_wire_canonical(ldns_buffer *buffer,
rdl_pos = ldns_buffer_position(buffer);
ldns_buffer_write_u16(buffer, 0);
}
-
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
if (pre_rfc3597) {
(void) ldns_rdf2buffer_wire_canonical(
- buffer, ldns_rr_rdf(rr, i));
+ buffer, ldns_rr_rdf(rr, i));
} else {
(void) ldns_rdf2buffer_wire(
- buffer, ldns_rr_rdf(rr, i));
+ buffer, ldns_rr_rdf(rr, i));
}
}
-
if (rdl_pos != 0) {
ldns_buffer_write_u16_at(buffer, rdl_pos,
ldns_buffer_position(buffer)
@@ -177,13 +176,11 @@ ldns_rr2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr, int section)
/* remember pos for later */
rdl_pos = ldns_buffer_position(buffer);
ldns_buffer_write_u16(buffer, 0);
- }
-
+ }
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
(void) ldns_rdf2buffer_wire(
buffer, ldns_rr_rdf(rr, i));
}
-
if (rdl_pos != 0) {
ldns_buffer_write_u16_at(buffer, rdl_pos,
ldns_buffer_position(buffer)
@@ -206,7 +203,8 @@ ldns_rrsig2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr)
/* Convert all the rdfs, except the actual signature data
* rdf number 8 - the last, hence: -1 */
for (i = 0; i < ldns_rr_rd_count(rr) - 1; i++) {
- (void) ldns_rdf2buffer_wire_canonical(buffer, ldns_rr_rdf(rr, i));
+ (void) ldns_rdf2buffer_wire_canonical(buffer,
+ ldns_rr_rdf(rr, i));
}
return ldns_buffer_status(buffer);
@@ -218,9 +216,8 @@ ldns_rr_rdata2buffer_wire(ldns_buffer *buffer, const ldns_rr *rr)
uint16_t i;
/* convert all the rdf's */
for (i = 0; i < ldns_rr_rd_count(rr); i++) {
- (void) ldns_rdf2buffer_wire(buffer, ldns_rr_rdf(rr, i));
+ (void) ldns_rdf2buffer_wire(buffer, ldns_rr_rdf(rr,i));
}
-
return ldns_buffer_status(buffer);
}
@@ -245,7 +242,8 @@ ldns_hdr2buffer_wire(ldns_buffer *buffer, const ldns_pkt *packet)
flags = ldns_pkt_ra(packet) << 7
/*| ldns_pkt_z(packet) << 6*/
| ldns_pkt_ad(packet) << 5
- | ldns_pkt_cd(packet) << 4 | ldns_pkt_get_rcode(packet);
+ | ldns_pkt_cd(packet) << 4
+ | ldns_pkt_get_rcode(packet);
ldns_buffer_write_u8(buffer, flags);
ldns_buffer_write_u16(buffer, ldns_pkt_qdcount(packet));
diff --git a/install-sh b/install-sh
index a9244eb0..377bb868 100755
--- a/install-sh
+++ b/install-sh
@@ -1,7 +1,7 @@
#!/bin/sh
# install - install a program, script, or datafile
-scriptversion=2011-01-19.21; # UTC
+scriptversion=2011-11-20.07; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
@@ -35,7 +35,7 @@ scriptversion=2011-01-19.21; # UTC
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
+# 'make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
@@ -156,7 +156,7 @@ while test $# -ne 0; do
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
- # Protect names problematic for `test' and other utilities.
+ # Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
@@ -190,7 +190,7 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
fi
shift # arg
dst_arg=$arg
- # Protect names problematic for `test' and other utilities.
+ # Protect names problematic for 'test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
@@ -202,7 +202,7 @@ if test $# -eq 0; then
echo "$0: no input file specified." >&2
exit 1
fi
- # It's OK to call `install-sh -d' without argument.
+ # It's OK to call 'install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
@@ -240,7 +240,7 @@ fi
for src
do
- # Protect names problematic for `test' and other utilities.
+ # Protect names problematic for 'test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
@@ -354,7 +354,7 @@ do
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
- # other-writeable bit of parent directory when it shouldn't.
+ # other-writable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
diff --git a/keys.c b/keys.c
index de7c9461..46f6a3d0 100644
--- a/keys.c
+++ b/keys.c
@@ -44,7 +44,7 @@ ldns_lookup_table ldns_signing_algorithms[] = {
};
ldns_key_list *
-ldns_key_list_new()
+ldns_key_list_new(void)
{
ldns_key_list *key_list = LDNS_MALLOC(ldns_key_list);
if (!key_list) {
@@ -57,7 +57,7 @@ ldns_key_list_new()
}
ldns_key *
-ldns_key_new()
+ldns_key_new(void)
{
ldns_key *newkey;
@@ -368,40 +368,50 @@ ldns_key_new_frm_fp_l(ldns_key **key, FILE *fp, int *line_nr)
#ifdef USE_SHA2
alg = LDNS_SIGN_RSASHA256;
#else
+# ifdef STDERR_MSGS
fprintf(stderr, "Warning: SHA256 not compiled into this ");
fprintf(stderr, "version of ldns\n");
+# endif
#endif
}
if (strncmp(d, "10 RSASHA512", 3) == 0) {
#ifdef USE_SHA2
alg = LDNS_SIGN_RSASHA512;
#else
+# ifdef STDERR_MSGS
fprintf(stderr, "Warning: SHA512 not compiled into this ");
fprintf(stderr, "version of ldns\n");
+# endif
#endif
}
if (strncmp(d, "12 ECC-GOST", 3) == 0) {
#ifdef USE_GOST
alg = LDNS_SIGN_ECC_GOST;
#else
+# ifdef STDERR_MSGS
fprintf(stderr, "Warning: ECC-GOST not compiled into this ");
fprintf(stderr, "version of ldns, use --enable-gost\n");
+# endif
#endif
}
if (strncmp(d, "13 ECDSAP256SHA256", 3) == 0) {
#ifdef USE_ECDSA
alg = LDNS_SIGN_ECDSAP256SHA256;
#else
+# ifdef STDERR_MSGS
fprintf(stderr, "Warning: ECDSA not compiled into this ");
fprintf(stderr, "version of ldns, use --enable-ecdsa\n");
+# endif
#endif
}
if (strncmp(d, "14 ECDSAP384SHA384", 3) == 0) {
#ifdef USE_ECDSA
alg = LDNS_SIGN_ECDSAP384SHA384;
#else
+# ifdef STDERR_MSGS
fprintf(stderr, "Warning: ECDSA not compiled into this ");
fprintf(stderr, "version of ldns, use --enable-ecdsa\n");
+# endif
#endif
}
if (strncmp(d, "157 HMAC-MD5", 4) == 0) {
@@ -1317,8 +1327,10 @@ ldns_key_dsa2bin(unsigned char *data, DSA *k, uint16_t *size)
memcpy(data, &T, 1);
if (T > 8) {
+#ifdef STDERR_MSGS
fprintf(stderr, "DSA key with T > 8 (ie. > 1024 bits)");
fprintf(stderr, " not implemented\n");
+#endif
return false;
}
@@ -1605,7 +1617,9 @@ ldns_read_anchor_file(const char *filename)
fp = fopen(filename, "r");
if (!fp) {
+#ifdef STDERR_MSGS
fprintf(stderr, "Unable to open %s: %s\n", filename, strerror(errno));
+#endif
LDNS_FREE(line);
return NULL;
}
@@ -1619,7 +1633,9 @@ ldns_read_anchor_file(const char *filename)
fclose(fp);
if (i <= 0) {
+#ifdef STDERR_MSGS
fprintf(stderr, "nothing read from %s", filename);
+#endif
LDNS_FREE(line);
return NULL;
} else {
@@ -1628,7 +1644,9 @@ ldns_read_anchor_file(const char *filename)
LDNS_FREE(line);
return r;
} else {
+#ifdef STDERR_MSGS
fprintf(stderr, "Error creating DNSKEY or DS rr from %s: %s\n", filename, ldns_get_errorstr_by_id(status));
+#endif
LDNS_FREE(line);
return NULL;
}
diff --git a/ldns/common.h.in b/ldns/common.h.in
index aedfc96d..8bf9654b 100644
--- a/ldns/common.h.in
+++ b/ldns/common.h.in
@@ -24,6 +24,9 @@
#define LDNS_BUILD_CONFIG_HAVE_ATTR_FORMAT @ldns_build_config_have_attr_format@
#define LDNS_BUILD_CONFIG_HAVE_ATTR_UNUSED @ldns_build_config_have_attr_unused@
#define LDNS_BUILD_CONFIG_HAVE_SOCKLEN_T @ldns_build_config_have_socklen_t@
+#define LDNS_BUILD_CONFIG_USE_DANE @ldns_build_config_use_dane@
+#define LDNS_BUILD_CONFIG_HAVE_B32_PTON @ldns_build_config_have_b32_pton@
+#define LDNS_BUILD_CONFIG_HAVE_B32_NTOP @ldns_build_config_have_b32_ntop@
/*
* HAVE_STDBOOL_H is not available when distributed as a library, but no build
diff --git a/ldns/dane.h b/ldns/dane.h
index c1c4e2d7..6adecd57 100644
--- a/ldns/dane.h
+++ b/ldns/dane.h
@@ -22,6 +22,7 @@
#ifndef LDNS_DANE_H
#define LDNS_DANE_H
+#if LDNS_BUILD_CONFIG_USE_DANE
#include <ldns/common.h>
#include <ldns/rdata.h>
@@ -240,5 +241,6 @@ ldns_status ldns_dane_verify(ldns_rr_list* tlsas,
}
#endif
+#endif /* LDNS_BUILD_CONFIG_USE_DANE */
#endif /* LDNS_DANE_H */
diff --git a/ldns/dnssec.h b/ldns/dnssec.h
index 34f63714..f4cdafbe 100644
--- a/ldns/dnssec.h
+++ b/ldns/dnssec.h
@@ -364,12 +364,30 @@ ldns_rdf *ldns_nsec3_bitmap(const ldns_rr *nsec3_rr);
ldns_rdf *ldns_nsec3_hash_name_frm_nsec3(const ldns_rr *nsec, ldns_rdf *name);
/**
- * Checks coverage of NSEC RR type bitmap
- * \param[in] nsec_bitmap The NSEC bitmap rdata field to check
- * \param[in] type The type to check
- * \return true if the NSEC RR covers the type
+ * Check if RR type t is enumerated and set in the RR type bitmap rdf.
+ * \param[in] bitmap the RR type bitmap rdf to look in
+ * \param[in] type the type to check for
+ * \return true when t is found and set, otherwise return false
*/
-bool ldns_nsec_bitmap_covers_type(const ldns_rdf *nsec_bitmap, ldns_rr_type type);
+bool ldns_nsec_bitmap_covers_type(const ldns_rdf* bitmap, ldns_rr_type type);
+
+/**
+ * Checks if RR type t is enumerated in the type bitmap rdf and sets the bit.
+ * \param[in] bitmap the RR type bitmap rdf to look in
+ * \param[in] type the type to for which the bit to set
+ * \return LDNS_STATUS_OK on success. LDNS_STATUS_TYPE_NOT_IN_BITMAP is
+ * returned when the bitmap does not contain the bit to set.
+ */
+ldns_status ldns_nsec_bitmap_set_type(ldns_rdf* bitmap, ldns_rr_type type);
+
+/**
+ * Checks if RR type t is enumerated in the type bitmap rdf and clears the bit.
+ * \param[in] bitmap the RR type bitmap rdf to look in
+ * \param[in] type the type to for which the bit to clear
+ * \return LDNS_STATUS_OK on success. LDNS_STATUS_TYPE_NOT_IN_BITMAP is
+ * returned when the bitmap does not contain the bit to clear.
+ */
+ldns_status ldns_nsec_bitmap_clear_type(ldns_rdf* bitmap, ldns_rr_type type);
/**
* Checks coverage of NSEC(3) RR name span
diff --git a/ldns/dnssec_sign.h b/ldns/dnssec_sign.h
index e77cb695..f51c7fb3 100644
--- a/ldns/dnssec_sign.h
+++ b/ldns/dnssec_sign.h
@@ -87,7 +87,7 @@ ldns_rdf *ldns_sign_public_rsamd5(ldns_buffer *to_sign, RSA *key);
* when walking the tree with the ldns_dnssec_name_node_next_nonglue()
* function. But watch out! Names that are partially occluded (like glue with
* the same name as the delegation) will not be marked and should specifically
- * be taken into account seperately.
+ * be taken into account separately.
*
* When glue_list is given (not NULL), in the process of marking the names, all
* glue resource records will be pushed to that list, even glue at the delegation name.
@@ -105,7 +105,7 @@ ldns_dnssec_zone_mark_and_get_glue(
* when walking the tree with the ldns_dnssec_name_node_next_nonglue()
* function. But watch out! Names that are partially occluded (like glue with
* the same name as the delegation) will not be marked and should specifically
- * be taken into account seperately.
+ * be taken into account separately.
*
* \param[in] zone the zone in which to mark the names
* \return LDNS_STATUS_OK on succesful completion
diff --git a/ldns/dnssec_verify.h b/ldns/dnssec_verify.h
index b6bdeca5..0c41e8c1 100644
--- a/ldns/dnssec_verify.h
+++ b/ldns/dnssec_verify.h
@@ -32,7 +32,7 @@ struct ldns_dnssec_data_chain_struct
* Creates a new dnssec_chain structure
* \return ldns_dnssec_data_chain *
*/
-ldns_dnssec_data_chain *ldns_dnssec_data_chain_new();
+ldns_dnssec_data_chain *ldns_dnssec_data_chain_new(void);
/**
* Frees a dnssec_data_chain structure
@@ -137,7 +137,7 @@ struct ldns_dnssec_trust_tree_struct
*
* \return ldns_dnssec_trust_tree *
*/
-ldns_dnssec_trust_tree *ldns_dnssec_trust_tree_new();
+ldns_dnssec_trust_tree *ldns_dnssec_trust_tree_new(void);
/**
* Frees the dnssec_trust_tree recursively
diff --git a/ldns/dnssec_zone.h b/ldns/dnssec_zone.h
index 70c81b04..b794f942 100644
--- a/ldns/dnssec_zone.h
+++ b/ldns/dnssec_zone.h
@@ -93,6 +93,13 @@ struct ldns_struct_dnssec_zone {
ldns_dnssec_name *soa;
/** tree of ldns_dnssec_names */
ldns_rbtree_t *names;
+ /** tree of ldns_dnssec_names by nsec3 hashes (when applicible) */
+ ldns_rbtree_t *hashed_names;
+ /** points to the first added NSEC3 rr whose parameters will be
+ * assumed for all subsequent NSEC3 rr's and which will be used
+ * to calculate hashed names
+ */
+ ldns_rr *_nsec3params;
};
typedef struct ldns_struct_dnssec_zone ldns_dnssec_zone;
@@ -100,7 +107,7 @@ typedef struct ldns_struct_dnssec_zone ldns_dnssec_zone;
* Creates a new entry for 1 pointer to an rr and 1 pointer to the next rrs
* \return the allocated data
*/
-ldns_dnssec_rrs *ldns_dnssec_rrs_new();
+ldns_dnssec_rrs *ldns_dnssec_rrs_new(void);
/**
* Frees the list of rrs, but *not* the individual ldns_rr records
@@ -119,7 +126,8 @@ void ldns_dnssec_rrs_free(ldns_dnssec_rrs *rrs);
void ldns_dnssec_rrs_deep_free(ldns_dnssec_rrs *rrs);
/**
- * Adds an RR to the list of RRs. The list will remain ordered
+ * Adds an RR to the list of RRs. The list will remain ordered.
+ * If an equal RR already exists, this RR will not be added.
*
* \param[in] rrs the list to add to
* \param[in] rr the RR to add
@@ -149,7 +157,7 @@ void ldns_dnssec_rrs_print_fmt(FILE *out,
* Creates a new list (entry) of RRsets
* \return the newly allocated structure
*/
-ldns_dnssec_rrsets *ldns_dnssec_rrsets_new();
+ldns_dnssec_rrsets *ldns_dnssec_rrsets_new(void);
/**
* Frees the list of rrsets and their rrs, but *not* the ldns_rr
@@ -224,7 +232,7 @@ void ldns_dnssec_rrsets_print_fmt(FILE *out,
* Create a new data structure for a dnssec name
* \return the allocated structure
*/
-ldns_dnssec_name *ldns_dnssec_name_new();
+ldns_dnssec_name *ldns_dnssec_name_new(void);
/**
* Create a new data structure for a dnssec name for the given RR
@@ -356,7 +364,7 @@ void ldns_dnssec_name_print_fmt(FILE *out,
* Creates a new dnssec_zone structure
* \return the allocated structure
*/
-ldns_dnssec_zone *ldns_dnssec_zone_new();
+ldns_dnssec_zone *ldns_dnssec_zone_new(void);
/**
* Create a new dnssec zone from a file.
diff --git a/ldns/error.h b/ldns/error.h
index bac38ff8..41b99ad1 100644
--- a/ldns/error.h
+++ b/ldns/error.h
@@ -117,7 +117,16 @@ enum ldns_enum_status {
LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH,
LDNS_STATUS_DANE_NON_CA_CERTIFICATE,
LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE,
- LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR
+ LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR,
+ LDNS_STATUS_EXISTS_ERR,
+ LDNS_STATUS_INVALID_ILNP64,
+ LDNS_STATUS_INVALID_EUI48,
+ LDNS_STATUS_INVALID_EUI64,
+ LDNS_STATUS_WIRE_RDATA_ERR,
+ LDNS_STATUS_INVALID_TAG,
+ LDNS_STATUS_TYPE_NOT_IN_BITMAP,
+ LDNS_STATUS_INVALID_RDF_TYPE,
+ LDNS_STATUS_RDATA_OVERFLOW,
};
typedef enum ldns_enum_status ldns_status;
diff --git a/ldns/host2str.h b/ldns/host2str.h
index bbf93276..e69389e9 100644
--- a/ldns/host2str.h
+++ b/ldns/host2str.h
@@ -40,32 +40,38 @@ extern "C" {
#define LDNS_APL_NEGATION 0x80
/**
- * Represent a NULL pointer (in stead of a pointer to a ldns_rr as "; (null)"
+ * Represent a NULL pointer (instead of a pointer to a ldns_rr as "; (null)"
* as opposed to outputting nothing at all in such a case.
*/
-#define LDNS_COMMENT_NULLS 0x0001
+/* Flag Name Flag Nr. Has data associated
+ ---------------------------------------------------------------------*/
+#define LDNS_COMMENT_NULLS (1 << 0)
/** Show key id with DNSKEY RR's as comment */
-#define LDNS_COMMENT_KEY_ID 0x0002
+#define LDNS_COMMENT_KEY_ID (1 << 1)
/** Show if a DNSKEY is a ZSK or KSK as comment */
-#define LDNS_COMMENT_KEY_TYPE 0x0004
+#define LDNS_COMMENT_KEY_TYPE (1 << 2)
/** Show DNSKEY key size as comment */
-#define LDNS_COMMENT_KEY_SIZE 0x0008
-/** Show key id, type and size as comment for DNSKEY RR's */
-#define LDNS_COMMENT_KEY (LDNS_COMMENT_KEY_ID \
- |LDNS_COMMENT_KEY_TYPE\
- |LDNS_COMMENT_KEY_SIZE)
+#define LDNS_COMMENT_KEY_SIZE (1 << 3)
/** Provide bubblebabble representation for DS RR's as comment */
-#define LDNS_COMMENT_BUBBLEBABBLE 0x0010
+#define LDNS_COMMENT_BUBBLEBABBLE (1 << 4)
/** Show when a NSEC3 RR has the optout flag set as comment */
-#define LDNS_COMMENT_FLAGS 0x0020
+#define LDNS_COMMENT_FLAGS (1 << 5)
/** Show the unhashed owner and next owner names for NSEC3 RR's as comment */
-#define LDNS_COMMENT_NSEC3_CHAIN 0x0040
+#define LDNS_COMMENT_NSEC3_CHAIN (1 << 6) /* yes */
/** Print mark up */
-#define LDNS_COMMENT_LAYOUT 0x0080
+#define LDNS_COMMENT_LAYOUT (1 << 7)
/** Also comment KEY_ID with RRSIGS **/
-#define LDNS_COMMENT_RRSIGS 0x0100
-#define LDNS_FMT_ZEROIZE_RRSIGS 0x0200
-#define LDNS_FMT_PAD_SOA_SERIAL 0x0400
+#define LDNS_COMMENT_RRSIGS (1 << 8)
+#define LDNS_FMT_ZEROIZE_RRSIGS (1 << 9)
+#define LDNS_FMT_PAD_SOA_SERIAL (1 << 10)
+#define LDNS_FMT_RFC3597 (1 << 11) /* yes */
+
+#define LDNS_FMT_FLAGS_WITH_DATA 2
+
+/** Show key id, type and size as comment for DNSKEY RR's */
+#define LDNS_COMMENT_KEY (LDNS_COMMENT_KEY_ID \
+ |LDNS_COMMENT_KEY_TYPE\
+ |LDNS_COMMENT_KEY_SIZE)
/**
* Output format specifier
@@ -87,6 +93,18 @@ struct ldns_struct_output_format
typedef struct ldns_struct_output_format ldns_output_format;
/**
+ * Output format struct with additional data for flags that use them.
+ * This struct may not be initialized directly. Use ldns_output_format_init
+ * to initialize.
+ */
+struct ldns_struct_output_format_storage
+{ int flags;
+ ldns_rbtree_t* hashmap; /* for LDNS_COMMENT_NSEC3_CHAIN */
+ ldns_rdf* bitmap; /* for LDNS_FMT_RFC3597 */
+};
+typedef struct ldns_struct_output_format_storage ldns_output_format_storage;
+
+/**
* Standard output format record that disables commenting in the textual
* representation of Resource Records completely.
*/
@@ -108,6 +126,55 @@ extern const ldns_output_format *ldns_output_format_default;
extern const ldns_output_format *ldns_output_format_bubblebabble;
/**
+ * Initialize output format storage to the default value.
+ * \param[in] fmt A reference to an output_format_ storage struct
+ * \return The initialized storage struct typecasted to ldns_output_format
+ */
+INLINE
+ldns_output_format* ldns_output_format_init(ldns_output_format_storage* fmt) {
+ fmt->flags = ldns_output_format_default->flags;
+ fmt->hashmap = NULL;
+ fmt->bitmap = NULL;
+ return (ldns_output_format*)fmt;
+}
+
+/**
+ * Set an ouput format flag.
+ */
+INLINE void ldns_output_format_set(ldns_output_format* fmt, int flag) {
+ fmt->flags |= flag;
+}
+
+/**
+ * Clear an ouput format flag.
+ */
+INLINE void ldns_output_format_clear(ldns_output_format* fmt, int flag) {
+ fmt->flags &= !flag;
+}
+
+/**
+ * Makes sure the LDNS_FMT_RFC3597 is set in the output format.
+ * Marks the type to be printed in RFC3597 format.
+ * /param[in] fmt the output format to update
+ * /param[in] the type to be printed in RFC3597 format
+ * /return LDNS_STATUS_OK on success
+ */
+ldns_status
+ldns_output_format_set_type(ldns_output_format* fmt, ldns_rr_type type);
+
+/**
+ * Makes sure the LDNS_FMT_RFC3597 is set in the output format.
+ * Marks the type to not be printed in RFC3597 format. When no other types
+ * have been marked before, all known types (except the given one) will be
+ * marked for printing in RFC3597 format.
+ * /param[in] fmt the output format to update
+ * /param[in] the type not to be printed in RFC3597 format
+ * /return LDNS_STATUS_OK on success
+ */
+ldns_status
+ldns_output_format_clear_type(ldns_output_format* fmt, ldns_rr_type type);
+
+/**
* Converts an ldns packet opcode value to its mnemonic, and adds that
* to the output buffer
* \param[in] *output the buffer to add the data to
@@ -399,15 +466,6 @@ ldns_status ldns_rdf2buffer_str_int16_data(ldns_buffer *output, const ldns_rdf *
*/
ldns_status ldns_rdf2buffer_str_ipseckey(ldns_buffer *output, const ldns_rdf *rdf);
-/**
- * Converts an LDNS_RDF_TYPE_TSIG rdata element to string format and adds it to the output buffer
- * \param[in] *rdf The rdata to convert
- * \param[in] *output The buffer to add the data to
- * \return LDNS_STATUS_OK on success, and error status on failure
- */
-ldns_status ldns_rdf2buffer_str_tsig(ldns_buffer *output, const ldns_rdf *rdf);
-
-
/**
* Converts the data in the rdata field to presentation
* format (as char *) and appends it to the given buffer
@@ -518,6 +576,66 @@ ldns_status ldns_rdf2buffer_str_int32(ldns_buffer *output, const ldns_rdf *rdf);
*/
ldns_status ldns_rdf2buffer_str_time(ldns_buffer *output, const ldns_rdf *rdf);
+/**
+ * Converts an LDNS_RDF_TYPE_ILNP64 rdata element to 4 hexadecimal numbers
+ * separated by colons and adds it to the output buffer
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_ilnp64(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Converts an LDNS_RDF_TYPE_EUI48 rdata element to 6 hexadecimal numbers
+ * separated by dashes and adds it to the output buffer
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_eui48(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Converts an LDNS_RDF_TYPE_EUI64 rdata element to 8 hexadecimal numbers
+ * separated by dashes and adds it to the output buffer
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_eui64(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Adds the LDNS_RDF_TYPE_TAG rdata to the output buffer,
+ * provided it contains only alphanumeric characters.
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_tag(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Adds the LDNS_RDF_TYPE_LONG_STR rdata to the output buffer, in-between
+ * double quotes and all non printable characters properly escaped.
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_long_str(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
+/**
+ * Converts an LDNS_RDF_TYPE_HIP rdata element to presentation format for
+ * the algorithm, HIT and Public Key and adds it the output buffer .
+ * \param[in] *rdf The rdata to convert
+ * \param[in] *output The buffer to add the data to
+ * \return LDNS_STATUS_OK on success, and error status on failure
+ */
+ldns_status ldns_rdf2buffer_str_hip(ldns_buffer *output,
+ const ldns_rdf *rdf);
+
/**
* Converts the data in the rdata field to presentation format and
* returns that as a char *.
diff --git a/ldns/keys.h b/ldns/keys.h
index 3e156233..d3b48738 100644
--- a/ldns/keys.h
+++ b/ldns/keys.h
@@ -166,13 +166,13 @@ typedef struct ldns_struct_key_list ldns_key_list;
* Creates a new empty key list
* \return a new ldns_key_list structure pointer
*/
-ldns_key_list *ldns_key_list_new();
+ldns_key_list *ldns_key_list_new(void);
/**
* Creates a new empty key structure
* \return a new ldns_key * structure
*/
-ldns_key *ldns_key_new();
+ldns_key *ldns_key_new(void);
/**
* Creates a new key based on the algorithm
diff --git a/ldns/ldns.h b/ldns/ldns.h
index a41e0325..60663ef9 100644
--- a/ldns/ldns.h
+++ b/ldns/ldns.h
@@ -26,7 +26,7 @@ faster than Perl.
The first main tool to use ldns is Drill, from which part of the library was
derived. From version 1.0.0 on, drill is included in the ldns release
-and will not be distributed seperately anymore. The library also includes some
+and will not be distributed separately anymore. The library also includes some
other examples and tools to show how it can be used. These can be found in the
examples/ directory in the tarball.
@@ -37,9 +37,9 @@ Feature list
- TSIG support,
- DNSSEC support; signing and verification,
- small size,
- - online documentation as well as manual pages.
+ - online documentation as well as manual pages.
-If you want to send us patches please use the code from subversion (trunk).
+If you want to send us patches please use the code from git.
\section using_ldns Using ldns
@@ -119,6 +119,7 @@ Or you can just use the menu above to browse through the API docs.
#include <ldns/parse.h>
#include <ldns/zone.h>
#include <ldns/dnssec_zone.h>
+#include <ldns/radix.h>
#include <ldns/rbtree.h>
#include <ldns/sha1.h>
#include <ldns/sha2.h>
diff --git a/ldns/net.h.in b/ldns/net.h.in
index cd4cfdec..e6b3618f 100644
--- a/ldns/net.h.in
+++ b/ldns/net.h.in
@@ -50,7 +50,6 @@ ldns_status ldns_udp_send(uint8_t **result, ldns_buffer *qbin, const struct sock
* \param[in] timeout *unused*, was the timeout value for the network
* \return the socket used
*/
-
int ldns_udp_bgsend(ldns_buffer *qbin, const struct sockaddr_storage *to, socklen_t tolen, struct timeval timeout);
/**
diff --git a/ldns/packet.h b/ldns/packet.h
index 687a6a25..9dca06f5 100644
--- a/ldns/packet.h
+++ b/ldns/packet.h
@@ -411,6 +411,17 @@ uint32_t ldns_pkt_querytime(const ldns_pkt *p);
size_t ldns_pkt_size(const ldns_pkt *p);
/**
+ * Return the number of RRs in the given section.
+ * Returns the sum of all RRs when LDNS_SECTION_ANY is given.
+ * Returns the sum of all non-question RRs when LDNS_SECTION_ANY_NOQUESTION
+ * is given.
+ * \param[in] p the packet
+ * \param[in] s the section
+ * \return the number of RRs in the given section
+ */
+uint16_t ldns_pkt_section_count(const ldns_pkt *p, ldns_pkt_section s);
+
+/**
* Return the packet's tsig pseudo rr's
* \param[in] p the packet
* \return the tsig rr
@@ -739,7 +750,7 @@ void ldns_pkt_set_edns_data(ldns_pkt *packet, ldns_rdf *data);
* allocates and initializes a ldns_pkt structure.
* \return pointer to the new packet
*/
-ldns_pkt *ldns_pkt_new();
+ldns_pkt *ldns_pkt_new(void);
/**
* frees the packet structure and all data that it contains.
@@ -760,6 +771,18 @@ void ldns_pkt_free(ldns_pkt *packet);
ldns_status ldns_pkt_query_new_frm_str(ldns_pkt **p, const char *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class , uint16_t flags);
/**
+ * creates an IXFR request packet for the given name, class.
+ * adds the SOA record to the authority section.
+ * \param[out] p the packet to be returned
+ * \param[in] rr_name the name to query for (as string)
+ * \param[in] rr_class the class to query for
+ * \param[in] flags packet flags
+ * \param[in] soa soa record to be added to the authority section
+ * \return LDNS_STATUS_OK or a ldns_status mesg with the error
+ */
+ldns_status ldns_pkt_ixfr_request_new_frm_str(ldns_pkt **p, const char *rr_name, ldns_rr_class rr_class, uint16_t flags, ldns_rr* soa);
+
+/**
* creates a packet with a query in it for the given name, type and class.
* \param[in] rr_name the name to query for
* \param[in] rr_type the type to query for
@@ -770,6 +793,17 @@ ldns_status ldns_pkt_query_new_frm_str(ldns_pkt **p, const char *rr_name, ldns_r
ldns_pkt *ldns_pkt_query_new(ldns_rdf *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class, uint16_t flags);
/**
+ * creates an IXFR request packet for the given name, type and class.
+ * adds the SOA record to the authority section.
+ * \param[in] rr_name the name to query for
+ * \param[in] rr_class the class to query for
+ * \param[in] flags packet flags
+ * \param[in] soa soa record to be added to the authority section
+ * \return ldns_pkt* a pointer to the new pkt
+ */
+ldns_pkt *ldns_pkt_ixfr_request_new(ldns_rdf *rr_name, ldns_rr_class rr_class, uint16_t flags, ldns_rr* soa);
+
+/**
* clones the given packet, creating a fully allocated copy
*
* \param[in] pkt the packet to clone
diff --git a/ldns/radix.h b/ldns/radix.h
new file mode 100644
index 00000000..f8833eb2
--- /dev/null
+++ b/ldns/radix.h
@@ -0,0 +1,240 @@
+/*
+ * radix.h -- generic radix tree
+ *
+ * Copyright (c) 2012, 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 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.
+ *
+ */
+
+/**
+ * \file
+ * Radix tree. Implementation taken from NSD 4, adjusted for use in ldns.
+ *
+ */
+
+#ifndef LDNS_RADIX_H_
+#define LDNS_RADIX_H_
+
+#include <ldns/error.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef uint16_t radix_strlen_t;
+typedef struct ldns_radix_array_t ldns_radix_array_t;
+typedef struct ldns_radix_node_t ldns_radix_node_t;
+typedef struct ldns_radix_t ldns_radix_t;
+
+/** Radix node select edge array */
+struct ldns_radix_array_t {
+ /** Additional string after the selection byte for this edge. */
+ uint8_t* str;
+ /** Length of additional string for this edge. */
+ radix_strlen_t len;
+ /** Node that deals with byte+str. */
+ ldns_radix_node_t* edge;
+};
+
+/** A node in a radix tree */
+struct ldns_radix_node_t {
+ /** Key corresponding to this node. */
+ uint8_t* key;
+ /** Key length corresponding to this node. */
+ radix_strlen_t klen;
+ /** Data corresponding to this node. */
+ void* data;
+ /** Parent node. */
+ ldns_radix_node_t* parent;
+ /** Index in the the parent node select edge array. */
+ uint8_t parent_index;
+ /** Length of the array. */
+ uint16_t len;
+ /** Offset of the array. */
+ uint16_t offset;
+ /** Capacity of the array. */
+ uint16_t capacity;
+ /** Select edge array. */
+ ldns_radix_array_t* array;
+};
+
+/** An entire radix tree */
+struct ldns_radix_t {
+ /** Root. */
+ ldns_radix_node_t* root;
+ /** Number of nodes in tree. */
+ size_t count;
+};
+
+/**
+ * Create a new radix tree.
+ * @return: new radix tree.
+ *
+ */
+ldns_radix_t* ldns_radix_create(void);
+
+/**
+ * Initialize radix tree.
+ * @param tree: uninitialized radix tree.
+ *
+ */
+void ldns_radix_init(ldns_radix_t* tree);
+
+/**
+ * Free the radix tree.
+ * @param tree: radix tree.
+ *
+ */
+void ldns_radix_free(ldns_radix_t* tree);
+
+/**
+ * Insert data into the tree.
+ * @param tree: tree to insert to.
+ * @param key: key.
+ * @param len: length of key.
+ * @param data: data.
+ * @return: status.
+ *
+ */
+ldns_status ldns_radix_insert(ldns_radix_t* tree, uint8_t* key,
+ radix_strlen_t len, void* data);
+
+/**
+ * Delete data from the tree.
+ * @param tree: tree to insert to.
+ * @param key: key.
+ * @param len: length of key.
+ * @return: unlinked data or NULL if not present.
+ *
+ */
+void* ldns_radix_delete(ldns_radix_t* tree, uint8_t* key, radix_strlen_t len);
+
+/**
+ * Search data in the tree.
+ * @param tree: tree to insert to.
+ * @param key: key.
+ * @param len: length of key.
+ * @return: the radix node or NULL if not found.
+ *
+ */
+ldns_radix_node_t* ldns_radix_search(ldns_radix_t* tree, uint8_t* key,
+ radix_strlen_t len);
+
+/**
+ * Search data in the tree, and if not found, find the closest smaller
+ * element in the tree.
+ * @param tree: tree to insert to.
+ * @param key: key.
+ * @param len: length of key.
+ * @param result: the radix node with the exact or closest match. NULL if
+ * the key is smaller than the smallest key in the tree.
+ * @return 1 if exact match, 0 otherwise.
+ *
+ */
+int ldns_radix_find_less_equal(ldns_radix_t* tree, uint8_t* key,
+ radix_strlen_t len, ldns_radix_node_t** result);
+
+/**
+ * Get the first element in the tree.
+ * @param tree: tree.
+ * @return: the radix node with the first element.
+ *
+ */
+ldns_radix_node_t* ldns_radix_first(ldns_radix_t* tree);
+
+/**
+ * Get the last element in the tree.
+ * @param tree: tree.
+ * @return: the radix node with the last element.
+ *
+ */
+ldns_radix_node_t* ldns_radix_last(ldns_radix_t* tree);
+
+/**
+ * Next element.
+ * @param node: node.
+ * @return: node with next element.
+ *
+ */
+ldns_radix_node_t* ldns_radix_next(ldns_radix_node_t* node);
+
+/**
+ * Previous element.
+ * @param node: node.
+ * @return: node with previous element.
+ *
+ */
+ldns_radix_node_t* ldns_radix_prev(ldns_radix_node_t* node);
+
+/**
+ * Split radix tree intwo.
+ * @param tree1: one tree.
+ * @param num: number of elements to split off.
+ * @param tree2: another tree.
+ * @return: status.
+ *
+ */
+ldns_status ldns_radix_split(ldns_radix_t* tree1, size_t num,
+ ldns_radix_t** tree2);
+
+/**
+ * Join two radix trees.
+ * @param tree1: one tree.
+ * @param tree2: another tree.
+ * @return: status.
+ *
+ */
+ldns_status ldns_radix_join(ldns_radix_t* tree1, ldns_radix_t* tree2);
+
+/**
+ * Call function for all nodes in the tree, such that leaf nodes are
+ * called before parent nodes.
+ * @param node: start node.
+ * @param func: function.
+ * @param arg: user argument.
+ *
+ */
+void ldns_radix_traverse_postorder(ldns_radix_node_t* node,
+ void (*func)(ldns_radix_node_t*, void*), void* arg);
+
+/**
+ * Print radix tree (for debugging purposes).
+ * @param fd: file descriptor.
+ * @param tree: tree.
+ *
+ */
+void ldns_radix_printf(FILE* fd, ldns_radix_t* tree);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LDNS_RADIX_H_ */
diff --git a/ldns/rdata.h b/ldns/rdata.h
index 229a4d4c..1866e8fc 100644
--- a/ldns/rdata.h
+++ b/ldns/rdata.h
@@ -28,12 +28,13 @@
extern "C" {
#endif
-#define LDNS_MAX_RDFLEN 8192
+#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
@@ -85,7 +86,10 @@ enum ldns_enum_rdf_type
LDNS_RDF_TYPE_PERIOD,
/** tsig time 48 bits */
LDNS_RDF_TYPE_TSIGTIME,
- LDNS_RDF_TYPE_TSIG,
+ /** 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,
@@ -104,7 +108,31 @@ enum ldns_enum_rdf_type
/** nsec3 hash salt */
LDNS_RDF_TYPE_NSEC3_SALT,
/** nsec3 base32 string (with length byte on wire */
- LDNS_RDF_TYPE_NSEC3_NEXT_OWNER
+ LDNS_RDF_TYPE_NSEC3_NEXT_OWNER,
+
+ /** 4 shorts represented as 4 * 16 bit hex numbers
+ * separated by colons. For NID and L64.
+ */
+ LDNS_RDF_TYPE_ILNP64,
+
+ /** 6 * 8 bit hex numbers separated by dashes. For EUI48. */
+ LDNS_RDF_TYPE_EUI48,
+ /** 8 * 8 bit hex numbers separated 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 ldns_enum_rdf_type ldns_rdf_type;
@@ -380,6 +408,34 @@ ldns_rdf *ldns_rdf_clone(const ldns_rdf *rd);
*/
int ldns_rdf_compare(const ldns_rdf *rd1, const ldns_rdf *rd2);
+/**
+ * Gets the algorithm value, the HIT and Public Key data from the rdf with
+ * type LDNS_RDF_TYPE_HIP.
+ * \param[in] rdf the rdf with type LDNS_RDF_TYPE_HIP
+ * \param[out] alg the algorithm
+ * \param[out] hit_size the size of the HIT data
+ * \param[out] hit the hit data
+ * \param[out] pk_size the size of the Public Key data
+ * \param[out] pk the Public Key data
+ * \return LDNS_STATUS_OK on success, and the error otherwise
+ */
+ldns_status ldns_rdf_hip_get_alg_hit_pk(ldns_rdf *rdf, uint8_t* alg,
+ uint8_t *hit_size, uint8_t** hit,
+ uint16_t *pk_size, uint8_t** pk);
+
+/**
+ * Creates a new LDNS_RDF_TYPE_HIP rdf from given data.
+ * \param[out] rdf the newly created LDNS_RDF_TYPE_HIP rdf
+ * \param[in] alg the algorithm
+ * \param[in] hit_size the size of the HIT data
+ * \param[in] hit the hit data
+ * \param[in] pk_size the size of the Public Key data
+ * \param[in] pk the Public Key data
+ * \return LDNS_STATUS_OK on success, and the error otherwise
+ */
+ldns_status ldns_rdf_hip_new_frm_alg_hit_pk(ldns_rdf** rdf, uint8_t alg,
+ uint8_t hit_size, uint8_t *hit, uint16_t pk_size, uint8_t *pk);
+
#ifdef __cplusplus
}
#endif
diff --git a/ldns/resolver.h b/ldns/resolver.h
index 7af5d401..26d4f480 100644
--- a/ldns/resolver.h
+++ b/ldns/resolver.h
@@ -138,6 +138,9 @@ struct ldns_struct_resolver
char *_tsig_keydata;
/** TSIG signing algorithm */
char *_tsig_algorithm;
+
+ /** Source address to query from */
+ ldns_rdf *_source;
};
typedef struct ldns_struct_resolver ldns_resolver;
@@ -152,6 +155,13 @@ typedef struct ldns_struct_resolver ldns_resolver;
uint16_t ldns_resolver_port(const ldns_resolver *r);
/**
+ * Get the source address the resolver should use
+ * \param[in] r the resolver
+ * \return the source rdf
+ */
+ldns_rdf *ldns_resolver_source(const ldns_resolver *r);
+
+/**
* Is the resolver set to recurse
* \param[in] r the resolver
* \return true if so, otherwise false
@@ -338,6 +348,13 @@ size_t ldns_resolver_searchlist_count(const ldns_resolver *r);
void ldns_resolver_set_port(ldns_resolver *r, uint16_t p);
/**
+ * Set the source rdf (address) the resolver should use
+ * \param[in] r the resolver
+ * \param[in] s the source address
+ */
+void ldns_resolver_set_source(ldns_resolver *r, ldns_rdf *s);
+
+/**
* Set the resolver recursion
* \param[in] r the resolver
* \param[in] b true: set to recurse, false: unset
@@ -464,9 +481,10 @@ void ldns_resolver_set_retrans(ldns_resolver *r, uint8_t re);
void ldns_resolver_set_fallback(ldns_resolver *r, bool fallback);
/**
- * Set the resolver retry interval (in seconds)
+ * Set the number of times a resolver should retry a nameserver before the
+ * next one is tried.
* \param[in] r the resolver
- * \param[in] re the retry interval
+ * \param[in] re the number of retries
*/
void ldns_resolver_set_retry(ldns_resolver *r, uint8_t re);
@@ -583,6 +601,22 @@ ldns_status ldns_resolver_push_nameserver_rr_list(ldns_resolver *r, ldns_rr_list
*/
ldns_pkt* ldns_resolver_search(const ldns_resolver *r, const ldns_rdf *rdf, ldns_rr_type t, ldns_rr_class c, uint16_t flags);
+
+/**
+ * Send the query for using the resolver and take the search list into account
+ * The search algorithm is as follows:
+ * If the name is absolute, try it as-is, otherwise apply the search list
+ * \param[out] pkt a packet with the reply from the nameserver
+ * \param[in] *r operate using this resolver
+ * \param[in] *rdf query for this name
+ * \param[in] t query for this type (may be 0, defaults to A)
+ * \param[in] c query for this class (may be 0, default to IN)
+ * \param[in] flags the query flags
+ *
+ * \return ldns_status LDNS_STATUS_OK on success
+ */
+ldns_status ldns_resolver_search_status(ldns_pkt** pkt, ldns_resolver *r, const ldns_rdf *rdf, ldns_rr_type t, ldns_rr_class c, uint16_t flags);
+
/**
* Form a query packet from a resolver and name/type/class combo
* \param[out] **q a pointer to a ldns_pkt pointer (initialized by this function)
@@ -619,12 +653,29 @@ ldns_status ldns_resolver_send_pkt(ldns_pkt **answer, ldns_resolver *r, ldns_pkt
/**
* Send a query to a nameserver
+ * \param[out] pkt a packet with the reply from the nameserver
* \param[in] *r operate using this resolver
* \param[in] *name query for this name
* \param[in] *t query for this type (may be 0, defaults to A)
* \param[in] *c query for this class (may be 0, default to IN)
* \param[in] flags the query flags
*
+ * \return ldns_status LDNS_STATUS_OK on success
+ * if _defnames is true the default domain will be added
+ */
+ldns_status ldns_resolver_query_status(ldns_pkt** pkt, ldns_resolver *r, const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c, uint16_t flags);
+
+
+/**
+ * Send a query to a nameserver
+ * \param[in] *r operate using this resolver
+ * (despite the const in the declaration,
+ * the struct is altered as a side-effect)
+ * \param[in] *name query for this name
+ * \param[in] *t query for this type (may be 0, defaults to A)
+ * \param[in] *c query for this class (may be 0, default to IN)
+ * \param[in] flags the query flags
+ *
* \return ldns_pkt* a packet with the reply from the nameserver
* if _defnames is true the default domain will be added
*/
diff --git a/ldns/rr.h b/ldns/rr.h
index 0520dcfe..ff499395 100644
--- a/ldns/rr.h
+++ b/ldns/rr.h
@@ -36,8 +36,8 @@ extern "C" {
/** The bytes TTL, CLASS and length use up in an rr */
#define LDNS_RR_OVERHEAD 10
-/* The first fields are 'common' and can be referenced instantly */
-#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 53
+/* The first fields are contiguous and can be referenced instantly */
+#define LDNS_RDATA_FIELD_DESCRIPTORS_COMMON 258
@@ -163,7 +163,7 @@ enum ldns_enum_rr_type
LDNS_RR_TYPE_OPT = 41,
/** RFC3123 */
LDNS_RR_TYPE_APL = 42,
- /** draft-ietf-dnsext-delegation */
+ /** RFC4034, RFC3658 */
LDNS_RR_TYPE_DS = 43,
/** SSH Key Fingerprint */
LDNS_RR_TYPE_SSHFP = 44, /* RFC 4255 */
@@ -179,19 +179,35 @@ enum ldns_enum_rr_type
LDNS_RR_TYPE_NSEC3 = 50, /* RFC 5155 */
LDNS_RR_TYPE_NSEC3PARAM = 51, /* RFC 5155 */
LDNS_RR_TYPE_NSEC3PARAMS = 51,
- /** draft-ietf-dane-protocol */
- LDNS_RR_TYPE_TLSA = 52,
+ 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,
+ 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 */
+
+ LDNS_RR_TYPE_EUI48 = 108, /* RFC 7043 */
+ LDNS_RR_TYPE_EUI64 = 109, /* RFC 7043 */
+
+ LDNS_RR_TYPE_TKEY = 249, /* RFC 2930 */
LDNS_RR_TYPE_TSIG = 250,
LDNS_RR_TYPE_IXFR = 251,
LDNS_RR_TYPE_AXFR = 252,
@@ -201,7 +217,12 @@ enum ldns_enum_rr_type
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,
@@ -337,6 +358,23 @@ struct ldns_struct_rr_descriptor
};
typedef struct ldns_struct_rr_descriptor ldns_rr_descriptor;
+
+/**
+ * Create a rr type bitmap rdf providing enough space to set all
+ * known (to ldns) rr types.
+ * \param[out] rdf the constructed rdf
+ * \return LDNS_STATUS_OK if all went well.
+ */
+ldns_status ldns_rdf_bitmap_known_rr_types_space(ldns_rdf** rdf);
+
+/**
+ * Create a rr type bitmap rdf with at least all known (to ldns) rr types set.
+ * \param[out] rdf the constructed rdf
+ * \return LDNS_STATUS_OK if all went well.
+ */
+ldns_status ldns_rdf_bitmap_known_rr_types(ldns_rdf** rdf);
+
+
/**
* creates a new rr structure.
* \return ldns_rr *
@@ -589,7 +627,7 @@ ldns_rr* ldns_rr_list_rr(const ldns_rr_list *rr_list, size_t nr);
* creates a new rr_list structure.
* \return a new rr_list structure
*/
-ldns_rr_list* ldns_rr_list_new();
+ldns_rr_list* ldns_rr_list_new(void);
/**
* frees an rr_list structure.
diff --git a/ldns/str2host.h b/ldns/str2host.h
index 09416cd2..341aa248 100644
--- a/ldns/str2host.h
+++ b/ldns/str2host.h
@@ -181,14 +181,6 @@ ldns_status ldns_str2rdf_alg(ldns_rdf **rd, const char *str);
ldns_status ldns_str2rdf_unknown(ldns_rdf **rd, const char *str);
/**
- * convert string with a tsig? RR into wireformat
- * \param[in] rd the rdf where to put the data
- * \param[in] str the string to be converted
- * \return ldns_status
- */
-ldns_status ldns_str2rdf_tsig(ldns_rdf **rd, const char *str);
-
-/**
* convert string with a protocol service into wireformat
* \param[in] rd the rdf where to put the data
* \param[in] str the string to be converted
@@ -244,6 +236,58 @@ ldns_status ldns_str2rdf_ipseckey(ldns_rdf **rd, const char *str);
*/
ldns_status ldns_str2rdf_dname(ldns_rdf **rd, const char *str);
+/**
+ * convert 4 * 16bit hex separated by colons into wireformat
+ * \param[in] rd the rdf where to put the data
+ * \param[in] str the string to be converted
+ * \return ldns_status
+ */
+ldns_status ldns_str2rdf_ilnp64(ldns_rdf **rd, const char *str);
+
+/**
+ * convert 6 hex bytes separated by dashes into wireformat
+ * \param[in] rd the rdf where to put the data
+ * \param[in] str the string to be converted
+ * \return ldns_status
+ */
+ldns_status ldns_str2rdf_eui48(ldns_rdf **rd, const char *str);
+
+/**
+ * convert 8 hex bytes separated by dashes into wireformat
+ * \param[in] rd the rdf where to put the data
+ * \param[in] str the string to be converted
+ * \return ldns_status
+ */
+ldns_status ldns_str2rdf_eui64(ldns_rdf **rd, const char *str);
+
+/**
+ * Convert a non-zero sequence of US-ASCII letters and numbers into wireformat
+ * \param[in] rd the rdf where to put the data
+ * \param[in] str the string to be converted
+ * \return ldns_status
+ */
+ldns_status ldns_str2rdf_tag(ldns_rdf **rd, const char *str);
+
+/**
+ * Convert a <character-string> encoding of the value field as specified
+ * [RFC1035], Section 5.1., encoded as one bug chunk of data.
+ * \param[in] rd the rdf where to put the data
+ * \param[in] str the string to be converted
+ * \return ldns_status
+ */
+ldns_status ldns_str2rdf_long_str(ldns_rdf **rd, const char *str);
+
+/**
+ * Convert a "<algorithm> <hit> <pk>" encoding of the value field as specified
+ * in Section 6. of [RFC5205], encoded as wireformat as specified in Section 5.
+ * of [RFC5205].
+ * \param[in] rd the rdf where to put the data
+ * \param[in] str the string to be converted
+ * \return ldns_status
+ */
+ldns_status ldns_str2rdf_hip(ldns_rdf **rd, const char *str);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/ldns/util.h.in b/ldns/util.h.in
index fe4ff372..b6c9abe0 100644
--- a/ldns/util.h.in
+++ b/ldns/util.h.in
@@ -325,42 +325,66 @@ uint16_t ldns_get_random(void);
*/
char *ldns_bubblebabble(uint8_t *data, size_t len);
-#ifndef B32_NTOP
-int ldns_b32_ntop(uint8_t const *src, size_t srclength,
- char *target, size_t targsize);
-int b32_ntop(uint8_t const *src, size_t srclength,
- char *target, size_t targsize);
-int ldns_b32_ntop_extended_hex(uint8_t const *src, size_t srclength,
- char *target, size_t targsize);
-int b32_ntop_extended_hex(uint8_t const *src, size_t srclength,
- char *target, size_t targsize);
+
+INLINE time_t ldns_time(time_t *t) { return time(t); }
+
+
/**
* calculates the size needed to store the result of b32_ntop
*/
/*@unused@*/
-INLINE size_t ldns_b32_ntop_calculate_size(size_t srcsize)
+INLINE size_t ldns_b32_ntop_calculate_size(size_t src_data_length)
{
- size_t result = ((((srcsize / 5) * 8) - 2) + 2);
- return result;
+ return src_data_length == 0 ? 0 : ((src_data_length - 1) / 5 + 1) * 8;
+}
+
+INLINE size_t ldns_b32_ntop_calculate_size_no_padding(size_t src_data_length)
+{
+ return ((src_data_length + 3) * 8 / 5) - 4;
}
-#endif /* !B32_NTOP */
-#ifndef B32_PTON
-int ldns_b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize);
-int b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize);
-int ldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize);
-int b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize);
+
+int ldns_b32_ntop(const uint8_t* src_data, size_t src_data_length,
+ char* target_text_buffer, size_t target_text_buffer_size);
+
+int ldns_b32_ntop_extended_hex(const uint8_t* src_data, size_t src_data_length,
+ char* target_text_buffer, size_t target_text_buffer_size);
+
+#if ! LDNS_BUILD_CONFIG_HAVE_B32_NTOP
+
+int b32_ntop(const uint8_t* src_data, size_t src_data_length,
+ char* target