diff --git a/.gitignore b/.gitignore
index 0f4482ef..c78d500d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,6 +39,7 @@ src/test/check_getdns_ev
src/test/scratchpad
src/test/scratchpad.c
src/tools/getdns_query
+src/stubby
doc/*.3
src/getdns/getdns.h
*.log
@@ -54,6 +55,13 @@ m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
src/config.h.in
-build/
getdns.pc
getdns_ext_event.pc
+/src/test/tpkg/result.*
+/src/test/tpkg/.done-*
+/src/test/tpkg/.tpkg.var.master
+/src/test/tpkg/scan-build-reports/
+/src/test/tpkg/install/
+/src/test/tpkg/build/
+/src/test/tpkg/build-stub-only/
+/src/test/tpkg/build-event-loops/
diff --git a/.gitmodules b/.gitmodules
index a79d3846..bc0b060e 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -2,3 +2,7 @@
path = src/jsmn
url = https://github.com/getdnsapi/jsmn.git
branch = getdns
+[submodule "stubby"]
+ path = stubby
+ url = https://github.com/getdnsapi/stubby.git
+ branch = develop
diff --git a/.travis.yml b/.travis.yml
index a447c7f1..98b98d95 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,7 @@ addons:
- libev-dev
- valgrind
- clang
+ - wget
script:
- mkdir tests
- cd tests
diff --git a/ChangeLog b/ChangeLog
index 1adfe0b6..a0226b71 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,101 @@
+* 2017-0?-??: Version 1.1.3
+ * No annotations with the output of getdns_query anymore,
+ unless -V option is given to increase verbosity
+ Thanks Ollivier Robert
+ * getdns_query will now exit with failure status if replies are BOGUS
+ * Bugfix: dnssec_return_validation_chain now also works when fallback
+ to full recursion was needed with dnssec_roadblock_avoidance
+ * More clear build instructions from Paul Hoffman. Thanks.
+ * Bugfix #320.1: Eliminate multiple closing of file descriptors
+ Thanks Neil Cook
+ * Bugfix #320.2: Array bounds bug in upstream_select
+ Thanks Neil Cook
+ * Bugfix #318: getdnsapi/getdns/README.md links to nonexistent wiki
+ pages. Thanks James Raftery
+ * Bugfix #322: MacOS 10.10 (Yosemite) provides TCP fastopen interface
+ but does not have it implemented. Thanks Joel Purra
+ * Compile without Stubby by default. Stubby now has a git repository
+ of its own. The new Stubby repository is added as a submodule.
+ Stubby will still be build alongside getdns with the --with-stubby
+ configure option.
+
+* 2017-07-03: Version 1.1.2
+ * Bugfix for parallel make install
+ * Bugfix to trigger event callbacks on socket errors
+ * A getdns_context_set_logfunc() function with which one may
+ register a callback log function for certain library subsystems
+ at certain levels. Currently this can only be used for
+ upstream stastistics subsystem.
+
+* 2017-06-15: Version 1.1.1
+ * Bugfix #306 hanging/segfaulting on certain (IPv6) upstream failures
+ * Spelling fix s/receive/receive. Thanks Andreas Schulze.
+ * Added stubby-setdns-macos.sh script to support Homebrew formula
+ * Include stubby.conf in the districution tarball
+ * Bugfix #286 reschedule reused listening addresses
+ * Bugfix #166 Allow parallel builds and unit-tests
+ * NSAP-PTR, EID and NIMLOC, TALINK, AVC support
+ * Bugfix of TA RR type
+ * OPENPGPKEY and SMIMEA support
+ * Bugfix TAG rdata type presentation format for CAA RR type
+ * Bugfix Zero sized gateways with IPSECKEY gateway_type 0
+ * Guidance for integration with systemd
+ * Also check for memory leaks with advances server capabilities.
+ * Bugfix convert IP string to IP dict with getdns_str2dict() directly.
+
+* 2017-04-13: Version 1.1.0
+ * bugfix: Check size of tls_auth_name.
+ * Improvements that came from Visual Studio static analysis
+ * Fix to compile with libressl. Thanks phicoh.
+ * Spelling fixes. Thanks Andreas Schulze.
+ * bugfix: Reschedule request timeout when getting the DNSSEC chain.
+ * getdns_context_unset_edns_maximum_udp_payload_size() to reset
+ to default IPv4/IPv6 dependent edns max udp payload size.
+ * Implement sensible default edns0 padding policy. Thanks DKG.
+ * Keep connections open with sync requests too.
+ * Fix of event loops so they do not give up with naked timers with
+ windows. Thanks Christian Huitema.
+ * Include peer certificate with DNS-over-TLS in combination with
+ the return_call_reporting extension.
+ * More fine grained control over TLS upstream retry and back off
+ behaviour with getdns_context_set_tls_backoff_time() and
+ getdns_context_set_tls_connection_retries().
+ * New round robin over the available upstreams feaure.
+ Enable with getdns_context_set_round_robin_upstreams()
+ * Bugfix: Queue requests when no sockets available for outgoing queries.
+ * Obey the outstanding query limit with STUB resolution mode too.
+ * Updated stubby config file
+ * Draft MDNS client implementation by Christian Huitema.
+ Enable with --enable-draft-mdns-support to configure
+ * bugfix: Let synchronous queries use fds > MAX_FDSETSIZE;
+ By moving default eventloop from select to poll
+ Thanks Neil Cook
+ * bugfix: authentication failure for self signed cert + only pinset
+ * bugfix: issue with session re-use making authentication appear to fail
+
+* 2017-01-13: Version 1.0.0
+ * edns0_cookies extension enabled by default (per RFC7873)
+ * dnssec_roadblock_avoidance enabled by default (per RFC8027)
+ * bugfix: DSA support with OpenSSL 1.1.0
+ * Initialize OpenSSL just once in a thread safe way
+ * Thread safety with arc4random function
+ * Improvements that came from Visual Studio static analysis
+ Thanks Christian Huitema
+ * Conventional RFC3986 IPv6 [address]:port parsing from getdns_query
+ * bugfix: OpenSSL 1.1.0 style crypto locking
+ Thanks volkommenheit
+ * configure tells *which* dependency is missing
+ * bugfix: Exclude terminating '\0' from bindata's returned by
+ getdns_get_suffix(). Thanks Jim Hague
+ * Better README.md. Thanks Andrew Sullivan
+
+* 2016-10-19: Version 1.1.0-a2
+ * Improved TLS connection management
+ * OpenSSL 1.1 support
+ * Stubby, Server version of getdns_query that by default listens
+ on 127.0.0.1 and ::1 and reads config from /etc/stubby.conf
+ and $HOME/.stubby.conf
+
* 2016-07-14: Version 1.1.0a1
* Conversion functions from text strings to getdns native types:
getdns_str2dict(), getdns_str2list(), getdns_str2bindata() and
@@ -127,7 +225,7 @@
'-1' to append suffix only to single label after failure
'-M' to append suffix only to multi label name after failure
'-N' to never append a suffix
- '-Z ' to set suffixes with the given comma separed list
+ '-Z ' to set suffixes with the given comma separated list
* Better help text for getdns_query (printed with the '-h' option)
* Setting the +specify_class extension with getdns_query
* Return NOT_IMPLEMENTED for not implemented namespaces, and the
diff --git a/Makefile.in b/Makefile.in
index b0a478a2..422f6d80 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -44,7 +44,7 @@ libdir = @libdir@
srcdir = @srcdir@
INSTALL = @INSTALL@
-all : default @GETDNS_QUERY@
+all : default @GETDNS_QUERY@
everything: default
cd src/test && $(MAKE)
@@ -52,7 +52,10 @@ everything: default
default:
cd src && $(MAKE) $@
-install: all getdns.pc getdns_ext_event.pc @INSTALL_GETDNS_QUERY@
+install-lib:
+ cd src && $(MAKE) install
+
+install: getdns.pc getdns_ext_event.pc install-lib @INSTALL_GETDNS_QUERY@
$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)
$(INSTALL) -m 644 $(srcdir)/AUTHORS $(DESTDIR)$(docdir)
$(INSTALL) -m 644 $(srcdir)/ChangeLog $(DESTDIR)$(docdir)
@@ -66,9 +69,7 @@ install: all getdns.pc getdns_ext_event.pc @INSTALL_GETDNS_QUERY@
$(INSTALL) -m 644 getdns_ext_event.pc $(DESTDIR)$(libdir)/pkgconfig
$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)/spec
$(INSTALL) -m 644 $(srcdir)/spec/index.html $(DESTDIR)$(docdir)/spec
- $(INSTALL) -m 644 $(srcdir)/spec/getdns*tgz $(DESTDIR)$(docdir)/spec || true
- cd src && $(MAKE) $@
- cd doc && $(MAKE) $@
+ cd doc && $(MAKE) install
@echo "***"
@echo "*** !!! IMPORTANT !!!! libgetdns needs a DNSSEC trust anchor!"
@echo "***"
@@ -98,23 +99,32 @@ doc: FORCE
example:
cd spec/example && $(MAKE) $@
-test:
+test: default
+ cd src/test && $(MAKE) $@
+
+getdns_query: default
+ cd src/tools && $(MAKE) $@
+
+stubby:
cd src && $(MAKE) $@
-getdns_query:
- cd src && $(MAKE) $@
-
-scratchpad:
- cd src && $(MAKE) $@
+scratchpad: default
+ cd src/test && $(MAKE) $@
pad: scratchpad
src/test/scratchpad || ./libtool exec gdb src/test/scratchpad
-install-getdns_query:
- cd src/tools && $(MAKE) install
+install-getdns_query: install-lib
+ cd src/tools && $(MAKE) $@
uninstall-getdns_query:
- cd src/tools && $(MAKE) uninstall
+ cd src/tools && $(MAKE) $@
+
+install-stubby:
+ cd src && $(MAKE) $@
+
+uninstall-stubby:
+ cd src && $(MAKE) $@
clean:
cd src && $(MAKE) $@
@@ -141,18 +151,22 @@ distclean:
rm -f m4/ltoptions.m4
rm -f m4/ltsugar.m4
rm -f m4/ltversion.m4
- rm -f $(distdir).tar.gz $(distdir).tar.gz.sha1
+ rm -f $(distdir).tar.gz $(distdir).tar.gz.sha256
rm -f $(distdir).tar.gz.md5 $(distdir).tar.gz.asc
megaclean:
- cd $(srcdir) && rm -fr * .dir-locals.el .gitignore .indent.pro .travis.yml && git reset --hard
+ cd $(srcdir) && rm -fr * .dir-locals.el .gitignore .indent.pro .travis.yml && git reset --hard && git submodule update --init
+
+autoclean: megaclean
+ libtoolize -ci
+ autoreconf -fi
dist: $(distdir).tar.gz
-pub: $(distdir).tar.gz.sha1 $(distdir).tar.gz.md5 $(distdir).tar.gz.asc
+pub: $(distdir).tar.gz.sha256 $(distdir).tar.gz.md5 $(distdir).tar.gz.asc
-$(distdir).tar.gz.sha1: $(distdir).tar.gz
- openssl sha1 $(distdir).tar.gz >$@
+$(distdir).tar.gz.sha256: $(distdir).tar.gz
+ openssl sha256 $(distdir).tar.gz >$@
$(distdir).tar.gz.md5: $(distdir).tar.gz
openssl md5 $(distdir).tar.gz >$@
@@ -178,7 +192,6 @@ $(distdir):
mkdir -p $(distdir)/src
mkdir -p $(distdir)/src/getdns
mkdir -p $(distdir)/src/test
- mkdir -p $(distdir)/src/test/jsmn
mkdir -p $(distdir)/src/extension
mkdir -p $(distdir)/src/compat
mkdir -p $(distdir)/src/util
@@ -188,6 +201,8 @@ $(distdir):
mkdir -p $(distdir)/doc
mkdir -p $(distdir)/spec
mkdir -p $(distdir)/spec/example
+ mkdir -p $(distdir)/stubby
+ mkdir -p $(distdir)/stubby/src
cp $(srcdir)/configure.ac $(distdir)
cp $(srcdir)/configure $(distdir)
cp $(srcdir)/AUTHORS $(distdir)
@@ -219,16 +234,22 @@ $(distdir):
cp $(srcdir)/src/test/*.good $(distdir)/src/test
cp $(srcdir)/src/compat/*.[ch] $(distdir)/src/compat
cp $(srcdir)/src/util/*.[ch] $(distdir)/src/util
+ cp -r $(srcdir)/src/util/orig-headers $(distdir)/src/util
+ cp -r $(srcdir)/src/util/auxiliary $(distdir)/src/util
cp $(srcdir)/src/gldns/*.[ch] $(distdir)/src/gldns
cp $(srcdir)/doc/Makefile.in $(distdir)/doc
cp $(srcdir)/doc/*.in $(distdir)/doc
cp $(srcdir)/doc/manpgaltnames $(distdir)/doc
cp $(srcdir)/spec/*.html $(distdir)/spec
- cp $(srcdir)/spec/*.tgz $(distdir)/spec || true
cp $(srcdir)/spec/example/Makefile.in $(distdir)/spec/example
cp $(srcdir)/spec/example/*.[ch] $(distdir)/spec/example
cp $(srcdir)/src/tools/Makefile.in $(distdir)/src/tools
cp $(srcdir)/src/tools/*.[ch] $(distdir)/src/tools
+ cp $(srcdir)/stubby/stubby.conf.example $(distdir)/stubby
+ cp $(srcdir)/stubby/stubby-setdns-macos.sh $(distdir)/stubby
+ cp $(srcdir)/stubby/src/stubby.c $(distdir)/stubby/src
+ cp $(srcdir)/stubby/COPYING $(distdir)/stubby
+ cp $(srcdir)/stubby/README.md $(distdir)/stubby
cp $(srcdir)/src/jsmn/*.[ch] $(distdir)/src/jsmn
cp $(srcdir)/src/jsmn/LICENSE $(distdir)/src/jsmn
cp $(srcdir)/src/jsmn/README.md $(distdir)/src/jsmn
diff --git a/README.md b/README.md
index 28a4d6ab..b54c8f73 100644
--- a/README.md
+++ b/README.md
@@ -5,23 +5,45 @@ getdns
* GitHub:
-getdns is an implementation of a modern asynchronous DNS API specification
-originally edited by Paul Hoffman. It is intended to make all types of DNS
-information easily available to application developers and non-DNS experts.
-The project home page at [getdnsapi.net](https://getdnsapi.net) provides
-documentation, binary downloads and news regarding the getdns API
-implementation. This implementation is licensed under the New BSD License
-(BSD-new).
+getdns is an implementation of a modern asynchronous DNS API; the specification was originally edited by Paul Hoffman. It is intended to make all types of DNS information easily available to application developers and non-DNS experts.
-This file captures the goals and direction of the project and the current state
-of the implementation.
+## Why you might want getdns
-If you are just getting started with the library take a look at the section
-below that describes building and handling external dependencies for the
-library. Once it is built you should take a look at src/examples to see how
-the library is used.
+Traditional access to DNS data from applications has several limitations:
-## Download
+* APIs require applications to have considerable sophistication about DNS data and data types
+
+* Some kinds of data about the response (notably, the resource record set time to live) is not exposed via any API, so applications need to process raw protocol responses to get such data
+
+* APIs are often blocking, meaning asynchronous access is not possible without some work
+
+* Sophisticated uses of the DNS (things like IDNA and DNSSEC validation) require considerable application work, possibly by application developers with little experience with the vagaries of DNS.
+
+getdns also provides an experimental DNS Privacy enabled client called 'stubby' - see below for more details.
+
+## Motivation for providing the API
+
+The developers are of the opinion that DNSSEC offers a unique global infrastructure for establishing and enhancing cryptographic trust relations. With the development of this API we intend to offer application developers a modern and flexible interface that enables end-to-end trust in the DNS architecture, and which will inspire application developers to implement innovative security solutions in their applications.
+
+### API Documentation
+
+Note that this implementation offers additional functionality to supplement that in the [official getdns API](https://getdnsapi.net/documentation/spec/). Some additions are convenient utility functions but other functionality is experimental prior to be being recommended for inclusion in the official API. The [Doxygen documentation](https://getdnsapi.net/doxygen/modules.html) provides the details of the full API for this implementation.
+
+## License
+
+This implementation is licensed under the New BSD License (BSD-new).
+
+Obtaining and getting started with getdns
+=========================================
+The project home page at [getdnsapi.net](https://getdnsapi.net) provides documentation, binary downloads, and news regarding the getdns API implementation. This README file captures the goals and direction of the project and the current state of the implementation.
+
+If you are just getting started with the library take a look at the section below that describes building and handling external dependencies for the library.
+
+### Examples
+Once it is built you should take a look at src/examples to see how the library is used.
+
+
+# Download
Download the sources from our [github repo](https://github.com/getdnsapi/getdns)
or from [getdnsapi.net](https://getdnsapi.net) and verify the download using
@@ -29,129 +51,79 @@ the checksums (SHA1 or MD5) or using gpg to verify the signature. Our keys are
available from the [pgp keyservers](https://keyserver.pgp.com)
* willem@nlnetlabs.nl, key id E5F8F8212F77A498
-* gwiley@verisign.com, key id 9DC3D572A6B73532
-## Mailing lists
+# Releases
-We have a [getdns users list](https://getdnsapi.net/mailman/listinfo/spec) for this implementation.
-
-The [getdns-api mailing list](https://getdnsapi.net/mailman/listinfo/spec)
-is a good place to engage in discussions regarding the design of the API.
-
-## Motivation for providing the API
-
-The developers are of the opinion that DNSSEC offers a unique global
-infrastructure for establishing and enhancing cryptographic trust relations.
-With the development of this API we intend to offer application developers a
-modern and flexible way that enables end-to-end trust in the DNS architecture
-and will inspire application developers towards innovative security solutions
-in their applications.
-
-## Goals
-
-The goals of this implementation of the getdns API are:
-
-* Provide an open source implementation, in C, of the formally described getdns API by getdns API team at
-* Initial support for FreeBSD, OSX, Linux (CentOS/RHEL, Ubuntu) via functional "configure" script
-* Initial support for Windows 8.1
-* Initial support to include the Android platform
-* Include examples and tests as part of the build
-* Document code using doxygen
-* Leverage github as much as possible for project coordination
-* Coding style/standards follow the BSD coding style
-
-Non-goals (things we will not be doing at least initially) include:
-* implementation of the traditional DNS related routines (gethostbyname, etc.)
-
-## Official and Additional API
-
-Note that this implementation offers additional functionality to supplement that
-in the official getdns API. Some additions are convenient utility functions but other functionality
-is experimental prior to be being recommended for inclusion in the official API.
-The 'Modules' page in the doxygen documentation provides a guide to both the
-official API and the additional functionality.
-
-## Language Bindings
-
-In parallel, the team is actively developing bindings for various languages.
-For more information, visit the
-[wiki](https://github.com/getdnsapi/getdns/wiki/Language-Bindings).
-
-
-Releases
-========
Release numbering follows the [Semantic Versioning](http://semver.org/)
approach. The code is currently under active development.
The following requirements were met as conditions for the present release:
* code compiles cleanly on at least the primary target platforms: OSX, RHEL/CentOS Linux, FreeBSD
-* examples must compile and run clean
-* clearly document supported/unsupported elements of the API
+* examples must compile and run cleanly
+* there must be clear documentation of supported and unsupported elements of the API
+# Building and External Dependencies
-Tickets/Bug Reports
-===================
-Tickets and bug reports should be reported via the [GitHub issues list](https://github.com/getdnsapi/getdns/issues).
+If you are installing from packages, you have to install the library and also the library-devel (or -dev) for your package management system to get the the necessary compile time files.
-Additionally, we have a mailing list at users@getdns.net.
-
-
-Building/External Dependencies
-==============================
-
-External dependencies are linked outside the getdns API build tree (we rely on configure to find them). We would like to keep the dependency tree short.
-Please refer to section for building on Windows for separate dependency and build instructions.
+External dependencies are linked outside the getdns API build tree (we rely on configure to find them). We would like to keep the dependency tree short. Please refer to section for building on Windows for separate dependency and build instructions for that platform.
* [libunbound from NLnet Labs](https://unbound.net/) version 1.4.16 or later.
-* [libidn from the FSF](https://www.gnu.org/software/libidn/) version 1.
+* [libidn from the FSF](https://www.gnu.org/software/libidn/) version 1. (Note that the libidn version means the conversions between A-labels and U-labels may permit conversion of formally invalid labels under IDNA2008.)
* [libssl and libcrypto from the OpenSSL Project](https://www.openssl.org/) version 0.9.7 or later. (Note: version 1.0.1 or later is required for TLS support, version 1.0.2 or later is required for TLS hostname authentication)
-* Doxygen is used to generate documentation, while this is not technically necessary for the build it makes things a lot more pleasant.
+* Doxygen is used to generate documentation; while this is not technically necessary for the build it makes things a lot more pleasant.
-You have to install the library and also the library-devel (or -dev) for your
-package management system to install the compile time files. If you checked
-out our git you need to copy the libtool helper scripts and rebuild configure
-with:
+For example, to build on a recent version of Ubuntu, you would need the following packages:
- # libtoolize -ci (use glibtoolize for OS X, libtool is installed as glibtool to avoid name conflict on OS X)
- # autoreconf -fi
+ # apt install build-essential libunbound-dev libidn11-dev libssl-dev libtool m4 autoconf
+
+If you are building from git, you need to do the following before building:
-If you want to make use of the configuration files that utilise a JSON-like format, you must do
# git submodule update --init
-before building.
+ # libtoolize -ci # (use glibtoolize for OS X, libtool is installed as glibtool to avoid name conflict on OS X)
+ # autoreconf -fi
-If you want to use the getdns_query command line wrapper script for testing or to enable getdns as a daemon then you must build it using
- # make getdns_query
+As well as building the getdns library 2 other tools are installed by default by the above process:
-## Minimal dependencies
+* getdns_query: a command line test script wrapper for getdns
+* stubby: an experimental DNS Privacy enabled client
-* getdns can be configured for stub resolution mode only with the `--enable-stub-only` option to configure. This removed the dependency on `libunbound`.
+Note: If you only want to build stubby, then use the `--with-stubby` option when running 'configure'.
+
+
+## Minimizing dependencies
+
+* getdns can be configured for stub resolution mode only with the `--enable-stub-only` option to configure. This removes the dependency on `libunbound`.
* Currently getdns only offers two helper functions to deal with IDN: `getdns_convert_ulabel_to_alabel` and `getdns_convert_alabel_to_ulabel`. If you do not need these functions, getdns can be configured to compile without them with the `--without-libidn` option to configure.
* When both `--enable-stub-only` and `--without-libidn` options are used, getdns has only one dependency left, which is OpenSSL.
-## Extensions / Event loop dependencies
+## Extensions and Event loop dependencies
-The implementation works with a variety of event loops, each built as a separate shared library. See [the wiki](https://github.com/getdnsapi/getdns/wiki/Asynchronous-Support#wiki-included-event-loop-integrations) for more details.
+The implementation works with a variety of event loops, each built as a separate shared library. See [this Doxygen page](https://getdnsapi.net/doxygen/group__eventloops.html) and [this man page](https://getdnsapi.net/documentation/manpages/#ASYNCHRONOUS USE) for more details.
* [libevent](http://libevent.org). Note: the examples *require* this and should work with either libevent 1.x or 2.x. 2.x is preferred.
* [libuv](https://github.com/joyent/libuv)
* [libev](http://software.schmorp.de/pkg/libev.html)
-NOTE: The current Windows implementation does not support the above.
+## Stubby
+
+* Stubby is an experimental implementation of a DNS Privacy enabled stub resolver than encrypts DNS queries using TLS. It is currently suitable for advanced/technical users - all feedback is welcome!
+* Details on how to use Stubby can be found in the [Stubby Reference Guide](https://getdnsapi.net/blog/dns-privacy-daemon-stubby).
+* Also see [dnsprivacy.org](https://dnsprivacy.org) for more information on DNS Privacy.
## Regression Tests
A suite of regression tests are included with the library, if you make changes or just
want to sanity check things on your system take a look at src/test. You will need
-to install [libcheck](https://libcheck.github.io/check/). The check library is also available from
-many of the package repositories for the more popular operating systems.
+to install [libcheck](https://libcheck.github.io/check/). The check library is also available from many of the package repositories for the more popular operating systems.
-NOTE: The current Windows implementation does not support the above.
+The regression tests do not work with --enable-stub-only.
-## DNSSEC
+## DNSSEC dependencies
For the library to be DNSSEC capable, it needs to know the root trust anchor.
The library will try to load the root trust anchor from
@@ -167,34 +139,66 @@ execute the following steps as root:
# mkdir -p /etc/unbound
# unbound-anchor -a /etc/unbound/getdns-root.key
-# Unsupported Features
+Support
+=======
+
+## Mailing lists
+
+We have a [getdns users list](https://getdnsapi.net/mailman/listinfo/users) for this implementation.
+
+The [getdns-api mailing list](https://getdnsapi.net/mailman/listinfo/spec) is a good place to engage in discussions regarding the design of the API.
+
+## Tickets and Bug Reports
+
+Tickets and bug reports should be reported via the [GitHub issues list](https://github.com/getdnsapi/getdns/issues).
+
+Features of this release
+========================
+
+## Goals
+
+The goals of this implementation of the getdns API are:
+
+* Provide an open source implementation, in C, of the formally described getdns API by getdns API team at
+* Support FreeBSD, OSX, Linux (CentOS/RHEL, Ubuntu) via functional "configure" script
+* Support Windows 8.1
+* Include examples and tests as part of the build
+* Document code using doxygen
+* Leverage github as much as possible for project coordination
+* Follow the BSD coding style/standards
+
+Non-goals (things we will not be doing at least initially) include:
+
+* implementation of the traditional DNS related routines (gethostbyname, etc.)
+
+## Language Bindings
+
+In parallel, the team is actively developing bindings for various languages.
+For more information, visit this
+[webpage](https://getdnsapi.net/bindings/).
+
+## Unsupported getDNS Features
The following API calls are documented in getDNS but *not supported* by the implementation at this time:
-* Disabling following of `CNAME`s with `getdns_context_set_follow_redirects()`
* Detecting changes to resolv.conf and hosts
* MDNS, NIS and NetBIOS namespaces (only DNS and LOCALFILES are supported)
-## Non-uniform implementation
+### Minor omissions
The following minor implementation omissions are noted:
Recursive mode does not support:
* TLS as a transport
* Non-zero connection idle timeouts or query pipelining
+* Anything other than query_type and resolution_type in the return_call_reporting extension
Stub mode does not support:
* Non zero idle timeouts for synchronous calls
-* Limit on number of outstanding queries
# Known Issues
-There are a few known issues which we have summarized below - the most recent
-and helpful list is being maintained in the git issues list in the repository.
-Other known issues are being managed in the git repository issue list.
-
-* When doing a synchronous lookup with a context that has outstanding asynchronous lookups, the callbacks for the asynchronous lookups might get called as a side effect of the synchronous lookup.
-
+* None
# Supported Platforms
@@ -203,9 +207,9 @@ The primary platforms targeted are Linux and FreeBSD, other platform are support
* RHEL/CentOS 6.4
* OSX 10.8
* Ubuntu 14.04
-* Microsoft Windows 8.1 (initial support for DNSSEC but no TLS provided for version 0.5.1)
+* Microsoft Windows 8.1
-We intend to add Android and other platforms to the releases as we have time to port it.
+We intend to add Android and other platforms to future releases as we have time to port it.
## Platform Specific Build Reports
@@ -218,11 +222,11 @@ If you're using [FreeBSD](https://www.freebsd.org/), you may install getdns via
If you are using FreeBSD 10 getdns can be intalled via 'pkg install getdns'.
-### CentOS/RHEL 6.5
+### CentOS and RHEL 6.5
-We rely on the most excellent package manager fpm to build the linux packages which
+We rely on the most excellent package manager fpm to build the linux packages, which
means that the packaging platform requires ruby 2.1.0. There are other ways to
-build the packages, this is simplythe one we chose to use.
+build the packages; this is simply the one we chose to use.
# cat /etc/redhat-release
CentOS release 6.5 (Final)
@@ -258,50 +262,48 @@ build the packages, this is simplythe one we chose to use.
create dmg
A self-compiled version of OpenSSL or the version installed via Homebrew is required.
- Note: If using a self-compiled version manual configuration of certificates into /usr/local/etc/openssl/certs is required for TLS authentication to work.
+ Note: If using a self-compiled version, manual configuration of certificates into /usr/local/etc/openssl/certs is required for TLS authentication to work.
#### Homebrew
If you're using [Homebrew](http://brew.sh/), you may run `brew install getdns`. By default, this will only build the core library without any 3rd party event loop support.
-To install the [event loop integration libraries](https://github.com/getdnsapi/getdns/wiki/Asynchronous-Support) that enable support for libevent, libuv, and libev, run: `brew install getdns --with-libevent --with-libuv --with-libev`. All switches are optional.
+To install the [event loop integration libraries](https://getdnsapi.net/doxygen/group__eventloops.html) that enable support for libevent, libuv, and libev, run: `brew install getdns --with-libevent --with-libuv --with-libev`. All switches are optional.
Note that in order to compile the examples, the `--with-libevent` switch is required.
As of the 0.2.0 release, when installing via Homebrew, the trust anchor is expected to be located at `$(brew --prefix)/etc/getdns-root.key`. Additionally, the OpenSSL library installed by Homebrew is linked against. Note that the Homebrew OpenSSL installation clones the Keychain certificates to the default OpenSSL location so TLS certificate authentication should work out of the box.
-
### Microsoft Windows 8.1
-This section has some Windows specific build instructions.
-
-Build tested using the following:
+The build has been tested using the following:
32 bit only Mingw: [Mingw(3.21.0) and Msys 1.0](http://www.mingw.org/) on Windows 8.1
32 bit build on a 64 bit Mingw [Download latest from: http://mingw-w64.org/doku.php/download/mingw-builds and http://msys2.github.io/]. IMPORTANT: Install tested ONLY on the "x86_64" for 64-bit installer of msys2.
-Dependencies:
+#### Dependencies
The following dependencies are
-openssl-1.0.2e
-libidn
+* openssl-1.0.2j
+* libidn
-Instructions to build openssl-1.0.2e:
+Instructions to build openssl-1.0.2j:
Open the mingw32_shell.bat from msys2 in order to build:
If necessary, install the following using pacman:
-pacman -S pkg-config libtool automake
-pacman -S autoconf automake-wrapper
- tar -xvf openssl-1.0.2e.tar
-cd openssl-1.0.2e/
-./Configure --prefix=${LOCALDESTDIR} --openssldir=${LOCALDESTDIR}/etc/ssl --libdir=lib shared zlib-dynamic mingw
-make
-make install
+ pacman -S pkg-config libtool automake
+ pacman -S autoconf automake-wrapper
+
+ tar -xvf openssl-1.0.2j.tar
+ cd openssl-1.0.2j/
+ ./Configure --prefix=${LOCALDESTDIR} --openssldir=${LOCALDESTDIR}/etc/ssl --libdir=lib shared zlib-dynamic mingw
+ make
+ make install
To configure:
./configure --enable-stub-only --with-trust-anchor="c:\\\MinGW\\\msys\\\1.0\\\etc\\\unbound\\\getdns-root.key" --with-ssl= --with-getdns_query
- The trust anchor is also installed by unbound on c:\program Files (X86)\unbound\root.key and can be referenced from there
+ The trust anchor is also installed by unbound on `c:\program Files (X86)\unbound\root.key` and can be referenced from there
or anywhere else that the user chooses to configure it.
After configuring, do a `make` and `make install` to build getdns for Windows.
@@ -315,6 +317,7 @@ To configure:
Contributors
============
+* Claus Assman
* Theogene Bucuti
* Andrew Cathrow, Verisign Labs
* Neil Cook
@@ -322,26 +325,38 @@ Contributors
* Craig Despeaux, Verisign, Inc.
* John Dickinson, Sinodun
* Sara Dickinson, Sinodun
+* Robert Edmonds
* Angelique Finan, Verisign, Inc.
+* Simson Garfinkel
* Daniel Kahn Gillmor
* Neel Goyal, Verisign, Inc.
* Bryan Graham, Verisign, Inc.
+* Robert Groenenberg
+* Jim Hague, Sinodun
* Paul Hoffman
* Scott Hollenbeck, Verising, Inc.
+* Christian Huitema
* Shumon Huque, Verisign Labs
+* Jelte Janssen
+* Guillem Jover
* Shane Kerr
* Anthony Kirby
* Olaf Kolkman, NLnet Labs
* Sanjay Mahurpawar, Verisign, Inc.
* Allison Mankin, Verisign, Inc. - Verisign Labs.
* Sai Mogali, Verisign, Inc.
+* Linus Nordberg
* Benno Overeinder, NLnet Labs
* Joel Purra
+* Tom Pusateri
* Prithvi Ranganath, Verisign, Inc.
+* Hoda Rohani, NLnet Labs
* Rushi Shah, Verisign, Inc.
* Vinay Soni, Verisign, Inc.
* Melinda Shore, No Mountain Software LLC
* Bob Steagall, Verisign, Inc.
+* Andrew Sullivan
+* Ondřej Surý
* Willem Toorop, NLnet Labs
* Gowri Visweswaran, Verisign Labs
* Wouter Wijngaards, NLnet Labs
diff --git a/configure.ac b/configure.ac
index 73150114..2156085e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,8 +36,12 @@ sinclude(./m4/acx_getaddrinfo.m4)
sinclude(./m4/ax_check_compile_flag.m4)
sinclude(./m4/pkg.m4)
-AC_INIT([getdns], [1.1.0], [users@getdnsapi.net], [], [https://getdnsapi.net])
-AC_SUBST(RELEASE_CANDIDATE, [a1])
+AC_INIT([getdns], [1.1.3], [users@getdnsapi.net], [], [https://getdnsapi.net])
+
+# Dont forget to put a dash in front of the release candidate!!!
+# That is how it is done with semantic versioning!
+#
+AC_SUBST(RELEASE_CANDIDATE, [-rc1])
# Set current date from system if not set
AC_ARG_WITH([current-date],
@@ -47,7 +51,7 @@ AC_ARG_WITH([current-date],
[CURRENT_DATE="`date -u +%Y-%m-%dT%H:%M:%SZ`"])
AC_SUBST(GETDNS_VERSION, ["AC_PACKAGE_VERSION$RELEASE_CANDIDATE"])
-AC_SUBST(GETDNS_NUMERIC_VERSION, [0x0100A100])
+AC_SUBST(GETDNS_NUMERIC_VERSION, [0x010102c1])
AC_SUBST(API_VERSION, ["December 2015"])
AC_SUBST(API_NUMERIC_VERSION, [0x07df0c00])
GETDNS_COMPILATION_COMMENT="AC_PACKAGE_NAME $GETDNS_VERSION configured on $CURRENT_DATE for the $API_VERSION version of the API"
@@ -77,10 +81,13 @@ GETDNS_COMPILATION_COMMENT="AC_PACKAGE_NAME $GETDNS_VERSION configured on $CURRE
# getdns-0.5.0 had libversion 4:0:3
# getdns-0.5.1 had libversion 4:1:3 (but should have been getdns-0.6.0)
# getdns-0.9.0 had libversion 5:0:4
-# getdns-1.0.0 will have libversion 5:1:4
-# getdns-1.1.0 will have libversion 6:0:5
+# getdns-1.0.0 had libversion 5:1:4
+# getdns-1.1.0 had libversion 6:0:0
+# getdns-1.1.1 had libversion 6:1:0
+# getdns-1.1.2 has libversion 7:0:1
+# getdns-1.1.3 will have libversion 7:1:1
#
-GETDNS_LIBVERSION=6:0:5
+GETDNS_LIBVERSION=7:1:1
AC_SUBST(GETDNS_COMPILATION_COMMENT)
AC_SUBST(GETDNS_LIBVERSION)
@@ -96,9 +103,17 @@ AC_PROG_CPP
AC_CANONICAL_HOST
CFLAGS="$CFLAGS"
+WPEDANTICFLAG=""
+WNOERRORFLAG=""
AC_PROG_CC_C99
AX_CHECK_COMPILE_FLAG([-xc99],[CFLAGS="$CFLAGS -xc99"],[],[])
AX_CHECK_COMPILE_FLAG([-Wall],[CFLAGS="$CFLAGS -Wall"],[],[])
+AX_CHECK_COMPILE_FLAG([-Wextra],[CFLAGS="$CFLAGS -Wextra"],[],[])
+AX_CHECK_COMPILE_FLAG([-Wpedantic],[WPEDANTICFLAG="-Wpedantic"],[],[])
+AX_CHECK_COMPILE_FLAG([-Wno-error=unused-parameter],[WNOERRORFLAG="-Wno-error=unused-parameter"],[],[])
+AX_CHECK_COMPILE_FLAG([-Wno-unused-parameter],[WNOERRORFLAG="$WNOERRORFLAG -Wno-unused-parameter"],[],[])
+AC_SUBST(WPEDANTICFLAG)
+AC_SUBST(WNOERRORFLAG)
case "$host_os" in
linux* ) CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE"
@@ -141,22 +156,32 @@ fi
])
ACX_ARG_RPATH
-
+AC_ARG_ENABLE(debug-req, AC_HELP_STRING([--enable-debug-req], [Enable request debugging]))
AC_ARG_ENABLE(debug-sched, AC_HELP_STRING([--enable-debug-sched], [Enable scheduling debugging messages]))
AC_ARG_ENABLE(debug-stub, AC_HELP_STRING([--enable-debug-stub], [Enable stub debugging messages]))
+AC_ARG_ENABLE(debug-daemon, AC_HELP_STRING([--enable-debug-daemon], [Enable daemon debugging messages]))
AC_ARG_ENABLE(debug-sec, AC_HELP_STRING([--enable-debug-sec], [Enable dnssec debugging messages]))
AC_ARG_ENABLE(debug-server, AC_HELP_STRING([--enable-debug-server], [Enable server debugging messages]))
-AC_ARG_ENABLE(all-debugging, AC_HELP_STRING([--enable-all-debugging], [Enable scheduling, stub and dnssec debugging]))
+AC_ARG_ENABLE(all-debugging, AC_HELP_STRING([--enable-all-debugging], [Enable all debugging messages]))
case "$enable_all_debugging" in
yes)
+ enable_debug_req=yes
enable_debug_sched=yes
enable_debug_stub=yes
+ enable_debug_daemon=yes
enable_debug_sec=yes
enable_debug_server=yes
;;
no|*)
;;
esac
+case "$enable_debug_req" in
+ yes)
+ AC_DEFINE_UNQUOTED([REQ_DEBUG], [1], [Define this to enable printing of request debugging messages.])
+ ;;
+ no|*)
+ ;;
+esac
case "$enable_debug_sched" in
yes)
AC_DEFINE_UNQUOTED([SCHED_DEBUG], [1], [Define this to enable printing of scheduling debugging messages.])
@@ -171,6 +196,13 @@ case "$enable_debug_stub" in
no|*)
;;
esac
+case "$enable_debug_daemon" in
+ yes)
+ AC_DEFINE_UNQUOTED([DAEMON_DEBUG], [1], [Define this to enable printing of daemon debugging messages.])
+ ;;
+ no|*)
+ ;;
+esac
case "$enable_debug_sec" in
yes)
AC_DEFINE_UNQUOTED([SEC_DEBUG], [1], [Define this to enable printing of dnssec debugging messages.])
@@ -198,6 +230,30 @@ case "$enable_debug_keep_connections_open" in
;;
esac
+
+DEFAULT_EVENTLOOP=select_eventloop
+AC_CHECK_HEADERS([sys/poll.h poll.h sys/resource.h],,, [AC_INCLUDES_DEFAULT])
+AC_ARG_ENABLE(poll-eventloop, AC_HELP_STRING([--disable-poll-eventloop], [Disable default eventloop based on poll (default=enabled if available)]))
+case "$enable_poll_eventloop" in
+ no)
+ ;;
+ yes|*)
+AC_MSG_CHECKING(for poll)
+AC_LINK_IFELSE([AC_LANG_PROGRAM([
+#ifdef HAVE_SYS_POLL_H
+#include
+#else
+#include
+#endif
+], [int rc; rc = poll((struct pollfd *)(0), 0, 0);])], [
+AC_MSG_RESULT(yes)
+AC_DEFINE_UNQUOTED([USE_POLL_DEFAULT_EVENTLOOP], [1], [Define this to enable a default eventloop based on poll().])
+DEFAULT_EVENTLOOP=poll_eventloop
+],[AC_MSG_RESULT(no)])
+ ;;
+esac
+AC_SUBST(DEFAULT_EVENTLOOP)
+
AC_ARG_ENABLE(tcp-fastopen, AC_HELP_STRING([--disable-tcp-fastopen], Disable TCP Fast Open (default=enabled if available)),
enable_tcp_fastopen="$enableval", enable_tcp_fastopen=yes)
if test "x$enable_tcp_fastopen" = xno; then
@@ -246,7 +302,8 @@ else
fi
AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
-AC_CHECK_FUNCS([OPENSSL_config EVP_md5 EVP_sha1 EVP_sha224 EVP_sha256 EVP_sha384 EVP_sha512 FIPS_mode ENGINE_load_cryptodev EVP_PKEY_keygen ECDSA_SIG_get0 EVP_MD_CTX_new EVP_PKEY_base_id HMAC_CTX_new HMAC_CTX_free TLS_client_method])
+AC_CHECK_HEADERS([openssl/bn.h openssl/rsa.h openssl/dsa.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_FUNCS([OPENSSL_config EVP_md5 EVP_sha1 EVP_sha224 EVP_sha256 EVP_sha384 EVP_sha512 FIPS_mode ENGINE_load_cryptodev EVP_PKEY_keygen ECDSA_SIG_get0 EVP_MD_CTX_new EVP_PKEY_base_id HMAC_CTX_new HMAC_CTX_free TLS_client_method DSA_SIG_set0 EVP_dss1 EVP_DigestVerify SSL_CTX_set_min_proto_version])
AC_CHECK_DECLS([SSL_COMP_get_compression_methods,sk_SSL_COMP_pop_free,SSL_CTX_set_ecdh_auto], [], [], [
AC_INCLUDES_DEFAULT
#ifdef HAVE_OPENSSL_ERR_H
@@ -270,6 +327,15 @@ AC_INCLUDES_DEFAULT
fi
+AC_ARG_ENABLE(sha1, AC_HELP_STRING([--disable-sha1], [Disable SHA1 RRSIG support, does not disable nsec3 support]))
+ case "$enable_sha1" in
+ no)
+ ;;
+ yes|*)
+ AC_DEFINE([USE_SHA1], [1], [Define this to enable SHA1 support.])
+ ;;
+esac
+
AC_ARG_ENABLE(sha2, AC_HELP_STRING([--disable-sha2], [Disable SHA256 and SHA512 RRSIG support]))
case "$enable_sha2" in
no)
@@ -433,39 +499,57 @@ case "$enable_dsa" in
;;
*) dnl default
# detect if DSA is supported, and turn it off if not.
- AC_CHECK_FUNC(EVP_dss1, [
+ AC_CHECK_FUNC(DSA_SIG_new, [
AC_DEFINE_UNQUOTED([USE_DSA], [1], [Define this to enable DSA support.])
], [if test "x$enable_dsa" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support DSA and you used --enable-dsa.])
fi ])
;;
esac
-AC_ARG_ENABLE(draft-dnssec-roadblock-avoidance, AC_HELP_STRING([--enable-draft-dnssec-roadblock-avoidance], [Enable experimental dnssec roadblock avoidance]))
-AC_ARG_ENABLE(draft-edns-cookies, AC_HELP_STRING([--enable-draft-edns-cookies], [Enable experimental edns cookies]))
-AC_ARG_ENABLE(all-drafts, AC_HELP_STRING([--enable-all-drafts], [Enable cookies and roadblock avoidance]))
+AC_ARG_ENABLE(ed25519, AC_HELP_STRING([--disable-ed25519], [Disable ED25519 support]))
+use_ed25519="no"
+case "$enable_ed25519" in
+ no)
+ ;;
+ *)
+ if test $USE_NSS = "no" -a $USE_NETTLE = "no"; then
+ AC_CHECK_DECLS([NID_ED25519], [
+ AC_DEFINE_UNQUOTED([USE_ED25519], [1], [Define this to enable ED25519 support.])
+ use_ed25519="yes"
+ ], [ if test "x$enable_ed25519" = "xyes"; then AC_MSG_ERROR([OpenSSL does not support ED25519 and you used --enable-ed25519.])
+ fi ], [AC_INCLUDES_DEFAULT
+#include
+ ])
+ fi
+ ;;
+esac
+
+AC_ARG_ENABLE(all-drafts, AC_HELP_STRING([--enable-all-drafts], [Enables the draft mdns client support]))
case "$enable_all_drafts" in
yes)
- enable_draft_dnssec_roadblock_avoidance=yes
- enable_draft_edns_cookies=yes
+ AC_DEFINE_UNQUOTED([HAVE_MDNS_SUPPORT], [1], [Define this to enable the draft mdns client support.])
;;
no|*)
;;
esac
-case "$enable_draft_dnssec_roadblock_avoidance" in
- yes)
- AC_DEFINE_UNQUOTED([DNSSEC_ROADBLOCK_AVOIDANCE], [1], [Define this to enable the experimental draft dnssec roadblock avoidance.])
+AC_ARG_ENABLE(dnssec-roadblock-avoidance, AC_HELP_STRING([--disable-dnssec-roadblock-avoidance], [Disable dnssec roadblock avoidance]))
+case "$enable_dnssec_roadblock_avoidance" in
+ no)
;;
- no|*)
+ yes|*)
+ AC_DEFINE_UNQUOTED([DNSSEC_ROADBLOCK_AVOIDANCE], [1], [Define this to enable the experimental dnssec roadblock avoidance.])
;;
esac
-case "$enable_draft_edns_cookies" in
- yes)
+
+AC_ARG_ENABLE(edns-cookies, AC_HELP_STRING([--disable-edns-cookies], [Disable edns cookies]))
+case "$enable_edns_cookies" in
+ no)
+ ;;
+ yes|*)
if test "x_$HAVE_SSL" != "x_yes"; then
- AC_MSG_ERROR([edns cookies need openssl libcrypto which is not available, please rerun without --enable-draft-edns-cookies])
+ AC_MSG_ERROR([edns cookies need openssl libcrypto which is not available, please rerun with --disable-edns-cookies])
fi
- AC_DEFINE_UNQUOTED([EDNS_COOKIES], [1], [Define this to enable the experimental draft edns cookies.])
- ;;
- no|*)
+ AC_DEFINE_UNQUOTED([EDNS_COOKIES], [1], [Define this to enable the experimental edns cookies.])
;;
esac
AC_DEFINE_UNQUOTED([EDNS_COOKIE_OPCODE], [10], [The edns cookie option code.])
@@ -474,6 +558,15 @@ AC_DEFINE_UNQUOTED([EDNS_COOKIE_ROLLOVER_TIME], [(24 * 60 * 60)], [How often the
AC_DEFINE_UNQUOTED([MAXIMUM_UPSTREAM_OPTION_SPACE], [3000], [limit for dynamically-generated DNS options])
AC_DEFINE_UNQUOTED([EDNS_PADDING_OPCODE], [12], [The edns padding option code.])
+AC_ARG_ENABLE(draft-mdns-support, AC_HELP_STRING([--enable-draft-mdns-support], [Enable draft mdns client support]))
+case "$enable_draft_mdns_support" in
+ yes)
+ AC_DEFINE_UNQUOTED([HAVE_MDNS_SUPPORT], [1], [Define this to enable the draft mdns client support.])
+ ;;
+ no|*)
+ ;;
+esac
+
my_with_libunbound=1
AC_ARG_ENABLE(stub-only, AC_HELP_STRING([--enable-stub-only], [Restricts resolution modes to STUB (which will be the default mode). Removes the libunbound dependency.]))
case "$enable_stub_only" in
@@ -553,10 +646,16 @@ fi
# Checks for libraries.
found_all_libs=1
+MISSING_DEPS=""
+MISSING_SEP=""
if test $my_with_libidn = 1
then
AC_MSG_NOTICE([Checking for dependency libidn])
- AC_CHECK_LIB([idn], [idna_to_ascii_8z], [], [found_all_libs=0])
+ AC_CHECK_LIB([idn], [idna_to_ascii_8z], [], [
+ MISSING_DEPS="${MISSING_DEPS}${MISSING_SEP}libidn"
+ MISSING_SEP=", "
+ found_all_libs=0
+ ])
fi
AC_ARG_ENABLE(unbound-event-api, AC_HELP_STRING([--disable-unbound-event-api], [Disable usage of libunbounds event API]))
@@ -585,12 +684,16 @@ then
])
fi
AC_CHECK_FUNCS([ub_ctx_set_stub])
- ], [found_all_libs=0])
+ ], [
+ MISSING_DEPS="${MISSING_DEPS}${MISSING_SEP}libunbound"
+ MISSING_SEP=", "
+ found_all_libs=0
+ ])
fi
if test $found_all_libs = 0
then
- AC_MSG_ERROR([One more dependencies is missing])
+ AC_MSG_ERROR([Missing dependencies: $MISSING_DEPS])
fi
AC_PATH_PROG([DOXYGEN], [doxygen])
@@ -607,7 +710,7 @@ AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
-AC_CHECK_TYPE([u_char])
+AC_CHECK_TYPES([u_char])
AC_CHECK_FUNCS([fcntl])
# check ioctlsocket
@@ -692,7 +795,7 @@ AS_IF([test x_$withval = x_no],
[AC_MSG_ERROR([event2/event.h and event.h missing, try without libevent])]
[have_libevent=0],
[AC_INCLUDES_DEFAULT]
- [#if HAVE_U_CHAR == 0
+ [#ifndef HAVE_U_CHAR
typedef unsigned char u_char;
#endif])],
[AC_INCLUDES_DEFAULT])],
@@ -903,6 +1006,26 @@ else
INSTALL_GETDNS_QUERY="install-getdns_query"
UNINSTALL_GETDNS_QUERY="uninstall-getdns_query"
fi
+AC_SUBST(GETDNS_QUERY)
+AC_SUBST(INSTALL_GETDNS_QUERY)
+AC_SUBST(UNINSTALL_GETDNS_QUERY)
+
+AC_ARG_WITH(stubby, AS_HELP_STRING([--with-stubby],
+ [Compile and install stubby, the (stub) resolver daemon]),
+ [], [withval="no"])
+if test x_$withval = x_yes; then
+ STUBBY="stubby"
+ INSTALL_STUBBY="install-stubby"
+ UNINSTALL_STUBBY="uninstall-stubby"
+else
+ STUBBY=""
+ INSTALL_STUBBY=""
+ UNINSTALL_STUBBY=""
+fi
+AC_SUBST(STUBBY)
+AC_SUBST(INSTALL_STUBBY)
+AC_SUBST(UNINSTALL_STUBBY)
+
AC_ARG_WITH(fd-setsize, AS_HELP_STRING([--with-fd-setsize=size],
[Set maximum file descriptor number that can be used by select]),
[], [withval="no"])
@@ -915,22 +1038,33 @@ case "$withval" in
;;
esac
-AC_SUBST(GETDNS_QUERY)
-AC_SUBST(INSTALL_GETDNS_QUERY)
-AC_SUBST(UNINSTALL_GETDNS_QUERY)
-
AC_CONFIG_FILES([Makefile src/Makefile src/version.c src/getdns/getdns.h src/getdns/getdns_extra.h spec/example/Makefile src/test/Makefile src/tools/Makefile doc/Makefile getdns.pc getdns_ext_event.pc])
if [ test -n "$DOXYGEN" ]
then AC_CONFIG_FILES([src/Doxyfile])
fi
+#---- check for pthreads library
+AC_SEARCH_LIBS([pthread_mutex_init],[pthread], [
+ AC_DEFINE([HAVE_PTHREAD], [1], [Have pthreads library])
+ LIBS="-lpthread $LIBS"
+], [AC_MSG_WARN([pthreads not available])])
+
+AC_MSG_CHECKING([whether the C compiler (${CC-cc}) supports the __func__ variable])
+AC_LANG_PUSH(C)
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[char*s=__func__;]],[[]])],
+ [AC_MSG_RESULT([yes])
+ AC_DEFINE(HAVE___FUNC__, [1], [Whether the C compiler support the __func__ variable])],
+ [AC_MSG_RESULT([no])])
+AC_LANG_POP(C)
+
dnl -----
dnl ----- Start of "Things needed for gldns" section
dnl -----
dnl ---------------------------------------------------------------------------
-AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h sys/select.h],,, [AC_INCLUDES_DEFAULT])
+AC_CHECK_HEADERS([stdarg.h stdint.h netinet/in.h arpa/inet.h netdb.h sys/socket.h time.h sys/time.h sys/select.h endian.h],,, [AC_INCLUDES_DEFAULT])
dnl Check the printf-format attribute (if any)
dnl result in HAVE_ATTR_FORMAT.
@@ -1022,8 +1156,6 @@ if test "$ac_cv_func_arc4random" = "no"; then
])
fi
-AC_DEFINE(USE_MINI_EVENT, 1, [Needed for sync stub resolver functions])
-
AC_TYPE_SIGNAL
case `uname` in
@@ -1037,21 +1169,32 @@ esac
AC_SUBST(C99COMPATFLAGS)
AC_DEFINE_UNQUOTED([MAX_CNAME_REFERRALS], [100], [The maximum number of cname referrals.])
+AC_DEFINE_UNQUOTED([DRAFT_RRTYPES], [1], [Define this to enable all rrtypes in gldns.])
AH_BOTTOM([
-#ifdef GETDNS_ON_WINDOWS
-/* On windows it is allowed to increase the FD_SETSIZE
- * (and nescessary to make our custom eventloop work)
- * See: https://support.microsoft.com/en-us/kb/111855
- */
-#ifndef FD_SETSIZE
-#define FD_SETSIZE 1024
+#ifdef HAVE___FUNC__
+#define __FUNC__ __func__
+#else
+#define __FUNC__ __FUNCTION__
#endif
-#define PRIsz "%Iu"
+#ifdef GETDNS_ON_WINDOWS
+ /* On windows it is allowed to increase the FD_SETSIZE
+ * (and nescessary to make our custom eventloop work)
+ * See: https://support.microsoft.com/en-us/kb/111855
+ */
+# ifndef FD_SETSIZE
+# define FD_SETSIZE 1024
+# endif
+# define PRIsz "%Iu"
+
+ /* Windows wants us to use _strdup instead of strdup */
+# ifndef strdup
+# define strdup _strdup
+# endif
#else
-#define PRIsz "%zu"
+# define PRIsz "%zu"
#endif
#include
@@ -1088,8 +1231,6 @@ AH_BOTTOM([
#define FD_SET_T
#endif
-
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -1144,6 +1285,12 @@ int inet_pton(int af, const char* src, void* dst);
const char *inet_ntop(int af, const void *src, char *dst, size_t size);
#endif
+#ifdef USE_WINSOCK
+static inline int _gldns_custom_vsnprintf(char *str, size_t size, const char *format, va_list ap)
+{ int r = vsnprintf(str, size, format, ap); return r == -1 ? _vscprintf(format, ap) : r; }
+# define vsnprintf _gldns_custom_vsnprintf
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/doc/Makefile.in b/doc/Makefile.in
index 301175bf..94770c77 100644
--- a/doc/Makefile.in
+++ b/doc/Makefile.in
@@ -77,6 +77,7 @@ uninstall:
clean:
for x in $(MANPAGES3); do rm -f $$($(srcdir)/manpgaltnames $$x); done
+ rm -f tagfile
rm -rf $(DOCDIRS) $(MANPAGES3)
distclean : clean
diff --git a/doc/getdns_address.3.in b/doc/getdns_address.3.in
index 122f2392..561518d9 100644
--- a/doc/getdns_address.3.in
+++ b/doc/getdns_address.3.in
@@ -33,7 +33,7 @@
-- get ip address(es) for a name
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_cancel_callback.3.in b/doc/getdns_cancel_callback.3.in
index 012bd3ef..297e3053 100644
--- a/doc/getdns_cancel_callback.3.in
+++ b/doc/getdns_cancel_callback.3.in
@@ -32,7 +32,7 @@
-- cancel an outstanding asyn getdns request
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_context.3.in b/doc/getdns_context.3.in
index 71ed4b15..6fb089bb 100644
--- a/doc/getdns_context.3.in
+++ b/doc/getdns_context.3.in
@@ -39,7 +39,7 @@
.ad n
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
@@ -141,7 +141,7 @@ in use might have a requirements on this issue. You may need to provide one or
two functions to allow it to function properly. For example before you call
getdns_context_create() you may need to use
the openssl functions CRYPTO_set_id_callback and CRYPTO_set_locking_callback to set up
-asyncronous operation (the application calls these functions once for initialisation).
+asynchronous operation (the application calls these functions once for initialisation).
Openssl 1.0.0 or later uses the CRYPTO_THREADID_set_callback function.
.HP 3
diff --git a/doc/getdns_context_set.3.in b/doc/getdns_context_set.3.in
index 606a653d..b97bc243 100644
--- a/doc/getdns_context_set.3.in
+++ b/doc/getdns_context_set.3.in
@@ -45,7 +45,7 @@
.ad n
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_context_set_context_update_callback.3.in b/doc/getdns_context_set_context_update_callback.3.in
index d85b1b3e..d51b34ff 100644
--- a/doc/getdns_context_set_context_update_callback.3.in
+++ b/doc/getdns_context_set_context_update_callback.3.in
@@ -32,7 +32,7 @@
-- get informed on getdns context updates
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_convert.3.in b/doc/getdns_convert.3.in
index 25614585..fb8fca91 100644
--- a/doc/getdns_convert.3.in
+++ b/doc/getdns_convert.3.in
@@ -34,7 +34,7 @@
-- convert dname between presentation- and wire-format
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_dict.3.in b/doc/getdns_dict.3.in
index d4d9b3b9..2ee2b45c 100644
--- a/doc/getdns_dict.3.in
+++ b/doc/getdns_dict.3.in
@@ -38,7 +38,7 @@
.ad n
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_dict_get.3.in b/doc/getdns_dict_get.3.in
index 956c0523..45c71870 100644
--- a/doc/getdns_dict_get.3.in
+++ b/doc/getdns_dict_get.3.in
@@ -38,7 +38,7 @@
-- get value by name from a getdns dict
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_dict_set.3.in b/doc/getdns_dict_set.3.in
index ee684090..f42e455a 100644
--- a/doc/getdns_dict_set.3.in
+++ b/doc/getdns_dict_set.3.in
@@ -36,7 +36,7 @@
-- set a value by name in a getdns dict
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_display_ip_address.3.in b/doc/getdns_display_ip_address.3.in
index a038f4e9..08ea7da1 100644
--- a/doc/getdns_display_ip_address.3.in
+++ b/doc/getdns_display_ip_address.3.in
@@ -32,7 +32,7 @@
-- convert an getdns ip address to string
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_general.3.in b/doc/getdns_general.3.in
index 9b983d0d..27b25574 100644
--- a/doc/getdns_general.3.in
+++ b/doc/getdns_general.3.in
@@ -33,7 +33,7 @@
-- do a getdns DNS lookup
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_hostname.3.in b/doc/getdns_hostname.3.in
index e45c3620..25f53b39 100644
--- a/doc/getdns_hostname.3.in
+++ b/doc/getdns_hostname.3.in
@@ -33,7 +33,7 @@
-- get hostname by address
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_list.3.in b/doc/getdns_list.3.in
index 2bbd8f3c..47a17272 100644
--- a/doc/getdns_list.3.in
+++ b/doc/getdns_list.3.in
@@ -38,7 +38,7 @@
.ad n
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_list_get.3.in b/doc/getdns_list_get.3.in
index 1749ef08..d58d6851 100644
--- a/doc/getdns_list_get.3.in
+++ b/doc/getdns_list_get.3.in
@@ -38,7 +38,7 @@
-- get a value by index from a getdns list
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_list_set.3.in b/doc/getdns_list_set.3.in
index 301bb882..cbba6959 100644
--- a/doc/getdns_list_set.3.in
+++ b/doc/getdns_list_set.3.in
@@ -36,7 +36,7 @@
-- set a value by index from a getdns list
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_pretty_print_dict.3.in b/doc/getdns_pretty_print_dict.3.in
index 7ab966e3..e3e9f73e 100644
--- a/doc/getdns_pretty_print_dict.3.in
+++ b/doc/getdns_pretty_print_dict.3.in
@@ -32,7 +32,7 @@
-- return a string representation of a getdns dict
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_root_trust_anchor.3.in b/doc/getdns_root_trust_anchor.3.in
index 401cd297..3d16b238 100644
--- a/doc/getdns_root_trust_anchor.3.in
+++ b/doc/getdns_root_trust_anchor.3.in
@@ -32,7 +32,7 @@
-- return the getdns list of default root trust anchors
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_service.3.in b/doc/getdns_service.3.in
index 35f40579..ab03c880 100644
--- a/doc/getdns_service.3.in
+++ b/doc/getdns_service.3.in
@@ -33,7 +33,7 @@
-- getdns lookup of a service
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/getdns_validate_dnssec.3.in b/doc/getdns_validate_dnssec.3.in
index bce70b85..a97ca72e 100644
--- a/doc/getdns_validate_dnssec.3.in
+++ b/doc/getdns_validate_dnssec.3.in
@@ -32,7 +32,7 @@
-- DNSSEC validate a given getdns record
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
#include
diff --git a/doc/libgetdns.3.in b/doc/libgetdns.3.in
index 0c4d2ece..791ed384 100644
--- a/doc/libgetdns.3.in
+++ b/doc/libgetdns.3.in
@@ -32,7 +32,7 @@ libgetdns
-- an implementation of a modern asynchronous DNS API by and for application developers
.SH LIBRARY
-DNS Resolver library (libgetdns, -lgetdns)
+DNS Resolver library (libgetdns, \-lgetdns)
.SH SYNOPSIS
.B libgetdns
@@ -230,7 +230,7 @@ Set to GETDNS_EXTENSION_TRUE to include the DNSSEC status for each DNS record in
.HP 3
"dnssec_return_only_secure" (int)
-Set to GETDNS_EXTENSION_TRUE to cause only records that the API can validate as secure withe DNSSEC to be returned in the
+Set to GETDNS_EXTENSION_TRUE to cause only records that the API can validate as secure with DNSSEC to be returned in the
.I replies_tree
and
.I replies_full lists
diff --git a/project-doc/cachedesign.txt b/project-doc/cachedesign.txt
index fcce2b3d..71606e7c 100644
--- a/project-doc/cachedesign.txt
+++ b/project-doc/cachedesign.txt
@@ -13,10 +13,10 @@ Recursive Resolver Cache
Caching is arguably an important feature for most recursive resolvers.
In this case we are not intending a replacement for the fully
functional recursive resolvers already available (BIND, Unbound, etc.)
-so we shoudl limit a cache implementation to behaviors important to
+so we should limit a cache implementation to behaviors important to
proper operation of a recursive resolver.
-DNSSEC validation can potentially triggers more queries than a simple
+DNSSEC validation can potentially trigger more queries than a simple
request for a A RR so I think it makes sense to cache root and TLD
data. Once we have gone that far it isn't much of a reach to cache
at each layer in the hierarchy (depth will not increase the coding
diff --git a/project-doc/release-procedure.txt b/project-doc/release-procedure.txt
index 6ffe4749..3222a85b 100644
--- a/project-doc/release-procedure.txt
+++ b/project-doc/release-procedure.txt
@@ -1,168 +1,93 @@
-High level release procedure that we follow to make a formal release for the
-getdns API project. This is a recipe - if you have a better way to do it then
-update this document and share it with us.
+High level release procedure for formal release for the getdns API project.
-- code freeze
- confirm with core team that all commits are in, from this point forward
- only bug fixes should be committed to the release branch, once the release
- is cut nothing should be committed to the release branch (make a new release)
+1) Git branching for a release
+ -- Confirm with core team (preferably via email) that all commits to be included
+ in the release are in the develop branch. Development for the next release can
+ continue on develop.
+ -- Create a release branch. We use the pattern "release/v1.0.0-b3" for naming
+ release branches. This branch is used for testing
+ and bug fixing while preparing the release (which can take several days
+ if there are un-foreseen issues). Note that from this point forward _only_
+ bug fixes for this release should be committed to the release branch.
+ -- Once the release is published there should be no further commits on that
+ release branch.
-- create a release branch
- in git repository named for the release, e.g. "v0.1.2"
- we do this because folks may want to continue to work in the master branch
- and be free to commit changes without injuring the release process. Since
- building and testing binaries for a release takes a few days we don't want to
- force changes to queue up.
+2) Prepare the release
+ -- Clone the upstream to a _new_ local directory. (Do NOT re-use and
+ existing working copy as this can lead to issues).
- One might argue that a release can be cut more quickly, however there are
- inevitably little tweaks that need to be made that get uncovered as a result
- of the binary builds - these tweaks need to be included in the souces for
- this release so building the source tarball can't be done until all of the
- binaries have been built and tested.
+ # git clone -b v1.0.0-b3 https://github.com/getdnsapi/getdns.git getdns-1.0.0-b3
-- clone repo release branch to a clean local repo
- this should be a brand spanking new directory - don't try to shortcut it and
- use a working directory with lots of cruft - crap will find its way into the
- release and embarass you:
+ -- Update several files to reflect release number/date
+ ./README.md
+ ./ChangeLog
+ ./configure.ac
+ - Check and change the values for:
+ - AC_INIT
+ - RELEASE_CANDIDATE
+ - GETDNS_NUMERIC_VERSION
+ - API_VERSION and API_NUMERUC_VERSION
+ - read the section "Library version" and update GETDNS_LIBVERSION carefully!
- # git clone -b v0.1.2 https://github.com/getdnsapi/getdns.git getdns-0.1.2
+ # autoreconf -fi
-- update files to reflect release number/date
- ./README.md
- ./ChangeLog
- ./configure.ac (AC_INIT)
- ./src/Makefile.in (-version-info, follow libtool guidelines)
+ Commit these changes to the release branch
- # make clean
- # autoreconf
+ # git commit -a -m "release number and date updates"
+ # git push
- commit these changes to the release branch
+3) Test
+ The unit and tpkg tests should be run on all the supported platforms. They must all
+ be able to fulfil all requirements. So they must have libidn, libev, libuv, libevent,
+ latest libunbound, latest openssl (at least 1.0.2) latest clang compiler
+ (for static analysis), latest valgrind. The tests can be run using:
- # git commit -a -m "release number and date updates"
- # git push
+ # ${GETDNS_SRCDIR}/src/test/tpkg/run-all.sh
-- prepare to build binaries for each target platform
- you need to remove libs and headers that might be lingering from previous builds
- to avoid accidentally including the wrong headers or linking the wrong libs
+ and evaluating the results.
- - create clean local repo
-
-- build source distribution tar
+4) Build and sign source distribution tarball
+ # rm -fr *
+ # git reset --hard
+ # git submodule update --init
+ # autoreconf -fi
+ # libtoolize -ci
# ./configure
- # make dist
- # openssl sha1 getdns-0.1.2.tar.gz > getdns-0.1.2.tar.gz.sha1
- # openssl md5 getdns-0.1.2.tar.gz > getdns-0.1.2.tar.gz.md5
- # gpg --armor --detach-sig --default-key gwiley@verisign.com getdns-0.1.2.tar.gz
+ # make pub
- - test the resulting tar by building it and running the regression tests
+ The resulting tarball must be built, installed and tested on all the supported
+ platforms. Be sure to use a user that was NOT used for the build, this will uncover
+ any issues related to absolute paths in the build
-- build CentOS binary
- # tar -xzvf getdns-0.1.2.tar.gz
- # cd getdns-0.1.2
- # ./configure --with-libevent --prefix=$HOME/build
- # make
- # make install
- # cd ~/build
- - fix the libdir path in the *.la files to point to /usr/local/lib
- - fix the dependency_libs entry in the *.la files to point to /usr/local/lib
- # fpm -x "*.la" -a native -s dir --rpm-sign -t rpm -n getdns -v 0.1.2 -d "unbound" -d "ldns" -d "libevent" -d "libidn" --prefix /usr/local --vendor "Verisign Inc., NLnet Labs" --license "BSD New" --url "http://www.getdnsapi.net" --description "Modern asynchronous API to the DNS" .
- - make sure your signing key is in the keyring on the build machine
- - contents of ~/.rpmmacros
- %_signature gpg
- %_gpg_path /root/.gnupg
- %_gpg_name A6B73532
- %_gpgbin /usr/bin/gpg
+5) Fix any problems
+ -- If a build breaks or an install fails then commit fixes to the release branch.
+ Then re-run steps 3 and 4 for all supported platforms using the new code.
- - name the rpm and checksum files something like this:
- getdns-0.1.3-1.CentOS_6_5.x86_64.rpm
- getdns-0.1.3-1.CentOS_6_5.x86_64.rpm.sha1
- getdns-0.1.3-1.CentOS_6_5.x86_64.rpm.md5
- - check the signature
- - install
- - test
+6) Merge branch changes back into master/develop
+ -- If this is a production release - then the release branch must be merged into master
+ Sign the merge tag if possible.
+ -- Now the release is ready, all the relevant commits on the release branch
+ should also be merged back into develop.
-- build OSX binary disk image
+7) Create the tarball
+ # make clean
+ # make pub
+ This generates getdns-1.0.0-b3.tar.gz + checksums + signatures.
- - build code (no additional libraries, note that regression tests will not build)
- if you are building a simple binary tar then something like this works
- # ./configure --prefix=/Users/gwiley/getdnsox/export
- # make
- # make install
- # tar -C /Users/gwiley/getdnsosx/export -cvf getdns-0.1.2.tar *
+8) Upload source tarball and checksums and signatures to the getdnsapi.net site
- - build code (with libevent)
- # ./configure --with-libevent2
+ # scp getdns-1.0.0-b3.tar.gz* getdnsapi.net:/usr/local/www/apache24/data/dist
- - run regression tests and verify that alls well
+9) Create and push signed tags to github
- if you have do do anything even mildly interesting to get the build or install to
- work then we either have to add it to the README.md or, preferably, fix it
- and update the branch
+ # git -s v1.0.0-b3
+ # git push --tags
- Be careful about tool sets loaded on your build hosts. You may have 'solved'
- problems while you are working that mask issues with the build for more typical
- users - this is why we want to build on hosts that are representative of
- our users.
+10) Update getdnsapi.net web site
+ - Create an entry the the 'Checksum' page using the content of ChangeLog
+ - Create a new 'News' entry
-- install on each target platform
- - make sure and use a user that was NOT used for the build, this will uncover
- any silliness related to absolute paths in the build
-
-- if a build breaks or an install fails then commit fixes to the relase branch
- - rebuild EVERY binary using the changed release branch
-
-- merge branch changes back into master
-
-- once all binaries are built and tested clean, create source tar ball
- and the actual package for each platform
-
- you may need to run this as root to permit the chown
- # make clean
- # make dist
- generates getdns-0.1.2.tar.gz
-
-- sign each binary/source tar using one or more developers keys
- - make sure that the keys you use to sign the release are also up to date
- on the getdnsapi.net site
-
-- generate checksums for each binary/source tar
-
-- upload source and binaries to the getdnsapi.net site
-
-- create a release in the github repository
- - from the main repo choose 'releases'
- - choose 'Draft a new release'
- - use tag v0.x.y to match the branch being released
- - for a release name use v0.x.y
- - for description cut/paste the ChangeLog entry
- - check the 'pre-release' checkbox (unless this is a production release)
-
-- update getdnsapi.net web site
- - push binaries to getdnsapi.net
- /usr/local/www/apache24/data/dist
- - news entry for the release
- /usr/local/www/apache24/data/news.html
- - download links and checksums
- /usr/local/www/apache24/data/frontpage.html
- - rebuild website
- # ./build.sh
-
-- announce message to
- getdns mailing list
- stub-resolvers mailing list
- Verisign internal via the matrix
-
-- update the
+11) Announce the release to the lists (make sure to sign the emails)
+ users@getdnsapi.net, spec@getdnsapi.net and maintainers@nlnetlabs.nl
-List of Build Targets
----------------------
-The naming conventions for each of these build products are specific to the
-platform they target. The result is that the naming seems a little inconsistent,
-however I felt that it is best to follow naming standards for the platform rather
-than try to impose a project specific standard across platforms.
-
-- source tar: getdns-0.1.2.tar.gz
-- OSX binary package: getdns-0.1.2-OSX_10_8.dmg
-- RHEL/CentOS: getdns-0.1.0-1.CentOS_6_5.x86_64.rpm
-- Debian/Ubuntu:
diff --git a/spec/index.html b/spec/index.html
index a0432b4c..6888489f 100644
--- a/spec/index.html
+++ b/spec/index.html
@@ -875,7 +875,7 @@ names:
query_name
(a bindata) is the name that was sent
query_type
(an int) is the type that was queried for
query_to
(a bindata) is the address to which the query was sent
-run_time
(a bindata) is the difference between the time the successful
+run_time/ms
(a bindata) is the difference between the time the successful
query started and ended in milliseconds, represented
as a uint32_t (this does not include time taken for connection set up
or transport fallback)
diff --git a/src/Doxyfile.in b/src/Doxyfile.in
index 2e8b3d63..925dd994 100644
--- a/src/Doxyfile.in
+++ b/src/Doxyfile.in
@@ -1,134 +1,129 @@
-# Doxyfile 1.8.3.1
-# Copyright (c) 2013, Verisign, Inc., NLnet Labs
-# All rights reserved.
-#
-# 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 names of the copyright holders 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 Verisign, Inc. BE LIABLE FOR ANY
-# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+# Doxyfile 1.8.11
# This file describes the settings to be used by the documentation system
# doxygen (www.doxygen.org) for a project.
#
-# All text after a hash (#) is considered a comment and will be ignored.
+# All text after a double hash (##) is considered a comment and is placed in
+# front of the TAG it is preceding.
+#
+# All text after a single hash (#) is considered a comment and will be ignored.
# The format is:
-# TAG = value [value, ...]
-# For lists items can also be appended using:
-# TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ").
+# TAG = value [value, ...]
+# For lists, items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (\" \").
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all
-# text before the first occurrence of this tag. Doxygen uses libiconv (or the
-# iconv built into libc) for the transcoding. See
-# http://www.gnu.org/software/libiconv for the list of possible encodings.
+# that follow. The default is UTF-8 which is also the encoding used for all text
+# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv
+# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv
+# for the list of possible encodings.
+# The default value is: UTF-8.
DOXYFILE_ENCODING = UTF-8
-# The PROJECT_NAME tag is a single word (or sequence of words) that should
-# identify the project. Note that if you do not use Doxywizard you need
-# to put quotes around the project name if it contains spaces.
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by
+# double-quotes, unless you are using Doxywizard) that should identify the
+# project for which the documentation is generated. This name is used in the
+# title of most generated pages and in a few other places.
+# The default value is: My Project.
PROJECT_NAME = "getdns"
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
+# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
+# could be handy for archiving the generated documentation or if some version
+# control system is used.
PROJECT_NUMBER = @PACKAGE_VERSION@
# Using the PROJECT_BRIEF tag one can provide an optional one line description
-# for a project that appears at the top of each page and should give viewer
-# a quick idea about the purpose of the project. Keep the description short.
+# for a project that appears at the top of each page and should give viewer a
+# quick idea about the purpose of the project. Keep the description short.
PROJECT_BRIEF = "An implementation of the getdns API - a modern asynchronous API for fetching DNS data"
-# With the PROJECT_LOGO tag one can specify an logo or icon that is
-# included in the documentation. The maximum height of the logo should not
-# exceed 55 pixels and the maximum width should not exceed 200 pixels.
-# Doxygen will copy the logo to the output directory.
+# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
+# in the documentation. The maximum height of the logo should not exceed 55
+# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
+# the logo to the output directory.
PROJECT_LOGO =
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path
+# into which the generated documentation will be written. If a relative path is
+# entered, it will be relative to the location where doxygen was started. If
+# left blank the current directory will be used.
OUTPUT_DIRECTORY = ../doc
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of
-# source files, where putting all generated files in the same directory would
-# otherwise cause performance problems for the file system.
+# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
+# directories (in 2 levels) under the output directory of each output format and
+# will distribute the generated files over these directories. Enabling this
+# option can be useful when feeding doxygen a huge amount of source files, where
+# putting all generated files in the same directory would otherwise causes
+# performance problems for the file system.
+# The default value is: NO.
CREATE_SUBDIRS = NO
+# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII
+# characters to appear in the names of generated files. If set to NO, non-ASCII
+# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode
+# U+3044.
+# The default value is: NO.
+
+ALLOW_UNICODE_NAMES = NO
+
# The OUTPUT_LANGUAGE tag is used to specify the language in which all
# documentation generated by doxygen is written. Doxygen will use this
# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
-# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
-# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
-# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,
-# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,
+# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),
+# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,
+# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),
+# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,
+# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,
+# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,
+# Ukrainian and Vietnamese.
+# The default value is: English.
OUTPUT_LANGUAGE = English
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
+# If the BRIEF_MEMBER_DESC tag is set to YES, doxygen will include brief member
+# descriptions after the members that are listed in the file and class
+# documentation (similar to Javadoc). Set to NO to disable this.
+# The default value is: YES.
BRIEF_MEMBER_DESC = YES
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# If the REPEAT_BRIEF tag is set to YES, doxygen will prepend the brief
+# description of a member or function before the detailed description
+#
+# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
# brief descriptions will be completely suppressed.
+# The default value is: YES.
REPEAT_BRIEF = YES
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is
-# used as the annotated text. Otherwise, the brief description is used as-is.
-# If left blank, the following values are used ("$name" is automatically
-# replaced with the name of the entity): "The $name class" "The $name widget"
-# "The $name file" "is" "provides" "specifies" "contains"
-# "represents" "a" "an" "the"
+# This tag implements a quasi-intelligent brief description abbreviator that is
+# used to form the text in various listings. Each string in this list, if found
+# as the leading text of the brief description, will be stripped from the text
+# and the result, after processing the whole list, is used as the annotated
+# text. Otherwise, the brief description is used as-is. If left blank, the
+# following values are used ($name is automatically replaced with the name of
+# the entity):The $name class, The $name widget, The $name file, is, provides,
+# specifies, contains, represents, a, an and the.
ABBREVIATE_BRIEF =
# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
+# doxygen will generate a detailed section even if there is only a brief
# description.
+# The default value is: NO.
ALWAYS_DETAILED_SEC = YES
@@ -136,247 +131,276 @@ ALWAYS_DETAILED_SEC = YES
# inherited members of a class in the documentation of that class as if those
# members were ordinary class members. Constructors, destructors and assignment
# operators of the base classes will not be shown.
+# The default value is: NO.
INLINE_INHERITED_MEMB = NO
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
+# If the FULL_PATH_NAMES tag is set to YES, doxygen will prepend the full path
+# before files name in the file list and in the header files. If set to NO the
+# shortest path that makes the file name unique will be used
+# The default value is: YES.
FULL_PATH_NAMES = NO
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip. Note that you specify absolute paths here, but also
-# relative paths, which will be relative from the directory where doxygen is
-# started.
+# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.
+# Stripping is only done if one of the specified strings matches the left-hand
+# part of the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the path to
+# strip.
+#
+# Note that you can specify absolute paths here, but also relative paths, which
+# will be relative from the directory where doxygen is started.
+# This tag requires that the tag FULL_PATH_NAMES is set to YES.
STRIP_FROM_PATH =
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
+# path mentioned in the documentation of a class, which tells the reader which
+# header file to include in order to use a class. If left blank only the name of
+# the header file containing the class definition is used. Otherwise one should
+# specify the list of include paths that are normally passed to the compiler
+# using the -I flag.
STRIP_FROM_INC_PATH =
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful if your file system
-# doesn't support long names like on DOS, Mac, or CD-ROM.
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
+# less readable) file names. This can be useful is your file systems doesn't
+# support long names like on DOS, Mac, or CD-ROM.
+# The default value is: NO.
SHORT_NAMES = NO
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like regular Qt-style comments
-# (thus requiring an explicit @brief command for a brief description.)
+# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the
+# first line (until the first dot) of a Javadoc-style comment as the brief
+# description. If set to NO, the Javadoc-style will behave just like regular Qt-
+# style comments (thus requiring an explicit @brief command for a brief
+# description.)
+# The default value is: NO.
JAVADOC_AUTOBRIEF = NO
-# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
-# interpret the first line (until the first dot) of a Qt-style
-# comment as the brief description. If set to NO, the comments
-# will behave just like regular Qt-style comments (thus requiring
-# an explicit \brief command for a brief description.)
+# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first
+# line (until the first dot) of a Qt-style comment as the brief description. If
+# set to NO, the Qt-style will behave just like regular Qt-style comments (thus
+# requiring an explicit \brief command for a brief description.)
+# The default value is: NO.
QT_AUTOBRIEF = NO
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a
+# multi-line C++ special comment block (i.e. a block of //! or /// comments) as
+# a brief description. This used to be the default behavior. The new default is
+# to treat a multi-line C++ comment block as a detailed description. Set this
+# tag to YES if you prefer the old behavior instead.
+#
+# Note that setting this tag to YES also means that rational rose comments are
+# not recognized any more.
+# The default value is: NO.
MULTILINE_CPP_IS_BRIEF = NO
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
+# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the
+# documentation from any documented member that it re-implements.
+# The default value is: YES.
INHERIT_DOCS = YES
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
-# a new page for each member. If set to NO, the documentation of a member will
-# be part of the file/class/namespace that contains it.
+# If the SEPARATE_MEMBER_PAGES tag is set to YES then doxygen will produce a new
+# page for each member. If set to NO, the documentation of a member will be part
+# of the file/class/namespace that contains it.
+# The default value is: NO.
SEPARATE_MEMBER_PAGES = NO
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
+# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen
+# uses this value to replace tabs by spaces in code fragments.
+# Minimum value: 1, maximum value: 16, default value: 4.
TAB_SIZE = 4
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
+# This tag can be used to specify a number of aliases that act as commands in
+# the documentation. An alias has the form:
+# name=value
+# For example adding
+# "sideeffect=@par Side Effects:\n"
+# will allow you to put the command \sideeffect (or @sideeffect) in the
+# documentation, which will result in a user-defined paragraph with heading
+# "Side Effects:". You can put \n's in the value part of an alias to insert
+# newlines.
ALIASES =
# This tag can be used to specify a number of word-keyword mappings (TCL only).
-# A mapping has the form "name=value". For example adding
-# "class=itcl::class" will allow you to use the command class in the
-# itcl::class meaning.
+# A mapping has the form "name=value". For example adding "class=itcl::class"
+# will allow you to use the command class in the itcl::class meaning.
TCL_SUBST =
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
-# sources only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources
+# only. Doxygen will then generate output that is more tailored for C. For
+# instance, some of the names that are used will be different. The list of all
+# members will be omitted, etc.
+# The default value is: NO.
OPTIMIZE_OUTPUT_FOR_C = YES
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
-# sources only. Doxygen will then generate output that is more tailored for
-# Java. For instance, namespaces will be presented as packages, qualified
-# scopes will look different, etc.
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or
+# Python sources only. Doxygen will then generate output that is more tailored
+# for that language. For instance, namespaces will be presented as packages,
+# qualified scopes will look different, etc.
+# The default value is: NO.
OPTIMIZE_OUTPUT_JAVA = NO
# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
-# sources only. Doxygen will then generate output that is more tailored for
-# Fortran.
+# sources. Doxygen will then generate output that is tailored for Fortran.
+# The default value is: NO.
OPTIMIZE_FOR_FORTRAN = NO
# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
-# sources. Doxygen will then generate output that is tailored for
-# VHDL.
+# sources. Doxygen will then generate output that is tailored for VHDL.
+# The default value is: NO.
OPTIMIZE_OUTPUT_VHDL = NO
# Doxygen selects the parser to use depending on the extension of the files it
# parses. With this tag you can assign which parser to use for a given
# extension. Doxygen has a built-in mapping, but you can override or extend it
-# using this tag. The format is ext=language, where ext is a file extension,
-# and language is one of the parsers supported by doxygen: IDL, Java,
-# Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C,
-# C++. For instance to make doxygen treat .inc files as Fortran files (default
-# is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note
-# that for custom extensions you also need to set FILE_PATTERNS otherwise the
-# files are not read by doxygen.
+# using this tag. The format is ext=language, where ext is a file extension, and
+# language is one of the parsers supported by doxygen: IDL, Java, Javascript,
+# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:
+# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:
+# Fortran. In the later case the parser tries to guess whether the code is fixed
+# or free formatted code, this is the default for Fortran type files), VHDL. For
+# instance to make doxygen treat .inc files as Fortran files (default is PHP),
+# and .f files as C (default is Fortran), use: inc=Fortran f=C.
+#
+# Note: For files without extension you can use no_extension as a placeholder.
+#
+# Note that for custom extensions you also need to set FILE_PATTERNS otherwise
+# the files are not read by doxygen.
EXTENSION_MAPPING =
-# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all
-# comments according to the Markdown format, which allows for more readable
+# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments
+# according to the Markdown format, which allows for more readable
# documentation. See http://daringfireball.net/projects/markdown/ for details.
-# The output of markdown processing is further processed by doxygen, so you
-# can mix doxygen, HTML, and XML commands with Markdown formatting.
-# Disable only in case of backward compatibilities issues.
+# The output of markdown processing is further processed by doxygen, so you can
+# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in
+# case of backward compatibilities issues.
+# The default value is: YES.
MARKDOWN_SUPPORT = YES
-# When enabled doxygen tries to link words that correspond to documented classes,
-# or namespaces to their corresponding documentation. Such a link can be
-# prevented in individual cases by by putting a % sign in front of the word or
+# When enabled doxygen tries to link words that correspond to documented
+# classes, or namespaces to their corresponding documentation. Such a link can
+# be prevented in individual cases by putting a % sign in front of the word or
# globally by setting AUTOLINK_SUPPORT to NO.
+# The default value is: YES.
AUTOLINK_SUPPORT = YES
# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
-# to include (a tag file for) the STL sources as input, then you should
-# set this tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also makes the inheritance and collaboration
+# to include (a tag file for) the STL sources as input, then you should set this
+# tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string);
+# versus func(std::string) {}). This also make the inheritance and collaboration
# diagrams that involve STL classes more complete and accurate.
+# The default value is: NO.
BUILTIN_STL_SUPPORT = NO
# If you use Microsoft's C++/CLI language, you should set this option to YES to
# enable parsing support.
+# The default value is: NO.
CPP_CLI_SUPPORT = NO
-# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
-# Doxygen will parse them like normal C++ but will assume all classes use public
-# instead of private inheritance when no explicit protection keyword is present.
+# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:
+# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen
+# will parse them like normal C++ but will assume all classes use public instead
+# of private inheritance when no explicit protection keyword is present.
+# The default value is: NO.
SIP_SUPPORT = NO
# For Microsoft's IDL there are propget and propput attributes to indicate
-# getter and setter methods for a property. Setting this option to YES (the
-# default) will make doxygen replace the get and set methods by a property in
-# the documentation. This will only work if the methods are indeed getting or
-# setting a simple type. If this is not the case, or you want to show the
-# methods anyway, you should set this option to NO.
+# getter and setter methods for a property. Setting this option to YES will make
+# doxygen to replace the get and set methods by a property in the documentation.
+# This will only work if the methods are indeed getting or setting a simple
+# type. If this is not the case, or you want to show the methods anyway, you
+# should set this option to NO.
+# The default value is: YES.
IDL_PROPERTY_SUPPORT = YES
# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
+# tag is set to YES then doxygen will reuse the documentation of the first
# member in the group (if any) for the other members of the group. By default
# all members of a group must be documented explicitly.
+# The default value is: NO.
DISTRIBUTE_GROUP_DOC = NO
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
+# If one adds a struct or class to a group and this option is enabled, then also
+# any nested class or struct is added to the same group. By default this option
+# is disabled and one has to add nested compounds explicitly via \ingroup.
+# The default value is: NO.
+
+GROUP_NESTED_COMPOUNDS = NO
+
+# Set the SUBGROUPING tag to YES to allow class member groups of the same type
+# (for instance a group of public functions) to be put as a subgroup of that
+# type (e.g. under the Public Functions section). Set it to NO to prevent
+# subgrouping. Alternatively, this can be done per class using the
+# \nosubgrouping command.
+# The default value is: YES.
SUBGROUPING = YES
-# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and
-# unions are shown inside the group in which they are included (e.g. using
-# @ingroup) instead of on a separate page (for HTML and Man pages) or
-# section (for LaTeX and RTF).
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions
+# are shown inside the group in which they are included (e.g. using \ingroup)
+# instead of on a separate page (for HTML and Man pages) or section (for LaTeX
+# and RTF).
+#
+# Note that this feature does not work in combination with
+# SEPARATE_MEMBER_PAGES.
+# The default value is: NO.
INLINE_GROUPED_CLASSES = NO
-# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
-# unions with only public data fields will be shown inline in the documentation
-# of the scope in which they are defined (i.e. file, namespace, or group
-# documentation), provided this scope is documented. If set to NO (the default),
-# structs, classes, and unions are shown on a separate page (for HTML and Man
-# pages) or section (for LaTeX and RTF).
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions
+# with only public data fields or simple typedef fields will be shown inline in
+# the documentation of the scope in which they are defined (i.e. file,
+# namespace, or group documentation), provided this scope is documented. If set
+# to NO, structs, classes, and unions are shown on a separate page (for HTML and
+# Man pages) or section (for LaTeX and RTF).
+# The default value is: NO.
INLINE_SIMPLE_STRUCTS = NO
-# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
-# is documented as struct, union, or enum with the name of the typedef. So
+# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or
+# enum is documented as struct, union, or enum with the name of the typedef. So
# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
# with name TypeT. When disabled the typedef will appear as a member of a file,
-# namespace, or class. And the struct will be named TypeS. This can typically
-# be useful for C code in case the coding convention dictates that all compound
+# namespace, or class. And the struct will be named TypeS. This can typically be
+# useful for C code in case the coding convention dictates that all compound
# types are typedef'ed and only the typedef is referenced, never the tag name.
+# The default value is: NO.
TYPEDEF_HIDES_STRUCT = NO
-# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
-# determine which symbols to keep in memory and which to flush to disk.
-# When the cache is full, less often used symbols will be written to disk.
-# For small to medium size projects (<1000 input files) the default value is
-# probably good enough. For larger projects a too small cache size can cause
-# doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penalty.
-# If the system has enough physical memory increasing the cache will improve the
-# performance by keeping more symbols in memory. Note that the value works on
-# a logarithmic scale so increasing the size by one will roughly double the
-# memory usage. The cache size is given by this formula:
-# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols.
-
-SYMBOL_CACHE_SIZE = 0
-
-# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
-# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
-# their name and scope. Since this can be an expensive process and often the
-# same symbol appear multiple times in the code, doxygen keeps a cache of
-# pre-resolved symbols. If the cache is too small doxygen will become slower.
-# If the cache is too large, memory is wasted. The cache size is given by this
-# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols.
+# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This
+# cache is used to resolve symbols given their name and scope. Since this can be
+# an expensive process and often the same symbol appears multiple times in the
+# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small
+# doxygen will become slower. If the cache is too large, memory is wasted. The
+# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range
+# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536
+# symbols. At the end of a run doxygen will report the cache usage and suggest
+# the optimal cache size from a speed point of view.
+# Minimum value: 0, maximum value: 9, default value: 0.
LOOKUP_CACHE_SIZE = 0
@@ -384,351 +408,409 @@ LOOKUP_CACHE_SIZE = 0
# Build related configuration options
#---------------------------------------------------------------------------
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+# If the EXTRACT_ALL tag is set to YES, doxygen will assume all entities in
+# documentation are documented, even if no documentation was available. Private
+# class members and static file members will be hidden unless the
+# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.
+# Note: This will also disable the warnings about undocumented members that are
+# normally produced when WARNINGS is set to YES.
+# The default value is: NO.
EXTRACT_ALL = YES
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
+# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
+# be included in the documentation.
+# The default value is: NO.
EXTRACT_PRIVATE = NO
-# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal
+# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation.
+# The default value is: NO.
EXTRACT_PACKAGE = NO
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
+# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
+# included in the documentation.
+# The default value is: NO.
EXTRACT_STATIC = YES
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
+# locally in source files will be included in the documentation. If set to NO,
+# only classes defined in header files are included. Does not have any effect
+# for Java sources.
+# The default value is: YES.
EXTRACT_LOCAL_CLASSES = YES
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
+# This flag is only useful for Objective-C code. If set to YES, local methods,
+# which are defined in the implementation section but not in the interface are
+# included in the documentation. If set to NO, only methods in the interface are
+# included.
+# The default value is: NO.
EXTRACT_LOCAL_METHODS = NO
# If this flag is set to YES, the members of anonymous namespaces will be
# extracted and appear in the documentation as a namespace called
-# 'anonymous_namespace{file}', where file will be replaced with the base
-# name of the file that contains the anonymous namespace. By default
-# anonymous namespaces are hidden.
+# 'anonymous_namespace{file}', where file will be replaced with the base name of
+# the file that contains the anonymous namespace. By default anonymous namespace
+# are hidden.
+# The default value is: NO.
EXTRACT_ANON_NSPACES = NO
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all
+# undocumented members inside documented classes or files. If set to NO these
+# members will be included in the various overviews, but no documentation
+# section is generated. This option has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
HIDE_UNDOC_MEMBERS = NO
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
+# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy. If set
+# to NO, these classes will be included in the various overviews. This option
+# has no effect if EXTRACT_ALL is enabled.
+# The default value is: NO.
HIDE_UNDOC_CLASSES = NO
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend
+# (class|struct|union) declarations. If set to NO, these declarations will be
+# included in the documentation.
+# The default value is: NO.
HIDE_FRIEND_COMPOUNDS = NO
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
+# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any
+# documentation blocks found inside the body of a function. If set to NO, these
+# blocks will be appended to the function's detailed documentation block.
+# The default value is: NO.
HIDE_IN_BODY_DOCS = NO
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
+# The INTERNAL_DOCS tag determines if documentation that is typed after a
+# \internal command is included. If the tag is set to NO then the documentation
+# will be excluded. Set it to YES to include the internal documentation.
+# The default value is: NO.
INTERNAL_DOCS = NO
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
+# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file
+# names in lower-case letters. If set to YES, upper-case letters are also
# allowed. This is useful if you have classes or files whose names only differ
# in case and if your file system supports case sensitive file names. Windows
# and Mac users are advised to set this option to NO.
+# The default value is: system dependent.
CASE_SENSE_NAMES = YES
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
+# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with
+# their full class and namespace scopes in the documentation. If set to YES, the
+# scope will be hidden.
+# The default value is: NO.
HIDE_SCOPE_NAMES = NO
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
+# If the HIDE_COMPOUND_REFERENCE tag is set to NO (default) then doxygen will
+# append additional text to a page's title, such as Class Reference. If set to
+# YES the compound reference will be hidden.
+# The default value is: NO.
+
+HIDE_COMPOUND_REFERENCE= NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of
+# the files that are included by a file in the documentation of that file.
+# The default value is: YES.
SHOW_INCLUDE_FILES = YES
-# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
-# will list include files with double quotes in the documentation
-# rather than with sharp brackets.
+# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each
+# grouped member an include statement to the documentation, telling the reader
+# which file to include in order to use the member.
+# The default value is: NO.
+
+SHOW_GROUPED_MEMB_INC = NO
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include
+# files with double quotes in the documentation rather than with sharp brackets.
+# The default value is: NO.
FORCE_LOCAL_INCLUDES = NO
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
+# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the
+# documentation for inline members.
+# The default value is: YES.
INLINE_INFO = YES
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
+# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the
+# (detailed) documentation of file and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order.
+# The default value is: YES.
SORT_MEMBER_DOCS = NO
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
+# descriptions of file, namespace and class members alphabetically by member
+# name. If set to NO, the members will appear in declaration order. Note that
+# this will also influence the order of the classes in the class list.
+# The default value is: NO.
SORT_BRIEF_DOCS = NO
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen
-# will sort the (brief and detailed) documentation of class members so that
-# constructors and destructors are listed first. If set to NO (the default)
-# the constructors will appear in the respective orders defined by
-# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.
-# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO
-# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
+# (brief and detailed) documentation of class members so that constructors and
+# destructors are listed first. If set to NO the constructors will appear in the
+# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.
+# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief
+# member documentation.
+# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting
+# detailed member documentation.
+# The default value is: NO.
SORT_MEMBERS_CTORS_1ST = NO
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
-# hierarchy of group names into alphabetical order. If set to NO (the default)
-# the group names will appear in their defined order.
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
+# of group names into alphabetical order. If set to NO the group names will
+# appear in their defined order.
+# The default value is: NO.
SORT_GROUP_NAMES = NO
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
+# fully-qualified names, including namespaces. If set to NO, the class list will
+# be sorted only by class name, not including the namespace part.
# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
+# Note: This option applies only to the class list, not to the alphabetical
+# list.
+# The default value is: NO.
SORT_BY_SCOPE_NAME = NO
-# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to
-# do proper type resolution of all parameters of a function it will reject a
-# match between the prototype and the implementation of a member function even
-# if there is only one candidate or it is obvious which candidate to choose
-# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen
-# will still accept a match between prototype and implementation in such cases.
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper
+# type resolution of all parameters of a function it will reject a match between
+# the prototype and the implementation of a member function even if there is
+# only one candidate or it is obvious which candidate to choose by doing a
+# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still
+# accept a match between prototype and implementation in such cases.
+# The default value is: NO.
STRICT_PROTO_MATCHING = NO
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
+# The GENERATE_TODOLIST tag can be used to enable (YES) or disable (NO) the todo
+# list. This list is created by putting \todo commands in the documentation.
+# The default value is: YES.
GENERATE_TODOLIST = YES
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
+# The GENERATE_TESTLIST tag can be used to enable (YES) or disable (NO) the test
+# list. This list is created by putting \test commands in the documentation.
+# The default value is: YES.
GENERATE_TESTLIST = YES
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
+# The GENERATE_BUGLIST tag can be used to enable (YES) or disable (NO) the bug
+# list. This list is created by putting \bug commands in the documentation.
+# The default value is: YES.
GENERATE_BUGLIST = YES
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or disable (NO)
+# the deprecated list. This list is created by putting \deprecated commands in
+# the documentation.
+# The default value is: YES.
GENERATE_DEPRECATEDLIST= YES
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if section-label ... \endif
-# and \cond section-label ... \endcond blocks.
+# The ENABLED_SECTIONS tag can be used to enable conditional documentation
+# sections, marked by \if ... \endif and \cond
+# ... \endcond blocks.
ENABLED_SECTIONS =
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or macro consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and macros in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the
+# initial value of a variable or macro / define can have for it to appear in the
+# documentation. If the initializer consists of more lines than specified here
+# it will be hidden. Use a value of 0 to hide initializers completely. The
+# appearance of the value of individual variables and macros / defines can be
+# controlled using \showinitializer or \hideinitializer command in the
+# documentation regardless of this setting.
+# Minimum value: 0, maximum value: 10000, default value: 30.
MAX_INITIALIZER_LINES = 30
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at
+# the bottom of the documentation of classes and structs. If set to YES, the
# list will mention the files that were used to generate the documentation.
+# The default value is: YES.
SHOW_USED_FILES = YES
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
-# This will remove the Files entry from the Quick Index and from the
-# Folder Tree View (if specified). The default is YES.
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This
+# will remove the Files entry from the Quick Index and from the Folder Tree View
+# (if specified).
+# The default value is: YES.
SHOW_FILES = YES
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
-# Namespaces page.
-# This will remove the Namespaces entry from the Quick Index
-# and from the Folder Tree View (if specified). The default is YES.
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces
+# page. This will remove the Namespaces entry from the Quick Index and from the
+# Folder Tree View (if specified).
+# The default value is: YES.
SHOW_NAMESPACES = YES
# The FILE_VERSION_FILTER tag can be used to specify a program or script that
# doxygen should invoke to get the current version for each file (typically from
# the version control system). Doxygen will invoke the program by executing (via
-# popen()) the command , where is the value of
-# the FILE_VERSION_FILTER tag, and is the name of an input file
-# provided by doxygen. Whatever the program writes to standard output
-# is used as the file version. See the manual for examples.
+# popen()) the command command input-file, where command is the value of the
+# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided
+# by doxygen. Whatever the program writes to standard output is used as the file
+# version. For an example see the documentation.
FILE_VERSION_FILTER =
# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed
# by doxygen. The layout file controls the global structure of the generated
# output files in an output format independent way. To create the layout file
-# that represents doxygen's defaults, run doxygen with the -l option.
-# You can optionally specify a file name after the option, if omitted
-# DoxygenLayout.xml will be used as the name of the layout file.
+# that represents doxygen's defaults, run doxygen with the -l option. You can
+# optionally specify a file name after the option, if omitted DoxygenLayout.xml
+# will be used as the name of the layout file.
+#
+# Note that if you run doxygen from a directory containing a file called
+# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE
+# tag is left empty.
LAYOUT_FILE =
-# The CITE_BIB_FILES tag can be used to specify one or more bib files
-# containing the references data. This must be a list of .bib files. The
-# .bib extension is automatically appended if omitted. Using this command
-# requires the bibtex tool to be installed. See also
-# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
-# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
-# feature you need bibtex and perl available in the search path. Do not use
-# file names with spaces, bibtex cannot handle them.
+# The CITE_BIB_FILES tag can be used to specify one or more bib files containing
+# the reference definitions. This must be a list of .bib files. The .bib
+# extension is automatically appended if omitted. This requires the bibtex tool
+# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.
+# For LaTeX the style of the bibliography can be controlled using
+# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the
+# search path. See also \cite for info how to create references.
CITE_BIB_FILES =
#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
+# Configuration options related to warning and progress messages
#---------------------------------------------------------------------------
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
+# The QUIET tag can be used to turn on/off the messages that are generated to
+# standard output by doxygen. If QUIET is set to YES this implies that the
+# messages are off.
+# The default value is: NO.
QUIET = NO
# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
+# generated to standard error (stderr) by doxygen. If WARNINGS is set to YES
+# this implies that the warnings are on.
+#
+# Tip: Turn warnings on while writing the documentation.
+# The default value is: YES.
WARNINGS = YES
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
+# If the WARN_IF_UNDOCUMENTED tag is set to YES then doxygen will generate
+# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag
+# will automatically be disabled.
+# The default value is: YES.
WARN_IF_UNDOCUMENTED = YES
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
+# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some parameters
+# in a documented function, or documenting parameters that don't exist or using
+# markup commands wrongly.
+# The default value is: YES.
WARN_IF_DOC_ERROR = YES
-# The WARN_NO_PARAMDOC option can be enabled to get warnings for
-# functions that are documented, but have no documentation for their parameters
-# or return value. If set to NO (the default) doxygen will only warn about
-# wrong or incomplete parameter documentation, but not about the absence of
-# documentation.
+# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that
+# are documented, but have no documentation for their parameters or return
+# value. If set to NO, doxygen will only warn about wrong or incomplete
+# parameter documentation, but not about the absence of documentation.
+# The default value is: NO.
WARN_NO_PARAMDOC = NO
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text. Optionally the format may contain
-# $version, which will be replaced by the version of the file (if it could
-# be obtained via FILE_VERSION_FILTER)
+# If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when
+# a warning is encountered.
+# The default value is: NO.
+
+WARN_AS_ERROR = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that doxygen
+# can produce. The string should contain the $file, $line, and $text tags, which
+# will be replaced by the file and line number from which the warning originated
+# and the warning text. Optionally the format may contain $version, which will
+# be replaced by the version of the file (if it could be obtained via
+# FILE_VERSION_FILTER)
+# The default value is: $file:$line: $text.
WARN_FORMAT = "$file:$line: $text"
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
+# The WARN_LOGFILE tag can be used to specify a file to which warning and error
+# messages should be written. If left blank the output is written to standard
+# error (stderr).
WARN_LOGFILE =
#---------------------------------------------------------------------------
-# configuration options related to the input files
+# Configuration options related to the input files
#---------------------------------------------------------------------------
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
+# The INPUT tag is used to specify the files and/or directories that contain
+# documented source files. You may enter file names like myfile.cpp or
+# directories like /usr/src/myproject. Separate the files or directories with
+# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
+# Note: If this tag is empty the current directory is searched.
INPUT = @srcdir@/getdns/ \
getdns/getdns.h \
getdns/getdns_extra.h \
@srcdir@/../README.md
-# @srcdir@/../spec/example/ \
-# getdns/ \
-# @srcdir@ \
-# @srcdir@/test/ \
-
# This tag can be used to specify the character encoding of the source files
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
-# also the default input encoding. Doxygen uses libiconv (or the iconv built
-# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
-# the list of possible encodings.
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+# libiconv (or the iconv built into libc) for the transcoding. See the libiconv
+# documentation (see: http://www.gnu.org/software/libiconv) for the list of
+# possible encodings.
+# The default value is: UTF-8.
INPUT_ENCODING = UTF-8
# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh
-# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py
-# *.f90 *.f *.for *.vhd *.vhdl
+# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and
+# *.h) to filter out the source-files in the directories.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# read by doxygen.
+#
+# If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp,
+# *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h,
+# *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc,
+# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f, *.for, *.tcl,
+# *.vhd, *.vhdl, *.ucf, *.qsf, *.as and *.js.
FILE_PATTERNS =
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
+# The RECURSIVE tag can be used to specify whether or not subdirectories should
+# be searched for input files as well.
+# The default value is: NO.
RECURSIVE = NO
# The EXCLUDE tag can be used to specify files and/or directories that should be
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
+#
# Note that relative paths are relative to the directory from which doxygen is
# run.
@@ -737,14 +819,16 @@ EXCLUDE = config.h
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
# from the input.
+# The default value is: NO.
EXCLUDE_SYMLINKS = NO
# If the value of the INPUT tag contains directories, you can use the
# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories. Note that the wildcards are matched
-# against the file with absolute path, so to exclude all test directories
-# for example use the pattern */test/*
+# certain files from those directories.
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories for example use the pattern */test/*
EXCLUDE_PATTERNS =
@@ -753,819 +837,1149 @@ EXCLUDE_PATTERNS =
# output. The symbol name can be a fully qualified name, a word, or if the
# wildcard * is used, a substring. Examples: ANamespace, AClass,
# AClass::ANamespace, ANamespace::*Test
+#
+# Note that the wildcards are matched against the file with absolute path, so to
+# exclude all test directories use the pattern */test/*
EXCLUDE_SYMBOLS =
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
+# The EXAMPLE_PATH tag can be used to specify one or more files or directories
+# that contain example code fragments that are included (see the \include
+# command).
EXAMPLE_PATH = example/
# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
+# *.h) to filter out the source-files in the directories. If left blank all
+# files are included.
EXAMPLE_PATTERNS =
# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
+# searched for input files to be used with the \include or \dontinclude commands
+# irrespective of the value of the RECURSIVE tag.
+# The default value is: NO.
EXAMPLE_RECURSIVE = NO
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
+# The IMAGE_PATH tag can be used to specify one or more files or directories
+# that contain images that are to be included in the documentation (see the
+# \image command).
IMAGE_PATH =
# The INPUT_FILTER tag can be used to specify a program that doxygen should
# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command , where
-# is the value of the INPUT_FILTER tag, and is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output.
-# If FILTER_PATTERNS is specified, this tag will be
-# ignored.
+# by executing (via popen()) the command:
+#
+#
+#
+# where is the value of the INPUT_FILTER tag, and is the
+# name of an input file. Doxygen will then use the output that the filter
+# program writes to standard output. If FILTER_PATTERNS is specified, this tag
+# will be ignored.
+#
+# Note that the filter must not add or remove lines; it is applied before the
+# code is scanned, but not when the output code is generated. If lines are added
+# or removed, the anchors will not be placed correctly.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
INPUT_FILTER =
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis.
-# Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match.
-# The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty or if
-# non of the patterns match the file name, INPUT_FILTER is applied.
+# basis. Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match. The filters are a list of the form: pattern=filter
+# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how
+# filters are used. If the FILTER_PATTERNS tag is empty or if none of the
+# patterns match the file name, INPUT_FILTER is applied.
+#
+# Note that for custom extensions or not directly supported extensions you also
+# need to set EXTENSION_MAPPING for the extension otherwise the files are not
+# properly processed by doxygen.
FILTER_PATTERNS =
# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# INPUT_FILTER) will also be used to filter the input files that are used for
+# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).
+# The default value is: NO.
FILTER_SOURCE_FILES = NO
# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file
-# pattern. A pattern will override the setting for FILTER_PATTERN (if any)
-# and it is also possible to disable source filtering for a specific pattern
-# using *.ext= (so without naming a filter). This option only has effect when
-# FILTER_SOURCE_FILES is enabled.
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and
+# it is also possible to disable source filtering for a specific pattern using
+# *.ext= (so without naming a filter).
+# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.
FILTER_SOURCE_PATTERNS =
-# If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that
-# is part of the input, its contents will be placed on the main page (index.html).
-# This can be useful if you have a project on for instance GitHub and want reuse
-# the introduction page also for the doxygen output.
+# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that
+# is part of the input, its contents will be placed on the main page
+# (index.html). This can be useful if you have a project on for instance GitHub
+# and want to reuse the introduction page also for the doxygen output.
USE_MDFILE_AS_MAINPAGE = @srcdir@/../README.md
#---------------------------------------------------------------------------
-# configuration options related to source browsing
+# Configuration options related to source browsing
#---------------------------------------------------------------------------
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will be
+# generated. Documented entities will be cross-referenced with these sources.
+#
+# Note: To get rid of all source code in the generated output, make sure that
+# also VERBATIM_HEADERS is set to NO.
+# The default value is: NO.
SOURCE_BROWSER = YES
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
+# Setting the INLINE_SOURCES tag to YES will include the body of functions,
+# classes and enums directly into the documentation.
+# The default value is: NO.
INLINE_SOURCES = NO
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C, C++ and Fortran comments will always remain visible.
+# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any
+# special comment blocks from generated source code fragments. Normal C, C++ and
+# Fortran comments will always remain visible.
+# The default value is: YES.
STRIP_CODE_COMMENTS = YES
-# If the REFERENCED_BY_RELATION tag is set to YES
-# then for each documented function all documented
-# functions referencing it will be listed.
+# If the REFERENCED_BY_RELATION tag is set to YES then for each documented
+# function all documented functions referencing it will be listed.
+# The default value is: NO.
REFERENCED_BY_RELATION = NO
-# If the REFERENCES_RELATION tag is set to YES
-# then for each documented function all documented entities
-# called/used by that function will be listed.
+# If the REFERENCES_RELATION tag is set to YES then for each documented function
+# all documented entities called/used by that function will be listed.
+# The default value is: NO.
REFERENCES_RELATION = NO
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code.
-# Otherwise they will link to the documentation.
+# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set
+# to YES then the hyperlinks from functions in REFERENCES_RELATION and
+# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will
+# link to the documentation.
+# The default value is: YES.
REFERENCES_LINK_SOURCE = YES
-# If the USE_HTAGS tag is set to YES then the references to source code
-# will point to the HTML generated by the htags(1) tool instead of doxygen
-# built-in source browser. The htags tool is part of GNU's global source
-# tagging system (see http://www.gnu.org/software/global/global.html). You
-# will need version 4.8.6 or higher.
+# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the
+# source code will show a tooltip with additional information such as prototype,
+# brief description and links to the definition and documentation. Since this
+# will make the HTML file larger and loading of large files a bit slower, you
+# can opt to disable this feature.
+# The default value is: YES.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
+
+SOURCE_TOOLTIPS = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code will
+# point to the HTML generated by the htags(1) tool instead of doxygen built-in
+# source browser. The htags tool is part of GNU's global source tagging system
+# (see http://www.gnu.org/software/global/global.html). You will need version
+# 4.8.6 or higher.
+#
+# To use it do the following:
+# - Install the latest version of global
+# - Enable SOURCE_BROWSER and USE_HTAGS in the config file
+# - Make sure the INPUT points to the root of the source tree
+# - Run doxygen as normal
+#
+# Doxygen will invoke htags (and that will in turn invoke gtags), so these
+# tools must be available from the command line (i.e. in the search path).
+#
+# The result: instead of the source browser generated by doxygen, the links to
+# source code will now point to the output of htags.
+# The default value is: NO.
+# This tag requires that the tag SOURCE_BROWSER is set to YES.
USE_HTAGS = NO
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
+# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a
+# verbatim copy of the header file for each class for which an include is
+# specified. Set to NO to disable this.
+# See also: Section \class.
+# The default value is: YES.
VERBATIM_HEADERS = YES
+# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the
+# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the
+# cost of reduced performance. This can be particularly helpful with template
+# rich C++ code for which doxygen's built-in parser lacks the necessary type
+# information.
+# Note: The availability of this option depends on whether or not doxygen was
+# generated with the -Duse-libclang=ON option for CMake.
+# The default value is: NO.
+
+CLANG_ASSISTED_PARSING = NO
+
+# If clang assisted parsing is enabled you can provide the compiler with command
+# line options that you would normally use when invoking the compiler. Note that
+# the include paths will already be set by doxygen for the files and directories
+# specified with INPUT and INCLUDE_PATH.
+# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.
+
+CLANG_OPTIONS =
+
#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
+# Configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all
+# compounds will be generated. Enable this if the project contains a lot of
+# classes, structs, unions or interfaces.
+# The default value is: YES.
ALPHABETICAL_INDEX = YES
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
+# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in
+# which the alphabetical index list will be split.
+# Minimum value: 1, maximum value: 20, default value: 5.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
COLS_IN_ALPHA_INDEX = 5
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
+# In case all classes in a project start with a common prefix, all classes will
+# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag
+# can be used to specify a prefix (or a list of prefixes) that should be ignored
+# while generating the index headers.
+# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.
IGNORE_PREFIX =
#---------------------------------------------------------------------------
-# configuration options related to the HTML output
+# Configuration options related to the HTML output
#---------------------------------------------------------------------------
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
+# If the GENERATE_HTML tag is set to YES, doxygen will generate HTML output
+# The default value is: YES.
GENERATE_HTML = YES
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_OUTPUT = html
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each
+# generated HTML page (for example: .htm, .php, .asp).
+# The default value is: .html.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FILE_EXTENSION = .html
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header. Note that when using a custom header you are responsible
-# for the proper inclusion of any scripts and style sheets that doxygen
-# needs, which is dependent on the configuration options used.
-# It is advised to generate a default header using "doxygen -w html
-# header.html footer.html stylesheet.css YourConfigFile" and then modify
-# that header. Note that the header is subject to change so you typically
-# have to redo this when upgrading to a newer version of doxygen or when
-# changing the value of configuration settings such as GENERATE_TREEVIEW!
+# The HTML_HEADER tag can be used to specify a user-defined HTML header file for
+# each generated HTML page. If the tag is left blank doxygen will generate a
+# standard header.
+#
+# To get valid HTML the header file that includes any scripts and style sheets
+# that doxygen needs, which is dependent on the configuration options used (e.g.
+# the setting GENERATE_TREEVIEW). It is highly recommended to start with a
+# default header using
+# doxygen -w html new_header.html new_footer.html new_stylesheet.css
+# YourConfigFile
+# and then modify the file new_header.html. See also section "Doxygen usage"
+# for information on how to generate the default header that doxygen normally
+# uses.
+# Note: The header is subject to change so you typically have to regenerate the
+# default header when upgrading to a newer version of doxygen. For a description
+# of the possible markers and block names see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_HEADER =
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
+# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each
+# generated HTML page. If the tag is left blank doxygen will generate a standard
+# footer. See HTML_HEADER for more information on how to generate a default
+# footer and what special commands can be used inside the footer. See also
+# section "Doxygen usage" for information on how to generate the default footer
+# that doxygen normally uses.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_FOOTER =
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If left blank doxygen will
-# generate a default style sheet. Note that it is recommended to use
-# HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this
-# tag will in the future become obsolete.
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style
+# sheet that is used by each HTML page. It can be used to fine-tune the look of
+# the HTML output. If left blank doxygen will generate a default style sheet.
+# See also section "Doxygen usage" for information on how to generate the style
+# sheet that doxygen normally uses.
+# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as
+# it is more robust and this tag (HTML_STYLESHEET) will in the future become
+# obsolete.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_STYLESHEET =
-# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional
-# user-defined cascading style sheet that is included after the standard
-# style sheets created by doxygen. Using this option one can overrule
-# certain style aspects. This is preferred over using HTML_STYLESHEET
-# since it does not replace the standard style sheet and is therefor more
-# robust against future updates. Doxygen will copy the style sheet file to
-# the output directory.
+# The HTML_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# cascading style sheets that are included after the standard style sheets
+# created by doxygen. Using this option one can overrule certain style aspects.
+# This is preferred over using HTML_STYLESHEET since it does not replace the
+# standard style sheet and is therefore more robust against future updates.
+# Doxygen will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list). For an example see the documentation.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_STYLESHEET =
# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
# that these files will be copied to the base HTML output directory. Use the
-# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
-# files. In the HTML_STYLESHEET file, use the file name only. Also note that
-# the files will be copied as-is; there are no commands or markers available.
+# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that the
+# files will be copied as-is; there are no commands or markers available.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_EXTRA_FILES =
-# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
-# Doxygen will adjust the colors in the style sheet and background images
-# according to this color. Hue is specified as an angle on a colorwheel,
-# see http://en.wikipedia.org/wiki/Hue for more information.
-# For instance the value 0 represents red, 60 is yellow, 120 is green,
-# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.
-# The allowed range is 0 to 359.
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen
+# will adjust the colors in the style sheet and background images according to
+# this color. Hue is specified as an angle on a colorwheel, see
+# http://en.wikipedia.org/wiki/Hue for more information. For instance the value
+# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300
+# purple, and 360 is red again.
+# Minimum value: 0, maximum value: 359, default value: 220.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE_HUE = 220
-# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of
-# the colors in the HTML output. For a value of 0 the output will use
-# grayscales only. A value of 255 will produce the most vivid colors.
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors
+# in the HTML output. For a value of 0 the output will use grayscales only. A
+# value of 255 will produce the most vivid colors.
+# Minimum value: 0, maximum value: 255, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE_SAT = 100
-# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to
-# the luminance component of the colors in the HTML output. Values below
-# 100 gradually make the output lighter, whereas values above 100 make
-# the output darker. The value divided by 100 is the actual gamma applied,
-# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,
-# and 100 does not change the gamma.
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the
+# luminance component of the colors in the HTML output. Values below 100
+# gradually make the output lighter, whereas values above 100 make the output
+# darker. The value divided by 100 is the actual gamma applied, so 80 represents
+# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not
+# change the gamma.
+# Minimum value: 40, maximum value: 240, default value: 80.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_COLORSTYLE_GAMMA = 80
# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
-# page will contain the date and time when the page was generated. Setting
-# this to NO can help when comparing the output of multiple runs.
+# page will contain the date and time when the page was generated. Setting this
+# to YES can help to show when doxygen was last run and thus if the
+# documentation is up to date.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_TIMESTAMP = YES
# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
# documentation will contain sections that can be hidden and shown after the
# page has loaded.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_DYNAMIC_SECTIONS = NO
-# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
-# entries shown in the various tree structured indices initially; the user
-# can expand and collapse entries dynamically later on. Doxygen will expand
-# the tree to such a level that at most the specified number of entries are
-# visible (unless a fully collapsed tree already exceeds this amount).
-# So setting the number of entries 1 will produce a full collapsed tree by
-# default. 0 is a special value representing an infinite number of entries
-# and will result in a full expanded tree by default.
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries
+# shown in the various tree structured indices initially; the user can expand
+# and collapse entries dynamically later on. Doxygen will expand the tree to
+# such a level that at most the specified number of entries are visible (unless
+# a fully collapsed tree already exceeds this amount). So setting the number of
+# entries 1 will produce a full collapsed tree by default. 0 is a special value
+# representing an infinite number of entries and will result in a full expanded
+# tree by default.
+# Minimum value: 0, maximum value: 9999, default value: 100.
+# This tag requires that the tag GENERATE_HTML is set to YES.
HTML_INDEX_NUM_ENTRIES = 100
-# If the GENERATE_DOCSET tag is set to YES, additional index files
-# will be generated that can be used as input for Apple's Xcode 3
-# integrated development environment, introduced with OSX 10.5 (Leopard).
-# To create a documentation set, doxygen will generate a Makefile in the
-# HTML output directory. Running make will produce the docset in that
-# directory and running "make install" will install the docset in
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
-# it at startup.
-# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
+# If the GENERATE_DOCSET tag is set to YES, additional index files will be
+# generated that can be used as input for Apple's Xcode 3 integrated development
+# environment (see: http://developer.apple.com/tools/xcode/), introduced with
+# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a
+# Makefile in the HTML output directory. Running make will produce the docset in
+# that directory and running make install will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at
+# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html
# for more information.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_DOCSET = NO
-# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
-# feed. A documentation feed provides an umbrella under which multiple
-# documentation sets from a single provider (such as a company or product suite)
-# can be grouped.
+# This tag determines the name of the docset feed. A documentation feed provides
+# an umbrella under which multiple documentation sets from a single provider
+# (such as a company or product suite) can be grouped.
+# The default value is: Doxygen generated docs.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_FEEDNAME = "Doxygen generated docs"
-# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
-# should uniquely identify the documentation set bundle. This should be a
-# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
-# will append .docset to the name.
+# This tag specifies a string that should uniquely identify the documentation
+# set bundle. This should be a reverse domain-name style string, e.g.
+# com.mycompany.MyDocSet. Doxygen will append .docset to the name.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_BUNDLE_ID = org.doxygen.Project
-# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely
-# identify the documentation publisher. This should be a reverse domain-name
-# style string, e.g. com.mycompany.MyDocSet.documentation.
+# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify
+# the documentation publisher. This should be a reverse domain-name style
+# string, e.g. com.mycompany.MyDocSet.documentation.
+# The default value is: org.doxygen.Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
-# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.
+# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.
+# The default value is: Publisher.
+# This tag requires that the tag GENERATE_DOCSET is set to YES.
DOCSET_PUBLISHER_NAME = Publisher
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
-# of the generated HTML documentation.
+# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three
+# additional HTML index files: index.hhp, index.hhc, and index.hhk. The
+# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop
+# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on
+# Windows.
+#
+# The HTML Help Workshop contains a compiler that can convert all HTML output
+# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML
+# files are now used as the Windows 98 help format, and will replace the old
+# Windows help format (.hlp) on all Windows platforms in the future. Compressed
+# HTML files also contain an index, a table of contents, and you can search for
+# words in the documentation. The HTML workshop also contains a viewer for
+# compressed HTML files.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_HTMLHELP = NO
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
+# The CHM_FILE tag can be used to specify the file name of the resulting .chm
+# file. You can add a path in front of the file if the result should not be
# written to the html output directory.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
CHM_FILE =
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
+# The HHC_LOCATION tag can be used to specify the location (absolute path
+# including file name) of the HTML help compiler (hhc.exe). If non-empty,
+# doxygen will try to run the HTML help compiler on the generated index.hhp.
+# The file has to be specified with full path.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
HHC_LOCATION =
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
+# The GENERATE_CHI flag controls if a separate .chi index file is generated
+# (YES) or that it should be included in the master .chm file (NO).
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
GENERATE_CHI = NO
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
-# is used to encode HtmlHelp index (hhk), content (hhc) and project file
-# content.
+# The CHM_INDEX_ENCODING is used to encode HtmlHelp index (hhk), content (hhc)
+# and project file content.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
CHM_INDEX_ENCODING =
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
+# The BINARY_TOC flag controls whether a binary table of contents is generated
+# (YES) or a normal table of contents (NO) in the .chm file. Furthermore it
+# enables the Previous and Next buttons.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
BINARY_TOC = NO
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
+# The TOC_EXPAND flag can be set to YES to add extra items for group members to
+# the table of contents of the HTML help documentation and to the tree view.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTMLHELP is set to YES.
TOC_EXPAND = NO
# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and
-# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated
-# that can be used as input for Qt's qhelpgenerator to generate a
-# Qt Compressed Help (.qch) of the generated HTML documentation.
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that
+# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help
+# (.qch) of the generated HTML documentation.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_QHP = NO
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
-# be used to specify the file name of the resulting .qch file.
-# The path specified is relative to the HTML output folder.
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify
+# the file name of the resulting .qch file. The path specified is relative to
+# the HTML output folder.
+# This tag requires that the tag GENERATE_QHP is set to YES.
QCH_FILE =
-# The QHP_NAMESPACE tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#namespace
+# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help
+# Project output. For more information please see Qt Help Project / Namespace
+# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_NAMESPACE = org.doxygen.Project
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt
+# Help Project output. For more information please see Qt Help Project / Virtual
+# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-
+# folders).
+# The default value is: doc.
+# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_VIRTUAL_FOLDER = doc
-# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to
-# add. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#custom-filters
+# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom
+# filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_NAME =
-# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the
-# custom filter to add. For more information please see
-#
-# Qt Help Project / Custom Filters .
+# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the
+# custom filter to add. For more information please see Qt Help Project / Custom
+# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-
+# filters).
+# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_CUST_FILTER_ATTRS =
# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this
-# project's
-# filter section matches.
-#
-# Qt Help Project / Filter Attributes .
+# project's filter section matches. Qt Help Project / Filter Attributes (see:
+# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).
+# This tag requires that the tag GENERATE_QHP is set to YES.
QHP_SECT_FILTER_ATTRS =
-# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
-# be used to specify the location of Qt's qhelpgenerator.
-# If non-empty doxygen will try to run qhelpgenerator on the generated
-# .qhp file.
+# The QHG_LOCATION tag can be used to specify the location of Qt's
+# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the
+# generated .qhp file.
+# This tag requires that the tag GENERATE_QHP is set to YES.
QHG_LOCATION =
-# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
-# will be generated, which together with the HTML files, form an Eclipse help
-# plugin. To install this plugin and make it available under the help contents
-# menu in Eclipse, the contents of the directory containing the HTML and XML
-# files needs to be copied into the plugins directory of eclipse. The name of
-# the directory within the plugins directory should be the same as
-# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before
-# the help appears.
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be
+# generated, together with the HTML files, they form an Eclipse help plugin. To
+# install this plugin and make it available under the help contents menu in
+# Eclipse, the contents of the directory containing the HTML and XML files needs
+# to be copied into the plugins directory of eclipse. The name of the directory
+# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.
+# After copying Eclipse needs to be restarted before the help appears.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_ECLIPSEHELP = NO
-# A unique identifier for the eclipse help plugin. When installing the plugin
-# the directory name containing the HTML and XML files should also have
-# this name.
+# A unique identifier for the Eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have this
+# name. Each documentation set should have its own identifier.
+# The default value is: org.doxygen.Project.
+# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.
ECLIPSE_DOC_ID = org.doxygen.Project
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)
-# at top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it. Since the tabs have the same information as the
-# navigation tree you can set this option to NO if you already set
-# GENERATE_TREEVIEW to YES.
+# If you want full control over the layout of the generated HTML pages it might
+# be necessary to disable the index and replace it with your own. The
+# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top
+# of each HTML page. A value of NO enables the index and the value YES disables
+# it. Since the tabs in the index contain the same information as the navigation
+# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
DISABLE_INDEX = NO
# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
-# structure should be generated to display hierarchical information.
-# If the tag value is set to YES, a side panel will be generated
-# containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
-# Windows users are probably better off using the HTML help feature.
-# Since the tree basically has the same information as the tab index you
-# could consider to set DISABLE_INDEX to NO when enabling this option.
+# structure should be generated to display hierarchical information. If the tag
+# value is set to YES, a side panel will be generated containing a tree-like
+# index structure (just like the one that is generated for HTML Help). For this
+# to work a browser that supports JavaScript, DHTML, CSS and frames is required
+# (i.e. any modern browser). Windows users are probably better off using the
+# HTML help feature. Via custom style sheets (see HTML_EXTRA_STYLESHEET) one can
+# further fine-tune the look of the index. As an example, the default style
+# sheet generated by doxygen has an example that shows how to put an image at
+# the root of the tree instead of the PROJECT_NAME. Since the tree basically has
+# the same information as the tab index, you could consider setting
+# DISABLE_INDEX to YES when enabling this option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
GENERATE_TREEVIEW = NO
-# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
-# (range [0,1..20]) that doxygen will group on one line in the generated HTML
-# documentation. Note that a value of 0 will completely suppress the enum
-# values from appearing in the overview section.
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that
+# doxygen will group on one line in the generated HTML documentation.
+#
+# Note that a value of 0 will completely suppress the enum values from appearing
+# in the overview section.
+# Minimum value: 0, maximum value: 20, default value: 4.
+# This tag requires that the tag GENERATE_HTML is set to YES.
ENUM_VALUES_PER_LINE = 4
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used
+# to set the initial width (in pixels) of the frame in which the tree is shown.
+# Minimum value: 0, maximum value: 1500, default value: 250.
+# This tag requires that the tag GENERATE_HTML is set to YES.
TREEVIEW_WIDTH = 250
-# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open
-# links to external symbols imported via tag files in a separate window.
+# If the EXT_LINKS_IN_WINDOW option is set to YES, doxygen will open links to
+# external symbols imported via tag files in a separate window.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
EXT_LINKS_IN_WINDOW = NO
-# Use this tag to change the font size of Latex formulas included
-# as images in the HTML documentation. The default is 10. Note that
-# when you change the font size after a successful doxygen run you need
-# to manually remove any form_*.png images from the HTML output directory
-# to force them to be regenerated.
+# Use this tag to change the font size of LaTeX formulas included as images in
+# the HTML documentation. When you change the font size after a successful
+# doxygen run you need to manually remove any form_*.png images from the HTML
+# output directory to force them to be regenerated.
+# Minimum value: 8, maximum value: 50, default value: 10.
+# This tag requires that the tag GENERATE_HTML is set to YES.
FORMULA_FONTSIZE = 10
# Use the FORMULA_TRANPARENT tag to determine whether or not the images
-# generated for formulas are transparent PNGs. Transparent PNGs are
-# not supported properly for IE 6.0, but are supported on all modern browsers.
-# Note that when changing this option you need to delete any form_*.png files
-# in the HTML output before the changes have effect.
+# generated for formulas are transparent PNGs. Transparent PNGs are not
+# supported properly for IE 6.0, but are supported on all modern browsers.
+#
+# Note that when changing this option you need to delete any form_*.png files in
+# the HTML output directory before the changes have effect.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
FORMULA_TRANSPARENT = YES
-# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax
-# (see http://www.mathjax.org) which uses client side Javascript for the
-# rendering instead of using prerendered bitmaps. Use this if you do not
-# have LaTeX installed or if you want to formulas look prettier in the HTML
-# output. When enabled you may also need to install MathJax separately and
-# configure the path to it using the MATHJAX_RELPATH option.
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see
+# http://www.mathjax.org) which uses client side Javascript for the rendering
+# instead of using pre-rendered bitmaps. Use this if you do not have LaTeX
+# installed or if you want to formulas look prettier in the HTML output. When
+# enabled you may also need to install MathJax separately and configure the path
+# to it using the MATHJAX_RELPATH option.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_HTML is set to YES.
USE_MATHJAX = NO
# When MathJax is enabled you can set the default output format to be used for
-# thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and
-# SVG. The default value is HTML-CSS, which is slower, but has the best
-# compatibility.
+# the MathJax output. See the MathJax site (see:
+# http://docs.mathjax.org/en/latest/output.html) for more details.
+# Possible values are: HTML-CSS (which is slower, but has the best
+# compatibility), NativeMML (i.e. MathML) and SVG.
+# The default value is: HTML-CSS.
+# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_FORMAT = HTML-CSS
-# When MathJax is enabled you need to specify the location relative to the
-# HTML output directory using the MATHJAX_RELPATH option. The destination
-# directory should contain the MathJax.js script. For instance, if the mathjax
-# directory is located at the same level as the HTML output directory, then
-# MATHJAX_RELPATH should be ../mathjax. The default value points to
-# the MathJax Content Delivery Network so you can quickly see the result without
-# installing MathJax.
-# However, it is strongly recommended to install a local
-# copy of MathJax from http://www.mathjax.org before deployment.
+# When MathJax is enabled you need to specify the location relative to the HTML
+# output directory using the MATHJAX_RELPATH option. The destination directory
+# should contain the MathJax.js script. For instance, if the mathjax directory
+# is located at the same level as the HTML output directory, then
+# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax
+# Content Delivery Network so you can quickly see the result without installing
+# MathJax. However, it is strongly recommended to install a local copy of
+# MathJax from http://www.mathjax.org before deployment.
+# The default value is: http://cdn.mathjax.org/mathjax/latest.
+# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
-# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension
-# names that should be enabled during MathJax rendering.
+# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax
+# extension names that should be enabled during MathJax rendering. For example
+# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
+# This tag requires that the tag USE_MATHJAX is set to YES.
MATHJAX_EXTENSIONS =
-# When the SEARCHENGINE tag is enabled doxygen will generate a search box
-# for the HTML output. The underlying search engine uses javascript
-# and DHTML and should work on any modern browser. Note that when using
-# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets
-# (GENERATE_DOCSET) there is already a search function so this one should
-# typically be disabled. For large projects the javascript based search engine
-# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces
+# of code that will be used on startup of the MathJax code. See the MathJax site
+# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an
+# example see the documentation.
+# This tag requires that the tag USE_MATHJAX is set to YES.
+
+MATHJAX_CODEFILE =
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for
+# the HTML output. The underlying search engine uses javascript and DHTML and
+# should work on any modern browser. Note that when using HTML help
+# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)
+# there is already a search function so this one should typically be disabled.
+# For large projects the javascript based search engine can be slow, then
+# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to
+# search using the keyboard; to jump to the search box use + S
+# (what the is depends on the OS and browser, but it is typically
+# , /, or both). Inside the search box use the to jump into the search results window, the results can be navigated
+# using the . Press to select an item or to cancel
+# the search. The filter options can be selected when the cursor is inside the
+# search box by pressing +. Also here use the
+# to select a filter and or to activate or cancel the filter
+# option.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_HTML is set to YES.
SEARCHENGINE = YES
# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
-# implemented using a web server instead of a web client using Javascript.
-# There are two flavours of web server based search depending on the
-# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for
-# searching and an index file used by the script. When EXTERNAL_SEARCH is
-# enabled the indexing and searching needs to be provided by external tools.
-# See the manual for details.
+# implemented using a web server instead of a web client using Javascript. There
+# are two flavors of web server based searching depending on the EXTERNAL_SEARCH
+# setting. When disabled, doxygen will generate a PHP script for searching and
+# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing
+# and searching needs to be provided by external tools. See the section
+# "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
SERVER_BASED_SEARCH = NO
-# When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP
+# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP
# script for searching. Instead the search results are written to an XML file
# which needs to be processed by an external indexer. Doxygen will invoke an
-# external search engine pointed to by the SEARCHENGINE_URL option to obtain
-# the search results. Doxygen ships with an example indexer (doxyindexer) and
-# search engine (doxysearch.cgi) which are based on the open source search engine
-# library Xapian. See the manual for configuration details.
+# external search engine pointed to by the SEARCHENGINE_URL option to obtain the
+# search results.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: http://xapian.org/).
+#
+# See the section "External Indexing and Searching" for details.
+# The default value is: NO.
+# This tag requires that the tag SEARCHENGINE is set to YES.
EXTERNAL_SEARCH = NO
# The SEARCHENGINE_URL should point to a search engine hosted by a web server
-# which will returned the search results when EXTERNAL_SEARCH is enabled.
-# Doxygen ships with an example search engine (doxysearch) which is based on
-# the open source search engine library Xapian. See the manual for configuration
-# details.
+# which will return the search results when EXTERNAL_SEARCH is enabled.
+#
+# Doxygen ships with an example indexer (doxyindexer) and search engine
+# (doxysearch.cgi) which are based on the open source search engine library
+# Xapian (see: http://xapian.org/). See the section "External Indexing and
+# Searching" for details.
+# This tag requires that the tag SEARCHENGINE is set to YES.
SEARCHENGINE_URL =
# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed
# search data is written to a file for indexing by an external tool. With the
# SEARCHDATA_FILE tag the name of this file can be specified.
+# The default file is: searchdata.xml.
+# This tag requires that the tag SEARCHENGINE is set to YES.
SEARCHDATA_FILE = searchdata.xml
-# When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the
+# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the
# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is
# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple
# projects and redirect the results back to the right project.
+# This tag requires that the tag SEARCHENGINE is set to YES.
EXTERNAL_SEARCH_ID =
# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen
# projects other than the one defined by this configuration file, but that are
# all added to the same external search index. Each project needs to have a
-# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id
-# of to a relative location where the documentation can be found.
-# The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ...
+# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of
+# to a relative location where the documentation can be found. The format is:
+# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...
+# This tag requires that the tag SEARCHENGINE is set to YES.
EXTRA_SEARCH_MAPPINGS =
#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
+# Configuration options related to the LaTeX output
#---------------------------------------------------------------------------
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
+# If the GENERATE_LATEX tag is set to YES, doxygen will generate LaTeX output.
+# The default value is: YES.
GENERATE_LATEX = YES
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_OUTPUT = latex
# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-# Note that when enabling USE_PDFLATEX this option is only used for
-# generating bitmaps for formulas in the HTML output, but not in the
-# Makefile that is written to the output directory.
+# invoked.
+#
+# Note that when enabling USE_PDFLATEX this option is only used for generating
+# bitmaps for formulas in the HTML output, but not in the Makefile that is
+# written to the output directory.
+# The default file is: latex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_CMD_NAME = latex
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate
+# index for LaTeX.
+# The default file is: makeindex.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
MAKEINDEX_CMD_NAME = makeindex
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
+# If the COMPACT_LATEX tag is set to YES, doxygen generates more compact LaTeX
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
COMPACT_LATEX = NO
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, letter, legal and
-# executive. If left blank a4wide will be used.
+# The PAPER_TYPE tag can be used to set the paper type that is used by the
+# printer.
+# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x
+# 14 inches) and executive (7.25 x 10.5 inches).
+# The default value is: a4.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
PAPER_TYPE = a4
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
+# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names
+# that should be included in the LaTeX output. The package can be specified just
+# by its name or with the correct syntax as to be used with the LaTeX
+# \usepackage command. To get the times font for instance you can specify :
+# EXTRA_PACKAGES=times or EXTRA_PACKAGES={times}
+# To use the option intlimits with the amsmath package you can specify:
+# EXTRA_PACKAGES=[intlimits]{amsmath}
+# If left blank no extra packages will be included.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
EXTRA_PACKAGES =
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the
+# generated LaTeX document. The header should contain everything until the first
+# chapter. If it is left blank doxygen will generate a standard header. See
+# section "Doxygen usage" for information on how to let doxygen write the
+# default header to a separate file.
+#
+# Note: Only use a user-defined header if you know what you are doing! The
+# following commands have a special meaning inside the header: $title,
+# $datetime, $date, $doxygenversion, $projectname, $projectnumber,
+# $projectbrief, $projectlogo. Doxygen will replace $title with the empty
+# string, for the replacement values of the other commands the user is referred
+# to HTML_HEADER.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_HEADER =
-# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for
-# the generated latex document. The footer should contain everything after
-# the last chapter. If it is left blank doxygen will generate a
-# standard footer. Notice: only use this tag if you know what you are doing!
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the
+# generated LaTeX document. The footer should contain everything after the last
+# chapter. If it is left blank doxygen will generate a standard footer. See
+# LATEX_HEADER for more information on how to generate a default footer and what
+# special commands can be used inside the footer.
+#
+# Note: Only use a user-defined footer if you know what you are doing!
+# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_FOOTER =
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
+# The LATEX_EXTRA_STYLESHEET tag can be used to specify additional user-defined
+# LaTeX style sheets that are included after the standard style sheets created
+# by doxygen. Using this option one can overrule certain style aspects. Doxygen
+# will copy the style sheet files to the output directory.
+# Note: The order of the extra style sheet files is of importance (e.g. the last
+# style sheet in the list overrules the setting of the previous ones in the
+# list).
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_STYLESHEET =
+
+# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or
+# other source files which should be copied to the LATEX_OUTPUT output
+# directory. Note that the files will be copied as-is; there are no commands or
+# markers available.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_EXTRA_FILES =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is
+# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will
+# contain links (just like the HTML output) instead of page references. This
+# makes the output suitable for online browsing using a PDF viewer.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
PDF_HYPERLINKS = YES
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
+# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate
+# the PDF file directly from the LaTeX files. Set this option to YES, to get a
# higher quality PDF documentation.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
USE_PDFLATEX = YES
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \batchmode
+# command to the generated LaTeX files. This will instruct LaTeX to keep running
+# if errors occur, instead of asking the user for help. This option is also used
+# when generating formulas in HTML.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_BATCHMODE = NO
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
+# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the
+# index chapters (such as File Index, Compound Index, etc.) in the output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_HIDE_INDICES = NO
-# If LATEX_SOURCE_CODE is set to YES then doxygen will include
-# source code with syntax highlighting in the LaTeX output.
-# Note that which sources are shown also depends on other settings
-# such as SOURCE_BROWSER.
+# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source
+# code with syntax highlighting in the LaTeX output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_SOURCE_CODE = NO
# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
-# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
-# http://en.wikipedia.org/wiki/BibTeX for more info.
+# bibliography, e.g. plainnat, or ieeetr. See
+# http://en.wikipedia.org/wiki/BibTeX and \cite for more info.
+# The default value is: plain.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
LATEX_BIB_STYLE = plain
+# If the LATEX_TIMESTAMP tag is set to YES then the footer of each generated
+# page will contain the date and time when the page was generated. Setting this
+# to NO can help when comparing the output of multiple runs.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_LATEX is set to YES.
+
+LATEX_TIMESTAMP = NO
+
#---------------------------------------------------------------------------
-# configuration options related to the RTF output
+# Configuration options related to the RTF output
#---------------------------------------------------------------------------
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
+# If the GENERATE_RTF tag is set to YES, doxygen will generate RTF output. The
+# RTF output is optimized for Word 97 and may not look too pretty with other RTF
+# readers/editors.
+# The default value is: NO.
GENERATE_RTF = NO
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: rtf.
+# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_OUTPUT = rtf
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
+# If the COMPACT_RTF tag is set to YES, doxygen generates more compact RTF
+# documents. This may be useful for small projects and may help to save some
+# trees in general.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
COMPACT_RTF = NO
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will
+# contain hyperlink fields. The RTF file will contain links (just like the HTML
+# output) instead of page references. This makes the output suitable for online
+# browsing using Word or some other Word compatible readers that support those
+# fields.
+#
+# Note: WordPad (write) and others do not support links.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_HYPERLINKS = NO
-# Load style sheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
+# Load stylesheet definitions from file. Syntax is similar to doxygen's config
+# file, i.e. a series of assignments. You only have to provide replacements,
+# missing definitions are set to their default value.
+#
+# See also section "Doxygen usage" for information on how to generate the
+# default style sheet that doxygen normally uses.
+# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_STYLESHEET_FILE =
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
+# Set optional variables used in the generation of an RTF document. Syntax is
+# similar to doxygen's config file. A template extensions file can be generated
+# using doxygen -e rtf extensionFile.
+# This tag requires that the tag GENERATE_RTF is set to YES.
RTF_EXTENSIONS_FILE =
+# If the RTF_SOURCE_CODE tag is set to YES then doxygen will include source code
+# with syntax highlighting in the RTF output.
+#
+# Note that which sources are shown also depends on other settings such as
+# SOURCE_BROWSER.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_RTF is set to YES.
+
+RTF_SOURCE_CODE = NO
+
#---------------------------------------------------------------------------
-# configuration options related to the man page output
+# Configuration options related to the man page output
#---------------------------------------------------------------------------
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
+# If the GENERATE_MAN tag is set to YES, doxygen will generate man pages for
+# classes and files.
+# The default value is: NO.
GENERATE_MAN = YES
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
+# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it. A directory man3 will be created inside the directory specified by
+# MAN_OUTPUT.
+# The default directory is: man.
+# This tag requires that the tag GENERATE_MAN is set to YES.
MAN_OUTPUT = man
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
+# The MAN_EXTENSION tag determines the extension that is added to the generated
+# man pages. In case the manual section does not start with a number, the number
+# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is
+# optional.
+# The default value is: .3.
+# This tag requires that the tag GENERATE_MAN is set to YES.
MAN_EXTENSION = .3
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
+# The MAN_SUBDIR tag determines the name of the directory created within
+# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+# MAN_EXTENSION with the initial . removed.
+# This tag requires that the tag GENERATE_MAN is set to YES.
+
+MAN_SUBDIR =
+
+# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it
+# will generate one additional man file for each entity documented in the real
+# man page(s). These additional files only source the real man page, but without
+# them the man command would be unable to find the correct page.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_MAN is set to YES.
MAN_LINKS = NO
#---------------------------------------------------------------------------
-# configuration options related to the XML output
+# Configuration options related to the XML output
#---------------------------------------------------------------------------
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
+# If the GENERATE_XML tag is set to YES, doxygen will generate an XML file that
+# captures the structure of the code including all documentation.
+# The default value is: NO.
GENERATE_XML = NO
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
+# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a
+# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of
+# it.
+# The default directory is: xml.
+# This tag requires that the tag GENERATE_XML is set to YES.
XML_OUTPUT = xml
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
+# If the XML_PROGRAMLISTING tag is set to YES, doxygen will dump the program
+# listings (including syntax highlighting and cross-referencing information) to
+# the XML output. Note that enabling this will significantly increase the size
+# of the XML output.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_XML is set to YES.
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
+# Configuration options related to the DOCBOOK output
#---------------------------------------------------------------------------
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
+# If the GENERATE_DOCBOOK tag is set to YES, doxygen will generate Docbook files
+# that can be used to generate PDF.
+# The default value is: NO.
+
+GENERATE_DOCBOOK = NO
+
+# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in
+# front of it.
+# The default directory is: docbook.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_OUTPUT = docbook
+
+# If the DOCBOOK_PROGRAMLISTING tag is set to YES, doxygen will include the
+# program listings (including syntax highlighting and cross-referencing
+# information) to the DOCBOOK output. Note that enabling this will significantly
+# increase the size of the DOCBOOK output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_DOCBOOK is set to YES.
+
+DOCBOOK_PROGRAMLISTING = NO
+
+#---------------------------------------------------------------------------
+# Configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES, doxygen will generate an
+# AutoGen Definitions (see http://autogen.sf.net) file that captures the
+# structure of the code including all documentation. Note that this feature is
+# still experimental and incomplete at the moment.
+# The default value is: NO.
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
+# Configuration options related to the Perl module output
#---------------------------------------------------------------------------
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
+# If the GENERATE_PERLMOD tag is set to YES, doxygen will generate a Perl module
+# file that captures the structure of the code including all documentation.
+#
+# Note that this feature is still experimental and incomplete at the moment.
+# The default value is: NO.
GENERATE_PERLMOD = NO
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
+# If the PERLMOD_LATEX tag is set to YES, doxygen will generate the necessary
+# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI
+# output from the Perl module output.
+# The default value is: NO.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
PERLMOD_LATEX = NO
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader.
-# This is useful
-# if you want to understand what is going on.
-# On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
+# If the PERLMOD_PRETTY tag is set to YES, the Perl module output will be nicely
+# formatted so it can be parsed by a human reader. This is useful if you want to
+# understand what is going on. On the other hand, if this tag is set to NO, the
+# size of the Perl module output will be much smaller and Perl will parse it
+# just the same.
+# The default value is: YES.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
PERLMOD_PRETTY = YES
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
+# The names of the make variables in the generated doxyrules.make file are
+# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful
+# so different doxyrules.make files included by the same Makefile don't
+# overwrite each other's variables.
+# This tag requires that the tag GENERATE_PERLMOD is set to YES.
PERLMOD_MAKEVAR_PREFIX =
@@ -1573,106 +1987,129 @@ PERLMOD_MAKEVAR_PREFIX =
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
+# If the ENABLE_PREPROCESSING tag is set to YES, doxygen will evaluate all
+# C-preprocessor directives found in the sources and include files.
+# The default value is: YES.
ENABLE_PREPROCESSING = YES
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
+# If the MACRO_EXPANSION tag is set to YES, doxygen will expand all macro names
+# in the source code. If set to NO, only conditional compilation will be
+# performed. Macro expansion can be done in a controlled way by setting
+# EXPAND_ONLY_PREDEF to YES.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
MACRO_EXPANSION = NO
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_DEFINED tags.
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
+# the macro expansion is limited to the macros specified with the PREDEFINED and
+# EXPAND_AS_DEFINED tags.
+# The default value is: NO.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
EXPAND_ONLY_PREDEF = NO
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# pointed to by INCLUDE_PATH will be searched when a #include is found.
+# If the SEARCH_INCLUDES tag is set to YES, the include files in the
+# INCLUDE_PATH will be searched if a #include is found.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
SEARCH_INCLUDES = YES
# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
+# contain include files that are not input files but should be processed by the
+# preprocessor.
+# This tag requires that the tag SEARCH_INCLUDES is set to YES.
INCLUDE_PATH =
# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
+# directories. If left blank, the patterns specified with FILE_PATTERNS will be
+# used.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
INCLUDE_FILE_PATTERNS =
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed. To prevent a macro definition from being
-# undefined via #undef or recursively expanded use the := operator
-# instead of the = operator.
+# The PREDEFINED tag can be used to specify one or more macro names that are
+# defined before the preprocessor is started (similar to the -D option of e.g.
+# gcc). The argument of the tag is a list of macros of the form: name or
+# name=definition (no spaces). If the definition and the "=" are omitted, "=1"
+# is assumed. To prevent a macro definition from being undefined via #undef or
+# recursively expanded use the := operator instead of the = operator.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED =
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition that
-# overrules the definition found in the source code.
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
+# tag can be used to specify a list of macro names that should be expanded. The
+# macro definition that is found in the sources will be used. Use the PREDEFINED
+# tag if you want to use a different macro definition that overrules the
+# definition found in the source code.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
EXPAND_AS_DEFINED =
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all references to function-like macros
-# that are alone on a line, have an all uppercase name, and do not end with a
-# semicolon, because these will confuse the parser if not removed.
+# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will
+# remove all references to function-like macros that are alone on a line, have
+# an all uppercase name, and do not end with a semicolon. Such function macros
+# are typically used for boiler-plate code, and will confuse the parser if not
+# removed.
+# The default value is: YES.
+# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
-# Configuration::additions related to external references
+# Configuration options related to external references
#---------------------------------------------------------------------------
-# The TAGFILES option can be used to specify one or more tagfiles. For each
-# tag file the location of the external documentation should be added. The
-# format of a tag file without this location is as follows:
-#
+# The TAGFILES tag can be used to specify one or more tag files. For each tag
+# file the location of the external documentation should be added. The format of
+# a tag file without this location is as follows:
# TAGFILES = file1 file2 ...
# Adding location for the tag files is done as follows:
-#
# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths
-# or URLs. Note that each tag file must have a unique name (where the name does
-# NOT include the path). If a tag file is not located in the directory in which
-# doxygen is run, you must also specify the path to the tagfile here.
+# where loc1 and loc2 can be relative or absolute paths or URLs. See the
+# section "Linking to external documentation" for more information about the use
+# of tag files.
+# Note: Each tag file must have a unique name (where the name does NOT include
+# the path). If a tag file is not located in the directory in which doxygen is
+# run, you must also specify the path to the tagfile here.
TAGFILES =
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create a
+# tag file that is based on the input files it reads. See section "Linking to
+# external documentation" for more information about the usage of tag files.
-GENERATE_TAGFILE =
+GENERATE_TAGFILE = ../doc/tagfile
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
+# If the ALLEXTERNALS tag is set to YES, all external class will be listed in
+# the class index. If set to NO, only the inherited external classes will be
+# listed.
+# The default value is: NO.
ALLEXTERNALS = NO
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
+# If the EXTERNAL_GROUPS tag is set to YES, all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will be
+# listed.
+# The default value is: YES.
EXTERNAL_GROUPS = YES
+# If the EXTERNAL_PAGES tag is set to YES, all external pages will be listed in
+# the related pages index. If set to NO, only the current project's pages will
+# be listed.
+# The default value is: YES.
+
+EXTERNAL_PAGES = YES
+
# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
+# interpreter (i.e. the result of 'which perl').
+# The default file (with absolute path) is: /usr/bin/perl.
PERL_PATH = /usr/bin/perl
@@ -1680,222 +2117,314 @@ PERL_PATH = /usr/bin/perl
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
-# or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option also works with HAVE_DOT disabled, but it is recommended to
-# install and use dot, since it yields more powerful graphs.
+# If the CLASS_DIAGRAMS tag is set to YES, doxygen will generate a class diagram
+# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to
+# NO turns the diagrams off. Note that this option also works with HAVE_DOT
+# disabled, but it is recommended to install and use dot, since it yields more
+# powerful graphs.
+# The default value is: YES.
CLASS_DIAGRAMS = YES
# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see
-# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# command. Doxygen will then run the mscgen tool (see:
+# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the
# documentation. The MSCGEN_PATH tag allows you to specify the directory where
# the mscgen tool resides. If left empty the tool is assumed to be found in the
# default search path.
MSCGEN_PATH =
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
+# You can include diagrams made with dia in doxygen documentation. Doxygen will
+# then run dia to produce the diagram and insert it in the documentation. The
+# DIA_PATH tag allows you to specify the directory where the dia binary resides.
+# If left empty dia is assumed to be found in the default search path.
+
+DIA_PATH =
+
+# If set to YES the inheritance and collaboration graphs will hide inheritance
+# and usage relations if the target is undocumented or is not a class.
+# The default value is: YES.
HIDE_UNDOC_RELATIONS = YES
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
+# available from the path. This tool is part of Graphviz (see:
+# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent
+# Bell Labs. The other options in this section have no effect if this option is
+# set to NO
+# The default value is: YES.
HAVE_DOT = NO
-# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is
-# allowed to run in parallel. When set to 0 (the default) doxygen will
-# base this on the number of processors available in the system. You can set it
-# explicitly to a value larger than 0 to get control over the balance
-# between CPU load and processing speed.
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
+# to run in parallel. When set to 0 doxygen will base this on the number of
+# processors available in the system. You can set it explicitly to a value
+# larger than 0 to get control over the balance between CPU load and processing
+# speed.
+# Minimum value: 0, maximum value: 32, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_NUM_THREADS = 0
-# By default doxygen will use the Helvetica font for all dot files that
-# doxygen generates. When you want a differently looking font you can specify
-# the font name using DOT_FONTNAME. You need to make sure dot is able to find
-# the font, which can be done by putting it in a standard location or by setting
-# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the
-# directory containing the font.
+# When you want a differently looking font in the dot files that doxygen
+# generates you can specify the font name using DOT_FONTNAME. You need to make
+# sure dot is able to find the font, which can be done by putting it in a
+# standard location or by setting the DOTFONTPATH environment variable or by
+# setting DOT_FONTPATH to the directory containing the font.
+# The default value is: Helvetica.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_FONTNAME = Helvetica
-# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
-# The default size is 10pt.
+# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
+# dot graphs.
+# Minimum value: 4, maximum value: 24, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_FONTSIZE = 10
-# By default doxygen will tell dot to use the Helvetica font.
-# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to
-# set the path where dot can find it.
+# By default doxygen will tell dot to use the default font as specified with
+# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set
+# the path where dot can find it using this tag.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_FONTPATH =
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# CLASS_DIAGRAMS tag to NO.
+# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for
+# each documented class showing the direct and indirect inheritance relations.
+# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
CLASS_GRAPH = YES
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
+# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a
+# graph for each documented class showing the direct and indirect implementation
+# dependencies (inheritance, containment, and class references variables) of the
+# class with other documented classes.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
COLLABORATION_GRAPH = YES
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for groups, showing the direct groups dependencies
+# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
+# groups, showing the direct groups dependencies.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
GROUP_GRAPHS = YES
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# If the UML_LOOK tag is set to YES, doxygen will generate inheritance and
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
UML_LOOK = NO
-# If the UML_LOOK tag is enabled, the fields and methods are shown inside
-# the class node. If there are many fields or methods and many nodes the
-# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS
-# threshold limits the number of items for each type to make the size more
-# managable. Set this to 0 for no limit. Note that the threshold may be
-# exceeded by 50% before the limit is enforced.
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside the
+# class node. If there are many fields or methods and many nodes the graph may
+# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the
+# number of items for each type to make the size more manageable. Set this to 0
+# for no limit. Note that the threshold may be exceeded by 50% before the limit
+# is enforced. So when you set the threshold to 10, up to 15 fields may appear,
+# but if the number exceeds 15, the total amount of fields shown is limited to
+# 10.
+# Minimum value: 0, maximum value: 100, default value: 10.
+# This tag requires that the tag HAVE_DOT is set to YES.
UML_LIMIT_NUM_FIELDS = 10
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
+# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and
+# collaboration graphs will show the relations between templates and their
+# instances.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
TEMPLATE_RELATIONS = NO
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
+# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
+# YES then doxygen will generate a graph for each documented file showing the
+# direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
INCLUDE_GRAPH = YES
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
+# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
+# set to YES then doxygen will generate a graph for each documented file showing
+# the direct and indirect include dependencies of the file with other documented
+# files.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
INCLUDED_BY_GRAPH = YES
-# If the CALL_GRAPH and HAVE_DOT options are set to YES then
-# doxygen will generate a call dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable call graphs
-# for selected functions only using the \callgraph command.
+# If the CALL_GRAPH tag is set to YES then doxygen will generate a call
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command. Disabling a call graph can be
+# accomplished by means of the command \hidecallgraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
CALL_GRAPH = NO
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
-# doxygen will generate a caller dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable caller
-# graphs for selected functions only using the \callergraph command.
+# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller
+# dependency graph for every global function or class method.
+#
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command. Disabling a caller graph can be
+# accomplished by means of the command \hidecallergraph.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
CALLER_GRAPH = NO
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will generate a graphical hierarchy of all classes instead of a textual one.
+# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical
+# hierarchy of all classes instead of a textual one.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
GRAPHICAL_HIERARCHY = YES
-# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES
-# then doxygen will show the dependencies a directory has on other directories
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
+# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the
+# dependencies a directory has on other directories in a graphical way. The
+# dependency relations are determined by the #include relations between the
+# files in the directories.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
DIRECTORY_GRAPH = YES
# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are svg, png, jpg, or gif.
-# If left blank png will be used. If you choose svg you need to set
-# HTML_FILE_EXTENSION to xhtml in order to make the SVG files
-# visible in IE 9+ (other browsers do not have this requirement).
+# generated by dot. For an explanation of the image formats see the section
+# output formats in the documentation of the dot tool (Graphviz (see:
+# http://www.graphviz.org/)).
+# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order
+# to make the SVG files visible in IE 9+ (other browsers do not have this
+# requirement).
+# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd,
+# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo,
+# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo,
+# png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and
+# png:gdiplus:gdiplus.
+# The default value is: png.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_IMAGE_FORMAT = png
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
# enable generation of interactive SVG images that allow zooming and panning.
-# Note that this requires a modern browser other than Internet Explorer.
-# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you
-# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files
-# visible. Older versions of IE do not have SVG support.
+#
+# Note that this requires a modern browser other than Internet Explorer. Tested
+# and working are Firefox, Chrome, Safari, and Opera.
+# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make
+# the SVG files visible. Older versions of IE do not have SVG support.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
INTERACTIVE_SVG = NO
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# The DOT_PATH tag can be used to specify the path where the dot tool can be
# found. If left blank, it is assumed the dot tool can be found in the path.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_PATH =
# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
+# contain dot files that are included in the documentation (see the \dotfile
+# command).
+# This tag requires that the tag HAVE_DOT is set to YES.
DOTFILE_DIRS =
# The MSCFILE_DIRS tag can be used to specify one or more directories that
-# contain msc files that are included in the documentation (see the
-# \mscfile command).
+# contain msc files that are included in the documentation (see the \mscfile
+# command).
MSCFILE_DIRS =
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
-# nodes that will be shown in the graph. If the number of nodes in a graph
-# becomes larger than this value, doxygen will truncate the graph, which is
-# visualized by representing a node as a red box. Note that doxygen if the
-# number of direct children of the root node in a graph is already larger than
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
-# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# The DIAFILE_DIRS tag can be used to specify one or more directories that
+# contain dia files that are included in the documentation (see the \diafile
+# command).
+
+DIAFILE_DIRS =
+
+# When using plantuml, the PLANTUML_JAR_PATH tag should be used to specify the
+# path where java can find the plantuml.jar file. If left blank, it is assumed
+# PlantUML is not used or called during a preprocessing step. Doxygen will
+# generate a warning when it encounters a \startuml command in this case and
+# will not generate output for the diagram.
+
+PLANTUML_JAR_PATH =
+
+# When using plantuml, the specified paths are searched for files specified by
+# the !include statement in a plantuml block.
+
+PLANTUML_INCLUDE_PATH =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes
+# that will be shown in the graph. If the number of nodes in a graph becomes
+# larger than this value, doxygen will truncate the graph, which is visualized
+# by representing a node as a red box. Note that doxygen if the number of direct
+# children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that
+# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+# Minimum value: 0, maximum value: 10000, default value: 50.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_GRAPH_MAX_NODES = 50
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes
-# that lay further from the root node will be omitted. Note that setting this
-# option to 1 or 2 may greatly reduce the computation time needed for large
-# code bases. Also note that the size of a graph can be further restricted by
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs
+# generated by dot. A depth value of 3 means that only nodes reachable from the
+# root by following a path via at most 3 edges will be shown. Nodes that lay
+# further from the root node will be omitted. Note that setting this option to 1
+# or 2 may greatly reduce the computation time needed for large code bases. Also
+# note that the size of a graph can be further restricted by
# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+# Minimum value: 0, maximum value: 1000, default value: 0.
+# This tag requires that the tag HAVE_DOT is set to YES.
MAX_DOT_GRAPH_DEPTH = 0
# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, because dot on Windows does not
-# seem to support this out of the box. Warning: Depending on the platform used,
-# enabling this option may lead to badly anti-aliased labels on the edges of
-# a graph (i.e. they become hard to read).
+# background. This is disabled by default, because dot on Windows does not seem
+# to support this out of the box.
+#
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_TRANSPARENT = NO
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# Set the DOT_MULTI_TARGETS tag to YES to allow dot to generate multiple output
# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10)
-# support this, this feature is disabled by default.
+# makes dot run faster, but since only newer versions of dot (>1.8.10) support
+# this, this feature is disabled by default.
+# The default value is: NO.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_MULTI_TARGETS = NO
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
+# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page
+# explaining the meaning of the various boxes and arrows in the dot generated
+# graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
GENERATE_LEGEND = YES
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
+# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot
+# files that are used to generate the various graphs.
+# The default value is: YES.
+# This tag requires that the tag HAVE_DOT is set to YES.
DOT_CLEANUP = YES
diff --git a/src/Makefile.in b/src/Makefile.in
index ecfcf082..22056063 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -35,20 +35,29 @@ libversion = @GETDNS_LIBVERSION@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
+sbindir = @sbindir@
libdir = @libdir@
includedir = @includedir@
+sysconfdir = @sysconfdir@
+localstatedir = @localstatedir@
+runstatedir = @runstatedir@
+stubbyconfdir = $(sysconfdir)/stubby
have_libevent = @have_libevent@
have_libuv = @have_libuv@
have_libev = @have_libev@
# datarootdir is here to please some checkers
datarootdir=@datarootdir@
INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
srcdir = @srcdir@
+stubbysrcdir = $(srcdir)/../stubby
LIBTOOL = ../libtool
CC=@CC@
-CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@
+CFLAGS=-I$(srcdir) -I. -I$(srcdir)/util/auxiliary @CFLAGS@ @CPPFLAGS@ $(XTRA_CFLAGS)
+WPEDANTICFLAG=@WPEDANTICFLAG@
+WNOERRORFLAG=@WNOERRORFLAG@
LDFLAGS=@LDFLAGS@ @LIBS@
EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@
@@ -63,103 +72,136 @@ EXTENSION_LIBUV_LDFLAGS=@EXTENSION_LIBUV_LDFLAGS@
C99COMPATFLAGS=@C99COMPATFLAGS@
+DEFAULT_EVENTLOOP_OBJ=@DEFAULT_EVENTLOOP@.lo
+
GETDNS_OBJ=const-info.lo convert.lo dict.lo dnssec.lo general.lo \
list.lo request-internal.lo pubkey-pinning.lo rr-dict.lo \
- rr-iter.lo server.lo stub.lo sync.lo ub_loop.lo util-internal.lo
+ rr-iter.lo server.lo stub.lo sync.lo ub_loop.lo util-internal.lo \
+ mdns.lo
GLDNS_OBJ=keyraw.lo gbuffer.lo wire2str.lo parse.lo parseutil.lo rrdef.lo \
str2wire.lo
+PROGRAMS=@STUBBY@
+
LIBOBJDIR=
LIBOBJS=@LIBOBJS@
COMPAT_OBJ=$(LIBOBJS:.o=.lo)
-UTIL_OBJ=rbtree.lo val_secalgo.lo
+UTIL_OBJ=rbtree.lo val_secalgo.lo lruhash.lo lookup3.lo locks.lo
JSMN_OBJ=jsmn.lo
-EXTENSION_OBJ=default_eventloop.lo libevent.lo libev.lo
+EXTENSION_OBJ=$(DEFAULT_EVENTLOOP_OBJ) libevent.lo libev.lo
NON_C99_OBJS=context.lo libuv.lo
.SUFFIXES: .c .o .a .lo .h
.c.o:
- $(CC) $(CFLAGS) -c $< -o $@
+ $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $< -o $@
.c.lo:
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $< -o $@
default: all
-all: libgetdns.la $(EXTENSION_LIBEVENT_LIB) $(EXTENSION_LIBUV_LIB) $(EXTENSION_LIBEV_LIB)
+all: libgetdns.la $(EXTENSION_LIBEVENT_LIB) $(EXTENSION_LIBUV_LIB) $(EXTENSION_LIBEV_LIB) $(PROGRAMS)
$(GETDNS_OBJ):
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$(@:.lo=.c) -o $@
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $(srcdir)/$(@:.lo=.c) -o $@
$(GLDNS_OBJ):
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/gldns/$(@:.lo=.c) -o $@
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $(srcdir)/gldns/$(@:.lo=.c) -o $@
$(COMPAT_OBJ):
$(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/compat/$(@:.lo=.c) -o $@
$(UTIL_OBJ):
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/util/$(@:.lo=.c) -o $@
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WNOERRORFLAG) -c $(srcdir)/util/$(@:.lo=.c) -o $@
$(JSMN_OBJ):
$(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -DJSMN_GETDNS -c $(srcdir)/jsmn/$(@:.lo=.c) -o $@
$(EXTENSION_OBJ):
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/extension/$(@:.lo=.c) -o $@
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $(srcdir)/extension/$(@:.lo=.c) -o $@
context.lo:
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(C99COMPATFLAGS) -c $(srcdir)/context.c -o context.lo
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) $(C99COMPATFLAGS) -c $(srcdir)/context.c -o context.lo
libuv.lo:
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(C99COMPATFLAGS) -c $(srcdir)/extension/libuv.c -o libuv.lo
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) $(C99COMPATFLAGS) -c $(srcdir)/extension/libuv.c -o libuv.lo
-install: libgetdns.la
+install-headers: getdns/getdns.h getdns/getdns_extra.h
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)
$(INSTALL) -m 755 -d $(DESTDIR)$(includedir)/getdns
$(INSTALL) -m 644 getdns/getdns.h $(DESTDIR)$(includedir)/getdns/getdns.h
$(INSTALL) -m 644 getdns/getdns_extra.h $(DESTDIR)$(includedir)/getdns/getdns_extra.h
+ if test $(have_libevent) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libevent.h $(DESTDIR)$(includedir)/getdns/ ; fi
+ if test $(have_libuv) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libuv.h $(DESTDIR)$(includedir)/getdns/ ; fi
+ if test $(have_libev) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libev.h $(DESTDIR)$(includedir)/getdns/ ; fi
+
+uninstall-headers:
+ rm -rf $(DESTDIR)$(includedir)/getdns
+
+install-libs: libgetdns.la
$(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
$(LIBTOOL) --mode=install cp libgetdns.la $(DESTDIR)$(libdir)
- if test $(have_libevent) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libevent.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBEVENT_LIB) $(DESTDIR)$(libdir) ; fi
- if test $(have_libuv) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libuv.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBUV_LIB) $(DESTDIR)$(libdir) ; fi
- if test $(have_libev) = 1 ; then $(INSTALL) -m 644 $(srcdir)/getdns/getdns_ext_libev.h $(DESTDIR)$(includedir)/getdns/ ; $(LIBTOOL) --mode=install cp $(EXTENSION_LIBEV_LIB) $(DESTDIR)$(libdir) ; fi
-
+ if test $(have_libevent) = 1 ; then $(LIBTOOL) --mode=install cp $(EXTENSION_LIBEVENT_LIB) $(DESTDIR)$(libdir) ; fi
+ if test $(have_libuv) = 1 ; then $(LIBTOOL) --mode=install cp $(EXTENSION_LIBUV_LIB) $(DESTDIR)$(libdir) ; fi
+ if test $(have_libev) = 1 ; then $(LIBTOOL) --mode=install cp $(EXTENSION_LIBEV_LIB) $(DESTDIR)$(libdir) ; fi
$(LIBTOOL) --mode=finish $(DESTDIR)$(libdir)
-uninstall:
- rm -rf $(DESTDIR)$(includedir)/getdns
- $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libgetdns.la
+uninstall-libs:
if test $(have_libevent) = 1; then $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(EXTENSION_LIBEVENT_LIB) ; fi
if test $(have_libuv) = 1; then $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(EXTENSION_LIBUV_LIB) ; fi
if test $(have_libev) = 1; then $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(EXTENSION_LIBEV_LIB) ; fi
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libgetdns.la
+
+install: install-libs install-headers @INSTALL_STUBBY@
+
+uninstall: @UNINSTALL_STUBBY@ uninstall-headers uninstall-libs
libgetdns_ext_event.la: libgetdns.la libevent.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ libevent.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libevent.symbols
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ libevent.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libevent.symbols
libgetdns_ext_uv.la: libgetdns.la libuv.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ libuv.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libuv.symbols
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ libuv.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libuv.symbols
libgetdns_ext_ev.la: libgetdns.la libev.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ libev.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libev.symbols
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ libev.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libev.symbols
-libgetdns.la: $(GETDNS_OBJ) version.lo context.lo default_eventloop.lo $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) $(JSMN_OBJ)
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ $(GETDNS_OBJ) version.lo context.lo default_eventloop.lo $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) $(JSMN_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/libgetdns.symbols
+libgetdns.la: $(GETDNS_OBJ) version.lo context.lo $(DEFAULT_EVENTLOOP_OBJ) $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) $(JSMN_OBJ)
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(GETDNS_OBJ) version.lo context.lo $(DEFAULT_EVENTLOOP_OBJ) $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) $(JSMN_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/libgetdns.symbols
-
-test: all
+test: default
cd test && $(MAKE) $@
-getdns_query: all
+getdns_query: default
cd tools && $(MAKE) $@
-scratchpad: all
+stubby.lo: $(stubbysrcdir)/src/stubby.c
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -DSTUBBYCONFDIR=\"$(sysconfdir)/stubby\" -DRUNSTATEDIR=\"$(runstatedir)\" -c $< -o $@
+
+stubby: stubby.lo libgetdns.la
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ stubby.lo $(LDFLAGS) libgetdns.la
+
+install-stubby: stubby $(stubbysrcdir)/stubby.conf.example $(stubbysrcdir)/stubby-setdns-macos.sh
+ $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
+ $(LIBTOOL) --mode=install cp stubby $(DESTDIR)$(bindir)
+ $(INSTALL) -m 755 -d $(DESTDIR)$(sbindir)
+ $(INSTALL) -m 755 $(stubbysrcdir)/stubby-setdns-macos.sh $(DESTDIR)$(sbindir)
+ $(INSTALL) -m 755 -d $(DESTDIR)$(stubbyconfdir)
+ test -f $(DESTDIR)$(stubbyconfdir)/stubby.conf || \
+ $(INSTALL_DATA) $(stubbysrcdir)/stubby.conf.example $(DESTDIR)$(stubbyconfdir)/stubby.conf
+
+uninstall-stubby:
+ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/stubby
+ rm -f $(DESTDIR)$(sbindir)/stubby-setdns-macos.sh
+
+scratchpad: default
cd test && $(MAKE) $@
pad: scratchpad
@@ -184,13 +226,14 @@ Makefile: $(srcdir)/Makefile.in ../config.status
depend:
(cd $(srcdir) ; awk 'BEGIN{P=1}{if(P)print}/^# Dependencies/{P=0}' Makefile.in > Makefile.in.new )
- (blddir=`pwd`; cd $(srcdir) ; gcc -MM -I. -I"$$blddir" *.c gldns/*.c compat/*.c util/*.c jsmn/*.c extension/*.c| \
+ (blddir=`pwd`; cd $(srcdir) ; gcc -MM -I. -I"$$blddir" -Iutil/auxiliary *.c gldns/*.c compat/*.c util/*.c jsmn/*.c extension/*.c| \
sed -e "s? $$blddir/? ?g" \
- -e 's?gldns/?$$(srcdir)/gldns/?g' \
- -e 's?compat/?$$(srcdir)/compat/?g' \
- -e 's?util/?$$(srcdir)/util/?g' \
- -e 's?jsmn/?$$(srcdir)/jsmn/?g' \
- -e 's?extension/?$$(srcdir)/extension/?g' \
+ -e 's? gldns/? $$(srcdir)/gldns/?g' \
+ -e 's? compat/? $$(srcdir)/compat/?g' \
+ -e 's? util/auxiliary/util/? $$(srcdir)/util/auxiliary/util/?g' \
+ -e 's? util/? $$(srcdir)/util/?g' \
+ -e 's? jsmn/? $$(srcdir)/jsmn/?g' \
+ -e 's? extension/? $$(srcdir)/extension/?g' \
-e 's? \([a-z_-]*\)\.\([ch]\)? $$(srcdir)/\1.\2?g' \
-e 's? \$$(srcdir)/config\.h? config.h?g' \
-e 's? \$$(srcdir)/getdns/getdns_extra\.h? getdns/getdns_extra.h?g' \
@@ -217,16 +260,22 @@ context.lo context.o: $(srcdir)/context.c \
$(srcdir)/debug.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/context.h \
getdns/getdns.h \
getdns/getdns_extra.h \
- $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
- $(srcdir)/server.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
- $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h $(srcdir)/stub.h $(srcdir)/list.h $(srcdir)/dict.h \
- $(srcdir)/pubkey-pinning.h
+ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
+ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h $(srcdir)/stub.h $(srcdir)/list.h \
+ $(srcdir)/dict.h $(srcdir)/pubkey-pinning.h
convert.lo convert.o: $(srcdir)/convert.c \
config.h \
getdns/getdns.h \
getdns/getdns_extra.h \
$(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
- $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/rr-iter.h \
+ $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/extension/default_eventloop.h \
+ $(srcdir)/extension/poll_eventloop.h $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h \
+ $(srcdir)/util/lruhash.h $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h \
+ $(srcdir)/util/orig-headers/locks.h $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/rr-iter.h \
$(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/wire2str.h \
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/parseutil.h $(srcdir)/const-info.h $(srcdir)/dict.h \
$(srcdir)/list.h $(srcdir)/jsmn/jsmn.h $(srcdir)/convert.h
@@ -235,62 +284,98 @@ dict.lo dict.o: $(srcdir)/dict.c \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h \
- $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
- $(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/const-info.h $(srcdir)/gldns/wire2str.h
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/util-internal.h $(srcdir)/context.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
+ $(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/const-info.h $(srcdir)/gldns/wire2str.h \
+ $(srcdir)/gldns/parseutil.h
dnssec.lo dnssec.o: $(srcdir)/dnssec.c \
config.h \
$(srcdir)/debug.h \
getdns/getdns.h \
$(srcdir)/context.h \
getdns/getdns_extra.h \
- $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
- $(srcdir)/server.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
- $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \
- $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/keyraw.h $(srcdir)/gldns/parseutil.h $(srcdir)/general.h $(srcdir)/dict.h \
- $(srcdir)/list.h $(srcdir)/util/val_secalgo.h
+ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
+ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h \
+ $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/keyraw.h $(srcdir)/gldns/parseutil.h \
+ $(srcdir)/general.h $(srcdir)/dict.h $(srcdir)/list.h $(srcdir)/util/val_secalgo.h \
+ $(srcdir)/util/orig-headers/val_secalgo.h
general.lo general.o: $(srcdir)/general.c \
config.h \
$(srcdir)/general.h \
getdns/getdns.h \
$(srcdir)/types-internal.h \
getdns/getdns_extra.h \
- $(srcdir)/util/rbtree.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/gldns/wire2str.h $(srcdir)/context.h \
- $(srcdir)/extension/default_eventloop.h $(srcdir)/server.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h \
- $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h $(srcdir)/stub.h \
- $(srcdir)/dict.h
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/ub_loop.h $(srcdir)/debug.h \
+ $(srcdir)/gldns/wire2str.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h \
+ $(srcdir)/extension/poll_eventloop.h $(srcdir)/types-internal.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
+ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h $(srcdir)/stub.h $(srcdir)/dict.h \
+ $(srcdir)/mdns.h
list.lo list.o: $(srcdir)/list.c $(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h \
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/util-internal.h \
config.h \
- $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h \
- $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/list.h $(srcdir)/dict.h
+ $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
+ $(srcdir)/gldns/pkthdr.h $(srcdir)/list.h $(srcdir)/dict.h
+mdns.lo mdns.o: $(srcdir)/mdns.c \
+ config.h \
+ $(srcdir)/debug.h $(srcdir)/context.h \
+ getdns/getdns.h \
+ getdns/getdns_extra.h \
+ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/general.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h \
+ $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/mdns.h \
+ $(srcdir)/util/auxiliary/util/fptr_wlist.h $(srcdir)/util/lookup3.h \
+ $(srcdir)/util/orig-headers/lookup3.h
pubkey-pinning.lo pubkey-pinning.o: $(srcdir)/pubkey-pinning.c \
config.h \
$(srcdir)/debug.h \
getdns/getdns.h \
$(srcdir)/context.h \
getdns/getdns_extra.h \
- $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
- $(srcdir)/server.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
- $(srcdir)/gldns/pkthdr.h
+ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
+ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h
request-internal.lo request-internal.o: $(srcdir)/request-internal.c \
config.h \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
- $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h \
- $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/util-internal.h $(srcdir)/context.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h \
$(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/dict.h \
- $(srcdir)/convert.h
+ $(srcdir)/convert.h $(srcdir)/general.h
rr-dict.lo rr-dict.o: $(srcdir)/rr-dict.c $(srcdir)/rr-dict.h \
config.h \
getdns/getdns.h \
$(srcdir)/gldns/gbuffer.h $(srcdir)/util-internal.h $(srcdir)/context.h \
getdns/getdns_extra.h \
- $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
- $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/rr-iter.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h
+ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/rr-iter.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dict.h
rr-iter.lo rr-iter.o: $(srcdir)/rr-iter.c $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
config.h \
getdns/getdns.h \
@@ -299,40 +384,52 @@ server.lo server.o: $(srcdir)/server.c \
config.h \
getdns/getdns_extra.h \
getdns/getdns.h \
- $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h \
- $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h
+ $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h
stub.lo stub.o: $(srcdir)/stub.c \
config.h \
$(srcdir)/debug.h $(srcdir)/stub.h \
getdns/getdns.h \
$(srcdir)/types-internal.h \
getdns/getdns_extra.h \
- $(srcdir)/util/rbtree.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h \
- $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
- $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h $(srcdir)/server.h \
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
+ $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/rr-iter.h \
+ $(srcdir)/rr-dict.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h \
+ $(srcdir)/extension/poll_eventloop.h $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/server.h \
+ $(srcdir)/util/lruhash.h $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h \
+ $(srcdir)/util/orig-headers/locks.h $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h \
$(srcdir)/util-internal.h $(srcdir)/general.h $(srcdir)/pubkey-pinning.h
sync.lo sync.o: $(srcdir)/sync.c \
getdns/getdns.h \
config.h \
$(srcdir)/context.h \
getdns/getdns_extra.h \
- $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
- $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/general.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
- $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h $(srcdir)/stub.h \
+ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h \
+ $(srcdir)/extension/default_eventloop.h $(srcdir)/extension/poll_eventloop.h \
+ $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/general.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h \
+ $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h $(srcdir)/stub.h \
$(srcdir)/gldns/wire2str.h
ub_loop.lo ub_loop.o: $(srcdir)/ub_loop.c $(srcdir)/ub_loop.h \
config.h \
getdns/getdns.h \
getdns/getdns_extra.h \
- $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/debug.h
+ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/debug.h
util-internal.lo util-internal.o: $(srcdir)/util-internal.c \
config.h \
getdns/getdns.h \
- $(srcdir)/dict.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h \
+ $(srcdir)/dict.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/types-internal.h \
getdns/getdns_extra.h \
- $(srcdir)/list.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h $(srcdir)/ub_loop.h \
- $(srcdir)/debug.h $(srcdir)/server.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \
- $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h
+ $(srcdir)/list.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h \
+ $(srcdir)/extension/poll_eventloop.h $(srcdir)/types-internal.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.h \
+ $(srcdir)/util/lruhash.h $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h \
+ $(srcdir)/util/orig-headers/locks.h $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/rr-iter.h \
+ $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \
+ $(srcdir)/dnssec.h $(srcdir)/gldns/rrdef.h
gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c \
config.h \
$(srcdir)/gldns/gbuffer.h
@@ -372,6 +469,8 @@ getentropy_osx.lo getentropy_osx.o: $(srcdir)/compat/getentropy_osx.c \
getentropy_solaris.lo getentropy_solaris.o: $(srcdir)/compat/getentropy_solaris.c \
config.h
getentropy_win.lo getentropy_win.o: $(srcdir)/compat/getentropy_win.c
+gettimeofday.lo gettimeofday.o: $(srcdir)/compat/gettimeofday.c \
+ config.h
inet_ntop.lo inet_ntop.o: $(srcdir)/compat/inet_ntop.c \
config.h
inet_pton.lo inet_pton.o: $(srcdir)/compat/inet_pton.c \
@@ -380,35 +479,59 @@ sha512.lo sha512.o: $(srcdir)/compat/sha512.c \
config.h
strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c \
config.h
+locks.lo locks.o: $(srcdir)/util/locks.c \
+ config.h \
+ $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h
+lookup3.lo lookup3.o: $(srcdir)/util/lookup3.c \
+ config.h \
+ $(srcdir)/util/auxiliary/util/storage/lookup3.h $(srcdir)/util/lookup3.h \
+ $(srcdir)/util/orig-headers/lookup3.h
+lruhash.lo lruhash.o: $(srcdir)/util/lruhash.c \
+ config.h \
+ $(srcdir)/util/auxiliary/util/storage/lruhash.h $(srcdir)/util/lruhash.h \
+ $(srcdir)/util/orig-headers/lruhash.h $(srcdir)/util/locks.h $(srcdir)/util/orig-headers/locks.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/util/auxiliary/util/fptr_wlist.h
rbtree.lo rbtree.o: $(srcdir)/util/rbtree.c \
config.h \
- $(srcdir)/util/log.h $(srcdir)/debug.h $(srcdir)/util/fptr_wlist.h $(srcdir)/util/rbtree.h
+ $(srcdir)/util/auxiliary/log.h $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h \
+ $(srcdir)/util/auxiliary/fptr_wlist.h $(srcdir)/util/auxiliary/util/fptr_wlist.h \
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h
val_secalgo.lo val_secalgo.o: $(srcdir)/util/val_secalgo.c \
config.h \
- $(srcdir)/util/val_secalgo.h $(srcdir)/util/log.h $(srcdir)/debug.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/keyraw.h \
- $(srcdir)/gldns/gbuffer.h
+ $(srcdir)/util/auxiliary/util/data/packed_rrset.h \
+ $(srcdir)/util/auxiliary/validator/val_secalgo.h $(srcdir)/util/val_secalgo.h \
+ $(srcdir)/util/orig-headers/val_secalgo.h $(srcdir)/util/auxiliary/validator/val_nsec3.h \
+ $(srcdir)/util/auxiliary/util/log.h $(srcdir)/debug.h $(srcdir)/util/auxiliary/sldns/rrdef.h \
+ $(srcdir)/gldns/rrdef.h $(srcdir)/util/auxiliary/sldns/keyraw.h $(srcdir)/gldns/keyraw.h \
+ $(srcdir)/util/auxiliary/sldns/sbuffer.h $(srcdir)/gldns/gbuffer.h
jsmn.lo jsmn.o: $(srcdir)/jsmn/jsmn.c $(srcdir)/jsmn/jsmn.h
-default_eventloop.lo default_eventloop.o: $(srcdir)/extension/default_eventloop.c \
- $(srcdir)/extension/default_eventloop.h \
- config.h \
- getdns/getdns.h \
- getdns/getdns_extra.h \
- $(srcdir)/debug.h
libev.lo libev.o: $(srcdir)/extension/libev.c \
config.h \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
- $(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libev.h
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/getdns/getdns_ext_libev.h
libevent.lo libevent.o: $(srcdir)/extension/libevent.c \
config.h \
$(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
- $(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libevent.h
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/getdns/getdns_ext_libevent.h
libuv.lo libuv.o: $(srcdir)/extension/libuv.c \
config.h \
$(srcdir)/debug.h $(srcdir)/types-internal.h \
getdns/getdns.h \
getdns/getdns_extra.h \
- $(srcdir)/util/rbtree.h $(srcdir)/getdns/getdns_ext_libuv.h
+ $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/getdns/getdns_ext_libuv.h
+poll_eventloop.lo poll_eventloop.o: $(srcdir)/extension/poll_eventloop.c \
+ config.h \
+ $(srcdir)/extension/poll_eventloop.h \
+ getdns/getdns.h \
+ getdns/getdns_extra.h \
+ $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h $(srcdir)/debug.h
+select_eventloop.lo select_eventloop.o: $(srcdir)/extension/select_eventloop.c \
+ config.h \
+ $(srcdir)/extension/select_eventloop.h \
+ getdns/getdns.h \
+ getdns/getdns_extra.h \
+ $(srcdir)/debug.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/util/orig-headers/rbtree.h
diff --git a/src/compat/arc4_lock.c b/src/compat/arc4_lock.c
index 44662841..cb9b5056 100644
--- a/src/compat/arc4_lock.c
+++ b/src/compat/arc4_lock.c
@@ -34,6 +34,79 @@
#include "config.h"
#define LOCKRET(func) func
+#ifdef HAVE_PTHREAD
+#include "pthread.h"
+
+static pthread_mutex_t arc_lock = PTHREAD_MUTEX_INITIALIZER;
+
+void _ARC4_LOCK(void)
+{
+ pthread_mutex_lock(&arc_lock);
+}
+
+void _ARC4_UNLOCK(void)
+{
+ pthread_mutex_unlock(&arc_lock);
+}
+#elif defined(GETDNS_ON_WINDOWS)
+ /*
+ * There is no explicit arc4random_init call, and thus
+ * the critical section must be allocated on the first call to
+ * ARC4_LOCK(). The interlocked test is used to verify that
+ * the critical section will be allocated only once.
+ *
+ * The work around is for the main program to call arc4random()
+ * at the beginning of execution, before spinning new threads.
+ *
+ * There is also no explicit arc4random_close call, and thus
+ * the critical section is never deleted. It will remain allocated
+ * as long as the program runs.
+ */
+static CRITICAL_SECTION arc_critical_section;
+static volatile long arc_critical_section_initialized = 0;
+
+void _ARC4_LOCK(void)
+{
+ long r = InterlockedCompareExchange(&arc_critical_section_initialized, 1, 0);
+
+ if (r != 2)
+ {
+ if (r == 0)
+ {
+ InitializeCriticalSection(&arc_critical_section);
+ arc_critical_section_initialized = 2;
+ }
+ else if (r == 1)
+ {
+ /*
+ * If the critical section is initialized, the first test
+ * will return the value 2.
+ *
+ * If several threads try to initialize the arc4random
+ * state "at the same time", the first one will find
+ * the "initialized" variable at 0, the other ones at 1.
+ *
+ * Since this is a fairly rare event, we resolve it with a
+ * simple active wait loop.
+ */
+
+ while (arc_critical_section_initialized != 2)
+ {
+ Sleep(1);
+ }
+ }
+ }
+
+ EnterCriticalSection(&arc_critical_section);
+}
+
+void _ARC4_UNLOCK(void)
+{
+ LeaveCriticalSection(&arc_critical_section);
+}
+
+#else
+ /* XXX - add non pthread specific lock routines here */
void _ARC4_LOCK(void)
{
}
@@ -41,4 +114,4 @@ void _ARC4_LOCK(void)
void _ARC4_UNLOCK(void)
{
}
-
+#endif
diff --git a/src/compat/arc4random.c b/src/compat/arc4random.c
index 2c78818f..7c9570b9 100644
--- a/src/compat/arc4random.c
+++ b/src/compat/arc4random.c
@@ -38,6 +38,9 @@
#ifndef GETDNS_ON_WINDOWS
#include
#endif
+#if defined(GETDNS_ON_WINDOWS) && !defined(MAP_INHERIT_ZERO)
+#define explicit_bzero(rnd, rnd_size) memset(rnd, 0, rnd_size)
+#endif
#define KEYSTREAM_ONLY
#include "chacha_private.h"
@@ -114,6 +117,9 @@ _rs_stir(void)
#ifdef SIGKILL
raise(SIGKILL);
#else
+#ifdef GETDNS_ON_WINDOWS
+ DebugBreak();
+#endif
exit(9); /* windows */
#endif
}
@@ -125,6 +131,9 @@ _rs_stir(void)
explicit_bzero(rnd, sizeof(rnd)); /* discard source seed */
/* invalidate rs_buf */
+#ifdef GETDNS_ON_WINDOWS
+ _Analysis_assume_(rs != NULL);
+#endif
rs->rs_have = 0;
memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
@@ -136,7 +145,15 @@ _rs_stir_if_needed(size_t len)
{
#ifndef MAP_INHERIT_ZERO
static pid_t _rs_pid = 0;
+#ifdef GETDNS_ON_WINDOWS
+ /*
+ * TODO: if compiling for the Windows Runtime, use GetCurrentProcessId(),
+ * but this requires linking with kernel32.lib
+ */
+ pid_t pid = _getpid();
+#else
pid_t pid = getpid();
+#endif
/* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */
if (_rs_pid == 0 || _rs_pid != pid) {
@@ -147,6 +164,9 @@ _rs_stir_if_needed(size_t len)
#endif
if (!rs || rs->rs_count <= len)
_rs_stir();
+#ifdef GETDNS_ON_WINDOWS
+ _Analysis_assume_(rs != NULL);
+#endif
if (rs->rs_count <= len)
rs->rs_count = 0;
else
diff --git a/src/compat/arc4random_uniform.c b/src/compat/arc4random_uniform.c
index 154260eb..c03c2c9b 100644
--- a/src/compat/arc4random_uniform.c
+++ b/src/compat/arc4random_uniform.c
@@ -39,7 +39,7 @@ arc4random_uniform(uint32_t upper_bound)
return 0;
/* 2**32 % x == (2**32 - x) % x */
- min = -upper_bound % upper_bound;
+ min = ((uint32_t)(-(int32_t)upper_bound)) % upper_bound;
/*
* This could theoretically loop forever but each retry has
diff --git a/src/compat/gettimeofday.c b/src/compat/gettimeofday.c
new file mode 100644
index 00000000..d8fe91bc
--- /dev/null
+++ b/src/compat/gettimeofday.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2016 Christian Huitema
+ *
+ * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR 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.
+ */
+
+ /*
+ * Numerous places in the code make reference to the Unix/Linux
+ * "gettimeofday()" function, which is not available in the standard
+ * windows libraries. This code provides a compatible implementation.
+ */
+#include "config.h"
+
+#ifdef GETDNS_ON_WINDOWS
+int gettimeofday(struct timeval* tv, struct timezone* tz)
+{
+ FILETIME ft;
+ uint64_t now = 0;
+
+ /*
+ * The GetSystemTimeAsFileTime API returns the number
+ * of 100-nanosecond intervals since January 1, 1601 (UTC),
+ * in FILETIME format.
+ */
+ GetSystemTimeAsFileTime(&ft);
+
+ /*
+ * Convert to plain 64 bit format, without making
+ * assumptions about the FILETIME structure alignment.
+ */
+ now |= ft.dwHighDateTime;
+ now <<= 32;
+ now |= ft.dwLowDateTime;
+ /*
+ * Convert units from 100ns to 1us
+ */
+ now /= 10;
+ /*
+ * Account for microseconds elapsed between 1601 and 1970.
+ */
+ now -= 11644473600000000ULL;
+
+ if (tv != NULL)
+ {
+ uint64_t sec = now / 1000000;
+ uint64_t usec = now % 1000000;
+
+ tv->tv_sec = (long)sec;
+ tv->tv_usec = (long)usec;
+ }
+
+ if (tz != NULL)
+ {
+ /*
+ * TODO: implement a timezone retrieval function.
+ * Not urgent, since the GetDNS code always set this parameter to NULL.
+ */
+ return -1;
+ }
+
+ return 0;
+}
+#endif /* GETDNS_ON_WINDOWS */
\ No newline at end of file
diff --git a/src/const-info.c b/src/const-info.c
index 0294e281..d2b5a007 100644
--- a/src/const-info.c
+++ b/src/const-info.c
@@ -9,90 +9,101 @@
static struct const_info consts_info[] = {
{ -1, NULL, "/* */" },
- { 0, "GETDNS_RETURN_GOOD", GETDNS_RETURN_GOOD_TEXT },
- { 1, "GETDNS_RETURN_GENERIC_ERROR", GETDNS_RETURN_GENERIC_ERROR_TEXT },
- { 300, "GETDNS_RETURN_BAD_DOMAIN_NAME", GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT },
- { 301, "GETDNS_RETURN_BAD_CONTEXT", GETDNS_RETURN_BAD_CONTEXT_TEXT },
- { 302, "GETDNS_RETURN_CONTEXT_UPDATE_FAIL", GETDNS_RETURN_CONTEXT_UPDATE_FAIL_TEXT },
- { 303, "GETDNS_RETURN_UNKNOWN_TRANSACTION", GETDNS_RETURN_UNKNOWN_TRANSACTION_TEXT },
- { 304, "GETDNS_RETURN_NO_SUCH_LIST_ITEM", GETDNS_RETURN_NO_SUCH_LIST_ITEM_TEXT },
- { 305, "GETDNS_RETURN_NO_SUCH_DICT_NAME", GETDNS_RETURN_NO_SUCH_DICT_NAME_TEXT },
- { 306, "GETDNS_RETURN_WRONG_TYPE_REQUESTED", GETDNS_RETURN_WRONG_TYPE_REQUESTED_TEXT },
- { 307, "GETDNS_RETURN_NO_SUCH_EXTENSION", GETDNS_RETURN_NO_SUCH_EXTENSION_TEXT },
- { 308, "GETDNS_RETURN_EXTENSION_MISFORMAT", GETDNS_RETURN_EXTENSION_MISFORMAT_TEXT },
- { 309, "GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED", GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT },
- { 310, "GETDNS_RETURN_MEMORY_ERROR", GETDNS_RETURN_MEMORY_ERROR_TEXT },
- { 311, "GETDNS_RETURN_INVALID_PARAMETER", GETDNS_RETURN_INVALID_PARAMETER_TEXT },
- { 312, "GETDNS_RETURN_NOT_IMPLEMENTED", GETDNS_RETURN_NOT_IMPLEMENTED_TEXT },
- { 399, "GETDNS_RETURN_NEED_MORE_SPACE", GETDNS_RETURN_NEED_MORE_SPACE_TEXT },
- { 400, "GETDNS_DNSSEC_SECURE", GETDNS_DNSSEC_SECURE_TEXT },
- { 401, "GETDNS_DNSSEC_BOGUS", GETDNS_DNSSEC_BOGUS_TEXT },
- { 402, "GETDNS_DNSSEC_INDETERMINATE", GETDNS_DNSSEC_INDETERMINATE_TEXT },
- { 403, "GETDNS_DNSSEC_INSECURE", GETDNS_DNSSEC_INSECURE_TEXT },
- { 404, "GETDNS_DNSSEC_NOT_PERFORMED", GETDNS_DNSSEC_NOT_PERFORMED_TEXT },
- { 500, "GETDNS_NAMESPACE_DNS", GETDNS_NAMESPACE_DNS_TEXT },
- { 501, "GETDNS_NAMESPACE_LOCALNAMES", GETDNS_NAMESPACE_LOCALNAMES_TEXT },
- { 502, "GETDNS_NAMESPACE_NETBIOS", GETDNS_NAMESPACE_NETBIOS_TEXT },
- { 503, "GETDNS_NAMESPACE_MDNS", GETDNS_NAMESPACE_MDNS_TEXT },
- { 504, "GETDNS_NAMESPACE_NIS", GETDNS_NAMESPACE_NIS_TEXT },
- { 520, "GETDNS_RESOLUTION_STUB", GETDNS_RESOLUTION_STUB_TEXT },
- { 521, "GETDNS_RESOLUTION_RECURSING", GETDNS_RESOLUTION_RECURSING_TEXT },
- { 530, "GETDNS_REDIRECTS_FOLLOW", GETDNS_REDIRECTS_FOLLOW_TEXT },
- { 531, "GETDNS_REDIRECTS_DO_NOT_FOLLOW", GETDNS_REDIRECTS_DO_NOT_FOLLOW_TEXT },
- { 540, "GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP", GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP_TEXT },
- { 541, "GETDNS_TRANSPORT_UDP_ONLY", GETDNS_TRANSPORT_UDP_ONLY_TEXT },
- { 542, "GETDNS_TRANSPORT_TCP_ONLY", GETDNS_TRANSPORT_TCP_ONLY_TEXT },
- { 543, "GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
- { 544, "GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
- { 545, "GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT },
- { 550, "GETDNS_APPEND_NAME_ALWAYS", GETDNS_APPEND_NAME_ALWAYS_TEXT },
- { 551, "GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE_TEXT },
- { 552, "GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE_TEXT },
- { 553, "GETDNS_APPEND_NAME_NEVER", GETDNS_APPEND_NAME_NEVER_TEXT },
- { 554, "GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST", GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST_TEXT },
- { 600, "GETDNS_CONTEXT_CODE_NAMESPACES", GETDNS_CONTEXT_CODE_NAMESPACES_TEXT },
- { 601, "GETDNS_CONTEXT_CODE_RESOLUTION_TYPE", GETDNS_CONTEXT_CODE_RESOLUTION_TYPE_TEXT },
- { 602, "GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS", GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS_TEXT },
- { 603, "GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS", GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS_TEXT },
- { 604, "GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS", GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS_TEXT },
- { 605, "GETDNS_CONTEXT_CODE_DNS_TRANSPORT", GETDNS_CONTEXT_CODE_DNS_TRANSPORT_TEXT },
- { 606, "GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES", GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES_TEXT },
- { 607, "GETDNS_CONTEXT_CODE_APPEND_NAME", GETDNS_CONTEXT_CODE_APPEND_NAME_TEXT },
- { 608, "GETDNS_CONTEXT_CODE_SUFFIX", GETDNS_CONTEXT_CODE_SUFFIX_TEXT },
- { 609, "GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS", GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS_TEXT },
- { 610, "GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE", GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE_TEXT },
- { 611, "GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE", GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE_TEXT },
- { 612, "GETDNS_CONTEXT_CODE_EDNS_VERSION", GETDNS_CONTEXT_CODE_EDNS_VERSION_TEXT },
- { 613, "GETDNS_CONTEXT_CODE_EDNS_DO_BIT", GETDNS_CONTEXT_CODE_EDNS_DO_BIT_TEXT },
- { 614, "GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW", GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW_TEXT },
- { 615, "GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS", GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS_TEXT },
- { 616, "GETDNS_CONTEXT_CODE_TIMEOUT", GETDNS_CONTEXT_CODE_TIMEOUT_TEXT },
- { 617, "GETDNS_CONTEXT_CODE_IDLE_TIMEOUT", GETDNS_CONTEXT_CODE_IDLE_TIMEOUT_TEXT },
- { 618, "GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION", GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION_TEXT },
- { 619, "GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE", GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE_TEXT },
- { 620, "GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE", GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE_TEXT },
- { 621, "GETDNS_CONTEXT_CODE_PUBKEY_PINSET", GETDNS_CONTEXT_CODE_PUBKEY_PINSET_TEXT },
- { 700, "GETDNS_CALLBACK_COMPLETE", GETDNS_CALLBACK_COMPLETE_TEXT },
- { 701, "GETDNS_CALLBACK_CANCEL", GETDNS_CALLBACK_CANCEL_TEXT },
- { 702, "GETDNS_CALLBACK_TIMEOUT", GETDNS_CALLBACK_TIMEOUT_TEXT },
- { 703, "GETDNS_CALLBACK_ERROR", GETDNS_CALLBACK_ERROR_TEXT },
- { 800, "GETDNS_NAMETYPE_DNS", GETDNS_NAMETYPE_DNS_TEXT },
- { 801, "GETDNS_NAMETYPE_WINS", GETDNS_NAMETYPE_WINS_TEXT },
- { 900, "GETDNS_RESPSTATUS_GOOD", GETDNS_RESPSTATUS_GOOD_TEXT },
- { 901, "GETDNS_RESPSTATUS_NO_NAME", GETDNS_RESPSTATUS_NO_NAME_TEXT },
- { 902, "GETDNS_RESPSTATUS_ALL_TIMEOUT", GETDNS_RESPSTATUS_ALL_TIMEOUT_TEXT },
- { 903, "GETDNS_RESPSTATUS_NO_SECURE_ANSWERS", GETDNS_RESPSTATUS_NO_SECURE_ANSWERS_TEXT },
- { 904, "GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS", GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS_TEXT },
- { 1000, "GETDNS_EXTENSION_TRUE", GETDNS_EXTENSION_TRUE_TEXT },
- { 1001, "GETDNS_EXTENSION_FALSE", GETDNS_EXTENSION_FALSE_TEXT },
- { 1100, "GETDNS_BAD_DNS_CNAME_IN_TARGET", GETDNS_BAD_DNS_CNAME_IN_TARGET_TEXT },
- { 1101, "GETDNS_BAD_DNS_ALL_NUMERIC_LABEL", GETDNS_BAD_DNS_ALL_NUMERIC_LABEL_TEXT },
- { 1102, "GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE", GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE_TEXT },
- { 1200, "GETDNS_TRANSPORT_UDP", GETDNS_TRANSPORT_UDP_TEXT },
- { 1201, "GETDNS_TRANSPORT_TCP", GETDNS_TRANSPORT_TCP_TEXT },
- { 1202, "GETDNS_TRANSPORT_TLS", GETDNS_TRANSPORT_TLS_TEXT },
- { 1300, "GETDNS_AUTHENTICATION_NONE", GETDNS_AUTHENTICATION_NONE_TEXT },
- { 1301, "GETDNS_AUTHENTICATION_REQUIRED", GETDNS_AUTHENTICATION_REQUIRED_TEXT },
+ { 0, "GETDNS_RETURN_GOOD", GETDNS_RETURN_GOOD_TEXT },
+ { 1, "GETDNS_RETURN_GENERIC_ERROR", GETDNS_RETURN_GENERIC_ERROR_TEXT },
+ { 2, "GETDNS_LOG_CRIT", GETDNS_LOG_CRIT_TEXT },
+ { 3, "GETDNS_LOG_ERR", GETDNS_LOG_ERR_TEXT },
+ { 4, "GETDNS_LOG_WARNING", GETDNS_LOG_WARNING_TEXT },
+ { 5, "GETDNS_LOG_NOTICE", GETDNS_LOG_NOTICE_TEXT },
+ { 6, "GETDNS_LOG_INFO", GETDNS_LOG_INFO_TEXT },
+ { 7, "GETDNS_LOG_DEBUG", GETDNS_LOG_DEBUG_TEXT },
+ { 300, "GETDNS_RETURN_BAD_DOMAIN_NAME", GETDNS_RETURN_BAD_DOMAIN_NAME_TEXT },
+ { 301, "GETDNS_RETURN_BAD_CONTEXT", GETDNS_RETURN_BAD_CONTEXT_TEXT },
+ { 302, "GETDNS_RETURN_CONTEXT_UPDATE_FAIL", GETDNS_RETURN_CONTEXT_UPDATE_FAIL_TEXT },
+ { 303, "GETDNS_RETURN_UNKNOWN_TRANSACTION", GETDNS_RETURN_UNKNOWN_TRANSACTION_TEXT },
+ { 304, "GETDNS_RETURN_NO_SUCH_LIST_ITEM", GETDNS_RETURN_NO_SUCH_LIST_ITEM_TEXT },
+ { 305, "GETDNS_RETURN_NO_SUCH_DICT_NAME", GETDNS_RETURN_NO_SUCH_DICT_NAME_TEXT },
+ { 306, "GETDNS_RETURN_WRONG_TYPE_REQUESTED", GETDNS_RETURN_WRONG_TYPE_REQUESTED_TEXT },
+ { 307, "GETDNS_RETURN_NO_SUCH_EXTENSION", GETDNS_RETURN_NO_SUCH_EXTENSION_TEXT },
+ { 308, "GETDNS_RETURN_EXTENSION_MISFORMAT", GETDNS_RETURN_EXTENSION_MISFORMAT_TEXT },
+ { 309, "GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED", GETDNS_RETURN_DNSSEC_WITH_STUB_DISALLOWED_TEXT },
+ { 310, "GETDNS_RETURN_MEMORY_ERROR", GETDNS_RETURN_MEMORY_ERROR_TEXT },
+ { 311, "GETDNS_RETURN_INVALID_PARAMETER", GETDNS_RETURN_INVALID_PARAMETER_TEXT },
+ { 312, "GETDNS_RETURN_NOT_IMPLEMENTED", GETDNS_RETURN_NOT_IMPLEMENTED_TEXT },
+ { 398, "GETDNS_RETURN_NO_UPSTREAM_AVAILABLE", GETDNS_RETURN_NO_UPSTREAM_AVAILABLE_TEXT },
+ { 399, "GETDNS_RETURN_NEED_MORE_SPACE", GETDNS_RETURN_NEED_MORE_SPACE_TEXT },
+ { 400, "GETDNS_DNSSEC_SECURE", GETDNS_DNSSEC_SECURE_TEXT },
+ { 401, "GETDNS_DNSSEC_BOGUS", GETDNS_DNSSEC_BOGUS_TEXT },
+ { 402, "GETDNS_DNSSEC_INDETERMINATE", GETDNS_DNSSEC_INDETERMINATE_TEXT },
+ { 403, "GETDNS_DNSSEC_INSECURE", GETDNS_DNSSEC_INSECURE_TEXT },
+ { 404, "GETDNS_DNSSEC_NOT_PERFORMED", GETDNS_DNSSEC_NOT_PERFORMED_TEXT },
+ { 500, "GETDNS_NAMESPACE_DNS", GETDNS_NAMESPACE_DNS_TEXT },
+ { 501, "GETDNS_NAMESPACE_LOCALNAMES", GETDNS_NAMESPACE_LOCALNAMES_TEXT },
+ { 502, "GETDNS_NAMESPACE_NETBIOS", GETDNS_NAMESPACE_NETBIOS_TEXT },
+ { 503, "GETDNS_NAMESPACE_MDNS", GETDNS_NAMESPACE_MDNS_TEXT },
+ { 504, "GETDNS_NAMESPACE_NIS", GETDNS_NAMESPACE_NIS_TEXT },
+ { 520, "GETDNS_RESOLUTION_STUB", GETDNS_RESOLUTION_STUB_TEXT },
+ { 521, "GETDNS_RESOLUTION_RECURSING", GETDNS_RESOLUTION_RECURSING_TEXT },
+ { 530, "GETDNS_REDIRECTS_FOLLOW", GETDNS_REDIRECTS_FOLLOW_TEXT },
+ { 531, "GETDNS_REDIRECTS_DO_NOT_FOLLOW", GETDNS_REDIRECTS_DO_NOT_FOLLOW_TEXT },
+ { 540, "GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP", GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP_TEXT },
+ { 541, "GETDNS_TRANSPORT_UDP_ONLY", GETDNS_TRANSPORT_UDP_ONLY_TEXT },
+ { 542, "GETDNS_TRANSPORT_TCP_ONLY", GETDNS_TRANSPORT_TCP_ONLY_TEXT },
+ { 543, "GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
+ { 544, "GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN_TEXT },
+ { 545, "GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN", GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN_TEXT },
+ { 550, "GETDNS_APPEND_NAME_ALWAYS", GETDNS_APPEND_NAME_ALWAYS_TEXT },
+ { 551, "GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE_TEXT },
+ { 552, "GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE", GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE_TEXT },
+ { 553, "GETDNS_APPEND_NAME_NEVER", GETDNS_APPEND_NAME_NEVER_TEXT },
+ { 554, "GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST", GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST_TEXT },
+ { 600, "GETDNS_CONTEXT_CODE_NAMESPACES", GETDNS_CONTEXT_CODE_NAMESPACES_TEXT },
+ { 601, "GETDNS_CONTEXT_CODE_RESOLUTION_TYPE", GETDNS_CONTEXT_CODE_RESOLUTION_TYPE_TEXT },
+ { 602, "GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS", GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS_TEXT },
+ { 603, "GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS", GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS_TEXT },
+ { 604, "GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS", GETDNS_CONTEXT_CODE_DNS_ROOT_SERVERS_TEXT },
+ { 605, "GETDNS_CONTEXT_CODE_DNS_TRANSPORT", GETDNS_CONTEXT_CODE_DNS_TRANSPORT_TEXT },
+ { 606, "GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES", GETDNS_CONTEXT_CODE_LIMIT_OUTSTANDING_QUERIES_TEXT },
+ { 607, "GETDNS_CONTEXT_CODE_APPEND_NAME", GETDNS_CONTEXT_CODE_APPEND_NAME_TEXT },
+ { 608, "GETDNS_CONTEXT_CODE_SUFFIX", GETDNS_CONTEXT_CODE_SUFFIX_TEXT },
+ { 609, "GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS", GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS_TEXT },
+ { 610, "GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE", GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE_TEXT },
+ { 611, "GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE", GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE_TEXT },
+ { 612, "GETDNS_CONTEXT_CODE_EDNS_VERSION", GETDNS_CONTEXT_CODE_EDNS_VERSION_TEXT },
+ { 613, "GETDNS_CONTEXT_CODE_EDNS_DO_BIT", GETDNS_CONTEXT_CODE_EDNS_DO_BIT_TEXT },
+ { 614, "GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW", GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW_TEXT },
+ { 615, "GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS", GETDNS_CONTEXT_CODE_MEMORY_FUNCTIONS_TEXT },
+ { 616, "GETDNS_CONTEXT_CODE_TIMEOUT", GETDNS_CONTEXT_CODE_TIMEOUT_TEXT },
+ { 617, "GETDNS_CONTEXT_CODE_IDLE_TIMEOUT", GETDNS_CONTEXT_CODE_IDLE_TIMEOUT_TEXT },
+ { 618, "GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION", GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION_TEXT },
+ { 619, "GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE", GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE_TEXT },
+ { 620, "GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE", GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE_TEXT },
+ { 621, "GETDNS_CONTEXT_CODE_PUBKEY_PINSET", GETDNS_CONTEXT_CODE_PUBKEY_PINSET_TEXT },
+ { 622, "GETDNS_CONTEXT_CODE_ROUND_ROBIN_UPSTREAMS", GETDNS_CONTEXT_CODE_ROUND_ROBIN_UPSTREAMS_TEXT },
+ { 623, "GETDNS_CONTEXT_CODE_TLS_BACKOFF_TIME", GETDNS_CONTEXT_CODE_TLS_BACKOFF_TIME_TEXT },
+ { 624, "GETDNS_CONTEXT_CODE_TLS_CONNECTION_RETRIES", GETDNS_CONTEXT_CODE_TLS_CONNECTION_RETRIES_TEXT },
+ { 700, "GETDNS_CALLBACK_COMPLETE", GETDNS_CALLBACK_COMPLETE_TEXT },
+ { 701, "GETDNS_CALLBACK_CANCEL", GETDNS_CALLBACK_CANCEL_TEXT },
+ { 702, "GETDNS_CALLBACK_TIMEOUT", GETDNS_CALLBACK_TIMEOUT_TEXT },
+ { 703, "GETDNS_CALLBACK_ERROR", GETDNS_CALLBACK_ERROR_TEXT },
+ { 800, "GETDNS_NAMETYPE_DNS", GETDNS_NAMETYPE_DNS_TEXT },
+ { 801, "GETDNS_NAMETYPE_WINS", GETDNS_NAMETYPE_WINS_TEXT },
+ { 900, "GETDNS_RESPSTATUS_GOOD", GETDNS_RESPSTATUS_GOOD_TEXT },
+ { 901, "GETDNS_RESPSTATUS_NO_NAME", GETDNS_RESPSTATUS_NO_NAME_TEXT },
+ { 902, "GETDNS_RESPSTATUS_ALL_TIMEOUT", GETDNS_RESPSTATUS_ALL_TIMEOUT_TEXT },
+ { 903, "GETDNS_RESPSTATUS_NO_SECURE_ANSWERS", GETDNS_RESPSTATUS_NO_SECURE_ANSWERS_TEXT },
+ { 904, "GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS", GETDNS_RESPSTATUS_ALL_BOGUS_ANSWERS_TEXT },
+ { 1000, "GETDNS_EXTENSION_TRUE", GETDNS_EXTENSION_TRUE_TEXT },
+ { 1001, "GETDNS_EXTENSION_FALSE", GETDNS_EXTENSION_FALSE_TEXT },
+ { 1100, "GETDNS_BAD_DNS_CNAME_IN_TARGET", GETDNS_BAD_DNS_CNAME_IN_TARGET_TEXT },
+ { 1101, "GETDNS_BAD_DNS_ALL_NUMERIC_LABEL", GETDNS_BAD_DNS_ALL_NUMERIC_LABEL_TEXT },
+ { 1102, "GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE", GETDNS_BAD_DNS_CNAME_RETURNED_FOR_OTHER_TYPE_TEXT },
+ { 1200, "GETDNS_TRANSPORT_UDP", GETDNS_TRANSPORT_UDP_TEXT },
+ { 1201, "GETDNS_TRANSPORT_TCP", GETDNS_TRANSPORT_TCP_TEXT },
+ { 1202, "GETDNS_TRANSPORT_TLS", GETDNS_TRANSPORT_TLS_TEXT },
+ { 1300, "GETDNS_AUTHENTICATION_NONE", GETDNS_AUTHENTICATION_NONE_TEXT },
+ { 1301, "GETDNS_AUTHENTICATION_REQUIRED", GETDNS_AUTHENTICATION_REQUIRED_TEXT },
+ { 4096, "GETDNS_LOG_UPSTREAM_STATS", GETDNS_LOG_UPSTREAM_STATS_TEXT },
};
static int const_info_cmp(const void *a, const void *b)
@@ -156,9 +167,12 @@ static struct const_name_info consts_name_info[] = {
{ "GETDNS_CONTEXT_CODE_NAMESPACES", 600 },
{ "GETDNS_CONTEXT_CODE_PUBKEY_PINSET", 621 },
{ "GETDNS_CONTEXT_CODE_RESOLUTION_TYPE", 601 },
+ { "GETDNS_CONTEXT_CODE_ROUND_ROBIN_UPSTREAMS", 622 },
{ "GETDNS_CONTEXT_CODE_SUFFIX", 608 },
{ "GETDNS_CONTEXT_CODE_TIMEOUT", 616 },
{ "GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION", 618 },
+ { "GETDNS_CONTEXT_CODE_TLS_BACKOFF_TIME", 623 },
+ { "GETDNS_CONTEXT_CODE_TLS_CONNECTION_RETRIES", 624 },
{ "GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE", 620 },
{ "GETDNS_CONTEXT_CODE_UPSTREAM_RECURSIVE_SERVERS", 603 },
{ "GETDNS_DNSSEC_BOGUS", 401 },
@@ -168,6 +182,15 @@ static struct const_name_info consts_name_info[] = {
{ "GETDNS_DNSSEC_SECURE", 400 },
{ "GETDNS_EXTENSION_FALSE", 1001 },
{ "GETDNS_EXTENSION_TRUE", 1000 },
+ { "GETDNS_LOG_ALERT", 1 },
+ { "GETDNS_LOG_CRIT", 2 },
+ { "GETDNS_LOG_DEBUG", 7 },
+ { "GETDNS_LOG_EMERG", 0 },
+ { "GETDNS_LOG_ERR", 3 },
+ { "GETDNS_LOG_INFO", 6 },
+ { "GETDNS_LOG_NOTICE", 5 },
+ { "GETDNS_LOG_UPSTREAM_STATS", 4096 },
+ { "GETDNS_LOG_WARNING", 4 },
{ "GETDNS_NAMESPACE_DNS", 500 },
{ "GETDNS_NAMESPACE_LOCALNAMES", 501 },
{ "GETDNS_NAMESPACE_MDNS", 503 },
@@ -188,6 +211,7 @@ static struct const_name_info consts_name_info[] = {
{ "GETDNS_RCODE_BADTIME", 18 },
{ "GETDNS_RCODE_BADTRUNC", 22 },
{ "GETDNS_RCODE_BADVERS", 16 },
+ { "GETDNS_RCODE_COOKIE", 23 },
{ "GETDNS_RCODE_FORMERR", 1 },
{ "GETDNS_RCODE_NOERROR", 0 },
{ "GETDNS_RCODE_NOTAUTH", 9 },
@@ -222,6 +246,7 @@ static struct const_name_info consts_name_info[] = {
{ "GETDNS_RETURN_NO_SUCH_DICT_NAME", 305 },
{ "GETDNS_RETURN_NO_SUCH_EXTENSION", 307 },
{ "GETDNS_RETURN_NO_SUCH_LIST_ITEM", 304 },
+ { "GETDNS_RETURN_NO_UPSTREAM_AVAILABLE", 398 },
{ "GETDNS_RETURN_UNKNOWN_TRANSACTION", 303 },
{ "GETDNS_RETURN_WRONG_TYPE_REQUESTED", 306 },
{ "GETDNS_RRCLASS_ANY", 255 },
@@ -235,6 +260,7 @@ static struct const_name_info consts_name_info[] = {
{ "GETDNS_RRTYPE_ANY", 255 },
{ "GETDNS_RRTYPE_APL", 42 },
{ "GETDNS_RRTYPE_ATMA", 34 },
+ { "GETDNS_RRTYPE_AVC", 258 },
{ "GETDNS_RRTYPE_AXFR", 252 },
{ "GETDNS_RRTYPE_CAA", 257 },
{ "GETDNS_RRTYPE_CDNSKEY", 60 },
@@ -274,6 +300,7 @@ static struct const_name_info consts_name_info[] = {
{ "GETDNS_RRTYPE_NINFO", 56 },
{ "GETDNS_RRTYPE_NS", 2 },
{ "GETDNS_RRTYPE_NSAP", 22 },
+ { "GETDNS_RRTYPE_NSAP_PTR", 23 },
{ "GETDNS_RRTYPE_NSEC", 47 },
{ "GETDNS_RRTYPE_NULL", 10 },
{ "GETDNS_RRTYPE_NXT", 30 },
@@ -287,6 +314,7 @@ static struct const_name_info consts_name_info[] = {
{ "GETDNS_RRTYPE_RT", 21 },
{ "GETDNS_RRTYPE_SIG", 24 },
{ "GETDNS_RRTYPE_SINK", 40 },
+ { "GETDNS_RRTYPE_SMIMEA", 53 },
{ "GETDNS_RRTYPE_SOA", 6 },
{ "GETDNS_RRTYPE_SPF", 99 },
{ "GETDNS_RRTYPE_SRV", 33 },
diff --git a/src/context.c b/src/context.c
index 847fb041..49fc7859 100644
--- a/src/context.c
+++ b/src/context.c
@@ -61,6 +61,12 @@ typedef unsigned short in_port_t;
#include
#include
+#include
+
+#ifdef HAVE_PTHREAD
+#include
+#endif
+#include
#include "config.h"
#ifdef HAVE_LIBUNBOUND
@@ -85,6 +91,21 @@ typedef unsigned short in_port_t;
#define GETDNS_STR_PORT_DNS "53"
#define GETDNS_STR_PORT_DNS_OVER_TLS "853"
+#ifdef HAVE_PTHREAD
+static pthread_mutex_t ssl_init_lock = PTHREAD_MUTEX_INITIALIZER;
+#endif
+static bool ssl_init=false;
+
+#ifdef HAVE_MDNS_SUPPORT
+/*
+ * Forward declaration of MDNS context init and destroy function.
+ * We do this here instead of including mdns.h, in order to
+ * minimize dependencies.
+ */
+void _getdns_mdns_context_init(struct getdns_context *context);
+void _getdns_mdns_context_destroy(struct getdns_context *context);
+#endif
+
void *plain_mem_funcs_user_arg = MF_PLAIN;
typedef struct host_name_addrs {
@@ -122,8 +143,7 @@ static getdns_return_t create_default_namespaces(struct getdns_context *context)
static getdns_return_t create_default_dns_transports(struct getdns_context *context);
static int transaction_id_cmp(const void *, const void *);
static void dispatch_updated(struct getdns_context *, uint16_t);
-static void cancel_dns_req(getdns_dns_req *);
-static void cancel_outstanding_requests(struct getdns_context*, int);
+static void cancel_outstanding_requests(getdns_context*);
/* unbound helpers */
#ifdef HAVE_LIBUNBOUND
@@ -134,8 +154,6 @@ static getdns_return_t set_ub_dns_transport(struct getdns_context*);
static void set_ub_limit_outstanding_queries(struct getdns_context*,
uint16_t);
static void set_ub_dnssec_allowed_skew(struct getdns_context*, uint32_t);
-static void set_ub_edns_maximum_udp_payload_size(struct getdns_context*,
- int);
#endif
/* Stuff to make it compile pedantically */
@@ -152,7 +170,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
HCERTSTORE hSystemStore;
PCCERT_CONTEXT pTargetCert = NULL;
- DEBUG_STUB("%s %-35s: %s\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__,
+ DEBUG_STUB("%s %-35s: %s\n", STUB_DEBUG_SETUP_TLS, __FUNC__,
"Adding Windows certificates to CA store");
/* load just once per context lifetime for this version of getdns
@@ -181,7 +199,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
/* failure if the CA store is empty or the call fails */
if ((pTargetCert = CertEnumCertificatesInStore(
hSystemStore, pTargetCert)) == 0) {
- DEBUG_STUB("%s %-35s: %s\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__,
+ DEBUG_STUB("%s %-35s: %s\n", STUB_DEBUG_SETUP_TLS, __FUNC__,
"CA certificate store for Windows is empty.");
return 0;
}
@@ -193,7 +211,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
pTargetCert->cbCertEncoded);
if (!cert1) {
/* return error if a cert fails */
- DEBUG_STUB("%s %-35s: %s %d:%s\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__,
+ DEBUG_STUB("%s %-35s: %s %d:%s\n", STUB_DEBUG_SETUP_TLS, __FUNC__,
"Unable to parse certificate in memory",
ERR_get_error(), ERR_error_string(ERR_get_error(), NULL));
return 0;
@@ -201,7 +219,7 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
else {
/* return error if a cert add to store fails */
if (X509_STORE_add_cert(store, cert1) == 0) {
- DEBUG_STUB("%s %-35s: %s %d:%s\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__,
+ DEBUG_STUB("%s %-35s: %s %d:%s\n", STUB_DEBUG_SETUP_TLS, __FUNC__,
"Error adding certificate", ERR_get_error(),
ERR_error_string(ERR_get_error(), NULL));
return 0;
@@ -224,6 +242,22 @@ add_WIN_cacerts_to_openssl_store(SSL_CTX* tls_ctx)
}
#endif
+static uint8_t*
+upstream_addr(getdns_upstream *upstream)
+{
+ return upstream->addr.ss_family == AF_INET
+ ? (void *)&((struct sockaddr_in*)&upstream->addr)->sin_addr
+ : (void *)&((struct sockaddr_in6*)&upstream->addr)->sin6_addr;
+}
+
+static in_port_t
+upstream_port(getdns_upstream *upstream)
+{
+ return ntohs(upstream->addr.ss_family == AF_INET
+ ? ((struct sockaddr_in *)&upstream->addr)->sin_port
+ : ((struct sockaddr_in6*)&upstream->addr)->sin6_port);
+}
+
static void destroy_local_host(_getdns_rbnode_t * node, void *arg)
{
getdns_context *context = (getdns_context *)arg;
@@ -418,7 +452,7 @@ sockaddr_dict(getdns_context *context, struct sockaddr *sa)
break;
port = ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
- if (port != GETDNS_PORT_DNS && port != GETDNS_PORT_DNS &&
+ if (port != GETDNS_PORT_ZERO && port != GETDNS_PORT_DNS &&
getdns_dict_set_int(address, "port", (uint32_t)port))
break;
@@ -616,6 +650,10 @@ upstreams_create(getdns_context *context, size_t size)
r->referenced = 1;
r->count = 0;
r->current_udp = 0;
+ r->current_stateful = 0;
+ r->tls_backoff_time = context->tls_backoff_time;
+ r->tls_connection_retries = context->tls_connection_retries;
+ r->log = context->log;
return r;
}
@@ -650,17 +688,26 @@ _getdns_upstreams_dereference(getdns_upstreams *upstreams)
while (upstream->finished_dnsreqs) {
dnsreq = upstream->finished_dnsreqs;
upstream->finished_dnsreqs = dnsreq->finished_next;
- (void) _getdns_context_cancel_request(dnsreq->context,
- dnsreq->trans_id, 1);
+ if (!dnsreq->internal_cb) { /* Not part of chain */
+ debug_req("Destroy ", *dnsreq->netreqs);
+ _getdns_context_cancel_request(dnsreq);
+ }
}
+ if (upstream->tls_session != NULL)
+ SSL_SESSION_free(upstream->tls_session);
+
if (upstream->tls_obj != NULL) {
- if (upstream->tls_session != NULL)
- SSL_SESSION_free(upstream->tls_session);
SSL_shutdown(upstream->tls_obj);
SSL_free(upstream->tls_obj);
}
if (upstream->fd != -1)
+ {
+#ifdef USE_WINSOCK
+ closesocket(upstream->fd);
+#else
close(upstream->fd);
+#endif
+ }
while (pin) {
sha256_pin_t *nextpin = pin->next;
GETDNS_FREE(upstreams->mf, pin);
@@ -671,6 +718,22 @@ _getdns_upstreams_dereference(getdns_upstreams *upstreams)
GETDNS_FREE(upstreams->mf, upstreams);
}
+void _getdns_upstream_log(getdns_upstream *upstream, uint64_t system,
+ getdns_loglevel_type level, const char *fmt, ...)
+{
+ va_list args;
+
+ if (!upstream || !upstream->upstreams || !upstream->upstreams->log.func
+ || !(upstream->upstreams->log.system & system)
+ || level > upstream->upstreams->log.level)
+ return;
+
+ va_start(args, fmt);
+ upstream->upstreams->log.func(
+ upstream->upstreams->log.userarg, system, level, fmt, args);
+ va_end(args);
+}
+
void
_getdns_upstream_shutdown(getdns_upstream *upstream)
{
@@ -679,38 +742,63 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
/* Update total stats for the upstream.*/
upstream->total_responses+=upstream->responses_received;
upstream->total_timeouts+=upstream->responses_timeouts;
- /* Pick up the auth state if it is of interest*/
- if (upstream->tls_auth_state != GETDNS_AUTH_NONE)
- upstream->past_tls_auth_state = upstream->tls_auth_state;
-
- DEBUG_STUB("%s %-35s: FD: %d Upstream Stats: Resp=%d,Timeouts=%d,Conns=%d,Conn_fails=%d,Conn_shutdowns=%d,Auth=%d\n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd,
- (int)upstream->total_responses, (int)upstream->total_timeouts,
- (int)upstream->conn_completed, (int)upstream->conn_setup_failed,
- (int)upstream->conn_shutdowns, upstream->past_tls_auth_state);
+ /* Need the last auth state when using session resumption*/
+ upstream->last_tls_auth_state = upstream->tls_auth_state;
+ /* Keep track of the best auth state this upstream has had*/
+ if (upstream->tls_auth_state > upstream->best_tls_auth_state)
+ upstream->best_tls_auth_state = upstream->tls_auth_state;
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Conn closed : Transport=%s - Resp=%d,Timeouts=%d,Auth=%s,Keepalive(ms)=%d\n",
+ upstream->addr_str,
+ (upstream->transport == GETDNS_TRANSPORT_TLS ? "TLS" : "TCP"),
+ (int)upstream->responses_received, (int)upstream->responses_timeouts,
+ _getdns_auth_str(upstream->tls_auth_state), (int)upstream->keepalive_timeout);
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Upstream stats: Transport=%s - Resp=%d,Timeouts=%d,Best_auth=%s\n",
+ upstream->addr_str,
+ (upstream->transport == GETDNS_TRANSPORT_TLS ? "TLS" : "TCP"),
+ (int)upstream->total_responses, (int)upstream->total_timeouts,
+ _getdns_auth_str(upstream->best_tls_auth_state));
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Upstream stats: Transport=%s - Conns=%d,Conn_fails=%d,Conn_shutdowns=%d,Backoffs=%d\n",
+ upstream->addr_str,
+ (upstream->transport == GETDNS_TRANSPORT_TLS ? "TLS" : "TCP"),
+ (int)upstream->conn_completed, (int)upstream->conn_setup_failed,
+ (int)upstream->conn_shutdowns, (int)upstream->conn_backoffs);
/* Back off connections that never got up service at all (probably no
TCP service or incompatible TLS version/cipher).
Leave choice between working upstreams to the stub.
This back-off should be time based for TLS according to RFC7858. For now,
use the same basis if we simply can't get TCP service either.*/
-
+ uint16_t conn_retries = upstream->upstreams->tls_connection_retries;
/* [TLS1]TODO: This arbitrary logic at the moment - review and improve!*/
- if (upstream->conn_setup_failed >= GETDNS_CONN_ATTEMPTS ||
- (upstream->conn_shutdowns >= GETDNS_CONN_ATTEMPTS*GETDNS_TRANSPORT_FAIL_MULT
- && upstream->total_responses == 0) ||
- (upstream->conn_completed >= GETDNS_CONN_ATTEMPTS &&
+ if (upstream->conn_setup_failed >= conn_retries
+ || ((int)upstream->conn_shutdowns >= conn_retries*GETDNS_TRANSPORT_FAIL_MULT
+ && upstream->total_responses == 0)
+ || (upstream->conn_completed >= conn_retries &&
upstream->total_responses == 0 &&
upstream->total_timeouts > GETDNS_TRANSPORT_FAIL_MULT)) {
- DEBUG_STUB("%s %-35s: FD: %d BACKING OFF THIS UPSTREAM! \n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd);
upstream->conn_state = GETDNS_CONN_BACKOFF;
- }
+ upstream->conn_retry_time = time(NULL) + upstream->upstreams->tls_backoff_time;
+ upstream->total_responses = 0;
+ upstream->total_timeouts = 0;
+ upstream->conn_completed = 0;
+ upstream->conn_setup_failed = 0;
+ upstream->conn_shutdowns = 0;
+ upstream->conn_backoffs++;
+
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : !Backing off this upstream - Will retry as new upstream at %s",
+ upstream->addr_str,
+ asctime(gmtime(&upstream->conn_retry_time)));
+ }
// Reset per connection counters
upstream->queries_sent = 0;
upstream->responses_received = 0;
upstream->responses_timeouts = 0;
upstream->keepalive_timeout = 0;
+ upstream->keepalive_shutdown = 0;
/* Now TLS stuff*/
upstream->tls_auth_state = GETDNS_AUTH_NONE;
@@ -720,7 +808,11 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
upstream->tls_obj = NULL;
}
if (upstream->fd != -1) {
+#ifdef USE_WINSOCK
+ closesocket(upstream->fd);
+#else
close(upstream->fd);
+#endif
upstream->fd = -1;
}
/* Set connection ready for use again*/
@@ -729,8 +821,11 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
}
static int
-tls_is_in_transports_list(getdns_context *context) {
- for (int i=0; i< context->dns_transport_count;i++) {
+tls_is_in_transports_list(getdns_context *context)
+{
+ size_t i;
+
+ for (i = 0; i< context->dns_transport_count;i++) {
if (context->dns_transports[i] == GETDNS_TRANSPORT_TLS)
return 1;
}
@@ -750,9 +845,22 @@ tls_only_is_in_transports_list(getdns_context *context) {
static int
net_req_query_id_cmp(const void *id1, const void *id2)
{
- return (intptr_t)id1 - (intptr_t)id2;
+ /*
+ * old code was:
+ * return (intptr_t)id1 - (intptr_t)id2;
+ *but this is incorrect on 64 bit architectures.
+ */
+ int ret = 0;
+
+ if (id1 != id2)
+ {
+ ret = ((intptr_t)id1 < (intptr_t)id2) ? -1 : 1;
+ }
+
+ return ret;
}
+
static getdns_tsig_info const tsig_info[] = {
{ GETDNS_NO_TSIG, NULL, 0, NULL, 0, 0, 0 }
, { GETDNS_HMAC_MD5 , "hmac-md5.sig-alg.reg.int", 24
@@ -779,7 +887,7 @@ static getdns_tsig_info const * const last_tsig_info =
const getdns_tsig_info *_getdns_get_tsig_info(getdns_tsig_algo tsig_alg)
{
- return tsig_alg > n_tsig_infos - 1
+ return ((unsigned) tsig_alg > n_tsig_infos - 1)
|| tsig_info[tsig_alg].alg == GETDNS_NO_TSIG ? NULL
: &tsig_info[tsig_alg];
}
@@ -828,17 +936,28 @@ upstream_init(getdns_upstream *upstream,
upstream->addr_len = ai->ai_addrlen;
(void) memcpy(&upstream->addr, ai->ai_addr, ai->ai_addrlen);
+ inet_ntop(upstream->addr.ss_family, upstream_addr(upstream),
+ upstream->addr_str, INET6_ADDRSTRLEN);
- /* How is this upstream doing? */
- upstream->conn_setup_failed = 0;
+ /* How is this upstream doing on connections? */
+ upstream->conn_completed = 0;
upstream->conn_shutdowns = 0;
+ upstream->conn_setup_failed = 0;
+ upstream->conn_retry_time = 0;
+ upstream->conn_backoffs = 0;
+ upstream->total_responses = 0;
+ upstream->total_timeouts = 0;
upstream->conn_state = GETDNS_CONN_CLOSED;
upstream->queries_sent = 0;
upstream->responses_received = 0;
upstream->responses_timeouts = 0;
+ upstream->keepalive_shutdown = 0;
upstream->keepalive_timeout = 0;
- upstream->to_retry = 2;
+ /* How is this upstream doing on UDP? */
+ upstream->to_retry = 1;
upstream->back_off = 1;
+ upstream->udp_responses = 0;
+ upstream->udp_timeouts = 0;
/* For sharing a socket to this upstream with TCP */
upstream->fd = -1;
@@ -848,6 +967,8 @@ upstream_init(getdns_upstream *upstream,
upstream->tls_hs_state = GETDNS_HS_NONE;
upstream->tls_auth_name[0] = '\0';
upstream->tls_auth_state = GETDNS_AUTH_NONE;
+ upstream->last_tls_auth_state = GETDNS_AUTH_NONE;
+ upstream->best_tls_auth_state = GETDNS_AUTH_NONE;
upstream->tls_pubkey_pinset = NULL;
upstream->loop = NULL;
(void) getdns_eventloop_event_init(
@@ -950,6 +1071,7 @@ set_os_defaults_windows(struct getdns_context *context)
getdns_upstream *upstream;
size_t length;
int s;
+ uint32_t info_err = 0;
if (context->fchg_resolvconf == NULL) {
context->fchg_resolvconf =
@@ -982,15 +1104,16 @@ set_os_defaults_windows(struct getdns_context *context)
if (info == NULL)
return GETDNS_RETURN_GENERIC_ERROR;
- if (GetNetworkParams(info, &buflen) == ERROR_BUFFER_OVERFLOW) {
+ if ((info_err = GetNetworkParams(info, &buflen)) == ERROR_BUFFER_OVERFLOW) {
free(info);
info = (FIXED_INFO *)malloc(buflen);
if (info == NULL)
return GETDNS_RETURN_GENERIC_ERROR;
+ info_err = GetNetworkParams(info, &buflen);
}
- if (GetNetworkParams(info, &buflen) == NO_ERROR) {
- ptr = info->DnsServerList.Next;
+ if (info_err == NO_ERROR) {
+ ptr = &info->DnsServerList;
*domain = 0;
while (ptr) {
for (size_t i = 0; i < GETDNS_UPSTREAM_TRANSPORTS; i++) {
@@ -1007,11 +1130,12 @@ set_os_defaults_windows(struct getdns_context *context)
freeaddrinfo(result);
}
ptr = ptr->Next;
-
}
- free(info);
}
+ if (info != NULL)
+ free(info);
+
suffix = getdns_list_create_with_context(context);
if (get_dns_suffix_windows(suffix, domain)) {
@@ -1182,6 +1306,26 @@ NULL_update_callback(
getdns_context *context, getdns_context_code_t code, void *userarg)
{ (void)context; (void)code; (void)userarg; }
+static int
+netreq_expiry_cmp(const void *id1, const void *id2)
+{
+ getdns_network_req *req1 = (getdns_network_req *)id1;
+ getdns_network_req *req2 = (getdns_network_req *)id2;
+
+ return req1->owner->expires < req2->owner->expires ? -1 :
+ req1->owner->expires > req2->owner->expires ? 1 :
+ req1 < req2 ? -1 :
+ req1 > req2 ? 1 : 0;
+}
+
+void _getdns_check_expired_pending_netreqs(
+ getdns_context *context, uint64_t *now_ms);
+static void _getdns_check_expired_pending_netreqs_cb(void *arg)
+{
+ uint64_t now_ms = 0;
+ _getdns_check_expired_pending_netreqs((getdns_context *)arg, &now_ms);
+}
+
/*
* getdns_context_create
*
@@ -1236,6 +1380,11 @@ getdns_context_create_with_extended_memory_functions(
result->update_callback2 = NULL_update_callback;
result->update_userarg = NULL;
+ result->log.func = NULL;
+ result->log.userarg = NULL;
+ result->log.system = 0;
+ result->log.level = GETDNS_LOG_ERR;
+
result->mf.mf_arg = userarg;
result->mf.mf.ext.malloc = malloc;
result->mf.mf.ext.realloc = realloc;
@@ -1245,6 +1394,15 @@ getdns_context_create_with_extended_memory_functions(
_getdns_rbtree_init(&result->outbound_requests, transaction_id_cmp);
_getdns_rbtree_init(&result->local_hosts, local_host_cmp);
+ _getdns_rbtree_init(&result->pending_netreqs, netreq_expiry_cmp);
+ result->first_pending_netreq = NULL;
+ result->netreqs_in_flight = 0;
+ result->pending_timeout_event.userarg = result;
+ result->pending_timeout_event.read_cb = NULL;
+ result->pending_timeout_event.write_cb = NULL;
+ result->pending_timeout_event.timeout_cb =
+ _getdns_check_expired_pending_netreqs_cb;
+ result->pending_timeout_event.ev = NULL;
result->server = NULL;
@@ -1267,7 +1425,7 @@ getdns_context_create_with_extended_memory_functions(
result->suffixes = no_suffixes;
result->suffixes_len = sizeof(no_suffixes);
- gldns_buffer_init_frm_data(&gbuf, result->trust_anchors_spc
+ gldns_buffer_init_vfixed_frm_data(&gbuf, result->trust_anchors_spc
, sizeof(result->trust_anchors_spc));
if (!_getdns_parse_ta_file(NULL, &gbuf)) {
@@ -1297,12 +1455,12 @@ getdns_context_create_with_extended_memory_functions(
result->edns_version = 0;
result->edns_do_bit = 0;
result->edns_client_subnet_private = 0;
- result->tls_query_padding_blocksize = 1; /* default is to not try to pad */
+ result->tls_query_padding_blocksize = 1; /* default is to pad queries sensibly */
result->tls_ctx = NULL;
result->extension = &result->default_eventloop.loop;
- _getdns_default_eventloop_init(&result->default_eventloop);
- _getdns_default_eventloop_init(&result->sync_eventloop);
+ _getdns_default_eventloop_init(&result->mf, &result->default_eventloop);
+ _getdns_default_eventloop_init(&result->mf, &result->sync_eventloop);
/* request extension defaults
*/
@@ -1343,14 +1501,30 @@ getdns_context_create_with_extended_memory_functions(
goto error;
result->tls_auth = GETDNS_AUTHENTICATION_NONE;
result->tls_auth_min = GETDNS_AUTHENTICATION_NONE;
+ result->round_robin_upstreams = 0;
+ result->tls_backoff_time = 3600;
+ result->tls_connection_retries = 2;
result->limit_outstanding_queries = 0;
/* unbound context is initialized here */
/* Unbound needs SSL to be init'ed this early when TLS is used. However we
* don't know that till later so we will have to do this every time. */
- if ((set_from_os & 2) == 0)
+#ifdef HAVE_PTHREAD
+ pthread_mutex_lock(&ssl_init_lock);
+#else
+ /* XXX implement Windows-style lock here */
+#endif
+ /* Only initialise SSL once and ideally in a thread-safe manner */
+ if (ssl_init == false) {
SSL_library_init();
+ ssl_init = true;
+ }
+#ifdef HAVE_PTHREAD
+ pthread_mutex_unlock(&ssl_init_lock);
+#else
+ /* XXX implement Windows-style unlock here */
+#endif
#ifdef HAVE_LIBUNBOUND
result->unbound_ctx = NULL;
@@ -1358,8 +1532,14 @@ getdns_context_create_with_extended_memory_functions(
goto error;
#endif
+
+#ifdef HAVE_MDNS_SUPPORT
+ _getdns_mdns_context_init(result);
+#endif
+
create_local_hosts(result);
+
*context = result;
return GETDNS_RETURN_GOOD;
error:
@@ -1421,10 +1601,10 @@ getdns_context_destroy(struct getdns_context *context)
context->destroying = 1;
/* cancel all outstanding requests */
- cancel_outstanding_requests(context, 1);
+ cancel_outstanding_requests(context);
/* Destroy listening addresses */
- (void) getdns_context_set_listen_addresses(context, NULL, NULL);
+ (void) getdns_context_set_listen_addresses(context, NULL, NULL, NULL);
/* This needs to be done before cleaning the extension, because there
* might be an idle_timeout schedules, which will not get unscheduled
@@ -1439,6 +1619,13 @@ getdns_context_destroy(struct getdns_context *context)
ub_ctx_delete(context->unbound_ctx);
#endif
+#ifdef HAVE_MDNS_SUPPORT
+ /*
+ * Release all ressource allocated for MDNS.
+ */
+ _getdns_mdns_context_destroy(context);
+#endif
+
if (context->namespaces)
GETDNS_FREE(context->my_mf, context->namespaces);
@@ -1521,6 +1708,37 @@ getdns_context_get_update_callback(getdns_context *context, void **userarg,
return GETDNS_RETURN_GOOD;
}
+getdns_return_t
+getdns_context_set_logfunc(getdns_context *context, void *userarg,
+ uint64_t system, getdns_loglevel_type level, getdns_logfunc_type log)
+{
+ if (!context)
+ return GETDNS_RETURN_INVALID_PARAMETER;
+
+ context->log.func = log;
+ context->log.userarg = userarg;
+ context->log.system = system;
+ context->log.level = level;
+ if (context->upstreams) {
+ context->upstreams->log = context->log;
+ }
+ return GETDNS_RETURN_GOOD;
+}
+
+void _getdns_context_log(getdns_context *context, uint64_t system,
+ getdns_loglevel_type level, const char *fmt, ...)
+{
+ va_list args;
+
+ if (!context || !context->log.func || !(context->log.system & system)
+ || level > context->log.level)
+ return;
+
+ va_start(args, fmt);
+ context->log.func(context->log.userarg, system, level, fmt, args);
+ va_end(args);
+}
+
#ifdef HAVE_LIBUNBOUND
/*
* Helpers to set options on the unbound ctx
@@ -1556,7 +1774,7 @@ getdns_context_request_count_changed(getdns_context *context)
if (context->outbound_requests.count && ! context->ub_event.ev){
DEBUG_SCHED("gc_request_count_changed "
"-> ub schedule(el_ev = %p, el_ev->ev = %p)\n",
- &context->ub_event, context->ub_event.ev);
+ (void *)&context->ub_event, (void *)context->ub_event.ev);
#ifndef USE_WINSOCK
#ifdef HAVE_UNBOUND_EVENT_API
if (!_getdns_ub_loop_enabled(&context->ub_loop))
@@ -1570,7 +1788,7 @@ getdns_context_request_count_changed(getdns_context *context)
context->ub_event.ev) {
DEBUG_SCHED("gc_request_count_changed "
"-> ub clear(el_ev = %p, el_ev->ev = %p)\n",
- &context->ub_event, context->ub_event.ev);
+ (void *)&context->ub_event, (void *)context->ub_event.ev);
#ifndef USE_WINSOCK
#ifdef HAVE_UNBOUND_EVENT_API
@@ -1605,7 +1823,7 @@ static getdns_return_t
rebuild_ub_ctx(struct getdns_context* context) {
if (context->unbound_ctx != NULL) {
/* cancel all requests and delete */
- cancel_outstanding_requests(context, 1);
+ cancel_outstanding_requests(context);
ub_ctx_delete(context->unbound_ctx);
context->unbound_ctx = NULL;
}
@@ -1630,9 +1848,9 @@ rebuild_ub_ctx(struct getdns_context* context) {
"target-fetch-policy:", "0 0 0 0 0");
#endif
set_ub_dnssec_allowed_skew(context,
- context->dnssec_allowed_skew);
- set_ub_edns_maximum_udp_payload_size(context,
- context->edns_maximum_udp_payload_size);
+ context->dnssec_allowed_skew);
+ set_ub_number_opt(context, "edns-buffer-size:",
+ context->edns_maximum_udp_payload_size);
set_ub_dns_transport(context);
context->ub_event.userarg = context;
@@ -1713,12 +1931,17 @@ getdns_context_set_namespaces(getdns_context *context,
for (i = 0; i < namespace_count; i++) {
if (namespaces[i] == GETDNS_NAMESPACE_NETBIOS ||
- namespaces[i] == GETDNS_NAMESPACE_MDNS ||
+#ifndef HAVE_MDNS_SUPPORT
+ namespaces[i] == GETDNS_NAMESPACE_MDNS ||
+#endif
namespaces[i] == GETDNS_NAMESPACE_NIS)
r = GETDNS_RETURN_NOT_IMPLEMENTED;
else if (namespaces[i] != GETDNS_NAMESPACE_DNS &&
- namespaces[i] != GETDNS_NAMESPACE_LOCALNAMES)
+#ifdef HAVE_MDNS_SUPPORT
+ namespaces[i] != GETDNS_NAMESPACE_MDNS &&
+#endif
+ namespaces[i] != GETDNS_NAMESPACE_LOCALNAMES )
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
}
GETDNS_FREE(context->my_mf, context->namespaces);
@@ -1928,11 +2151,69 @@ getdns_context_set_tls_authentication(getdns_context *context,
return GETDNS_RETURN_GOOD;
} /* getdns_context_set_tls_authentication_list */
+/*
+ * getdns_context_set_round_robin_upstreams
+ *
+ */
+getdns_return_t
+getdns_context_set_round_robin_upstreams(getdns_context *context, uint8_t value)
+{
+ RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+ /* only allow 0 or 1 */
+ if (value != 0 && value != 1) {
+ return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
+ }
+
+ context->round_robin_upstreams = value;
+
+ dispatch_updated(context, GETDNS_CONTEXT_CODE_ROUND_ROBIN_UPSTREAMS);
+
+ return GETDNS_RETURN_GOOD;
+} /* getdns_context_set_round_robin_upstreams */
+
+/*
+ * getdns_context_set_tls_backoff_time
+ *
+ */
+getdns_return_t
+getdns_context_set_tls_backoff_time(getdns_context *context, uint16_t value)
+{
+ RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+ /* Value is in seconds. Should we have a lower limit? 1 second?*/
+ context->tls_backoff_time = value;
+
+ dispatch_updated(context, GETDNS_CONTEXT_CODE_TLS_BACKOFF_TIME);
+
+ return GETDNS_RETURN_GOOD;
+} /* getdns_context_set_tls_backoff_time */
+
+/*
+ * getdns_context_set_tls_connection_retries
+ *
+ */
+getdns_return_t
+getdns_context_set_tls_connection_retries(getdns_context *context, uint16_t value)
+{
+ RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+ /* Should we put a sensible upper limit on this? 10?*/
+ // if (value > 10) {
+ // return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
+ // }
+
+ context->tls_connection_retries = value;
+
+ dispatch_updated(context, GETDNS_CONTEXT_CODE_TLS_CONNECTION_RETRIES);
+
+ return GETDNS_RETURN_GOOD;
+} /* getdns_context_set_tls_connection retries */
+
+#ifdef HAVE_LIBUNBOUND
static void
-set_ub_limit_outstanding_queries(struct getdns_context* context, uint16_t value) {
+set_ub_limit_outstanding_queries(getdns_context* context, uint16_t value) {
/* num-queries-per-thread */
set_ub_number_opt(context, "num-queries-per-thread:", value);
}
+#endif
/*
* getdns_context_set_limit_outstanding_queries
*
@@ -1942,7 +2223,9 @@ getdns_context_set_limit_outstanding_queries(struct getdns_context *context,
uint16_t limit)
{
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+#ifdef HAVE_LIBUNBOUND
set_ub_limit_outstanding_queries(context, limit);
+#endif
if (limit != context->limit_outstanding_queries) {
context->limit_outstanding_queries = limit;
dispatch_updated(context,
@@ -1977,18 +2260,38 @@ getdns_context_set_timeout(struct getdns_context *context, uint64_t timeout)
*
*/
getdns_return_t
-getdns_context_set_idle_timeout(struct getdns_context *context, uint64_t timeout)
+getdns_context_set_idle_timeout(getdns_context *context, uint64_t timeout)
{
- RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+ size_t i;
- /* Shuold we enforce maximum based on edns-tcp-keepalive spec? */
- /* 0 should be allowed as that is the default.*/
+ if (!context)
+ return GETDNS_RETURN_INVALID_PARAMETER;
- context->idle_timeout = timeout;
+ /* Shuold we enforce maximum based on edns-tcp-keepalive spec? */
+ /* 0 should be allowed as that is the default.*/
- dispatch_updated(context, GETDNS_CONTEXT_CODE_IDLE_TIMEOUT);
+ context->idle_timeout = timeout;
- return GETDNS_RETURN_GOOD;
+ dispatch_updated(context, GETDNS_CONTEXT_CODE_IDLE_TIMEOUT);
+
+ if (timeout)
+ return GETDNS_RETURN_GOOD;
+
+ /* If timeout == 0, call scheduled idle timeout events */
+ for (i = 0; i < context->upstreams->count; i++) {
+ getdns_upstream *upstream =
+ &context->upstreams->upstreams[i];
+
+ if (!upstream->event.ev ||
+ !upstream->event.timeout_cb ||
+ upstream->event.read_cb ||
+ upstream->event.write_cb)
+ continue;
+
+ GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
+ upstream->event.timeout_cb(upstream->event.userarg);
+ }
+ return GETDNS_RETURN_GOOD;
} /* getdns_context_set_timeout */
@@ -2224,7 +2527,7 @@ getdns_context_set_suffix(getdns_context *context, getdns_list *value)
context->suffixes_len = sizeof(no_suffixes);
return GETDNS_RETURN_GOOD;
}
- gldns_buffer_init_frm_data(&gbuf, buf_spc, sizeof(buf_spc));
+ gldns_buffer_init_vfixed_frm_data(&gbuf, buf_spc, sizeof(buf_spc));
for (;;) {
for ( i = 0
; !(r = getdns_list_get_bindata(value, i, &bindata))
@@ -2246,7 +2549,7 @@ getdns_context_set_suffix(getdns_context *context, getdns_list *value)
if (gldns_str2wire_dname_buf(name, dname, &dname_len))
return GETDNS_RETURN_GENERIC_ERROR;
- gldns_buffer_write_u8(&gbuf, dname_len);
+ gldns_buffer_write_u8(&gbuf, (uint8_t) dname_len);
gldns_buffer_write(&gbuf, dname, dname_len);
}
if (r == GETDNS_RETURN_NO_SUCH_LIST_ITEM)
@@ -2314,11 +2617,13 @@ getdns_context_set_dnssec_trust_anchors(
return GETDNS_RETURN_GOOD;
} /* getdns_context_set_dnssec_trust_anchors */
+#ifdef HAVE_LIBUNBOUND
static void
set_ub_dnssec_allowed_skew(struct getdns_context* context, uint32_t value) {
set_ub_number_opt(context, "val-sig-skew-min:", value);
set_ub_number_opt(context, "val-sig-skew-max:", value);
}
+#endif
/*
* getdns_context_set_dnssec_allowed_skew
*
@@ -2328,7 +2633,9 @@ getdns_context_set_dnssec_allowed_skew(struct getdns_context *context,
uint32_t value)
{
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+#ifdef HAVE_LIBUNBOUND
set_ub_dnssec_allowed_skew(context, value);
+#endif
if (value != context->dnssec_allowed_skew) {
context->dnssec_allowed_skew = value;
dispatch_updated(context, GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW);
@@ -2539,12 +2846,21 @@ getdns_context_set_upstream_recursive_servers(struct getdns_context *context,
if (getdns_upstream_transports[j] == GETDNS_TRANSPORT_TLS) {
getdns_list *pubkey_pinset = NULL;
if (dict && (r = getdns_dict_get_bindata(
- dict, "tls_auth_name", &tls_auth_name)) == GETDNS_RETURN_GOOD) {
- /*TODO: VALIDATE THIS STRING!*/
+ dict, "tls_auth_name", &tls_auth_name)) == GETDNS_RETURN_GOOD) {
+
+ if (tls_auth_name->size >= sizeof(upstream->tls_auth_name)) {
+ /* tls_auth_name's are just
+ * domain names and should
+ * thus not be larger than 256
+ * bytes.
+ */
+ goto invalid_parameter;
+ }
memcpy(upstream->tls_auth_name,
(char *)tls_auth_name->data,
tls_auth_name->size);
- upstream->tls_auth_name[tls_auth_name->size] = '\0';
+ upstream->tls_auth_name
+ [tls_auth_name->size] = '\0';
}
if (dict && (r = getdns_dict_get_list(dict, "tls_pubkey_pinset",
&pubkey_pinset)) == GETDNS_RETURN_GOOD) {
@@ -2596,13 +2912,26 @@ error:
} /* getdns_context_set_upstream_recursive_servers */
-static void
-set_ub_edns_maximum_udp_payload_size(struct getdns_context* context,
- int value) {
- /* edns-buffer-size */
- if (value >= 512 && value <= 65535)
- set_ub_number_opt(context, "edns-buffer-size:", (uint16_t)value);
-}
+/*
+ * getdns_context_unset_edns_maximum_udp_payload_size
+ *
+ */
+getdns_return_t
+getdns_context_unset_edns_maximum_udp_payload_size(getdns_context *context)
+{
+ if (!context)
+ return GETDNS_RETURN_INVALID_PARAMETER;
+
+#ifdef HAVE_LIBUNBOUND
+ set_ub_number_opt(context, "edns-buffer-size:", 4096);
+#endif
+ if (context->edns_maximum_udp_payload_size != -1) {
+ context->edns_maximum_udp_payload_size = -1;
+ dispatch_updated(context,
+ GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE);
+ }
+ return GETDNS_RETURN_GOOD;
+} /* getdns_context_set_edns_maximum_udp_payload_size */
/*
* getdns_context_set_edns_maximum_udp_payload_size
@@ -2615,11 +2944,9 @@ getdns_context_set_edns_maximum_udp_payload_size(struct getdns_context *context,
if (!context)
return GETDNS_RETURN_INVALID_PARAMETER;
- /* check for < 512. uint16_t won't let it go above max) */
- if (value < 512)
- value = 512;
-
- set_ub_edns_maximum_udp_payload_size(context, value);
+#ifdef HAVE_LIBUNBOUND
+ set_ub_number_opt(context, "edns-buffer-size:", value);
+#endif
if (value != context->edns_maximum_udp_payload_size) {
context->edns_maximum_udp_payload_size = value;
dispatch_updated(context,
@@ -2765,28 +3092,68 @@ getdns_context_set_memory_functions(struct getdns_context *context,
context, MF_PLAIN, mf.ext.malloc, mf.ext.realloc, mf.ext.free);
} /* getdns_context_set_memory_functions*/
-/* cancel the request */
-static void
-cancel_dns_req(getdns_dns_req *req)
+void
+_getdns_context_track_outbound_request(getdns_dns_req *dnsreq)
+{
+ /* Called only by getdns_general_ns() after successful allocation */
+ assert(dnsreq);
+
+ dnsreq->node.key = &(dnsreq->trans_id);
+ if (_getdns_rbtree_insert(
+ &dnsreq->context->outbound_requests, &dnsreq->node))
+ getdns_context_request_count_changed(dnsreq->context);
+}
+
+void
+_getdns_context_clear_outbound_request(getdns_dns_req *dnsreq)
+{
+ if (!dnsreq) return;
+
+ if (dnsreq->loop && dnsreq->loop->vmt && dnsreq->timeout.timeout_cb) {
+ dnsreq->loop->vmt->clear(dnsreq->loop, &dnsreq->timeout);
+ dnsreq->timeout.timeout_cb = NULL;
+ }
+ /* delete the node from the tree */
+ if (_getdns_rbtree_delete(
+ &dnsreq->context->outbound_requests, &dnsreq->trans_id))
+ getdns_context_request_count_changed(dnsreq->context);
+
+ if (dnsreq->chain)
+ _getdns_cancel_validation_chain(dnsreq);
+}
+
+void
+_getdns_context_cancel_request(getdns_dns_req *dnsreq)
{
getdns_network_req *netreq, **netreq_p;
- for (netreq_p = req->netreqs; (netreq = *netreq_p); netreq_p++)
+ DEBUG_SCHED("%s(%p)\n", __FUNC__, (void *)dnsreq);
+ if (!dnsreq) return;
+
+ _getdns_context_clear_outbound_request(dnsreq);
+
+ /* cancel network requests */
+ for (netreq_p = dnsreq->netreqs; (netreq = *netreq_p); netreq_p++)
#ifdef HAVE_LIBUNBOUND
if (netreq->unbound_id != -1) {
- ub_cancel(req->context->unbound_ctx,
+ ub_cancel(dnsreq->context->unbound_ctx,
netreq->unbound_id);
netreq->unbound_id = -1;
} else
#endif
_getdns_cancel_stub_request(netreq);
- req->canceled = 1;
+ /* clean up */
+ _getdns_dns_req_free(dnsreq);
}
+/*
+ * getdns_cancel_callback
+ *
+ */
getdns_return_t
-_getdns_context_cancel_request(getdns_context *context,
- getdns_transaction_t transaction_id, int fire_callback)
+getdns_cancel_callback(getdns_context *context,
+ getdns_transaction_t transaction_id)
{
getdns_dns_req *dnsreq;
@@ -2798,54 +3165,73 @@ _getdns_context_cancel_request(getdns_context *context,
&context->outbound_requests, &transaction_id)))
return GETDNS_RETURN_UNKNOWN_TRANSACTION;
- /* do the cancel */
- cancel_dns_req(dnsreq);
-
- if (fire_callback) {
- context->processing = 1;
- dnsreq->user_callback(context, GETDNS_CALLBACK_CANCEL,
- NULL, dnsreq->user_pointer, transaction_id);
- context->processing = 0;
- }
-
- /* clean up */
- _getdns_dns_req_free(dnsreq);
- return GETDNS_RETURN_GOOD;
-}
-
-/*
- * getdns_cancel_callback
- *
- */
-getdns_return_t
-getdns_cancel_callback(getdns_context *context,
- getdns_transaction_t transaction_id)
-{
- if (!context)
- return GETDNS_RETURN_INVALID_PARAMETER;
-
- getdns_return_t r = _getdns_context_cancel_request(context, transaction_id, 1);
getdns_context_request_count_changed(context);
- return r;
+
+ debug_req("CB Cancel ", *dnsreq->netreqs);
+ if (dnsreq->user_callback) {
+ dnsreq->context->processing = 1;
+ dnsreq->user_callback(dnsreq->context, GETDNS_CALLBACK_CANCEL,
+ NULL, dnsreq->user_pointer, dnsreq->trans_id);
+ dnsreq->context->processing = 0;
+ }
+ if (!dnsreq->internal_cb) { /* Not part of chain */
+ debug_req("Destroy ", *dnsreq->netreqs);
+ _getdns_context_cancel_request(dnsreq);
+ }
+ return GETDNS_RETURN_GOOD;
} /* getdns_cancel_callback */
-#ifndef STUB_NATIVE_DNSSEC
-static uint8_t*
-upstream_addr(getdns_upstream *upstream)
+void
+_getdns_context_request_timed_out(getdns_dns_req *dnsreq)
{
- return upstream->addr.ss_family == AF_INET
- ? (void *)&((struct sockaddr_in*)&upstream->addr)->sin_addr
- : (void *)&((struct sockaddr_in6*)&upstream->addr)->sin6_addr;
+ DEBUG_SCHED("%s(%p)\n", __FUNC__, (void *)dnsreq);
+
+ debug_req("CB Timeout ", *dnsreq->netreqs);
+ if (dnsreq->user_callback) {
+ dnsreq->context->processing = 1;
+ dnsreq->user_callback(dnsreq->context, GETDNS_CALLBACK_TIMEOUT,
+ _getdns_create_getdns_response(dnsreq),
+ dnsreq->user_pointer, dnsreq->trans_id);
+ dnsreq->context->processing = 0;
+ }
+ _getdns_context_cancel_request(dnsreq);
}
-static in_port_t
-upstream_port(getdns_upstream *upstream)
+static void
+accumulate_outstanding_transactions(_getdns_rbnode_t *node, void* arg)
{
- return ntohs(upstream->addr.ss_family == AF_INET
- ? ((struct sockaddr_in *)&upstream->addr)->sin_port
- : ((struct sockaddr_in6*)&upstream->addr)->sin6_port);
+ *(*(getdns_transaction_t**)arg)++ = ((getdns_dns_req*)node)->trans_id;
}
+static void
+cancel_outstanding_requests(getdns_context* context)
+{
+ getdns_transaction_t *trans_ids, *tids_a, *tids_i;
+
+ if (context->outbound_requests.count == 0)
+ return;
+
+ tids_i = tids_a = trans_ids = GETDNS_XMALLOC(context->my_mf,
+ getdns_transaction_t, context->outbound_requests.count);
+
+ _getdns_traverse_postorder(&context->outbound_requests,
+ accumulate_outstanding_transactions, &tids_a);
+
+ while (tids_i < tids_a) {
+
+ /* We have to cancel by transaction_id because we do not know
+ * what happens when the user_callback is called. It might
+ * delete getdns_dns_req's that were scheduled to be canceled.
+ * The extra lookup with transaction_id makes sure we do not
+ * access freed memory.
+ */
+ (void) getdns_cancel_callback(context, *tids_i++);
+ }
+ GETDNS_FREE(context->my_mf, trans_ids);
+}
+
+#ifndef STUB_NATIVE_DNSSEC
+
static uint32_t *
upstream_scope_id(getdns_upstream *upstream)
{
@@ -3020,7 +3406,7 @@ getdns_return_t
_getdns_context_prepare_for_resolution(struct getdns_context *context,
int usenamespaces)
{
- int i;
+ size_t i;
getdns_return_t r;
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
@@ -3052,7 +3438,7 @@ _getdns_context_prepare_for_resolution(struct getdns_context *context,
if(context->tls_ctx == NULL)
return GETDNS_RETURN_BAD_CONTEXT;
-# ifdef HAVE_TLS_CLIENT_METHOD
+# ifdef HAVE_SSL_CTX_SET_MIN_PROTO_VERSION
if (!SSL_CTX_set_min_proto_version(
context->tls_ctx, TLS1_2_VERSION)) {
SSL_CTX_free(context->tls_ctx);
@@ -3128,54 +3514,6 @@ _getdns_context_prepare_for_resolution(struct getdns_context *context,
return r;
} /* _getdns_context_prepare_for_resolution */
-getdns_return_t
-_getdns_context_track_outbound_request(getdns_dns_req *dnsreq)
-{
- if (!dnsreq)
- return GETDNS_RETURN_INVALID_PARAMETER;
-
- dnsreq->node.key = &(dnsreq->trans_id);
- if (!_getdns_rbtree_insert(
- &dnsreq->context->outbound_requests, &dnsreq->node))
- return GETDNS_RETURN_GENERIC_ERROR;
-
- getdns_context_request_count_changed(dnsreq->context);
- return GETDNS_RETURN_GOOD;
-}
-
-getdns_return_t
-_getdns_context_clear_outbound_request(getdns_dns_req *dnsreq)
-{
- if (!dnsreq)
- return GETDNS_RETURN_INVALID_PARAMETER;
-
- if (!_getdns_rbtree_delete(
- &dnsreq->context->outbound_requests, &dnsreq->trans_id))
- return GETDNS_RETURN_GENERIC_ERROR;
-
- getdns_context_request_count_changed(dnsreq->context);
- return GETDNS_RETURN_GOOD;
-}
-
-getdns_return_t
-_getdns_context_request_timed_out(getdns_dns_req *req)
-{
- /* Don't use req after callback */
- getdns_context* context = req->context;
- getdns_transaction_t trans_id = req->trans_id;
- getdns_callback_t cb = req->user_callback;
- void *user_arg = req->user_pointer;
- getdns_dict *response = _getdns_create_getdns_response(req);
-
- /* cancel the req - also clears it from outbound and cleans up*/
- _getdns_context_cancel_request(context, trans_id, 0);
- context->processing = 1;
- cb(context, GETDNS_CALLBACK_TIMEOUT, response, user_arg, trans_id);
- context->processing = 0;
- getdns_context_request_count_changed(context);
- return GETDNS_RETURN_GOOD;
-}
-
char *
_getdns_strdup(const struct mem_funcs *mfs, const char *s)
{
@@ -3257,33 +3595,6 @@ getdns_context_run(getdns_context *context)
context->extension->vmt->run(context->extension);
}
-typedef struct timeout_accumulator {
- getdns_transaction_t* ids;
- int idx;
-} timeout_accumulator;
-
-static void
-accumulate_outstanding_transactions(_getdns_rbnode_t* node, void* arg) {
- timeout_accumulator* acc = (timeout_accumulator*) arg;
- acc->ids[acc->idx] = *((getdns_transaction_t*) node->key);
- acc->idx++;
-}
-
-static void
-cancel_outstanding_requests(struct getdns_context* context, int fire_callback) {
- if (context->outbound_requests.count > 0) {
- timeout_accumulator acc;
- int i;
- acc.idx = 0;
- acc.ids = GETDNS_XMALLOC(context->my_mf, getdns_transaction_t, context->outbound_requests.count);
- _getdns_traverse_postorder(&context->outbound_requests, accumulate_outstanding_transactions, &acc);
- for (i = 0; i < acc.idx; ++i) {
- _getdns_context_cancel_request(context, acc.ids[i], fire_callback);
- }
- GETDNS_FREE(context->my_mf, acc.ids);
- }
-}
-
getdns_return_t
getdns_context_detach_eventloop(struct getdns_context* context)
{
@@ -3297,10 +3608,10 @@ getdns_context_detach_eventloop(struct getdns_context* context)
* and they may destroy the context )
*/
/* cancel all outstanding requests */
- cancel_outstanding_requests(context, 1);
+ cancel_outstanding_requests(context);
context->extension->vmt->cleanup(context->extension);
context->extension = &context->default_eventloop.loop;
- _getdns_default_eventloop_init(&context->default_eventloop);
+ _getdns_default_eventloop_init(&context->mf, &context->default_eventloop);
#ifdef HAVE_UNBOUND_EVENT_API
if (_getdns_ub_loop_enabled(&context->ub_loop))
context->ub_loop.extension = context->extension;
@@ -3315,7 +3626,7 @@ getdns_context_set_eventloop(getdns_context* context, getdns_eventloop* loop)
return GETDNS_RETURN_INVALID_PARAMETER;
if (context->extension) {
- cancel_outstanding_requests(context, 1);
+ cancel_outstanding_requests(context);
context->extension->vmt->cleanup(context->extension);
}
context->extension = loop;
@@ -3340,14 +3651,6 @@ getdns_context_get_eventloop(getdns_context *context, getdns_eventloop **loop)
return GETDNS_RETURN_GOOD;
}
-static in_port_t
-upstream_port(getdns_upstream *upstream)
-{
- return ntohs(upstream->addr.ss_family == AF_INET
- ? ((struct sockaddr_in *)&upstream->addr)->sin_port
- : ((struct sockaddr_in6*)&upstream->addr)->sin6_port);
-}
-
static getdns_dict*
_get_context_settings(getdns_context* context)
{
@@ -3359,10 +3662,12 @@ _get_context_settings(getdns_context* context)
return NULL;
/* int fields */
+ /* the timeouts are stored as uint64, but the value maximum used in
+ practice is 6553500ms, so we just trim the value to be on the safe side. */
if ( getdns_dict_set_int(result, "timeout",
- context->timeout)
+ (context->timeout > 0xFFFFFFFFull) ? 0xFFFFFFFF: (uint32_t) context->timeout)
|| getdns_dict_set_int(result, "idle_timeout",
- context->idle_timeout)
+ (context->idle_timeout > 0xFFFFFFFFull) ? 0xFFFFFFFF : (uint32_t) context->idle_timeout)
|| getdns_dict_set_int(result, "limit_outstanding_queries",
context->limit_outstanding_queries)
|| getdns_dict_set_int(result, "dnssec_allowed_skew",
@@ -3381,7 +3686,13 @@ _get_context_settings(getdns_context* context)
|| getdns_dict_set_int(result, "append_name",
context->append_name)
|| getdns_dict_set_int(result, "tls_authentication",
- context->tls_auth))
+ context->tls_auth)
+ || getdns_dict_set_int(result, "round_robin_upstreams",
+ context->round_robin_upstreams)
+ || getdns_dict_set_int(result, "tls_backoff_time",
+ context->tls_backoff_time)
+ || getdns_dict_set_int(result, "tls_connection_retries",
+ context->tls_connection_retries))
goto error;
/* list fields */
@@ -3506,7 +3817,7 @@ _getdns_context_local_namespace_resolve(
getdns_context *context = dnsreq->context;
host_name_addrs *hnas;
uint8_t lookup[256];
- getdns_list empty_list = { 0 };
+ getdns_list empty_list = { 0, 0, NULL, { NULL, {{ NULL, NULL, NULL }}}};
getdns_bindata bindata;
getdns_list *jaa;
size_t i;
@@ -3677,6 +3988,33 @@ getdns_context_get_tls_authentication(getdns_context *context,
return GETDNS_RETURN_GOOD;
}
+getdns_return_t
+getdns_context_get_round_robin_upstreams(getdns_context *context,
+ uint8_t* value) {
+ RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+ RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER);
+ *value = context->round_robin_upstreams;
+ return GETDNS_RETURN_GOOD;
+}
+
+getdns_return_t
+getdns_context_get_tls_backoff_time(getdns_context *context,
+ uint16_t* value) {
+ RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+ RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER);
+ *value = context->tls_backoff_time;
+ return GETDNS_RETURN_GOOD;
+}
+
+getdns_return_t
+getdns_context_get_tls_connection_retries(getdns_context *context,
+ uint16_t* value) {
+ RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
+ RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER);
+ *value = context->tls_connection_retries;
+ return GETDNS_RETURN_GOOD;
+}
+
getdns_return_t
getdns_context_get_limit_outstanding_queries(getdns_context *context,
uint16_t* value) {
@@ -3756,8 +4094,7 @@ getdns_context_get_suffix(getdns_context *context, getdns_list **value)
r = GETDNS_RETURN_GENERIC_ERROR;
break;
}
- if ((r = _getdns_list_append_const_bindata(
- list, strlen(name) + 1, name)))
+ if ((r = _getdns_list_append_string(list, name)))
break;
dname += dname_len;
dname_len = *dname++;
@@ -3906,7 +4243,8 @@ getdns_context_get_edns_maximum_udp_payload_size(getdns_context *context,
uint16_t* value) {
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
RETURN_IF_NULL(value, GETDNS_RETURN_INVALID_PARAMETER);
- *value = context->edns_maximum_udp_payload_size;
+ *value = context->edns_maximum_udp_payload_size == -1 ? 0
+ : context->edns_maximum_udp_payload_size;
return GETDNS_RETURN_GOOD;
}
@@ -4018,7 +4356,7 @@ static getdns_return_t _get_list_or_read_file(const getdns_dict *config_dict,
break; \
X[i] = (getdns_ ## T ## _t)n; \
} \
- r = getdns_context_set_ ##X (context, count, X); \
+ r = getdns_context_set_ ##X (context, i, X); \
}
#define EXTENSION_SETTING_BOOL(X) \
@@ -4073,6 +4411,9 @@ _getdns_context_config_setting(getdns_context *context,
CONTEXT_SETTING_INT(edns_client_subnet_private)
CONTEXT_SETTING_INT(tls_authentication)
+ CONTEXT_SETTING_INT(round_robin_upstreams)
+ CONTEXT_SETTING_INT(tls_backoff_time)
+ CONTEXT_SETTING_INT(tls_connection_retries)
CONTEXT_SETTING_INT(tls_query_padding_blocksize)
/**************************************/
diff --git a/src/context.h b/src/context.h
index 84a2c40c..03164522 100644
--- a/src/context.h
+++ b/src/context.h
@@ -45,6 +45,9 @@
#include "util/rbtree.h"
#include "ub_loop.h"
#include "server.h"
+#ifdef HAVE_MDNS_SUPPORT
+#include "util/lruhash.h"
+#endif
struct getdns_dns_req;
struct ub_ctx;
@@ -124,10 +127,36 @@ typedef struct getdns_upstream {
socklen_t addr_len;
struct sockaddr_storage addr;
+ char addr_str[INET6_ADDRSTRLEN];
- /* How is this upstream doing over UDP? */
- int to_retry;
- int back_off;
+ /**
+ * How is this upstream doing over UDP?
+ *
+ * to_retry = 1, back_off = 1, in context.c:upstream_init()
+ *
+ * When querying over UDP, first a upstream is selected which to_retry
+ * value > 0 in stub.c:upstream_select().
+ *
+ * Every time a udp request times out, to_retry is decreased, and if
+ * it reaches 0, it is set to minus back_off in
+ * stub.c:stub_next_upstream().
+ *
+ * to_retry will become > 0 again. because each time an upstream is
+ * selected for a UDP query in stub.c:upstream_select(), all to_retry
+ * counters <= 0 are incremented.
+ *
+ * On continuous failure, the stubs are less likely to be reselected,
+ * because each time to_retry is set to minus back_off, in
+ * stub.c:stub_next_upstream(), the back_off value is doubled.
+ *
+ * Finally, if all upstreams are failing, the upstreams with the
+ * smallest back_off value will be selected, and the back_off value
+ * decremented by one.
+ */
+ int to_retry; /* (initialized to 1) */
+ int back_off; /* (initialized to 1) */
+ size_t udp_responses;
+ size_t udp_timeouts;
/* For stateful upstreams, need to share the connection and track the
activity on the connection */
@@ -140,14 +169,18 @@ typedef struct getdns_upstream {
size_t conn_completed;
size_t conn_shutdowns;
size_t conn_setup_failed;
+ time_t conn_retry_time;
+ size_t conn_backoffs;
size_t total_responses;
size_t total_timeouts;
- getdns_auth_state_t past_tls_auth_state;
+ getdns_auth_state_t best_tls_auth_state;
+ getdns_auth_state_t last_tls_auth_state;
/* These are per connection. */
getdns_conn_state_t conn_state;
size_t queries_sent;
size_t responses_received;
size_t responses_timeouts;
+ size_t keepalive_shutdown;
uint64_t keepalive_timeout;
/* Management of outstanding requests on stateful transports */
@@ -203,11 +236,22 @@ typedef struct getdns_upstream {
} getdns_upstream;
+typedef struct getdns_log_config {
+ getdns_logfunc_type func;
+ void *userarg;
+ uint64_t system;
+ getdns_loglevel_type level;
+} getdns_log_config;
+
typedef struct getdns_upstreams {
struct mem_funcs mf;
size_t referenced;
size_t count;
size_t current_udp;
+ size_t current_stateful;
+ uint16_t tls_backoff_time;
+ uint16_t tls_connection_retries;
+ getdns_log_config log;
getdns_upstream upstreams[];
} getdns_upstreams;
@@ -215,7 +259,7 @@ struct getdns_context {
/* Context values */
getdns_resolution_t resolution_type;
getdns_namespace_t *namespaces;
- int namespace_count;
+ size_t namespace_count;
uint64_t timeout;
uint64_t idle_timeout;
getdns_redirects_t follow_redirects;
@@ -239,6 +283,9 @@ struct getdns_context {
uint32_t dnssec_allowed_skew;
getdns_tls_authentication_t tls_auth; /* What user requested for TLS*/
getdns_tls_authentication_t tls_auth_min; /* Derived minimum auth allowed*/
+ uint8_t round_robin_upstreams;
+ uint16_t tls_backoff_time;
+ uint16_t tls_connection_retries;
getdns_transport_list_t *dns_transports;
size_t dns_transport_count;
@@ -255,6 +302,8 @@ struct getdns_context {
getdns_update_callback2 update_callback2;
void *update_userarg;
+ getdns_log_config log;
+
int processing;
int destroying;
@@ -282,6 +331,14 @@ struct getdns_context {
*/
_getdns_rbtree_t outbound_requests;
+ /* network requests
+ */
+ size_t netreqs_in_flight;
+
+ _getdns_rbtree_t pending_netreqs;
+ getdns_network_req *first_pending_netreq;
+ getdns_eventloop_event pending_timeout_event;
+
struct listen_set *server;
/* Event loop extension. */
@@ -300,19 +357,19 @@ struct getdns_context {
/* request extension defaults */
getdns_dict *header;
getdns_dict *add_opt_parameters;
- int add_warning_for_bad_dns : 1;
- int dnssec_return_all_statuses : 1;
- int dnssec_return_full_validation_chain : 1;
- int dnssec_return_only_secure : 1;
- int dnssec_return_status : 1;
- int dnssec_return_validation_chain : 1;
+ unsigned add_warning_for_bad_dns : 1;
+ unsigned dnssec_return_all_statuses : 1;
+ unsigned dnssec_return_full_validation_chain : 1;
+ unsigned dnssec_return_only_secure : 1;
+ unsigned dnssec_return_status : 1;
+ unsigned dnssec_return_validation_chain : 1;
#ifdef DNSSEC_ROADBLOCK_AVOIDANCE
- int dnssec_roadblock_avoidance : 1;
+ unsigned dnssec_roadblock_avoidance : 1;
#endif
- int edns_cookies : 1;
- int return_api_information : 1; /* Not used */
- int return_both_v4_and_v6 : 1;
- int return_call_reporting : 1;
+ unsigned edns_cookies : 1;
+ unsigned return_api_information : 1; /* Not used */
+ unsigned return_both_v4_and_v6 : 1;
+ unsigned return_call_reporting : 1;
uint16_t specify_class;
/*
@@ -327,8 +384,32 @@ struct getdns_context {
/* We need to run WSAStartup() to be able to use getaddrinfo() */
WSADATA wsaData;
#endif
+
+ /* MDNS */
+#ifdef HAVE_MDNS_SUPPORT
+ /*
+ * If supporting MDNS, context may be instantiated either in basic mode
+ * or in full mode. If working in extended mode, two multicast sockets are
+ * left open, for IPv4 and IPv6. Data can be received on either socket.
+ * The context also keeps a list of open queries, characterized by a
+ * name and an RR type, and a list of received answers, characterized
+ * by name, RR type and data value.
+ */
+ int mdns_extended_support; /* 0 = no support, 1 = supported, 2 = initialization needed */
+ int mdns_connection_nb; /* typically 0 or 2 for IPv4 and IPv6 */
+ struct mdns_network_connection * mdns_connection;
+ struct lruhash * mdns_cache;
+
+#endif /* HAVE_MDNS_SUPPORT */
}; /* getdns_context */
+void _getdns_upstream_log(getdns_upstream *upstream, uint64_t system,
+ getdns_loglevel_type level, const char *fmt, ...);
+
+void _getdns_context_log(getdns_context *context, uint64_t system,
+ getdns_loglevel_type level, const char *fmt, ...);
+
+
/** internal functions **/
/**
* Sets up the unbound contexts with stub or recursive behavior
@@ -340,19 +421,33 @@ struct getdns_context {
getdns_return_t _getdns_context_prepare_for_resolution(struct getdns_context *context,
int usenamespaces);
-/* track an outbound request */
-getdns_return_t _getdns_context_track_outbound_request(struct getdns_dns_req
- *req);
-/* clear the outbound request from being tracked - does not cancel it */
-getdns_return_t _getdns_context_clear_outbound_request(struct getdns_dns_req
- *req);
+/* Register a getdns_dns_req with context.
+ * - Without pluggable unbound event API,
+ * ub_fd() is scheduled when this was the first request.
+ */
+void _getdns_context_track_outbound_request(getdns_dns_req *dnsreq);
-getdns_return_t _getdns_context_request_timed_out(struct getdns_dns_req
- *req);
+/* Deregister getdns_dns_req from the context.
+ * - Without pluggable unbound event API,
+ * ub_fd() is scheduled when this was the first request.
+ * - Potential timeout events will be cleared.
+ * - All associated getdns_dns_reqs (to get the validation chain)
+ * will be canceled.
+ */
+void _getdns_context_clear_outbound_request(getdns_dns_req *dnsreq);
-/* cancel callback internal - flag to indicate if req should be freed and callback fired */
-getdns_return_t _getdns_context_cancel_request(struct getdns_context *context,
- getdns_transaction_t transaction_id, int fire_callback);
+/* Cancels and frees a getdns_dns_req (without calling user callbacks)
+ * - Deregisters getdns_dns_req with _getdns_context_clear_outbound_request()
+ * - Cancels associated getdns_network_reqs
+ * (by calling ub_cancel() or _getdns_cancel_stub_request())
+ * - Frees the getdns_dns_req
+ */
+void _getdns_context_cancel_request(getdns_dns_req *dnsreq);
+
+/* Calls user callback (with GETDNS_CALLBACK_TIMEOUT + response dict), then
+ * cancels and frees the getdns_dns_req with _getdns_context_cancel_request()
+ */
+void _getdns_context_request_timed_out(getdns_dns_req *dnsreq);
char *_getdns_strdup(const struct mem_funcs *mfs, const char *str);
diff --git a/src/convert.c b/src/convert.c
index f0b4251d..180db8f5 100644
--- a/src/convert.c
+++ b/src/convert.c
@@ -57,9 +57,6 @@
#include "convert.h"
#include "debug.h"
-/* stuff to make it compile pedantically */
-#define UNUSED_PARAM(x) ((void)(x))
-
getdns_return_t
getdns_convert_dns_name_to_fqdn(
const getdns_bindata *dns_name_wire_fmt, char **fqdn_as_string)
@@ -154,6 +151,7 @@ getdns_convert_ulabel_to_alabel(const char *ulabel)
free(prepped2);
return buf;
#else
+ (void)ulabel;
return NULL;
#endif
}
@@ -183,6 +181,7 @@ getdns_convert_alabel_to_ulabel(const char *alabel)
}
return buf;
#else
+ (void)alabel;
return NULL;
#endif
}
@@ -289,7 +288,7 @@ getdns_rr_dict2wire_scan(
return GETDNS_RETURN_INVALID_PARAMETER;
- gldns_buffer_init_frm_data(&gbuf, *wire, *wire_sz);
+ gldns_buffer_init_vfixed_frm_data(&gbuf, *wire, *wire_sz);
if ((r = _getdns_rr_dict2wire(rr_dict, &gbuf)))
return r;
@@ -439,7 +438,7 @@ getdns_rr_dict2str_scan(
if (!rr_dict || !str || !*str || !str_len)
return GETDNS_RETURN_INVALID_PARAMETER;
- gldns_buffer_init_frm_data(&gbuf, buf, sizeof(buf_spc));
+ gldns_buffer_init_vfixed_frm_data(&gbuf, buf, sizeof(buf_spc));
r = _getdns_rr_dict2wire(rr_dict, &gbuf);
if (gldns_buffer_position(&gbuf) > sizeof(buf_spc)) {
if (!(buf = GETDNS_XMALLOC(
@@ -830,7 +829,6 @@ _getdns_reply_dict2wire(
}
}
remove_dnssec = !getdns_dict_get_int(reply, "/header/do", &n) && n == 0;
- DEBUG_SERVER("remove_dnssec: %d\n", remove_dnssec);
if (!getdns_dict_get_list(reply, "answer", §ion)) {
for ( n = 0, i = 0
@@ -953,7 +951,7 @@ getdns_msg_dict2wire_scan(
if (!msg_dict || !wire || !wire_sz || (!*wire && *wire_sz))
return GETDNS_RETURN_INVALID_PARAMETER;
- gldns_buffer_init_frm_data(&gbuf, *wire, *wire_sz);
+ gldns_buffer_init_vfixed_frm_data(&gbuf, *wire, *wire_sz);
if ((r = _getdns_msg_dict2wire_buf(msg_dict, &gbuf)))
return r;
@@ -1029,7 +1027,7 @@ getdns_msg_dict2str_scan(
if (!msg_dict || !str || !*str || !str_len)
return GETDNS_RETURN_INVALID_PARAMETER;
- gldns_buffer_init_frm_data(&gbuf, buf, sizeof(buf_spc));
+ gldns_buffer_init_vfixed_frm_data(&gbuf, buf, sizeof(buf_spc));
r = _getdns_msg_dict2wire_buf(msg_dict, &gbuf);
if (gldns_buffer_position(&gbuf) > sizeof(buf_spc)) {
if (!(buf = GETDNS_XMALLOC(
@@ -1066,7 +1064,7 @@ getdns_msg_dict2str_scan(
}
static getdns_dict *
-_getdns_ipaddr_dict_mf(struct mem_funcs *mf, char *ipstr)
+_getdns_ipaddr_dict_mf(struct mem_funcs *mf, const char *ipstr)
{
getdns_dict *r = _getdns_dict_create_with_mf(mf);
char *s = strchr(ipstr, '%'), *scope_id_str = "";
@@ -1187,7 +1185,7 @@ static int _jsmn_get_ipdict(struct mem_funcs *mf, const char *js, jsmntok_t *t,
char value_str[3072];
int size = t->end - t->start;
- if (size <= 0 || size >= sizeof(value_str))
+ if (size <= 0 || size >= (int)sizeof(value_str))
return 0;
(void) memcpy(value_str, js + t->start, size);
@@ -1197,21 +1195,81 @@ static int _jsmn_get_ipdict(struct mem_funcs *mf, const char *js, jsmntok_t *t,
return *value != NULL;
}
+static int _jsmn_get_base64_data(struct mem_funcs *mf, const char *js, jsmntok_t *t,
+ getdns_bindata **value)
+{
+ int e, i;
+ int size = t->end - t->start;
+ char value_str_buf[1025];
+ char *value_str;
+ size_t target_buf_size;
+
+ assert(size >= 4);
+
+ if (size % 4 != 0)
+ return 0;
+
+ e = t->end;
+ if (js[e - 1] == '=') e -= 1;
+ if (js[e - 1] == '=') e -= 1;
+
+ for (i = t->start; i < e; i++)
+ if (!((js[i] >= '0' && js[i] <= '9')
+ ||(js[i] >= 'a' && js[i] <= 'z')
+ ||(js[i] >= 'A' && js[i] <= 'Z')
+ || js[i] == '+' || js[i] == '/'))
+ return 0;
+
+ target_buf_size = gldns_b64_pton_calculate_size(size);
+ if (!(*value = GETDNS_MALLOC(*mf, getdns_bindata)))
+ return 0;
+
+ else if (!((*value)->data = GETDNS_XMALLOC(
+ *mf, uint8_t, target_buf_size))) {
+ GETDNS_FREE(*mf, *value);
+ return 0;
+ }
+ if ((size_t)size >= sizeof(value_str_buf))
+ value_str = GETDNS_XMALLOC(*mf, char, size + 1);
+ else value_str = value_str_buf;
+
+ if (value_str) {
+ (void) memcpy(value_str, js + t->start, size);
+ value_str[size] = '\0';
+
+ e = gldns_b64_pton(value_str, (*value)->data, target_buf_size);
+
+ if (value_str != value_str_buf)
+ GETDNS_FREE(*mf, value_str);
+
+ if (e > 0) {
+ (*value)->size = e;
+ return 1;
+ }
+ }
+ GETDNS_FREE(*mf, (*value)->data);
+ GETDNS_FREE(*mf, *value);
+ return 0;
+}
+
static int _jsmn_get_data(struct mem_funcs *mf, const char *js, jsmntok_t *t,
getdns_bindata **value)
{
- size_t i, j;
+ int i;
+ size_t j;
uint8_t h, l;
- if ((t->end - t->start) < 4 || (t->end - t->start) % 2 == 1 ||
- js[t->start] != '0' || js[t->start + 1] != 'x')
+ if ((t->end - t->start) < 4 || (t->end - t->start) % 2 == 1)
return 0;
+ if (js[t->start] != '0' || js[t->start + 1] != 'x')
+ return _jsmn_get_base64_data(mf, js, t, value);
+
for (i = t->start + 2; i < t->end; i++)
if (!((js[i] >= '0' && js[i] <= '9')
||(js[i] >= 'a' && js[i] <= 'f')
||(js[i] >= 'A' && js[i] <= 'F')))
- return 0;
+ return _jsmn_get_base64_data(mf, js, t, value);
if (!(*value = GETDNS_MALLOC(*mf, getdns_bindata)))
return 0;
@@ -1241,8 +1299,9 @@ static int _jsmn_get_dname(struct mem_funcs *mf, const char *js, jsmntok_t *t,
{
char value_str[1025];
int size = t->end - t->start;
+ (void)mf; /* TODO: Fix to use mf */
- if (size <= 0 || size >= sizeof(value_str) || js[t->end - 1] != '.')
+ if (size <= 0 || size >= (int)sizeof(value_str) || js[t->end - 1] != '.')
return 0;
(void) memcpy(value_str, js + t->start, size);
@@ -1258,7 +1317,7 @@ static int _jsmn_get_ipv4(struct mem_funcs *mf, const char *js, jsmntok_t *t,
int size = t->end - t->start;
uint8_t buf[4];
- if (size <= 0 || size >= sizeof(value_str))
+ if (size <= 0 || size >= (int)sizeof(value_str))
return 0;
(void) memcpy(value_str, js + t->start, size);
@@ -1288,7 +1347,7 @@ static int _jsmn_get_ipv6(struct mem_funcs *mf, const char *js, jsmntok_t *t,
int size = t->end - t->start;
uint8_t buf[16];
- if (size <= 0 || size >= sizeof(value_str))
+ if (size <= 0 || size >= (int)sizeof(value_str))
return 0;
(void) memcpy(value_str, js + t->start, size);
@@ -1311,14 +1370,13 @@ static int _jsmn_get_ipv6(struct mem_funcs *mf, const char *js, jsmntok_t *t,
return 0;
}
-static int _jsmn_get_int(struct mem_funcs *mf, const char *js, jsmntok_t *t,
- uint32_t *value)
+static int _jsmn_get_int(const char *js, jsmntok_t *t, uint32_t *value)
{
char value_str[11];
int size = t->end - t->start;
char *endptr;
- if (size <= 0 || size >= sizeof(value_str))
+ if (size <= 0 || size >= (int)sizeof(value_str))
return 0;
(void) memcpy(value_str, js + t->start, size);
@@ -1328,13 +1386,12 @@ static int _jsmn_get_int(struct mem_funcs *mf, const char *js, jsmntok_t *t,
return *value_str != '\0' && *endptr == '\0';
}
-static int _jsmn_get_const(struct mem_funcs *mf, const char *js, jsmntok_t *t,
- uint32_t *value)
+static int _jsmn_get_const(const char *js, jsmntok_t *t, uint32_t *value)
{
char value_str[80];
int size = t->end - t->start;
- if (size <= 0 || size >= sizeof(value_str))
+ if (size <= 0 || size >= (int)sizeof(value_str))
return 0;
(void) memcpy(value_str, js + t->start, size);
@@ -1368,7 +1425,8 @@ static int _jsmn_get_item(struct mem_funcs *mf, const char *js, jsmntok_t *t,
static int _jsmn_get_dict(struct mem_funcs *mf, const char *js, jsmntok_t *t,
size_t count, getdns_dict *dict, getdns_return_t *r)
{
- size_t i, j = 1;
+ int i;
+ size_t j = 1;
char key_spc[1024], *key = NULL;
getdns_item child_item;
@@ -1388,7 +1446,7 @@ static int _jsmn_get_dict(struct mem_funcs *mf, const char *js, jsmntok_t *t,
*r = GETDNS_RETURN_GENERIC_ERROR; /* range error */
break;
}
- if (t[j].end - t[j].start < sizeof(key_spc))
+ if (t[j].end - t[j].start < (int)sizeof(key_spc))
key = key_spc;
else if (!(key = GETDNS_XMALLOC(
@@ -1446,7 +1504,8 @@ static int _jsmn_get_dict(struct mem_funcs *mf, const char *js, jsmntok_t *t,
static int _jsmn_get_list(struct mem_funcs *mf, const char *js, jsmntok_t *t,
size_t count, getdns_list *list, getdns_return_t *r)
{
- size_t i, j = 1, index = 0;
+ int i;
+ size_t j = 1, index = 0;
getdns_item child_item;
if (t->size <= 0)
@@ -1525,8 +1584,8 @@ static int _jsmn_get_item(struct mem_funcs *mf, const char *js, jsmntok_t *t,
*r = GETDNS_RETURN_GENERIC_ERROR;
break;
- } else if (_jsmn_get_int(mf, js, t, &item->data.n)
- || _jsmn_get_const(mf, js, t, &item->data.n)) {
+ } else if (_jsmn_get_int(js, t, &item->data.n)
+ || _jsmn_get_const(js, t, &item->data.n)) {
item->dtype = t_int;
}
@@ -1607,6 +1666,31 @@ getdns_str2dict(const char *str, getdns_dict **dict)
getdns_item item;
getdns_return_t r;
+ if (!str || !dict)
+ return GETDNS_RETURN_INVALID_PARAMETER;
+
+ while (*str && isspace(*str))
+ str++;
+
+ if (*str != '{') {
+ char value_buf[3072], *value_str = value_buf;
+
+ if (strlen(str) > sizeof(value_str) - 1)
+ value_str = strdup(str);
+ else
+ (void)strncpy(value_buf, str, sizeof(value_buf));
+
+ getdns_dict *dict_r = _getdns_ipaddr_dict_mf(
+ &_getdns_plain_mem_funcs, value_str);
+
+ if (value_str != value_buf)
+ free(value_str);
+
+ if (dict_r) {
+ *dict = dict_r;
+ return GETDNS_RETURN_GOOD;
+ }
+ }
if ((r = _getdns_str2item_mf(&_getdns_plain_mem_funcs, str, &item)))
return r;
@@ -1664,6 +1748,9 @@ getdns_str2list(const char *str, getdns_list **list)
getdns_item item;
getdns_return_t r;
+ if (!str || !list)
+ return GETDNS_RETURN_INVALID_PARAMETER;
+
if ((r = _getdns_str2item_mf(&_getdns_plain_mem_funcs, str, &item)))
return r;
@@ -1681,6 +1768,9 @@ getdns_str2bindata(const char *str, getdns_bindata **bindata)
getdns_item item;
getdns_return_t r;
+ if (!str || !bindata)
+ return GETDNS_RETURN_INVALID_PARAMETER;
+
if ((r = _getdns_str2item_mf(&_getdns_plain_mem_funcs, str, &item)))
return r;
@@ -1698,6 +1788,9 @@ getdns_str2int(const char *str, uint32_t *value)
getdns_item item;
getdns_return_t r;
+ if (!str || !value)
+ return GETDNS_RETURN_INVALID_PARAMETER;
+
if ((r = _getdns_str2item_mf(&_getdns_plain_mem_funcs, str, &item)))
return r;
diff --git a/src/debug.h b/src/debug.h
index 91051435..f779840b 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -36,7 +36,6 @@
#define DEBUG_H
#include "config.h"
-
#define STUB_DEBUG_ENTRY "=> ENTRY: "
#define STUB_DEBUG_SETUP "--- SETUP: "
#define STUB_DEBUG_SETUP_TLS "--- SETUP(TLS): "
@@ -46,6 +45,21 @@
#define STUB_DEBUG_WRITE "------- WRITE: "
#define STUB_DEBUG_CLEANUP "--- CLEANUP: "
+#ifdef GETDNS_ON_WINDOWS
+#define DEBUG_ON(...) do { \
+ struct timeval tv; \
+ struct tm tm; \
+ char buf[10]; \
+ time_t tsec; \
+ \
+ gettimeofday(&tv, NULL); \
+ tsec = (time_t) tv.tv_sec; \
+ gmtime_s(&tm, (const time_t *) &tsec); \
+ strftime(buf, 10, "%H:%M:%S", &tm); \
+ fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \
+ fprintf(stderr, __VA_ARGS__); \
+ } while (0)
+#else
#define DEBUG_ON(...) do { \
struct timeval tv; \
struct tm tm; \
@@ -57,6 +71,7 @@
fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \
fprintf(stderr, __VA_ARGS__); \
} while (0)
+#endif
#define DEBUG_NL(...) do { \
struct timeval tv; \
@@ -74,6 +89,31 @@
#define DEBUG_OFF(...) do {} while (0)
+#if defined(REQ_DEBUG) && REQ_DEBUG
+#include
+#define DEBUG_REQ(...) DEBUG_ON(__VA_ARGS__)
+#include "gldns/wire2str.h"
+#include "rr-dict.h"
+#include "types-internal.h"
+static inline void debug_req(const char *msg, getdns_network_req *netreq)
+{
+ char str[1024];
+ struct timeval tv;
+ uint64_t t;
+
+ (void) gettimeofday(&tv, NULL);
+ t = tv.tv_sec * 1000 + tv.tv_usec / 1000;
+ t = t >= netreq->owner->expires ? 0 : netreq->owner->expires - t;
+ (void) gldns_wire2str_dname_buf(netreq->owner->name,
+ netreq->owner->name_len, str, sizeof(str));
+ DEBUG_REQ("NETREQ %s %4"PRIu64" %s %s\n", msg, t,
+ str, _getdns_rr_type_name(netreq->request_type));
+}
+#else
+#define DEBUG_REQ(...) DEBUG_OFF(__VA_ARGS__)
+#define debug_req(...) DEBUG_OFF(__VA_ARGS__)
+#endif
+
#if defined(SCHED_DEBUG) && SCHED_DEBUG
#include
#define DEBUG_SCHED(...) DEBUG_ON(__VA_ARGS__)
@@ -88,6 +128,13 @@
#define DEBUG_STUB(...) DEBUG_OFF(__VA_ARGS__)
#endif
+#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
+#include
+#define DEBUG_DAEMON(...) DEBUG_ON(__VA_ARGS__)
+#else
+#define DEBUG_DAEMON(...) DEBUG_OFF(__VA_ARGS__)
+#endif
+
#if defined(SEC_DEBUG) && SEC_DEBUG
#include
#define DEBUG_SEC(...) DEBUG_ON(__VA_ARGS__)
@@ -102,5 +149,28 @@
#define DEBUG_SERVER(...) DEBUG_OFF(__VA_ARGS__)
#endif
+#define MDNS_DEBUG_ENTRY "-> MDNS ENTRY: "
+#define MDNS_DEBUG_READ "-- MDNS READ: "
+#define MDNS_DEBUG_MREAD "-- MDNS MREAD: "
+#define MDNS_DEBUG_WRITE "-- MDNS WRITE: "
+#define MDNS_DEBUG_CLEANUP "-- MDNS CLEANUP:"
+
+#if defined(MDNS_DEBUG) && MDNS_DEBUG
+#include
+#define DEBUG_MDNS(...) DEBUG_ON(__VA_ARGS__)
+#else
+#define DEBUG_MDNS(...) DEBUG_OFF(__VA_ARGS__)
+#endif
+
+#if (defined(REQ_DEBUG) && REQ_DEBUG) || \
+ (defined(SCHED_DEBUG) && SCHED_DEBUG) || \
+ (defined(STUB_DEBUG) && STUB_DEBUG) || \
+ (defined(DAEMON_DEBUG) && DAEMON_DEBUG) || \
+ (defined(SEC_DEBUG) && SEC_DEBUG) || \
+ (defined(SERVER_DEBUG) && SERVER_DEBUG) || \
+ (defined(MDNS_DEBUG) && MDNS_DEBUG)
+#define DEBUGGING 1
+#endif
+
#endif
/* debug.h */
diff --git a/src/dict.c b/src/dict.c
index e7294e62..d6986788 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -51,10 +51,11 @@
#include "const-info.h"
#include "gldns/gbuffer.h"
#include "gldns/wire2str.h"
+#include "gldns/parseutil.h"
static char *_json_ptr_first(const struct mem_funcs *mf,
- const char *jptr, char *first, size_t first_sz)
+ const char *jptr, char *first, ssize_t first_sz)
{
const char *next_ref, *k;
char *j;
@@ -65,7 +66,7 @@ static char *_json_ptr_first(const struct mem_funcs *mf,
if (!(next_ref = strchr(jptr, '/')))
next_ref = strchr(jptr, '\0');
- if (next_ref - jptr + 1 > first_sz || !first)
+ if ((ssize_t)(next_ref - jptr + 1) > first_sz || !first)
first = GETDNS_XMALLOC(*mf, char, next_ref - jptr + 1);
for (j = first, k = jptr; k < next_ref; j++, k++)
@@ -731,18 +732,44 @@ _getdns_bindata_is_dname(getdns_bindata *bindata)
bindata->data[bindata->size - 1] == 0;
}
+static int
+getdns_pp_base64(gldns_buffer *buf, getdns_bindata *bindata)
+{
+ size_t p = gldns_buffer_position(buf);
+ size_t base64str_sz;
+ char *target;
+ size_t avail;
+
+ if (gldns_buffer_printf(buf, " size);
+ target = (char *)gldns_buffer_current(buf);
+ avail = gldns_buffer_remaining(buf);
+ if (avail >= base64str_sz)
+ gldns_buffer_skip(buf, gldns_b64_ntop(
+ bindata->data, bindata->size,
+ target, base64str_sz));
+ else
+ gldns_buffer_skip(buf, base64str_sz);
+
+ if (gldns_buffer_printf(buf, ">") < 0)
+ return -1;
+
+ return gldns_buffer_position(buf) - p;
+}
+
/*---------------------------------------- getdns_pp_bindata */
/**
* private function to pretty print bindata to a gldns_buffer
* @param buf buffer to write to
- * @param indent number of spaces to append after newline
* @param bindata the bindata to print
* @return on success the number of written characters
* if an output error is encountered, a negative value
*/
static int
-getdns_pp_bindata(gldns_buffer *buf, size_t indent,
- getdns_bindata *bindata, int rdata_raw, int json)
+getdns_pp_bindata(gldns_buffer *buf, getdns_bindata *bindata,
+ int rdata_raw, int json)
{
size_t i, p = gldns_buffer_position(buf);
uint8_t *dptr;
@@ -887,7 +914,7 @@ getdns_pp_list(gldns_buffer *buf, size_t indent, const getdns_list *list,
GETDNS_RETURN_GOOD)
return -1;
if (getdns_pp_bindata(
- buf, indent, bindata_item, 0, json) < 0)
+ buf, bindata_item, 0, json) < 0)
return -1;
break;
@@ -1095,8 +1122,18 @@ getdns_pp_dict(gldns_buffer * buf, size_t indent,
)) < 0)
return -1;
+ } else if (!json &&
+ (strcmp(item->node.key, "pin-sha256") == 0 ||
+ strcmp(item->node.key, "value") == 0) &&
+ item->i.data.bindata->size > 0 &&
+ item->i.data.bindata->size % 4 == 0) {
+
+ if (getdns_pp_base64(buf,
+ item->i.data.bindata) < 0)
+ return -1;
+
} else if (getdns_pp_bindata(
- buf, indent, item->i.data.bindata,
+ buf, item->i.data.bindata,
(strcmp(item->node.key, "rdata_raw") == 0),
json) < 0)
return -1;
@@ -1187,9 +1224,9 @@ getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict)
if (!dict) return -1;
- gldns_buffer_init_frm_data(&buf, str, size);
+ gldns_buffer_init_vfixed_frm_data(&buf, str, size);
return getdns_pp_dict(&buf, 0, dict, 0) < 0
- ? -1 : gldns_buffer_position(&buf);
+ ? -1 : (int)gldns_buffer_position(&buf);
}
char *
@@ -1221,9 +1258,9 @@ getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list)
if (!list) return -1;
- gldns_buffer_init_frm_data(&buf, str, size);
+ gldns_buffer_init_vfixed_frm_data(&buf, str, size);
return getdns_pp_list(&buf, 0, list, 0, 0) < 0
- ? -1 : gldns_buffer_position(&buf);
+ ? -1 : (int)gldns_buffer_position(&buf);
}
char *
@@ -1256,9 +1293,9 @@ getdns_snprint_json_dict(
if (!dict) return -1;
- gldns_buffer_init_frm_data(&buf, str, size);
+ gldns_buffer_init_vfixed_frm_data(&buf, str, size);
return getdns_pp_dict(&buf, 0, dict, pretty ? 1 : 2) < 0
- ? -1 : gldns_buffer_position(&buf);
+ ? -1 : (int)gldns_buffer_position(&buf);
}
char *
@@ -1291,9 +1328,9 @@ getdns_snprint_json_list(
if (!list) return -1;
- gldns_buffer_init_frm_data(&buf, str, size);
+ gldns_buffer_init_vfixed_frm_data(&buf, str, size);
return getdns_pp_list(&buf, 0, list, 0, pretty ? 1 : 2) < 0
- ? -1 : gldns_buffer_position(&buf);
+ ? -1 : (int)gldns_buffer_position(&buf);
}
/* dict.c */
diff --git a/src/dnssec.c b/src/dnssec.c
index 2622701d..61b3161a 100644
--- a/src/dnssec.c
+++ b/src/dnssec.c
@@ -256,7 +256,7 @@ static uint8_t *_dname_label_copy(uint8_t *dst, const uint8_t *src, size_t dst_l
{
uint8_t *r = dst, i;
- if (!src || *src + 1 > dst_len)
+ if (!src || (size_t)*src + 1 > dst_len)
return NULL;
for (i = (*dst++ = *src++); i ; i--)
@@ -528,7 +528,7 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf,
chain_head *head;
const uint8_t *labels[128], **last_label, **label;
- size_t max_labels; /* max labels in common */
+ ssize_t max_labels; /* max labels in common */
chain_head *max_head;
chain_node *max_node;
@@ -550,16 +550,31 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf,
/* Also, try to prevent adding double rrsets */
if ( rrset->rr_class == head->rrset.rr_class
&& rrset->rr_type == head->rrset.rr_type
- && rrset->pkt == head->rrset.pkt
- && rrset->pkt_len == head->rrset.pkt_len
- && _dname_equal(rrset->name, head->rrset.name))
- return NULL;
+ && _dname_equal(rrset->name, head->rrset.name)) {
+ if (rrset->pkt == head->rrset.pkt &&
+ rrset->pkt_len == head->rrset.pkt_len)
+ return NULL;
+ else {
+ /* Anticipate resubmissions due to
+ * roadblock avoidance */
+ head->rrset.pkt = rrset->pkt;
+ head->rrset.pkt_len = rrset->pkt_len;
+ return head;
+ }
+ }
+
+ if ( rrset->rr_class == head->rrset.rr_class
+ && rrset->rr_type == head->rrset.rr_type
+ && rrset->pkt != head->rrset.pkt
+ && _dname_equal(rrset->name, head->rrset.name)) {
+ return NULL;
+ }
for (label = labels; label < last_label; label++) {
if (! _dname_is_parent(*label, head->rrset.name))
break;
}
- if (label - labels > max_labels) {
+ if ((ssize_t)(label - labels) > max_labels) {
max_labels = label - labels;
max_head = head;
}
@@ -616,6 +631,11 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf,
head->node_count = node_count;
if (!node_count) {
+ /* When this head has no nodes of itself, it must have found
+ * another head which has nodes for its labels (i.e. max_head)
+ */
+ assert(max_head != NULL);
+
head->parent = max_head->parent;
return head;
}
@@ -857,6 +877,7 @@ static getdns_dict *CD_extension(getdns_dns_req *dnsreq)
? dnssec_ok_checking_disabled_roadblock_avoidance
: dnssec_ok_checking_disabled_avoid_roadblocks;
#else
+ (void)dnsreq;
return dnssec_ok_checking_disabled;
#endif
}
@@ -1038,13 +1059,13 @@ static void val_chain_node_cb(getdns_dns_req *dnsreq)
_getdns_rrsig_iter *rrsig, rrsig_spc;
size_t n_signers;
- _getdns_context_clear_outbound_request(dnsreq);
switch (netreq->request_type) {
case GETDNS_RRTYPE_DS : node->ds.pkt = netreq->response;
node->ds.pkt_len = netreq->response_len;
break;
case GETDNS_RRTYPE_DNSKEY: node->dnskey.pkt = netreq->response;
node->dnskey.pkt_len = netreq->response_len;
+ /* fallthrough */
default : check_chain_complete(node->chains);
return;
}
@@ -1088,7 +1109,9 @@ static void val_chain_node_soa_cb(getdns_dns_req *dnsreq)
_getdns_rrset_iter i_spc, *i;
_getdns_rrset *rrset;
- _getdns_context_clear_outbound_request(dnsreq);
+ /* A SOA query is always scheduled with a node as the user argument.
+ */
+ assert(node != NULL);
for ( i = _getdns_rrset_iter_init(&i_spc, netreq->response
, netreq->response_len
@@ -1097,10 +1120,8 @@ static void val_chain_node_soa_cb(getdns_dns_req *dnsreq)
; i = _getdns_rrset_iter_next(i)) {
rrset = _getdns_rrset_iter_value(i);
- if (rrset->rr_type == GETDNS_RRTYPE_SOA)
- break;
- }
- if (i) {
+ if (rrset->rr_type != GETDNS_RRTYPE_SOA)
+ continue;
while (node &&
! _dname_equal(node->ds.name, rrset->name))
@@ -1112,11 +1133,14 @@ static void val_chain_node_soa_cb(getdns_dns_req *dnsreq)
} else {
/* SOA for a different name */
node = (chain_node *)dnsreq->user_pointer;
- node->lock++;
- val_chain_sched_soa_node(node->parent);
+ if (node->parent) {
+ node->lock++;
+ val_chain_sched_soa_node(node->parent);
+ }
}
-
- } else if (node->parent) {
+ break;
+ }
+ if (!i && node->parent) {
node->lock++;
val_chain_sched_soa_node(node->parent);
}
@@ -1314,7 +1338,7 @@ static int _rr_iter_rdata_cmp(const void *a, const void *b)
* When the rrset was a wildcard expansion (rrsig labels < labels owner name),
* nc_name will be set to the next closer (within rrset->name).
*/
-#define VAL_RRSET_SPC_SZ 1024
+#define VAL_RRSET_SPC_SZ 256
static int _getdns_verify_rrsig(struct mem_funcs *mf,
_getdns_rrset *rrset, _getdns_rrsig_iter *rrsig, _getdns_rrtype_iter *key, const uint8_t **nc_name)
{
@@ -1626,7 +1650,7 @@ static int nsec3_iteration_count_high(_getdns_rrtype_iter *dnskey, _getdns_rrset
return gldns_read_uint16(rr->rr_i.rr_type + 12) > 150;
}
-static int check_dates(int32_t now, int32_t skew, int32_t exp, int32_t inc)
+static int check_dates(time_t now, int32_t skew, int32_t exp, int32_t inc)
{
return (exp - inc > 0) && (inc - now < skew) && (now - exp < skew);
}
@@ -1871,7 +1895,7 @@ static int ds_authenticates_keys(struct mem_funcs *mf,
max_supported_digest = ds->rr_i.rr_type[13];
max_supported_result = 0;
- if (digest_len != ds->rr_i.nxt - ds->rr_i.rr_type-14
+ if ((int)digest_len != ds->rr_i.nxt - ds->rr_i.rr_type-14
|| memcmp(digest, ds->rr_i.rr_type+14, digest_len) != 0) {
if (digest != digest_spc)
GETDNS_FREE(*mf, digest);
@@ -2408,6 +2432,7 @@ static int key_proves_nonexistance(
* ========================+
* First find the closest encloser.
*/
+ if (*rrset->name)
for ( nc_name = rrset->name, ce_name = rrset->name + *rrset->name + 1
; *ce_name ; nc_name = ce_name, ce_name += *ce_name + 1) {
@@ -2670,6 +2695,7 @@ static int chain_head_validate(struct mem_funcs *mf, time_t now, uint32_t skew,
if (_getdns_rrset_has_rrs(&ds_ta)) {
switch (chain_head_validate_with_ta(mf,now,skew,head,&ds_ta)) {
case GETDNS_DNSSEC_SECURE : s = GETDNS_DNSSEC_SECURE;
+ /* fallthrough */
case GETDNS_DNSSEC_INSECURE: if (s != GETDNS_DNSSEC_SECURE)
s = GETDNS_DNSSEC_INSECURE;
break;
@@ -2687,6 +2713,7 @@ static int chain_head_validate(struct mem_funcs *mf, time_t now, uint32_t skew,
* evaluated by processing each head in turn. The worst outcome per network request
* is the dnssec status for that network request.
*/
+#ifdef STUB_NATIVE_DNSSEC
static void chain_set_netreq_dnssec_status(chain_head *chain, _getdns_rrset_iter *tas)
{
chain_head *head;
@@ -2723,6 +2750,7 @@ static void chain_set_netreq_dnssec_status(chain_head *chain, _getdns_rrset_iter
}
}
}
+#endif
/* The DNSSEC status of all heads for a chain structure is evaluated by
* processing each head in turn. The worst outcome is the dnssec status for
@@ -3087,18 +3115,50 @@ static void check_chain_complete(chain_head *chain)
&& !dnsreq->avoid_dnssec_roadblocks
&& dnsreq->netreqs[0]->dnssec_status == GETDNS_DNSSEC_BOGUS) {
- int r = GETDNS_RETURN_GOOD;
getdns_network_req **netreq_p, *netreq;
+ uint64_t now_ms = 0;
dnsreq->avoid_dnssec_roadblocks = 1;
+ dnsreq->chain->lock += 1;
for ( netreq_p = dnsreq->netreqs
- ; !r && (netreq = *netreq_p)
+ ; (netreq = *netreq_p)
; netreq_p++) {
- netreq->state = NET_REQ_NOT_SENT;
+ _getdns_netreq_change_state(netreq, NET_REQ_NOT_SENT);
+ netreq->dnssec_status =
+ GETDNS_DNSSEC_INDETERMINATE;
netreq->owner = dnsreq;
- r = _getdns_submit_netreq(netreq);
+ (void) _getdns_submit_netreq(netreq, &now_ms);
+ }
+ if (!dnsreq->dnssec_return_validation_chain)
+ return;
+
+ for ( head = chain; head ; head = next ) {
+ next = head->next;
+ for ( node_count = head->node_count
+ , node = head->parent
+ ; node_count
+ ; node_count--, node = node->parent ) {
+
+ if (node->dnskey_req) {
+ _getdns_netreq_change_state(
+ node->dnskey_req,
+ NET_REQ_NOT_SENT);
+ node->dnskey_req->owner->
+ avoid_dnssec_roadblocks = 1;
+ (void) _getdns_submit_netreq(
+ node->dnskey_req, &now_ms);
+ }
+ if (node->ds_req) {
+ _getdns_netreq_change_state(
+ node->ds_req, NET_REQ_NOT_SENT);
+ node->ds_req->owner->
+ avoid_dnssec_roadblocks = 1;
+ (void) _getdns_submit_netreq(
+ node->ds_req, &now_ms);
+ }
+ }
}
return;
}
@@ -3121,17 +3181,89 @@ static void check_chain_complete(chain_head *chain)
_getdns_call_user_callback(dnsreq, response_dict);
}
+void _getdns_validation_chain_timeout(getdns_dns_req *dnsreq)
+{
+ chain_head *head = dnsreq->chain, *next;
+ chain_node *node;
+ size_t node_count;
+
+ while (head) {
+ next = head->next;
+
+ for ( node_count = head->node_count, node = head->parent
+ ; node_count
+ ; node_count--, node = node->parent ) {
+
+ if (!_getdns_netreq_finished(node->dnskey_req)) {
+ _getdns_context_cancel_request(
+ node->dnskey_req->owner);
+ node->dnskey_req = NULL;
+ }
+
+ if (!_getdns_netreq_finished(node->ds_req)) {
+ _getdns_context_cancel_request(
+ node->ds_req->owner);
+ node->ds_req = NULL;
+ }
+
+ if (!_getdns_netreq_finished(node->soa_req)) {
+ _getdns_context_cancel_request(
+ node->soa_req->owner);
+ node->soa_req = NULL;
+ }
+ }
+ head = next;
+ }
+ dnsreq->request_timed_out = 1;
+ check_chain_complete(dnsreq->chain);
+}
+
+void _getdns_cancel_validation_chain(getdns_dns_req *dnsreq)
+{
+ chain_head *head = dnsreq->chain, *next;
+ chain_node *node;
+ size_t node_count;
+
+ dnsreq->chain = NULL;
+ while (head) {
+ next = head->next;
+
+ for ( node_count = head->node_count, node = head->parent
+ ; node_count
+ ; node_count--, node = node->parent ) {
+
+ if (node->dnskey_req)
+ _getdns_context_cancel_request(
+ node->dnskey_req->owner);
+
+ if (node->ds_req)
+ _getdns_context_cancel_request(
+ node->ds_req->owner);
+
+ if (node->soa_req)
+ _getdns_context_cancel_request(
+ node->soa_req->owner);
+ }
+ GETDNS_FREE(head->my_mf, head);
+ head = next;
+ }
+}
void _getdns_get_validation_chain(getdns_dns_req *dnsreq)
{
getdns_network_req *netreq, **netreq_p;
chain_head *chain = NULL, *chain_p;
- if (dnsreq->validating)
+ if (dnsreq->avoid_dnssec_roadblocks) {
+ chain = dnsreq->chain;
+
+ } else if (dnsreq->validating)
return;
dnsreq->validating = 1;
- for (netreq_p = dnsreq->netreqs; (netreq = *netreq_p) ; netreq_p++) {
+ if (dnsreq->avoid_dnssec_roadblocks && chain->lock == 0)
+ ; /* pass */
+ else for (netreq_p = dnsreq->netreqs; (netreq = *netreq_p) ; netreq_p++) {
if (! netreq->response
|| netreq->response_len < GLDNS_HEADER_SIZE
|| ( GLDNS_RCODE_WIRE(netreq->response)
@@ -3158,6 +3290,10 @@ void _getdns_get_validation_chain(getdns_dns_req *dnsreq)
for (chain_p = chain; chain_p; chain_p = chain_p->next) {
if (chain_p->lock) chain_p->lock--;
}
+ dnsreq->chain = chain;
+ if (dnsreq->avoid_dnssec_roadblocks && chain->lock)
+ chain->lock -= 1;
+
check_chain_complete(chain);
} else {
dnsreq->validating = 0;
diff --git a/src/dnssec.h b/src/dnssec.h
index 4237f933..b0334d52 100644
--- a/src/dnssec.h
+++ b/src/dnssec.h
@@ -46,6 +46,8 @@
/* Do some additional requests to fetch the complete validation chain */
void _getdns_get_validation_chain(getdns_dns_req *dns_req);
+void _getdns_cancel_validation_chain(getdns_dns_req *dns_req);
+void _getdns_validation_chain_timeout(getdns_dns_req *dns_req);
uint16_t _getdns_parse_ta_file(time_t *ta_mtime, gldns_buffer *gbuf);
diff --git a/src/extension/default_eventloop.h b/src/extension/default_eventloop.h
index 7f6b78f0..7b611349 100644
--- a/src/extension/default_eventloop.h
+++ b/src/extension/default_eventloop.h
@@ -1,6 +1,6 @@
/*
* \file default_eventloop.h
- * @brief Build in default eventloop extension that uses select.
+ * @brief Build in default eventloop extension that uses either poll or select.
*
*/
/*
@@ -32,28 +32,13 @@
#ifndef DEFAULT_EVENTLOOP_H_
#define DEFAULT_EVENTLOOP_H_
#include "config.h"
-#include "getdns/getdns.h"
-#include "getdns/getdns_extra.h"
-
-/* No more than select's capability queries can be outstanding,
- * The number of outstanding timeouts should be less or equal then
- * the number of outstanding queries, so MAX_TIMEOUTS equal to
- * FD_SETSIZE should be safe.
- */
-#define MAX_TIMEOUTS FD_SETSIZE
-
-/* Eventloop based on select */
-typedef struct _getdns_default_eventloop {
- getdns_eventloop loop;
- getdns_eventloop_event *fd_events[FD_SETSIZE];
- uint64_t fd_timeout_times[FD_SETSIZE];
- getdns_eventloop_event *timeout_events[MAX_TIMEOUTS];
- uint64_t timeout_times[MAX_TIMEOUTS];
-} _getdns_default_eventloop;
-
-
-void
-_getdns_default_eventloop_init(_getdns_default_eventloop *loop);
-
+#ifdef USE_POLL_DEFAULT_EVENTLOOP
+#include "extension/poll_eventloop.h"
+#define _getdns_default_eventloop _getdns_poll_eventloop
+#define _getdns_default_eventloop_init _getdns_poll_eventloop_init
+#else
+#include "extension/select_eventloop.h"
+#define _getdns_default_eventloop _getdns_select_eventloop
+#define _getdns_default_eventloop_init _getdns_select_eventloop_init
+#endif
#endif
-
diff --git a/src/extension/libev.c b/src/extension/libev.c
index 6a8c26e9..ff36b5c2 100644
--- a/src/extension/libev.c
+++ b/src/extension/libev.c
@@ -97,6 +97,7 @@ static void
getdns_libev_read_cb(struct ev_loop *l, struct ev_io *io, int revents)
{
getdns_eventloop_event *el_ev = (getdns_eventloop_event *)io->data;
+ (void)l; (void)revents;
assert(el_ev->read_cb);
el_ev->read_cb(el_ev->userarg);
}
@@ -105,14 +106,16 @@ static void
getdns_libev_write_cb(struct ev_loop *l, struct ev_io *io, int revents)
{
getdns_eventloop_event *el_ev = (getdns_eventloop_event *)io->data;
+ (void)l; (void)revents;
assert(el_ev->write_cb);
el_ev->write_cb(el_ev->userarg);
}
static void
-getdns_libev_timeout_cb(struct ev_loop *l, struct ev_timer *timer, int revent)
+getdns_libev_timeout_cb(struct ev_loop *l, struct ev_timer *timer, int revents)
{
getdns_eventloop_event *el_ev = (getdns_eventloop_event *)timer->data;
+ (void)l; (void)revents;
assert(el_ev->timeout_cb);
el_ev->timeout_cb(el_ev->userarg);
}
diff --git a/src/extension/libevent.c b/src/extension/libevent.c
index 800ebe8e..d096d347 100644
--- a/src/extension/libevent.c
+++ b/src/extension/libevent.c
@@ -95,6 +95,7 @@ static getdns_return_t
getdns_libevent_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev)
{
struct event *my_ev = (struct event *)el_ev->ev;
+ (void)loop;
assert(my_ev);
@@ -110,6 +111,7 @@ static void
getdns_libevent_callback(evutil_socket_t fd, short bits, void *arg)
{
getdns_eventloop_event *el_ev = (getdns_eventloop_event *)arg;
+ (void)fd;
if (bits & EV_READ) {
assert(el_ev->read_cb);
diff --git a/src/extension/libuv.c b/src/extension/libuv.c
index adf97835..ec9257be 100644
--- a/src/extension/libuv.c
+++ b/src/extension/libuv.c
@@ -104,6 +104,7 @@ getdns_libuv_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev)
poll_timer *my_ev = (poll_timer *)el_ev->ev;
uv_poll_t *my_poll;
uv_timer_t *my_timer;
+ (void)loop;
assert(my_ev);
@@ -141,6 +142,7 @@ static void
getdns_libuv_read_cb(uv_poll_t *poll, int status, int events)
{
getdns_eventloop_event *el_ev = (getdns_eventloop_event *)poll->data;
+ (void)status; (void)events;
assert(el_ev->read_cb);
DEBUG_UV("enter libuv_read_cb(el_ev = %p, el_ev->ev = %p)\n"
, el_ev, el_ev->ev);
@@ -153,6 +155,7 @@ static void
getdns_libuv_write_cb(uv_poll_t *poll, int status, int events)
{
getdns_eventloop_event *el_ev = (getdns_eventloop_event *)poll->data;
+ (void)status; (void)events;
assert(el_ev->write_cb);
DEBUG_UV("enter libuv_write_cb(el_ev = %p, el_ev->ev = %p)\n"
, el_ev, el_ev->ev);
diff --git a/src/extension/poll_eventloop.c b/src/extension/poll_eventloop.c
new file mode 100644
index 00000000..e796de10
--- /dev/null
+++ b/src/extension/poll_eventloop.c
@@ -0,0 +1,551 @@
+/*
+ * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
+ * All rights reserved.
+ *
+ * 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 names of the copyright holders 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 Verisign, Inc. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#ifdef HAVE_SYS_POLL_H
+#include
+#else
+#ifndef USE_WINSOCK
+#include
+#endif
+#endif
+#ifdef HAVE_SYS_RESOURCE_H
+#include
+#endif
+#include "extension/poll_eventloop.h"
+#include "debug.h"
+
+enum { init_fd_events_capacity = 64
+ , init_to_events_capacity = 64 };
+
+static void *get_to_event(_getdns_poll_eventloop *loop,
+ getdns_eventloop_event *event, uint64_t timeout_time)
+{
+ if (loop->to_events_free == loop->to_events_capacity) {
+ if (loop->to_events_free) {
+ _getdns_poll_event *to_events = GETDNS_XREALLOC(
+ loop->mf, loop->to_events, _getdns_poll_event,
+ loop->to_events_free * 2);
+ if (!to_events)
+ return NULL;
+ (void) memset(&to_events[loop->to_events_free],
+ 0, sizeof(_getdns_poll_event)
+ * loop->to_events_free);
+
+ loop->to_events_capacity = loop->to_events_free * 2;
+ loop->to_events = to_events;
+ } else {
+ if (!(loop->to_events = GETDNS_XMALLOC(loop->mf,
+ _getdns_poll_event, init_to_events_capacity)))
+ return NULL;
+
+ (void) memset(loop->to_events, 0,
+ sizeof(_getdns_poll_event)
+ * init_to_events_capacity);
+
+ loop->to_events_capacity = init_to_events_capacity;
+ }
+ }
+ loop->to_events[loop->to_events_free].event = event;
+ loop->to_events[loop->to_events_free].timeout_time = timeout_time;
+ loop->to_events_n_used++;
+ return (void *) (intptr_t) (++loop->to_events_free);
+}
+
+static void *get_fd_event(_getdns_poll_eventloop *loop, int fd,
+ getdns_eventloop_event *event, uint64_t timeout_time)
+{
+ size_t i;
+
+ if (loop->fd_events_free == loop->fd_events_capacity) {
+ if (loop->fd_events_free) {
+ _getdns_poll_event *fd_events = GETDNS_XREALLOC(
+ loop->mf, loop->fd_events, _getdns_poll_event,
+ loop->fd_events_free * 2);
+ struct pollfd *pfds = GETDNS_XREALLOC(
+ loop->mf, loop->pfds, struct pollfd,
+ loop->fd_events_free * 2);
+
+ if (!fd_events || !pfds) {
+ if (fd_events)
+ GETDNS_FREE(loop->mf, fd_events);
+ if (pfds)
+ GETDNS_FREE(loop->mf, pfds);
+ return NULL;
+ }
+ (void) memset(&fd_events[loop->fd_events_free],
+ 0, sizeof(_getdns_poll_event)
+ * loop->fd_events_free);
+ for ( i = loop->fd_events_free
+ ; i < loop->fd_events_free * 2
+ ; i++) {
+ pfds[i].fd = -1;
+ pfds[i].events = 0;
+ pfds[i].revents = 0;
+ }
+ loop->fd_events_capacity = loop->fd_events_free * 2;
+ loop->fd_events = fd_events;
+ loop->pfds = pfds;
+ } else {
+ if (!(loop->fd_events = GETDNS_XMALLOC(loop->mf,
+ _getdns_poll_event, init_fd_events_capacity)) ||
+ !(loop->pfds = GETDNS_XMALLOC(loop->mf,
+ struct pollfd, init_fd_events_capacity))) {
+ GETDNS_NULL_FREE(loop->mf, loop->fd_events);
+ return NULL;
+ }
+ (void) memset(loop->fd_events, 0,
+ sizeof(_getdns_poll_event)
+ * init_fd_events_capacity);
+ for (i = 0; i < init_fd_events_capacity; i++) {
+ loop->pfds[i].fd = -1;
+ loop->pfds[i].events = 0;
+ loop->pfds[i].revents = 0;
+ }
+ loop->fd_events_capacity = init_fd_events_capacity;
+ }
+ }
+ loop->pfds[loop->fd_events_free].fd = fd;
+ loop->pfds[loop->fd_events_free].events = 0;
+ if (event->read_cb)
+ loop->pfds[loop->fd_events_free].events |= POLLIN;
+ if (event->write_cb)
+ loop->pfds[loop->fd_events_free].events |= POLLOUT;
+ loop->fd_events[loop->fd_events_free].event = event;
+ loop->fd_events[loop->fd_events_free].timeout_time = timeout_time;
+ loop->fd_events_n_used++;
+ return (void *) (intptr_t) (++loop->fd_events_free);
+}
+
+static uint64_t get_now_plus(uint64_t amount)
+{
+ struct timeval tv;
+ uint64_t now;
+
+ if (gettimeofday(&tv, NULL)) {
+ perror("gettimeofday() failed");
+ exit(EXIT_FAILURE);
+ }
+ now = tv.tv_sec * 1000000 + tv.tv_usec;
+
+ return (now + amount * 1000) >= now
+ ? now + amount * 1000 : TIMEOUT_FOREVER;
+}
+
+static getdns_return_t
+poll_eventloop_schedule(getdns_eventloop *loop,
+ int fd, uint64_t timeout, getdns_eventloop_event *event)
+{
+ _getdns_poll_eventloop *poll_loop = (_getdns_poll_eventloop *)loop;
+
+ DEBUG_SCHED( "%s(loop: %p, fd: %d, timeout: %"PRIu64", event: %p)\n"
+ , __FUNC__, (void *)loop, fd, timeout, (void *)event);
+
+ if (!loop || !event)
+ return GETDNS_RETURN_INVALID_PARAMETER;
+
+ if (fd >= 0 && !(event->read_cb || event->write_cb)) {
+ DEBUG_SCHED("WARNING: fd event without "
+ "read or write cb!\n");
+ fd = -1;
+ }
+ if (fd >= 0) {
+ if (!(event->ev = get_fd_event(
+ poll_loop, fd, event, get_now_plus(timeout)))) {
+ DEBUG_SCHED("ERROR: scheduled read/write slots!\n");
+ return GETDNS_RETURN_GENERIC_ERROR;
+ }
+ DEBUG_SCHED( "scheduled read/write at for %d at %p\n"
+ , fd, (void *)event->ev);
+ return GETDNS_RETURN_GOOD;
+ }
+ if (!event->timeout_cb) {
+ DEBUG_SCHED("ERROR: fd < 0 without timeout_cb!\n");
+ return GETDNS_RETURN_GENERIC_ERROR;
+ }
+ if (event->read_cb) {
+ DEBUG_SCHED("ERROR: timeout event with read_cb! Clearing.\n");
+ event->read_cb = NULL;
+ }
+ if (event->write_cb) {
+ DEBUG_SCHED("ERROR: timeout event with write_cb! Clearing.\n");
+ event->write_cb = NULL;
+ }
+ if (!(event->ev = get_to_event(poll_loop, event, get_now_plus(timeout)))) {
+ DEBUG_SCHED("ERROR: Out of timeout slots!\n");
+ return GETDNS_RETURN_GENERIC_ERROR;
+ }
+ DEBUG_SCHED("scheduled timeout at slot %p\n", (void *)event->ev);
+ return GETDNS_RETURN_GOOD;
+}
+
+static getdns_return_t
+poll_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
+{
+ _getdns_poll_eventloop *poll_loop = (_getdns_poll_eventloop *)loop;
+
+ if (!loop || !event)
+ return GETDNS_RETURN_INVALID_PARAMETER;
+
+ DEBUG_SCHED( "%s(loop: %p, event: %p)\n", __FUNC__, (void *)loop, (void *)event);
+
+ if (!event->ev)
+ return GETDNS_RETURN_GOOD;
+
+ else if (event->timeout_cb && !event->read_cb && !event->write_cb) {
+ size_t i = ((size_t) (intptr_t) event->ev) - 1;
+
+ /* This may happen with full recursive synchronous requests
+ * with the unbound pluggable event API, because the default
+ * poll_eventloop is temporarily replaced by a poll_eventloop
+ * used only in synchronous calls. When the synchronous request
+ * had an answer, the poll_eventloop for the synchronous is
+ * cleaned, however it could still have outstanding events.
+ */
+ if (i >= poll_loop->to_events_capacity ||
+ poll_loop->to_events[i].event != event) {
+ event->ev = NULL;
+ DEBUG_SCHED( "ERROR: Event mismatch %p\n", (void *)event->ev);
+ return GETDNS_RETURN_GENERIC_ERROR;
+ }
+ poll_loop->to_events[i].event = NULL;
+ if (--poll_loop->to_events_n_used == 0) {
+ poll_loop->to_events_free = 0;
+ }
+ DEBUG_SCHED( "cleared timeout at slot %p\n", (void *)event->ev);
+ } else {
+ size_t i = ((size_t) (intptr_t) event->ev) - 1;
+
+ /* This may happen with full recursive synchronous requests
+ * with the unbound pluggable event API, because the default
+ * poll_eventloop is temporarily replaced by a poll_eventloop
+ * used only in synchronous calls. When the synchronous request
+ * had an answer, the poll_eventloop for the synchronous is
+ * cleaned, however it could still have outstanding events.
+ */
+ if (i >= poll_loop->fd_events_capacity ||
+ poll_loop->fd_events[i].event != event) {
+ event->ev = NULL;
+ DEBUG_SCHED( "ERROR: Event mismatch %p\n", (void *)event->ev);
+ return GETDNS_RETURN_GENERIC_ERROR;
+ }
+ poll_loop->fd_events[i].event = NULL;
+ if (--poll_loop->fd_events_n_used == 0) {
+ poll_loop->fd_events_free = 0;
+ }
+ DEBUG_SCHED( "cleared read/write for %d at slot %p\n"
+ , poll_loop->pfds[i].fd, (void *)event->ev);
+ poll_loop->pfds[i].fd = -1; /* Not necessary, but to be sure */
+ }
+ event->ev = NULL;
+ return GETDNS_RETURN_GOOD;
+}
+
+static void
+poll_eventloop_cleanup(getdns_eventloop *loop)
+{
+ _getdns_poll_eventloop *poll_loop = (_getdns_poll_eventloop *)loop;
+ struct mem_funcs *mf = &poll_loop->mf;
+
+ GETDNS_NULL_FREE(*mf, poll_loop->pfds);
+ if (poll_loop->fd_events) {
+ GETDNS_FREE(*mf, poll_loop->fd_events);
+ poll_loop->fd_events = NULL;
+ poll_loop->fd_events_capacity = 0;
+ poll_loop->fd_events_free = 0;
+ poll_loop->fd_events_n_used = 0;
+ }
+ if (poll_loop->to_events) {
+ GETDNS_FREE(*mf, poll_loop->to_events);
+ poll_loop->to_events = NULL;
+ poll_loop->to_events_capacity = 0;
+ poll_loop->to_events_free = 0;
+ poll_loop->to_events_n_used = 0;
+ }
+}
+
+static void
+poll_read_cb(int fd, getdns_eventloop_event *event)
+{
+#if !defined(SCHED_DEBUG) || !SCHED_DEBUG
+ (void)fd;
+#endif
+ DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNC__, fd, (void *)event);
+ event->read_cb(event->userarg);
+}
+
+static void
+poll_write_cb(int fd, getdns_eventloop_event *event)
+{
+#if !defined(SCHED_DEBUG) || !SCHED_DEBUG
+ (void)fd;
+#endif
+ DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNC__, fd, (void *)event);
+ event->write_cb(event->userarg);
+}
+
+static void
+poll_timeout_cb(getdns_eventloop_event *event)
+{
+ DEBUG_SCHED( "%s(event: %p)\n", __FUNC__, (void *)event);
+ event->timeout_cb(event->userarg);
+}
+
+static void
+poll_eventloop_run_once(getdns_eventloop *loop, int blocking)
+{
+ _getdns_poll_eventloop *poll_loop = (_getdns_poll_eventloop *)loop;
+ uint64_t now, timeout = TIMEOUT_FOREVER;
+ size_t i = 0, j;
+ int poll_timeout = 0;
+
+ if (!loop)
+ return;
+
+ now = get_now_plus(0);
+
+ for (i = 0, j = 0; i < poll_loop->to_events_free; i++, j++) {
+ while (poll_loop->to_events[i].event == NULL) {
+ if (++i == poll_loop->to_events_free) {
+ poll_loop->to_events_free = j;
+ break;
+ }
+ }
+ if (j < i) {
+ if (j >= poll_loop->to_events_free)
+ break;
+ poll_loop->to_events[j] = poll_loop->to_events[i];
+ poll_loop->to_events[i].event = NULL;
+ poll_loop->to_events[j].event->ev =
+ (void *) (intptr_t) (j + 1);
+ }
+ if (poll_loop->to_events[j].timeout_time < now)
+ poll_timeout_cb(poll_loop->to_events[j].event);
+ }
+ for (i = 0, j = 0; i < poll_loop->to_events_free; i++, j++) {
+ while (poll_loop->to_events[i].event == NULL) {
+ if (++i == poll_loop->to_events_free) {
+ poll_loop->to_events_free = j;
+ break;
+ }
+ }
+ if (j < i) {
+ if (j >= poll_loop->to_events_free)
+ break;
+ poll_loop->to_events[j] = poll_loop->to_events[i];
+ poll_loop->to_events[i].event = NULL;
+ poll_loop->to_events[j].event->ev =
+ (void *) (intptr_t) (j + 1);
+ }
+ if (poll_loop->to_events[j].timeout_time < timeout)
+ timeout = poll_loop->to_events[j].timeout_time;
+ }
+ if ((timeout == TIMEOUT_FOREVER) && (poll_loop->fd_events_free == 0))
+ return;
+
+ for (i = 0, j = 0; i < poll_loop->fd_events_free; i++, j++) {
+ while (poll_loop->fd_events[i].event == NULL) {
+ if (++i == poll_loop->fd_events_free) {
+ poll_loop->fd_events_free = j;
+ break;
+ }
+ }
+ if (j < i) {
+ if (j >= poll_loop->fd_events_free)
+ break;
+ poll_loop->fd_events[j] = poll_loop->fd_events[i];
+ poll_loop->fd_events[i].event = NULL;
+ poll_loop->fd_events[j].event->ev =
+ (void *) (intptr_t) (j + 1);
+ poll_loop->pfds[j] = poll_loop->pfds[i];
+ poll_loop->pfds[i].fd = -1;
+ }
+ if (poll_loop->fd_events[j].timeout_time < timeout)
+ timeout = poll_loop->fd_events[j].timeout_time;
+ }
+
+ if (timeout == TIMEOUT_FOREVER) {
+ poll_timeout = -1;
+
+ } else if (! blocking || now > timeout) {
+ poll_timeout = 0;
+ } else {
+ /* turn microseconds into milliseconds */
+ poll_timeout = (timeout - now) / 1000;
+ }
+ DEBUG_SCHED( "poll(fd_free: %d, fd_used: %d, to_free: %d, to_used: %d, timeout: %d)\n"
+ , (int)poll_loop->fd_events_free, (int)poll_loop->fd_events_n_used
+ , (int)poll_loop->to_events_free, (int)poll_loop->to_events_n_used
+ , poll_timeout
+ );
+#ifdef USE_WINSOCK
+ if (poll_loop->fd_events_free == 0)
+ {
+ Sleep(poll_timeout);
+ } else
+ if (WSAPoll(poll_loop->pfds, poll_loop->fd_events_free, poll_timeout) < 0) {
+#else
+ if (poll(poll_loop->pfds, poll_loop->fd_events_free, poll_timeout) < 0) {
+#endif
+ perror("poll() failed");
+ exit(EXIT_FAILURE);
+ }
+ now = get_now_plus(0);
+
+ for (i = 0, j = 0; i < poll_loop->fd_events_free; i++, j++) {
+ while (poll_loop->fd_events[i].event == NULL) {
+ if (++i == poll_loop->fd_events_free) {
+ poll_loop->fd_events_free = j;
+ break;
+ }
+ }
+ if (j < i) {
+ if (j >= poll_loop->fd_events_free)
+ break;
+ poll_loop->fd_events[j] = poll_loop->fd_events[i];
+ poll_loop->fd_events[i].event = NULL;
+ poll_loop->fd_events[j].event->ev =
+ (void *) (intptr_t) (j + 1);
+ poll_loop->pfds[j] = poll_loop->pfds[i];
+ poll_loop->pfds[i].fd = -1;
+ }
+ if (poll_loop->fd_events[j].event->write_cb &&
+ poll_loop->pfds[j].revents & (POLLOUT|POLLERR|POLLHUP|POLLNVAL))
+ poll_write_cb( poll_loop->pfds[j].fd
+ , poll_loop->fd_events[j].event);
+
+ if (poll_loop->fd_events[j].event &&
+ poll_loop->fd_events[j].event->read_cb &&
+ poll_loop->pfds[j].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL))
+ poll_read_cb( poll_loop->pfds[j].fd
+ , poll_loop->fd_events[j].event);
+ }
+ for (i = 0, j = 0; i < poll_loop->fd_events_free; i++, j++) {
+ while (poll_loop->fd_events[i].event == NULL) {
+ if (++i == poll_loop->fd_events_free) {
+ poll_loop->fd_events_free = j;
+ break;
+ }
+ }
+ if (j < i) {
+ if (j >= poll_loop->fd_events_free)
+ break;
+ poll_loop->fd_events[j] = poll_loop->fd_events[i];
+ poll_loop->fd_events[i].event = NULL;
+ poll_loop->fd_events[j].event->ev =
+ (void *) (intptr_t) (j + 1);
+ poll_loop->pfds[j] = poll_loop->pfds[i];
+ poll_loop->pfds[i].fd = -1;
+ }
+ if (poll_loop->fd_events[j].timeout_time < now)
+ poll_timeout_cb(poll_loop->fd_events[j].event);
+ }
+
+ for (i = 0, j = 0; i < poll_loop->to_events_free; i++, j++) {
+ while (poll_loop->to_events[i].event == NULL) {
+ if (++i == poll_loop->to_events_free) {
+ poll_loop->to_events_free = j;
+ break;
+ }
+ }
+ if (j < i) {
+ if (j >= poll_loop->to_events_free)
+ break;
+ poll_loop->to_events[j] = poll_loop->to_events[i];
+ poll_loop->to_events[i].event = NULL;
+ poll_loop->to_events[j].event->ev =
+ (void *) (intptr_t) (j + 1);
+ }
+ if (poll_loop->to_events[j].timeout_time < now)
+ poll_timeout_cb(poll_loop->to_events[j].event);
+ }
+}
+
+static void
+poll_eventloop_run(getdns_eventloop *loop)
+{
+ _getdns_poll_eventloop *poll_loop = (_getdns_poll_eventloop *)loop;
+
+ if (!loop)
+ return;
+
+ /* keep going until all the events are cleared */
+ while (poll_loop->fd_events_n_used || poll_loop->to_events_n_used) {
+ poll_eventloop_run_once(loop, 1);
+ }
+}
+
+void
+_getdns_poll_eventloop_init(struct mem_funcs *mf, _getdns_poll_eventloop *loop)
+{
+ static getdns_eventloop_vmt poll_eventloop_vmt = {
+ poll_eventloop_cleanup,
+ poll_eventloop_schedule,
+ poll_eventloop_clear,
+ poll_eventloop_run,
+ poll_eventloop_run_once
+ };
+
+ loop->loop.vmt = &poll_eventloop_vmt;
+ loop->mf = *mf;
+
+ loop->to_events_capacity = init_to_events_capacity;
+ if ((loop->to_events = GETDNS_XMALLOC(
+ *mf, _getdns_poll_event, init_to_events_capacity)))
+ (void) memset(loop->to_events, 0,
+ sizeof(_getdns_poll_event) * init_to_events_capacity);
+ else
+ loop->to_events_capacity = 0;
+ loop->to_events_free = 0;
+ loop->to_events_n_used = 0;
+
+ loop->fd_events_capacity = init_fd_events_capacity;
+ if ((loop->fd_events = GETDNS_XMALLOC(
+ *mf, _getdns_poll_event, init_fd_events_capacity)) &&
+ (loop->pfds = GETDNS_XMALLOC(
+ *mf, struct pollfd, init_fd_events_capacity))) {
+ size_t i;
+
+ (void) memset(loop->fd_events, 0,
+ sizeof(_getdns_poll_event) * init_fd_events_capacity);
+ for (i = 0; i < init_fd_events_capacity; i++) {
+ loop->pfds[i].fd = -1;
+ loop->pfds[i].events = 0;
+ loop->pfds[i].revents = 0;
+ }
+ } else {
+ loop->fd_events_capacity = 0;
+ if (loop->fd_events) {
+ GETDNS_FREE(*mf, loop->fd_events);
+ loop->fd_events = NULL;
+ }
+ }
+ loop->fd_events_free = 0;
+ loop->fd_events_n_used = 0;
+}
+
diff --git a/src/extension/poll_eventloop.h b/src/extension/poll_eventloop.h
new file mode 100644
index 00000000..e4e4bb7e
--- /dev/null
+++ b/src/extension/poll_eventloop.h
@@ -0,0 +1,66 @@
+/*
+ * \file poll_eventloop.h
+ * @brief Build in default eventloop extension that uses select.
+ *
+ */
+/*
+ * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
+ * All rights reserved.
+ *
+ * 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 names of the copyright holders 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 Verisign, Inc. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef POLL_EVENTLOOP_H_
+#define POLL_EVENTLOOP_H_
+#include "config.h"
+#include "getdns/getdns.h"
+#include "getdns/getdns_extra.h"
+#include "types-internal.h"
+
+/* Eventloop based on poll */
+
+typedef struct _getdns_poll_event {
+ getdns_eventloop_event *event;
+ uint64_t timeout_time;
+} _getdns_poll_event;
+
+typedef struct _getdns_poll_eventloop {
+ getdns_eventloop loop;
+ struct mem_funcs mf;
+
+ struct pollfd *pfds;
+ size_t fd_events_capacity;
+ _getdns_poll_event *fd_events;
+ size_t fd_events_free;
+ size_t fd_events_n_used;
+
+ size_t to_events_capacity;
+ _getdns_poll_event *to_events;
+ size_t to_events_free;
+ size_t to_events_n_used;
+} _getdns_poll_eventloop;
+
+void
+_getdns_poll_eventloop_init(struct mem_funcs *mf, _getdns_poll_eventloop *loop);
+
+#endif
+
diff --git a/src/extension/default_eventloop.c b/src/extension/select_eventloop.c
similarity index 52%
rename from src/extension/default_eventloop.c
rename to src/extension/select_eventloop.c
index 10efff59..47769afd 100644
--- a/src/extension/default_eventloop.c
+++ b/src/extension/select_eventloop.c
@@ -25,32 +25,36 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "extension/default_eventloop.h"
+#include "config.h"
+
+#include "extension/select_eventloop.h"
#include "debug.h"
+#include "types-internal.h"
static uint64_t get_now_plus(uint64_t amount)
{
struct timeval tv;
uint64_t now;
-
+
if (gettimeofday(&tv, NULL)) {
perror("gettimeofday() failed");
exit(EXIT_FAILURE);
}
now = tv.tv_sec * 1000000 + tv.tv_usec;
- return (now + amount * 1000) >= now ? now + amount * 1000 : -1;
+ return (now + amount * 1000) >= now
+ ? now + amount * 1000 : TIMEOUT_FOREVER;
}
static getdns_return_t
-default_eventloop_schedule(getdns_eventloop *loop,
+select_eventloop_schedule(getdns_eventloop *loop,
int fd, uint64_t timeout, getdns_eventloop_event *event)
{
- _getdns_default_eventloop *default_loop = (_getdns_default_eventloop *)loop;
+ _getdns_select_eventloop *select_loop = (_getdns_select_eventloop *)loop;
size_t i;
DEBUG_SCHED( "%s(loop: %p, fd: %d, timeout: %"PRIu64", event: %p, FD_SETSIZE: %d)\n"
- , __FUNCTION__, loop, fd, timeout, event, FD_SETSIZE);
+ , __FUNC__, (void *)loop, fd, timeout, (void *)event, FD_SETSIZE);
if (!loop || !event)
return GETDNS_RETURN_INVALID_PARAMETER;
@@ -67,22 +71,21 @@ default_eventloop_schedule(getdns_eventloop *loop,
}
if (fd >= 0) {
#if defined(SCHED_DEBUG) && SCHED_DEBUG
- if (default_loop->fd_events[fd]) {
- if (default_loop->fd_events[fd] == event) {
+ if (select_loop->fd_events[fd]) {
+ if (select_loop->fd_events[fd] == event) {
DEBUG_SCHED("WARNING: Event %p not cleared "
"before being rescheduled!\n"
- , default_loop->fd_events[fd]);
+ , (void *)select_loop->fd_events[fd]);
} else {
DEBUG_SCHED("ERROR: A different event is "
"already present at fd slot: %p!\n"
- , default_loop->fd_events[fd]);
+ , (void *)select_loop->fd_events[fd]);
}
}
#endif
- default_loop->fd_events[fd] = event;
- default_loop->fd_timeout_times[fd] = get_now_plus(timeout);
- event->ev = (void *) (intptr_t) fd + 1;
-
+ select_loop->fd_events[fd] = event;
+ select_loop->fd_timeout_times[fd] = get_now_plus(timeout);
+ event->ev = (void *)(intptr_t)(fd + 1);
DEBUG_SCHED( "scheduled read/write at %d\n", fd);
return GETDNS_RETURN_GOOD;
}
@@ -99,11 +102,10 @@ default_eventloop_schedule(getdns_eventloop *loop,
event->write_cb = NULL;
}
for (i = 0; i < MAX_TIMEOUTS; i++) {
- if (default_loop->timeout_events[i] == NULL) {
- default_loop->timeout_events[i] = event;
- default_loop->timeout_times[i] = get_now_plus(timeout);
- event->ev = (void *) (intptr_t) i + 1;
-
+ if (select_loop->timeout_events[i] == NULL) {
+ select_loop->timeout_events[i] = event;
+ select_loop->timeout_times[i] = get_now_plus(timeout);
+ event->ev = (void *)(intptr_t)(i + 1);
DEBUG_SCHED( "scheduled timeout at %d\n", (int)i);
return GETDNS_RETURN_GOOD;
}
@@ -113,75 +115,85 @@ default_eventloop_schedule(getdns_eventloop *loop,
}
static getdns_return_t
-default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
+select_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
{
- _getdns_default_eventloop *default_loop = (_getdns_default_eventloop *)loop;
+ _getdns_select_eventloop *select_loop = (_getdns_select_eventloop *)loop;
ssize_t i;
if (!loop || !event)
return GETDNS_RETURN_INVALID_PARAMETER;
- DEBUG_SCHED( "%s(loop: %p, event: %p)\n", __FUNCTION__, loop, event);
+ DEBUG_SCHED( "%s(loop: %p, event: %p)\n", __FUNC__, (void *)loop, (void *)event);
i = (intptr_t)event->ev - 1;
- if (i < 0 || i > FD_SETSIZE) {
+ if (i < 0 || i >= FD_SETSIZE) {
return GETDNS_RETURN_GENERIC_ERROR;
}
if (event->timeout_cb && !event->read_cb && !event->write_cb) {
#if defined(SCHED_DEBUG) && SCHED_DEBUG
- if (default_loop->timeout_events[i] != event)
+ if (select_loop->timeout_events[i] != event)
DEBUG_SCHED( "ERROR: Different/wrong event present at "
"timeout slot: %p!\n"
- , default_loop->timeout_events[i]);
+ , (void *)select_loop->timeout_events[i]);
#endif
- default_loop->timeout_events[i] = NULL;
+ select_loop->timeout_events[i] = NULL;
} else {
#if defined(SCHED_DEBUG) && SCHED_DEBUG
- if (default_loop->fd_events[i] != event)
+ if (select_loop->fd_events[i] != event)
DEBUG_SCHED( "ERROR: Different/wrong event present at "
"fd slot: %p!\n"
- , default_loop->fd_events[i]);
+ , (void *)select_loop->fd_events[i]);
#endif
- default_loop->fd_events[i] = NULL;
+ select_loop->fd_events[i] = NULL;
}
event->ev = NULL;
return GETDNS_RETURN_GOOD;
}
static void
-default_eventloop_cleanup(getdns_eventloop *loop)
+select_eventloop_cleanup(getdns_eventloop *loop)
{
+ (void)loop;
}
static void
-default_read_cb(int fd, getdns_eventloop_event *event)
+select_read_cb(int fd, getdns_eventloop_event *event)
{
- DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event);
+#if !defined(SCHED_DEBUG) || !SCHED_DEBUG
+ (void)fd;
+#endif
+ DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNC__, fd, (void *)event);
event->read_cb(event->userarg);
}
static void
-default_write_cb(int fd, getdns_eventloop_event *event)
+select_write_cb(int fd, getdns_eventloop_event *event)
{
- DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event);
+#if !defined(SCHED_DEBUG) || !SCHED_DEBUG
+ (void)fd;
+#endif
+ DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNC__, fd, (void *)event);
event->write_cb(event->userarg);
}
static void
-default_timeout_cb(int fd, getdns_eventloop_event *event)
+select_timeout_cb(int fd, getdns_eventloop_event *event)
{
- DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event);
+#if !defined(SCHED_DEBUG) || !SCHED_DEBUG
+ (void)fd;
+#endif
+ DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNC__, fd, (void *)event);
event->timeout_cb(event->userarg);
}
static void
-default_eventloop_run_once(getdns_eventloop *loop, int blocking)
+select_eventloop_run_once(getdns_eventloop *loop, int blocking)
{
- _getdns_default_eventloop *default_loop = (_getdns_default_eventloop *)loop;
+ _getdns_select_eventloop *select_loop = (_getdns_select_eventloop *)loop;
fd_set readfds, writefds;
int fd, max_fd = -1;
- uint64_t now, timeout = (uint64_t)-1;
+ uint64_t now, timeout = TIMEOUT_FOREVER;
size_t i;
struct timeval tv;
@@ -193,69 +205,79 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking)
now = get_now_plus(0);
for (i = 0; i < MAX_TIMEOUTS; i++) {
- if (!default_loop->timeout_events[i])
+ if (!select_loop->timeout_events[i])
continue;
- if (now > default_loop->timeout_times[i])
- default_timeout_cb(-1, default_loop->timeout_events[i]);
- else if (default_loop->timeout_times[i] < timeout)
- timeout = default_loop->timeout_times[i];
+ if (now > select_loop->timeout_times[i])
+ select_timeout_cb(-1, select_loop->timeout_events[i]);
+ else if (select_loop->timeout_times[i] < timeout)
+ timeout = select_loop->timeout_times[i];
}
- for (fd = 0; fd < FD_SETSIZE; fd++) {
- if (!default_loop->fd_events[fd])
+ for (fd = 0; fd < (int)FD_SETSIZE; fd++) {
+ if (!select_loop->fd_events[fd])
continue;
- if (default_loop->fd_events[fd]->read_cb)
+ if (select_loop->fd_events[fd]->read_cb)
FD_SET(fd, &readfds);
- if (default_loop->fd_events[fd]->write_cb)
+ if (select_loop->fd_events[fd]->write_cb)
FD_SET(fd, &writefds);
if (fd > max_fd)
max_fd = fd;
- if (default_loop->fd_timeout_times[fd] < timeout)
- timeout = default_loop->fd_timeout_times[fd];
+ if (select_loop->fd_timeout_times[fd] < timeout)
+ timeout = select_loop->fd_timeout_times[fd];
}
- if (max_fd == -1 && timeout == (uint64_t)-1)
+ if (max_fd == -1 && timeout == TIMEOUT_FOREVER)
return;
if (! blocking || now > timeout) {
tv.tv_sec = 0;
tv.tv_usec = 0;
} else {
- tv.tv_sec = (timeout - now) / 1000000;
- tv.tv_usec = (timeout - now) % 1000000;
+ tv.tv_sec = (long)((timeout - now) / 1000000);
+ tv.tv_usec = (long)((timeout - now) % 1000000);
}
+#ifdef USE_WINSOCK
+ if (max_fd == -1)
+ {
+ if (timeout != TIMEOUT_FOREVER)
+ {
+ uint32_t timeout_ms = (tv.tv_usec / 1000) + (tv.tv_sec * 1000);
+ Sleep(timeout_ms);
+ }
+ } else
+#endif
if (select(max_fd + 1, &readfds, &writefds, NULL,
- (timeout == ((uint64_t)-1) ? NULL : &tv)) < 0) {
+ (timeout == TIMEOUT_FOREVER ? NULL : &tv)) < 0) {
perror("select() failed");
exit(EXIT_FAILURE);
}
now = get_now_plus(0);
- for (fd = 0; fd < FD_SETSIZE; fd++) {
- if (default_loop->fd_events[fd] &&
- default_loop->fd_events[fd]->read_cb &&
+ for (fd = 0; fd < (int)FD_SETSIZE; fd++) {
+ if (select_loop->fd_events[fd] &&
+ select_loop->fd_events[fd]->read_cb &&
FD_ISSET(fd, &readfds))
- default_read_cb(fd, default_loop->fd_events[fd]);
+ select_read_cb(fd, select_loop->fd_events[fd]);
- if (default_loop->fd_events[fd] &&
- default_loop->fd_events[fd]->write_cb &&
+ if (select_loop->fd_events[fd] &&
+ select_loop->fd_events[fd]->write_cb &&
FD_ISSET(fd, &writefds))
- default_write_cb(fd, default_loop->fd_events[fd]);
+ select_write_cb(fd, select_loop->fd_events[fd]);
- if (default_loop->fd_events[fd] &&
- default_loop->fd_events[fd]->timeout_cb &&
- now > default_loop->fd_timeout_times[fd])
- default_timeout_cb(fd, default_loop->fd_events[fd]);
+ if (select_loop->fd_events[fd] &&
+ select_loop->fd_events[fd]->timeout_cb &&
+ now > select_loop->fd_timeout_times[fd])
+ select_timeout_cb(fd, select_loop->fd_events[fd]);
i = fd;
- if (default_loop->timeout_events[i] &&
- default_loop->timeout_events[i]->timeout_cb &&
- now > default_loop->timeout_times[i])
- default_timeout_cb(-1, default_loop->timeout_events[i]);
+ if (select_loop->timeout_events[i] &&
+ select_loop->timeout_events[i]->timeout_cb &&
+ now > select_loop->timeout_times[i])
+ select_timeout_cb(-1, select_loop->timeout_events[i]);
}
}
static void
-default_eventloop_run(getdns_eventloop *loop)
+select_eventloop_run(getdns_eventloop *loop)
{
- _getdns_default_eventloop *default_loop = (_getdns_default_eventloop *)loop;
+ _getdns_select_eventloop *select_loop = (_getdns_select_eventloop *)loop;
size_t i;
if (!loop)
@@ -263,8 +285,8 @@ default_eventloop_run(getdns_eventloop *loop)
i = 0;
while (i < MAX_TIMEOUTS) {
- if (default_loop->fd_events[i] || default_loop->timeout_events[i]) {
- default_eventloop_run_once(loop, 1);
+ if (select_loop->fd_events[i] || select_loop->timeout_events[i]) {
+ select_eventloop_run_once(loop, 1);
i = 0;
} else {
i++;
@@ -273,16 +295,16 @@ default_eventloop_run(getdns_eventloop *loop)
}
void
-_getdns_default_eventloop_init(_getdns_default_eventloop *loop)
+_getdns_select_eventloop_init(struct mem_funcs *mf, _getdns_select_eventloop *loop)
{
- static getdns_eventloop_vmt default_eventloop_vmt = {
- default_eventloop_cleanup,
- default_eventloop_schedule,
- default_eventloop_clear,
- default_eventloop_run,
- default_eventloop_run_once
+ static getdns_eventloop_vmt select_eventloop_vmt = {
+ select_eventloop_cleanup,
+ select_eventloop_schedule,
+ select_eventloop_clear,
+ select_eventloop_run,
+ select_eventloop_run_once
};
-
- (void) memset(loop, 0, sizeof(_getdns_default_eventloop));
- loop->loop.vmt = &default_eventloop_vmt;
+ (void) mf;
+ (void) memset(loop, 0, sizeof(_getdns_select_eventloop));
+ loop->loop.vmt = &select_eventloop_vmt;
}
diff --git a/src/extension/select_eventloop.h b/src/extension/select_eventloop.h
new file mode 100644
index 00000000..e830a2ac
--- /dev/null
+++ b/src/extension/select_eventloop.h
@@ -0,0 +1,58 @@
+/*
+ * \file select_eventloop.h
+ * @brief Build in default eventloop extension that uses select.
+ *
+ */
+/*
+ * Copyright (c) 2013, NLNet Labs, Verisign, Inc.
+ * All rights reserved.
+ *
+ * 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 names of the copyright holders 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 Verisign, Inc. BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef SELECT_EVENTLOOP_H_
+#define SELECT_EVENTLOOP_H_
+#include "config.h"
+#include "getdns/getdns.h"
+#include "getdns/getdns_extra.h"
+
+/* No more than select's capability queries can be outstanding,
+ * The number of outstanding timeouts should be less or equal then
+ * the number of outstanding queries, so MAX_TIMEOUTS equal to
+ * FD_SETSIZE should be safe.
+ */
+#define MAX_TIMEOUTS FD_SETSIZE
+
+/* Eventloop based on select */
+typedef struct _getdns_select_eventloop {
+ getdns_eventloop loop;
+ getdns_eventloop_event *fd_events[FD_SETSIZE];
+ uint64_t fd_timeout_times[FD_SETSIZE];
+ getdns_eventloop_event *timeout_events[MAX_TIMEOUTS];
+ uint64_t timeout_times[MAX_TIMEOUTS];
+} _getdns_select_eventloop;
+
+
+void
+_getdns_select_eventloop_init(struct mem_funcs *mf, _getdns_select_eventloop *loop);
+
+#endif
diff --git a/src/general.c b/src/general.c
index 99e4cff5..2420a47c 100644
--- a/src/general.c
+++ b/src/general.c
@@ -52,32 +52,26 @@
#include "dnssec.h"
#include "stub.h"
#include "dict.h"
+#include "mdns.h"
+#include "debug.h"
-/* cancel, cleanup and send timeout to callback */
-static void
-ub_resolve_timeout(void *arg)
+void _getdns_call_user_callback(getdns_dns_req *dnsreq, getdns_dict *response)
{
- getdns_dns_req *dns_req = (getdns_dns_req *) arg;
- (void) _getdns_context_request_timed_out(dns_req);
-}
+ _getdns_context_clear_outbound_request(dnsreq);
-void _getdns_call_user_callback(getdns_dns_req *dns_req,
- struct getdns_dict *response)
-{
- struct getdns_context *context = dns_req->context;
- getdns_transaction_t trans_id = dns_req->trans_id;
- getdns_callback_t cb = dns_req->user_callback;
- void *user_arg = dns_req->user_pointer;
-
- /* clean up */
- _getdns_context_clear_outbound_request(dns_req);
- _getdns_dns_req_free(dns_req);
-
- context->processing = 1;
- cb(context,
- (response ? GETDNS_CALLBACK_COMPLETE : GETDNS_CALLBACK_ERROR),
- response, user_arg, trans_id);
- context->processing = 0;
+#if defined(REQ_DEBUG) && REQ_DEBUG
+ debug_req(__FUNC__, *dnsreq->netreqs);
+#endif
+ if (dnsreq->user_callback) {
+ dnsreq->context->processing = 1;
+ dnsreq->user_callback(dnsreq->context,
+ ( ! response ? GETDNS_CALLBACK_ERROR
+ : dnsreq->request_timed_out ? GETDNS_CALLBACK_TIMEOUT
+ : GETDNS_CALLBACK_COMPLETE ),
+ response, dnsreq->user_pointer, dnsreq->trans_id);
+ dnsreq->context->processing = 0;
+ }
+ _getdns_dns_req_free(dnsreq);
}
static int
@@ -101,17 +95,28 @@ void
_getdns_check_dns_req_complete(getdns_dns_req *dns_req)
{
getdns_network_req **netreq_p, *netreq;
- int results_found = 0, r;
+ int results_found = 0, timed_out = 1, r;
+ uint64_t now_ms = 0;
for (netreq_p = dns_req->netreqs; (netreq = *netreq_p); netreq_p++)
if (!_getdns_netreq_finished(netreq))
return;
- else if (netreq->response_len > 0)
- results_found = 1;
+ else {
+ if (netreq->state != NET_REQ_TIMED_OUT)
+ timed_out = 0;
+ if (netreq->response_len > 0)
+ results_found = 1;
+ }
+
+ if (timed_out) {
+ _getdns_context_request_timed_out(dns_req);
+ return;
+ }
/* Do we have to check more suffixes on nxdomain/nodata?
*/
- if (dns_req->suffix_appended && /* Something was appended */
+ if (dns_req->is_dns_request &&
+ dns_req->suffix_appended && /* Something was appended */
dns_req->suffix_len > 1 && /* Next suffix available */
no_answer(dns_req)) {
/* Remove suffix from name */
@@ -137,16 +142,17 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req)
; (netreq = *netreq_p)
; netreq_p++ ) {
_getdns_netreq_reinit(netreq);
- if ((r = _getdns_submit_netreq(netreq))) {
+ if ((r = _getdns_submit_netreq(netreq, &now_ms))) {
if (r == DNS_REQ_FINISHED)
return;
- netreq->state = NET_REQ_FINISHED;
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
}
}
_getdns_check_dns_req_complete(dns_req);
return;
}
} else if (
+ dns_req->is_dns_request &&
( dns_req->append_name ==
GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE ||
dns_req->append_name ==
@@ -175,21 +181,32 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req)
; (netreq = *netreq_p)
; netreq_p++ ) {
_getdns_netreq_reinit(netreq);
- if ((r = _getdns_submit_netreq(netreq))) {
+ if ((r = _getdns_submit_netreq(netreq, &now_ms))) {
if (r == DNS_REQ_FINISHED)
return;
- netreq->state = NET_REQ_FINISHED;
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
}
}
_getdns_check_dns_req_complete(dns_req);
return;
}
}
+#if defined(REQ_DEBUG) && REQ_DEBUG
if (dns_req->internal_cb)
+ debug_req("CB Internal", *dns_req->netreqs);
+ else if (results_found)
+ debug_req("CB Complete", *dns_req->netreqs);
+ else
+ debug_req("CB Error ", *dns_req->netreqs);
+#endif
+ if (dns_req->internal_cb) {
+ _getdns_context_clear_outbound_request(dns_req);
dns_req->internal_cb(dns_req);
- else if (! results_found)
+ } else if (! results_found)
_getdns_call_user_callback(dns_req, NULL);
- else if (dns_req->dnssec_return_validation_chain
+ else if (
+ dns_req->is_dns_request &&
+ (dns_req->dnssec_return_validation_chain
#ifdef DNSSEC_ROADBLOCK_AVOIDANCE
|| ( dns_req->dnssec_roadblock_avoidance
&& !dns_req->avoid_dnssec_roadblocks)
@@ -197,14 +214,29 @@ _getdns_check_dns_req_complete(getdns_dns_req *dns_req)
#ifdef STUB_NATIVE_DNSSEC
|| (dns_req->context->resolution_type == GETDNS_RESOLUTION_STUB
+ && !dns_req->avoid_dnssec_roadblocks
&& (dns_req->dnssec_return_status ||
dns_req->dnssec_return_only_secure ||
dns_req->dnssec_return_all_statuses
))
#endif
- )
+ )) {
+ /* Reschedule timeout for this DNS request
+ */
+ if (dns_req->timeout.timeout_cb && dns_req->timeout.ev)
+ GETDNS_CLEAR_EVENT(dns_req->loop, &dns_req->timeout);
+
+ GETDNS_SCHEDULE_EVENT(dns_req->loop, -1,
+ _getdns_ms_until_expiry2(dns_req->expires, &now_ms),
+ getdns_eventloop_event_init(&dns_req->timeout, dns_req,
+ NULL, NULL, (getdns_eventloop_callback)
+ _getdns_validation_chain_timeout));
+
+#if defined(REQ_DEBUG) && REQ_DEBUG
+ debug_req("getting validation chain for ", *dns_req->netreqs);
+#endif
_getdns_get_validation_chain(dns_req);
- else
+ } else
_getdns_call_user_callback(
dns_req, _getdns_create_getdns_response(dns_req));
}
@@ -218,7 +250,7 @@ ub_resolve_event_callback(void* arg, int rcode, void *pkt, int pkt_len,
getdns_network_req *netreq = (getdns_network_req *) arg;
getdns_dns_req *dns_req = netreq->owner;
- netreq->state = NET_REQ_FINISHED;
+ _getdns_netreq_change_state(netreq, NET_REQ_FINISHED);
/* parse */
if (getdns_apply_network_result(
netreq, rcode, pkt, pkt_len, sec, why_bogus)) {
@@ -236,7 +268,7 @@ ub_resolve_callback(void* arg, int err, struct ub_result* ub_res)
getdns_network_req *netreq = (getdns_network_req *) arg;
getdns_dns_req *dns_req = netreq->owner;
- netreq->state = NET_REQ_FINISHED;
+ _getdns_netreq_change_state(netreq, NET_REQ_FINISHED);
if (err != 0) {
_getdns_call_user_callback(dns_req, NULL);
return;
@@ -257,28 +289,131 @@ ub_resolve_callback(void* arg, int err, struct ub_result* ub_res)
#endif
+void _getdns_check_expired_pending_netreqs(
+ getdns_context *context, uint64_t *now_ms)
+{
+ getdns_network_req *first;
+
+ assert(context);
+
+ while (context->pending_netreqs.count) {
+ first = (getdns_network_req *)
+ _getdns_rbtree_first(&context->pending_netreqs);
+
+ if (_getdns_ms_until_expiry2(first->owner->expires, now_ms) > 0)
+ break;
+
+ (void) _getdns_rbtree_delete(&context->pending_netreqs, first);
+ _getdns_netreq_change_state(first, NET_REQ_TIMED_OUT);
+ _getdns_check_dns_req_complete(first->owner);
+ }
+ first = context->pending_netreqs.count ? (getdns_network_req *)
+ _getdns_rbtree_first(&context->pending_netreqs) : NULL;
+
+ if (first == context->first_pending_netreq ||
+ (first && context->first_pending_netreq &&
+ first->owner->expires == context->first_pending_netreq->owner->expires))
+ return; /* Nothing changed */
+
+ if (context->first_pending_netreq)
+ GETDNS_CLEAR_EVENT( context->extension
+ , &context->pending_timeout_event);
+
+ if ((context->first_pending_netreq = first))
+ GETDNS_SCHEDULE_EVENT( context->extension, -1,
+ _getdns_ms_until_expiry2(first->owner->expires, now_ms),
+ &context->pending_timeout_event);
+}
+
+void
+_getdns_netreq_change_state(
+ getdns_network_req *netreq, network_req_state new_state)
+{
+ getdns_context *context;
+ uint64_t now_ms;
+ getdns_network_req *prev;
+
+ if (!netreq)
+ return;
+
+ if (!netreq->owner->is_dns_request) {
+ netreq->state = new_state;
+ return;
+ }
+
+ context = netreq->owner->context;
+
+ if (netreq->state != NET_REQ_IN_FLIGHT) {
+ if (new_state == NET_REQ_IN_FLIGHT)
+ context->netreqs_in_flight += 1;
+ netreq->state = new_state;
+ return;
+ }
+ if (new_state == NET_REQ_IN_FLIGHT) /* No change */
+ return;
+ netreq->state = new_state;
+ context->netreqs_in_flight -= 1;
+
+ now_ms = 0;
+ prev = NULL;
+ while (context->pending_netreqs.count > 0 &&
+ ( context->limit_outstanding_queries > context->netreqs_in_flight
+ || context->limit_outstanding_queries == 0 )) {
+
+ getdns_network_req *first = (getdns_network_req *)
+ _getdns_rbtree_first(&context->pending_netreqs);
+
+ /* To prevent loops due to _getdns_submit_netreq re-inserting
+ * because of errno == EMFILE
+ */
+ if (first == prev)
+ break;
+ else
+ prev = first;
+
+ (void) _getdns_rbtree_delete(&context->pending_netreqs, first);
+ (void) _getdns_submit_netreq(first, &now_ms);
+ }
+}
+
int
-_getdns_submit_netreq(getdns_network_req *netreq)
+_getdns_submit_netreq(getdns_network_req *netreq, uint64_t *now_ms)
{
getdns_return_t r;
getdns_dns_req *dns_req = netreq->owner;
+ getdns_context *context = dns_req->context;
char name[1024];
int dnsreq_freed = 0;
#ifdef HAVE_LIBUNBOUND
int ub_resolve_r;
#endif
+ if (context->limit_outstanding_queries > 0 &&
+ context->netreqs_in_flight >= context->limit_outstanding_queries) {
+
+ netreq->node.key = netreq;
+ if (_getdns_rbtree_insert(
+ &context->pending_netreqs, &netreq->node)) {
+
+ _getdns_check_expired_pending_netreqs(context, now_ms);
+ return GETDNS_RETURN_GOOD;
+ }
+ }
+ _getdns_netreq_change_state(netreq, NET_REQ_IN_FLIGHT);
+
+ debug_req("Submitting ", netreq);
+
#ifdef STUB_NATIVE_DNSSEC
# ifdef DNSSEC_ROADBLOCK_AVOIDANCE
- if ((dns_req->context->resolution_type == GETDNS_RESOLUTION_RECURSING
+ if ((context->resolution_type == GETDNS_RESOLUTION_RECURSING
&& !dns_req->dnssec_roadblock_avoidance)
|| dns_req->avoid_dnssec_roadblocks) {
# else
- if ( dns_req->context->resolution_type == GETDNS_RESOLUTION_RECURSING) {
+ if ( context->resolution_type == GETDNS_RESOLUTION_RECURSING) {
# endif
#else
- if ( dns_req->context->resolution_type == GETDNS_RESOLUTION_RECURSING
+ if ( context->resolution_type == GETDNS_RESOLUTION_RECURSING
|| dns_req->dnssec_return_status
|| dns_req->dnssec_return_only_secure
|| dns_req->dnssec_return_all_statuses
@@ -289,10 +424,13 @@ _getdns_submit_netreq(getdns_network_req *netreq)
dns_req->timeout.userarg = dns_req;
dns_req->timeout.read_cb = NULL;
dns_req->timeout.write_cb = NULL;
- dns_req->timeout.timeout_cb = ub_resolve_timeout;
+ dns_req->timeout.timeout_cb =
+ (getdns_eventloop_callback)
+ _getdns_context_request_timed_out;
dns_req->timeout.ev = NULL;
if ((r = dns_req->loop->vmt->schedule(dns_req->loop, -1,
- dns_req->context->timeout, &dns_req->timeout)))
+ _getdns_ms_until_expiry2(dns_req->expires, now_ms),
+ &dns_req->timeout)))
return r;
}
(void) gldns_wire2str_dname_buf(dns_req->name,
@@ -301,15 +439,15 @@ _getdns_submit_netreq(getdns_network_req *netreq)
#ifdef HAVE_LIBUNBOUND
dns_req->freed = &dnsreq_freed;
#ifdef HAVE_UNBOUND_EVENT_API
- if (_getdns_ub_loop_enabled(&dns_req->context->ub_loop))
- ub_resolve_r = ub_resolve_event(dns_req->context->unbound_ctx,
- name, netreq->request_type, netreq->owner->request_class,
+ if (_getdns_ub_loop_enabled(&context->ub_loop))
+ ub_resolve_r = ub_resolve_event(context->unbound_ctx,
+ name, netreq->request_type, dns_req->request_class,
netreq, ub_resolve_event_callback, &(netreq->unbound_id)) ?
GETDNS_RETURN_GENERIC_ERROR : GETDNS_RETURN_GOOD;
else
#endif
- ub_resolve_r = ub_resolve_async(dns_req->context->unbound_ctx,
- name, netreq->request_type, netreq->owner->request_class,
+ ub_resolve_r = ub_resolve_async(context->unbound_ctx,
+ name, netreq->request_type, dns_req->request_class,
netreq, ub_resolve_callback, &(netreq->unbound_id)) ?
GETDNS_RETURN_GENERIC_ERROR : GETDNS_RETURN_GOOD;
if (dnsreq_freed)
@@ -322,7 +460,7 @@ _getdns_submit_netreq(getdns_network_req *netreq)
}
/* Submit with stub resolver */
dns_req->freed = &dnsreq_freed;
- r = _getdns_submit_stub_request(netreq);
+ r = _getdns_submit_stub_request(netreq, now_ms);
if (dnsreq_freed)
return DNS_REQ_FINISHED;
dns_req->freed = NULL;
@@ -421,6 +559,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
getdns_dns_req *req;
getdns_dict *localnames_response;
size_t i;
+ uint64_t now_ms = 0;
if (!context || !name || (!callbackfn && !internal_cb))
return GETDNS_RETURN_INVALID_PARAMETER;
@@ -438,7 +577,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
/* create the request */
if (!(req = _getdns_dns_req_new(
- context, loop, name, request_type, extensions)))
+ context, loop, name, request_type, extensions, &now_ms)))
return GETDNS_RETURN_MEMORY_ERROR;
req->user_pointer = userarg;
@@ -456,13 +595,13 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
for ( netreq_p = req->netreqs
; !r && (netreq = *netreq_p)
; netreq_p++) {
- if ((r = _getdns_submit_netreq(netreq))) {
+ if ((r = _getdns_submit_netreq(netreq, &now_ms))) {
if (r == DNS_REQ_FINISHED) {
if (return_netreq_p)
*return_netreq_p = NULL;
return GETDNS_RETURN_GOOD;
}
- netreq->state = NET_REQ_FINISHED;
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
}
}
@@ -471,11 +610,34 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
if (!(r = _getdns_context_local_namespace_resolve(
req, &localnames_response))) {
-
+ req->is_dns_request = 0;
_getdns_call_user_callback
( req, localnames_response);
break;
}
+#ifdef HAVE_MDNS_SUPPORT
+ } else if (context->namespaces[i] == GETDNS_NAMESPACE_MDNS) {
+ /* Check whether the name belongs in the MDNS space */
+ if (!(r = _getdns_mdns_namespace_check(req)))
+ {
+ req->is_dns_request = 0;
+ // Submit the query to the MDNS transport.
+ for (netreq_p = req->netreqs
+ ; !r && (netreq = *netreq_p)
+ ; netreq_p++) {
+ if ((r = _getdns_submit_mdns_request(netreq))) {
+ if (r == DNS_REQ_FINISHED) {
+ if (return_netreq_p)
+ *return_netreq_p = NULL;
+ return GETDNS_RETURN_GOOD;
+ }
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
+ }
+ }
+ /* Stop processing more namespaces, since there was a match */
+ break;
+ }
+#endif /* HAVE_MDNS_SUPPORT */
} else if (context->namespaces[i] == GETDNS_NAMESPACE_DNS) {
/* TODO: We will get a good return code here even if
@@ -486,13 +648,13 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
for ( netreq_p = req->netreqs
; !r && (netreq = *netreq_p)
; netreq_p++) {
- if ((r = _getdns_submit_netreq(netreq))) {
+ if ((r = _getdns_submit_netreq(netreq, &now_ms))) {
if (r == DNS_REQ_FINISHED) {
if (return_netreq_p)
*return_netreq_p = NULL;
return GETDNS_RETURN_GOOD;
}
- netreq->state = NET_REQ_FINISHED;
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
}
}
break;
diff --git a/src/general.h b/src/general.h
index 29b52f47..e0860c78 100644
--- a/src/general.h
+++ b/src/general.h
@@ -45,8 +45,20 @@
#define DNS_REQ_FINISHED -1
void _getdns_call_user_callback(getdns_dns_req *, getdns_dict *);
+
+/* Change state of the netreq req.
+ * - Increments context->netreqs_in_flight
+ * when state changes from NOT_SENT to IN_FLIGHT
+ * - Decrements context->netreqs_in_flight
+ * when state changes from IN_FLIGHT to FINISHED, TIMED_OUT or ERRORED
+ * - Resubmits NOT_SENT netreqs from context->pending_netreqs,
+ * when # pending_netreqs < limit_outstanding_queries
+ */
+void _getdns_netreq_change_state(
+ getdns_network_req *netreq, network_req_state new_state);
+
void _getdns_check_dns_req_complete(getdns_dns_req *dns_req);
-int _getdns_submit_netreq(getdns_network_req *netreq);
+int _getdns_submit_netreq(getdns_network_req *netreq, uint64_t *now_ms);
getdns_return_t
diff --git a/src/getdns/getdns.h.in b/src/getdns/getdns.h.in
index 048c2056..85c297c3 100644
--- a/src/getdns/getdns.h.in
+++ b/src/getdns/getdns.h.in
@@ -47,12 +47,12 @@ extern "C" {
#define GETDNS_COMPILATION_COMMENT "@GETDNS_COMPILATION_COMMENT@"
-/** \defgroup getdnsAPI Official getdns API
- * @{
+/**
+ * \defgroup functions Functions
+ * \defgroup valuesandtexts Values and texts
*/
-
-/** \defgroup valuesandtexts Values and texts
+/** \addtogroup valuesandtexts Values and texts
* @{
*/
@@ -120,6 +120,7 @@ typedef enum getdns_return_t {
* \defgroup namespacetypestext Namespace types and texts
* @{
*/
+
typedef enum getdns_namespace_t {
GETDNS_NAMESPACE_DNS = 500,
GETDNS_NAMESPACE_LOCALNAMES = 501,
@@ -376,6 +377,7 @@ typedef enum getdns_callback_type_t {
#define GETDNS_RRTYPE_ISDN 20
#define GETDNS_RRTYPE_RT 21
#define GETDNS_RRTYPE_NSAP 22
+#define GETDNS_RRTYPE_NSAP_PTR 23
#define GETDNS_RRTYPE_SIG 24
#define GETDNS_RRTYPE_KEY 25
#define GETDNS_RRTYPE_PX 26
@@ -405,6 +407,7 @@ typedef enum getdns_callback_type_t {
#define GETDNS_RRTYPE_NSEC3 50
#define GETDNS_RRTYPE_NSEC3PARAM 51
#define GETDNS_RRTYPE_TLSA 52
+#define GETDNS_RRTYPE_SMIMEA 53
#define GETDNS_RRTYPE_HIP 55
#define GETDNS_RRTYPE_NINFO 56
#define GETDNS_RRTYPE_RKEY 57
@@ -433,6 +436,7 @@ typedef enum getdns_callback_type_t {
#define GETDNS_RRTYPE_ANY 255
#define GETDNS_RRTYPE_URI 256
#define GETDNS_RRTYPE_CAA 257
+#define GETDNS_RRTYPE_AVC 258
#define GETDNS_RRTYPE_TA 32768
#define GETDNS_RRTYPE_DLV 32769
/** @}
@@ -485,21 +489,45 @@ typedef enum getdns_callback_type_t {
#define GETDNS_RCODE_BADNAME 20
#define GETDNS_RCODE_BADALG 21
#define GETDNS_RCODE_BADTRUNC 22
+#define GETDNS_RCODE_COOKIE 23
/** @}
*/
+/**
+ * Many calls in the DNS API require a DNS context. A DNS context contains
+ * the information that the API needs in order to process DNS calls, such
+ * as the locations of upstream DNS servers, DNSSEC trust anchors, and so on.
+ * The internal structure of the DNS context is opaque, and might be different
+ * on each OS. When a context is passed to any function, it must be an
+ * allocated context; the context must not be NULL.
+ *
+ * Use getdns_context_set_* functions to configure a context.
+ */
typedef struct getdns_context getdns_context;
+
+/**
+ * When scheduling asynchronous requests, transaction identifiers associated
+ * with the request are returned. These identifiers are of the type:
+ * getdns_transaction_t. These identifiers can be used to associate answers
+ * with requests, and also to cancel outstanding requests.
+ */
typedef uint64_t getdns_transaction_t;
/**
- * used to check data types within complex types (dict, list)
+ * getdns_list_get_data_type() and getdns_dict_get_data_type() return the type
+ * of data on an index in a getdns_list, or on a name in a getdns_dict.
*/
typedef enum getdns_data_type
{
t_dict, t_list, t_int, t_bindata
} getdns_data_type;
+
+
+/**
+ * A struct to hold binary data.
+ */
typedef struct getdns_bindata
{
size_t size;
@@ -522,31 +550,27 @@ typedef struct getdns_list getdns_list;
*/
-/** \defgroup functions Functions
+/** \addtogroup functions Functions
* @{
*/
/* Specify the order of the following groups manually here so they appear in
a better order in doxygen */
/**
- * \defgroup list_create getdns_list creation/destruction functions
- * \defgroup getdns_list_set getdns_list_set functions
- * \defgroup getdns_list_get_functions getdns_list_get functions
- * \defgroup dict_create getdns_dict creation/destruction functions
- * \defgroup getdns_dict_set getdns_dict_set functions
- * \defgroup getdns_dict_get_functions getdns_dict_get functions
- * \defgroup context_create getdns_context creation/destruction functions
- * \defgroup context_set getdns_context_set functions
- * \defgroup callbackfns getdns_callback functions
- * \defgroup eventloops getdns event loop extension functions
- * \defgroup funcs Asynchronous API functions
- * \defgroup syncfuncs Synchronous API functions that do not use callbacks
+ * \defgroup getdns_context Creating, destroying, configuring and reading configuration from getdns_contexts
+ * \defgroup getdns_dict Creating, destroying, reading from and manipulating getdns_dicts
+ * \defgroup getdns_list Creating, destroying, reading from and manipulating getdns_lists
+ * \defgroup asyncfuncs Scheduling asynchronous requests
+ * \defgroup syncfuncs Performing synchronous requests
+ * \defgroup eventloops Event loop extension functions
+ * \defgroup versionfuncs Version functions
+ * \defgroup dnssecfuncs DNSSEC functions
* \defgroup utils Utility functions
*/
/**
- * \addtogroup getdns_list_get_functions getdns_list_get functions
+ * \addtogroup getdns_list
* @{
*/
@@ -625,7 +649,7 @@ getdns_return_t getdns_list_get_int(const getdns_list *list, size_t index,
/**
- * \addtogroup getdns_dict_get_functions getdns_dict_get functions
+ * \addtogroup getdns_dict
* @{
*/
@@ -699,7 +723,7 @@ getdns_return_t getdns_dict_get_int(const getdns_dict *dict,
/**
- * \addtogroup list_create getdns_list creation/destruction functions
+ * \addtogroup getdns_list
* @{
*/
@@ -708,12 +732,46 @@ getdns_return_t getdns_dict_get_int(const getdns_dict *dict,
* @return pointer to an allocated list, NULL if insufficient memory
*/
getdns_list *getdns_list_create();
+
+/**
+ * create a new list with no items, creating and initializing it with the
+ * custom memory function from context. These memory functions will be used
+ * for creating, and inherited by the list members when populating the list.
+ * The custom deallocator will be used for destroying the list.
+ * @param context The context from which the custom memory functions will be
+ * used to create and initialize the list.
+ * @return pointer to an allocated list, NULL if insufficient memory
+ */
getdns_list *getdns_list_create_with_context(getdns_context *context);
+
+/**
+ * create a new list with no items, creating and initializing it with the
+ * provided custom memory function. These memory functions will be used
+ * for creating, and inherited by the list members when populating the list.
+ * The custom deallocator will be used for destroying the list.
+ * @param malloc Custom allocator
+ * @param realloc Custom reallocator
+ * @param free Custom deallocator
+ * @return pointer to an allocated list, NULL if insufficient memory
+ */
getdns_list *getdns_list_create_with_memory_functions(
void *(*malloc) (size_t),
void *(*realloc) (void *, size_t),
void (*free) (void *)
);
+
+/**
+ * create a new list with no items, creating and initializing it with the
+ * provided extended custom memory function. These memory functions will be
+ * used for creating, and inherited by the list members when populating the
+ * list. The custom deallocator will be used for destroying the list.
+ * @param userarg Will be passed as the first argument to the extended
+ * custom malloc, realloc, and free.
+ * @param malloc Custom allocator
+ * @param realloc Custom reallocator
+ * @param free Custom deallocator
+ * @return pointer to an allocated list, NULL if insufficient memory
+ */
getdns_list *getdns_list_create_with_extended_memory_functions(
void *userarg,
void *(*malloc) (void *userarg, size_t),
@@ -735,7 +793,7 @@ void getdns_list_destroy(getdns_list *list);
/**
- * \addtogroup getdns_list_set getdns_list_set functions
+ * \addtogroup getdns_list
* @{
*/
@@ -785,7 +843,7 @@ getdns_return_t getdns_list_set_int(getdns_list *list, size_t index,
/**
- * \addtogroup dict_create getdns_dict creation/destruction functions
+ * \addtogroup getdns_dict
* @{
*/
@@ -794,12 +852,46 @@ getdns_return_t getdns_list_set_int(getdns_list *list, size_t index,
* @return pointer to an allocated dictionary, NULL if insufficient memory
*/
getdns_dict *getdns_dict_create();
+
+/**
+ * create a new dict with no items, creating and initializing it with the
+ * custom memory function from context. These memory functions will be used
+ * for creating, and inherited by the list members when populating the dict.
+ * The custom deallocator will be used for destroying the dict.
+ * @param context The context from which the custom memory functions will be
+ * used to create and initialize the dict.
+ * @return pointer to an allocated dict, NULL if insufficient memory
+ */
getdns_dict *getdns_dict_create_with_context(getdns_context *context);
+
+/**
+ * create a new dict with no items, creating and initializing it with the
+ * provided custom memory function. These memory functions will be used
+ * for creating, and inherited by the dict members when populating the dict.
+ * The custom deallocator will be used for destroying the dict.
+ * @param malloc Custom allocator
+ * @param realloc Custom reallocator
+ * @param free Custom deallocator
+ * @return pointer to an allocated dict, NULL if insufficient memory
+ */
getdns_dict *getdns_dict_create_with_memory_functions(
void *(*malloc) (size_t),
void *(*realloc) (void *, size_t),
void (*free) (void *)
);
+
+/**
+ * create a new dict with no items, creating and initializing it with the
+ * provided extended custom memory function. These memory functions will be
+ * used for creating, and inherited by the dict members when populating the
+ * dict. The custom deallocator will be used for destroying the dict.
+ * @param userarg Will be passed as the first argument to the extended
+ * custom malloc, realloc, and free.
+ * @param malloc Custom allocator
+ * @param realloc Custom reallocator
+ * @param free Custom deallocator
+ * @return pointer to an allocated dict, NULL if insufficient memory
+ */
getdns_dict *getdns_dict_create_with_extended_memory_functions(
void *userarg,
void *(*malloc) (void *userarg, size_t),
@@ -818,12 +910,21 @@ void getdns_dict_destroy(getdns_dict *dict);
/**
- * \addtogroup getdns_dict_set getdns_dict_set functions
+ * \addtogroup getdns_dict
* @{
*/
+/**
+ * create a new entry in the dictionary, or replace the value of an existing entry
+ * this routine makes a copy of the child_dict_
+ * @param dict dictionary in which to add or change the value
+ * @param name key that identifies which item in the dictionary to add/change
+ * @param child_dict value to assign to the node identified by name
+ * @return GETDNS_RETURN_GOOD on success
+ */
getdns_return_t getdns_dict_set_dict(getdns_dict *dict,
const char *name, const getdns_dict *child_dict);
+
/**
* create a new entry in the dictionary, or replace the value of an existing entry
* this routine makes a copy of the child_list
@@ -853,6 +954,14 @@ getdns_return_t getdns_dict_set_bindata(getdns_dict *dict,
*/
getdns_return_t getdns_dict_set_int(getdns_dict *dict, const char *name,
uint32_t child_uint32);
+
+/**
+ * creates a string that describes the dictionary in a human readable form
+ * one line per item in the dictionary
+ * @param some_dict dictionary to pretty print
+ * @return character array (caller must free this) containing pretty string
+ */
+char *getdns_pretty_print_dict(const getdns_dict *some_dict);
/** @}
*/
@@ -867,23 +976,46 @@ getdns_return_t getdns_dict_set_int(getdns_dict *dict, const char *name,
*/
getdns_return_t getdns_dict_remove_name(getdns_dict *dict, const char *name);
-
/**
- * \addtogroup callbackfns getdns_callback functions
+ * \addtogroup asyncfuncs
+ * @{
+ */
+/**
+ * The type of the callback function that must be registered when scheduling
+ * asynchronous requests. The registered function will be called from the
+ * eventloop with the following parameters.
+ * @see callbacktype
+ * @param context The DNS context that was used in the calling function
+ * @param callback_type Supplies the reason for the callback.
+ * This will be one of:
+ * - GETDNS_CALLBACK_COMPLETE The response has the
+ * requested data in it
+ * - GETDNS_CALLBACK_CANCEL The calling program cancelled
+ * the callback; response is NULL
+ * - GETDNS_CALLBACK_TIMEOUT The requested action timed
+ * out; response is filled in with empty structures or
+ * will contain additional information about the timeout
+ * when used in combination with the
+ * return_call_reporting extension.
+ * - GETDNS_CALLBACK_ERROR The requested action had an
+ * error; response is NULL.
+ * @param response A response object with the response data.
+ * The application is responsible for cleaning up the response
+ * object with getdns_dict_destroy.
+ * @param userarg Identical to the userarg passed to the calling function.
+ * @param transaction_id The transaction identifier that was assigned by the
+ * calling function.
*/
-/* Callback arguments */
typedef void (*getdns_callback_t) (getdns_context *context,
getdns_callback_type_t callback_type,
getdns_dict * response,
void *userarg, getdns_transaction_t transaction_id);
-/**
- * \addtogroup funcs Asynchronous API functions
- * @{
- */
/**
* retrieve general DNS data
+ * @see rrtypes
+ * @see getdns_general_sync
* @param context pointer to a previously created context to be used for this call
* @param name the ASCII based domain name to lookup
* @param request_type RR type for the query, e.g. GETDNS_RR_TYPE_NS
@@ -903,6 +1035,7 @@ getdns_general(getdns_context *context,
/**
* retrieve address assigned to a DNS name
+ * @see getdns_address_sync
* @param context pointer to a previously created context to be used for this call
* @param name the ASCII based domain name to lookup
* @param extensions dict data structures, NULL to use no extensions
@@ -920,6 +1053,7 @@ getdns_address(getdns_context *context,
/**
* retrieve hostname assigned to an IP address
+ * @see getdns_hostname_sync
* @param context pointer to a previously created context to be used for this call
* @param address the address to look up
* @param extensions dict data structures, NULL to use no extensions
@@ -937,6 +1071,7 @@ getdns_hostname(getdns_context *context,
/**
* retrieve a service assigned to a DNS name
+ * @see getdns_service_sync
* @param context pointer to a previously created context to be used for this call
* @param name the ASCII based domain name to lookup
* @param extensions dict data structures, NULL to use no extensions
@@ -956,7 +1091,7 @@ getdns_service(getdns_context *context,
/**
- * \addtogroup context_create getdns_context creation/destruction functions
+ * \addtogroup getdns_context
* @{
*/
@@ -966,7 +1101,6 @@ getdns_service(getdns_context *context,
* (e.g. CRYPTO_THREADID_set_call) depending on the library version used.
* @param context context that can be used immediately with other API calls
* @param set_from_os set to 1 to initialize the context with os defaults
- * the second bit set (2) prevents OpenSSL library initialization.
* @return GETDNS_RETURN_GOOD on success
*/
getdns_return_t
@@ -979,7 +1113,6 @@ getdns_context_create(getdns_context ** context, int set_from_os);
* (e.g. CRYPTO_THREADID_set_call) depending on the library version used.
* @param context context that can be used immediately with other API calls
* @param set_from_os set to 1 to initialize the context with os defaults
- * the second bit set (2) prevents OpenSSL library initialization.
* @param malloc custom malloc function
* @param realloc custom realloc function
* @param free custom free function
@@ -1001,7 +1134,6 @@ getdns_context_create_with_memory_functions(
* (e.g. CRYPTO_THREADID_set_call) depending on the library version used.
* @param context context that can be used immediately with other API calls
* @param set_from_os set to 1 to initialize the context with os defaults
- * the second bit set (2) prevents OpenSSL library initialization.
* @param userarg parameter passed to the custom malloc, realloc and free functions
* @param malloc custom malloc function
* @param realloc custom realloc function
@@ -1018,15 +1150,24 @@ getdns_context_create_with_extended_memory_functions(
void (*free) (void *userarg, void *)
);
+/**
+ * destroy the context. All outstanding requests will be cancelled with
+ * the getdns_cancel_callback() function.
+ */
void getdns_context_destroy(getdns_context *context);
/** @}
*/
/**
- * \addtogroup callbackfns getdns_callback functions
+ * \addtogroup asyncfuncs
* @{
*/
+/**
+ * Cancel an outstanding asynchronous request. The callback registered with
+ * the request will be called with the getdns_callback_type_t set to
+ * GETDNS_CALLBACK_CANCEL and the response set to NULL.
+ */
getdns_return_t
getdns_cancel_callback(getdns_context *context,
getdns_transaction_t transaction_id);
@@ -1035,7 +1176,7 @@ getdns_cancel_callback(getdns_context *context,
/**
- * \addtogroup syncfuncs Synchronous API functions that do not use callbacks
+ * \addtogroup syncfuncs
* @{
*/
/** These functions do not use callbacks, when the application calls one of these
@@ -1046,6 +1187,8 @@ getdns_cancel_callback(getdns_context *context,
/**
* retrieve general DNS data
+ * @see rrtypes
+ * @see getdns_general
* @param context pointer to a previously created context to be used for this call
* @param name the ASCII based domain name to lookup
* @param request_type RR type for the query, e.g. GETDNS_RR_TYPE_NS
@@ -1062,6 +1205,7 @@ getdns_general_sync(getdns_context *context,
/**
* retrieve address assigned to a DNS name
+ * @see getdns_address
* @param context pointer to a previously created context to be used for this call
* @param name the ASCII based domain name to lookup
* @param extensions dict data structures, NULL to use no extensions
@@ -1076,6 +1220,7 @@ getdns_address_sync(getdns_context *context,
/**
* retrieve hostname assigned to an IP address
+ * @see getdns_hostname
* @param context pointer to a previously created context to be used for this call
* @param address the address to look up
* @param extensions dict data structures, NULL to use no extensions
@@ -1090,6 +1235,7 @@ getdns_hostname_sync(getdns_context *context,
/**
* retrieve a service assigned to a DNS name
+ * @see getdns_service
* @param context pointer to a previously created context to be used for this call
* @param name the ASCII based domain name to lookup
* @param extensions dict data structures, NULL to use no extensions
@@ -1110,36 +1256,119 @@ getdns_service_sync(getdns_context *context,
* @{
*/
+/**
+ * Convert a domain name in DNS wire format to presentation format.
+ * The newly allocated string should be freed with free.
+ * @param dns_name_wire_fmt A bindata to the DNS name in wire format
+ * @param fqdn_as_string A reference to a pointer that will be set
+ * to a newly allocated string containing the
+ * presentation format of the name. The caller
+ * is responsible for deallocate this space with free().
+ * @return GETDNS_RETURN_GOOD on success or GETDNS_RETURN_GENERIC_ERROR
+ * when the wireformat name could not be parsed.
+ */
getdns_return_t
getdns_convert_dns_name_to_fqdn(
const getdns_bindata *dns_name_wire_fmt,
char **fqdn_as_string);
+/**
+ * Convert a domain name in presentation format to DNS wire format.
+ * @param fqdn_as_string The name to convert in presentation format.
+ * @param dns_name_wire_fmt A reference to a pointer that will be set
+ * to a newly allocated bindata containing the
+ * DNS wire format of the name. The caller
+ * is responsible for deallocate this space with free().
+ * @return GETDNS_RETURN_GOOD on success or GETDNS_RETURN_GENERIC_ERROR
+ * when the presentation format name could not be parsed.
+ */
getdns_return_t
getdns_convert_fqdn_to_dns_name(
const char *fqdn_as_string,
getdns_bindata **dns_name_wire_fmt);
+/**
+ * Convert an Unicode encoded label to ASCII encoding following the
+ * rules for IDNA 2008 described in RFC 5890-5892.
+ * @param ulabel The Unicode encoded label to convert.
+ * @return The ASCII encoding label. The caller is responsible for deallocate
+ * this space with free().
+ */
char *getdns_convert_ulabel_to_alabel(const char *ulabel);
+/**
+ * Convert an ASCII encoded label to Unicode encoding following the
+ * rules for IDNA 2008 described in RFC 5890-5892.
+ * @param alabel The ASCII encoded label to convert.
+ * @return The Unicode encoding label. The caller is responsible for
+ * deallocation with free().
+ */
char *getdns_convert_alabel_to_ulabel(const char *alabel);
+/** @}
+ */
+
+/**
+ * \addtogroup dnssecfuncs
+ * @{
+ */
+
+/**
+ * Offline DNSSEC validate Resource Records with the help of support
+ * records and a DNSSEC trust anchor.
+ * @see dnssecvalues
+ * @param to_validate This is a list of reply_dicts to validate (as can
+ * be seen under "replies_tree" in a response dict), or
+ * an RRset with signatures represented as a list of
+ * rr_dicts. The format of rr_dict can be seen in
+ * the sections of reply_dicts in response dicts.
+ * It is also possible to validate the non-existance
+ * of a query. Besides all the necessary NSEC(3)s plus
+ * signature, the to_validate should then also contain
+ * a question rr_dict with a qname, qclass and qtype.
+ * @param support_records A list of all the DNSKEY, DS and NSEC(3) RRsets
+ * (in the form of rr_dicts) that may be used to
+ * validate the RRsets or replies in to_validate.
+ * The value returned under "validation_chain" in a
+ * response dict when the dnssec_return_validation_chain
+ * extension was used, can be used directly for this.
+ * @param trust_anchors A list of rr_dicts containing the DNSSEC trust anchors.
+ * The return value of the getdns_root_trust_anchor()
+ * can be used directly for this.
+ * @return The function returns one of GETDNS_DNSSEC_SECURE,
+ * GETDNS_DNSSEC_BOGUS, GETDNS_DNSSEC_INDETERMINATE, or GETDNS_DNSSEC_INSECURE
+ * depending on the validation status.
+ */
getdns_return_t
getdns_validate_dnssec(const getdns_list *to_validate,
const getdns_list *support_records,
const getdns_list *trust_anchors);
-/* Get root trust anchor */
+/**
+ * Get the default list of trust anchor records that is used by the library
+ * to validate DNSSEC.
+ * @param utc_date_of_anchor Set to the number of seconds since epoch
+ * the trust anchors were obtained
+ * @return The list of DNSSEC trust anchors, or NULL on error. The caller is
+ * responsible for deallocating the list with getdns_list_destroy().
+ */
getdns_list *getdns_root_trust_anchor(time_t *utc_date_of_anchor);
-/**
- * creates a string that describes the dictionary in a human readable form
- * one line per item in the dictionary
- * @param some_dict dictionary to pretty print
- * @return character array (caller must free this) containing pretty string
+/** @}
*/
-char *getdns_pretty_print_dict(const getdns_dict *some_dict);
+/**
+ * \addtogroup utils
+ * @{
+ */
+
+/**
+ * Converts a getdns_bindata representing an IPv4 or IPv6 address to a
+ * textual representation.
+ * @param bindata_of_ipv4_or_ipv6_address The IP address to convert.
+ * @return character array (caller must free this) containing the textual
+ * representation of the address.
+ */
char *getdns_display_ip_address(const getdns_bindata
*bindata_of_ipv4_or_ipv6_address);
@@ -1148,9 +1377,23 @@ char *getdns_display_ip_address(const getdns_bindata
/**
- * \addtogroup context_set getdns_context_set functions
+ * \addtogroup getdns_context
* @{
*/
+
+/**
+ * An application can be notified when the context is changed.
+ * Note that this implementation has an extended version of this function
+ * in which an additional userarg parameter can be registered:
+ * #getdns_context_set_update_callback .
+ * @see contextcodetypestext
+ * @param context The context for which to monitor changes
+ * @param value The callback function that will be called when any context is
+ * changed. A update callback function can be deregistered by
+ * passing NULL.
+ * @return GETDNS_RETURN_GOOD when succesful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL.
+ */
getdns_return_t
getdns_context_set_context_update_callback(
getdns_context *context,
@@ -1158,73 +1401,366 @@ getdns_context_set_context_update_callback(
getdns_context_code_t changed_item)
);
+/**
+ * Specify whether DNS queries are performed with recursive lookups or as a
+ * stub resolver. The default value is GETDNS_RESOLUTION_RECURSING.
+ * @see getdns_context_get_resolution_type
+ * @see resolutiontypestext
+ * @param context The context to configure
+ * @param value GETDNS_RESOLUTION_RECURSING or GETDNS_RESOLUTION_STUB.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_CONTEXT_UPDATE_FAIL with unknown resolution types
+ * @return GETDNS_RETURN_NOT_IMPLEMENTED when getdns was compiled for stub
+ * resolution only and recursing resolution type was requested.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL.
+ */
getdns_return_t
getdns_context_set_resolution_type(getdns_context *context,
getdns_resolution_t value);
+/**
+ * Sets the ordered list of namespaces that will be queried.
+ * This context setting is ignored for the getdns_general and
+ * getdns_general_sync functions; it is used for the other funtions.
+ * When a normal lookup is done, the API does the lookups in the order given
+ * and stops when it gets the first result
+ * @see getdns_context_get_namespaces
+ * @see namespacetypestext
+ * @param context The context to configure
+ * @param namespace_count The number of values in the namespaces list.
+ * @param namespaces An ordered list of namespaces that will be queried.
+ * The values are: GETDNS_NAMESPACE_DNS,
+ * GETDNS_NAMESPACE_LOCALNAMES, GETDNS_NAMESPACE_NETBIOS,
+ * GETDNS_NAMESPACE_MDNS, and GETDNS_NAMESPACE_NIS.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_CONTEXT_UPDATE_FAIL with unknown namespace types
+ * @return GETDNS_RETURN_NOT_IMPLEMENTED when unsupported namespaces were
+ * given. Currently this implementation supports only
+ * GETDNS_NAMESPACE_DNS, GETDNS_NAMESPACE_LOCALNAMES and has an
+ * draft implementation of GETDNS_NAMESPACE_MDNS, which has to be
+ * enabled at configure time.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL.
+ */
getdns_return_t
getdns_context_set_namespaces(getdns_context *context,
size_t namespace_count, getdns_namespace_t *namespaces);
+/**
+ * Specifies what transport are used for DNS lookups. The default is
+ * GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP. Use of this function
+ * is discouraged. Please use #getdns_context_set_dns_transport_list()
+ * instead of this function.
+ * @see getdns_context_get_dns_transport
+ * @see transporttypestext
+ * @see getdns_context_set_dns_transport_list
+ * @param context The context to configure
+ * @param value The transport to use for DNS lookups.
+ * The value is GETDNS_TRANSPORT_UDP_FIRST_AND_FALL_BACK_TO_TCP,
+ * GETDNS_TRANSPORT_UDP_ONLY, GETDNS_TRANSPORT_TCP_ONLY,
+ * GETDNS_TRANSPORT_TCP_ONLY_KEEP_CONNECTIONS_OPEN,
+ * GETDNS_TRANSPORT_TLS_ONLY_KEEP_CONNECTIONS_OPEN or
+ * GETDNS_TRANSPORT_TLS_FIRST_AND_FALL_BACK_TO_TCP_KEEP_CONNECTIONS_OPEN.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_CONTEXT_UPDATE_FAIL with unknown values
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL.
+ */
getdns_return_t
getdns_context_set_dns_transport(getdns_context *context,
getdns_transport_t value);
+/**
+ * Specifies what transport is used for DNS lookups. The default is a list
+ * containing GETDNS_TRANSPORT_UDP then GETDNS_TRANSPORT_TCP. The API will
+ * return information on the actual transport used to fulfill the request in
+ * the response dict, when the return_call_reporting extension is used.
+ * @see getdns_context_get_dns_transport_list
+ * @see transportlisttypestext
+ * @see getdns_context_set_dns_transport
+ * @param context The context to configure
+ * @param transport_count The number of values in the transports list.
+ * @param transports An ordered list of transports that will be used for DNS
+ * lookups. If only one transport value is specified it will
+ * be the only transport used. Should it not be available
+ * basic resolution will fail. Fallback transport options are
+ * specified by including multiple values in the list.
+ * The values are: GETDNS_TRANSPORT_UDP, GETDNS_TRANSPORT_TCP,
+ * or GETDNS_TRANSPORT_TLS
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_CONTEXT_UPDATE_FAIL with unknown values
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL.
+ */
getdns_return_t
getdns_context_set_dns_transport_list(getdns_context *context,
size_t transport_count, getdns_transport_list_t *transports);
+/**
+ * Specify number of milliseconds the API will leave an idle TCP or TLS
+ * connection open for (idle means no outstanding responses and no pending
+ * queries). When set to 0, all currently open idle connections will be
+ * closed immediately. The default is 0.
+ * Note with synchronous queries, idle connections can not reliably be timed.
+ * Each new synchronous request, will reset the counter no matter the time
+ * in between requests, and thus leave the connection open always. This
+ * setting is thus only meaningful when doing requests asynchronously.
+ * @see getdns_context_get_idle_timeout
+ * @param context The context to configure
+ * @param timeout The number of milliseconds the API will leave an idle TCP
+ * or TLS connection open for
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL.
+ */
getdns_return_t
getdns_context_set_idle_timeout(getdns_context *context, uint64_t timeout);
+/**
+ * Limit the number of outstanding DNS queries. When more than limit requests
+ * are scheduled, they are kept on an internal queue, to be rescheduled when
+ * the number of outstanding queries drops below the limit again.
+ * A value of 0 indicates that the number of outstanding DNS queries is
+ * unlimited, however, queries will be put on the internal queue too when
+ * system resources are exhausted (i.e. number of available sockets).
+ * The default value is 0.
+ * @see getdns_context_get_limit_outstanding_queries
+ * @param context The context to configure
+ * @param limit The maximum number of outstanding DNS queries.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL.
+ */
getdns_return_t
getdns_context_set_limit_outstanding_queries(getdns_context *context,
uint16_t limit);
+/**
+ * Specifies number of milliseconds the API will wait for request to return.
+ * The default is 5000 (i.e. 5 seconds).
+ * @see getdns_context_get_timeout
+ * @param context The context to configure
+ * @param timeout The number of milliseconds the API will wait for request to
+ * return.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER for a timeout 0,
+ * or when context was NULL
+ */
getdns_return_t
getdns_context_set_timeout(getdns_context *context, uint64_t timeout);
+/**
+ * Specifies whether or not DNS queries follow redirects.
+ * The default value is GETDNS_REDIRECTS_FOLLOW.
+ * In this implementation, redirects are only actively followed in the recursing
+ * resolution mode. The GETDNS_REDIRECTS_DO_NOT_FOLLOW will not prevent this,
+ * but the response will be stripped of all resource records that could only be
+ * found through following redirects. The setting will do this with answers
+ * provided by an upstream in stub resolution mode too.
+ * @see getdns_context_get_follow_redirects
+ * @see redirectpoliciestext
+ * @param context The context to configure
+ * @param value GETDNS_REDIRECTS_FOLLOW for normal following of redirects
+ * through CNAME and DNAME; or GETDNS_REDIRECTS_DO_NOT_FOLLOW to
+ * cause any lookups that would have gone through CNAME and DNAME
+ * to return the CNAME or DNAME, not the eventual target.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER for an unknown value,
+ * or when context was NULL
+ */
getdns_return_t
getdns_context_set_follow_redirects(getdns_context *context,
getdns_redirects_t value);
+/**
+ * Configure the list of addresses to be used for looking up top-level domains.
+ * The default is the list of "normal" IANA root servers
+ * @see getdns_context_get_dns_root_servers
+ * @param context The context to configure
+ * @param addresses The list contains dicts that are addresses to be used for
+ * looking up top-level domains. Each dict in the list
+ * contains at least two names: address_type (whose value is
+ * a bindata; it is currently either "IPv4" or "IPv6") and
+ * address_data (whose value is a bindata).
+ * This implementation also accepts a list of addressxi
+ * bindatas. Or a list of rr_dicts for address records (i.e.
+ * the additional section of a NS query for ".", or a with
+ * getdns_fp2rr_list() converted root.hints file).
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_ CONTEXT_UPDATE_FAIL when there were problems
+ * parsing the provided addresses list.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_dns_root_servers(getdns_context *context,
getdns_list *addresses);
+/**
+ * Specifies whether, how and when to append a suffix to the query string.
+ * The non-standard implementation default is
+ * GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST.
+ * @see getdns_context_get_append_name
+ * @see suffixappendtypestext
+ * @param context The context to configure
+ * @param value GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST,
+ * GETDNS_APPEND_NAME_ALWAYS,
+ * GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE,
+ * GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE,
+ * or GETDNS_APPEND_NAME_NEVER.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_ CONTEXT_UPDATE_FAIL with unknown values.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_append_name(getdns_context *context,
getdns_append_name_t value);
+/**
+ * Specify the list of suffixes to be appended based on the value off the
+ * append_name setting. The default is read from OS, or an empty list when
+ * the context is not initialized with OS defaults.
+ * @see getdns_context_get_suffix
+ * @param context The context to configure
+ * @param value A list of bindatas that are strings that are to be appended
+ * based on the value off the append_name setting.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_ CONTEXT_UPDATE_FAIL with unknown values.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_suffix(getdns_context *context, getdns_list *value);
+/**
+ * Specify the DNSSEC trust anchors. The default is to read it from
+ * @TRUST_ANCHOR_FILE@.
+ * @see getdns_context_get_dnssec_trust_anchors
+ * @param context The context to configure
+ * @param value A list of rr_dicts for DS or DNSKEY that are the DNSSEC
+ * trust anchors.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_ CONTEXT_UPDATE_FAIL with unknown values.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_dnssec_trust_anchors(getdns_context *context,
getdns_list *value);
+/**
+ * Specify the DNSSEC allowed skew. The default is 0.
+ * @see getdns_context_get_dnssec_allowed_skew
+ * @param context The context to configure
+ * @param value The number of seconds of skew that is allowed in either
+ * direction when checking an RRSIG's Expiration and Inception
+ * fields.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_dnssec_allowed_skew(getdns_context *context,
uint32_t value);
+
+/**
+ * Specify where a stub resolver will send queries. The default value is set
+ * from the OS when the context is created with the set_from_os flag, or
+ * empty otherwise.
+ * @see getdns_context_get_upstream_recursive_servers
+ * @param context The context to configure
+ * @param upstream_list The upstreams are specified either by a getdns_bindata
+ * containing a IPv4 or IPv6 address in network format
+ * or a `getdns_dict`, containing at least a name
+ * `address_data` whose value is the address bindata, and
+ * optionally also:
+ * - `scode_id` containing an getdns_bindata with the
+ * scope ID for IPv6 link-local addresses.
+ * - `port` an integer specifying which port to use to
+ * contact this upstream over UDP and TCP;
+ * the default is 53
+ * - `tsig_algorithm` (a bindata) that is the name of the
+ * TSIG hash algorithm
+ * - `tsig_name` (a bindata) that is the name of the TSIG key
+ * - `tsig_secret` (a bindata) that is the TSIG key
+ * - `tls_port` (a integer) that is the port to use to
+ * contact this upstream over TLS
+ * - `tls_auth_name` (a bindata) that is the name of the
+ * upstream (as a bindata containing a string) which
+ * must be verified to confirm its identity.
+ * - `tls_pubkey_pinset` (a list) containing dicts with
+ * - `digest` which must be a bindata containing the
+ * text sha256
+ * - `value` A SHA256 hash of the `SubjectPublicKeyInfo`
+ * of the upstream, which will be used to authenticate
+ * it.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when `context` or `upstream_list` was `NULL`
+ * @return GETDNS_RETURN_CONTEXT_UPDATE_FAIL when there were problems parsing
+ * the `upstream_list`.
+ */
getdns_return_t
getdns_context_set_upstream_recursive_servers(getdns_context *context,
getdns_list *upstream_list);
+/**
+ * Set the maximum UDP payload size advertised in a EDNS0 OPT record.
+ * When not set (the default), outgoing values will adhere to the suggestions
+ * in RFC 6891 and may follow a scheme that uses multiple values to maximize
+ * receptivity.
+ * @see getdns_context_get_edns_maximum_udp_payload_size
+ * @see getdns_context_unset_edns_maximum_udp_payload_size
+ * @param context The context to configure
+ * @param value The maximum UDP payload size advertised in a EDNS0 OPT record.
+ * The value must be between 512 and 65536
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_edns_maximum_udp_payload_size(getdns_context *context,
uint16_t value);
+/**
+ * Set the rcode advertised in a EDNS0 OPT record. The default is 0.
+ * @see getdns_context_get_edns_extended_rcode
+ * @param context The context to configure
+ * @param value A value between 0 and 255.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_edns_extended_rcode(getdns_context *context,
uint8_t value);
+/**
+ * Set the version advertised in a EDNS0 OPT record. The default is 0.
+ * @see getdns_context_get_edns_version
+ * @param context The context to configure
+ * @param value A value between 0 and 255.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_edns_version(getdns_context *context, uint8_t value);
+/**
+ * Set the DO ibit advertised in a EDNS0 OPT record. The default is 0.
+ * However use of any of the dnssec_* extension will override this setting
+ * and set the DO bit.
+ * @see getdns_context_get_edns_do_bit
+ * @param context The context to configure
+ * @param value A value between 0 and 1.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_edns_do_bit(getdns_context *context, uint8_t value);
+/**
+ * Specify custom memory management functions to be used with this context.
+ * The given memory management functions will be used for creating the response
+ * dicts. The response dicts inherit the custom memory management functions
+ * from the context and will deallocate themselves (and their members) with the
+ * custom deallocator. By default, the system `malloc`, `realloc`, and `free` are used.
+ * @param context The context to configure
+ * @param malloc A custom memory allocator. The default is `malloc`.
+ * @param realloc A custom memory reallocator. The default is `realloc`.
+ * @param free A custom memory deallocator. The default is `free`.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_memory_functions(getdns_context *context,
void *(*malloc) (size_t),
@@ -1232,6 +1768,22 @@ getdns_context_set_memory_functions(getdns_context *context,
void (*free) (void *)
);
+/**
+ * Specify custom extended memory management functions to be used with this
+ * context. The value of `userarg` argument will be passed to the custom
+ * `malloc`, `realloc`, and `free`.
+ * The response dicts inherit the custom memory management functions
+ * from the context and will deallocate themselves (and their members) with the
+ * custom deallocator. By default, the system `malloc`, `realloc`, and `free` are used.
+ * @param context The context to configure
+ * @param userarg This value will be passed as the `userarg` argument to the
+ * custom `malloc`, `realloc` and `free` function.
+ * @param malloc A custom memory allocator. The default is a wrapper for `malloc`.
+ * @param realloc A custom memory reallocator. The default is a wrapper for `realloc`.
+ * @param free A custom memory deallocator. The default is a wrapper for `free`.
+ * @return GETDNS_RETURN_GOOD when successful.
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context was NULL
+ */
getdns_return_t
getdns_context_set_extended_memory_functions(getdns_context *context,
void *userarg,
@@ -1242,16 +1794,28 @@ getdns_context_set_extended_memory_functions(getdns_context *context,
/** @}
*/
-/* api information support */
+/**
+ * Retrieve information about the API itself and inspect the current context.
+ * The returned dictionary can be used with getdns_context_config() directly
+ * to configure another context with precisely these settings.
+ * @param context The context from which to get the information
+ * @return A getdns_dict containing the following name/value pairs:
+ * - `version_string` (a bindata) represents the version string for this version of the DNS API.
+ * - `implementation_string` (a bindata) is a string showing which
+ * implementation of the getdns API this is. In our implementation
+ * this will always be set to "https://getdnsapi.net"
+ * - resolution_type (an int) is the type of resolver that the API is
+ * acting as in this context: GETDNS_RESOLUTION_RECURSING or
+ * GETDNS_RESOLUTION_STUB.
+ * - all_context (a dict) with names for all the other settings in
+ * context.
+ */
getdns_dict*
getdns_context_get_api_information(getdns_context* context);
/** @}
*/
-/** @}
- */
-
#ifdef __cplusplus
}
#endif
diff --git a/src/getdns/getdns_ext_libev.h b/src/getdns/getdns_ext_libev.h
index c65ef8d3..3a39530f 100644
--- a/src/getdns/getdns_ext_libev.h
+++ b/src/getdns/getdns_ext_libev.h
@@ -48,7 +48,21 @@ struct ev_loop;
/**
* \ingroup eventloops
*/
-/* For libevent, which we are using for these examples */
+/**
+ * Associate the libev ev_loop with the context, so that all
+ * asynchronous requests will schedule Input/Output with it.
+ * Synchronous requests will still use a default eventloop based on `poll()`.
+ * Applications need to @code #include @endcode
+ * and link with libgetdns_ext_ev to use this function.
+ * getdns needs to have been configured with --with-libev for this
+ * extension to be available.
+ * @param context The context to configure
+ * @param ev_loop The libev event loop to associate with this context.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_BAD_CONTEXT when context is NULL
+ * @return GETDNS_RETURN_INVALID_PARAMETER when ev_loop is NULL
+ * @return GETDNS_RETURN_MEMORY_ERROR when memory could not be allocated
+ */
getdns_return_t
getdns_extension_set_libev_loop(struct getdns_context *context,
struct ev_loop *ev_loop);
diff --git a/src/getdns/getdns_ext_libevent.h b/src/getdns/getdns_ext_libevent.h
index de364e3f..a7fbc9b5 100644
--- a/src/getdns/getdns_ext_libevent.h
+++ b/src/getdns/getdns_ext_libevent.h
@@ -47,7 +47,21 @@ struct event_base;
/**
* \ingroup eventloops
*/
-/* For libevent, which we are using for these examples */
+/**
+ * Associate the libevent event_base with the context, so that all
+ * asynchronous requests will schedule Input/Output with it.
+ * Synchronous requests will still use a default eventloop based on `poll()`.
+ * Applications need to @code #include @endcode
+ * and link with libgetdns_ext_event to use this function.
+ * getdns needs to have been configured with --with-libevent for this
+ * extension to be available.
+ * @param context The context to configure
+ * @param this_event_base The libevent event base to associate with this context.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_BAD_CONTEXT when context is NULL
+ * @return GETDNS_RETURN_INVALID_PARAMETER when this_event_base is NULL
+ * @return GETDNS_RETURN_MEMORY_ERROR when memory could not be allocated
+ */
getdns_return_t
getdns_extension_set_libevent_base(struct getdns_context *context,
struct event_base *this_event_base);
diff --git a/src/getdns/getdns_ext_libuv.h b/src/getdns/getdns_ext_libuv.h
index f8809149..03463499 100644
--- a/src/getdns/getdns_ext_libuv.h
+++ b/src/getdns/getdns_ext_libuv.h
@@ -47,7 +47,21 @@ struct uv_loop_s;
/**
* \ingroup eventloops
*/
-/* For libevent, which we are using for these examples */
+/**
+ * Associate the libuv uv_loop with the context, so that all
+ * asynchronous requests will schedule Input/Output with it.
+ * Synchronous requests will still use a default eventloop based on `poll()`.
+ * Applications need to @code #include @endcode
+ * and link with libgetdns_ext_uv to use this function.
+ * getdns needs to have been configured with --with-libuv for this
+ * extension to be available.
+ * @param context The context to configure
+ * @param uv_loop The libuv event loop to associate with this context.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_BAD_CONTEXT when context is NULL
+ * @return GETDNS_RETURN_INVALID_PARAMETER when uv_loop is NULL
+ * @return GETDNS_RETURN_MEMORY_ERROR when memory could not be allocated
+ */
getdns_return_t
getdns_extension_set_libuv_loop(struct getdns_context *context,
struct uv_loop_s *uv_loop);
diff --git a/src/getdns/getdns_extra.h.in b/src/getdns/getdns_extra.h.in
index 5fd10afb..571eeae7 100644
--- a/src/getdns/getdns_extra.h.in
+++ b/src/getdns/getdns_extra.h.in
@@ -39,23 +39,22 @@
#include
#include
#include
+#include
#ifdef __cplusplus
extern "C" {
#endif
-/** \defgroup UnofficialgetdnsAPI Additional API for getdns implementation
- * @{
- */
-
-/** \defgroup Uvaluesandtexts Additional values and texts
+/** \addtogroup valuesandtexts Values and texts
* @{
*/
/**
- * \defgroup Ureturnvaluesandtext Additional return values and texts
+ * \addtogroup returntypestext Return values and texts
* @{
*/
+#define GETDNS_RETURN_NO_UPSTREAM_AVAILABLE ((getdns_return_t) 398 )
+#define GETDNS_RETURN_NO_UPSTREAM_AVAILABLE_TEXT "None of the configured upstreams could be used to send queries on the specified transports"
#define GETDNS_RETURN_NEED_MORE_SPACE ((getdns_return_t) 399 )
#define GETDNS_RETURN_NEED_MORE_SPACE_TEXT "The buffer was too small"
/** @}
@@ -63,7 +62,7 @@ extern "C" {
/**
- * \defgroup Ucontextcodes Additional context codes and texts
+ * \addtogroup contextcodetypestext Context code values and texts
* @{
*/
#define GETDNS_CONTEXT_CODE_TLS_AUTHENTICATION 618
@@ -74,12 +73,18 @@ extern "C" {
#define GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE_TEXT "Change related to getdns_context_set_tls_query_padding_blocksize"
#define GETDNS_CONTEXT_CODE_PUBKEY_PINSET 621
#define GETDNS_CONTEXT_CODE_PUBKEY_PINSET_TEXT "Change related to getdns_context_set_pubkey_pinset"
+#define GETDNS_CONTEXT_CODE_ROUND_ROBIN_UPSTREAMS 622
+#define GETDNS_CONTEXT_CODE_ROUND_ROBIN_UPSTREAMS_TEXT "Change related to getdns_context_set_round_robin_upstreams"
+#define GETDNS_CONTEXT_CODE_TLS_BACKOFF_TIME 623
+#define GETDNS_CONTEXT_CODE_TLS_BACKOFF_TIME_TEXT "Change related to getdns_context_set_tls_backoff_time"
+#define GETDNS_CONTEXT_CODE_TLS_CONNECTION_RETRIES 624
+#define GETDNS_CONTEXT_CODE_TLS_CONNECTION_RETRIES_TEXT "Change related to getdns_context_set_tls_connection_retries"
/** @}
*/
/**
- * \defgroup versions Additional version values
+ * \defgroup versions Version values
* @{
*/
#define GETDNS_VERSION "@GETDNS_VERSION@"
@@ -94,7 +99,7 @@ extern "C" {
#define GETDNS_AUTHENTICATION_HOSTNAME GETDNS_AUTHENTICATION_REQUIRED
/**
- * \defgroup authvaulesandtext Additional authentication values and texts
+ * \defgroup authvaulesandtext Authentication values and texts
* @{
*/
/* Authentication options used when doing TLS */
@@ -110,7 +115,7 @@ typedef enum getdns_tls_authentication_t {
/**
- * \defgroup appendname Additional append name values and texts
+ * \addtogroup suffixappendtypestext Suffix appending values and texts
* @{
*/
#define GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST ((getdns_append_name_t) 554 )
@@ -118,13 +123,13 @@ typedef enum getdns_tls_authentication_t {
/** @}
*/
-
/**
- * \defgroup Uvaluesandtextsdepricated Additional transport values and texts (will be deprecated)
+ * \addtogroup transporttypestext Transport arrangements and texts
* @{
*/
-/** WARNING! Do not use the constants below. They will be removed from future
+/**
+ * WARNING! Do not use the constants below. They will be removed from future
* releases. Please use the getdns_context_set_dns_transport_list with the
* GETDNS_TRANSPORT_UDP, GETDNS_TRANSPORT_TCP and GETDNS_TRANSPORT_TLS
* constants instead.
@@ -141,78 +146,216 @@ typedef enum getdns_tls_authentication_t {
/**
- * \defgroup Ufunctions Additional functions
+ * \addtogroup functions Functions
* @{
*/
/**
- * \defgroup Ueventloops Additional event loop extension functions
+ * \addtogroup eventloops Event loop extension functions
* @{
*/
+/**
+ * The type of callback function that is used by the callbacks in an
+ * getdns_eventloop_event.
+ * @param userarg This will have the value of the userarg attribute of the
+ * getdns_eventloop_event struct in which this callback was
+ * present.
+ */
typedef void (*getdns_eventloop_callback)(void *userarg);
-/* context extension event data */
-typedef struct getdns_eventloop_event {
+
+typedef struct getdns_eventloop_event getdns_eventloop_event;
+/**
+ * getdns uses an event loop abstraction layer to interface with event loop
+ * extensions. The extension accepts registration of getdns_eventloop_events
+ * and translates them to the underlying event loop API for which it is an
+ * extension. Also applications using getdns can use the abstraction layer
+ * themselves and in doing so inherit the flexibility being immediately
+ * compatible with all the event loop systems for which there is an extension
+ * already (i.e. libevent, libev and libuv).
+ */
+struct getdns_eventloop_event {
+ /**
+ * The userarg argument that will be passed to the
+ * getdns_eventloop_callbacks when they are fired.
+ */
void *userarg;
+
+ /**
+ * When not NULL, it will be fired when the associated file descriptor
+ * is readable.
+ */
getdns_eventloop_callback read_cb;
+
+ /**
+ * When not NULL, it will be fired when the associated file descriptor
+ * is writable.
+ */
getdns_eventloop_callback write_cb;
+
+ /**
+ * When not NULL, it will be fired when the during scheduling specified
+ * timeout time has passed.
+ */
getdns_eventloop_callback timeout_cb;
- /* Pointer to the underlying event
- * that the eventloop extension will create and free.
+ /**
+ * Pointer to the underlying event
+ * that an eventloop extension must manage (i.e. create and free.)
*/
void *ev;
-} getdns_eventloop_event;
+};
typedef struct getdns_eventloop_vmt getdns_eventloop_vmt;
+
+/**
+ * The manifestation of the event loop abstraction layer. Event loop
+ * extension implementers should extend this with attributed needed for the
+ * underlying event loop.
+ * The current event loop extension can be obtained with the
+ * getdns_context_get_eventloop() function.
+ */
typedef struct getdns_eventloop {
+ /**
+ * The Virtual Method Table providing the interface for this specific
+ * event loop extension.
+ */
getdns_eventloop_vmt *vmt;
} getdns_eventloop;
-/* A prototype for a method having no arguments and not return value. */
+/**
+ * The function prototype for the `cleanup` and `run` functions in an getdns
+ * event loop's Virtual Method Table. These methods have no (extra) arguments
+ * and return nothing.
+ * @param loop The event loop to `run` or `cleanup`
+ */
typedef void (*getdns_eventloop_noargs)(getdns_eventloop *loop);
-/* Call the extension to schedule an event
- *
+/**
+ * The function prototype for the `schedule` function in an event loop
+ * Virtual Method Table.
* The getdns_eventloop_event must be provided by the caller with the callbacks
* and userarg therein already supplied (by the caller). This function will set
* the ev pointer (in the getdns_eventloop_event) to refer to the underlying
* (extension) event.
+ * @param loop The event loop for which to register the event.
+ * @param fd The file descriptor for which to schedule the read_cb and/or
+ * write_cb callbacks.
+ * @param timeout The number of milliseconds that must pass without read
+ * and/or write event after which the timeout_cb callback is fired.
+ * @param ev The event with all attributes provisioned, except for the ev->ev
+ * attribute, which will be provisioned by the implementation of
+ * the schedule method.
+ * @return GETDNS_RETURN_GOOD when successful and an error code otherwise.
*/
typedef getdns_return_t (*getdns_eventloop_schedule)(getdns_eventloop *loop,
int fd, uint64_t timeout, getdns_eventloop_event *ev);
-/* Call the extension to clean a scheduled event */
+/**
+ * The function prototype for the `clean` function in an event loop
+ * Virtual Method Table.
+ * The implementation must clear the event (which is referred to with
+ * ev->ev) in the underlying event loop and make ev->ev NULL when done.
+ * getdns will test for this value to determine if events are scheduled or not.
+ * @param loop The event loop for which to event needs to be cleared.
+ * @param[in,out] ev The event with the ev->ev attribute referring to the
+ * underlying event. ev->ev must be set to NULL after the event
+ * was cleared.
+ * @return GETDNS_RETURN_GOOD when successful and an error code otherwise.
+ */
typedef getdns_return_t (*getdns_eventloop_clear)
(getdns_eventloop *loop, getdns_eventloop_event *ev);
+/**
+ * The function prototype for the `run_once` function in an event loop
+ * Virtual Method Table. The implementation must do a single round of
+ * firing callbacks, either blocking or not.
+ * @param loop The event loop to run
+ * @param blocking When 0, only callbacks for file descriptors that are
+ * immediately readable or writable or timeouts that have
+ * passed will be fired. When 1, the eventloop will wait
+ * until the first callback can be fired, either because a
+ * associated file descriptor has become readable or writeable,
+ * or because a timeout time passed.
+ */
typedef void (*getdns_eventloop_run_once)(getdns_eventloop *loop,int blocking);
- /* Virtual Method Table */
+/**
+ * The Virtual Method Table providing the interface for this specific
+ * event loop extension.
+ */
struct getdns_eventloop_vmt {
+ /**
+ * Destroy the getdns_eventloop and the associated underlying event
+ * loop for which it is an extension.
+ */
getdns_eventloop_noargs cleanup;
+
+ /**
+ * Schedule a getdns_eventloop_event with a getdns_eventloop.
+ */
getdns_eventloop_schedule schedule;
+
+ /**
+ * Clear a getdns_eventloop_event
+ */
getdns_eventloop_clear clear;
+
+ /**
+ * Run the getdns_eventloop until it has no getdns_eventloop_events
+ * scheduled.
+ */
getdns_eventloop_noargs run;
+
+ /**
+ * Do a single iteration of firing callbacks for scheduled events
+ * and then return.
+ */
getdns_eventloop_run_once run_once;
};
-/* set an event loop extension on the context */
+/**
+ * Configure a context to use the specified event loop abstraction extension.
+ * This function must be called with an provisioned eventloop by the
+ * event loop extension registration functions.
+ * @see getdns_context_get_eventloop
+ * @param context The context to configure
+ * @param eventloop The event loop abstraction extension with a completely
+ * provisioned Virtual Method Table and other associated
+ * data which is opaque to the user.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or eventloop were NULL.
+ */
getdns_return_t
getdns_context_set_eventloop(getdns_context* context,
getdns_eventloop *eventloop);
-/* get the currently active (pluggable) eventloop from the context */
+/**
+ * Get the current event loop abstraction extension from the context
+ * Applications using getdns can use the event loop abstraction extension
+ * themselves directly to inherit the flexibility being immediately
+ * compatible with all the event loop systems for which there is an extension
+ * (i.e. libevent, libev and libuv).
+ * @see getdns_context_set_eventloop
+ * @param[in] context The context to get the eventloop from
+ * @param[out] eventloop The currently active event loop abstraction extension
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or evenloop were NULL
+ */
getdns_return_t
getdns_context_get_eventloop(getdns_context* context,
getdns_eventloop **eventloop);
-/* detach the eventloop from the context */
-getdns_return_t
-getdns_context_detach_eventloop(getdns_context *context);
-
-/* Run the context's event loop until nothing more to do */
+/**
+ * Run the context's event loop until nothing more to do.
+ * This is equivalend to:
+ * ```c
+ * if (getdns_context_get_eventloop(context, &loop) == GETDNS_RETURN_GOOD)
+ * loop->vmt->run(loop);
+ * ```
+ * @param context The context which event loop to run.
+ */
void
getdns_context_run(getdns_context *context);
/** @}
@@ -220,20 +363,14 @@ getdns_context_run(getdns_context *context);
/**
- * \defgroup contextfunction Additional getdns_context async functions
+ * \addtogroup getdns_context
* @{
*/
-/* process async reqs */
-getdns_return_t getdns_context_process_async(getdns_context* context);
-/** @}
- */
-/**
- * \defgroup Ucontextset Additional getdns_context_set functions
- * @{
- */
/**
* Register a callback function for context changes.
+ * @see getdns_context_set_context_update_callback
+ * @see contextcodetypestext
* @param context The context to monitor for changes
* @param userarg A user defined argument that will be passed to the callback
* function.
@@ -248,118 +385,512 @@ getdns_return_t
getdns_context_set_update_callback(getdns_context *context, void *userarg,
void (*value) (getdns_context *, getdns_context_code_t, void *));
-/* Enable the return_dnssec_status extension on every request.
- value is either GETDNS_EXTENSION_TRUE or GETDNS_EXTENSION_FALSE
- returns GETDNS_RETURN_GOOD on success or GETDNS_RETURN_INVALID_PARAMETER
- if context or value is invalid */
+/**
+ * Enable the return_dnssec_status extension on every request.
+ * @param context The context to configure
+ * @param enabled is either GETDNS_EXTENSION_TRUE or GETDNS_EXTENSION_FALSE
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context or value is invalid
+ */
getdns_return_t getdns_context_set_return_dnssec_status(
getdns_context *context, int enabled);
-/* tells underlying unbound to use background threads or fork */
-getdns_return_t getdns_context_set_use_threads(getdns_context* context,
- int use_threads);
-
+/**
+ * Configure context for oppertunistic or scrict usage profile with DNS
+ * over TLS.
+ * @see getdns_context_get_tls_authentication
+ * @see authvaulesandtext
+ * @param context The context to configure
+ * @param value is either GETDNS_AUTHENTICATION_REQUIRED for the strict
+ * usage profile or GETDNS_AUTHENTICATION_NONE for opportunistic
+ * profile.
+ * See #getdns_context_set_upstream_recursive_servers
+ * for details on how to configure credentials per upstream.
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context is null or value has an
+ * invalid value.
+ */
getdns_return_t
getdns_context_set_tls_authentication(
getdns_context *context, getdns_tls_authentication_t value);
+/**
+ * Configure context to round robin queries over the available upstreams
+ * when resolving with the stub resolution type.
+ * @see getdns_context_get_round_robin_upstreams
+ * @param context The context to configure
+ * @param value is either 1 to enable and 0 to disable round robin.
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context is null or value has an
+ * invalid value.
+ */
+getdns_return_t
+getdns_context_set_round_robin_upstreams(getdns_context *context, uint8_t value);
+
+/**
+ * Configure the amount of seconds a TLS connection should not be tried with
+ * an upstream when it has never been tried before. Default is 3600 which is
+ * one hour.
+ * @see getdns_context_get_tls_backoff_time
+ * @param context The context to configure
+ * @param value Number of seconds before an attempt to setup DNS over TLS,
+ * with an upstream for which setting up an TLS connection has
+ * never been successful before, will be retried.
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context is null.
+ */
+getdns_return_t
+getdns_context_set_tls_backoff_time(getdns_context *context, uint16_t value);
+
+/**
+ * Configure the number of times getdns retries to setup DNS over TLS with a
+ * specific upstream, before it decides to give up for tls_backoff_time
+ * seconds. The default is 2.
+ * @see getdns_context_get_tls_connection_retries
+ * @param context The context to configure
+ * @param value Number of attempts to retry setting up a DNS over TLS
+ * connection before giving up.
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context is null.
+ */
+getdns_return_t
+getdns_context_set_tls_connection_retries(getdns_context *context, uint16_t value);
+
+/**
+ * Configure context to sent queries with the EDNS Client Subnet option set
+ * to hide the originating network when resolving in stub resolution.
+ * The default is 0 (disabled).
+ * @see getdns_context_get_edns_client_subnet_private
+ * @param context The context to configure
+ * @param value is either 1 to enable and 0 to disable.
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context is null or value has an
+ * invalid value.
+ */
getdns_return_t
getdns_context_set_edns_client_subnet_private(getdns_context *context, uint8_t value);
+/**
+ * Configure context to pad each outgoing query over TLS to a multiple of the
+ * requested blocksizes. A value of 0 means disable, and a value of 1 means
+ * to "pad using a sensible policy". The default is 1 (pad using sensible policy).
+ * @see getdns_context_get_tls_query_padding_blocksize
+ * @param context The context to configure
+ * @param value The requested block size to pad to, or 0 to disable, or 1 to
+ * indicate that the library should use a sinsible policy.
+ * Currently that just means to pad to a multiple of 128 octets for
+ * outgoing queries, but this might change in the future.
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context is null or value has an
+ * invalid value.
+ */
getdns_return_t
getdns_context_set_tls_query_padding_blocksize(getdns_context *context, uint16_t value);
-/** @}
- */
- /**
- * \defgroup Ucontextget Additional getdns_context_get functions
- * @{
- */
-/** begin getters **/
+/**
+ * Configure context to advertise maximum UDP payload size values, that
+ * adhere to the suggestions in RFC 6891 and may follow a scheme that uses
+ * multiple values to maximize receptivity. In practice with our implementation
+ * this means 1432 for IPv4 upstreams and 1232 for IPv6 upstreams.
+ * The default is to have the edns maximum UDP payload size to be unset and
+ * thus use the adaptive scheme.
+ * @see getdns_context_set_edns_maximum_udp_payload_size
+ * @see getdns_context_get_edns_maximum_udp_payload_size
+ * @param context The context to configure
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context is null.
+ */
+getdns_return_t
+getdns_context_unset_edns_maximum_udp_payload_size(getdns_context *context);
+
+
+typedef enum getdns_loglevel_type {
+ GETDNS_LOG_EMERG = 0,
+ GETDNS_LOG_ALERT = 1,
+ GETDNS_LOG_CRIT = 2,
+ GETDNS_LOG_ERR = 3,
+ GETDNS_LOG_WARNING = 4,
+ GETDNS_LOG_NOTICE = 5,
+ GETDNS_LOG_INFO = 6,
+ GETDNS_LOG_DEBUG = 7
+} getdns_loglevel_type;
+
+#define GETDNS_LOG_EMERG_TEXT "System is unusable"
+#define GETDNS_LOG_ALERT_TEXT "Action must be taken immediately"
+#define GETDNS_LOG_CRIT_TEXT "Critical conditions"
+#define GETDNS_LOG_ERR_TEXT "Error conditions"
+#define GETDNS_LOG_WARNING_TEXT "Warning conditions"
+#define GETDNS_LOG_NOTICE_TEXT "normal, but significant, condition"
+#define GETDNS_LOG_INFO_TEXT "Informational message"
+#define GETDNS_LOG_DEBUG_TEXT "Debug-level message"
+
+#define GETDNS_LOG_UPSTREAM_STATS 4096
+#define GETDNS_LOG_UPSTREAM_STATS_TEXT "Log messages about upstream statistics"
+
+typedef void (*getdns_logfunc_type) (void *userarg, uint64_t log_systems,
+ getdns_loglevel_type, const char *, va_list ap);
+
+/**
+ *
+ */
+getdns_return_t
+getdns_context_set_logfunc(getdns_context *context, void *userarg,
+ uint64_t system, getdns_loglevel_type level, getdns_logfunc_type func);
+
+/**
+ * Get the current resolution type setting from this context.
+ * @see getdns_context_set_resolution_type
+ * @see resolutiontypestext
+ * @param[in] context The context from which to get the setting
+ * @param[out] value The resolution type, either GETDNS_RESOLUTION_RECURSING
+ * or GETDNS_RESOLUTION_STUB.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_resolution_type(getdns_context *context,
getdns_resolution_t* value);
-/** users must call free on the resulting namespaces if not NULL */
+/**
+ * Get a copy of the namespaces list setting from this context.
+ * Users must call free on the resulting namespaces if not NULL
+ * @see getdns_context_set_namespaces
+ * @see namespacetypestext
+ * @param[in] context The context from which to get the setting
+ * @param[out] namespace_count The length of the list.
+ * @param[out] namespaces The returned namespaces list.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when any of the arguments was NULL.
+ */
getdns_return_t
getdns_context_get_namespaces(getdns_context *context,
size_t* namespace_count, getdns_namespace_t **namespaces);
+/**
+ * Get what transports are used for DNS lookups.
+ * @see getdns_context_set_dns_transport
+ * @see transporttypestext
+ * @see getdns_context_get_dns_transport_list
+ * @param[in] context The context from which to get the setting
+ * @param[out] value The transport to use for DNS lookups.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when any of the arguments was NULL.
+ */
getdns_return_t
getdns_context_get_dns_transport(getdns_context *context,
getdns_transport_t* value);
+/**
+ * Get a copy of the transports list setting from this context.
+ * Users must call free on the resulting transports if not NULL
+ * @see getdns_context_set_dns_transport_list
+ * @see transportlisttypestext
+ * @see getdns_context_get_dns_transport
+ * @param[in] context The context from which to get the setting
+ * @param[out] transport_count The length of the list.
+ * @param[out] transports The returned transports list.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when any of the arguments was NULL.
+ */
getdns_return_t
getdns_context_get_dns_transport_list(getdns_context *context,
size_t* transport_count, getdns_transport_list_t **transports);
+/**
+ * Get the current limit for oustanding queries setting from this context.
+ * @see getdns_context_set_limit_outstanding_queries
+ * @param[in] context The context from which to get the setting
+ * @param[out] limit The current limit for oustanding queries
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or limit was NULL.
+ */
getdns_return_t
getdns_context_get_limit_outstanding_queries(getdns_context *context,
uint16_t* limit);
+/**
+ * Get the current number of milliseconds the API will wait for request
+ * to return setting from this context.
+ * @see getdns_context_set_timeout
+ * @param[in] context The context from which to get the setting
+ * @param[out] timeout The number of milliseconds the API will wait for a
+ * response.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or limit was NULL.
+ */
getdns_return_t
getdns_context_get_timeout(getdns_context *context, uint64_t* timeout);
+/**
+ * Get the current number of milliseconds the API will leave an idle TCP or TLS
+ * connection open for (idle means no outstanding responses and no pending
+ * queries).
+ * @see getdns_context_set_idle_timeout
+ * @param[in] context The context from which to get the setting
+ * @param[out] timeout The number of milliseconds the API will leave an idle TCP
+ * or TLS connection open for
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or timeout was NULL.
+ */
getdns_return_t
getdns_context_get_idle_timeout(getdns_context *context, uint64_t* timeout);
+/**
+ * Get the setting that says whether or not DNS queries follow redirects.
+ * @see getdns_context_set_follow_redirects
+ * @see redirectpoliciestext
+ * @param[in] context The context from which to get the setting
+ * @param[out] value Either GETDNS_REDIRECTS_FOLLOW or GETDNS_REDIRECTS_DO_NOT_FOLLOW
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_follow_redirects(getdns_context *context,
getdns_redirects_t* value);
+/**
+ * Get a copy of the list of addresses in use for looking up top-level domains
+ * in use by the context.
+ * Callers are responsible for deallocating the returned list with
+ * #getdns_list_destroy()
+ * @see getdns_context_set_dns_root_servers
+ * @param[in] context The context from which to get the setting
+ * @param[out] addresses A copy of the list of dns root servers in use for
+ * looking up top level domains. The caller must
+ * destroy this list.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or adresses was NULL.
+ * @return GETDNS_RETURN_MEMORY_ERROR when the copy could not be allocated
+ */
getdns_return_t
getdns_context_get_dns_root_servers(getdns_context *context,
getdns_list **addresses);
+/**
+ * Get whether, how and when a suffix is appended to a query string with
+ * the context.
+ * @see getdns_context_set_append_name
+ * @see suffixappendtypestext
+ * @param[in] context The context from which to get the setting
+ * @param[out] value GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST,
+ * GETDNS_APPEND_NAME_ALWAYS,
+ * GETDNS_APPEND_NAME_ONLY_TO_SINGLE_LABEL_AFTER_FAILURE,
+ * GETDNS_APPEND_NAME_ONLY_TO_MULTIPLE_LABEL_NAME_AFTER_FAILURE,
+ * or GETDNS_APPEND_NAME_NEVER
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_append_name(getdns_context *context,
getdns_append_name_t* value);
+/**
+ * Get a copy of the list of suffixes to be appended based on the value off the
+ * append_name setting in use by context
+ * Callers are responsible for deallocating the returned list with
+ * #getdns_list_destroy()
+ * @see getdns_context_set_suffix
+ * @param[in] context The context from which to get the setting
+ * @param[out] value A copy of the list of suffixes. The caller must destroy
+ * this list.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ * @return GETDNS_RETURN_MEMORY_ERROR when the copy could not be allocated
+ */
getdns_return_t
getdns_context_get_suffix(getdns_context *context, getdns_list **value);
+/**
+ * Get a copy of the list of DNSSEC trust anchors in use by context.
+ * Callers are responsible for deallocating the returned list with
+ * #getdns_list_destroy()
+ * @see getdns_context_set_dnssec_trust_anchors
+ * @param[in] context The context from which to get the setting
+ * @param[out] value A copy of the list of DNSSEC trust anchors.
+ * The caller must destroy this list.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ * @return GETDNS_RETURN_MEMORY_ERROR when the copy could not be allocated
+ */
getdns_return_t
getdns_context_get_dnssec_trust_anchors(getdns_context *context,
getdns_list **value);
+/**
+ * Get the allowed DNSSEC skew setting from context
+ * @see getdns_context_set_dnssec_allowed_skew
+ * @param[in] context The context from which to get the setting
+ * @param[out] value The number of seconds of skew that is allowed in either
+ * direction when checking an RRSIG's Expiration and Inception
+ * fields.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_dnssec_allowed_skew(getdns_context *context,
uint32_t* value);
+/**
+ * Get a copy of the list of upstream that will be targeted in stub resolution
+ * mode.
+ * Callers are responsible for deallocating the returned list with
+ * #getdns_list_destroy()
+ * @see getdns_context_set_upstream_recursive_servers
+ * @param[in] context The context from which to get the setting
+ * @param[out] upstream_list A copy of the list of upstreams.
+ * The caller must destroy this list.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ * @return GETDNS_RETURN_MEMORY_ERROR when the copy could not be allocated
+ */
getdns_return_t
getdns_context_get_upstream_recursive_servers(getdns_context *context,
getdns_list **upstream_list);
+/**
+ * Get the maximum UDP payload size advertised in an EDNS0 OPT record
+ * setting from context
+ * @see getdns_context_set_edns_maximum_udp_payload_size
+ * @see getdns_context_unset_edns_maximum_udp_payload_size
+ * @param[in] context The context from which to get the setting
+ * @param[out] value the maximum UDP payload size advertised in an EDNS0
+ * OPT record. When the value is unset, 0 is returned.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_edns_maximum_udp_payload_size(getdns_context *context,
uint16_t* value);
+/**
+ * Get the rcode advertised in an EDNS0 OPT record setting from context
+ * @see getdns_context_set_edns_extended_rcode
+ * @param[in] context The context from which to get the setting
+ * @param[out] value The rcode advertised in an EDNS0 OPT record
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_edns_extended_rcode(getdns_context *context,
uint8_t* value);
+/**
+ * Get the version advertised in an EDNS0 OPT record setting from context
+ * @see getdns_context_set_edns_version
+ * @param[in] context The context from which to get the setting
+ * @param[out] value The version advertised in an EDNS0 OPT record
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_edns_version(getdns_context *context, uint8_t* value);
+/**
+ * Get the DO bit advertised in an EDNS0 OPT record setting from context
+ * @see getdns_context_set_edns_do_bit
+ * @param[in] context The context from which to get the setting
+ * @param[out] value 1 if the DO bit is advertised in EDNS0 OPT records,
+ * 0 otherwise.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_edns_do_bit(getdns_context *context, uint8_t* value);
+/**
+ * Get whether queries with this context will have the EDNS Client Subnet
+ * option set to hide the originating network when resolving in stub
+ * resolution.
+ * @see getdns_context_set_edns_do_bit
+ * @param[in] context The context from which to get the setting
+ * @param[out] value 1 if the setting is on, 0 otherwise
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_edns_client_subnet_private(getdns_context *context, uint8_t* value);
+/**
+ * Get the blocksize that will be used to pad outgoing queries over TLS.
+ * @see getdns_context_set_tls_query_padding_blocksize
+ * @param[in] context The context from which to get the setting
+ * @param[out] value The padding blocksize, or 0 if padding is disabled,
+ * or 1 if the setting is to pad using a sensible policy.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_tls_query_padding_blocksize(getdns_context *context, uint16_t* value);
+/**
+ * Get whether the upstream needs to be authenticated whith DNS over TLS.
+ * @see getdns_context_set_tls_authentication
+ * @see authvaulesandtext
+ * @param[in] context The context from which to get the setting
+ * @param[out] value is either GETDNS_AUTHENTICATION_REQUIRED if
+ * authentication is required, or GETDNS_AUTHENTICATION_NONE
+ * if authentication is optional. When credentials are
+ * available, the API will still try to authenticate the
+ * upstream.
+ * See #getdns_context_set_upstream_recursive_servers
+ * for details on how to configure credentials per upstream.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
getdns_return_t
getdns_context_get_tls_authentication(getdns_context *context,
getdns_tls_authentication_t* value);
+/**
+ * Get whether the context is configured to round robin queries over the available
+ * upstreams.
+ * @see getdns_context_get_round_robin_upstreams
+ * @param[in] context The context from which to get the setting
+ * @param[out] value 1 if the setting is on, 0 otherwise
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
+getdns_return_t
+getdns_context_get_round_robin_upstreams(getdns_context *context,
+ uint8_t* value);
+
+/**
+ * Get the amount of seconds a TLS connection should not be tried with
+ * an upstream when it has never been tried before.
+ * @see getdns_context_set_tls_backoff_time
+ * @param[in] context The context from which to get the setting
+ * @param[out] value Number of seconds before an attempt to setup DNS over TLS,
+ * with an upstream for which setting up an TLS connection has
+ * never been successful before, will be retried.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
+getdns_return_t
+getdns_context_get_tls_backoff_time(getdns_context *context,
+ uint16_t* value);
+
+/**
+ * Get the number of times getdns retries to setup DNS over TLS with a
+ * specific upstream, before it decides to give up for tls_backoff_time
+ * seconds.
+ * @see getdns_context_set_tls_connection_retries
+ * @param[in] context The context from which to get the setting
+ * @param[out] value Number of attempts to retry setting up a DNS over TLS
+ * connection before giving up.
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context or value was NULL.
+ */
+getdns_return_t
+getdns_context_get_tls_connection_retries(getdns_context *context,
+ uint16_t* value);
+
/**
* Get the currently registered callback function and user defined argument
* for context changes.
- * Combined with getdns_context_set_update_callback this can be used to
+ * Combined with #getdns_context_set_update_callback this can be used to
* "chain" context update callbacks and in this way create a subscription
* service catering multiple interested parties.
+ * @see contextcodetypestext
* @param context The context to monitor for changes
* @param userarg A user defined argument to be passed to the callback
* function.
@@ -371,23 +902,59 @@ getdns_return_t
getdns_context_get_update_callback(getdns_context *context, void **userarg,
void (**value) (getdns_context *, getdns_context_code_t, void *));
-/* Async support */
-uint32_t getdns_context_get_num_pending_requests(getdns_context* context,
- struct timeval* next_timeout);
/** @}
*/
/**
- * \defgroup Uutilityfunctions Additional utility functions
+ * \addtogroup versionfuncs Version functions
* @{
*/
+/**
+ * Get the version number of this implementation.
+ * @see versions
+ * @return The version number as string. For example "@GETDNS_VERSION@".
+ */
const char *getdns_get_version(void);
+
+/**
+ * Get the version number of this implementation as number.
+ * @see versions
+ * @return The version number as number. For example @GETDNS_NUMERIC_VERSION@.
+ * - The most significant byte of this uint32_t is the Major version.
+ * - The second most significant byte is the Minor version.
+ * - The third most significant byte the Patch version.
+ */
uint32_t getdns_get_version_number(void);
+
+/**
+ * Get the version of the getdns API specification this library implements
+ * as a string.
+ * @see versions
+ * @return The API specification version as string. For example "@API_VERSION@"
+ */
const char *getdns_get_api_version(void);
+
+/**
+ * Get the version of the getdns API specification this library implements
+ * as a number.
+ * @see versions
+ * @return The API specification version as number. For example "@API_NUMERIC_VERSION@"
+ * - The most significant 16 bits represent the year.
+ * - The third most significant byte the day.
+ */
+
uint32_t getdns_get_api_version_number(void);
+/** @}
+ */
+
+/**
+ * \addtogroup utils Utility functions
+ * @{
+ */
+
/**
* Returns a text describing the getdns error code, or NULL when the error
* code is unkown.
@@ -397,18 +964,58 @@ uint32_t getdns_get_api_version_number(void);
*/
const char *getdns_get_errorstr_by_id(uint16_t err);
-/* dict util */
-/* set a string as bindata */
-getdns_return_t getdns_dict_util_set_string(struct getdns_dict * dict,
- char *name, const char *value);
+/** @}
+ */
-/* get a string from a dict. the result must be freed if valid */
-getdns_return_t getdns_dict_util_get_string(struct getdns_dict * dict,
- char *name, char **result);
+
+/**
+ * \addtogroup getdns_dict
+ * @{
+ */
+
+/**
+ * Create a new entry in the dictionary, or replace the value of an existing
+ * entry, with a getdns_bindata representing a string. The string will be
+ * copied. The size of the bindata will be strlen(value), though there will
+ * be a '\0' byte directly after the size'd position even, though the size
+ * argument suggests that this would not be part of the bindata's date space.
+ * @see getdns_dict_set_bindata
+ * @param dict dictionary in which to add or change the value
+ * @param name key that identifies which item in the dictionary to add/change
+ * @param value string to be copied and stored in the bindata at key
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER when one of the arguments was NULL
+ * @return GETDNS_RETURN_MEMORY_ERROR when the copy could not be allocated
+ */
+getdns_return_t
+getdns_dict_util_set_string(getdns_dict *dict, char *name, const char *value);
+
+/**
+ * Get the string associated with the speicifed name. The string should not
+ * be free()'d by the caller.
+ * @see getdns_dict_get_bindata
+ * @param dict dictionary from which to fetch the bindata
+ * @param name a name/key value to look up in the dictionary
+ * @param result The bindata's data value
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_NO_SUCH_DICT_NAME if dict is invalid or name does not exist
+ */
+getdns_return_t
+getdns_dict_util_get_string(getdns_dict * dict, char *name, char **result);
+
+/** @}
+ */
+
+
+/**
+ * \addtogroup dnssecfuncs
+ * @{
+ */
/**
* Validate replies or resource records.
*
+ * @see dnssecvalues
* @param to_validate A list of RR-dicts with companion RRSIG-RR-dicts
* which will be validated. Or a list of reply-dicts
* that will be validated. The "replies_tree" list
@@ -478,6 +1085,16 @@ getdns_validate_dnssec2(const getdns_list *to_validate,
const getdns_list *trust_anchors,
time_t validation_time, uint32_t skew);
+
+/** @}
+ */
+
+
+/**
+ * \addtogroup utils
+ * @{
+ */
+
/**
* Public Key Pinning functionality:
*
@@ -530,6 +1147,60 @@ getdns_return_t getdns_pubkey_pinset_sanity_check(
const getdns_list* pinset,
getdns_list* errorlist);
+/** @}
+ */
+
+
+/**
+ * \addtogroup getdns_context
+ * @{
+ */
+
+/**
+ * Configure a context with settings given in a getdns_dict.
+ *
+ * @param context The context to be configured.
+ * @param config_dict The getdns_dict containing the settings.
+ * The settings have the same name as returned by the
+ * getdns_context_get_api_information() function, or as
+ * used in the names of the getdns_context_get_*() and
+ * getdns_context_set_*() functions.
+ * - The dict returned by
+ * getdns_context_get_api_information() can be used
+ * as the config_dict directly, but context settings
+ * do *not* have to be below a `"all_context"` key.
+ * - It is possible to set default values for extensions
+ * that could otherwise only be given on a per query
+ * basis. For example:
+ * `{ dnssec_return_status: GETDNS_EXTENSION_TRUE }` is
+ * equivalent to using the
+ * getdns_context_set_return_dnssec_status() function
+ * with that value, but default values for the other
+ * extensions can be set by this method now too.
+ * For example
+ * `{ return_call_reporting: GETDNS_EXTENSION_TRUE}`
+ * - Trust anchor files and root hints content can also be
+ * given by file, for example:
+ *
+ * { dns_root_servers : "named.root"
+ * , dnssec_trust_anchors: "/etc/unbound/getdns-root.key"
+ * }
+ * @return GETDNS_RETURN_GOOD on success or an error code on failure.
+ * **Beware** that context might be partially configured on error. For retry
+ * strategies it is advised to recreate a new config.
+ */
+getdns_return_t
+getdns_context_config(getdns_context *context, const getdns_dict *config_dict);
+
+
+
+/** @}
+ */
+
+/**
+ * \addtogroup getdns_dict
+ * @{
+ */
/**
* Pretty print the getdns_dict in a given buffer snprintf style.
@@ -544,27 +1215,6 @@ getdns_return_t getdns_pubkey_pinset_sanity_check(
int
getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict);
-/**
- * creates a string that describes the list in a human readable form.
- * @param some_list list to pretty print
- * @return character array (caller must free this) containing pretty string
- */
-char *
-getdns_pretty_print_list(const getdns_list *some_list);
-
-/**
- * Pretty print the getdns_list in a given buffer snprintf style.
- * @param str pointer to the buffer to print to
- * @param size size of the given buffer. No more than size bytes (including
- * the terminating null byte) will be written to str.
- * @param list getdns_list to print
- * @return The number of characters written excluding the terminating null byte
- * or the number of characters which would have been written if enough space
- * had been available.
- */
-int
-getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list);
-
/**
* creates a string containing a json representation of some_dict.
* bindatas are converted to strings when possible, including bindatas for
@@ -595,6 +1245,35 @@ int
getdns_snprint_json_dict(
char *str, size_t size, const getdns_dict *dict, int pretty);
+/** @}
+ */
+
+/**
+ * \addtogroup getdns_list
+ * @{
+ */
+
+/**
+ * creates a string that describes the list in a human readable form.
+ * @param some_list list to pretty print
+ * @return character array (caller must free this) containing pretty string
+ */
+char *
+getdns_pretty_print_list(const getdns_list *some_list);
+
+/**
+ * Pretty print the getdns_list in a given buffer snprintf style.
+ * @param str pointer to the buffer to print to
+ * @param size size of the given buffer. No more than size bytes (including
+ * the terminating null byte) will be written to str.
+ * @param list getdns_list to print
+ * @return The number of characters written excluding the terminating null byte
+ * or the number of characters which would have been written if enough space
+ * had been available.
+ */
+int
+getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list);
+
/**
* creates a string containing a json representation of some_list.
* bindatas are converted to strings when possible, including bindatas for
@@ -626,6 +1305,14 @@ getdns_snprint_json_list(
char *str, size_t size, const getdns_list *list, int pretty);
+/** @}
+ */
+
+/**
+ * \defgroup UDNSDataConversionFunctions Converting between getdns DNS dicts, DNS wire format and DNS presentation format
+ * @{
+ */
+
/**
* Convert rr_dict to wireformat representation of the resource record.
*
@@ -939,6 +1626,14 @@ getdns_return_t
getdns_msg_dict2str_scan(
const getdns_dict *msg_dict, char **str, int *str_len);
+/** @}
+ */
+
+/**
+ * \defgroup Ustring2getdns_data Converting strings to getdns data structures
+ * @{
+ */
+
/**
* Convert string text to a getdns_dict.
*
@@ -986,7 +1681,8 @@ getdns_str2list(const char *str, getdns_list **list);
* - bindata representation of IP or IPv6 addresses may be
* given in their presentation format. For example:
* `{ dns_root_servers: [ 2001:7fd::1, 193.0.14.129 ] }`
- * - Arbitrary binary data may be given with a `0x` prefix.
+ * - Arbitrary binary data may be given with a `0x` prefix,
+ * or in base64 encoding.
* For example:
*
* { add_opt_parameters:
@@ -1003,7 +1699,7 @@ getdns_str2list(const char *str, getdns_list **list);
* [ { address_data : 2a04:b900:0:100::37
* , tsig_name : hmac-md5.tsigs.getdnsapi.net.
* , tsig_algorithm: hmac-md5.sig-alg.reg.int.
- * , tsig_secret : 0xD7A1BAF4E4DE5D6EB149
+ * , tsig_secret : 16G69OTeXW6xSQ==
* } ]
* }
*
@@ -1027,50 +1723,23 @@ getdns_str2bindata(const char *str, getdns_bindata **bindata);
getdns_return_t
getdns_str2int(const char *str, uint32_t *value);
-/**
- * Configure a context with settings given in a getdns_dict.
- *
- * @param context The context to be configured.
- * @param config_dict The getdns_dict containing the settings.
- * The settings have the same name as returned by the
- * getdns_context_get_api_information() function, or as
- * used in the names of the getdns_context_get_*() and
- * getdns_context_set_*() functions.
- * - The dict returned by
- * getdns_context_get_api_information() can be used
- * as the config_dict directly, but context settings
- * do *not* have to be below a `"all_context"` key.
- * - It is possible to set default values for extensions
- * that could otherwise only be given on a per query
- * basis. For example:
- * `{ dnssec_return_status: GETDNS_EXTENSION_TRUE }` is
- * equivalent to using the
- * getdns_context_set_return_dnssec_status() function
- * with that value, but default values for the other
- * extensions can be set by this method now too.
- * For example
- * `{ return_call_reporting: GETDNS_EXTENSION_TRUE}`
- * - Trust anchor files and root hints content can also be
- * given by file, for example:
- *
- * { dns_root_servers : "named.root"
- * , dnssec_trust_anchors: "/etc/unbound/getdns-root.key"
- * }
- * @return GETDNS_RETURN_GOOD on success or an error code on failure.
- * **Beware** that context might be partially configured on error. For retry
- * strategies it is advised to recreate a new config.
+/** @}
*/
-getdns_return_t
-getdns_context_config(getdns_context *context, const getdns_dict *config_dict);
+/**
+ * \defgroup UServerFunctions Creating simple DNS servers
+ * @{
+ */
/**
* The user defined request handler that will be called on incoming requests.
*/
typedef void (*getdns_request_handler_t)(
- getdns_context *context,
- getdns_dict *request,
- getdns_transaction_t request_id
+ getdns_context *context,
+ getdns_callback_type_t callback_type,
+ getdns_dict *request,
+ void *userarg,
+ getdns_transaction_t request_id
);
/**
@@ -1079,6 +1748,11 @@ typedef void (*getdns_request_handler_t)(
*
* @param context The context managing the eventloop that needs to be run to
* start serving.
+ * @param listen_addresses A list of address dicts or bindatas that will be
+ * listened on for DNS requests. Both UDP and TCP
+ * transports will be used.
+ * @param userarg A user defined argument that will be passed to the handler
+ * untouched.
* @param handler The user defined request handler that will be called with the
* request received in reply dict format. To reply to this request
* the function has to construct a response (or modify the request)
@@ -1088,9 +1762,6 @@ typedef void (*getdns_request_handler_t)(
* not answered by the function, by not calling getdns_reply() this
* will cause a memory leak. The user most use getdns_reply()
* with NULL as the response to not answer/cancel a request.
- * @param listen_addresses A list of address dicts or bindatas that will be
- * listened on for DNS requests. Both UDP and TCP
- * transports will be used.
* @return GETDNS_RETURN_GOOD on success or an error code on failure.
* On failure, the current set of listening addresses is left in place.
* Also, if there is overlap in listening_addresses between the active set
@@ -1099,8 +1770,9 @@ typedef void (*getdns_request_handler_t)(
* DNS transactions will remain.
*/
getdns_return_t
-getdns_context_set_listen_addresses(getdns_context *context,
- getdns_request_handler_t handler, const getdns_list *listen_addresses);
+getdns_context_set_listen_addresses(
+ getdns_context *context, const getdns_list *listen_addresses,
+ void *userarg, getdns_request_handler_t handler);
/**
* Answer the request associated with a request_id that is received by a
@@ -1108,11 +1780,11 @@ getdns_context_set_listen_addresses(getdns_context *context,
*
* @param context The context managing the eventloop that needs to be run to
* listen for and answer requests.
- * @param request_id The identifier that links this response with the
- * received request.
* @param reply The answer in getdns reply dict or response dict format.
* When NULL is given as reply, the request is not answered
* but all associated state is deleted.
+ * @param request_id The identifier that links this response with the
+ * received request.
* @return GETDNS_RETURN_GOOD on success or an error code on failure.
* On fatal failure (no retry strategy possible) the user still needs to
* cancel the request by recalling getdns_reply() but with NULL as response,
@@ -1120,7 +1792,7 @@ getdns_context_set_listen_addresses(getdns_context *context,
*/
getdns_return_t
getdns_reply(getdns_context *context,
- getdns_transaction_t request_id, getdns_dict *reply);
+ getdns_dict *reply, getdns_transaction_t request_id);
/** @}
@@ -1128,22 +1800,63 @@ getdns_reply(getdns_context *context,
/**
- * \defgroup Uutilityfunctionsdeprecated Additional utility functions (will be deprecated)
+ * \defgroup Uutilityfunctionsdeprecated Deptricated utility functions
* @{
*/
-/* WARNING! Function getdns_strerror is not in the API specification and
+/**
+ * WARNING! Function getdns_strerror is not in the API specification and
* is likely to be removed from future versions of our implementation, to be
* replaced by getdns_get_errorstr_by_id or something similar.
* Please use getdns_get_errorstr_by_id instead of getdns_strerror.
*/
getdns_return_t getdns_strerror(getdns_return_t err, char *buf, size_t buflen);
-/** @}
- */
-/** @}
- */
-/** @}
- */
+/**
+ * Runs the event loop once non blocking.
+ * WARNING! Do not use this function. This function will be removed in
+ * future versions of getdns.
+ */
+getdns_return_t getdns_context_process_async(getdns_context* context);
+
+/**
+ * Return the number of pending requests and the point of time of the next
+ * timeout.
+ * WARNING! Do not use this function. This function will be removed in
+ * future versions of getdns.
+ */
+uint32_t getdns_context_get_num_pending_requests(getdns_context* context,
+ struct timeval* next_timeout);
+
+/**
+ * Detach the eventloop from the context. Resets the context with the default
+ * event loop based on poll(). WARNING! Do not use this function. It is For
+ * internal use only and may disappear in future releases.
+ * @param context The context to reset to default event loop usage
+ * @return GETDNS_RETURN_GOOD when successful
+ * @return GETDNS_RETURN_INVALID_PARAMETER when context is NULL
+ */
+getdns_return_t
+getdns_context_detach_eventloop(getdns_context *context);
+
+/**
+ * Tell underlying unbound context to use background threads or fork.
+ * This is only relevant for libunbound version before 1.5.9. After this
+ * version the underlying unbound will share the event loop with getdns
+ * eliminating the use for threads. Since the need for this function is
+ * doubtful and likely to disappear in the future, use is strongly
+ * discouraged.
+ * @param context The context to configure
+ * @param use_threads is either 1 to use threads, or 0 to use fork
+ * @return GETDNS_RETURN_GOOD on success
+ * @return GETDNS_RETURN_INVALID_PARAMETER if context is NULL
+ */
+getdns_return_t getdns_context_set_use_threads(getdns_context* context,
+ int use_threads);
+
+/** @}
+ */
+/** @}
+ */
#ifdef __cplusplus
}
#endif
diff --git a/src/gldns/gbuffer.c b/src/gldns/gbuffer.c
index ac70415d..180fa631 100644
--- a/src/gldns/gbuffer.c
+++ b/src/gldns/gbuffer.c
@@ -33,6 +33,7 @@ gldns_buffer_new(size_t capacity)
buffer->_position = 0;
buffer->_limit = buffer->_capacity = capacity;
buffer->_fixed = 0;
+ buffer->_vfixed = 0;
buffer->_status_err = 0;
gldns_buffer_invariant(buffer);
@@ -48,6 +49,9 @@ gldns_buffer_new_frm_data(gldns_buffer *buffer, void *data, size_t size)
buffer->_position = 0;
buffer->_limit = buffer->_capacity = size;
buffer->_fixed = 0;
+ buffer->_vfixed = 0;
+ if (!buffer->_fixed && buffer->_data)
+ free(buffer->_data);
buffer->_data = malloc(size);
if(!buffer->_data) {
buffer->_status_err = 1;
@@ -66,6 +70,17 @@ gldns_buffer_init_frm_data(gldns_buffer *buffer, void *data, size_t size)
buffer->_data = data;
buffer->_capacity = buffer->_limit = size;
buffer->_fixed = 1;
+ buffer->_vfixed = 0;
+}
+
+void
+gldns_buffer_init_vfixed_frm_data(gldns_buffer *buffer, void *data, size_t size)
+{
+ memset(buffer, 0, sizeof(*buffer));
+ buffer->_data = data;
+ buffer->_capacity = buffer->_limit = size;
+ buffer->_fixed = 1;
+ buffer->_vfixed = 1;
}
int
@@ -120,20 +135,19 @@ gldns_buffer_printf(gldns_buffer *buffer, const char *format, ...)
remaining = gldns_buffer_remaining(buffer);
va_start(args, format);
- written = _gldns_vsnprintf((char*)gldns_buffer_current(buffer),
- remaining, format, args);
+ written = vsnprintf((char *) gldns_buffer_current(buffer), remaining,
+ format, args);
va_end(args);
if (written == -1) {
buffer->_status_err = 1;
return -1;
- } else if (!buffer->_fixed && (size_t) written >= remaining) {
+ } else if (!buffer->_vfixed && (size_t) written >= remaining) {
if (!gldns_buffer_reserve(buffer, (size_t) written + 1)) {
buffer->_status_err = 1;
return -1;
}
va_start(args, format);
- written = _gldns_vsnprintf(
- (char *) gldns_buffer_current(buffer),
+ written = vsnprintf((char *) gldns_buffer_current(buffer),
gldns_buffer_remaining(buffer), format, args);
va_end(args);
if (written == -1) {
diff --git a/src/gldns/gbuffer.h b/src/gldns/gbuffer.h
index 2db9e250..32b3f9d1 100644
--- a/src/gldns/gbuffer.h
+++ b/src/gldns/gbuffer.h
@@ -27,21 +27,6 @@ extern "C" {
# endif
#endif
-#ifndef USE_WINSOCK
-#define _gldns_vsnprintf vsnprintf
-#else
-/* Unlike Linux and BSD, vsnprintf on Windows returns -1 on overflow.
- * Here it is redefined to always return the amount printed
- * if enough space had been available.
- */
-INLINE int
-_gldns_vsnprintf(char *str, size_t size, const char *format, va_list ap)
-{
- int r = vsnprintf(str, size, format, ap);
- return r == -1 ? _vscprintf(format, ap) : r;
-}
-#endif
-
/*
* Copy data allowing for unaligned accesses in network byte order
* (big endian).
@@ -145,6 +130,17 @@ struct gldns_buffer
/** If the buffer is fixed it cannot be resized */
unsigned _fixed : 1;
+ /** If the buffer is vfixed, no more than capacity bytes willl be
+ * written to _data, however the _position counter will be updated
+ * with the amount that would have been written in consecutive
+ * writes. This allows for a modus operandi in which a sequence is
+ * written on a fixed capacity buffer (perhaps with _data on stack).
+ * When everything could be written, then the _data is immediately
+ * usable, if not, then a buffer could be allocated sized precisely
+ * to fit the data for a second attempt.
+ */
+ unsigned _vfixed : 1;
+
/** The current state of the buffer. If writing to the buffer fails
* for any reason, this value is changed. This way, you can perform
* multiple writes in sequence and check for success afterwards. */
@@ -162,9 +158,9 @@ INLINE void
gldns_buffer_invariant(gldns_buffer *buffer)
{
assert(buffer != NULL);
- assert(buffer->_position <= buffer->_limit || buffer->_fixed);
+ assert(buffer->_position <= buffer->_limit || buffer->_vfixed);
assert(buffer->_limit <= buffer->_capacity);
- assert(buffer->_data != NULL || (buffer->_capacity == 0 && buffer->_fixed));
+ assert(buffer->_data != NULL || (buffer->_vfixed && buffer->_capacity == 0));
}
#endif
@@ -196,6 +192,19 @@ void gldns_buffer_new_frm_data(gldns_buffer *buffer, void *data, size_t size);
*/
void gldns_buffer_init_frm_data(gldns_buffer *buffer, void *data, size_t size);
+/**
+ * Setup a buffer with the data pointed to. No data copied, no memory allocs.
+ * The buffer is "virtually" fixed. Writes beyond size (the capacity) will
+ * only update position, but no data will be written beyond capacity. This
+ * allows to determine how big the buffer should have been to contain all the
+ * written data, by looking at the position with gldns_buffer_position(),
+ * similarly to the return value of POSIX's snprintf.
+ * \param[in] buffer pointer to the buffer to put the data in
+ * \param[in] data the data to encapsulate in the buffer
+ * \param[in] size the size of the data
+ */
+void gldns_buffer_init_vfixed_frm_data(gldns_buffer *buffer, void *data, size_t size);
+
/**
* clears the buffer and make it ready for writing. The buffer's limit
* is set to the capacity and the position is set to 0.
@@ -259,7 +268,7 @@ gldns_buffer_position(gldns_buffer *buffer)
INLINE void
gldns_buffer_set_position(gldns_buffer *buffer, size_t mark)
{
- assert(mark <= buffer->_limit || buffer->_fixed);
+ assert(mark <= buffer->_limit || buffer->_vfixed);
buffer->_position = mark;
}
@@ -273,7 +282,7 @@ gldns_buffer_set_position(gldns_buffer *buffer, size_t mark)
INLINE void
gldns_buffer_skip(gldns_buffer *buffer, ssize_t count)
{
- assert(buffer->_position + count <= buffer->_limit || buffer->_fixed);
+ assert(buffer->_position + count <= buffer->_limit || buffer->_vfixed);
buffer->_position += count;
}
@@ -345,7 +354,7 @@ int gldns_buffer_reserve(gldns_buffer *buffer, size_t amount);
INLINE uint8_t *
gldns_buffer_at(const gldns_buffer *buffer, size_t at)
{
- assert(at <= buffer->_limit || buffer->_fixed);
+ assert(at <= buffer->_limit || buffer->_vfixed);
return buffer->_data + at;
}
@@ -395,6 +404,7 @@ INLINE size_t
gldns_buffer_remaining_at(gldns_buffer *buffer, size_t at)
{
gldns_buffer_invariant(buffer);
+ assert(at <= buffer->_limit || buffer->_vfixed);
return at < buffer->_limit ? buffer->_limit - at : 0;
}
@@ -447,7 +457,7 @@ gldns_buffer_available(gldns_buffer *buffer, size_t count)
INLINE void
gldns_buffer_write_at(gldns_buffer *buffer, size_t at, const void *data, size_t count)
{
- if (!buffer->_fixed)
+ if (!buffer->_vfixed)
assert(gldns_buffer_available_at(buffer, at, count));
else if (gldns_buffer_remaining_at(buffer, at) == 0)
return;
@@ -459,6 +469,30 @@ gldns_buffer_write_at(gldns_buffer *buffer, size_t at, const void *data, size_t
memcpy(buffer->_data + at, data, count);
}
+/**
+ * set the given byte to the buffer at the specified position
+ * \param[in] buffer the buffer
+ * \param[in] at the position (in number of bytes) to write the data at
+ * \param[in] c the byte to set to the buffer
+ * \param[in] count the number of bytes of bytes to write
+ */
+
+INLINE void
+gldns_buffer_set_at(gldns_buffer *buffer, size_t at, int c, size_t count)
+{
+ if (!buffer->_vfixed)
+ assert(gldns_buffer_available_at(buffer, at, count));
+ else if (gldns_buffer_remaining_at(buffer, at) == 0)
+ return;
+ else if (count > gldns_buffer_remaining_at(buffer, at)) {
+ memset(buffer->_data + at, c,
+ gldns_buffer_remaining_at(buffer, at));
+ return;
+ }
+ memset(buffer->_data + at, c, count);
+}
+
+
/**
* writes count bytes of data to the current position of the buffer
* \param[in] buffer the buffer
@@ -504,7 +538,7 @@ gldns_buffer_write_string(gldns_buffer *buffer, const char *str)
INLINE void
gldns_buffer_write_u8_at(gldns_buffer *buffer, size_t at, uint8_t data)
{
- if (buffer->_fixed && at + sizeof(data) > buffer->_limit) return;
+ if (buffer->_vfixed && at + sizeof(data) > buffer->_limit) return;
assert(gldns_buffer_available_at(buffer, at, sizeof(data)));
buffer->_data[at] = data;
}
@@ -530,7 +564,7 @@ gldns_buffer_write_u8(gldns_buffer *buffer, uint8_t data)
INLINE void
gldns_buffer_write_u16_at(gldns_buffer *buffer, size_t at, uint16_t data)
{
- if (buffer->_fixed && at + sizeof(data) > buffer->_limit) return;
+ if (buffer->_vfixed && at + sizeof(data) > buffer->_limit) return;
assert(gldns_buffer_available_at(buffer, at, sizeof(data)));
gldns_write_uint16(buffer->_data + at, data);
}
@@ -556,7 +590,7 @@ gldns_buffer_write_u16(gldns_buffer *buffer, uint16_t data)
INLINE void
gldns_buffer_write_u32_at(gldns_buffer *buffer, size_t at, uint32_t data)
{
- if (buffer->_fixed && at + sizeof(data) > buffer->_limit) return;
+ if (buffer->_vfixed && at + sizeof(data) > buffer->_limit) return;
assert(gldns_buffer_available_at(buffer, at, sizeof(data)));
gldns_write_uint32(buffer->_data + at, data);
}
@@ -570,7 +604,7 @@ gldns_buffer_write_u32_at(gldns_buffer *buffer, size_t at, uint32_t data)
INLINE void
gldns_buffer_write_u48_at(gldns_buffer *buffer, size_t at, uint64_t data)
{
- if (buffer->_fixed && at + 6 > buffer->_limit) return;
+ if (buffer->_vfixed && at + 6 > buffer->_limit) return;
assert(gldns_buffer_available_at(buffer, at, 6));
gldns_write_uint48(buffer->_data + at, data);
}
diff --git a/src/gldns/keyraw.c b/src/gldns/keyraw.c
index 7a27e7f0..3f6f1a20 100644
--- a/src/gldns/keyraw.c
+++ b/src/gldns/keyraw.c
@@ -23,6 +23,15 @@
#ifdef HAVE_OPENSSL_ENGINE_H
# include
#endif
+#ifdef HAVE_OPENSSL_BN_H
+#include
+#endif
+#ifdef HAVE_OPENSSL_RSA_H
+#include
+#endif
+#ifdef HAVE_OPENSSL_DSA_H
+#include
+#endif
#endif /* HAVE_SSL */
size_t
@@ -215,6 +224,7 @@ gldns_key_buf2dsa_raw(unsigned char* key, size_t len)
BN_free(Y);
return NULL;
}
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL)
#ifndef S_SPLINT_S
dsa->p = P;
dsa->q = Q;
@@ -222,6 +232,25 @@ gldns_key_buf2dsa_raw(unsigned char* key, size_t len)
dsa->pub_key = Y;
#endif /* splint */
+#else /* OPENSSL_VERSION_NUMBER */
+ if (!DSA_set0_pqg(dsa, P, Q, G)) {
+ /* QPG not yet attached, need to free */
+ BN_free(Q);
+ BN_free(P);
+ BN_free(G);
+
+ DSA_free(dsa);
+ BN_free(Y);
+ return NULL;
+ }
+ if (!DSA_set0_key(dsa, Y, NULL)) {
+ /* QPG attached, cleaned up by DSA_fre() */
+ DSA_free(dsa);
+ BN_free(Y);
+ return NULL;
+ }
+#endif
+
return dsa;
}
@@ -273,11 +302,21 @@ gldns_key_buf2rsa_raw(unsigned char* key, size_t len)
BN_free(modulus);
return NULL;
}
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL)
#ifndef S_SPLINT_S
rsa->n = modulus;
rsa->e = exponent;
#endif /* splint */
+#else /* OPENSSL_VERSION_NUMBER */
+ if (!RSA_set0_key(rsa, modulus, exponent, NULL)) {
+ BN_free(exponent);
+ BN_free(modulus);
+ RSA_free(rsa);
+ return NULL;
+ }
+#endif
+
return rsa;
}
@@ -349,6 +388,27 @@ gldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo)
}
#endif /* USE_ECDSA */
+#ifdef USE_ED25519
+EVP_PKEY*
+gldns_ed255192pkey_raw(const unsigned char* key, size_t keylen)
+{
+ /* ASN1 for ED25519 is 302a300506032b6570032100 <32byteskey> */
+ uint8_t pre[] = {0x30, 0x2a, 0x30, 0x05, 0x06, 0x03, 0x2b, 0x65,
+ 0x70, 0x03, 0x21, 0x00};
+ int pre_len = 12;
+ uint8_t buf[256];
+ EVP_PKEY *evp_key;
+ /* pp gets modified by d2i() */
+ const unsigned char* pp = (unsigned char*)buf;
+ if(keylen != 32 || keylen + pre_len > sizeof(buf))
+ return NULL; /* wrong length */
+ memmove(buf, pre, pre_len);
+ memmove(buf+pre_len, key, keylen);
+ evp_key = d2i_PUBKEY(NULL, &pp, (int)(pre_len+keylen));
+ return evp_key;
+}
+#endif /* USE_ED25519 */
+
int
gldns_digest_evp(unsigned char* data, unsigned int len, unsigned char* dest,
const EVP_MD* md)
diff --git a/src/gldns/keyraw.h b/src/gldns/keyraw.h
index c0d33e60..60e2bfde 100644
--- a/src/gldns/keyraw.h
+++ b/src/gldns/keyraw.h
@@ -92,6 +92,15 @@ EVP_PKEY* gldns_ecdsa2pkey_raw(unsigned char* key, size_t keylen, uint8_t algo);
*/
RSA *gldns_key_buf2rsa_raw(unsigned char* key, size_t len);
+/**
+ * Converts a holding buffer with key material to EVP PKEY in openssl.
+ * Only available if ldns was compiled with ED25519.
+ * \param[in] key the uncompressed wireformat of the key.
+ * \param[in] len length of key data
+ * \return the key or NULL on error.
+ */
+EVP_PKEY* gldns_ed255192pkey_raw(const unsigned char* key, size_t len);
+
/**
* Utility function to calculate hash using generic EVP_MD pointer.
* \param[in] data the data to hash.
diff --git a/src/gldns/parse.c b/src/gldns/parse.c
index e15b4780..d44c328e 100644
--- a/src/gldns/parse.c
+++ b/src/gldns/parse.c
@@ -120,6 +120,10 @@ gldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *l
if (line_nr) {
*line_nr = *line_nr + 1;
}
+ if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) {
+ *t = '\0';
+ return -1;
+ }
*t++ = ' ';
prev_c = c;
continue;
diff --git a/src/gldns/parseutil.c b/src/gldns/parseutil.c
index d68fa89c..558446cb 100644
--- a/src/gldns/parseutil.c
+++ b/src/gldns/parseutil.c
@@ -402,10 +402,12 @@ gldns_b32_ntop_base(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz,
/* ........ ........ ....4444 4....... ........ */
c = src[3] >> 7 ;
+ /* fallthrough */
case 3: dst[4] = b32[(src[2] & 0x0f) << 1 | c];
/* ........ .......3 3333.... ........ ........ */
c = src[2] >> 4 ;
+ /* fallthrough */
case 2: dst[3] = b32[(src[1] & 0x01) << 4 | c];
/* ........ ..22222. ........ ........ ........ */
@@ -413,6 +415,7 @@ gldns_b32_ntop_base(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz,
/* .....111 11...... ........ ........ ........ */
c = src[1] >> 6 ;
+ /* fallthrough */
case 1: dst[1] = b32[(src[0] & 0x07) << 2 | c];
/* 00000... ........ ........ ........ ........ */
@@ -423,9 +426,12 @@ gldns_b32_ntop_base(const uint8_t* src, size_t src_sz, char* dst, size_t dst_sz,
switch (src_sz) {
case 1: dst[2] = '=';
dst[3] = '=';
+ /* fallthrough */
case 2: dst[4] = '=';
+ /* fallthrough */
case 3: dst[5] = '=';
dst[6] = '=';
+ /* fallthrough */
case 4: dst[7] = '=';
}
}
@@ -537,15 +543,18 @@ gldns_b32_pton_base(const char* src, size_t src_sz, uint8_t* dst, size_t dst_sz,
/* ........ ........ ........ .55555.. ........ */
/* ........ ........ ....4444 4....... ........ */
dst[3] = buf[4] << 7 | buf[5] << 2 | buf[6] >> 3;
+ /* fallthrough */
case 5: /* ........ ........ ....4444 4....... ........ */
/* ........ .......3 3333.... ........ ........ */
dst[2] = buf[3] << 4 | buf[4] >> 1;
+ /* fallthrough */
case 4: /* ........ .......3 3333.... ........ ........ */
/* ........ ..22222. ........ ........ ........ */
/* .....111 11...... ........ ........ ........ */
dst[1] = buf[1] << 6 | buf[2] << 1 | buf[3] >> 4;
+ /* fallthrough */
case 2: /* .....111 11...... ........ ........ ........ */
/* 00000... ........ ........ ........ ........ */
diff --git a/src/gldns/rrdef.c b/src/gldns/rrdef.c
index 3d5a5961..91739232 100644
--- a/src/gldns/rrdef.c
+++ b/src/gldns/rrdef.c
@@ -175,7 +175,7 @@ static const gldns_rdf_type type_tkey_wireformat[] = {
GLDNS_RDF_TYPE_TIME,
GLDNS_RDF_TYPE_TIME,
GLDNS_RDF_TYPE_INT16,
- GLDNS_RDF_TYPE_INT16,
+ GLDNS_RDF_TYPE_TSIGERROR,
GLDNS_RDF_TYPE_INT16_DATA,
GLDNS_RDF_TYPE_INT16_DATA,
};
@@ -185,7 +185,7 @@ static const gldns_rdf_type type_tsig_wireformat[] = {
GLDNS_RDF_TYPE_INT16,
GLDNS_RDF_TYPE_INT16_DATA,
GLDNS_RDF_TYPE_INT16,
- GLDNS_RDF_TYPE_INT16,
+ GLDNS_RDF_TYPE_TSIGERROR,
GLDNS_RDF_TYPE_INT16_DATA
};
static const gldns_rdf_type type_tlsa_wireformat[] = {
@@ -341,8 +341,12 @@ static gldns_rr_descriptor rdata_field_descriptors[] = {
{GLDNS_RR_TYPE_NSEC3PARAM, "NSEC3PARAM", 4, 4, type_nsec3param_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 },
/* 52 */
{GLDNS_RR_TYPE_TLSA, "TLSA", 4, 4, type_tlsa_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 },
-
+ /*53 */
+#ifdef DRAFT_RRTYPES
+ {GLDNS_RR_TYPE_SMIMEA, "SMIMEA", 4, 4, type_tlsa_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 },
+#else
{GLDNS_RR_TYPE_NULL, "TYPE53", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 },
+#endif
{GLDNS_RR_TYPE_NULL, "TYPE54", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 },
/* 55
* Hip ends with 0 or more Rendezvous Servers represented as dname's.
@@ -600,6 +604,12 @@ static gldns_rr_descriptor rdata_field_descriptors[] = {
{GLDNS_RR_TYPE_URI, "URI", 3, 3, type_uri_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 },
/* 257 */
{GLDNS_RR_TYPE_CAA, "CAA", 3, 3, type_caa_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 },
+#ifdef DRAFT_RRTYPES
+ /* 258 */
+ {GLDNS_RR_TYPE_AVC, "AVC", 1, 0, NULL, GLDNS_RDF_TYPE_STR, GLDNS_RR_NO_COMPRESS, 0 },
+#else
+{GLDNS_RR_TYPE_NULL, "TYPE258", 1, 1, type_0_wireformat, GLDNS_RDF_TYPE_NONE, GLDNS_RR_NO_COMPRESS, 0 },
+#endif
/* split in array, no longer contiguous */
diff --git a/src/gldns/rrdef.h b/src/gldns/rrdef.h
index b13580ea..b5975aa1 100644
--- a/src/gldns/rrdef.h
+++ b/src/gldns/rrdef.h
@@ -38,7 +38,7 @@ extern "C" {
#define GLDNS_KEY_REVOKE_KEY 0x0080 /* used to revoke KSK, rfc 5011 */
/* The first fields are contiguous and can be referenced instantly */
-#define GLDNS_RDATA_FIELD_DESCRIPTORS_COMMON 258
+#define GLDNS_RDATA_FIELD_DESCRIPTORS_COMMON 259
/** lookuptable for rr classes */
extern struct gldns_struct_lookup_table* gldns_rr_classes;
@@ -195,7 +195,7 @@ enum gldns_enum_rr_type
GLDNS_RR_TYPE_TALINK = 58,
GLDNS_RR_TYPE_CDS = 59, /** RFC 7344 */
GLDNS_RR_TYPE_CDNSKEY = 60, /** RFC 7344 */
- GLDNS_RR_TYPE_OPENPGPKEY = 61, /* draft-ietf-dane-openpgpkey */
+ GLDNS_RR_TYPE_OPENPGPKEY = 61, /* RFC 7929 */
GLDNS_RR_TYPE_CSYNC = 62, /* RFC 7477 */
GLDNS_RR_TYPE_SPF = 99, /* RFC 4408 */
@@ -226,6 +226,7 @@ enum gldns_enum_rr_type
GLDNS_RR_TYPE_ANY = 255,
GLDNS_RR_TYPE_URI = 256, /* RFC 7553 */
GLDNS_RR_TYPE_CAA = 257, /* RFC 6844 */
+ GLDNS_RR_TYPE_AVC = 258,
/** DNSSEC Trust Authorities */
GLDNS_RR_TYPE_TA = 32768,
@@ -350,6 +351,9 @@ enum gldns_enum_rdf_type
*/
GLDNS_RDF_TYPE_LONG_STR,
+ /** TSIG extended 16bit error value */
+ GLDNS_RDF_TYPE_TSIGERROR,
+
/* Aliases */
GLDNS_RDF_TYPE_BITMAP = GLDNS_RDF_TYPE_NSEC
};
@@ -372,6 +376,8 @@ enum gldns_enum_algorithm
GLDNS_ECC_GOST = 12, /* RFC 5933 */
GLDNS_ECDSAP256SHA256 = 13, /* RFC 6605 */
GLDNS_ECDSAP384SHA384 = 14, /* RFC 6605 */
+ GLDNS_ED25519 = 15, /* RFC 8080 */
+ GLDNS_ED448 = 16, /* RFC 8080 */
GLDNS_INDIRECT = 252,
GLDNS_PRIVATEDNS = 253,
GLDNS_PRIVATEOID = 254
@@ -420,7 +426,7 @@ enum gldns_enum_edns_option
GLDNS_EDNS_DAU = 5, /* RFC6975 */
GLDNS_EDNS_DHU = 6, /* RFC6975 */
GLDNS_EDNS_N3U = 7, /* RFC6975 */
- GLDNS_EDNS_CLIENT_SUBNET = 8, /* draft-vandergaast-edns-client-subnet */
+ GLDNS_EDNS_CLIENT_SUBNET = 8, /* RFC7871 */
GLDNS_EDNS_KEEPALIVE = 11, /* draft-ietf-dnsop-edns-tcp-keepalive*/
GLDNS_EDNS_PADDING = 12 /* RFC7830 */
};
@@ -428,6 +434,15 @@ typedef enum gldns_enum_edns_option gldns_edns_option;
#define GLDNS_EDNS_MASK_DO_BIT 0x8000
+/** TSIG and TKEY extended rcodes (16bit), 0-15 are the normal rcodes. */
+#define GLDNS_TSIG_ERROR_NOERROR 0
+#define GLDNS_TSIG_ERROR_BADSIG 16
+#define GLDNS_TSIG_ERROR_BADKEY 17
+#define GLDNS_TSIG_ERROR_BADTIME 18
+#define GLDNS_TSIG_ERROR_BADMODE 19
+#define GLDNS_TSIG_ERROR_BADNAME 20
+#define GLDNS_TSIG_ERROR_BADALG 21
+
/**
* Contains all information about resource record types.
*
diff --git a/src/gldns/str2wire.c b/src/gldns/str2wire.c
index 4550a29a..ffd3d464 100644
--- a/src/gldns/str2wire.c
+++ b/src/gldns/str2wire.c
@@ -328,7 +328,7 @@ rrinternal_write_typeclassttl(gldns_buffer* strbuf, uint8_t* rr, size_t len,
/** find delimiters for type */
static const char*
-rrinternal_get_delims(gldns_rdf_type rdftype, uint16_t r_cnt, uint16_t r_max)
+rrinternal_get_delims(gldns_rdf_type rdftype, size_t r_cnt, size_t r_max)
{
switch(rdftype) {
case GLDNS_RDF_TYPE_B64 :
@@ -463,7 +463,7 @@ rrinternal_parse_unknown(gldns_buffer* strbuf, char* token, size_t token_len,
static int
rrinternal_parse_rdf(gldns_buffer* strbuf, char* token, size_t token_len,
uint8_t* rr, size_t rr_len, size_t* rr_cur_len, gldns_rdf_type rdftype,
- uint16_t rr_type, uint16_t r_cnt, uint16_t r_max, size_t dname_len,
+ uint16_t rr_type, size_t r_cnt, size_t r_max, size_t dname_len,
uint8_t* origin, size_t origin_len)
{
size_t len;
@@ -613,7 +613,7 @@ rrinternal_parse_rdata(gldns_buffer* strbuf, char* token, size_t token_len,
uint8_t* origin, size_t origin_len)
{
const gldns_rr_descriptor *desc = gldns_rr_descript((uint16_t)rr_type);
- uint16_t r_cnt, r_min, r_max;
+ size_t r_cnt, r_min, r_max;
size_t rr_cur_len = dname_len + 10, pre_data_pos, token_strlen;
int was_unknown_rr_format = 0, parens = 0, status, quoted;
const char* delimiters;
@@ -664,6 +664,14 @@ rrinternal_parse_rdata(gldns_buffer* strbuf, char* token, size_t token_len,
&pre_data_pos, delimiters,
rdftype, &token_strlen))
break;
+ } else if(rdftype == GLDNS_RDF_TYPE_INT16_DATA &&
+ strcmp(token, "0")!=0) {
+ /* affix len and b64 fields */
+ if(!gldns_affix_token(strbuf, token,
+ &token_len, "ed, &parens,
+ &pre_data_pos, delimiters,
+ rdftype, &token_strlen))
+ break;
}
/* normal RR */
@@ -693,7 +701,7 @@ rrinternal_parse_rdata(gldns_buffer* strbuf, char* token, size_t token_len,
gldns_buffer_position(strbuf));
}
/* write rdata length */
- gldns_write_uint16(rr+dname_len+8, rr_cur_len-dname_len-10);
+ gldns_write_uint16(rr+dname_len+8, (uint16_t)(rr_cur_len-dname_len-10));
*rr_len = rr_cur_len;
return GLDNS_WIREPARSE_ERR_OK;
}
@@ -861,6 +869,8 @@ int gldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
/* we can have the situation, where we've read ok, but still got
* no bytes to play with, in this case size is 0 */
if(size == 0) {
+ if(*len > 0)
+ rr[0] = 0;
*len = 0;
*dname_len = 0;
return GLDNS_WIREPARSE_ERR_OK;
@@ -868,6 +878,7 @@ int gldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
if(strncmp(line, "$ORIGIN", 7) == 0 && isspace((unsigned char)line[7])) {
int s;
+ strlcpy((char*)rr, line, *len);
*len = 0;
*dname_len = 0;
if(!parse_state) return GLDNS_WIREPARSE_ERR_OK;
@@ -878,12 +889,19 @@ int gldns_fp2wire_rr_buf(FILE* in, uint8_t* rr, size_t* len, size_t* dname_len,
return s;
} else if(strncmp(line, "$TTL", 4) == 0 && isspace((unsigned char)line[4])) {
const char* end = NULL;
+ strlcpy((char*)rr, line, *len);
*len = 0;
*dname_len = 0;
if(!parse_state) return GLDNS_WIREPARSE_ERR_OK;
parse_state->default_ttl = gldns_str2period(
gldns_strip_ws(line+5), &end);
} else if (strncmp(line, "$INCLUDE", 8) == 0) {
+ strlcpy((char*)rr, line, *len);
+ *len = 0;
+ *dname_len = 0;
+ return GLDNS_WIREPARSE_ERR_INCLUDE;
+ } else if (strncmp(line, "$", 1) == 0) {
+ strlcpy((char*)rr, line, *len);
*len = 0;
*dname_len = 0;
return GLDNS_WIREPARSE_ERR_INCLUDE;
@@ -940,6 +958,8 @@ int gldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len,
return gldns_str2wire_time_buf(str, rd, len);
case GLDNS_RDF_TYPE_PERIOD:
return gldns_str2wire_period_buf(str, rd, len);
+ case GLDNS_RDF_TYPE_TSIGTIME:
+ return gldns_str2wire_tsigtime_buf(str, rd, len);
case GLDNS_RDF_TYPE_LOC:
return gldns_str2wire_loc_buf(str, rd, len);
case GLDNS_RDF_TYPE_WKS:
@@ -964,6 +984,8 @@ int gldns_str2wire_rdf_buf(const char* str, uint8_t* rd, size_t* len,
return gldns_str2wire_tag_buf(str, rd, len);
case GLDNS_RDF_TYPE_LONG_STR:
return gldns_str2wire_long_str_buf(str, rd, len);
+ case GLDNS_RDF_TYPE_TSIGERROR:
+ return gldns_str2wire_tsigerror_buf(str, rd, len);
case GLDNS_RDF_TYPE_HIP:
return gldns_str2wire_hip_buf(str, rd, len);
case GLDNS_RDF_TYPE_INT16_DATA:
@@ -1168,6 +1190,10 @@ int gldns_str2wire_b64_buf(const char* str, uint8_t* rd, size_t* len)
{
size_t sz = gldns_b64_pton_calculate_size(strlen(str));
int n;
+ if(strcmp(str, "0") == 0) {
+ *len = 0;
+ return GLDNS_WIREPARSE_ERR_OK;
+ }
if(*len < sz)
return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
n = gldns_b64_pton(str, rd, *len);
@@ -1201,6 +1227,10 @@ int gldns_str2wire_hex_buf(const char* str, uint8_t* rd, size_t* len)
s++;
continue;
}
+ if(dlen == 0 && *s == '0' && *(s+1) == 0) {
+ *len = 0;
+ return GLDNS_WIREPARSE_ERR_OK;
+ }
if(!isxdigit((unsigned char)*s))
return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_HEX, s-str);
if(*len < dlen/2 + 1)
@@ -1341,6 +1371,21 @@ int gldns_str2wire_alg_buf(const char* str, uint8_t* rd, size_t* len)
return GLDNS_WIREPARSE_ERR_OK;
}
+int gldns_str2wire_tsigerror_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ gldns_lookup_table *lt = gldns_lookup_by_name(gldns_tsig_errors, str);
+ if(*len < 2)
+ return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ if(lt) {
+ gldns_write_uint16(rd, (uint16_t)lt->id);
+ *len = 2;
+ } else {
+ /* try as-is (a number) */
+ return gldns_str2wire_int16_buf(str, rd, len);
+ }
+ return GLDNS_WIREPARSE_ERR_OK;
+}
+
int gldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len)
{
/* convert a time YYYYDDMMHHMMSS to wireformat */
@@ -1369,7 +1414,7 @@ int gldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len)
if (tm.tm_sec < 0 || tm.tm_sec > 59)
return GLDNS_WIREPARSE_ERR_SYNTAX_TIME;
- gldns_write_uint32(rd, gldns_mktime_from_utc(&tm));
+ gldns_write_uint32(rd, (uint32_t)gldns_mktime_from_utc(&tm));
} else {
/* handle it as 32 bits timestamp */
char *end;
@@ -1383,6 +1428,24 @@ int gldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len)
return GLDNS_WIREPARSE_ERR_OK;
}
+int gldns_str2wire_tsigtime_buf(const char* str, uint8_t* rd, size_t* len)
+{
+ char* end;
+ uint64_t t = (uint64_t)strtol((char*)str, &end, 10);
+ uint16_t high;
+ uint32_t low;
+ if(*end != 0)
+ return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TIME, end-str);
+ if(*len < 6)
+ return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
+ high = (uint16_t)(t>>32);
+ low = (uint32_t)(t);
+ gldns_write_uint16(rd, high);
+ gldns_write_uint32(rd+2, low);
+ *len = 6;
+ return GLDNS_WIREPARSE_ERR_OK;
+}
+
int gldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len)
{
const char* end;
@@ -1932,7 +1995,7 @@ int gldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len)
if(!isalnum((unsigned char)*ptr))
return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TAG, ptr-str);
}
- rd[0] = slen;
+ rd[0] = (uint8_t)slen;
memmove(rd+1, str, slen);
*len = slen+1;
return GLDNS_WIREPARSE_ERR_OK;
@@ -2000,7 +2063,7 @@ int gldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len)
return RET_ERR_SHIFT(e, s-(char*)str);
if(pklen > 65535)
return RET_ERR(GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW, s-(char*)str+65535);
- gldns_write_uint16(rd+2, pklen);
+ gldns_write_uint16(rd+2, (uint16_t)pklen);
*len = 4 + hitlen + pklen;
return GLDNS_WIREPARSE_ERR_OK;
@@ -2008,16 +2071,29 @@ int gldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len)
int gldns_str2wire_int16_data_buf(const char* str, uint8_t* rd, size_t* len)
{
- size_t sz = gldns_b64_pton_calculate_size(strlen(str));
+ char* s;
int n;
- if(*len < sz+2)
+ n = strtol(str, &s, 10);
+ if(*len < ((size_t)n)+2)
return GLDNS_WIREPARSE_ERR_BUFFER_TOO_SMALL;
- if(sz > 65535)
+ if(n > 65535)
return GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW;
- n = gldns_b64_pton(str, rd+2, (*len)-2);
+
+ if(n == 0) {
+ gldns_write_uint16(rd, 0);
+ *len = 2;
+ return GLDNS_WIREPARSE_ERR_OK;
+ }
+ if(*s != ' ')
+ return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_INT, s-(char*)str);
+ s++;
+ while(*s == ' ')
+ s++;
+
+ n = gldns_b64_pton(s, rd+2, (*len)-2);
if(n < 0)
return GLDNS_WIREPARSE_ERR_SYNTAX_B64;
gldns_write_uint16(rd, (uint16_t)n);
- *len = (size_t)n;
+ *len = ((size_t)n)+2;
return GLDNS_WIREPARSE_ERR_OK;
}
diff --git a/src/gldns/str2wire.h b/src/gldns/str2wire.h
index e9360447..1b7777bd 100644
--- a/src/gldns/str2wire.h
+++ b/src/gldns/str2wire.h
@@ -237,6 +237,8 @@ struct gldns_file_parse_state {
* @param rr: this is malloced by the user and the result is stored here,
* if an RR is read. If no RR is read this is signalled with the
* return len set to 0 (for ORIGIN, TTL directives).
+ * The read line is available in the rr_buf (zero terminated), for
+ * $DIRECTIVE style elements.
* @param len: on input, the length of the rr buffer. on output the rr len.
* Buffer size of 64k should be enough.
* @param dname_len: returns the length of the dname initial part of the rr.
@@ -417,6 +419,24 @@ int gldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len);
*/
int gldns_str2wire_period_buf(const char* str, uint8_t* rd, size_t* len);
+/**
+ * Convert rdf of type GLDNS_RDF_TYPE_TSIGTIME from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int gldns_str2wire_tsigtime_buf(const char* str, uint8_t* rd, size_t* len);
+
+/**
+ * Convert rdf of type GLDNS_RDF_TYPE_TSIGERROR from string to wireformat.
+ * @param str: the text to convert for this rdata element.
+ * @param rd: rdata buffer for the wireformat.
+ * @param len: length of rd buffer on input, used length on output.
+ * @return 0 on success, error on failure.
+ */
+int gldns_str2wire_tsigerror_buf(const char* str, uint8_t* rd, size_t* len);
+
/**
* Convert rdf of type GLDNS_RDF_TYPE_LOC from string to wireformat.
* @param str: the text to convert for this rdata element.
diff --git a/src/gldns/wire2str.c b/src/gldns/wire2str.c
index abc055d7..2718925e 100644
--- a/src/gldns/wire2str.c
+++ b/src/gldns/wire2str.c
@@ -47,6 +47,8 @@ static gldns_lookup_table gldns_algorithms_data[] = {
{ GLDNS_ECC_GOST, "ECC-GOST"},
{ GLDNS_ECDSAP256SHA256, "ECDSAP256SHA256"},
{ GLDNS_ECDSAP384SHA384, "ECDSAP384SHA384"},
+ { GLDNS_ED25519, "ED25519"},
+ { GLDNS_ED448, "ED448"},
{ GLDNS_INDIRECT, "INDIRECT" },
{ GLDNS_PRIVATEDNS, "PRIVATEDNS" },
{ GLDNS_PRIVATEOID, "PRIVATEOID" },
@@ -171,6 +173,28 @@ static gldns_lookup_table gldns_edns_options_data[] = {
};
gldns_lookup_table* gldns_edns_options = gldns_edns_options_data;
+static gldns_lookup_table gldns_tsig_errors_data[] = {
+ { GLDNS_TSIG_ERROR_NOERROR, "NOERROR" },
+ { GLDNS_RCODE_FORMERR, "FORMERR" },
+ { GLDNS_RCODE_SERVFAIL, "SERVFAIL" },
+ { GLDNS_RCODE_NXDOMAIN, "NXDOMAIN" },
+ { GLDNS_RCODE_NOTIMPL, "NOTIMPL" },
+ { GLDNS_RCODE_REFUSED, "REFUSED" },
+ { GLDNS_RCODE_YXDOMAIN, "YXDOMAIN" },
+ { GLDNS_RCODE_YXRRSET, "YXRRSET" },
+ { GLDNS_RCODE_NXRRSET, "NXRRSET" },
+ { GLDNS_RCODE_NOTAUTH, "NOTAUTH" },
+ { GLDNS_RCODE_NOTZONE, "NOTZONE" },
+ { GLDNS_TSIG_ERROR_BADSIG, "BADSIG" },
+ { GLDNS_TSIG_ERROR_BADKEY, "BADKEY" },
+ { GLDNS_TSIG_ERROR_BADTIME, "BADTIME" },
+ { GLDNS_TSIG_ERROR_BADMODE, "BADMODE" },
+ { GLDNS_TSIG_ERROR_BADNAME, "BADNAME" },
+ { GLDNS_TSIG_ERROR_BADALG, "BADALG" },
+ { 0, NULL }
+};
+gldns_lookup_table* gldns_tsig_errors = gldns_tsig_errors_data;
+
char* gldns_wire2str_pkt(uint8_t* data, size_t len)
{
size_t slen = (size_t)gldns_wire2str_pkt_buf(data, len, NULL, 0);
@@ -271,6 +295,12 @@ int gldns_wire2str_rcode_buf(int rcode, char* s, size_t slen)
return gldns_wire2str_rcode_print(&s, &slen, rcode);
}
+int gldns_wire2str_opcode_buf(int opcode, char* s, size_t slen)
+{
+ /* use arguments as temporary variables */
+ return gldns_wire2str_opcode_print(&s, &slen, opcode);
+}
+
int gldns_wire2str_dname_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
{
/* use arguments as temporary variables */
@@ -279,7 +309,7 @@ int gldns_wire2str_dname_buf(uint8_t* d, size_t dlen, char* s, size_t slen)
int gldns_str_vprint(char** str, size_t* slen, const char* format, va_list args)
{
- int w = _gldns_vsnprintf(*str, *slen, format, args);
+ int w = vsnprintf(*str, *slen, format, args);
if(w < 0) {
/* error in printout */
return 0;
@@ -668,7 +698,7 @@ int gldns_wire2str_rdata_scan(uint8_t** d, size_t* dlen, char** s,
uint8_t* origd = *d;
char* origs = *s;
size_t origdlen = *dlen, origslen = *slen;
- uint16_t r_cnt, r_max;
+ size_t r_cnt, r_max;
gldns_rdf_type rdftype;
int w = 0, n;
@@ -789,8 +819,9 @@ int gldns_wire2str_dname_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen,
}
/* spool label characters, end with '.' */
- if(in_buf && *dlen < labellen) labellen = *dlen;
- else if(!in_buf && pos+labellen > pkt+pktlen)
+ if(in_buf && *dlen < (size_t)labellen)
+ labellen = (uint8_t)*dlen;
+ else if(!in_buf && pos+(size_t)labellen > pkt+pktlen)
labellen = (uint8_t)(pkt + pktlen - pos);
for(i=0; i<(unsigned)labellen; i++) {
w += dname_char_print(s, slen, *pos++);
@@ -967,6 +998,8 @@ int gldns_wire2str_rdf_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen,
return gldns_wire2str_tag_scan(d, dlen, s, slen);
case GLDNS_RDF_TYPE_LONG_STR:
return gldns_wire2str_long_str_scan(d, dlen, s, slen);
+ case GLDNS_RDF_TYPE_TSIGERROR:
+ return gldns_wire2str_tsigerror_scan(d, dlen, s, slen);
}
/* unknown rdf type */
return -1;
@@ -1187,11 +1220,17 @@ static int gldns_wire2str_b64_scan_num(uint8_t** d, size_t* dl, char** s,
int gldns_wire2str_b64_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
{
+ if(*dl == 0) {
+ return gldns_str_print(s, sl, "0");
+ }
return gldns_wire2str_b64_scan_num(d, dl, s, sl, *dl);
}
int gldns_wire2str_hex_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
{
+ if(*dl == 0) {
+ return gldns_str_print(s, sl, "0");
+ }
return print_remainder_hex("", d, dl, s, sl);
}
@@ -1565,6 +1604,7 @@ int gldns_wire2str_hip_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
int gldns_wire2str_int16_data_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
{
+ int w;
uint16_t n;
if(*dl < 2)
return -1;
@@ -1573,7 +1613,12 @@ int gldns_wire2str_int16_data_scan(uint8_t** d, size_t* dl, char** s, size_t* sl
return -1;
(*d)+=2;
(*dl)-=2;
- return gldns_wire2str_b64_scan_num(d, dl, s, sl, n);
+ if(n == 0) {
+ return gldns_str_print(s, sl, "0");
+ }
+ w = gldns_str_print(s, sl, "%u ", (unsigned)n);
+ w += gldns_wire2str_b64_scan_num(d, dl, s, sl, n);
+ return w;
}
int gldns_wire2str_nsec3_next_owner_scan(uint8_t** d, size_t* dl, char** s,
@@ -1630,10 +1675,10 @@ int gldns_wire2str_tag_scan(uint8_t** d, size_t* dl, char** s, size_t* sl)
if(*dl < 1+n)
return -1;
for(i=0; iname)
+ w = gldns_str_print(s, sl, "%s", lt->name);
+ else w = gldns_str_print(s, sl, "%d", data);
+ (*dl)-=2;
+ (*d)+=2;
+ return w;
+}
+
int gldns_wire2str_edns_llq_print(char** s, size_t* sl, uint8_t* data,
size_t len)
{
@@ -1983,10 +2043,10 @@ int gldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str,
w += gldns_str_print(str, str_len, " ; udp: %u", (unsigned)udpsize);
if(rdatalen) {
- if(*data_len < rdatalen) {
+ if((size_t)*data_len < rdatalen) {
w += gldns_str_print(str, str_len,
" ; Error EDNS rdata too short; ");
- rdatalen = *data_len;
+ rdatalen = (uint16_t)*data_len;
}
w += print_edns_opts(str, str_len, *data, rdatalen);
(*data) += rdatalen;
diff --git a/src/gldns/wire2str.h b/src/gldns/wire2str.h
index 050fb8e7..2007fd8e 100644
--- a/src/gldns/wire2str.h
+++ b/src/gldns/wire2str.h
@@ -38,6 +38,8 @@ extern struct gldns_struct_lookup_table* gldns_edns_flags;
extern struct gldns_struct_lookup_table* gldns_edns_options;
/** error string from wireparse */
extern struct gldns_struct_lookup_table* gldns_wireparse_errors;
+/** tsig errors are the rcodes with extra (higher) values */
+extern struct gldns_struct_lookup_table* gldns_tsig_errors;
/**
* Convert wireformat packet to a string representation
@@ -118,7 +120,7 @@ int gldns_str_print(char** str, size_t* slen, const char* format, ...)
* @param str_len: the size of the string buffer. If more is needed, it'll
* silently truncate the output to fit in the buffer.
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_pkt_buf(uint8_t* data, size_t data_len, char* str,
size_t str_len);
@@ -351,7 +353,7 @@ int gldns_wire2str_edns_option_code_print(char** str, size_t* str_len,
* @param str_len: the size of the string buffer. If more is needed, it'll
* silently truncate the output to fit in the buffer.
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str,
size_t str_len);
@@ -369,7 +371,7 @@ int gldns_wire2str_rr_buf(uint8_t* rr, size_t rr_len, char* str,
* @param str_len: the size of the string buffer. If more is needed, it'll
* silently truncate the output to fit in the buffer.
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_rr_unknown_buf(uint8_t* rr, size_t rr_len, char* str,
size_t str_len);
@@ -389,7 +391,7 @@ int gldns_wire2str_rr_unknown_buf(uint8_t* rr, size_t rr_len, char* str,
* @param str_len: the size of the string buffer. If more is needed, it'll
* silently truncate the output to fit in the buffer.
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rr_len, size_t dname_len,
char* str, size_t str_len);
@@ -406,7 +408,7 @@ int gldns_wire2str_rr_comment_buf(uint8_t* rr, size_t rr_len, size_t dname_len,
* silently truncate the output to fit in the buffer.
* @param rrtype: rr type of the data
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str,
size_t str_len, uint16_t rrtype);
@@ -417,7 +419,7 @@ int gldns_wire2str_rdata_buf(uint8_t* rdata, size_t rdata_len, char* str,
* @param str: the string to write to.
* @param len: length of str.
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_type_buf(uint16_t rrtype, char* str, size_t len);
@@ -427,7 +429,7 @@ int gldns_wire2str_type_buf(uint16_t rrtype, char* str, size_t len);
* @param str: the string to write to.
* @param len: length of str.
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_class_buf(uint16_t rrclass, char* str, size_t len);
@@ -437,10 +439,21 @@ int gldns_wire2str_class_buf(uint16_t rrclass, char* str, size_t len);
* @param str: the string to write to.
* @param len: length of str.
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_rcode_buf(int rcode, char* str, size_t len);
+/**
+ * Convert host format opcode to a string. 'QUERY', 'NOTIFY', 'UPDATE'.
+ * With user buffer.
+ * @param opcode: opcode as integer in host order
+ * @param str: the string to write to.
+ * @param len: length of str.
+ * @return the number of characters for this element, excluding zerobyte.
+ * Is larger or equal than str_len if output was truncated.
+ */
+int gldns_wire2str_opcode_buf(int opcode, char* str, size_t len);
+
/**
* Convert wire dname to a string, "example.com.". With user buffer.
* @param dname: the dname in uncompressed wireformat.
@@ -448,7 +461,7 @@ int gldns_wire2str_rcode_buf(int rcode, char* str, size_t len);
* @param str: the string to write to.
* @param len: length of string.
* @return the number of characters for this element, excluding zerobyte.
- * Is larger than str_len if output was truncated.
+ * Is larger or equal than str_len if output was truncated.
*/
int gldns_wire2str_dname_buf(uint8_t* dname, size_t dname_len, char* str,
size_t len);
@@ -796,6 +809,19 @@ int gldns_wire2str_hip_scan(uint8_t** data, size_t* data_len, char** str,
int gldns_wire2str_int16_data_scan(uint8_t** data, size_t* data_len, char** str,
size_t* str_len);
+/**
+ * Scan wireformat tsigerror field to string, with user buffers.
+ * It shifts the arguments to move along (see gldns_wire2str_pkt_scan).
+ * @param data: wireformat data.
+ * @param data_len: length of data buffer.
+ * @param str: string buffer.
+ * @param str_len: length of string buffer.
+ * @return number of characters (except null) needed to print.
+ * Can return -1 on failure.
+ */
+int gldns_wire2str_tsigerror_scan(uint8_t** data, size_t* data_len, char** str,
+ size_t* str_len);
+
/**
* Scan wireformat nsec3_next_owner field to string, with user buffers.
* It shifts the arguments to move along (see gldns_wire2str_pkt_scan).
diff --git a/src/jsmn b/src/jsmn
index 49024a6e..c831c386 160000
--- a/src/jsmn
+++ b/src/jsmn
@@ -1 +1 @@
-Subproject commit 49024a6e11739c866bce0e9f3617278b98906ad0
+Subproject commit c831c3869f56a571a79a3cbf58e0a366e588e256
diff --git a/src/libgetdns.symbols b/src/libgetdns.symbols
index 0b98b211..43564ecd 100644
--- a/src/libgetdns.symbols
+++ b/src/libgetdns.symbols
@@ -26,9 +26,12 @@ getdns_context_get_limit_outstanding_queries
getdns_context_get_namespaces
getdns_context_get_num_pending_requests
getdns_context_get_resolution_type
+getdns_context_get_round_robin_upstreams
getdns_context_get_suffix
getdns_context_get_timeout
getdns_context_get_tls_authentication
+getdns_context_get_tls_backoff_time
+getdns_context_get_tls_connection_retries
getdns_context_get_tls_query_padding_blocksize
getdns_context_get_update_callback
getdns_context_get_upstream_recursive_servers
@@ -52,17 +55,22 @@ getdns_context_set_follow_redirects
getdns_context_set_idle_timeout
getdns_context_set_limit_outstanding_queries
getdns_context_set_listen_addresses
+getdns_context_set_logfunc
getdns_context_set_memory_functions
getdns_context_set_namespaces
getdns_context_set_resolution_type
getdns_context_set_return_dnssec_status
+getdns_context_set_round_robin_upstreams
getdns_context_set_suffix
getdns_context_set_timeout
getdns_context_set_tls_authentication
+getdns_context_set_tls_backoff_time
+getdns_context_set_tls_connection_retries
getdns_context_set_tls_query_padding_blocksize
getdns_context_set_update_callback
getdns_context_set_upstream_recursive_servers
getdns_context_set_use_threads
+getdns_context_unset_edns_maximum_udp_payload_size
getdns_convert_alabel_to_ulabel
getdns_convert_dns_name_to_fqdn
getdns_convert_fqdn_to_dns_name
diff --git a/src/list.c b/src/list.c
index eec2a1c1..7a7d3e38 100644
--- a/src/list.c
+++ b/src/list.c
@@ -312,7 +312,7 @@ getdns_return_t
_getdns_list_copy(const struct getdns_list * srclist,
struct getdns_list ** dstlist)
{
- int i;
+ size_t i;
getdns_return_t retval;
if (!dstlist)
@@ -353,6 +353,9 @@ _getdns_list_copy(const struct getdns_list * srclist,
retval = _getdns_list_append_dict(*dstlist,
srclist->items[i].data.dict);
break;
+ default:
+ retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED;
+ break;
}
if (retval != GETDNS_RETURN_GOOD) {
getdns_list_destroy(*dstlist);
diff --git a/src/mdns.c b/src/mdns.c
new file mode 100644
index 00000000..56ce7013
--- /dev/null
+++ b/src/mdns.c
@@ -0,0 +1,2161 @@
+/*
+ * Functions for MDNS resolving.
+ */
+
+ /*
+ * Copyright (c) 2016 Christian Huitema
+ *
+ * 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 THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include "config.h"
+#include "debug.h"
+#include "context.h"
+#include "general.h"
+#include "gldns/pkthdr.h"
+#include "gldns/rrdef.h"
+#include "util-internal.h"
+#include "mdns.h"
+
+#ifdef HAVE_MDNS_SUPPORT
+
+#ifdef USE_WINSOCK
+typedef u_short sa_family_t;
+#define _getdns_EWOULDBLOCK (WSAGetLastError() == WSATRY_AGAIN ||\
+ WSAGetLastError() == WSAEWOULDBLOCK)
+#define _getdns_EINPROGRESS (WSAGetLastError() == WSAEINPROGRESS)
+#else
+#define _getdns_EWOULDBLOCK (errno == EAGAIN || errno == EWOULDBLOCK)
+#define _getdns_EINPROGRESS (errno == EINPROGRESS)
+#define SOCKADDR struct sockaddr
+#define SOCKADDR_IN struct sockaddr_in
+#define SOCKADDR_IN6 struct sockaddr_in6
+#define SOCKET int
+#define IP_MREQ struct ip_mreq
+#define IPV6_MREQ struct ipv6_mreq
+#define BOOL int
+#define TRUE 1
+#endif
+
+/* Define IPV6_ADD_MEMBERSHIP for FreeBSD and Mac OS X */
+#ifndef IPV6_ADD_MEMBERSHIP
+#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
+#endif
+
+uint64_t _getdns_get_time_as_uintt64();
+
+#include "util/fptr_wlist.h"
+#include "util/lookup3.h"
+
+/*
+ * Constants defined in RFC 6762
+ */
+
+#define MDNS_MCAST_IPV4_LONG 0xE00000FB /* 224.0.0.251 */
+#define MDNS_MCAST_PORT 5353
+
+static uint8_t mdns_mcast_ipv6[] = {
+ 0xFF, 0x02, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0xFB
+};
+
+static uint8_t mdns_suffix_dot_local[] = { 5, 'l', 'o', 'c', 'a', 'l', 0 };
+static uint8_t mdns_suffix_254_169_in_addr_arpa[] = {
+ 3, '2', '5', '4',
+ 3, '1', '6', '9',
+ 7, 'i', 'n', '-', 'a', 'd', 'd', 'r',
+ 4, 'a', 'r', 'p', 'a', 0 };
+static uint8_t mdns_suffix_8_e_f_ip6_arpa[] = {
+ 1, '8', 1, 'e', 1, 'f',
+ 3, 'i', 'p', '6',
+ 4, 'a', 'r', 'p', 'a', 0 };
+static uint8_t mdns_suffix_9_e_f_ip6_arpa[] = {
+ 1, '9', 1, 'e', 1, 'f',
+ 3, 'i', 'p', '6',
+ 4, 'a', 'r', 'p', 'a', 0 };
+static uint8_t mdns_suffix_a_e_f_ip6_arpa[] = {
+ 1, 'a', 1, 'e', 1, 'f',
+ 3, 'i', 'p', '6',
+ 4, 'a', 'r', 'p', 'a', 0 };
+static uint8_t mdns_suffix_b_e_f_ip6_arpa[] = {
+ 1, 'b', 1, 'e', 1, 'f',
+ 3, 'i', 'p', '6',
+ 4, 'a', 'r', 'p', 'a', 0 };
+
+#define MDNS_PACKET_INDEX_QCODE 2
+#define MDNS_PACKET_INDEX_QUERY 4
+#define MDNS_PACKET_INDEX_ANSWER 6
+
+/*
+ * MDNS cache management using LRU Hash.
+ *
+ * Each record contains a DNS query + response, formatted as received from
+ * the network. By convention, there will be exactly one query, and
+ * a variable number of answers. Auth and AD sections will not be cached.
+ * For maintenance purpose, each recontains a last accessed time stamp.
+ *
+ * This structure works very well for classic DNS caches, but for MDNS we
+ * have to consider processing a new record for an existing cache entry. If
+ * the record is present, its TTL should be updated. If the record is not
+ * present, it should be added to the existing data.
+ *
+ * After an update, the TTL of all the records should be updated. Some
+ * records will end up with a TTL value of zero. These records should be
+ * deleted, using a "compression" procedure.
+ */
+
+
+
+/*
+ * For the data part, we want to allocate in rounded increments, so as to reduce the
+ * number of calls to XMALLOC
+ */
+
+static uint32_t
+mdns_util_suggest_size(uint32_t required_size)
+{
+ return (required_size <= 512) ? ((required_size <= 256) ? 256 : 512) :
+ ((required_size + 1023) & 0xFFFFFC00);
+}
+
+/*
+ * Cache management utilities
+ */
+static int
+mdns_util_skip_name(uint8_t *p)
+{
+ int x = 0;
+ int l;
+
+ for (;;) {
+ l = p[x];
+ if (l == 0)
+ {
+ x++;
+ break;
+ }
+ else if (l >= 0xC0)
+ {
+ x += 2;
+ break;
+ }
+ else
+ {
+ x += l + 1;
+ }
+ }
+ return x;
+}
+
+static size_t
+mdns_util_copy_name(uint8_t * message, size_t message_length, size_t current_index,
+ uint8_t *name, int name_len_max, int name_index, int * name_len)
+{
+ uint8_t l;
+ size_t recursive_index;
+
+ *name_len = 0;
+ while (current_index < message_length && name_index < name_len_max) {
+ l = message[current_index++];
+ if (l == 0)
+ {
+ name[name_index++] = 0;
+ *name_len = name_index;
+ break;
+ }
+ else if (l >= 0xC0)
+ {
+ if (current_index < message_length)
+ {
+ recursive_index = ((l & 63) << 8) | message[current_index++];
+
+ (void) mdns_util_copy_name(message, message_length,
+ recursive_index, name, name_len_max, name_index, name_len);
+
+ if (*name_len == 0)
+ {
+ current_index = message_length;
+ }
+ }
+ break;
+ }
+ else if (current_index + l < message_length &&
+ name_index + l + 1 < name_len_max)
+ {
+ name[name_index++] = l;
+
+ memcpy(name + name_index, message + current_index, l);
+ name_index += l;
+ current_index += l;
+ }
+ else
+ {
+ current_index = message_length;
+ break;
+ }
+ }
+
+ return current_index;
+}
+
+static int
+mdns_util_skip_query(uint8_t *p)
+{
+ return mdns_util_skip_name(p) + 4;
+}
+
+/*
+ * Single copy procedure for many record types
+ * copy N octets, then the canonical value of the name.
+ */
+static int
+mdns_util_canonical_flags_and_name(uint8_t *message, int message_length,
+ int record_length,
+ int current_index,
+ int nb_octets_to_copy,
+ uint8_t *buffer, int buffer_max,
+ uint8_t **actual_record, int *actual_length)
+{
+ int ret = 0;
+ int buffer_index = 0;
+ int name_len = 0;
+
+ if (buffer_max <= nb_octets_to_copy || record_length <= nb_octets_to_copy)
+ {
+ /* incorrect buffer */
+ ret = GETDNS_RETURN_GENERIC_ERROR;
+ }
+ else
+ {
+ for (int i = 0; i < nb_octets_to_copy; i++)
+ {
+ buffer[buffer_index++] = message[current_index++];
+ }
+
+ current_index = mdns_util_copy_name(message, message_length, current_index, buffer, buffer_max, buffer_index, &name_len);
+ if (current_index == record_length)
+ {
+ buffer_index += name_len;
+ *actual_record = buffer;
+ *actual_length = buffer_index;
+ }
+ else
+ {
+ /* something went wrong. */
+ ret = GETDNS_RETURN_BAD_DOMAIN_NAME;
+ }
+ }
+
+ return ret;
+}
+/*
+ * Set record value to canonical form
+ */
+static int
+mdns_util_canonical_record(uint8_t *message, int message_length,
+ int record_type, int record_class, int record_length,
+ int record_index,
+ uint8_t *buffer, int buffer_max,
+ uint8_t **actual_record, int *actual_length)
+{
+ int ret = 0;
+ int current_index = record_index;
+ /* Check whether the record needs canonization */
+ *actual_record = message + record_index;
+ *actual_length = record_length;
+
+ if (record_class != GLDNS_RR_CLASS_IN)
+ {
+ /*
+ * No attempt at canonization outside the IN class.
+ */
+ return 0;
+ }
+
+ switch (record_type)
+ {
+
+ case GLDNS_RR_TYPE_NS:
+ case GLDNS_RR_TYPE_CNAME:
+ case GLDNS_RR_TYPE_PTR:
+ case GLDNS_RR_TYPE_MD:
+ case GLDNS_RR_TYPE_MB:
+ case GLDNS_RR_TYPE_MF:
+ case GLDNS_RR_TYPE_MG:
+ case GLDNS_RR_TYPE_MR:
+ case GLDNS_RR_TYPE_NSAP_PTR:
+ /*
+ * copy the name in canonical form
+ */
+ ret = mdns_util_canonical_flags_and_name(message, message_length,
+ record_length, current_index, 0,
+ buffer, buffer_max, actual_record, actual_length);
+ break;
+
+ case GLDNS_RR_TYPE_A:
+ case GLDNS_RR_TYPE_AAAA:
+ case GLDNS_RR_TYPE_TXT:
+ case GLDNS_RR_TYPE_HINFO:
+ case GLDNS_RR_TYPE_MINFO:
+ case GLDNS_RR_TYPE_NULL:
+ case GLDNS_RR_TYPE_WKS:
+ case GLDNS_RR_TYPE_X25:
+ case GLDNS_RR_TYPE_ISDN:
+ case GLDNS_RR_TYPE_NSAP:
+ case GLDNS_RR_TYPE_SIG:
+ case GLDNS_RR_TYPE_KEY:
+ case GLDNS_RR_TYPE_GPOS:
+ case GLDNS_RR_TYPE_LOC:
+ case GLDNS_RR_TYPE_EID:
+ case GLDNS_RR_TYPE_NIMLOC:
+ /* leave the content as is, no domain name in content */
+ break;
+
+ case GLDNS_RR_TYPE_SRV:
+ /*
+ * Copy 6 octets for weight(2), priority(2) and port(2),
+ * then copy the name.
+ */
+ ret = mdns_util_canonical_flags_and_name(message, message_length,
+ record_length, current_index, 6,
+ buffer, buffer_max, actual_record, actual_length);
+ break;
+
+ case GLDNS_RR_TYPE_MX:
+ case GLDNS_RR_TYPE_RT:
+ case GLDNS_RR_TYPE_AFSDB:
+ /*
+ * copy two bytes preference or subtype, then
+ * copy the name in canonical form
+ */
+ ret = mdns_util_canonical_flags_and_name(message, message_length,
+ record_length, current_index, 2,
+ buffer, buffer_max, actual_record, actual_length);
+ break;
+
+ case GLDNS_RR_TYPE_NAPTR:
+ case GLDNS_RR_TYPE_SOA:
+ case GLDNS_RR_TYPE_RP:
+ case GLDNS_RR_TYPE_NXT:
+ case GLDNS_RR_TYPE_PX:
+ case GLDNS_RR_TYPE_ATMA:
+ /*
+ * Group of record types that are complex, and also
+ * unexpected in MDNS/DNS-SD operation. Copying the
+ * record directly will work as long as the sender
+ * does not attempt name compression.
+ * TODO: log some kind of error.
+ */
+ break;
+#if 0
+
+ /** RFC2915 */
+ GLDNS_RR_TYPE_NAPTR = 35,
+ /** RFC2230 */
+ GLDNS_RR_TYPE_KX = 36,
+ /** RFC2538 */
+ GLDNS_RR_TYPE_CERT = 37,
+ /** RFC2874 */
+ GLDNS_RR_TYPE_A6 = 38,
+ /** RFC2672 */
+ GLDNS_RR_TYPE_DNAME = 39,
+ /** dnsind-kitchen-sink-02.txt */
+ GLDNS_RR_TYPE_SINK = 40,
+ /** Pseudo OPT record... */
+ GLDNS_RR_TYPE_OPT = 41,
+ /** RFC3123 */
+ GLDNS_RR_TYPE_APL = 42,
+ /** RFC4034, RFC3658 */
+ GLDNS_RR_TYPE_DS = 43,
+ /** SSH Key Fingerprint */
+ GLDNS_RR_TYPE_SSHFP = 44, /* RFC 4255 */
+ /** IPsec Key */
+ GLDNS_RR_TYPE_IPSECKEY = 45, /* RFC 4025 */
+ /** DNSSEC */
+ GLDNS_RR_TYPE_RRSIG = 46, /* RFC 4034 */
+ GLDNS_RR_TYPE_NSEC = 47, /* RFC 4034 */
+ GLDNS_RR_TYPE_DNSKEY = 48, /* RFC 4034 */
+
+ GLDNS_RR_TYPE_DHCID = 49, /* RFC 4701 */
+ /* NSEC3 */
+ GLDNS_RR_TYPE_NSEC3 = 50, /* RFC 5155 */
+ GLDNS_RR_TYPE_NSEC3PARAM = 51, /* RFC 5155 */
+ GLDNS_RR_TYPE_NSEC3PARAMS = 51,
+ GLDNS_RR_TYPE_TLSA = 52, /* RFC 6698 */
+ GLDNS_RR_TYPE_SMIMEA = 53, /* draft-ietf-dane-smime, TLSA-like but may
+ be extended */
+
+ GLDNS_RR_TYPE_HIP = 55, /* RFC 5205 */
+
+ /** draft-reid-dnsext-zs */
+ GLDNS_RR_TYPE_NINFO = 56,
+ /** draft-reid-dnsext-rkey */
+ GLDNS_RR_TYPE_RKEY = 57,
+ /** draft-ietf-dnsop-trust-history */
+ GLDNS_RR_TYPE_TALINK = 58,
+ GLDNS_RR_TYPE_CDS = 59, /** RFC 7344 */
+ GLDNS_RR_TYPE_CDNSKEY = 60, /** RFC 7344 */
+ GLDNS_RR_TYPE_OPENPGPKEY = 61, /* RFC 7929 */
+ GLDNS_RR_TYPE_CSYNC = 62, /* RFC 7477 */
+
+ GLDNS_RR_TYPE_SPF = 99, /* RFC 4408 */
+
+ GLDNS_RR_TYPE_UINFO = 100,
+ GLDNS_RR_TYPE_UID = 101,
+ GLDNS_RR_TYPE_GID = 102,
+ GLDNS_RR_TYPE_UNSPEC = 103,
+
+ GLDNS_RR_TYPE_NID = 104, /* RFC 6742 */
+ GLDNS_RR_TYPE_L32 = 105, /* RFC 6742 */
+ GLDNS_RR_TYPE_L64 = 106, /* RFC 6742 */
+ GLDNS_RR_TYPE_LP = 107, /* RFC 6742 */
+
+ /** draft-jabley-dnsext-eui48-eui64-rrtypes */
+ GLDNS_RR_TYPE_EUI48 = 108,
+ GLDNS_RR_TYPE_EUI64 = 109,
+
+ GLDNS_RR_TYPE_TKEY = 249, /* RFC 2930 */
+ GLDNS_RR_TYPE_TSIG = 250,
+ GLDNS_RR_TYPE_IXFR = 251,
+ GLDNS_RR_TYPE_AXFR = 252,
+ /** A request for mailbox-related records (MB, MG or MR) */
+ GLDNS_RR_TYPE_MAILB = 253,
+ /** A request for mail agent RRs (Obsolete - see MX) */
+ GLDNS_RR_TYPE_MAILA = 254,
+ /** any type (wildcard) */
+ GLDNS_RR_TYPE_ANY = 255,
+ GLDNS_RR_TYPE_URI = 256, /* RFC 7553 */
+ GLDNS_RR_TYPE_CAA = 257, /* RFC 6844 */
+#endif
+ default:
+ /*
+ * Unknown record type. Not expected in MDNS/DNS-SD. Just keep the current value.
+ * TODO: log some kind of error.
+ */
+ break;
+ }
+
+ return ret;
+}
+/*
+ * Comparison and other functions required for cache management
+ */
+
+ /**
+ * Calculates the size of an entry.
+ *
+ * size = mdns_cache_size (key, data).
+ */
+static size_t mdns_cache_entry_size(void* vkey, void* vdata)
+{
+ size_t sz = 0;
+
+ if (vkey != NULL)
+ {
+ sz += sizeof(getdns_mdns_cached_key_header) + ((getdns_mdns_cached_key_header*)vkey)->name_len;
+ }
+
+ if (vdata != NULL)
+ {
+ sz += ((getdns_mdns_cached_record_header*)vdata)->allocated_length;
+ }
+
+ return sz;
+}
+
+/** type of function that compares two keys. return 0 if equal. */
+static int mdns_cache_key_comp(void* vkey1, void* vkey2)
+{
+ getdns_mdns_cached_key_header *header1 = (getdns_mdns_cached_key_header*)vkey1;
+ getdns_mdns_cached_key_header *header2 = (getdns_mdns_cached_key_header*)vkey2;
+
+ return (header1->record_type == header2->record_type &&
+ header1->record_class == header2->record_class &&
+ header1->name_len == header2->name_len)
+ ? memcmp(((uint8_t*)vkey1) + sizeof(getdns_mdns_cached_key_header),
+ ((uint8_t*)vkey2) + sizeof(getdns_mdns_cached_key_header),
+ header1->name_len)
+ : -1;
+}
+
+/** old keys are deleted.
+* markdel() is used first.
+* This function is called: func(key, userarg)
+* the userarg is set to the context in which the LRU hash table was created.
+* TODO: is there a need to free the lock in the embedded hash entry structure?
+*/
+static void msdn_cache_delkey(void* vkey, void* vcontext)
+{
+ GETDNS_FREE(((struct getdns_context *) vcontext)->mf, vkey);
+}
+
+/** old data is deleted. This function is called: func(data, userarg).
+ * Since we use the hash table for both data and requests, need to
+ * terminate whatever request was ongoing. TODO: we should have some smarts
+ * in cache management and never drop cached entries with active requests.
+ */
+static void msdn_cache_deldata(void* vdata, void* vcontext)
+{
+ getdns_mdns_cached_record_header* header = ((getdns_mdns_cached_record_header*)vdata);
+
+ while (header->netreq_first)
+ {
+ /* Need to unchain the request from that entry */
+ getdns_network_req* netreq = header->netreq_first;
+ header->netreq_first = netreq->mdns_netreq_next;
+ netreq->mdns_netreq_next = NULL;
+
+ /* TODO: treating as a timeout for now, may consider treating as error */
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ _getdns_netreq_change_state(netreq, NET_REQ_TIMED_OUT);
+ if (netreq->owner->user_callback) {
+ (void)_getdns_context_request_timed_out(netreq->owner);
+ }
+ _getdns_check_dns_req_complete(netreq->owner);
+
+ }
+ GETDNS_FREE(((struct getdns_context *) vcontext)->mf, vdata);
+}
+
+/*
+ * Read the number of answers in a cached record
+ */
+static int
+mdns_cache_nb_records_in_entry(uint8_t * cached_data)
+{
+ int message_index = sizeof(getdns_mdns_cached_record_header);
+ int nb_answers = (cached_data[message_index + MDNS_PACKET_INDEX_ANSWER] << 8) |
+ cached_data[message_index + MDNS_PACKET_INDEX_ANSWER + 1];
+
+ return nb_answers;
+}
+
+/*
+ * Create a key in preallocated buffer
+ * the allocated size of key should be >= sizeof(getdns_mdns_cached_key_header) + name_len
+ */
+static void msdn_cache_create_key_in_buffer(
+ uint8_t* key,
+ uint8_t * name, int name_len,
+ int record_type, int record_class)
+{
+ getdns_mdns_cached_key_header * header = (getdns_mdns_cached_key_header*)key;
+
+ memset(key, 0, sizeof(getdns_mdns_cached_key_header));
+ header->record_type = record_type;
+ header->record_class = record_class;
+ header->name_len = name_len;
+ (void) memcpy(key + sizeof(getdns_mdns_cached_key_header), name, name_len);
+}
+
+static uint8_t * mdns_cache_create_key(
+ uint8_t * name, int name_len,
+ int record_type, int record_class,
+ struct getdns_context * context)
+{
+ uint8_t* key = GETDNS_XMALLOC(context->mf, uint8_t, sizeof(getdns_mdns_cached_key_header) + name_len);
+
+ if (key != NULL)
+ {
+ msdn_cache_create_key_in_buffer(key, name, name_len, record_type, record_class);
+ }
+
+ return key;
+}
+
+static uint8_t * mdns_cache_create_data(
+ uint8_t * name, int name_len,
+ int record_type, int record_class,
+ int record_data_len,
+ uint64_t current_time,
+ struct getdns_context * context)
+{
+ getdns_mdns_cached_record_header * header;
+ int current_index;
+ size_t data_size = sizeof(getdns_mdns_cached_record_header) + 12 + name_len + 4;
+ size_t alloc_size = mdns_util_suggest_size(data_size + record_data_len + 2 + 2 + 2 + 4 + 2);
+
+ uint8_t* data = GETDNS_XMALLOC(context->mf, uint8_t, alloc_size);
+
+ if (data != NULL)
+ {
+ header = (getdns_mdns_cached_record_header *)data;
+ header->insertion_microsec = current_time;
+ header->content_len = data_size;
+ header->allocated_length = alloc_size;
+ header->netreq_first = NULL;
+ current_index = sizeof(getdns_mdns_cached_record_header);
+ memset(data + current_index, 0, 12);
+ data[current_index + MDNS_PACKET_INDEX_QUERY + 1] = 1; /* 1 query present by default */
+ current_index += 12;
+ memcpy(data + current_index, name, name_len);
+ current_index += name_len;
+ data[current_index++] = (uint8_t)(record_type >> 8);
+ data[current_index++] = (uint8_t)(record_type);
+ data[current_index++] = (uint8_t)(record_class >> 8);
+ data[current_index++] = (uint8_t)(record_class);
+ }
+
+ return data;
+}
+
+
+/*
+ * Add a record.
+ */
+static int
+mdns_add_record_to_cache_entry(struct getdns_context *context,
+ uint8_t * old_record, uint8_t ** new_record,
+ int record_type, int record_class, int ttl,
+ uint8_t * record_data, int record_data_len)
+{
+ int ret = 0;
+ getdns_mdns_cached_record_header *header = (getdns_mdns_cached_record_header*)old_record;
+ /* Compute the record length */
+ uint32_t record_length = 2 + 2 + 2 + 4 + 2 + record_data_len;
+ uint32_t current_length = header->content_len;
+ /* update the number of records */
+ uint8_t *start_answer_code = old_record + sizeof(getdns_mdns_cached_record_header) + MDNS_PACKET_INDEX_ANSWER;
+ uint16_t nb_answers = (start_answer_code[0] << 8) + start_answer_code[1];
+ nb_answers++;
+ start_answer_code[0] = (uint8_t)(nb_answers >> 8);
+ start_answer_code[1] = (uint8_t)(nb_answers&0xFF);
+
+ /* Update the content length and reallocate memory if needed */
+ header->content_len += record_length;
+ if (header->content_len > header->allocated_length)
+ {
+ /* realloc to a new length, */
+ do {
+ header->allocated_length = mdns_util_suggest_size(header->content_len);
+ } while (header->content_len > header->allocated_length);
+
+ *new_record = GETDNS_XREALLOC(context->mf, old_record, uint8_t, header->allocated_length);
+ }
+ else
+ {
+ *new_record = old_record;
+ }
+
+ if (*new_record == NULL)
+ {
+ ret = GETDNS_RETURN_MEMORY_ERROR;
+ }
+ else
+ {
+ /* copy the record */
+ /* First, point name relative to beginning of DNS message */
+ (*new_record)[current_length++] = 0xC0;
+ (*new_record)[current_length++] = 12;
+ /* encode the components of the per record header */
+ (*new_record)[current_length++] = (uint8_t)((record_type >> 8) & 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((record_type)& 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((record_class >> 8) & 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((record_class)& 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((ttl >> 24) & 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((ttl >> 16) & 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((ttl >> 8) & 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((ttl)& 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((record_data_len >> 8) & 0xFF);
+ (*new_record)[current_length++] = (uint8_t)((record_data_len) & 0xFF);
+ memcpy(*new_record + current_length, record_data, record_data_len);
+
+ }
+
+ return ret;
+}
+
+static int
+mdns_update_cache_ttl_and_prune(struct getdns_context *context,
+ uint8_t * old_record, uint8_t ** new_record,
+ int record_type, int record_class, int ttl,
+ uint8_t * record_data, int record_data_len,
+ uint64_t current_time)
+{
+ /*
+ * Compute the TTL delta
+ */
+ int ret = 0;
+ getdns_mdns_cached_record_header *header = (getdns_mdns_cached_record_header*)old_record;
+ uint32_t delta_t_sec = (uint32_t)((current_time - header->insertion_microsec) / 1000000ll);
+ header->insertion_microsec += delta_t_sec * 1000000;
+ int message_index;
+ int answer_index;
+ int nb_answers;
+ int nb_answers_left;
+ int current_record_length;
+ int current_record_data_len;
+ uint32_t current_record_ttl;
+ int not_matched_yet = (record_data == NULL) ? 0 : 1;
+ int last_copied_index;
+ int current_hole_index = 0;
+ int record_name_length = 0;
+ int record_ttl_index = 0;
+
+ /*
+ * Skip the query
+ */
+ message_index = sizeof(getdns_mdns_cached_record_header);
+ nb_answers = (old_record[message_index + MDNS_PACKET_INDEX_ANSWER] << 8) |
+ old_record[message_index + MDNS_PACKET_INDEX_ANSWER + 1];
+ nb_answers_left = nb_answers;
+ answer_index = message_index + 12 + mdns_util_skip_query(old_record + message_index + 12);
+ last_copied_index = answer_index;
+
+ /*
+ * Examine each record
+ */
+ for (int i = 0; i < nb_answers; i++)
+ {
+ record_name_length = mdns_util_skip_name(old_record + answer_index);
+ record_ttl_index = answer_index + record_name_length + 2 + 2;
+
+ current_record_ttl = (old_record[record_ttl_index] << 24)
+ | (old_record[record_ttl_index + 1] << 16)
+ | (old_record[record_ttl_index + 2] << 8)
+ | (old_record[record_ttl_index + 3]);
+
+ current_record_data_len = (old_record[record_ttl_index + 4] << 8)
+ | (old_record[record_ttl_index + 5]);
+
+ current_record_length = record_name_length + 2 + 2 + 4 + 2 + current_record_data_len;
+
+ if (not_matched_yet &&
+ current_record_data_len == record_data_len &&
+ memcmp(old_record + record_ttl_index + 4 + 2, record_data, record_data_len) == 0)
+ {
+ not_matched_yet = 0;
+ current_record_ttl = ttl;
+ }
+ else
+ {
+ /* Not a match */
+ if (current_record_ttl > delta_t_sec)
+ {
+ current_record_ttl -= delta_t_sec;
+ }
+ else
+ {
+ current_record_ttl = 0;
+ }
+ }
+
+ if (current_record_ttl == 0)
+ {
+ nb_answers_left--;
+
+ /* this record should be compacted away */
+ if (current_hole_index == 0)
+ {
+ /* encountering the first hole in the message,
+ * no need to copy anything yet.
+ */
+ last_copied_index = answer_index;
+ }
+ else if (current_hole_index != answer_index)
+ {
+ /* copy the data from hole to answer */
+ memmove(old_record + last_copied_index, old_record + current_hole_index,
+ answer_index - current_hole_index);
+ last_copied_index += answer_index - current_hole_index;
+ }
+
+ /* extend the current hole */
+ current_hole_index = answer_index + current_record_length;
+ }
+ else
+ {
+ /* keeping this record, but updating the TTL */
+ old_record[record_ttl_index] = (uint8_t)(current_record_ttl >> 24);
+ old_record[record_ttl_index + 1] = (uint8_t)(current_record_ttl >> 16);
+ old_record[record_ttl_index + 2] = (uint8_t)(current_record_ttl >> 8);
+ old_record[record_ttl_index + 3] = (uint8_t)(current_record_ttl);
+ }
+ /* progress to the next record */
+ answer_index += current_record_length;
+ }
+
+ /* if necessary, copy the pending data */
+ if (current_hole_index != answer_index && current_hole_index != 0)
+ {
+ /* copy the data from hole to last answer */
+ memmove(old_record + last_copied_index, old_record + current_hole_index,
+ answer_index - current_hole_index);
+ last_copied_index += answer_index - current_hole_index;
+
+ /* dead assignment */
+ /* answer_index = last_copied_index; */
+ }
+
+ /* if some records were deleted, update the record headers */
+ if (nb_answers != nb_answers_left)
+ {
+ header->content_len = last_copied_index;
+ old_record[message_index + MDNS_PACKET_INDEX_ANSWER] = (uint8_t)(nb_answers_left >> 8);
+ old_record[message_index + MDNS_PACKET_INDEX_ANSWER + 1] = (uint8_t)(nb_answers_left);
+ }
+
+ /*
+ * if the update was never seen, ask for an addition
+ */
+ if (ttl > 0 && not_matched_yet)
+ {
+ mdns_add_record_to_cache_entry(context, old_record, new_record,
+ record_type, record_class, ttl, record_data, record_data_len);
+ nb_answers_left++;
+ }
+ else
+ {
+ *new_record = old_record;
+ }
+
+ return ret;
+}
+
+/*
+ * Get a cached entry by name and record type .
+ */
+static struct lruhash_entry *
+mdns_access_cached_entry_by_name(
+struct getdns_context *context,
+ uint8_t * name, int name_len,
+ int record_type, int record_class)
+{
+ uint8_t temp_key[256 + sizeof(getdns_mdns_cached_key_header)];
+ hashvalue_type hash;
+ struct lruhash_entry *entry;
+
+ msdn_cache_create_key_in_buffer(temp_key, name, name_len, record_type, record_class);
+
+ /* TODO: make hash init value a random number in the context, for defense against DOS */
+ hash = hashlittle(temp_key, name_len + sizeof(getdns_mdns_cached_key_header), 0xCAC8E);
+
+ entry = lruhash_lookup(context->mdns_cache, hash, temp_key, 1);
+
+ return entry;
+}
+
+
+/*
+* Add entry function for the MDNS record cache.
+*/
+static int
+mdns_propose_entry_to_cache(
+ struct getdns_context *context,
+ uint8_t * name, int name_len,
+ int record_type, int record_class, int ttl,
+ uint8_t * record_data, int record_data_len,
+ getdns_network_req * netreq,
+ uint64_t current_time)
+{
+ int ret = 0;
+ uint8_t temp_key[256 + sizeof(getdns_mdns_cached_key_header)];
+ hashvalue_type hash;
+ struct lruhash_entry *entry, *new_entry;
+ uint8_t *key, *data;
+ getdns_mdns_cached_record_header * header;
+
+ msdn_cache_create_key_in_buffer(temp_key, name, name_len, record_type, record_class);
+
+
+ /* TODO: make hash init value a random number in the context, for defense against DOS */
+ hash = hashlittle(temp_key, name_len + sizeof(getdns_mdns_cached_key_header), 0xCAC8E);
+
+ entry = lruhash_lookup(context->mdns_cache, hash, temp_key, 1);
+
+ if (entry == NULL && ttl != 0)
+ {
+ /*
+ * Create an empty entry.
+ */
+ key = mdns_cache_create_key(name, name_len, record_type, record_class, context);
+ data = mdns_cache_create_data(name, name_len, record_type, record_class,
+ record_data_len, current_time, context);
+
+ if (key == NULL || data == NULL)
+ {
+ if (key != NULL)
+ {
+ GETDNS_FREE(context->mf, key);
+ key = NULL;
+ }
+
+ if (data != NULL)
+ {
+ GETDNS_FREE(context->mf, data);
+ data = NULL;
+ }
+ }
+ else
+ {
+ new_entry = &((getdns_mdns_cached_key_header*)key)->entry;
+
+ memset(new_entry, 0, sizeof(struct lruhash_entry));
+ lock_rw_init(&new_entry->lock);
+ new_entry->hash = hash;
+ new_entry->key = key;
+ new_entry->data = data;
+
+ entry = lruhash_insert_or_retrieve(context->mdns_cache, hash, new_entry, data, NULL);
+
+ if (entry != new_entry)
+ {
+ /* There was already an entry for this name, which is really weird.
+ * But it can in theory happen in a race condition.
+ */
+ GETDNS_FREE(context->mf, key);
+ key = NULL;
+ GETDNS_FREE(context->mf, data);
+ data = NULL;
+ }
+ }
+ }
+
+ if (entry != NULL)
+ {
+ if (record_data != NULL && record_data_len > 0)
+ ret = mdns_update_cache_ttl_and_prune(context,
+ (uint8_t*)entry->data, &data,
+ record_type, record_class, ttl, record_data, record_data_len,
+ current_time);
+
+ if (netreq != NULL)
+ {
+ /* chain the continuous request to the cache line */
+ header = (getdns_mdns_cached_record_header *) entry->data;
+ netreq->mdns_netreq_next = header->netreq_first;
+ header->netreq_first = netreq;
+ }
+ else
+ {
+ header = (getdns_mdns_cached_record_header *)entry->data;
+
+ /* if the entry is empty, move it to the bottom of the LRU */
+ if (mdns_cache_nb_records_in_entry((uint8_t*)(entry->data)) == 0 &&
+ header->netreq_first == NULL)
+ {
+ lru_demote(context->mdns_cache, entry);
+ }
+ }
+
+ /* then, unlock the entry */
+ lock_rw_unlock(&entry->lock);
+ }
+
+ return ret;
+}
+
+
+/*
+ * Serve a request from the cached value
+ */
+static int
+mdns_complete_query_from_cache_entry(
+ getdns_network_req *netreq,
+ struct lruhash_entry *entry)
+{
+ int ret = 0;
+ uint8_t *packet = ((uint8_t *)entry->data) + sizeof(getdns_mdns_cached_record_header);
+ getdns_mdns_cached_record_header * header = (getdns_mdns_cached_record_header*)entry->data;
+ size_t packet_length = header->content_len - sizeof(getdns_mdns_cached_record_header);
+ getdns_network_req **prev_netreq;
+ int found = 0;
+ int nb_answers = mdns_cache_nb_records_in_entry((uint8_t *)entry->data);
+
+ /* Clear the event associated to the query */
+ GETDNS_CLEAR_EVENT(netreq->owner->loop, &netreq->event);
+
+ /* remove the completed query from the waiting list */
+ prev_netreq = &header->netreq_first;
+ while (*prev_netreq != NULL)
+ {
+ if (*prev_netreq == netreq)
+ {
+ *prev_netreq = netreq->mdns_netreq_next;
+ netreq->mdns_netreq_next = NULL;
+ found = 1;
+ break;
+ }
+ else
+ {
+ prev_netreq = &((*prev_netreq)->mdns_netreq_next);
+ }
+ }
+
+ if (found)
+ {
+ if (nb_answers == 0)
+ {
+ }
+ else
+ {
+ /* copy the returned value in the response field */
+ if (packet_length > netreq->wire_data_sz)
+ {
+ netreq->response = GETDNS_XREALLOC(
+ netreq->owner->context->mf, netreq->response, uint8_t, packet_length);
+ }
+
+ if (netreq->response != NULL)
+ {
+ memcpy(netreq->response, packet, packet_length);
+
+ netreq->response[MDNS_PACKET_INDEX_QCODE] = 0x84;
+
+ netreq->response_len = packet_length;
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ _getdns_netreq_change_state(netreq, NET_REQ_FINISHED);
+ _getdns_check_dns_req_complete(netreq->owner);
+ }
+ else
+ {
+ /* Fail the query? */
+ netreq->response_len = 0;
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
+ _getdns_check_dns_req_complete(netreq->owner);
+ }
+ }
+ }
+ else
+ {
+ /* Failure */
+ netreq->response_len = 0;
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
+ _getdns_check_dns_req_complete(netreq->owner);
+ }
+
+ return ret;
+}
+
+/*
+ * Processing of requests after cache update.
+ * This is coded as synchronous processing, under lock. This is probably wrong.
+ * It would be better to just collate the responses for now, and
+ * process the queries out of the loop.
+ */
+static int
+mdns_cache_complete_queries(
+ struct getdns_context *context,
+ uint8_t * name, int name_len,
+ int record_type, int record_class)
+{
+ int ret = 0;
+ struct lruhash_entry *entry;
+ getdns_mdns_cached_record_header * header;
+ getdns_network_req * netreq;
+
+ entry = mdns_access_cached_entry_by_name(context, name, name_len, record_type, record_class);
+
+ if (entry != NULL)
+ {
+ if (entry->data != NULL)
+ {
+ header = (getdns_mdns_cached_record_header *)entry->data;
+
+ while ((netreq = header->netreq_first) != NULL)
+ {
+ mdns_complete_query_from_cache_entry(netreq, entry);
+ }
+ }
+ lock_rw_unlock(&entry->lock);
+ }
+
+ return ret;
+}
+
+/*
+* Timeout of multicast MDNS query
+*/
+static void
+mdns_mcast_timeout_cb(void *userarg)
+{
+ getdns_network_req *netreq = (getdns_network_req *)userarg;
+ getdns_dns_req *dnsreq = netreq->owner;
+ getdns_context *context = dnsreq->context;
+
+ uint8_t temp_key[256 + sizeof(getdns_mdns_cached_key_header)];
+ hashvalue_type hash;
+ struct lruhash_entry *entry;
+ int found = 0;
+
+ DEBUG_MDNS("%s %-35s: MSG: %p\n",
+ MDNS_DEBUG_CLEANUP, __FUNC__, netreq);
+
+ msdn_cache_create_key_in_buffer(temp_key, dnsreq->name, dnsreq->name_len,
+ netreq->request_type, dnsreq->request_class);
+
+
+ /* TODO: make hash init value a random number in the context, for defense against DOS */
+ hash = hashlittle(temp_key, dnsreq->name_len + sizeof(getdns_mdns_cached_key_header), 0xCAC8E);
+
+ /* Open the corresponding cache entry */
+ entry = lruhash_lookup(context->mdns_cache, hash, temp_key, 1);
+
+ if (entry != NULL)
+ {
+ if (entry->data != NULL)
+ {
+ /* Remove entry from chain and serve the query */
+ found = 1;
+ mdns_complete_query_from_cache_entry(netreq, entry);
+ }
+ lock_rw_unlock(&entry->lock);
+ }
+
+ if (!found)
+ {
+ /* Fail the request on timeout */
+ netreq->response_len = 0;
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
+ _getdns_check_dns_req_complete(netreq->owner);
+ }
+}
+
+/*
+ * Multicast receive event callback
+ */
+static void
+mdns_udp_multicast_read_cb(void *userarg)
+{
+ mdns_network_connection * cnx = (mdns_network_connection *)userarg;
+ uint64_t current_time;
+ ssize_t read;
+ DEBUG_MDNS("%s %-35s: CTX: %p, NET=%d \n", MDNS_DEBUG_MREAD,
+ __FUNC__, cnx->context, cnx->addr_mcast.ss_family);
+
+ current_time = _getdns_get_time_as_uintt64();
+
+ GETDNS_CLEAR_EVENT(
+ cnx->context->extension, &cnx->event);
+
+ read = recvfrom(cnx->fd, (void *)cnx->response,
+ sizeof(cnx->response), 0, NULL, NULL);
+
+
+ if (read == -1 && _getdns_EWOULDBLOCK)
+ return; /* TODO: this will stop the receive loop! */
+
+ if (read >= GLDNS_HEADER_SIZE)
+ {
+ /* parse the response, find the relevant queries, submit the records to the cache */
+ int opcodeAndflags = cnx->response[2];
+ int nb_queries = (cnx->response[4] << 8) | cnx->response[5];
+ int nb_responses = (cnx->response[6] << 8) | cnx->response[7];
+
+ if (opcodeAndflags != 0x84)
+ {
+ /* this is not an MDNS answer packet. */
+ }
+ else
+ {
+ ssize_t current_index = 12;
+ uint8_t name[256];
+ int name_len;
+ int record_type;
+ int record_class;
+ int record_ttl;
+ int record_data_len;
+ int nb_records = 0;
+ int nb_queries_skipped = 0;
+ int start_of_records;
+ int signalled_records = 0;
+
+ /*
+ * In normal mDNS operation, there should not be any query here.
+ * But just in case, we can skip the queries...
+ */
+ while (current_index < read && nb_queries_skipped < nb_queries)
+ {
+ current_index += mdns_util_skip_query(&cnx->response[current_index]);
+ nb_queries_skipped++;
+ }
+ start_of_records = current_index;
+ /*
+ * Parse the answers and propose them to the cache
+ */
+
+ while (current_index < read && nb_records < nb_responses)
+ {
+ /* Copy and skip the name */
+ current_index = mdns_util_copy_name(cnx->response, read, current_index,
+ name, sizeof(name), 0, &name_len);
+ if (current_index + 12 >= read)
+ {
+ /* bogus packet.. Should log. */
+ current_index = read;
+ }
+ else
+ {
+ /* Parse the record header */
+ record_type = (cnx->response[current_index++] << 8);
+ record_type |= (cnx->response[current_index++]);
+ /* TODO: handle the cache flush bit! */
+ record_class = (cnx->response[current_index++] << 8)&0x7F;
+ record_class |= (cnx->response[current_index++]);
+ record_ttl = (cnx->response[current_index++] << 24);
+ record_ttl |= (cnx->response[current_index++] << 16);
+ record_ttl |= (cnx->response[current_index++] << 8);
+ record_ttl |= (cnx->response[current_index++]);
+ record_data_len = (cnx->response[current_index++] << 8);
+ record_data_len |= (cnx->response[current_index++]);
+
+ if (current_index + record_data_len <= read)
+ {
+ /*
+ * Set the record to canonical form. This is required, since
+ * MDNS software commonly uses name compression for PTR or SRV records.
+ */
+ int actual_length;
+ uint8_t *actual_record;
+ uint8_t buffer[1024];
+
+ /* TODO: do something in case of canonization failures */
+ (void) mdns_util_canonical_record(cnx->response, read,
+ record_type, record_class, record_data_len, current_index,
+ buffer, sizeof(buffer), &actual_record, &actual_length);
+
+
+ /* Submit to the cache. As a side effect, may signal that a continuous request is done. */
+ (void) mdns_propose_entry_to_cache(cnx->context, name, name_len,
+ record_type, record_class, record_ttl,
+ actual_record, actual_length, NULL,
+ current_time);
+
+ current_index += record_data_len;
+ nb_records++;
+ }
+ else
+ {
+ /* bogus packet.. Should log. */
+ current_index = read;
+ }
+ }
+ }
+
+ /* Go over the queries that were mentioned in the update, and prepare returns. */
+ current_index = start_of_records;
+ while (current_index < read && signalled_records < nb_responses)
+ {
+ /* copy the name */
+ current_index = mdns_util_copy_name(cnx->response, read, current_index,
+ name, sizeof(name), 0, &name_len);
+ if (current_index + 12 >= read)
+ {
+ /* bogus packet.. Should log. */
+ current_index = read;
+ }
+ else
+ {
+ /* Parse the record header */
+ record_type = (cnx->response[current_index++] << 8);
+ record_type |= (cnx->response[current_index++]);
+ record_class = (cnx->response[current_index++] << 8);
+ record_class |= (cnx->response[current_index++]);
+ current_index += 4;
+ record_data_len = (cnx->response[current_index++] << 8);
+ record_data_len |= (cnx->response[current_index++]);
+ current_index += record_data_len;
+
+ /* process the pending requests */
+ (void)mdns_cache_complete_queries(cnx->context, name, name_len, record_type, record_class);
+ }
+ }
+ }
+ }
+ else
+ {
+ /* bogus packet.. Should log. */
+ }
+
+ /*
+ * Relaunch the event, so we can go read the next packet.
+ */
+ GETDNS_SCHEDULE_EVENT(
+ cnx->context->extension, cnx->fd, 0,
+ getdns_eventloop_event_init(&cnx->event, cnx,
+ mdns_udp_multicast_read_cb, NULL, NULL));
+}
+
+/*
+ * Create the two required multicast sockets
+ */
+static int mdns_open_ipv4_multicast(SOCKADDR_STORAGE* mcast_dest, int* mcast_dest_len)
+{
+ getdns_return_t ret = 0;
+ SOCKET fd4 = -1;
+ SOCKADDR_IN ipv4_dest;
+ SOCKADDR_IN ipv4_port;
+ BOOL so_reuse_bool = TRUE;
+ int so_reuse_bool_OptLen = sizeof(BOOL);
+ uint8_t ttl = 255;
+ IP_MREQ mreq4;
+
+ memset(mcast_dest, 0, sizeof(SOCKADDR_STORAGE));
+ *mcast_dest_len = 0;
+ memset(&ipv4_dest, 0, sizeof(ipv4_dest));
+ memset(&ipv4_port, 0, sizeof(ipv4_dest));
+ ipv4_dest.sin_family = AF_INET;
+ ipv4_dest.sin_port = htons(MDNS_MCAST_PORT);
+ ipv4_dest.sin_addr.s_addr = htonl(MDNS_MCAST_IPV4_LONG);
+ ipv4_port.sin_family = AF_INET;
+ ipv4_port.sin_port = htons(MDNS_MCAST_PORT);
+ /* memcpy(&ipv4_dest.sin_addr, mdns_mcast_ipv4, sizeof(mdns_mcast_ipv4)); */
+
+
+
+ fd4 = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+
+ if (fd4 != -1)
+ {
+ /*
+ * No need to test the output of the so_reuse call,
+ * since the only result that matters is that of bind.
+ */
+ (void)setsockopt(fd4, SOL_SOCKET, SO_REUSEADDR
+ , (const char*)&so_reuse_bool, so_reuse_bool_OptLen);
+
+ if (bind(fd4, (SOCKADDR*)&ipv4_port, sizeof(ipv4_port)) != 0)
+ {
+ ret = -1;
+ }
+ else
+ {
+ mreq4.imr_multiaddr = ipv4_dest.sin_addr;
+ mreq4.imr_interface = ipv4_port.sin_addr;
+
+ if (setsockopt(fd4, IPPROTO_IP, IP_ADD_MEMBERSHIP
+ , (const char*)&mreq4, (int) sizeof(mreq4)) != 0)
+ {
+ ret = -1;
+ }
+ else if (setsockopt(fd4, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) != 0)
+ {
+ ret = -1;
+ }
+ }
+ }
+
+ if (ret != 0 && fd4 != -1)
+ {
+#ifdef USE_WINSOCK
+ closesocket(fd4);
+#else
+ close(fd4);
+#endif
+ fd4 = -1;
+ }
+
+ if (ret == 0)
+ {
+ memcpy(mcast_dest, &ipv4_dest, sizeof(ipv4_dest));
+ *mcast_dest_len = sizeof(ipv4_dest);
+ }
+
+ return fd4;
+}
+
+static int mdns_open_ipv6_multicast(SOCKADDR_STORAGE* mcast_dest, int* mcast_dest_len)
+{
+ getdns_return_t ret = 0;
+ SOCKET fd6 = -1;
+ SOCKADDR_IN6 ipv6_dest;
+ SOCKADDR_IN6 ipv6_port;
+ uint8_t so_reuse_bool = 1;
+ uint8_t ttl = 255;
+ IPV6_MREQ mreq6;
+
+ memset(mcast_dest, 0, sizeof(SOCKADDR_STORAGE));
+ *mcast_dest_len = 0;
+ memset(&ipv6_dest, 0, sizeof(ipv6_dest));
+ memset(&ipv6_port, 0, sizeof(ipv6_dest));
+ ipv6_dest.sin6_family = AF_INET6;
+ ipv6_dest.sin6_port = htons(MDNS_MCAST_PORT);
+ ipv6_port.sin6_family = AF_INET6;
+ ipv6_port.sin6_port = htons(MDNS_MCAST_PORT);
+ memcpy(&ipv6_dest.sin6_addr
+ , mdns_mcast_ipv6, sizeof(mdns_mcast_ipv6));
+
+
+ fd6 = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+
+ if (fd6 != -1)
+ {
+ /*
+ * No need to test the output of the so_reuse call,
+ * since the only result that matters is that of bind.
+ */
+ (void)setsockopt(fd6, SOL_SOCKET, SO_REUSEADDR
+ , (const char*)&so_reuse_bool, (int) sizeof(BOOL));
+
+ if (bind(fd6, (SOCKADDR*)&ipv6_port, sizeof(ipv6_port)) != 0)
+ {
+ ret = -1;
+ }
+ else
+ {
+ memcpy(&mreq6.ipv6mr_multiaddr
+ , &ipv6_dest.sin6_addr, sizeof(mreq6.ipv6mr_multiaddr));
+ memcpy(&mreq6.ipv6mr_interface
+ , &ipv6_port.sin6_addr, sizeof(mreq6.ipv6mr_interface));
+
+ if (setsockopt(fd6, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP
+ , (const char*)&mreq6, (int) sizeof(mreq6)) != 0)
+ {
+ ret = -1;
+ }
+ else if (setsockopt(fd6, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &ttl, sizeof(ttl)) != 0)
+ {
+ ret = -1;
+ }
+ }
+ }
+
+ if (ret != 0 && fd6 != -1)
+ {
+#ifdef USE_WINSOCK
+ closesocket(fd6);
+#else
+ close(fd6);
+#endif
+ fd6 = -1;
+ }
+
+ if (ret == 0)
+ {
+ memcpy(mcast_dest, &ipv6_dest, sizeof(ipv6_dest));
+ *mcast_dest_len = sizeof(ipv6_dest);
+ }
+ return fd6;
+}
+
+/*
+ * Delayed opening of the MDNS sockets, and launch of the MDNS listeners
+ */
+static getdns_return_t mdns_delayed_network_init(struct getdns_context *context)
+{
+ getdns_return_t ret = 0;
+
+ if (context->mdns_extended_support == 2)
+ {
+ context->mdns_cache = lruhash_create(128, 10000000,
+ mdns_cache_entry_size, mdns_cache_key_comp,
+ msdn_cache_delkey, msdn_cache_deldata,
+ context);
+
+ if (context->mdns_cache == NULL)
+ {
+ ret = GETDNS_RETURN_MEMORY_ERROR;
+ }
+ else
+ {
+ context->mdns_connection = (mdns_network_connection *)
+ GETDNS_XMALLOC(context->my_mf, mdns_network_connection, 2);
+
+ if (context->mdns_connection == NULL)
+ {
+ ret = GETDNS_RETURN_MEMORY_ERROR;
+ }
+ else
+ {
+ context->mdns_connection_nb = 2;
+
+ context->mdns_connection[0].fd = mdns_open_ipv4_multicast(
+ &context->mdns_connection[0].addr_mcast
+ , &context->mdns_connection[0].addr_mcast_len);
+ context->mdns_connection[0].context = context;
+ context->mdns_connection[1].fd = mdns_open_ipv6_multicast(
+ &context->mdns_connection[1].addr_mcast
+ , &context->mdns_connection[1].addr_mcast_len);
+ context->mdns_connection[1].context = context;
+
+ if (context->mdns_connection[0].fd == -1 ||
+ context->mdns_connection[1].fd == -1)
+ {
+ ret = GETDNS_RETURN_GENERIC_ERROR;
+ }
+ else
+ {
+ /* TODO: launch the receive loops */
+ for (int i = 0; i < 2; i++)
+ {
+ GETDNS_CLEAR_EVENT(context->extension, &context->mdns_connection[i].event);
+ GETDNS_SCHEDULE_EVENT(
+ context->extension, context->mdns_connection[i].fd, 0,
+ getdns_eventloop_event_init(&context->mdns_connection[i].event,
+ &context->mdns_connection[i],
+ mdns_udp_multicast_read_cb, NULL, NULL));
+ }
+ }
+
+ if (ret != 0)
+ {
+ for (int i = 0; i < 2; i++)
+ {
+ if (context->mdns_connection[i].fd != -1)
+ {
+
+ GETDNS_CLEAR_EVENT(context->extension
+ , &context->mdns_connection[i].event);
+#ifdef USE_WINSOCK
+ closesocket(context->mdns_connection[i].fd);
+#else
+ close(context->mdns_connection[i].fd);
+#endif
+ }
+ }
+
+ GETDNS_FREE(context->my_mf, context->mdns_connection);
+ context->mdns_connection = NULL;
+ context->mdns_connection_nb = 0;
+ }
+ } /* mdns-connection != NULL */
+
+ if (ret != 0)
+ {
+ /* delete the cache that was just created, since the network connection failed */
+ lruhash_delete(context->mdns_cache);
+ context->mdns_cache = NULL;
+ }
+ } /* cache != NULL */
+
+ context->mdns_extended_support = (ret == 0) ? 1 : 0;
+ }
+
+ return ret;
+}
+
+/*
+ * Initialize a continuous query from netreq
+ */
+static getdns_return_t mdns_initialize_continuous_request(getdns_network_req *netreq)
+{
+ getdns_return_t ret = 0;
+ getdns_dns_req *dnsreq = netreq->owner;
+ struct getdns_context *context = dnsreq->context;
+
+ uint8_t temp_key[256 + sizeof(getdns_mdns_cached_key_header)];
+ hashvalue_type hash;
+ struct lruhash_entry *entry;
+ size_t pkt_len = netreq->response - netreq->query;
+
+ msdn_cache_create_key_in_buffer(temp_key, dnsreq->name, dnsreq->name_len,
+ netreq->request_type, dnsreq->request_class);
+
+ /* TODO: make hash init value a random number in the context, for defense against DOS */
+ hash = hashlittle(temp_key, dnsreq->name_len + sizeof(getdns_mdns_cached_key_header), 0xCAC8E);
+
+ entry = lruhash_lookup(context->mdns_cache, hash, temp_key, 1);
+
+ if (entry == NULL)
+ {
+ /*
+ * First, create an entry for the query
+ */
+
+ ret = mdns_propose_entry_to_cache(context, dnsreq->name, dnsreq->name_len,
+ netreq->request_type, dnsreq->request_class, 1, NULL, 0,
+ netreq, _getdns_get_time_as_uintt64());
+ }
+ else
+ {
+ /*
+ * Check whether the cache entry is recent.
+ * If yes, just return it, but first update the entry tracking in the cache entry.
+ */
+
+ /*
+ * and unlock the entry!
+ */
+ }
+
+ if (ret == 0)
+ {
+ /* If the query is not actually complete, are a per query timer. */
+ if (netreq->state < NET_REQ_FINISHED)
+ {
+ GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
+ GETDNS_SCHEDULE_EVENT(
+ dnsreq->loop, -1, _getdns_ms_until_expiry(dnsreq->expires),
+ getdns_eventloop_event_init(&netreq->event, netreq,
+ NULL, NULL, mdns_mcast_timeout_cb));
+ }
+ /* If the entry was created less than 1 sec ago, send a query */
+
+ if (context->mdns_connection_nb <= 0)
+ {
+ /* oops, no network! */
+ ret = GETDNS_RETURN_GENERIC_ERROR;
+ }
+ else
+ {
+ /* TODO? Set TTL=255 for compliance with RFC 6762 */
+ int fd_index = context->mdns_connection_nb - 1;
+ int sent = sendto(
+ context->mdns_connection[fd_index].fd
+ , (const void *)netreq->query, pkt_len, 0
+ , (SOCKADDR*)&context->mdns_connection[fd_index].addr_mcast
+ , context->mdns_connection[fd_index].addr_mcast_len);
+
+ if (sent < 0 || pkt_len != (size_t)sent)
+ {
+ ret = GETDNS_RETURN_GENERIC_ERROR;
+ }
+
+ /* TODO: update the send query time */
+ }
+ }
+
+ return ret;
+}
+
+/*
+ * Initialize the MDNS part of the context structure.
+ */
+void _getdns_mdns_context_init(struct getdns_context *context)
+{
+ context->mdns_extended_support = 2; /* 0 = no support, 1 = supported, 2 = initialization needed */
+ context->mdns_connection = NULL;
+ context->mdns_connection_nb = 0;
+ context->mdns_cache = NULL;
+}
+
+/*
+ * Delete all the data allocated for MDNS in a context
+ */
+void _getdns_mdns_context_destroy(struct getdns_context *context)
+{
+ /* Clear all the cached records. This will terminate all pending network requests */
+ if (context->mdns_cache != NULL)
+ {
+ lruhash_delete(context->mdns_cache);
+ context->mdns_cache = NULL;
+ }
+ /* Close the connections */
+ if (context->mdns_connection != NULL)
+ {
+ for (int i = 0; i < context->mdns_connection_nb; i++)
+ {
+ /* suppress the receive event */
+ GETDNS_CLEAR_EVENT(context->extension, &context->mdns_connection[i].event);
+ /* close the socket */
+#ifdef USE_WINSOCK
+ closesocket(context->mdns_connection[i].fd);
+#else
+ close(context->mdns_connection[i].fd);
+#endif
+ }
+
+ GETDNS_FREE(context->mf, context->mdns_connection);
+ context->mdns_connection = NULL;
+ context->mdns_connection_nb = 0;
+ }
+}
+
+/* TODO: actualy delete what is required.. */
+static void
+mdns_cleanup(getdns_network_req *netreq)
+{
+ DEBUG_MDNS("%s %-35s: MSG: %p\n",
+ MDNS_DEBUG_CLEANUP, __FUNC__, netreq);
+ getdns_dns_req *dnsreq = netreq->owner;
+
+ GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
+}
+
+void
+_getdns_cancel_mdns_request(getdns_network_req *netreq)
+{
+ mdns_cleanup(netreq);
+ if (netreq->fd >= 0) {
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
+ close(netreq->fd);
+#endif
+ }
+}
+
+static void
+mdns_timeout_cb(void *userarg)
+{
+ getdns_network_req *netreq = (getdns_network_req *)userarg;
+ DEBUG_MDNS("%s %-35s: MSG: %p\n",
+ MDNS_DEBUG_CLEANUP, __FUNC__, netreq);
+
+ /* TODO: do we need a retry logic here? */
+
+ /* Check the required cleanup */
+ mdns_cleanup(netreq);
+ if (netreq->fd >= 0)
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
+ close(netreq->fd);
+#endif
+ _getdns_netreq_change_state(netreq, NET_REQ_TIMED_OUT);
+ if (netreq->owner->user_callback) {
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ (void)_getdns_context_request_timed_out(netreq->owner);
+ }
+ else
+ _getdns_check_dns_req_complete(netreq->owner);
+}
+
+
+
+/*****************************************/
+/* UDP callback functions for basic MDNS */
+/*****************************************/
+
+static void
+mdns_udp_read_cb(void *userarg)
+{
+ getdns_network_req *netreq = (getdns_network_req *)userarg;
+ getdns_dns_req *dnsreq = netreq->owner;
+ ssize_t read;
+ DEBUG_MDNS("%s %-35s: MSG: %p \n", MDNS_DEBUG_READ,
+ __FUNC__, netreq);
+
+ GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
+
+ read = recvfrom(netreq->fd, (void *)netreq->response,
+ netreq->max_udp_payload_size + 1, /* If read == max_udp_payload_size
+ * then all is good. If read ==
+ * max_udp_payload_size + 1, then
+ * we receive more then requested!
+ * i.e. overflow
+ */
+ 0, NULL, NULL);
+ if (read == -1 && _getdns_EWOULDBLOCK)
+ return;
+
+ if (read < GLDNS_HEADER_SIZE)
+ return; /* Not DNS */
+
+ if (GLDNS_ID_WIRE(netreq->response) != GLDNS_ID_WIRE(netreq->query))
+ return; /* Cache poisoning attempt ;) */
+
+ // TODO: check whether EDNS server cookies are required for MDNS
+
+ // TODO: check that the source address originates from the local network.
+ // TODO: check TTL = 255
+
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
+ close(netreq->fd);
+#endif
+ /*
+ * TODO: how to handle an MDNS response with TC bit set?
+ * Ignore it for now, as we do not support any kind of TCP fallback
+ * for basic MDNS.
+ */
+
+ netreq->response_len = read;
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ _getdns_netreq_change_state(netreq, NET_REQ_FINISHED);
+ _getdns_check_dns_req_complete(dnsreq);
+}
+
+static void
+mdns_udp_write_cb(void *userarg)
+{
+ getdns_network_req *netreq = (getdns_network_req *)userarg;
+ getdns_dns_req *dnsreq = netreq->owner;
+ size_t pkt_len = netreq->response - netreq->query;
+ struct sockaddr_in mdns_mcast_v4;
+ int ttl = 255;
+ int r;
+
+ DEBUG_MDNS("%s %-35s: MSG: %p \n", MDNS_DEBUG_WRITE,
+ __FUNC__, netreq);
+
+ GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
+
+ netreq->debug_start_time = _getdns_get_time_as_uintt64();
+ netreq->debug_udp = 1;
+ GLDNS_ID_SET(netreq->query, (uint16_t) arc4random());
+
+ /* do we need to handle options valid in the MDNS context? */
+
+ /* Probably no need for TSIG in MDNS */
+
+
+ /* Always use multicast address */
+ mdns_mcast_v4.sin_family = AF_INET;
+ mdns_mcast_v4.sin_port = htons(MDNS_MCAST_PORT);
+ mdns_mcast_v4.sin_addr.s_addr = htonl(MDNS_MCAST_IPV4_LONG);
+ /* memcpy(&mdns_mcast_v4.sin_addr.s_addr, mdns_mcast_ipv4, sizeof(mdns_mcast_ipv4)); */
+
+ /* Set TTL=255 for compliance with RFC 6762 */
+ r = setsockopt(netreq->fd, IPPROTO_IP, IP_TTL, (const char *)&ttl, sizeof(ttl));
+
+ if (r != 0 ||
+ (ssize_t)pkt_len != sendto(
+ netreq->fd, (const void *)netreq->query, pkt_len, 0,
+ (struct sockaddr *)&mdns_mcast_v4,
+ sizeof(mdns_mcast_v4))) {
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
+ close(netreq->fd);
+#endif
+ return;
+ }
+ GETDNS_SCHEDULE_EVENT(
+ dnsreq->loop, netreq->fd,
+ _getdns_ms_until_expiry(dnsreq->expires),
+ getdns_eventloop_event_init(&netreq->event, netreq,
+ mdns_udp_read_cb, NULL, mdns_timeout_cb));
+}
+
+/*
+ * MDNS Request Submission
+ */
+
+getdns_return_t
+_getdns_submit_mdns_request(getdns_network_req *netreq)
+{
+ DEBUG_MDNS("%s %-35s: MSG: %p TYPE: %d\n", MDNS_DEBUG_ENTRY, __FUNC__,
+ netreq, netreq->request_type);
+ int fd = -1;
+ getdns_dns_req *dnsreq = netreq->owner;
+ struct getdns_context * context = dnsreq->context;
+ getdns_return_t ret = 0;
+
+ /*
+ * TO DO: depending on context type, perform basic processing versus full MDNS
+ */
+
+ if (context->mdns_extended_support == 2)
+ {
+ /* Not initialize yet. Do it know before processing the query */
+ ret = mdns_delayed_network_init(context);
+
+ if (ret != 0)
+ {
+ return ret;
+ }
+ }
+
+ if (context->mdns_extended_support == 1)
+ {
+ /* extended DNS support */
+ ret = mdns_initialize_continuous_request(netreq);
+ }
+ else
+ {
+ /* basic MDNS request */
+
+ /* Open the UDP socket required for the request */
+ if ((fd = socket(
+ AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1)
+ return -1;
+ /* TODO: do we need getdns_sock_nonblock(fd); */
+
+ /* Schedule the MDNS request */
+ netreq->fd = fd;
+ GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
+ GETDNS_SCHEDULE_EVENT(
+ dnsreq->loop, netreq->fd,
+ _getdns_ms_until_expiry(dnsreq->expires),
+ getdns_eventloop_event_init(&netreq->event, netreq,
+ NULL, mdns_udp_write_cb, mdns_timeout_cb));
+ ret = GETDNS_RETURN_GOOD;
+ }
+
+ return ret;
+}
+
+/*
+ * MDNS name space management
+ */
+
+static int
+mdns_suffix_compare(register const uint8_t *d1, register const uint8_t *d2)
+{
+ int ret = 0;
+ uint8_t *d1_head = (uint8_t *) d1;
+ uint8_t *d1_current;
+ uint8_t *d2_current;
+ int is_matching = 0;
+ int part_length;
+ int i;
+ uint8_t c;
+
+ /* Skip the first name part, since we want at least one label before the suffix */
+ if (*d1_head != 0)
+ d1_head += *d1_head + 1;
+
+ while (*d1_head != 0)
+ {
+ /* check whether we have a match at this point */
+ d1_current = d1_head;
+ d2_current = (uint8_t *) d2;
+ is_matching = 0;
+
+ /* compare length and value of all successive labels */
+ while (*d1_current == *d2_current)
+ {
+ part_length = *d1_current;
+ if (part_length == 0)
+ {
+ /* We have reached the top label, there is a match */
+ ret = 1;
+ break;
+ }
+
+ /* The label's lengths are matching, check the content */
+ is_matching = 1;
+ d1_current++;
+ d2_current++;
+
+ for (i = 0; i < part_length; i++)
+ {
+ c = d1_current[i];
+ if (isupper(c))
+ c = tolower(c);
+ if (c != d2_current[i])
+ {
+ is_matching = 0;
+ break;
+ }
+ }
+
+ /* move the pointers to the next label */
+ if (is_matching)
+ {
+ d1_current += part_length;
+ d2_current += part_length;
+ }
+ }
+
+ /* if no match found yet, move to the next label of d1 */
+ if (is_matching)
+ break;
+ else
+ d1_head += *d1_head + 1;
+ }
+
+ return ret;
+}
+
+
+getdns_return_t
+_getdns_mdns_namespace_check(
+ getdns_dns_req *dnsreq)
+{
+ getdns_return_t ret = GETDNS_RETURN_GENERIC_ERROR;
+
+ /* Checking the prefixes defined in RFC 6762 */
+ if (mdns_suffix_compare(dnsreq->name, mdns_suffix_dot_local) ||
+ mdns_suffix_compare(dnsreq->name, mdns_suffix_254_169_in_addr_arpa) ||
+ mdns_suffix_compare(dnsreq->name, mdns_suffix_8_e_f_ip6_arpa) ||
+ mdns_suffix_compare(dnsreq->name, mdns_suffix_9_e_f_ip6_arpa) ||
+ mdns_suffix_compare(dnsreq->name, mdns_suffix_a_e_f_ip6_arpa) ||
+ mdns_suffix_compare(dnsreq->name, mdns_suffix_b_e_f_ip6_arpa))
+ ret = GETDNS_RETURN_GOOD;
+
+ return ret;
+}
+
+#endif /* HAVE_MDNS_SUPPORT */
+
+#ifdef MDNS_UNIT_TEST
+
+/*
+ * Test adding data to the LRU Cache
+ */
+
+static BYTE mdns_exampleRRAM[] = {
+ 0, 0, /* Transaction ID = 0 */
+ 0x84, 0, /* Answer: QR=1 (80), AA=1 (04) */
+ 0, 0, /* QD Count = 0 */
+ 0, 1, /* AN Count = 1 */
+ 0, 0, /* NS Count = 0 */
+ 0, 0, /* AD Count = 0 */
+ 7, /* length of "example" name part */
+ 'e', 'x', 'a', 'm', 'p', 'l', 'e',
+ 5, /* length of "local" name part */
+ 'l', 'o', 'c', 'a', 'l',
+ 0, /* length of the root name part */
+ 0, 1, /* QTYPE = 1, A record */
+ 0, 1, /* QCLASS = 1, IN */
+ 0, 0, 0, 255, /* TTL: 255 sec */
+ 0, 4, /* length of RDATA */
+ 10, 0, 0, 1 /* Value of RDATA (some IPv4 address) */
+};
+
+
+uint8_t mdns_test_name[] = {
+ 7, /* length of "example" name part */
+ 't', 'e', 's', 't', 'i', 'n', 'g',
+ 5, /* length of "local" name part */
+ 'l', 'o', 'c', 'a', 'l',
+ 0, /* length of the root name part */
+};
+
+uint8_t mdns_test_first_address[4] = { 10, 0, 0, 1 };
+uint8_t mdns_test_second_address[4] = { 10, 0, 0, 2 };
+uint8_t mdns_test_third_address[4] = { 10, 0, 0, 3 };
+
+int mdns_finalize_lru_test(struct getdns_context* context,
+ uint8_t * name, int name_len, int record_type, int record_class,
+ int expected_nb_records,
+ uint8_t * buffer, size_t buffer_max, size_t* entry_length)
+{
+ int ret = 0;
+ /* verify that the entry is there */
+ struct lruhash_entry * entry =
+ mdns_access_cached_entry_by_name(context, name, name_len, record_type, record_class);
+
+
+ *entry_length = 0;
+
+ if (entry == NULL)
+ {
+ if (expected_nb_records != 0)
+ ret = -1;
+ }
+ else
+ {
+ int nbanswers = mdns_cache_nb_records_in_entry((uint8_t*)entry->data);
+ if (nbanswers != expected_nb_records)
+ {
+ ret = -2;
+ }
+
+ if (buffer != NULL)
+ {
+ getdns_mdns_cached_record_header * header =
+ (getdns_mdns_cached_record_header*)entry->data;
+ size_t record_length = header->content_len - sizeof(getdns_mdns_cached_record_header);
+
+ if (record_length > buffer_max)
+ {
+ ret = -3;
+ }
+ else
+ {
+ memcpy(buffer, ((uint8_t *)entry->data) + sizeof(getdns_mdns_cached_record_header),
+ record_length);
+ *entry_length = record_length;
+ }
+ }
+
+ lock_rw_unlock(&entry->lock);
+ }
+
+ return ret;
+}
+
+int mdns_addition_test(struct getdns_context* context,
+ uint8_t * buffer, size_t buffer_max, size_t* entry_length)
+{
+ int ret =
+ mdns_propose_entry_to_cache(context, mdns_test_name, sizeof(mdns_test_name), 1, 1, 255,
+ mdns_test_first_address, 4, NULL, _getdns_get_time_as_uintt64());
+
+ if (ret == 0)
+ {
+ ret = mdns_finalize_lru_test(context, mdns_test_name, sizeof(mdns_test_name), 1, 1,
+ 1, buffer, buffer_max, entry_length);
+ }
+
+ return ret;
+}
+
+int mdns_addition_test2(struct getdns_context* context,
+ uint8_t * buffer, size_t buffer_max, size_t* entry_length)
+{
+ int ret =
+ mdns_propose_entry_to_cache(context, mdns_test_name, sizeof(mdns_test_name), 1, 1, 255,
+ mdns_test_first_address, 4, NULL, _getdns_get_time_as_uintt64());
+
+ if (ret == 0)
+ {
+ /* add a second entry, with a different value */
+ ret =
+ mdns_propose_entry_to_cache(context, mdns_test_name, sizeof(mdns_test_name), 1, 1, 255,
+ mdns_test_second_address, 4, NULL, _getdns_get_time_as_uintt64());
+ }
+
+ if (ret == 0)
+ {
+ /* add a third entry, with a different value */
+ ret =
+ mdns_propose_entry_to_cache(context, mdns_test_name, sizeof(mdns_test_name), 1, 1, 255,
+ mdns_test_third_address, 4, NULL, _getdns_get_time_as_uintt64());
+ }
+
+ if (ret == 0)
+ {
+ ret = mdns_finalize_lru_test(context, mdns_test_name, sizeof(mdns_test_name), 1, 1,
+ 3, buffer, buffer_max, entry_length);
+ }
+
+ return ret;
+}
+
+int mdns_deletion_test(struct getdns_context* context,
+ uint8_t * buffer, size_t buffer_max, size_t* entry_length)
+{
+ /* insert data with TTL = 0 to trigger suppression */
+ int ret =
+ mdns_propose_entry_to_cache(context, mdns_test_name, sizeof(mdns_test_name), 1, 1, 0,
+ mdns_test_second_address, 4, NULL, _getdns_get_time_as_uintt64());
+
+ if (ret == 0)
+ {
+ ret = mdns_finalize_lru_test(context, mdns_test_name, sizeof(mdns_test_name), 1, 1,
+ 2, buffer, buffer_max, entry_length);
+ }
+
+ return ret;
+}
+
+int mdns_deletion_test2(struct getdns_context* context,
+ uint8_t * buffer, size_t buffer_max, size_t* entry_length)
+{
+ /* insert data with TTL = 0 to trigger suppression */
+ int ret =
+ mdns_propose_entry_to_cache(context, mdns_test_name, sizeof(mdns_test_name), 1, 1, 0,
+ mdns_test_first_address, 4, NULL, _getdns_get_time_as_uintt64());
+
+ if (ret == 0)
+ {
+ ret =
+ mdns_propose_entry_to_cache(context, mdns_test_name, sizeof(mdns_test_name), 1, 1, 0,
+ mdns_test_third_address, 4, NULL, _getdns_get_time_as_uintt64());
+ }
+
+ if (ret == 0)
+ {
+ ret = mdns_finalize_lru_test(context, mdns_test_name, sizeof(mdns_test_name), 1, 1,
+ 0, buffer, buffer_max, entry_length);
+ }
+
+ return ret;
+}
+
+
+int mdns_test_prepare(struct getdns_context* context)
+{
+ return mdns_delayed_network_init(context);
+}
+
+#endif
diff --git a/src/mdns.h b/src/mdns.h
new file mode 100644
index 00000000..b7c7d20c
--- /dev/null
+++ b/src/mdns.h
@@ -0,0 +1,121 @@
+/*
+* Functions for MDNS resolving.
+*/
+
+/*
+* Copyright (c) 2016 Christian Huitema
+*
+* 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 THE AUTHOR DISCLAIMS ALL WARRANTIES
+* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+*/
+
+#ifndef MDNS_H
+#define MDNS_H
+
+#ifdef HAVE_MDNS_SUPPORT
+#include "getdns/getdns.h"
+#include "types-internal.h"
+#include "util/lruhash.h"
+#include "config.h"
+
+#ifndef USE_WINSOCK
+#define SOCKADDR_STORAGE struct sockaddr_storage
+#endif
+
+getdns_return_t
+_getdns_submit_mdns_request(getdns_network_req *netreq);
+
+getdns_return_t
+_getdns_mdns_namespace_check(getdns_dns_req *dnsreq);
+
+/*
+ * data structure for continuous queries
+ */
+
+typedef struct getdns_mdns_known_record
+{
+ /* For storage in context->mdns_known_records_by_value */
+ _getdns_rbnode_t node;
+ uint64_t insertion_microsec;
+ uint16_t record_type;
+ uint16_t record_class;
+ uint32_t ttl;
+ int name_len;
+ int record_data_len;
+ uint8_t* name;
+ uint8_t * record_data;
+} getdns_mdns_known_record;
+
+/*
+ * Each entry in the hash table is keyed by type, class and name.
+ * The key structure also contains the LRU hash entry structure.
+ * The data part contains:
+ * - 64 bit time stamp
+ * - 32 bit word describing the record size
+ * - 32 bit word describing teh allocated memory size
+ * - valid DNS response, including 1 query and N answers, 0 AUTH, 0 AD.
+ * For economy, the names of all answers are encoded using header compression, pointing
+ * to the name in the query, i.e. offset 12 from beginning of message.
+ * For stability, the names included in the data part of records are not compressed.
+ */
+
+typedef struct getdns_mdns_cached_key_header
+{
+ /* embedded entry, for LRU hash */
+ struct lruhash_entry entry;
+ /* identification */
+ uint16_t record_type;
+ uint16_t record_class;
+ int name_len;
+ /* the octets following this structure contain the name */
+} getdns_mdns_cached_key_header;
+
+typedef struct getdns_mdns_cached_record_header
+{
+ uint64_t insertion_microsec;
+ uint32_t content_len;
+ uint32_t allocated_length;
+ /* list of user queries */
+ getdns_network_req *netreq_first;
+} getdns_mdns_cached_record_header;
+
+typedef struct getdns_mdns_continuous_query
+{
+ /* For storage in context->mdns_continuous_queries_by_name_rrtype */
+ _getdns_rbnode_t node;
+ uint8_t name[256]; /* binary representation of name being queried */
+ int name_len;
+ uint16_t request_class;
+ uint16_t request_type;
+ /* list of user queries */
+ getdns_network_req *netreq_first;
+ /* todo: do we need an expiration date, or a timer? */
+ /* todo: do we need an update mark for showing last results? */
+} getdns_mdns_continuous_query;
+
+typedef struct mdns_network_connection
+{
+ struct getdns_context* context;
+ int fd;
+ int addr_mcast_len;
+ SOCKADDR_STORAGE addr_mcast;
+ getdns_eventloop_event event;
+ uint8_t response[1500];
+} mdns_network_connection;
+
+
+void _getdns_mdns_context_init(struct getdns_context *context);
+void _getdns_mdns_context_destroy(struct getdns_context *context);
+
+#endif /* HAVE_MDNS_SUPPORT */
+
+#endif /* MDNS_H */
diff --git a/src/mk-const-info.c.sh b/src/mk-const-info.c.sh
index f9c54323..715719ef 100755
--- a/src/mk-const-info.c.sh
+++ b/src/mk-const-info.c.sh
@@ -14,7 +14,7 @@ cat > const-info.c << END_OF_HEAD
static struct const_info consts_info[] = {
{ -1, NULL, "/* */" },
END_OF_HEAD
-gawk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ key = sprintf("%4d", $3); consts[key] = $1; }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/^#define GETDNS_RRCLASS/ && !/^#define GETDNS_OPCODE/ && !/^#define GETDNS_RCODE/ && !/_TEXT/{ key = sprintf("%4d", $3); consts[key] = $2; }/^#define GETDNS_[A-Z_]+[ ]+\(\(getdns_(return|append_name)_t) [0-9]+ \)/{ key = sprintf("%4d", $4); consts[key] = $2; }END{ n = asorti(consts, const_vals); for ( i = 1; i <= n; i++) { val = const_vals[i]; name = consts[val]; print "\t{ "val", \""name"\", "name"_TEXT },"}}' getdns/getdns.h.in getdns/getdns_extra.h.in | sed 's/,,/,/g' >> const-info.c
+gawk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ key = sprintf("%7d", $3); consts[key] = $1; }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/^#define GETDNS_RRCLASS/ && !/^#define GETDNS_OPCODE/ && !/^#define GETDNS_RCODE/ && !/_TEXT/{ key = sprintf("%7d", $3); consts[key] = $2; }/^#define GETDNS_[A-Z_]+[ ]+\(\(getdns_(return|append_name)_t) [0-9]+ \)/{ key = sprintf("%7d", $4); consts[key] = $2; }END{ n = asorti(consts, const_vals); for ( i = 1; i <= n; i++) { val = const_vals[i]; name = consts[val]; print "\t{ "val", \""name"\", "name"_TEXT },"}}' getdns/getdns_extra.h.in getdns/getdns.h.in | sed 's/,,/,/g' >> const-info.c
cat >> const-info.c << END_OF_TAIL
};
diff --git a/src/mk-symfiles.sh b/src/mk-symfiles.sh
index 878196b9..597657b7 100755
--- a/src/mk-symfiles.sh
+++ b/src/mk-symfiles.sh
@@ -3,7 +3,7 @@
write_symbols() {
OUTPUT=$1
shift
- grep 'getdns_[0-9a-zA-Z_]*(' $* | grep -v '^#' | grep -v 'INLINE' \
+ grep 'getdns_[0-9a-zA-Z_]*(' $* | grep -v '^#' | grep -v 'INLINE' | grep -v 'getdns_extra\.h\.in: \* if' \
| sed -e 's/(.*$//g' -e 's/^.*getdns_/getdns_/g' | LC_ALL=C sort | uniq > $OUTPUT
}
diff --git a/src/pubkey-pinning.c b/src/pubkey-pinning.c
index 8a2250d8..a960ab66 100644
--- a/src/pubkey-pinning.c
+++ b/src/pubkey-pinning.c
@@ -56,6 +56,10 @@
#include "context.h"
#include "util-internal.h"
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL)
+#define X509_STORE_CTX_get0_untrusted(store) store->untrusted
+#endif
+
/* we only support sha256 at the moment. adding support for another
digest is more complex than just adding another entry here. in
particular, you'll probably need a match for a particular cert
@@ -93,7 +97,7 @@ getdns_dict* getdns_pubkey_pin_create_from_string(
const char* str)
{
BIO *bio = NULL;
- int i;
+ size_t i;
uint8_t buf[SHA256_DIGEST_LENGTH];
char inbuf[B64_ENCODED_SHA256_LENGTH + 1];
getdns_bindata value = { .size = SHA256_DIGEST_LENGTH, .data = buf };
@@ -310,15 +314,27 @@ _getdns_get_pubkey_pinset_list(getdns_context *ctx,
see doc/HOWTO/proxy_certificates.txt as an example
*/
static int
-_get_ssl_getdns_upstream_idx()
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL)
+_get_ssl_getdns_upstream_idx(void)
+#else
+_get_ssl_getdns_upstream_idx(X509_STORE *store)
+#endif
{
static volatile int idx = -1;
if (idx < 0) {
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL)
CRYPTO_w_lock(CRYPTO_LOCK_X509_STORE);
+#else
+ X509_STORE_lock(store);
+#endif
if (idx < 0)
idx = SSL_get_ex_new_index(0, "associated getdns upstream",
NULL,NULL,NULL);
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL)
CRYPTO_w_unlock(CRYPTO_LOCK_X509_STORE);
+#else
+ X509_STORE_unlock(store);
+#endif
}
return idx;
}
@@ -326,7 +342,11 @@ _get_ssl_getdns_upstream_idx()
getdns_upstream*
_getdns_upstream_from_x509_store(X509_STORE_CTX *store)
{
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL)
int uidx = _get_ssl_getdns_upstream_idx();
+#else
+ int uidx = _get_ssl_getdns_upstream_idx(X509_STORE_CTX_get0_store(store));
+#endif
int sslidx = SSL_get_ex_data_X509_STORE_CTX_idx();
const SSL *ssl;
@@ -344,7 +364,11 @@ getdns_return_t
_getdns_associate_upstream_with_SSL(SSL *ssl,
getdns_upstream *upstream)
{
+#if OPENSSL_VERSION_NUMBER < 0x10100000 || defined(HAVE_LIBRESSL)
int uidx = _get_ssl_getdns_upstream_idx();
+#else
+ int uidx = _get_ssl_getdns_upstream_idx(SSL_CTX_get_cert_store(SSL_get_SSL_CTX(ssl)));
+#endif
if (SSL_set_ex_data(ssl, uidx, upstream))
return GETDNS_RETURN_GOOD;
else
@@ -358,10 +382,10 @@ _getdns_verify_pinset_match(const sha256_pin_t *pinset,
X509_STORE_CTX *store)
{
getdns_return_t ret = GETDNS_RETURN_GENERIC_ERROR;
- X509 *x;
+ X509 *x, *prev = NULL;
int i, len;
unsigned char raw[4096];
- unsigned char *next = raw;
+ unsigned char *next;
unsigned char buf[sizeof(pinset->pin)];
const sha256_pin_t *p;
@@ -383,33 +407,45 @@ _getdns_verify_pinset_match(const sha256_pin_t *pinset,
/* TODO: how do we handle raw public keys? */
- for (i = 0; i < sk_X509_num(store->untrusted); i++) {
- if (i > 0) {
- /* TODO: how do we ensure that the certificates in
- * each stage appropriately sign the previous one?
- * for now, to be safe, we only examine the end-entity
- * cert: */
- return GETDNS_RETURN_GENERIC_ERROR;
- }
+ for (i = 0; i < sk_X509_num(X509_STORE_CTX_get0_untrusted(store)); i++, prev = x) {
- x = sk_X509_value(store->untrusted, i);
+ x = sk_X509_value(X509_STORE_CTX_get0_untrusted(store), i);
#if defined(STUB_DEBUG) && STUB_DEBUG
DEBUG_STUB("%s %-35s: Name of cert: %d ",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, i);
+ STUB_DEBUG_SETUP_TLS, __FUNC__, i);
X509_NAME_print_ex_fp(stderr, X509_get_subject_name(x), 1, XN_FLAG_ONELINE);
fprintf(stderr, "\n");
#endif
+ if (i > 0) {
+ /* we ensure that "prev" is signed by "x" */
+ EVP_PKEY *pkey = X509_get_pubkey(x);
+ int verified;
+ if (!pkey) {
+ DEBUG_STUB("%s %-35s: Could not get pubkey from cert %d (%p)\n",
+ STUB_DEBUG_SETUP_TLS, __FUNC__, i, (void*)x);
+ return GETDNS_RETURN_GENERIC_ERROR;
+ }
+ verified = X509_verify(prev, pkey);
+ EVP_PKEY_free(pkey);
+ if (!verified) {
+ DEBUG_STUB("%s %-35s: cert %d (%p) was not signed by cert %d\n",
+ STUB_DEBUG_SETUP_TLS, __FUNC__, i-1, (void*)prev, i);
+ return GETDNS_RETURN_GENERIC_ERROR;
+ }
+ }
+
/* digest the cert with sha256 */
len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), NULL);
- if (len > sizeof(raw)) {
+ if (len > (int)sizeof(raw)) {
DEBUG_STUB("%s %-35s: Pubkey %d is larger than "PRIsz" octets\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, sizeof(raw));
+ STUB_DEBUG_SETUP_TLS, __FUNC__, i, sizeof(raw));
continue;
}
+ next = raw;
i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), &next);
if (next - raw != len) {
DEBUG_STUB("%s %-35s: Pubkey %d claimed it needed %d octets, really needed "PRIsz"\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, len, next - raw);
+ STUB_DEBUG_SETUP_TLS, __FUNC__, i, len, next - raw);
continue;
}
SHA256(raw, len, buf);
@@ -418,11 +454,11 @@ _getdns_verify_pinset_match(const sha256_pin_t *pinset,
for (p = pinset; p; p = p->next)
if (0 == memcmp(buf, p->pin, sizeof(p->pin))) {
DEBUG_STUB("%s %-35s: Pubkey %d matched pin %p ("PRIsz")\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, p, sizeof(p->pin));
+ STUB_DEBUG_SETUP_TLS, __FUNC__, i, (void*)p, sizeof(p->pin));
return GETDNS_RETURN_GOOD;
} else
DEBUG_STUB("%s %-35s: Pubkey %d did not match pin %p\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, p);
+ STUB_DEBUG_SETUP_TLS, __FUNC__, i, (void*)p);
}
return ret;
diff --git a/src/request-internal.c b/src/request-internal.c
index 141f977a..15f97179 100644
--- a/src/request-internal.c
+++ b/src/request-internal.c
@@ -43,6 +43,7 @@
#include "dict.h"
#include "debug.h"
#include "convert.h"
+#include "general.h"
/* MAXIMUM_TSIG_SPACE = TSIG name (dname) : 256
* TSIG type (uint16_t) : 2
@@ -65,20 +66,20 @@
getdns_dict dnssec_ok_checking_disabled_spc = {
{ RBTREE_NULL, 0, (int (*)(const void *, const void *)) strcmp },
- { 0 }
+ { NULL, {{ NULL, NULL, NULL }}}
};
getdns_dict *dnssec_ok_checking_disabled = &dnssec_ok_checking_disabled_spc;
getdns_dict dnssec_ok_checking_disabled_roadblock_avoidance_spc = {
{ RBTREE_NULL, 0, (int (*)(const void *, const void *)) strcmp },
- { 0 }
+ { NULL, {{ NULL, NULL, NULL }}}
};
getdns_dict *dnssec_ok_checking_disabled_roadblock_avoidance
= &dnssec_ok_checking_disabled_roadblock_avoidance_spc;
getdns_dict dnssec_ok_checking_disabled_avoid_roadblocks_spc = {
{ RBTREE_NULL, 0, (int (*)(const void *, const void *)) strcmp },
- { 0 }
+ { NULL, {{ NULL, NULL, NULL }}}
};
getdns_dict *dnssec_ok_checking_disabled_avoid_roadblocks
= &dnssec_ok_checking_disabled_avoid_roadblocks_spc;
@@ -109,6 +110,9 @@ network_req_cleanup(getdns_network_req *net_req)
if (net_req->response && (net_req->response < net_req->wire_data ||
net_req->response > net_req->wire_data+ net_req->wire_data_sz))
GETDNS_FREE(net_req->owner->my_mf, net_req->response);
+ if (net_req->debug_tls_peer_cert.size &&
+ net_req->debug_tls_peer_cert.data)
+ OPENSSL_free(net_req->debug_tls_peer_cert.data);
}
static uint8_t *
@@ -118,10 +122,9 @@ netreq_reset(getdns_network_req *net_req)
/* variables that need to be reset on reinit
*/
net_req->unbound_id = -1;
- net_req->state = NET_REQ_NOT_SENT;
+ _getdns_netreq_change_state(net_req, NET_REQ_NOT_SENT);
net_req->dnssec_status = GETDNS_DNSSEC_INDETERMINATE;
net_req->tsig_status = GETDNS_DNSSEC_INDETERMINATE;
- net_req->query_id = 0;
net_req->response_len = 0;
/* Some fields to record info for return_call_reporting */
net_req->debug_start_time = 0;
@@ -181,8 +184,14 @@ network_req_init(getdns_network_req *net_req, getdns_dns_req *owner,
net_req->write_queue_tail = NULL;
/* Some fields to record info for return_call_reporting */
net_req->debug_tls_auth_status = GETDNS_AUTH_NONE;
+ net_req->debug_tls_peer_cert.size = 0;
+ net_req->debug_tls_peer_cert.data = NULL;
net_req->debug_udp = 0;
+ /* Scheduling, touch only via _getdns_netreq_change_state!
+ */
+ net_req->state = NET_REQ_NOT_SENT;
+
if (max_query_sz == 0) {
net_req->query = NULL;
net_req->opt = NULL;
@@ -262,10 +271,10 @@ _getdns_network_req_clear_upstream_options(getdns_network_req * req)
{
size_t pktlen;
if (req->opt) {
- gldns_write_uint16(req->opt + 9, req->base_query_option_sz);
+ gldns_write_uint16(req->opt + 9, (uint16_t) req->base_query_option_sz);
req->response = req->opt + 11 + req->base_query_option_sz;
pktlen = req->response - req->query;
- gldns_write_uint16(req->query - 2, pktlen);
+ gldns_write_uint16(req->query - 2, (uint16_t) pktlen);
}
}
@@ -383,7 +392,7 @@ _getdns_network_req_add_tsig(getdns_network_req *req)
#endif
tsig_info = _getdns_get_tsig_info(upstream->tsig_alg);
- gldns_buffer_init_frm_data(&gbuf, req->response, MAXIMUM_TSIG_SPACE);
+ gldns_buffer_init_vfixed_frm_data(&gbuf, req->response, MAXIMUM_TSIG_SPACE);
gldns_buffer_write(&gbuf,
upstream->tsig_dname, upstream->tsig_dname_len); /* Name */
gldns_buffer_write_u16(&gbuf, GETDNS_RRCLASS_ANY); /* Class */
@@ -428,7 +437,7 @@ _getdns_network_req_add_tsig(getdns_network_req *req)
gldns_buffer_write_u16(&gbuf, GETDNS_RRCLASS_ANY); /* Class */
gldns_buffer_write_u32(&gbuf, 0); /* TTL */
gldns_buffer_write_u16(&gbuf,
- tsig_info->dname_len + 10 + md_len + 6); /* RdLen */
+ (uint16_t)(tsig_info->dname_len + 10 + md_len + 6)); /* RdLen */
gldns_buffer_write(&gbuf,
tsig_info->dname, tsig_info->dname_len); /* Algorithm Name */
gldns_buffer_write_u48(&gbuf, time(NULL)); /* Time Signed */
@@ -474,7 +483,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
HMAC_CTX ctx_space;
#endif
- DEBUG_STUB("%s %-35s: Validate TSIG\n", STUB_DEBUG_TSIG, __FUNCTION__);
+ DEBUG_STUB("%s %-35s: Validate TSIG\n", STUB_DEBUG_TSIG, __FUNC__);
for ( rr = _getdns_rr_iter_init(&rr_spc, req->query,
(req->response - req->query))
; rr
@@ -491,7 +500,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
if (request_mac_len != rdf->nxt - rdf->pos - 2)
return;
DEBUG_STUB("%s %-35s: Request MAC found length %d\n",
- STUB_DEBUG_TSIG, __FUNCTION__, (int)(request_mac_len));
+ STUB_DEBUG_TSIG, __FUNC__, (int)(request_mac_len));
request_mac = rdf->pos + 2;
@@ -548,7 +557,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
if (response_mac_len != rdf->nxt - rdf->pos - 2)
return;
DEBUG_STUB("%s %-35s: Response MAC found length: %d\n",
- STUB_DEBUG_TSIG, __FUNCTION__, (int)(response_mac_len));
+ STUB_DEBUG_TSIG, __FUNC__, (int)(response_mac_len));
response_mac = rdf->pos + 2;
if (!(rdf = _getdns_rdf_iter_next(rdf)) ||
@@ -565,7 +574,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
return;
gldns_buffer_write_u16(&gbuf, 0); /* Other len */
- other_len = gldns_read_uint16(rdf->pos);
+ other_len = (uint8_t) gldns_read_uint16(rdf->pos);
if (other_len != rdf->nxt - rdf->pos - 2)
return;
if (other_len)
@@ -573,7 +582,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
/* TSIG found */
DEBUG_STUB("%s %-35s: TSIG found, original ID: %d\n",
- STUB_DEBUG_TSIG, __FUNCTION__, (int)original_id);
+ STUB_DEBUG_TSIG, __FUNC__, (int)original_id);
gldns_write_uint16(req->response + 10,
gldns_read_uint16(req->response + 10) - 1);
@@ -614,7 +623,7 @@ _getdns_network_validate_tsig(getdns_network_req *req)
HMAC_Final(ctx, result_mac, &result_mac_len);
DEBUG_STUB("%s %-35s: Result MAC length: %d\n",
- STUB_DEBUG_TSIG, __FUNCTION__, (int)(result_mac_len));
+ STUB_DEBUG_TSIG, __FUNC__, (int)(result_mac_len));
if (result_mac_len == response_mac_len &&
memcmp(result_mac, response_mac, result_mac_len) == 0)
req->tsig_status = GETDNS_DNSSEC_SECURE;
@@ -644,7 +653,7 @@ _getdns_dns_req_free(getdns_dns_req * req)
network_req_cleanup(*net_req);
/* clear timeout event */
- if (req->timeout.timeout_cb) {
+ if (req->loop && req->loop->vmt && req->timeout.timeout_cb) {
req->loop->vmt->clear(req->loop, &req->timeout);
req->timeout.timeout_cb = NULL;
}
@@ -658,7 +667,8 @@ static const uint8_t no_suffixes[] = { 1, 0 };
/* create a new dns req to be submitted */
getdns_dns_req *
_getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
- const char *name, uint16_t request_type, getdns_dict *extensions)
+ const char *name, uint16_t request_type, getdns_dict *extensions,
+ uint64_t *now_ms)
{
int dnssec_return_status = is_extension_set(
extensions, "dnssec_return_status",
@@ -755,17 +765,26 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
edns_do_bit = context->edns_do_bit;
if (have_add_opt_parameters) {
- if (!getdns_dict_get_int(add_opt_parameters,
+ if (getdns_dict_get_int(add_opt_parameters,
"maximum_udp_payload_size",
- &get_edns_maximum_udp_payload_size))
+ &get_edns_maximum_udp_payload_size)) {
+ if (!getdns_dict_get_int(
+ add_opt_parameters, "udp_payload_size",
+ &get_edns_maximum_udp_payload_size))
+ edns_maximum_udp_payload_size =
+ get_edns_maximum_udp_payload_size;
+ } else
edns_maximum_udp_payload_size =
get_edns_maximum_udp_payload_size;
+
(void) getdns_dict_get_int(add_opt_parameters,
"extended_rcode", &edns_extended_rcode);
(void) getdns_dict_get_int(add_opt_parameters,
"version", &edns_version);
- (void) getdns_dict_get_int(add_opt_parameters,
- "do_bit", &edns_do_bit);
+ if (getdns_dict_get_int(add_opt_parameters,
+ "do_bit", &edns_do_bit))
+ (void) getdns_dict_get_int(
+ add_opt_parameters, "do", &edns_do_bit);
}
}
if (have_add_opt_parameters && getdns_dict_get_list(
@@ -887,9 +906,7 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
}
result->context = context;
result->loop = loop;
- result->canceled = 0;
- result->trans_id = (((uint64_t)arc4random()) << 32) |
- ((uint64_t)arc4random());
+ result->trans_id = (uint64_t) (intptr_t) result;
result->dnssec_return_status = dnssec_return_status;
result->dnssec_return_only_secure = dnssec_return_only_secure;
result->dnssec_return_all_statuses = dnssec_return_all_statuses;
@@ -925,12 +942,15 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
result->finished_next = NULL;
result->freed = NULL;
result->validating = 0;
+ result->is_dns_request = 1;
+ result->request_timed_out = 0;
+ result->chain = NULL;
network_req_init(result->netreqs[0], result,
request_type, dnssec_extension_set, with_opt,
edns_maximum_udp_payload_size,
edns_extended_rcode, edns_version, edns_do_bit,
- opt_options_size, noptions, options,
+ (uint16_t) opt_options_size, noptions, options,
netreq_sz - sizeof(getdns_network_req), max_query_sz,
extensions);
@@ -941,9 +961,14 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
dnssec_extension_set, with_opt,
edns_maximum_udp_payload_size,
edns_extended_rcode, edns_version, edns_do_bit,
- opt_options_size, noptions, options,
+ (uint16_t) opt_options_size, noptions, options,
netreq_sz - sizeof(getdns_network_req), max_query_sz,
extensions);
+ if (*now_ms == 0 && (*now_ms = _getdns_get_now_ms()) == 0)
+ result->expires = 0;
+ else
+ result->expires = *now_ms + context->timeout;
+
return result;
}
diff --git a/src/rr-dict.c b/src/rr-dict.c
index 76972997..1206ed53 100644
--- a/src/rr-dict.c
+++ b/src/rr-dict.c
@@ -47,6 +47,7 @@
static const uint8_t *
apl_n_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf)
{
+ (void)pkt;
return rdf < pkt_end ? rdf + 1 : NULL;
}
static getdns_return_t
@@ -55,11 +56,6 @@ apl_n_wire2dict(getdns_dict *dict, const uint8_t *rdf)
return getdns_dict_set_int(dict, "n", (*rdf >> 7));
}
static getdns_return_t
-apl_n_wire2list(getdns_list *list, const uint8_t *rdf)
-{
- return _getdns_list_append_int(list, (*rdf >> 7));
-}
-static getdns_return_t
apl_n_2wire(uint32_t value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
{
(void)rdata; /* unused parameter */
@@ -84,22 +80,10 @@ apl_n_dict2wire(const getdns_dict *dict,
else
return apl_n_2wire(value, rdata, rdf, rdf_len);
}
-static getdns_return_t
-apl_n_list2wire(const getdns_list *list, size_t i,
- uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
-{
- getdns_return_t r;
- uint32_t value;
-
- if ((r = getdns_list_get_int(list, i, &value)))
- return r;
- else
- return apl_n_2wire(value, rdata, rdf, rdf_len);
-}
static _getdns_rdf_special apl_n = {
apl_n_rdf_end,
- apl_n_wire2dict, apl_n_wire2list,
- apl_n_dict2wire, apl_n_list2wire
+ apl_n_wire2dict, NULL,
+ apl_n_dict2wire, NULL
};
static const uint8_t *
@@ -107,6 +91,7 @@ apl_afdpart_rdf_end(
const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf)
{
const uint8_t *end = rdf + (rdf[-1] & 0x7F);
+ (void)(pkt);
return end <= pkt_end ? end : NULL;
}
static getdns_return_t
@@ -116,11 +101,6 @@ apl_afdpart_wire2dict(getdns_dict *dict, const uint8_t *rdf)
dict, "afdpart", (rdf[-1] & 0x7F), rdf);
}
static getdns_return_t
-apl_afdpart_wire2list(getdns_list *list, const uint8_t *rdf)
-{
- return _getdns_list_append_const_bindata(list, (rdf[-1] & 0x7F), rdf);
-}
-static getdns_return_t
apl_afdpart_2wire(
const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
{
@@ -154,22 +134,10 @@ apl_afdpart_dict2wire(
else
return apl_afdpart_2wire(value, rdata, rdf, rdf_len);
}
-static getdns_return_t
-apl_afdpart_list2wire(const getdns_list *list,
- size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
-{
- getdns_return_t r;
- getdns_bindata *value;
-
- if ((r = getdns_list_get_bindata(list, i, &value)))
- return r;
- else
- return apl_afdpart_2wire(value, rdata, rdf, rdf_len);
-}
static _getdns_rdf_special apl_afdpart = {
apl_afdpart_rdf_end,
- apl_afdpart_wire2dict, apl_afdpart_wire2list,
- apl_afdpart_dict2wire, apl_afdpart_list2wire
+ apl_afdpart_wire2dict, NULL,
+ apl_afdpart_dict2wire, NULL
};
static const uint8_t *
@@ -244,30 +212,12 @@ ipseckey_gateway_wire2dict(getdns_dict *dict, const uint8_t *rdf)
return _getdns_dict_set_const_bindata(dict, "gateway", size, data);
}
static getdns_return_t
-ipseckey_gateway_wire2list(getdns_list *list, const uint8_t *rdf)
-{
- size_t size;
- const uint8_t *data;
-
- if (ipseckey_gateway_equip_const_bindata(rdf, &size, &data))
- return GETDNS_RETURN_GENERIC_ERROR;
-
- else if (!size)
- return GETDNS_RETURN_GOOD;
- else
- return _getdns_list_append_const_bindata(list, size, data);
-}
-static getdns_return_t
ipseckey_gateway_2wire(
const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
{
- if (rdf - 2 < rdata)
- return GETDNS_RETURN_GENERIC_ERROR;
+ assert(rdf - 2 >= rdata && rdf[-2] > 0);
switch (rdf[-2]) {
- case 0: if (value && value->size > 0)
- return GETDNS_RETURN_INVALID_PARAMETER;
- break;
case 1: if (!value || value->size != 4)
return GETDNS_RETURN_INVALID_PARAMETER;
if (*rdf_len < 4) {
@@ -308,33 +258,29 @@ ipseckey_gateway_dict2wire(
getdns_return_t r;
getdns_bindata *value;
- if ((r = getdns_dict_get_bindata(dict, "gateway", &value)))
- return r;
- else
- return ipseckey_gateway_2wire(value, rdata, rdf, rdf_len);
-}
-static getdns_return_t
-ipseckey_gateway_list2wire(const getdns_list *list,
- size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
-{
- getdns_return_t r;
- getdns_bindata *value;
+ if (rdf - 2 < rdata)
+ return GETDNS_RETURN_GENERIC_ERROR;
- if ((r = getdns_list_get_bindata(list, i, &value)))
+ else if (rdf[-2] == 0) {
+ *rdf_len = 0;
+ return GETDNS_RETURN_GOOD;
+ }
+ else if ((r = getdns_dict_get_bindata(dict, "gateway", &value)))
return r;
else
return ipseckey_gateway_2wire(value, rdata, rdf, rdf_len);
}
static _getdns_rdf_special ipseckey_gateway = {
ipseckey_gateway_rdf_end,
- ipseckey_gateway_wire2dict, ipseckey_gateway_wire2list,
- ipseckey_gateway_dict2wire, ipseckey_gateway_list2wire
+ ipseckey_gateway_wire2dict, NULL,
+ ipseckey_gateway_dict2wire, NULL
};
static const uint8_t *
hip_pk_algorithm_rdf_end(
const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf)
{
+ (void)(pkt);
return rdf + 4 > pkt_end ? NULL
: rdf + 4 + *rdf + gldns_read_uint16(rdf + 2) > pkt_end ? NULL
: rdf + 1;
@@ -345,11 +291,6 @@ hip_pk_algorithm_wire2dict(getdns_dict *dict, const uint8_t *rdf)
return getdns_dict_set_int(dict, "pk_algorithm", rdf[1]);
}
static getdns_return_t
-hip_pk_algorithm_wire2list(getdns_list *list, const uint8_t *rdf)
-{
- return _getdns_list_append_int(list, rdf[1]);
-}
-static getdns_return_t
hip_pk_algorithm_2wire(uint32_t value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
{
if (rdata != rdf)
@@ -376,27 +317,16 @@ hip_pk_algorithm_dict2wire(
else
return hip_pk_algorithm_2wire(value, rdata, rdf, rdf_len);
}
-static getdns_return_t
-hip_pk_algorithm_list2wire(const getdns_list *list,
- size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
-{
- getdns_return_t r;
- uint32_t value;
-
- if ((r = getdns_list_get_int(list, i, &value)))
- return r;
- else
- return hip_pk_algorithm_2wire(value, rdata, rdf, rdf_len);
-}
static _getdns_rdf_special hip_pk_algorithm = {
hip_pk_algorithm_rdf_end,
- hip_pk_algorithm_wire2dict, hip_pk_algorithm_wire2list,
- hip_pk_algorithm_dict2wire, hip_pk_algorithm_list2wire
+ hip_pk_algorithm_wire2dict, NULL,
+ hip_pk_algorithm_dict2wire, NULL
};
static const uint8_t *
hip_hit_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf)
{
+ (void)(pkt);
return rdf + 3 > pkt_end ? NULL
: rdf + 3 + rdf[-1] + gldns_read_uint16(rdf + 1) > pkt_end ? NULL
: rdf + 1;
@@ -407,11 +337,6 @@ hip_hit_wire2dict(getdns_dict *dict, const uint8_t *rdf)
return _getdns_dict_set_const_bindata(dict, "hit", rdf[-1], rdf + 3);
}
static getdns_return_t
-hip_hit_wire2list(getdns_list *list, const uint8_t *rdf)
-{
- return _getdns_list_append_const_bindata(list, rdf[-1], rdf + 3);
-}
-static getdns_return_t
hip_hit_2wire(
const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
{
@@ -429,7 +354,7 @@ hip_hit_2wire(
return GETDNS_RETURN_NEED_MORE_SPACE;
}
*rdf_len = value->size;
- rdata[0] = value->size;
+ rdata[0] = (uint8_t) value->size;
(void)memcpy(rdf, value->data, value->size);
return GETDNS_RETURN_GOOD;
}
@@ -445,28 +370,17 @@ hip_hit_dict2wire(
else
return hip_hit_2wire(value, rdata, rdf, rdf_len);
}
-static getdns_return_t
-hip_hit_list2wire(const getdns_list *list,
- size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
-{
- getdns_return_t r;
- getdns_bindata *value;
-
- if ((r = getdns_list_get_bindata(list, i, &value)))
- return r;
- else
- return hip_hit_2wire(value, rdata, rdf, rdf_len);
-}
static _getdns_rdf_special hip_hit = {
hip_hit_rdf_end,
- hip_hit_wire2dict, hip_hit_wire2list,
- hip_hit_dict2wire, hip_hit_list2wire
+ hip_hit_wire2dict, NULL,
+ hip_hit_dict2wire, NULL
};
static const uint8_t *
hip_public_key_rdf_end(
const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf)
{
+ (void)(pkt);
return rdf + 2 > pkt_end ? NULL
: rdf + 2 + rdf[-2] + gldns_read_uint16(rdf) > pkt_end ? NULL
: rdf + 2 + rdf[-2] + gldns_read_uint16(rdf);
@@ -478,12 +392,6 @@ hip_public_key_wire2dict(getdns_dict *dict, const uint8_t *rdf)
dict, "public_key", gldns_read_uint16(rdf), rdf + 2 + rdf[-2]);
}
static getdns_return_t
-hip_public_key_wire2list(getdns_list *list, const uint8_t *rdf)
-{
- return _getdns_list_append_const_bindata(
- list, gldns_read_uint16(rdf), rdf + 2 + rdf[-2]);
-}
-static getdns_return_t
hip_public_key_2wire(
const getdns_bindata *value, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
{
@@ -501,7 +409,7 @@ hip_public_key_2wire(
return GETDNS_RETURN_NEED_MORE_SPACE;
}
*rdf_len = value->size;
- gldns_write_uint16(rdata + 2, value->size);
+ gldns_write_uint16(rdata + 2, (uint16_t) value->size);
(void)memcpy(rdf, value->data, value->size);
return GETDNS_RETURN_GOOD;
}
@@ -517,242 +425,241 @@ hip_public_key_dict2wire(
else
return hip_public_key_2wire(value, rdata, rdf, rdf_len);
}
-static getdns_return_t
-hip_public_key_list2wire(
- const getdns_list *list, size_t i, uint8_t *rdata, uint8_t *rdf, size_t *rdf_len)
-{
- getdns_return_t r;
- getdns_bindata *value;
-
- if ((r = getdns_list_get_bindata(list, i, &value)))
- return r;
- else
- return hip_public_key_2wire(value, rdata, rdf, rdf_len);
-}
static _getdns_rdf_special hip_public_key = {
hip_public_key_rdf_end,
- hip_public_key_wire2dict, hip_public_key_wire2list,
- hip_public_key_dict2wire, hip_public_key_list2wire
+ hip_public_key_wire2dict, NULL,
+ hip_public_key_dict2wire, NULL
};
static _getdns_rdata_def a_rdata[] = {
- { "ipv4_address" , GETDNS_RDF_A }};
+ { "ipv4_address" , GETDNS_RDF_A , NULL }};
static _getdns_rdata_def ns_rdata[] = {
- { "nsdname" , GETDNS_RDF_N_C }};
+ { "nsdname" , GETDNS_RDF_N_C , NULL }};
static _getdns_rdata_def md_rdata[] = {
- { "madname" , GETDNS_RDF_N_C }};
+ { "madname" , GETDNS_RDF_N_C , NULL }};
static _getdns_rdata_def cname_rdata[] = {
- { "cname" , GETDNS_RDF_N_C }};
+ { "cname" , GETDNS_RDF_N_C , NULL }};
static _getdns_rdata_def soa_rdata[] = {
- { "mname" , GETDNS_RDF_N_C },
- { "rname" , GETDNS_RDF_N_C },
- { "serial" , GETDNS_RDF_I4 },
- { "refresh" , GETDNS_RDF_I4 },
- { "retry" , GETDNS_RDF_I4 },
- { "expire" , GETDNS_RDF_I4 },
- { "minimum" , GETDNS_RDF_I4 }};
+ { "mname" , GETDNS_RDF_N_C , NULL },
+ { "rname" , GETDNS_RDF_N_C , NULL },
+ { "serial" , GETDNS_RDF_I4 , NULL },
+ { "refresh" , GETDNS_RDF_I4 , NULL },
+ { "retry" , GETDNS_RDF_I4 , NULL },
+ { "expire" , GETDNS_RDF_I4 , NULL },
+ { "minimum" , GETDNS_RDF_I4 , NULL }};
static _getdns_rdata_def mg_rdata[] = {
- { "mgmname" , GETDNS_RDF_N_C }};
+ { "mgmname" , GETDNS_RDF_N_C , NULL }};
static _getdns_rdata_def mr_rdata[] = {
- { "newname" , GETDNS_RDF_N_C }};
+ { "newname" , GETDNS_RDF_N_C , NULL }};
static _getdns_rdata_def null_rdata[] = {
- { "anything" , GETDNS_RDF_X }};
+ { "anything" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def wks_rdata[] = {
- { "address" , GETDNS_RDF_A },
- { "protocol" , GETDNS_RDF_I1 },
- { "bitmap" , GETDNS_RDF_X }};
+ { "address" , GETDNS_RDF_A , NULL },
+ { "protocol" , GETDNS_RDF_I1 , NULL },
+ { "bitmap" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def ptr_rdata[] = {
- { "ptrdname" , GETDNS_RDF_N_C }};
+ { "ptrdname" , GETDNS_RDF_N_C , NULL }};
static _getdns_rdata_def hinfo_rdata[] = {
- { "cpu" , GETDNS_RDF_S },
- { "os" , GETDNS_RDF_S }};
+ { "cpu" , GETDNS_RDF_S , NULL },
+ { "os" , GETDNS_RDF_S , NULL }};
static _getdns_rdata_def minfo_rdata[] = {
- { "rmailbx" , GETDNS_RDF_N_C },
- { "emailbx" , GETDNS_RDF_N_C }};
+ { "rmailbx" , GETDNS_RDF_N_C , NULL },
+ { "emailbx" , GETDNS_RDF_N_C , NULL }};
static _getdns_rdata_def mx_rdata[] = {
- { "preference" , GETDNS_RDF_I2 },
- { "exchange" , GETDNS_RDF_N_C }};
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "exchange" , GETDNS_RDF_N_C , NULL }};
static _getdns_rdata_def txt_rdata[] = {
- { "txt_strings" , GETDNS_RDF_S_M }};
+ { "txt_strings" , GETDNS_RDF_S_M , NULL }};
static _getdns_rdata_def rp_rdata[] = {
- { "mbox_dname" , GETDNS_RDF_N },
- { "txt_dname" , GETDNS_RDF_N }};
+ { "mbox_dname" , GETDNS_RDF_N , NULL },
+ { "txt_dname" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def afsdb_rdata[] = {
- { "subtype" , GETDNS_RDF_I2 },
- { "hostname" , GETDNS_RDF_N }};
+ { "subtype" , GETDNS_RDF_I2 , NULL },
+ { "hostname" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def x25_rdata[] = {
- { "psdn_address" , GETDNS_RDF_S }};
+ { "psdn_address" , GETDNS_RDF_S , NULL }};
static _getdns_rdata_def isdn_rdata[] = {
- { "isdn_address" , GETDNS_RDF_S },
- { "sa" , GETDNS_RDF_S }};
+ { "isdn_address" , GETDNS_RDF_S , NULL },
+ { "sa" , GETDNS_RDF_S , NULL }};
static _getdns_rdata_def rt_rdata[] = {
- { "preference" , GETDNS_RDF_I2 },
- { "intermediate_host" , GETDNS_RDF_N }};
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "intermediate_host" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def nsap_rdata[] = {
- { "nsap" , GETDNS_RDF_X }};
+ { "nsap" , GETDNS_RDF_X , NULL }};
+static _getdns_rdata_def nsap_ptr_rdata[] = {
+ { "owner" , GETDNS_RDF_S , NULL }};
static _getdns_rdata_def sig_rdata[] = {
- { "sig_obsolete" , GETDNS_RDF_X }};
+ { "sig_obsolete" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def key_rdata[] = {
- { "key_obsolete" , GETDNS_RDF_X }};
+ { "key_obsolete" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def px_rdata[] = {
- { "preference" , GETDNS_RDF_I2 },
- { "map822" , GETDNS_RDF_N },
- { "mapx400" , GETDNS_RDF_N }};
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "map822" , GETDNS_RDF_N , NULL },
+ { "mapx400" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def gpos_rdata[] = {
- { "longitude" , GETDNS_RDF_S },
- { "latitude" , GETDNS_RDF_S },
- { "altitude" , GETDNS_RDF_S }};
+ { "longitude" , GETDNS_RDF_S , NULL },
+ { "latitude" , GETDNS_RDF_S , NULL },
+ { "altitude" , GETDNS_RDF_S , NULL }};
static _getdns_rdata_def aaaa_rdata[] = {
- { "ipv6_address" , GETDNS_RDF_AAAA }};
+ { "ipv6_address" , GETDNS_RDF_AAAA , NULL }};
static _getdns_rdata_def loc_rdata[] = {
- { "loc_obsolete" , GETDNS_RDF_X }};
+ { "loc_obsolete" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def nxt_rdata[] = {
- { "nxt_obsolete" , GETDNS_RDF_X }};
+ { "nxt_obsolete" , GETDNS_RDF_X , NULL }};
+static _getdns_rdata_def eid_rdata[] = {
+ { "endpoint_identifier" , GETDNS_RDF_X , NULL }};
+static _getdns_rdata_def nimloc_rdata[] = {
+ { "nimrod_locator" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def srv_rdata[] = {
- { "priority" , GETDNS_RDF_I2 },
- { "weight" , GETDNS_RDF_I2 },
- { "port" , GETDNS_RDF_I2 },
- { "target" , GETDNS_RDF_N }};
+ { "priority" , GETDNS_RDF_I2 , NULL },
+ { "weight" , GETDNS_RDF_I2 , NULL },
+ { "port" , GETDNS_RDF_I2 , NULL },
+ { "target" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def atma_rdata[] = {
- { "format" , GETDNS_RDF_X }};
+ { "format" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def naptr_rdata[] = {
- { "order" , GETDNS_RDF_I2 },
- { "preference" , GETDNS_RDF_I2 },
- { "flags" , GETDNS_RDF_S },
- { "service" , GETDNS_RDF_S },
- { "regexp" , GETDNS_RDF_S },
- { "replacement" , GETDNS_RDF_N }};
+ { "order" , GETDNS_RDF_I2 , NULL },
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "flags" , GETDNS_RDF_S , NULL },
+ { "service" , GETDNS_RDF_S , NULL },
+ { "regexp" , GETDNS_RDF_S , NULL },
+ { "replacement" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def kx_rdata[] = {
- { "preference" , GETDNS_RDF_I2 },
- { "exchanger" , GETDNS_RDF_N }};
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "exchanger" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def cert_rdata[] = {
- { "type" , GETDNS_RDF_I2 },
- { "key_tag" , GETDNS_RDF_I2 },
- { "algorithm" , GETDNS_RDF_I1 },
- { "certificate_or_crl" , GETDNS_RDF_B }};
+ { "type" , GETDNS_RDF_I2 , NULL },
+ { "key_tag" , GETDNS_RDF_I2 , NULL },
+ { "algorithm" , GETDNS_RDF_I1 , NULL },
+ { "certificate_or_crl" , GETDNS_RDF_B , NULL }};
static _getdns_rdata_def a6_rdata[] = {
- { "a6_obsolete" , GETDNS_RDF_X }};
+ { "a6_obsolete" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def dname_rdata[] = {
- { "target" , GETDNS_RDF_N }};
+ { "target" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def opt_rdata[] = {
- { "options" , GETDNS_RDF_R },
- { "option_code" , GETDNS_RDF_I2 },
- { "option_data" , GETDNS_RDF_X_S }};
+ { "options" , GETDNS_RDF_R , NULL },
+ { "option_code" , GETDNS_RDF_I2 , NULL },
+ { "option_data" , GETDNS_RDF_X_S , NULL }};
static _getdns_rdata_def apl_rdata[] = {
- { "apitems" , GETDNS_RDF_R },
- { "address_family" , GETDNS_RDF_I2 },
- { "prefix" , GETDNS_RDF_I1 },
+ { "apitems" , GETDNS_RDF_R , NULL },
+ { "address_family" , GETDNS_RDF_I2 , NULL },
+ { "prefix" , GETDNS_RDF_I1 , NULL },
{ "n" , GETDNS_RDF_SPECIAL, &apl_n },
{ "afdpart" , GETDNS_RDF_SPECIAL, &apl_afdpart }};
static _getdns_rdata_def ds_rdata[] = {
- { "key_tag" , GETDNS_RDF_I2 },
- { "algorithm" , GETDNS_RDF_I1 },
- { "digest_type" , GETDNS_RDF_I1 },
- { "digest" , GETDNS_RDF_X }};
+ { "key_tag" , GETDNS_RDF_I2 , NULL },
+ { "algorithm" , GETDNS_RDF_I1 , NULL },
+ { "digest_type" , GETDNS_RDF_I1 , NULL },
+ { "digest" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def sshfp_rdata[] = {
- { "algorithm" , GETDNS_RDF_I1 },
- { "fp_type" , GETDNS_RDF_I1 },
- { "fingerprint" , GETDNS_RDF_X }};
+ { "algorithm" , GETDNS_RDF_I1 , NULL },
+ { "fp_type" , GETDNS_RDF_I1 , NULL },
+ { "fingerprint" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def ipseckey_rdata[] = {
- { "algorithm" , GETDNS_RDF_I1 },
- { "gateway_type" , GETDNS_RDF_I1 },
- { "precedence" , GETDNS_RDF_I1 },
+ { "algorithm" , GETDNS_RDF_I1 , NULL },
+ { "gateway_type" , GETDNS_RDF_I1 , NULL },
+ { "precedence" , GETDNS_RDF_I1 , NULL },
{ "gateway" , GETDNS_RDF_SPECIAL, &ipseckey_gateway },
- { "public_key" , GETDNS_RDF_B }};
+ { "public_key" , GETDNS_RDF_B , NULL }};
static _getdns_rdata_def rrsig_rdata[] = {
- { "type_covered" , GETDNS_RDF_I2 },
- { "algorithm" , GETDNS_RDF_I1 },
- { "labels" , GETDNS_RDF_I1 },
- { "original_ttl" , GETDNS_RDF_I4 },
- { "signature_expiration" , GETDNS_RDF_T },
- { "signature_inception" , GETDNS_RDF_T },
- { "key_tag" , GETDNS_RDF_I2 },
- { "signers_name" , GETDNS_RDF_N },
- { "signature" , GETDNS_RDF_B }};
+ { "type_covered" , GETDNS_RDF_I2 , NULL },
+ { "algorithm" , GETDNS_RDF_I1 , NULL },
+ { "labels" , GETDNS_RDF_I1 , NULL },
+ { "original_ttl" , GETDNS_RDF_I4 , NULL },
+ { "signature_expiration" , GETDNS_RDF_T , NULL },
+ { "signature_inception" , GETDNS_RDF_T , NULL },
+ { "key_tag" , GETDNS_RDF_I2 , NULL },
+ { "signers_name" , GETDNS_RDF_N , NULL },
+ { "signature" , GETDNS_RDF_B , NULL }};
static _getdns_rdata_def nsec_rdata[] = {
- { "next_domain_name" , GETDNS_RDF_N },
- { "type_bit_maps" , GETDNS_RDF_X }};
+ { "next_domain_name" , GETDNS_RDF_N , NULL },
+ { "type_bit_maps" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def dnskey_rdata[] = {
- { "flags" , GETDNS_RDF_I2 },
- { "protocol" , GETDNS_RDF_I1 },
- { "algorithm" , GETDNS_RDF_I1 },
- { "public_key" , GETDNS_RDF_B }};
+ { "flags" , GETDNS_RDF_I2 , NULL },
+ { "protocol" , GETDNS_RDF_I1 , NULL },
+ { "algorithm" , GETDNS_RDF_I1 , NULL },
+ { "public_key" , GETDNS_RDF_B , NULL }};
static _getdns_rdata_def dhcid_rdata[] = {
- { "dhcid_opaque" , GETDNS_RDF_B }};
+ { "dhcid_opaque" , GETDNS_RDF_B , NULL }};
static _getdns_rdata_def nsec3_rdata[] = {
- { "hash_algorithm" , GETDNS_RDF_I1 },
- { "flags" , GETDNS_RDF_I1 },
- { "iterations" , GETDNS_RDF_I2 },
- { "salt" , GETDNS_RDF_X_C },
- { "next_hashed_owner_name" , GETDNS_RDF_B32_C},
- { "type_bit_maps" , GETDNS_RDF_X }};
+ { "hash_algorithm" , GETDNS_RDF_I1 , NULL },
+ { "flags" , GETDNS_RDF_I1 , NULL },
+ { "iterations" , GETDNS_RDF_I2 , NULL },
+ { "salt" , GETDNS_RDF_X_C , NULL },
+ { "next_hashed_owner_name" , GETDNS_RDF_B32_C , NULL },
+ { "type_bit_maps" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def nsec3param_rdata[] = {
- { "hash_algorithm" , GETDNS_RDF_I1 },
- { "flags" , GETDNS_RDF_I1 },
- { "iterations" , GETDNS_RDF_I2 },
- { "salt" , GETDNS_RDF_X_C }};
+ { "hash_algorithm" , GETDNS_RDF_I1 , NULL },
+ { "flags" , GETDNS_RDF_I1 , NULL },
+ { "iterations" , GETDNS_RDF_I2 , NULL },
+ { "salt" , GETDNS_RDF_X_C , NULL }};
static _getdns_rdata_def tlsa_rdata[] = {
- { "certificate_usage" , GETDNS_RDF_I1 },
- { "selector" , GETDNS_RDF_I1 },
- { "matching_type" , GETDNS_RDF_I1 },
- { "certificate_association_data", GETDNS_RDF_X }};
+ { "certificate_usage" , GETDNS_RDF_I1 , NULL },
+ { "selector" , GETDNS_RDF_I1 , NULL },
+ { "matching_type" , GETDNS_RDF_I1 , NULL },
+ { "certificate_association_data", GETDNS_RDF_X , NULL }};
static _getdns_rdata_def hip_rdata[] = {
{ "pk_algorithm" , GETDNS_RDF_SPECIAL, &hip_pk_algorithm },
{ "hit" , GETDNS_RDF_SPECIAL, &hip_hit },
{ "public_key" , GETDNS_RDF_SPECIAL, &hip_public_key },
- { "rendezvous_servers" , GETDNS_RDF_N_M }};
+ { "rendezvous_servers" , GETDNS_RDF_N_M , NULL }};
+static _getdns_rdata_def talink_rdata[] = {
+ { "previous" , GETDNS_RDF_N , NULL },
+ { "next" , GETDNS_RDF_N , NULL }};
+static _getdns_rdata_def openpgpkey_rdata[] = {
+ { "transferable_public_key" , GETDNS_RDF_B , NULL }};
static _getdns_rdata_def csync_rdata[] = {
- { "serial" , GETDNS_RDF_I4 },
- { "flags" , GETDNS_RDF_I2 },
- { "type_bit_maps" , GETDNS_RDF_X }};
+ { "serial" , GETDNS_RDF_I4 , NULL },
+ { "flags" , GETDNS_RDF_I2 , NULL },
+ { "type_bit_maps" , GETDNS_RDF_X , NULL }};
static _getdns_rdata_def spf_rdata[] = {
- { "text" , GETDNS_RDF_S_M }};
+ { "text" , GETDNS_RDF_S_M , NULL }};
static _getdns_rdata_def nid_rdata[] = {
- { "preference" , GETDNS_RDF_I2 },
- { "node_id" , GETDNS_RDF_AA }};
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "node_id" , GETDNS_RDF_AA , NULL }};
static _getdns_rdata_def l32_rdata[] = {
- { "preference" , GETDNS_RDF_I2 },
- { "locator32" , GETDNS_RDF_A }};
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "locator32" , GETDNS_RDF_A , NULL }};
static _getdns_rdata_def l64_rdata[] = {
- { "preference" , GETDNS_RDF_I2 },
- { "locator64" , GETDNS_RDF_AA }};
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "locator64" , GETDNS_RDF_AA , NULL }};
static _getdns_rdata_def lp_rdata[] = {
- { "preference" , GETDNS_RDF_I2 },
- { "fqdn" , GETDNS_RDF_N }};
+ { "preference" , GETDNS_RDF_I2 , NULL },
+ { "fqdn" , GETDNS_RDF_N , NULL }};
static _getdns_rdata_def eui48_rdata[] = {
- { "eui48_address" , GETDNS_RDF_X6 }};
+ { "eui48_address" , GETDNS_RDF_X6 , NULL }};
static _getdns_rdata_def eui64_rdata[] = {
- { "eui64_address" , GETDNS_RDF_X8 }};
+ { "eui64_address" , GETDNS_RDF_X8 , NULL }};
static _getdns_rdata_def tkey_rdata[] = {
- { "algorithm" , GETDNS_RDF_N },
- { "inception" , GETDNS_RDF_T },
- { "expiration" , GETDNS_RDF_T },
- { "mode" , GETDNS_RDF_I2 },
- { "error" , GETDNS_RDF_I2 },
- { "key_data" , GETDNS_RDF_X_S },
- { "other_data" , GETDNS_RDF_X_S }};
+ { "algorithm" , GETDNS_RDF_N , NULL },
+ { "inception" , GETDNS_RDF_T , NULL },
+ { "expiration" , GETDNS_RDF_T , NULL },
+ { "mode" , GETDNS_RDF_I2 , NULL },
+ { "error" , GETDNS_RDF_I2 , NULL },
+ { "key_data" , GETDNS_RDF_X_S , NULL },
+ { "other_data" , GETDNS_RDF_X_S , NULL }};
static _getdns_rdata_def tsig_rdata[] = {
- { "algorithm" , GETDNS_RDF_N },
- { "time_signed" , GETDNS_RDF_T6 },
- { "fudge" , GETDNS_RDF_I2 },
- { "mac" , GETDNS_RDF_X_S },
- { "original_id" , GETDNS_RDF_I2 },
- { "error" , GETDNS_RDF_I2 },
- { "other_data" , GETDNS_RDF_X_S }};
+ { "algorithm" , GETDNS_RDF_N , NULL },
+ { "time_signed" , GETDNS_RDF_T6 , NULL },
+ { "fudge" , GETDNS_RDF_I2 , NULL },
+ { "mac" , GETDNS_RDF_X_S , NULL },
+ { "original_id" , GETDNS_RDF_I2 , NULL },
+ { "error" , GETDNS_RDF_I2 , NULL },
+ { "other_data" , GETDNS_RDF_X_S , NULL }};
static _getdns_rdata_def uri_rdata[] = {
- { "priority" , GETDNS_RDF_I2 },
- { "weight" , GETDNS_RDF_I2 },
- { "target" , GETDNS_RDF_S_L }};
+ { "priority" , GETDNS_RDF_I2 , NULL },
+ { "weight" , GETDNS_RDF_I2 , NULL },
+ { "target" , GETDNS_RDF_S_L , NULL }};
static _getdns_rdata_def caa_rdata[] = {
- { "flags" , GETDNS_RDF_I1 },
- { "tag" , GETDNS_RDF_S },
- { "value" , GETDNS_RDF_S_L }};
+ { "flags" , GETDNS_RDF_I1 , NULL },
+ { "tag" , GETDNS_RDF_S , NULL },
+ { "value" , GETDNS_RDF_S_L , NULL }};
static _getdns_rdata_def dlv_rdata[] = {
- { "key_tag" , GETDNS_RDF_I2 },
- { "algorithm" , GETDNS_RDF_I1 },
- { "digest_type" , GETDNS_RDF_I1 },
- { "digest" , GETDNS_RDF_X }};
+ { "key_tag" , GETDNS_RDF_I2 , NULL },
+ { "algorithm" , GETDNS_RDF_I1 , NULL },
+ { "digest_type" , GETDNS_RDF_I1 , NULL },
+ { "digest" , GETDNS_RDF_X , NULL }};
static _getdns_rr_def _getdns_rr_defs[] = {
{ NULL, NULL, 0 },
@@ -777,17 +684,17 @@ static _getdns_rr_def _getdns_rr_defs[] = {
{ "X25", x25_rdata, ALEN( x25_rdata) },
{ "ISDN", isdn_rdata, ALEN( isdn_rdata) },
{ "RT", rt_rdata, ALEN( rt_rdata) },
- { "NSAP", nsap_rdata, ALEN( nsap_rdata) }, /* - 22 */
- { NULL, NULL, 0 },
- { "SIG", sig_rdata, ALEN( sig_rdata) }, /* 24 - */
+ { "NSAP", nsap_rdata, ALEN( nsap_rdata) },
+ { "NSAP_PTR", nsap_ptr_rdata, ALEN( nsap_ptr_rdata) },
+ { "SIG", sig_rdata, ALEN( sig_rdata) },
{ "KEY", key_rdata, ALEN( key_rdata) },
{ "PX", px_rdata, ALEN( px_rdata) },
{ "GPOS", gpos_rdata, ALEN( gpos_rdata) },
{ "AAAA", aaaa_rdata, ALEN( aaaa_rdata) },
{ "LOC", loc_rdata, ALEN( loc_rdata) },
{ "NXT", nxt_rdata, ALEN( nxt_rdata) },
- { "EID", UNKNOWN_RDATA, 0 },
- { "NIMLOC", UNKNOWN_RDATA, 0 },
+ { "EID", eid_rdata, ALEN( eid_rdata) },
+ { "NIMLOC", nimloc_rdata, ALEN( nimloc_rdata) },
{ "SRV", srv_rdata, ALEN( srv_rdata) },
{ "ATMA", atma_rdata, ALEN( atma_rdata) },
{ "NAPTR", naptr_rdata, ALEN( naptr_rdata) },
@@ -807,16 +714,16 @@ static _getdns_rr_def _getdns_rr_defs[] = {
{ "DHCID", dhcid_rdata, ALEN( dhcid_rdata) },
{ "NSEC3", nsec3_rdata, ALEN( nsec3_rdata) },
{ "NSEC3PARAM", nsec3param_rdata, ALEN(nsec3param_rdata) },
- { "TLSA", tlsa_rdata, ALEN( tlsa_rdata) }, /* - 52 */
- { NULL, NULL, 0 },
+ { "TLSA", tlsa_rdata, ALEN( tlsa_rdata) },
+ { "SMIMEA", tlsa_rdata, ALEN( tlsa_rdata) }, /* - 53 */
{ NULL, NULL, 0 },
{ "HIP", hip_rdata, ALEN( hip_rdata) }, /* 55 - */
{ "NINFO", UNKNOWN_RDATA, 0 },
{ "RKEY", UNKNOWN_RDATA, 0 },
- { "TALINK", UNKNOWN_RDATA, 0 },
+ { "TALINK", talink_rdata, ALEN( talink_rdata) },
{ "CDS", ds_rdata, ALEN( ds_rdata) },
{ "CDNSKEY", dnskey_rdata, ALEN( dnskey_rdata) },
- { "OPENPGPKEY", UNKNOWN_RDATA, 0 }, /* 61 - */
+ { "OPENPGPKEY", openpgpkey_rdata, ALEN(openpgpkey_rdata) }, /* 61 - */
{ "CSYNC", csync_rdata, ALEN( csync_rdata) }, /* - 62 */
{ NULL, NULL, 0 },
{ NULL, NULL, 0 },
@@ -1012,20 +919,21 @@ static _getdns_rr_def _getdns_rr_defs[] = {
{ "MAILA", UNKNOWN_RDATA, 0 }, /* - 254 */
{ NULL, NULL, 0 },
{ "URI", uri_rdata, ALEN( uri_rdata) }, /* 256 - */
- { "CAA", caa_rdata, ALEN( caa_rdata) }, /* - 257 */
- { "TA", UNKNOWN_RDATA, 0 }, /* 32768 */
+ { "CAA", caa_rdata, ALEN( caa_rdata) },
+ { "AVC", txt_rdata, ALEN( txt_rdata) }, /* - 258 */
+ { "TA", ds_rdata, ALEN( ds_rdata) }, /* 32768 */
{ "DLV", dlv_rdata, ALEN( dlv_rdata) } /* 32769 */
};
const _getdns_rr_def *
_getdns_rr_def_lookup(uint16_t rr_type)
{
- if (rr_type <= 257)
+ if (rr_type <= 258)
return &_getdns_rr_defs[rr_type];
else if (rr_type == 32768)
- return &_getdns_rr_defs[258];
- else if (rr_type == 32769)
return &_getdns_rr_defs[259];
+ else if (rr_type == 32769)
+ return &_getdns_rr_defs[260];
return _getdns_rr_defs;
}
@@ -1115,7 +1023,12 @@ write_rdata_field(gldns_buffer *buf, uint8_t *rdata_start,
return GETDNS_RETURN_GENERIC_ERROR;
} else if (!(rd_def->type & GETDNS_RDF_REPEAT)) {
-
+ /*
+ * Non repetitive special rdatafield,
+ * We must have a dict2wire function
+ */
+ assert(rd_def->special->dict2wire);
+
rdf_len = gldns_buffer_remaining(buf);
r = rd_def->special->dict2wire(rdata, rdata_start,
gldns_buffer_current(buf), &rdf_len);
@@ -1125,12 +1038,21 @@ write_rdata_field(gldns_buffer *buf, uint8_t *rdata_start,
if (r)
return r;
+ /* We do not have repetitive special rdata fields (yet)
+ *
+ * LCOV_EXCL_START
+ */
} else if ((r = getdns_dict_get_list(rdata, rd_def->name, &list))) {
return r == GETDNS_RETURN_NO_SUCH_DICT_NAME
? GETDNS_RETURN_GOOD : r;
} else for ( i = 0; r == GETDNS_RETURN_GOOD; i++ ) {
+ /*
+ * A repetitive special rdata field must have the list2wire
+ * function.
+ */
+ assert(rd_def->special->list2wire);
rdf_len = gldns_buffer_remaining(buf);
r = rd_def->special->list2wire(list, i, rdata_start,
@@ -1139,6 +1061,7 @@ write_rdata_field(gldns_buffer *buf, uint8_t *rdata_start,
r == GETDNS_RETURN_NEED_MORE_SPACE)
gldns_buffer_skip(buf, rdf_len);
}
+ /* LCOV_EXCL_STOP */
return r != GETDNS_RETURN_NO_SUCH_LIST_ITEM ? r : GETDNS_RETURN_GOOD;
}
diff --git a/src/rr-dict.h b/src/rr-dict.h
index 6ab52b88..e19e0387 100644
--- a/src/rr-dict.h
+++ b/src/rr-dict.h
@@ -138,7 +138,7 @@ typedef struct _getdns_rdata_def {
typedef struct _getdns_rr_def {
const char *name;
const _getdns_rdata_def *rdata;
- int n_rdata_fields;
+ size_t n_rdata_fields;
} _getdns_rr_def;
const _getdns_rr_def *_getdns_rr_def_lookup(uint16_t rr_type);
diff --git a/src/rr-iter.c b/src/rr-iter.c
index 9b332603..7d57ace7 100644
--- a/src/rr-iter.c
+++ b/src/rr-iter.c
@@ -75,8 +75,8 @@ find_rrtype(_getdns_rr_iter *i)
/* Past the last RR in the pkt */
if (i->pkt &&
- GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) +
- GLDNS_NSCOUNT(i->pkt) + GLDNS_ARCOUNT(i->pkt) <= i->n)
+ (size_t)GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) +
+ GLDNS_NSCOUNT(i->pkt) + GLDNS_ARCOUNT(i->pkt) <= i->n)
goto done;
for (pos = i->pos; pos + 4 < i->pkt_end; pos += *pos + 1)
@@ -101,7 +101,7 @@ done:
}
_getdns_rr_iter *
-_getdns_rr_iter_init(_getdns_rr_iter *i, const uint8_t *pkt, size_t pkt_len)
+_getdns_rr_iter_init(_getdns_rr_iter *i, const uint8_t *pkt, const size_t pkt_len)
{
assert(i);
@@ -119,7 +119,7 @@ _getdns_rr_iter_init(_getdns_rr_iter *i, const uint8_t *pkt, size_t pkt_len)
_getdns_rr_iter *
_getdns_single_rr_iter_init(
- _getdns_rr_iter *i, const uint8_t *wire, size_t wire_len)
+ _getdns_rr_iter *i, const uint8_t *wire, const size_t wire_len)
{
assert(i);
@@ -518,8 +518,16 @@ rdf_iter_find_nxt(_getdns_rdf_iter *i)
/* Empty rdata fields are only allowed in case of non-repeating
* remaining data. So only the GETDNS_RDF_BINDATA bit is set.
+ *
+ * There is one exception, the IPSECKEY has an empty special rdata
+ * field "gateway" when another rdata field, "gateway_type" is 0.
+ * In general, the special wire2dict or list functions should
+ * handle this case themselves, so allow for 0 sized RDF_SPECIAL
+ * typed rdata fields too.
*/
- (i->nxt > i->pos || (i->rdd_pos->type == GETDNS_RDF_BINDATA)))
+ ( i->nxt > i->pos
+ || i->rdd_pos->type == GETDNS_RDF_BINDATA
+ || i->rdd_pos->type == GETDNS_RDF_SPECIAL))
return i;
done:
i->pos = NULL;
diff --git a/src/rr-iter.h b/src/rr-iter.h
index d657d484..d440d939 100644
--- a/src/rr-iter.h
+++ b/src/rr-iter.h
@@ -76,7 +76,7 @@ _getdns_rr_iter *_getdns_single_rr_iter_init(_getdns_rr_iter *i,
const uint8_t *wire, const size_t wire_len);
static inline _getdns_rr_iter *_getdns_rr_iter_rewind(_getdns_rr_iter *i)
-{ return _getdns_rr_iter_init(i, i->pkt, i->pkt_end - i->pkt); }
+{ return i ? _getdns_rr_iter_init(i, i->pkt, i->pkt_end - i->pkt) : NULL; }
_getdns_rr_iter *_getdns_rr_iter_next(_getdns_rr_iter *i);
@@ -86,19 +86,19 @@ const uint8_t *_getdns_owner_if_or_as_decompressed(
static inline _getdns_section
_getdns_rr_iter_section(_getdns_rr_iter *i)
{
- return !i->pkt ? (i->nxt - i->rr_type == 4 ? SECTION_QUESTION
- : SECTION_ANSWER )
- : i->n < GLDNS_QDCOUNT(i->pkt) ? SECTION_QUESTION
- : i->n < GLDNS_QDCOUNT(i->pkt)
- + GLDNS_ANCOUNT(i->pkt) ? SECTION_ANSWER
- : i->n < GLDNS_QDCOUNT(i->pkt)
- + GLDNS_ANCOUNT(i->pkt)
- + GLDNS_NSCOUNT(i->pkt) ? SECTION_AUTHORITY
- : i->n < GLDNS_QDCOUNT(i->pkt)
- + GLDNS_ANCOUNT(i->pkt)
- + GLDNS_NSCOUNT(i->pkt)
- + GLDNS_ARCOUNT(i->pkt) ? SECTION_ADDITIONAL
- : SECTION_ANY;
+ return ! i->pkt ? (i->nxt - i->rr_type == 4 ? SECTION_QUESTION
+ : SECTION_ANSWER )
+ : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) ? SECTION_QUESTION
+ : i->n < (size_t)GLDNS_QDCOUNT(i->pkt)
+ + GLDNS_ANCOUNT(i->pkt) ? SECTION_ANSWER
+ : i->n < (size_t)GLDNS_QDCOUNT(i->pkt)
+ + GLDNS_ANCOUNT(i->pkt)
+ + GLDNS_NSCOUNT(i->pkt) ? SECTION_AUTHORITY
+ : i->n < (size_t)GLDNS_QDCOUNT(i->pkt)
+ + GLDNS_ANCOUNT(i->pkt)
+ + GLDNS_NSCOUNT(i->pkt)
+ + GLDNS_ARCOUNT(i->pkt) ? SECTION_ADDITIONAL
+ : SECTION_ANY;
}
/* Utility functions to read rr_type and rr_class from a rr iterator */
@@ -181,7 +181,7 @@ static inline _getdns_rrset *_getdns_rrset_iter_value(_getdns_rrset_iter *i)
{ return i && i->rr_i.pos ? &i->rrset : NULL; }
static inline _getdns_rrset_iter *_getdns_rrset_iter_rewind(_getdns_rrset_iter *i)
-{ return _getdns_rrset_iter_init(i, i->rrset.pkt, i->rrset.pkt_len, i->rrset.sections); }
+{ return i ? _getdns_rrset_iter_init(i, i->rrset.pkt, i->rrset.pkt_len, i->rrset.sections) : NULL; }
typedef struct _getdns_rdf_iter {
const uint8_t *pkt;
diff --git a/src/server.c b/src/server.c
index 9e4caa76..05267b60 100644
--- a/src/server.c
+++ b/src/server.c
@@ -26,7 +26,14 @@
*/
#include "config.h"
+
+#ifndef USE_WINSOCK
#include
+#else
+#include
+#include
+#endif
+
#include "getdns/getdns_extra.h"
#include "context.h"
#include "types-internal.h"
@@ -65,6 +72,7 @@ struct listener {
*/
struct listen_set {
getdns_context *context;
+ void *userarg;
getdns_request_handler_t handler;
_getdns_rbtree_t connections_set;
@@ -100,9 +108,9 @@ typedef struct tcp_connection {
getdns_eventloop_event event;
uint8_t *read_buf;
- size_t read_buf_len;
+ ssize_t read_buf_len;
uint8_t *read_pos;
- size_t to_read;
+ ssize_t to_read;
tcp_to_write *to_write;
size_t to_answer;
@@ -127,7 +135,11 @@ static void tcp_connection_destroy(tcp_connection *conn)
loop->vmt->clear(loop, &conn->event);
if (conn->fd >= 0)
+#ifdef USE_WINSOCK
+ (void) closesocket(conn->fd);
+#else
(void) close(conn->fd);
+#endif
GETDNS_FREE(*mf, conn->read_buf);
for (cur = conn->to_write; cur; cur = next) {
@@ -177,8 +189,8 @@ static void tcp_write_cb(void *userarg)
}
to_write = conn->to_write;
if (conn->fd == -1 ||
- (written = write(conn->fd, &to_write->write_buf[to_write->written],
- to_write->write_buf_len - to_write->written)) == -1) {
+ (written = send(conn->fd, &to_write->write_buf[to_write->written],
+ to_write->write_buf_len - to_write->written, 0)) == -1) {
/* IO error, close connection */
conn->event.read_cb = conn->event.write_cb =
@@ -231,7 +243,7 @@ _getdns_cancel_reply(getdns_context *context, connection *conn)
getdns_return_t
getdns_reply(
- getdns_context *context, getdns_transaction_t request_id, getdns_dict *reply)
+ getdns_context *context, getdns_dict *reply, getdns_transaction_t request_id)
{
/* TODO: Check request_id at context->outbound_requests */
connection *conn = (connection *)(intptr_t)request_id;
@@ -268,11 +280,15 @@ getdns_reply(
else if (conn->l->transport == GETDNS_TRANSPORT_UDP) {
listener *l = conn->l;
- if (conn->l->fd >= 0 && sendto(conn->l->fd, buf, len, 0,
+ if (conn->l->fd >= 0 && sendto(conn->l->fd, (void *)buf, len, 0,
(struct sockaddr *)&conn->remote_in, conn->addrlen) == -1) {
/* IO error, cleanup this listener */
loop->vmt->clear(loop, &conn->l->event);
+#ifdef USE_WINSOCK
+ closesocket(conn->l->fd);
+#else
close(conn->l->fd);
+#endif
conn->l->fd = -1;
}
/* Unlink this connection */
@@ -351,7 +367,7 @@ static void tcp_read_cb(void *userarg)
(void) loop->vmt->schedule(loop, conn->fd,
DOWNSTREAM_IDLE_TIMEOUT, &conn->event);
- if ((bytes_read = read(conn->fd, conn->read_pos, conn->to_read)) == -1) {
+ if ((bytes_read = recv(conn->fd, conn->read_pos, conn->to_read, 0)) < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
return; /* Come back to do the read later */
@@ -400,9 +416,14 @@ static void tcp_read_cb(void *userarg)
else {
conn->to_answer++;
+ /* TODO: wish list item:
+ * (void) getdns_dict_set_int64(
+ * request_dict, "request_id", intptr_t)conn);
+ */
/* Call request handler */
conn->super.l->set->handler(
- conn->super.l->set->context, request_dict, (intptr_t)conn);
+ conn->super.l->set->context, GETDNS_CALLBACK_COMPLETE,
+ request_dict, conn->super.l->set->userarg, (intptr_t)conn);
conn->read_pos = conn->read_buf;
conn->to_read = 2;
@@ -460,7 +481,11 @@ static void tcp_accept_cb(void *userarg)
&conn->super.remote_in, &conn->super.addrlen)) == -1) {
/* IO error, cleanup this listener */
loop->vmt->clear(loop, &l->event);
+#ifdef USE_WINSOCK
+ closesocket(l->fd);
+#else
close(l->fd);
+#endif
l->fd = -1;
GETDNS_FREE(*mf, conn);
return;
@@ -526,11 +551,15 @@ static void udp_read_cb(void *userarg)
conn->l = l;
conn->addrlen = sizeof(conn->remote_in);
- if ((len = recvfrom(l->fd, buf, sizeof(buf), 0,
+ if ((len = recvfrom(l->fd, (void *)buf, sizeof(buf), 0,
(struct sockaddr *)&conn->remote_in, &conn->addrlen)) == -1) {
/* IO error, cleanup this listener. */
loop->vmt->clear(loop, &l->event);
+#ifdef USE_WINSOCK
+ closesocket(l->fd);
+#else
close(l->fd);
+#endif
l->fd = -1;
#if 0 && defined(SERVER_DEBUG) && SERVER_DEBUG
@@ -618,8 +647,14 @@ static void udp_read_cb(void *userarg)
conn->prev_next = &l->connections;
l->connections = conn;
+ /* TODO: wish list item:
+ * (void) getdns_dict_set_int64(
+ * request_dict, "request_id", (intptr_t)conn);
+ */
/* Call request handler */
- l->set->handler(l->set->context, request_dict, (intptr_t)conn);
+ l->set->handler(l->set->context, GETDNS_CALLBACK_COMPLETE,
+ request_dict, l->set->userarg, (intptr_t)conn);
+
return;
}
GETDNS_FREE(*mf, conn);
@@ -636,7 +671,7 @@ static void free_listen_set_when_done(listen_set *set)
if (!(mf = &set->context->mf))
return;
- DEBUG_SERVER("To free listen set: %p\n", set);
+ DEBUG_SERVER("To free listen set: %p\n", (void *)set);
for (i = 0; i < set->count; i++) {
listener *l = &set->items[i];
@@ -647,7 +682,7 @@ static void free_listen_set_when_done(listen_set *set)
return;
}
GETDNS_FREE(*mf, set);
- DEBUG_SERVER("Listen set: %p freed\n", set);
+ DEBUG_SERVER("Listen set: %p freed\n", (void *)set);
}
static void remove_listeners(listen_set *set)
@@ -673,7 +708,11 @@ static void remove_listeners(listen_set *set)
continue;
loop->vmt->clear(loop, &l->event);
+#ifdef USE_WINSOCK
+ closesocket(l->fd);
+#else
close(l->fd);
+#endif
l->fd = -1;
if (l->transport != GETDNS_TRANSPORT_TCP)
@@ -692,7 +731,11 @@ static void remove_listeners(listen_set *set)
static getdns_return_t add_listeners(listen_set *set)
{
+#ifdef USE_WINSOCK
+ static const char enable = 1;
+#else
static const int enable = 1;
+#endif
struct mem_funcs *mf;
getdns_eventloop *loop;
@@ -726,9 +769,9 @@ static getdns_return_t add_listeners(listen_set *set)
break;
if (setsockopt(l->fd, SOL_SOCKET, SO_REUSEADDR,
- &enable, sizeof(int)) < 0)
+ &enable, sizeof(int)) < 0) {
; /* Ignore */
-
+ }
if (bind(l->fd, (struct sockaddr *)&l->addr,
l->addr_len) == -1)
/* IO error */
@@ -765,9 +808,9 @@ ptr_cmp(const void *a, const void *b)
return a == b ? 0 : (a < b ? -1 : 1);
}
-getdns_return_t getdns_context_set_listen_addresses(getdns_context *context,
- getdns_request_handler_t request_handler,
- const getdns_list *listen_addresses)
+getdns_return_t getdns_context_set_listen_addresses(
+ getdns_context *context, const getdns_list *listen_addresses,
+ void *userarg, getdns_request_handler_t request_handler)
{
static const getdns_transport_list_t listen_transports[]
= { GETDNS_TRANSPORT_UDP, GETDNS_TRANSPORT_TCP };
@@ -786,10 +829,9 @@ getdns_return_t getdns_context_set_listen_addresses(getdns_context *context,
size_t i;
struct addrinfo hints;
- DEBUG_SERVER("getdns_context_set_listen_addresses(%p, %p, %p)\n",
- context, request_handler,
+ DEBUG_SERVER("getdns_context_set_listen_addresses(%p, , %p)\n",
+ (void *)context, (void *)listen_addresses);
- listen_addresses);
if (!(mf = &context->mf))
return GETDNS_RETURN_GENERIC_ERROR;
@@ -826,10 +868,11 @@ getdns_return_t getdns_context_set_listen_addresses(getdns_context *context,
_getdns_rbtree_init(&new_set->connections_set, ptr_cmp);
DEBUG_SERVER("New listen set: %p, current_set: %p\n",
- new_set, current_set);
+ (void *)new_set, (void *)current_set);
new_set->context = context;
new_set->handler = request_handler;
+ new_set->userarg = userarg;
new_set->count = new_set_count * n_transports;
(void) memset(new_set->items, 0,
sizeof(listener) * new_set_count * n_transports);
@@ -952,15 +995,16 @@ getdns_return_t getdns_context_set_listen_addresses(getdns_context *context,
connection *conn;
loop->vmt->clear(loop, &l->to_replace->event);
- (void) memset(&l->to_replace->event, 0,
- sizeof(getdns_eventloop_event));
l->fd = l->to_replace->fd;
l->event = l->to_replace->event;
+ l->event.userarg = l;
l->connections = l->to_replace->connections;
for (conn = l->connections; conn; conn = conn->next)
conn->l = l;
+ (void) memset(&l->to_replace->event, 0,
+ sizeof(getdns_eventloop_event));
l->to_replace->connections = NULL;
l->to_replace->fd = -1;
diff --git a/src/stub.c b/src/stub.c
index 2b6f9c36..de8121dd 100644
--- a/src/stub.c
+++ b/src/stub.c
@@ -32,6 +32,23 @@
*/
#include "config.h"
+
+/* Intercept and do not sent out COM DS queries with TLS
+ * For debugging purposes only. Never commit with this turned on.
+ */
+#define INTERCEPT_COM_DS 0
+
+#ifdef USE_POLL_DEFAULT_EVENTLOOP
+# ifdef HAVE_SYS_POLL_H
+# include
+# else
+#ifdef USE_WINSOCK
+#define poll(fdarray, nbsockets, timer) WSAPoll(fdarray, nbsockets, timer)
+#else
+# include
+#endif
+# endif
+#endif
#include "debug.h"
#include
#include
@@ -54,15 +71,18 @@ typedef u_short sa_family_t;
#define _getdns_EWOULDBLOCK (WSAGetLastError() == WSATRY_AGAIN ||\
WSAGetLastError() == WSAEWOULDBLOCK)
#define _getdns_EINPROGRESS (WSAGetLastError() == WSAEINPROGRESS)
+#define _getdns_EMFILE (WSAGetLastError() == WSAEMFILE)
#else
#define _getdns_EWOULDBLOCK (errno == EAGAIN || errno == EWOULDBLOCK)
#define _getdns_EINPROGRESS (errno == EINPROGRESS)
+#define _getdns_EMFILE (errno == EMFILE)
#endif
/* WSA TODO:
* STUB_TCP_WOULDBLOCK added to deal with edge triggered event loops (versus
* level triggered). See also lines containing WSA TODO below...
*/
+#define STUB_TRY_AGAIN_LATER -24 /* EMFILE, i.e. Out of OS resources */
#define STUB_NO_AUTH -8 /* Existing TLS connection is not authenticated */
#define STUB_CONN_GONE -7 /* Connection has failed, clear queue*/
#define STUB_TCP_WOULDBLOCK -6
@@ -86,7 +106,7 @@ static void upstream_idle_timeout_cb(void *userarg);
static void upstream_schedule_netreq(getdns_upstream *upstream,
getdns_network_req *netreq);
static void upstream_reschedule_events(getdns_upstream *upstream,
- size_t idle_timeout);
+ uint64_t idle_timeout);
static int upstream_working_ok(getdns_upstream *upstream);
static int upstream_auth_status_ok(getdns_upstream *upstream,
getdns_network_req *netreq);
@@ -96,7 +116,7 @@ static int upstream_connect(getdns_upstream *upstream,
static int fallback_on_write(getdns_network_req *netreq);
static void stub_timeout_cb(void *userarg);
-static uint64_t _getdns_get_time_as_uintt64();
+uint64_t _getdns_get_time_as_uintt64();
/*****************************/
/* General utility functions */
/*****************************/
@@ -252,7 +272,7 @@ match_edns_opt_rr(uint16_t code, uint8_t *response, size_t response_len,
(void) gldns_wire2str_rr_scan(
&data, &data_len, &str, &str_len, (uint8_t *)rr_iter->pkt, rr_iter->pkt_end - rr_iter->pkt);
DEBUG_STUB("%s %-35s: OPT RR: %s",
- STUB_DEBUG_READ, __FUNCTION__, str_spc);
+ STUB_DEBUG_READ, __FUNC__, str_spc);
#endif
/* OPT found, now search for the specified option */
@@ -342,12 +362,20 @@ process_keepalive(
/* Use server sent value unless the client specified a shorter one.
Convert to ms first (wire value has units of 100ms) */
uint64_t server_keepalive = ((uint64_t)gldns_read_uint16(position))*100;
+ DEBUG_STUB("%s %-35s: FD: %d Server Keepalive received: %d ms\n",
+ STUB_DEBUG_READ, __FUNC__, upstream->fd,
+ (int)server_keepalive);
if (netreq->owner->context->idle_timeout < server_keepalive)
upstream->keepalive_timeout = netreq->owner->context->idle_timeout;
else {
+ if (server_keepalive == 0) {
+ /* This means the server wants us to shut the connection (sending no
+ more queries). */
+ upstream->keepalive_shutdown = 1;
+ }
upstream->keepalive_timeout = server_keepalive;
DEBUG_STUB("%s %-35s: FD: %d Server Keepalive used: %d ms\n",
- STUB_DEBUG_READ, __FUNCTION__, upstream->fd,
+ STUB_DEBUG_READ, __FUNC__, upstream->fd,
(int)server_keepalive);
}
}
@@ -377,7 +405,7 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport)
{
int fd = -1;
DEBUG_STUB("%s %-35s: Creating TCP connection: %p\n", STUB_DEBUG_SETUP,
- __FUNCTION__, upstream);
+ __FUNC__, (void*)upstream);
if ((fd = socket(upstream->addr.ss_family, SOCK_STREAM, IPPROTO_TCP)) == -1)
return -1;
@@ -390,27 +418,33 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport)
if (transport == GETDNS_TRANSPORT_TCP)
return fd;
#elif USE_OSX_TCP_FASTOPEN
+ (void)transport;
sa_endpoints_t endpoints;
endpoints.sae_srcif = 0;
endpoints.sae_srcaddr = NULL;
endpoints.sae_srcaddrlen = 0;
endpoints.sae_dstaddr = (struct sockaddr *)&upstream->addr;
endpoints.sae_dstaddrlen = upstream->addr_len;
- if (connectx(fd, &endpoints, SAE_ASSOCID_ANY,
+ if (connectx(fd, &endpoints, SAE_ASSOCID_ANY,
CONNECT_DATA_IDEMPOTENT | CONNECT_RESUME_ON_READ_WRITE,
- NULL, 0, NULL, NULL) == -1) {
- if (errno != EINPROGRESS) {
- close(fd);
- return -1;
- }
+ NULL, 0, NULL, NULL) == 0) {
+ return fd;
}
- return fd;
+ if (errno == EINPROGRESS) {
+ return fd;
+ }
+#else
+ (void)transport;
#endif
if (connect(fd, (struct sockaddr *)&upstream->addr,
upstream->addr_len) == -1) {
if (_getdns_EINPROGRESS || _getdns_EWOULDBLOCK)
return fd;
+#ifdef USE_WINSOCK
+ closesocket(fd);
+#else
close(fd);
+#endif
return -1;
}
return fd;
@@ -466,22 +500,20 @@ static void
stub_cleanup(getdns_network_req *netreq)
{
DEBUG_STUB("%s %-35s: MSG: %p\n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, netreq);
+ STUB_DEBUG_CLEANUP, __FUNC__, (void*)netreq);
getdns_dns_req *dnsreq = netreq->owner;
getdns_network_req *r, *prev_r;
getdns_upstream *upstream;
- intptr_t query_id_intptr;
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
/* Nothing globally scheduled? Then nothing queued */
- if (!(upstream = netreq->upstream)->event.ev)
+ if (!netreq->upstream || !(upstream = netreq->upstream)->event.ev)
return;
/* Delete from upstream->netreq_by_query_id (if present) */
- query_id_intptr = (intptr_t)netreq->query_id;
- (void) _getdns_rbtree_delete(
- &upstream->netreq_by_query_id, (void *)query_id_intptr);
+ (void) _getdns_rbtree_delete(&upstream->netreq_by_query_id,
+ (void *)(intptr_t)GLDNS_ID_WIRE(netreq->query));
/* Delete from upstream->write_queue (if present) */
for (prev_r = NULL, r = upstream->write_queue; r;
@@ -505,8 +537,10 @@ stub_cleanup(getdns_network_req *netreq)
static void
upstream_failed(getdns_upstream *upstream, int during_setup)
{
- DEBUG_STUB("%s %-35s: FD: %d During setup = %d\n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd, during_setup);
+ getdns_network_req *netreq;
+
+ DEBUG_STUB("%s %-35s: FD: %d Failure during connection setup = %d\n",
+ STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd, during_setup);
/* Fallback code should take care of queue queries and then close conn
when idle.*/
/* [TLS1]TODO: Work out how to re-open the connection and re-try
@@ -514,9 +548,14 @@ upstream_failed(getdns_upstream *upstream, int during_setup)
if (during_setup) {
/* Reset timeout on setup failure to trigger fallback handling.*/
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
- GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd, TIMEOUT_FOREVER,
- getdns_eventloop_event_init(&upstream->event, upstream,
- NULL, upstream_write_cb, NULL));
+ /* Need this check because if the setup failed because the interface is
+ not up we get -1 and then a seg fault. Found when using IPv6 address
+ but IPv6 interface not enabled.*/
+ if (upstream->fd != -1) {
+ GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd, TIMEOUT_FOREVER,
+ getdns_eventloop_event_init(&upstream->event, upstream,
+ NULL, upstream_write_cb, NULL));
+ }
/* Special case if failure was due to authentication issues since this
upstream could be used oppotunistically with no problem.*/
if (!(upstream->transport == GETDNS_TRANSPORT_TLS &&
@@ -525,16 +564,14 @@ upstream_failed(getdns_upstream *upstream, int during_setup)
} else {
upstream->conn_shutdowns++;
/* [TLS1]TODO: Re-try these queries if possible.*/
- getdns_network_req *netreq;
- while (upstream->netreq_by_query_id.count) {
- netreq = (getdns_network_req *)
- _getdns_rbtree_first(&upstream->netreq_by_query_id);
- stub_cleanup(netreq);
- netreq->state = NET_REQ_FINISHED;
- _getdns_check_dns_req_complete(netreq->owner);
- }
}
-
+ while (upstream->netreq_by_query_id.count) {
+ netreq = (getdns_network_req *)
+ _getdns_rbtree_first(&upstream->netreq_by_query_id);
+ stub_cleanup(netreq);
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
+ _getdns_check_dns_req_complete(netreq->owner);
+ }
upstream->conn_state = GETDNS_CONN_TEARDOWN;
}
@@ -542,9 +579,16 @@ void
_getdns_cancel_stub_request(getdns_network_req *netreq)
{
DEBUG_STUB("%s %-35s: MSG: %p\n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, netreq);
+ STUB_DEBUG_CLEANUP, __FUNC__, (void*)netreq);
stub_cleanup(netreq);
- if (netreq->fd >= 0) close(netreq->fd);
+ if (netreq->fd >= 0) {
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
+ close(netreq->fd);
+#endif
+ netreq->fd = -1;
+ }
}
static void
@@ -552,12 +596,23 @@ stub_timeout_cb(void *userarg)
{
getdns_network_req *netreq = (getdns_network_req *)userarg;
DEBUG_STUB("%s %-35s: MSG: %p\n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, netreq);
+ STUB_DEBUG_CLEANUP, __FUNC__, (void*)netreq);
stub_cleanup(netreq);
- netreq->state = NET_REQ_TIMED_OUT;
+ _getdns_netreq_change_state(netreq, NET_REQ_TIMED_OUT);
/* Handle upstream*/
if (netreq->fd >= 0) {
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
close(netreq->fd);
+#endif
+ netreq->fd = -1;
+ netreq->upstream->udp_timeouts++;
+ if (netreq->upstream->udp_timeouts % 100 == 0)
+ _getdns_upstream_log(netreq->upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Upstream stats: Transport=UDP - Resp=%d,Timeouts=%d\n",
+ netreq->upstream->addr_str,
+ (int)netreq->upstream->udp_responses, (int)netreq->upstream->udp_timeouts);
stub_next_upstream(netreq);
} else {
netreq->upstream->responses_timeouts++;
@@ -565,7 +620,7 @@ stub_timeout_cb(void *userarg)
if (netreq->owner->user_callback) {
netreq->debug_end_time = _getdns_get_time_as_uintt64();
/* Note this calls cancel_request which calls stub_cleanup again....!*/
- (void) _getdns_context_request_timed_out(netreq->owner);
+ _getdns_context_request_timed_out(netreq->owner);
} else
_getdns_check_dns_req_complete(netreq->owner);
}
@@ -575,7 +630,7 @@ upstream_idle_timeout_cb(void *userarg)
{
getdns_upstream *upstream = (getdns_upstream *)userarg;
DEBUG_STUB("%s %-35s: FD: %d Closing connection\n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd);
+ STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd);
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
upstream->event.timeout_cb = NULL;
upstream->event.read_cb = NULL;
@@ -586,9 +641,17 @@ upstream_idle_timeout_cb(void *userarg)
static void
upstream_setup_timeout_cb(void *userarg)
{
+ int ret;
getdns_upstream *upstream = (getdns_upstream *)userarg;
+#ifdef USE_POLL_DEFAULT_EVENTLOOP
+ struct pollfd fds;
+#else
+ fd_set fds;
+ struct timeval tval;
+#endif
+
DEBUG_STUB("%s %-35s: FD: %d\n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd);
+ STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd);
/* Clean up and trigger a write to let the fallback code to its job */
upstream_failed(upstream, 1);
@@ -596,17 +659,20 @@ upstream_setup_timeout_cb(void *userarg)
* TCP SYN and doesn't do a reset (as is the case with e.g. 8.8.8.8@853).
* For that case the socket never becomes writable so doesn't trigger any
* callbacks. If so then clear out the queue in one go.*/
- int ret;
- fd_set fds;
+#ifdef USE_POLL_DEFAULT_EVENTLOOP
+ fds.fd = upstream->fd;
+ fds.events = POLLOUT;
+ ret = poll(&fds, 1, 0);
+#else
FD_ZERO(&fds);
- FD_SET(FD_SET_T upstream->fd, &fds);
- struct timeval tval;
+ FD_SET((int)(upstream->fd), &fds);
tval.tv_sec = 0;
tval.tv_usec = 0;
ret = select(upstream->fd+1, NULL, &fds, NULL, &tval);
+#endif
if (ret == 0) {
DEBUG_STUB("%s %-35s: FD: %d Cleaning up dangling queue\n",
- STUB_DEBUG_CLEANUP, __FUNCTION__, upstream->fd);
+ STUB_DEBUG_CLEANUP, __FUNC__, upstream->fd);
while (upstream->write_queue)
upstream_write_cb(upstream);
}
@@ -634,7 +700,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf)
tcp->to_read = 2; /* Packet size */
}
read = recv(fd, (void *)tcp->read_pos, tcp->to_read, 0);
- if (read == -1) {
+ if (read < 0) {
if (_getdns_EWOULDBLOCK)
return STUB_TCP_WOULDBLOCK;
else
@@ -643,7 +709,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf)
/* Remote end closed the socket */
/* TODO: Try to reconnect */
return STUB_TCP_ERROR;
- } else if (read> tcp->to_read) {
+ } else if ((size_t)read > tcp->to_read) {
return STUB_TCP_ERROR;
}
tcp->to_read -= read;
@@ -682,7 +748,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf)
/* stub_tcp_write(fd, tcp, netreq)
* will return STUB_TCP_AGAIN when we need to come back again,
- * STUB_TCP_ERROR on error and a query_id on successfull sent.
+ * STUB_TCP_ERROR on error and a query_id on successful sent.
*/
static int
stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
@@ -711,6 +777,7 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
&netreq->upstream->netreq_by_query_id, &netreq->node));
GLDNS_ID_SET(netreq->query, query_id);
+
if (netreq->opt) {
_getdns_network_req_clear_upstream_options(netreq);
/* no limits on the max udp payload size with tcp */
@@ -726,7 +793,7 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
netreq->owner->context->idle_timeout != 0) {
/* Add the keepalive option to the first query on this connection*/
DEBUG_STUB("%s %-35s: FD: %d Requesting keepalive \n",
- STUB_DEBUG_WRITE, __FUNCTION__, fd);
+ STUB_DEBUG_WRITE, __FUNC__, fd);
if (attach_edns_keepalive(netreq))
return STUB_OUT_OF_OPTIONS;
netreq->keepalive_sent = 1;
@@ -751,12 +818,12 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
(struct sockaddr *)&(netreq->upstream->addr),
netreq->upstream->addr_len);
#endif
- if ((written == -1 && (_getdns_EWOULDBLOCK ||
+ if ((written < 0 && (_getdns_EWOULDBLOCK ||
/* Add the error case where the connection is in progress which is when
a cookie is not available (e.g. when doing the first request to an
upstream). We must let the handshake complete since non-blocking. */
_getdns_EINPROGRESS)) ||
- written < pkt_len + 2) {
+ (size_t)written < pkt_len + 2) {
/* We couldn't write the whole packet.
* We have to return with STUB_TCP_AGAIN.
@@ -768,8 +835,13 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
return STUB_TCP_WOULDBLOCK;
- } else if (written == -1)
+ } else if (written == -1) {
+ DEBUG_STUB("%s %-35s: MSG: %p error while writing to TCP socket:"
+ " %s\n", STUB_DEBUG_WRITE, __FUNC__, (void*)netreq
+ , strerror(errno));
+
return STUB_TCP_ERROR;
+ }
/* We were able to write everything! Start reading. */
return (int) query_id;
@@ -778,13 +850,23 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq)
/* Coming back from an earlier unfinished write or handshake.
* Try to send remaining data */
+#ifdef USE_WINSOCK
+ written = send(fd, tcp->write_buf + tcp->written,
+ tcp->write_buf_len - tcp->written, 0);
+#else
written = write(fd, tcp->write_buf + tcp->written,
tcp->write_buf_len - tcp->written);
+#endif
if (written == -1) {
if (_getdns_EWOULDBLOCK)
return STUB_TCP_WOULDBLOCK;
- else
+ else {
+ DEBUG_STUB("%s %-35s: MSG: %p error while writing to TCP socket:"
+ " %s\n", STUB_DEBUG_WRITE, __FUNC__, (void*)netreq
+ , strerror(errno));
+
return STUB_TCP_ERROR;
+ }
}
tcp->written += written;
if (tcp->written < tcp->write_buf_len)
@@ -817,48 +899,81 @@ tls_verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
getdns_upstream *upstream;
getdns_return_t pinset_ret = GETDNS_RETURN_GOOD;
upstream = _getdns_upstream_from_x509_store(ctx);
+ if (!upstream)
+ return 0;
-#if defined(STUB_DEBUG) && STUB_DEBUG || defined(X509_V_ERR_HOSTNAME_MISMATCH)
- int err = X509_STORE_CTX_get_error(ctx);
-
+ int err = X509_STORE_CTX_get_error(ctx);
+#if defined(STUB_DEBUG) && STUB_DEBUG
DEBUG_STUB("%s %-35s: FD: %d Verify result: (%d) \"%s\"\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd, err,
+ STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd, err,
X509_verify_cert_error_string(err));
#endif
+ if (!preverify_ok && !upstream->tls_fallback_ok)
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Verify failed : Transport=TLS - *Failure* - (%d) \"%s\"\n",
+ upstream->addr_str, err,
+ X509_verify_cert_error_string(err));
+ /* First deal with the hostname authentication done by OpenSSL. */
#ifdef X509_V_ERR_HOSTNAME_MISMATCH
+# if defined(STUB_DEBUG) && STUB_DEBUG
/*Report if error is hostname mismatch*/
- if (upstream && upstream->tls_fallback_ok && err == X509_V_ERR_HOSTNAME_MISMATCH) {
- DEBUG_STUB("%s %-35s: FD: %d WARNING: Proceeding even though hostname validation failed!\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd);
- upstream->tls_auth_state = GETDNS_AUTH_FAILED;
- }
+ if (err == X509_V_ERR_HOSTNAME_MISMATCH && upstream->tls_fallback_ok)
+ DEBUG_STUB("%s %-35s: FD: %d WARNING: Proceeding even though hostname validation failed!\n",
+ STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd);
+# endif
#else
/* if we weren't built against OpenSSL with hostname matching we
* could not have matched the hostname, so this would be an automatic
* tls_auth_fail if there is a hostname provided*/
- if (upstream->tls_auth_name[0])
+ if (upstream->tls_auth_name[0]) {
upstream->tls_auth_state = GETDNS_AUTH_FAILED;
+ preverify_ok = 0;
+ }
#endif
- if (upstream && upstream->tls_pubkey_pinset)
+
+ /* Now deal with the pinset validation*/
+ if (upstream->tls_pubkey_pinset)
pinset_ret = _getdns_verify_pinset_match(upstream->tls_pubkey_pinset, ctx);
if (pinset_ret != GETDNS_RETURN_GOOD) {
DEBUG_STUB("%s %-35s: FD: %d, WARNING: Pinset validation failure!\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd);
+ STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd);
preverify_ok = 0;
upstream->tls_auth_state = GETDNS_AUTH_FAILED;
if (upstream->tls_fallback_ok)
DEBUG_STUB("%s %-35s: FD: %d, WARNING: Proceeding even though pinset validation failed!\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd);
+ STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd);
+ else
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Conn failed : Transport=TLS - *Failure* - Pinset validation failure\n",
+ upstream->addr_str);
+ } else {
+ /* If we _only_ had a pinset and it is good then force succesful
+ authentication when the cert self-signed
+ TODO: We need to check for other error cases here, not blindly accept the cert!! */
+ if ((upstream->tls_pubkey_pinset && upstream->tls_auth_name[0] == '\0') &&
+ (err == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN ||
+ err == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT)) {
+ preverify_ok = 1;
+ DEBUG_STUB("%s %-35s: FD: %d, Allowing self-signed (%d) cert since pins match\n",
+ STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd, err);
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Verify passed : Transport=TLS - Allowing self-signed cert since pins match\n",
+ upstream->addr_str);
+ }
}
+
/* If nothing has failed yet and we had credentials, we have succesfully authenticated*/
- if (upstream->tls_auth_state == GETDNS_AUTH_NONE &&
- (upstream->tls_pubkey_pinset || upstream->tls_auth_name[0]))
+ if (preverify_ok == 0)
+ upstream->tls_auth_state = GETDNS_AUTH_FAILED;
+ else if (upstream->tls_auth_state == GETDNS_AUTH_NONE &&
+ (upstream->tls_pubkey_pinset || upstream->tls_auth_name[0]))
upstream->tls_auth_state = GETDNS_AUTH_OK;
+
/* If fallback is allowed, proceed regardless of what the auth error is
(might not be hostname or pinset related) */
- return (upstream && upstream->tls_fallback_ok) ? 1 : preverify_ok;
+ return (upstream->tls_fallback_ok) ? 1 : preverify_ok;
}
static SSL*
@@ -891,7 +1006,7 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
if (upstream->tls_auth_name[0] != '\0') {
/*Request certificate for the auth_name*/
DEBUG_STUB("%s %-35s: Hostname verification requested for: %s\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->tls_auth_name);
+ STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->tls_auth_name);
SSL_set_tlsext_host_name(ssl, upstream->tls_auth_name);
#ifdef HAVE_SSL_HN_AUTH
/* Set up native OpenSSL hostname verification*/
@@ -902,7 +1017,7 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
#else
if (dnsreq->netreqs[0]->tls_auth_min == GETDNS_AUTHENTICATION_REQUIRED) {
DEBUG_STUB("%s %-35s: ERROR: TLS Authentication functionality not available\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__);
+ STUB_DEBUG_SETUP_TLS, __FUNC__);
upstream->tls_hs_state = GETDNS_HS_FAILED;
return NULL;
}
@@ -916,31 +1031,45 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
if (dnsreq->netreqs[0]->tls_auth_min == GETDNS_AUTHENTICATION_REQUIRED) {
if (upstream->tls_pubkey_pinset) {
DEBUG_STUB("%s %-35s: Proceeding with only pubkey pinning authentication\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__);
+ STUB_DEBUG_SETUP_TLS, __FUNC__);
} else {
DEBUG_STUB("%s %-35s: ERROR: No host name or pubkey pinset provided for TLS authentication\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__);
+ STUB_DEBUG_SETUP_TLS, __FUNC__);
upstream->tls_hs_state = GETDNS_HS_FAILED;
return NULL;
}
} else {
/* no hostname verification, so we will make opportunistic connections */
DEBUG_STUB("%s %-35s: Proceeding even though no hostname provided!\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__);
+ STUB_DEBUG_SETUP_TLS, __FUNC__);
upstream->tls_fallback_ok = 1;
}
}
if (upstream->tls_fallback_ok) {
SSL_set_cipher_list(ssl, "DEFAULT");
DEBUG_STUB("%s %-35s: WARNING: Using Oppotunistic TLS (fallback allowed)!\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__);
+ STUB_DEBUG_SETUP_TLS, __FUNC__);
} else
DEBUG_STUB("%s %-35s: Using Strict TLS \n", STUB_DEBUG_SETUP_TLS,
- __FUNCTION__);
+ __FUNC__);
SSL_set_verify(ssl, SSL_VERIFY_PEER, tls_verify_callback);
SSL_set_connect_state(ssl);
(void) SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY);
+
+ /* Session resumption. There are trade-offs here. Want to do it when
+ possible only if we have the right type of connection. Note a change
+ to the upstream auth info creates a new upstream so never re-uses.*/
+ if (upstream->tls_session != NULL) {
+ if ((upstream->tls_fallback_ok == 0 &&
+ upstream->last_tls_auth_state == GETDNS_AUTH_OK) ||
+ upstream->tls_fallback_ok == 1) {
+ SSL_set_session(ssl, upstream->tls_session);
+ DEBUG_STUB("%s %-35s: Attempting session re-use\n", STUB_DEBUG_SETUP_TLS,
+ __FUNC__);
+ }
+ }
+
return ssl;
}
@@ -948,7 +1077,7 @@ static int
tls_do_handshake(getdns_upstream *upstream)
{
DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_SETUP_TLS,
- __FUNCTION__, upstream->fd);
+ __FUNC__, upstream->fd);
int r;
int want;
ERR_clear_error();
@@ -974,7 +1103,7 @@ tls_do_handshake(getdns_upstream *upstream)
return STUB_TCP_AGAIN;
default:
DEBUG_STUB("%s %-35s: FD: %d Handshake failed %d\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd,
+ STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd,
want);
return STUB_SETUP_ERROR;
}
@@ -982,8 +1111,12 @@ tls_do_handshake(getdns_upstream *upstream)
upstream->tls_hs_state = GETDNS_HS_DONE;
upstream->conn_state = GETDNS_CONN_OPEN;
upstream->conn_completed++;
- DEBUG_STUB("%s %-35s: FD: %d Handshake succeeded with auth state %d. Session is %s.\n",
- STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd, upstream->tls_auth_state,
+ /* A re-used session is not verified so need to fix up state in that case */
+ if (SSL_session_reused(upstream->tls_obj))
+ upstream->tls_auth_state = upstream->last_tls_auth_state;
+ DEBUG_STUB("%s %-35s: FD: %d Handshake succeeded with auth state %s. Session is %s.\n",
+ STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd,
+ _getdns_auth_str(upstream->tls_auth_state),
SSL_session_reused(upstream->tls_obj) ?"re-used":"new");
if (upstream->tls_session != NULL)
SSL_SESSION_free(upstream->tls_session);
@@ -1142,6 +1275,7 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
&netreq->upstream->netreq_by_query_id, &netreq->node));
GLDNS_ID_SET(netreq->query, query_id);
+
/* TODO: Review if more EDNS0 handling can be centralised.*/
if (netreq->opt) {
_getdns_network_req_clear_upstream_options(netreq);
@@ -1158,17 +1292,20 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
/* Add the keepalive option to every nth query on this
connection */
DEBUG_STUB("%s %-35s: FD: %d Requesting keepalive \n",
- STUB_DEBUG_SETUP, __FUNCTION__, upstream->fd);
+ STUB_DEBUG_SETUP, __FUNC__, upstream->fd);
if (attach_edns_keepalive(netreq))
return STUB_OUT_OF_OPTIONS;
netreq->keepalive_sent = 1;
}
- if (netreq->owner->tls_query_padding_blocksize > 1) {
+ if (netreq->owner->tls_query_padding_blocksize > 0) {
+ uint16_t blksz = netreq->owner->tls_query_padding_blocksize;
+ if (blksz == 1) /* use a sensible default policy */
+ blksz = 128;
pkt_len = netreq->response - netreq->query;
pkt_len += 4; /* this accounts for the OPTION-CODE and OPTION-LENGTH of the padding */
- padding_sz = pkt_len % netreq->owner->tls_query_padding_blocksize;
+ padding_sz = pkt_len % blksz;
if (padding_sz)
- padding_sz = netreq->owner->tls_query_padding_blocksize - padding_sz;
+ padding_sz = blksz - padding_sz;
if (_getdns_network_req_add_upstream_option(netreq,
EDNS_PADDING_OPCODE,
padding_sz, NULL))
@@ -1182,10 +1319,39 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
/* TODO[TLS]: Handle error cases, partial writes, renegotiation etc. */
ERR_clear_error();
- written = SSL_write(tls_obj, netreq->query - 2, pkt_len + 2);
- if (written <= 0)
- return STUB_TCP_ERROR;
+#if INTERCEPT_COM_DS
+ /* Intercept and do not sent out COM DS queries. For debugging
+ * purposes only. Never commit with this turned on.
+ */
+ if (netreq->request_type == GETDNS_RRTYPE_DS &&
+ netreq->owner->name_len == 5 &&
+ netreq->owner->name[0] == 3 &&
+ (netreq->owner->name[1] & 0xDF) == 'C' &&
+ (netreq->owner->name[2] & 0xDF) == 'O' &&
+ (netreq->owner->name[3] & 0xDF) == 'M' &&
+ netreq->owner->name[4] == 0) {
+ debug_req("Intercepting", netreq);
+ written = pkt_len + 2;
+ } else
+#endif
+ written = SSL_write(tls_obj, netreq->query - 2, pkt_len + 2);
+ if (written <= 0) {
+ /* SSL_write will not do partial writes, because
+ * SSL_MODE_ENABLE_PARTIAL_WRITE is not default,
+ * but the write could fail because of renegotiation.
+ * In that case SSL_get_error() will return
+ * SSL_ERROR_WANT_READ or, SSL_ERROR_WANT_WRITE.
+ * Return for retry in such cases.
+ */
+ switch (SSL_get_error(tls_obj, written)) {
+ case SSL_ERROR_WANT_READ:
+ case SSL_ERROR_WANT_WRITE:
+ return STUB_TCP_AGAIN;
+ default:
+ return STUB_TCP_ERROR;
+ }
+ }
/* We were able to write everything! Start reading. */
return (int) query_id;
@@ -1194,12 +1360,12 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp,
return STUB_TCP_ERROR;
}
-static uint64_t
+uint64_t
_getdns_get_time_as_uintt64() {
-
+
struct timeval tv;
uint64_t now;
-
+
if (gettimeofday(&tv, NULL)) {
return 0;
}
@@ -1207,10 +1373,12 @@ _getdns_get_time_as_uintt64() {
return now;
}
+
/**************************/
/* UDP callback functions */
/**************************/
+
static void
stub_udp_read_cb(void *userarg)
{
@@ -1219,9 +1387,7 @@ stub_udp_read_cb(void *userarg)
getdns_upstream *upstream = netreq->upstream;
ssize_t read;
DEBUG_STUB("%s %-35s: MSG: %p \n", STUB_DEBUG_READ,
- __FUNCTION__, netreq);
-
- GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
+ __FUNC__, (void*)netreq);
read = recvfrom(netreq->fd, (void *)netreq->response,
netreq->max_udp_payload_size + 1, /* If read == max_udp_payload_size
@@ -1232,23 +1398,50 @@ stub_udp_read_cb(void *userarg)
*/
0, NULL, NULL);
if (read == -1 && _getdns_EWOULDBLOCK)
- return;
+ return; /* Try again later */
+ if (read == -1) {
+ DEBUG_STUB("%s %-35s: MSG: %p error while reading from socket:"
+ " %s\n", STUB_DEBUG_READ, __FUNC__, (void*)netreq
+ , strerror(errno));
+
+ stub_cleanup(netreq);
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
+ /* Handle upstream*/
+ if (netreq->fd >= 0) {
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
+ close(netreq->fd);
+#endif
+ netreq->fd = -1;
+ stub_next_upstream(netreq);
+ }
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ _getdns_check_dns_req_complete(netreq->owner);
+ return;
+ }
if (read < GLDNS_HEADER_SIZE)
return; /* Not DNS */
- if (GLDNS_ID_WIRE(netreq->response) != netreq->query_id)
+ if (GLDNS_ID_WIRE(netreq->response) != GLDNS_ID_WIRE(netreq->query))
return; /* Cache poisoning attempt ;) */
if (netreq->owner->edns_cookies && match_and_process_server_cookie(
upstream, netreq->response, read))
return; /* Client cookie didn't match? */
+ GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
+
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
close(netreq->fd);
+#endif
netreq->fd = -1;
while (GLDNS_TC_WIRE(netreq->response)) {
DEBUG_STUB("%s %-35s: MSG: %p TC bit set in response \n", STUB_DEBUG_READ,
- __FUNCTION__, netreq);
+ __FUNC__, (void*)netreq);
if (!(netreq->transport_current < netreq->transport_count))
break;
getdns_transport_list_t next_transport =
@@ -1261,17 +1454,30 @@ stub_udp_read_cb(void *userarg)
dnsreq)) == -1)
break;
upstream_schedule_netreq(netreq->upstream, netreq);
- GETDNS_SCHEDULE_EVENT(
- dnsreq->loop, -1, dnsreq->context->timeout,
+ GETDNS_SCHEDULE_EVENT(dnsreq->loop, -1,
+ _getdns_ms_until_expiry(dnsreq->expires),
getdns_eventloop_event_init(&netreq->event,
netreq, NULL, NULL, stub_timeout_cb));
return;
}
netreq->response_len = read;
- dnsreq->upstreams->current_udp = 0;
+ if (!dnsreq->context->round_robin_upstreams)
+ dnsreq->upstreams->current_udp = 0;
+ else {
+ dnsreq->upstreams->current_udp+=GETDNS_UPSTREAM_TRANSPORTS;
+ if (dnsreq->upstreams->current_udp >= dnsreq->upstreams->count)
+ dnsreq->upstreams->current_udp = 0;
+ }
netreq->debug_end_time = _getdns_get_time_as_uintt64();
- netreq->state = NET_REQ_FINISHED;
+ _getdns_netreq_change_state(netreq, NET_REQ_FINISHED);
+ upstream->udp_responses++;
+ if (upstream->udp_responses == 1 ||
+ upstream->udp_responses % 100 == 0)
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Upstream stats: Transport=UDP - Resp=%d,Timeouts=%d\n",
+ upstream->addr_str,
+ (int)upstream->udp_responses, (int)upstream->udp_timeouts);
_getdns_check_dns_req_complete(dnsreq);
}
@@ -1281,15 +1487,15 @@ stub_udp_write_cb(void *userarg)
getdns_network_req *netreq = (getdns_network_req *)userarg;
getdns_dns_req *dnsreq = netreq->owner;
size_t pkt_len;
+ ssize_t written;
DEBUG_STUB("%s %-35s: MSG: %p \n", STUB_DEBUG_WRITE,
- __FUNCTION__, netreq);
+ __FUNC__, (void *)netreq);
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
netreq->debug_start_time = _getdns_get_time_as_uintt64();
netreq->debug_udp = 1;
- netreq->query_id = arc4random();
- GLDNS_ID_SET(netreq->query, netreq->query_id);
+ GLDNS_ID_SET(netreq->query, (uint16_t)arc4random());
if (netreq->opt) {
_getdns_network_req_clear_upstream_options(netreq);
if (netreq->edns_maximum_udp_payload_size == -1)
@@ -1305,15 +1511,39 @@ stub_udp_write_cb(void *userarg)
return; /* too many upstream options */
}
pkt_len = _getdns_network_req_add_tsig(netreq);
- if ((ssize_t)pkt_len != sendto(
+ if ((ssize_t)pkt_len != (written = sendto(
netreq->fd, (const void *)netreq->query, pkt_len, 0,
(struct sockaddr *)&netreq->upstream->addr,
- netreq->upstream->addr_len)) {
- close(netreq->fd);
+ netreq->upstream->addr_len))) {
+
+#if defined(STUB_DEBUG) && STUB_DEBUG
+ if (written == -1)
+ DEBUG_STUB( "%s %-35s: MSG: %p error: %s\n"
+ , STUB_DEBUG_WRITE, __FUNC__, (void *)netreq
+ , strerror(errno));
+ else
+ DEBUG_STUB( "%s %-35s: MSG: %p returned: %d, expeced: %d\n"
+ , STUB_DEBUG_WRITE, __FUNC__, (void *)netreq
+ , (int)written, (int)pkt_len);
+#endif
+ stub_cleanup(netreq);
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
+ /* Handle upstream*/
+ if (netreq->fd >= 0) {
+#ifdef USE_WINSOCK
+ closesocket(netreq->fd);
+#else
+ close(netreq->fd);
+#endif
+ netreq->fd = -1;
+ stub_next_upstream(netreq);
+ }
+ netreq->debug_end_time = _getdns_get_time_as_uintt64();
+ _getdns_check_dns_req_complete(netreq->owner);
return;
}
- GETDNS_SCHEDULE_EVENT(
- dnsreq->loop, netreq->fd, dnsreq->context->timeout,
+ GETDNS_SCHEDULE_EVENT(dnsreq->loop, netreq->fd,
+ _getdns_ms_until_expiry(dnsreq->expires),
getdns_eventloop_event_init(&netreq->event, netreq,
stub_udp_read_cb, NULL, stub_timeout_cb));
}
@@ -1344,7 +1574,7 @@ static void
upstream_read_cb(void *userarg)
{
getdns_upstream *upstream = (getdns_upstream *)userarg;
- DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_READ, __FUNCTION__,
+ DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_READ, __FUNC__,
upstream->fd);
getdns_network_req *netreq;
int q;
@@ -1385,8 +1615,8 @@ upstream_read_cb(void *userarg)
}
DEBUG_STUB("%s %-35s: MSG: %p (read)\n",
- STUB_DEBUG_READ, __FUNCTION__, netreq);
- netreq->state = NET_REQ_FINISHED;
+ STUB_DEBUG_READ, __FUNC__, (void*)netreq);
+ _getdns_netreq_change_state(netreq, NET_REQ_FINISHED);
netreq->response = upstream->tcp.read_buf;
netreq->response_len =
upstream->tcp.read_pos - upstream->tcp.read_buf;
@@ -1457,6 +1687,7 @@ upstream_write_cb(void *userarg)
getdns_upstream *upstream = (getdns_upstream *)userarg;
getdns_network_req *netreq = upstream->write_queue;
int q;
+ X509 *cert;
if (!netreq) {
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
@@ -1466,7 +1697,7 @@ upstream_write_cb(void *userarg)
netreq->debug_start_time = _getdns_get_time_as_uintt64();
DEBUG_STUB("%s %-35s: MSG: %p (writing)\n", STUB_DEBUG_WRITE,
- __FUNCTION__, netreq);
+ __FUNC__, (void*)netreq);
/* Health checks on current connection */
if (upstream->conn_state == GETDNS_CONN_TEARDOWN)
@@ -1485,31 +1716,46 @@ upstream_write_cb(void *userarg)
*/
case STUB_TCP_WOULDBLOCK:
return;
+ case STUB_OUT_OF_OPTIONS:
case STUB_TCP_ERROR:
/* New problem with the TCP connection itself. Need to fallback.*/
/* Fall through */
case STUB_SETUP_ERROR:
/* Could not complete the set up. Need to fallback.*/
- DEBUG_STUB("%s %-35s: MSG: %p ERROR = %d\n", STUB_DEBUG_WRITE,
- __FUNCTION__, ((getdns_network_req *)userarg), q);
+ DEBUG_STUB("%s %-35s: Upstream: %p ERROR = %d\n", STUB_DEBUG_WRITE,
+ __FUNC__, (void*)userarg, q);
+ (void) _getdns_rbtree_delete(&upstream->netreq_by_query_id,
+ (void *)(intptr_t)GLDNS_ID_WIRE(netreq->query));
upstream_failed(upstream, (q == STUB_TCP_ERROR ? 0:1));
/* Fall through */
case STUB_CONN_GONE:
case STUB_NO_AUTH:
/* Cleaning up after connection or auth check failure. Need to fallback. */
stub_cleanup(netreq);
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Conn closed : Transport=%s - *Failure*\n",
+ upstream->addr_str,
+ (upstream->transport == GETDNS_TRANSPORT_TLS ? "TLS" : "TCP"));
if (fallback_on_write(netreq) == STUB_TCP_ERROR) {
/* TODO: Need new state to report transport unavailable*/
- netreq->state = NET_REQ_FINISHED;
+ _getdns_netreq_change_state(netreq, NET_REQ_ERRORED);
_getdns_check_dns_req_complete(netreq->owner);
}
return;
default:
+ if (netreq->owner->return_call_reporting &&
+ netreq->upstream->tls_obj &&
+ netreq->debug_tls_peer_cert.data == NULL &&
+ (cert = SSL_get_peer_certificate(netreq->upstream->tls_obj))) {
+ netreq->debug_tls_peer_cert.size = i2d_X509(
+ cert, &netreq->debug_tls_peer_cert.data);
+ X509_free(cert);
+ }
/* Need this because auth status is reset on connection close */
netreq->debug_tls_auth_status = netreq->upstream->tls_auth_state;
upstream->queries_sent++;
- netreq->query_id = (uint16_t) q;
+
/* Unqueue the netreq from the write_queue */
if (!(upstream->write_queue = netreq->write_queue_tail)) {
upstream->write_queue_last = NULL;
@@ -1545,14 +1791,29 @@ upstream_working_ok(getdns_upstream *upstream)
{
/* [TLS1]TODO: This arbitrary logic at the moment - review and improve!*/
return (upstream->responses_timeouts >
- upstream->responses_received*GETDNS_CONN_ATTEMPTS ? 0 : 1);
+ upstream->responses_received*
+ upstream->upstreams->tls_connection_retries ? 0 : 1);
}
static int
upstream_active(getdns_upstream *upstream)
{
- return ((upstream->conn_state == GETDNS_CONN_SETUP ||
- upstream->conn_state == GETDNS_CONN_OPEN) ? 1 : 0);
+ if ((upstream->conn_state == GETDNS_CONN_SETUP ||
+ upstream->conn_state == GETDNS_CONN_OPEN) &&
+ upstream->keepalive_shutdown == 0)
+ return 1;
+ return 0;
+}
+
+static int
+upstream_usable(getdns_upstream *upstream)
+{
+ if ((upstream->conn_state == GETDNS_CONN_CLOSED ||
+ upstream->conn_state == GETDNS_CONN_SETUP ||
+ upstream->conn_state == GETDNS_CONN_OPEN) &&
+ upstream->keepalive_shutdown == 0)
+ return 1;
+ return 0;
}
static int
@@ -1575,15 +1836,21 @@ upstream_valid(getdns_upstream *upstream,
getdns_transport_list_t transport,
getdns_network_req *netreq)
{
- if (upstream->transport != transport || upstream->conn_state != GETDNS_CONN_CLOSED)
+ if (!(upstream->transport == transport && upstream_usable(upstream)))
return 0;
if (transport == GETDNS_TRANSPORT_TCP)
return 1;
+ if (upstream->conn_state == GETDNS_CONN_OPEN) {
+ if (!upstream_auth_status_ok(upstream, netreq))
+ return 0;
+ else
+ return 1;
+ }
/* We need to check past authentication history to see if this is usable for TLS.*/
if (netreq->tls_auth_min != GETDNS_AUTHENTICATION_REQUIRED)
return 1;
- return ((upstream->past_tls_auth_state == GETDNS_AUTH_OK ||
- upstream->past_tls_auth_state == GETDNS_AUTH_NONE) ? 1 : 0);
+ return ((upstream->best_tls_auth_state == GETDNS_AUTH_OK ||
+ upstream->best_tls_auth_state == GETDNS_AUTH_NONE) ? 1 : 0);
}
static int
@@ -1610,38 +1877,65 @@ upstream_select_stateful(getdns_network_req *netreq, getdns_transport_list_t tra
getdns_upstream *upstream = NULL;
getdns_upstreams *upstreams = netreq->owner->upstreams;
size_t i;
-
+ time_t now = time(NULL);
+
if (!upstreams->count)
return NULL;
- /* [TLS1]TODO: Add check to re-instate backed-off upstreams after X amount
- of time*/
-
- /* First find if an open upstream has the correct properties and use that*/
+ /* A check to re-instate backed-off upstreams after X amount of time*/
for (i = 0; i < upstreams->count; i++) {
- if (upstream_valid_and_open(&upstreams->upstreams[i], transport, netreq))
- return &upstreams->upstreams[i];
+ if (upstreams->upstreams[i].conn_state == GETDNS_CONN_BACKOFF &&
+ upstreams->upstreams[i].conn_retry_time < now) {
+ upstreams->upstreams[i].conn_state = GETDNS_CONN_CLOSED;
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Re-instating upstream\n",
+ upstreams->upstreams[i].addr_str);
+ }
}
- /* OK - we will have to open one. Choose the first one that has the best stats
- and the right properties, but because we completely back off failed
+ if (netreq->owner->context->round_robin_upstreams == 0) {
+ /* First find if an open upstream has the correct properties and use that*/
+ for (i = 0; i < upstreams->count; i++) {
+ if (upstream_valid_and_open(&upstreams->upstreams[i], transport, netreq))
+ return &upstreams->upstreams[i];
+ }
+ }
+
+ /* OK - Find the next one to use. First check we have at least one valid
+ upstream because we completely back off failed
upstreams we may have no valid upstream at all (in contrast to UDP). This
will be better communicated to the user when we have better error codes*/
- for (i = 0; i < upstreams->count; i++) {
- DEBUG_STUB("%s %-35s: Testing %d %d\n", STUB_DEBUG_SETUP,
- __FUNCTION__, (int)i, (int)upstreams->upstreams[i].conn_state);
+ i = upstreams->current_stateful;
+ do {
+ DEBUG_STUB("%s %-35s: Testing upstreams %d %d\n", STUB_DEBUG_SETUP,
+ __FUNC__, (int)i, (int)upstreams->upstreams[i].conn_state);
if (upstream_valid(&upstreams->upstreams[i], transport, netreq)) {
upstream = &upstreams->upstreams[i];
break;
}
- }
+ i++;
+ if (i >= upstreams->count)
+ i = 0;
+ } while (i != upstreams->current_stateful);
if (!upstream)
return NULL;
- for (i++; i < upstreams->count; i++) {
- if (upstream_valid(&upstreams->upstreams[i], transport, netreq) &&
- upstream_stats(&upstreams->upstreams[i]) > upstream_stats(upstream))
- upstream = &upstreams->upstreams[i];
+
+ /* Now select the specific upstream */
+ if (netreq->owner->context->round_robin_upstreams == 0) {
+ /* Base the decision on the stats, noting we will have started from 0*/
+ for (i++; i < upstreams->count; i++) {
+ if (upstream_valid(&upstreams->upstreams[i], transport, netreq) &&
+ upstream_stats(&upstreams->upstreams[i]) > upstream_stats(upstream))
+ upstream = &upstreams->upstreams[i];
+ }
+ } else {
+ /* Simplistic, but always just pick the first one, incrementing the current.
+ Note we are not distinguishing TCP/TLS here....*/
+ upstreams->current_stateful+=GETDNS_UPSTREAM_TRANSPORTS;
+ if (upstreams->current_stateful >= upstreams->count)
+ upstreams->current_stateful = 0;
}
+
return upstream;
}
@@ -1667,7 +1961,7 @@ upstream_select(getdns_network_req *netreq)
return &upstreams->upstreams[i];
}
i+=GETDNS_UPSTREAM_TRANSPORTS;
- if (i > upstreams->count)
+ if (i >= upstreams->count)
i = 0;
} while (i != upstreams->current_udp);
@@ -1677,9 +1971,10 @@ upstream_select(getdns_network_req *netreq)
upstream->back_off)
upstream = &upstreams->upstreams[i];
- upstream->back_off++;
+ if (upstream->back_off > 1)
+ upstream->back_off--;
upstream->to_retry = 1;
- upstreams->current_udp = (upstream - upstreams->upstreams) / GETDNS_UPSTREAM_TRANSPORTS;
+ upstreams->current_udp = upstream - upstreams->upstreams;
return upstream;
}
@@ -1688,7 +1983,7 @@ upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport,
getdns_dns_req *dnsreq)
{
DEBUG_STUB("%s %-35s: Getting upstream connection: %p\n", STUB_DEBUG_SETUP,
- __FUNCTION__, upstream);
+ __FUNC__, (void*)upstream);
int fd = -1;
switch(transport) {
case GETDNS_TRANSPORT_UDP:
@@ -1715,14 +2010,20 @@ upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport,
upstream->tls_obj = tls_create_object(dnsreq, fd, upstream);
if (upstream->tls_obj == NULL) {
upstream_failed(upstream, 1);
+#ifdef USE_WINSOCK
+ closesocket(fd);
+#else
close(fd);
+#endif
return -1;
}
- if (upstream->tls_session != NULL)
- SSL_set_session(upstream->tls_obj, upstream->tls_session);
upstream->tls_hs_state = GETDNS_HS_WRITE;
}
upstream->conn_state = GETDNS_CONN_SETUP;
+ _getdns_upstream_log(upstream, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "%-40s : Conn init : Transport=%s - Profile=%s\n",
+ upstream->addr_str, transport == GETDNS_TRANSPORT_TLS ? "TLS":"TCP",
+ dnsreq->context->tls_auth_min == GETDNS_AUTHENTICATION_NONE ? "Opportunistic":"Strict");
break;
default:
return -1;
@@ -1736,21 +2037,28 @@ upstream_find_for_transport(getdns_network_req *netreq,
getdns_transport_list_t transport,
int *fd)
{
- /* [TLS1]TODO: Don't currently loop over upstreams here as UDP will timeout
- and stateful will fallback. But there is a case where connect returns -1
- that we need to deal with!!!! so add a while loop to test fd*/
getdns_upstream *upstream = NULL;
+
+ /* UDP always returns an upstream, the only reason this will fail is if
+ no socket is available, in which case that is an error.*/
if (transport == GETDNS_TRANSPORT_UDP) {
upstream = upstream_select(netreq);
+ *fd = upstream_connect(upstream, transport, netreq->owner);
+ return upstream;
}
- else
- upstream = upstream_select_stateful(netreq, transport);
- if (!upstream)
- return NULL;
- *fd = upstream_connect(upstream, transport, netreq->owner);
- DEBUG_STUB("%s %-35s: FD: %d Connecting to upstream: %p No: %d\n",
- STUB_DEBUG_SETUP, __FUNCTION__, *fd, upstream,
+ else {
+ /* For stateful transport we should keep trying until all our transports
+ are exhausted/backed-off (no upstream)*/
+ do {
+ upstream = upstream_select_stateful(netreq, transport);
+ if (!upstream)
+ return NULL;
+ *fd = upstream_connect(upstream, transport, netreq->owner);
+ } while (*fd == -1);
+ DEBUG_STUB("%s %-35s: FD: %d Connecting to upstream: %p No: %d\n",
+ STUB_DEBUG_SETUP, __FUNC__, *fd, (void*)upstream,
(int)(upstream - netreq->owner->context->upstreams->upstreams));
+ }
return upstream;
}
@@ -1764,15 +2072,25 @@ upstream_find_for_netreq(getdns_network_req *netreq)
upstream = upstream_find_for_transport(netreq,
netreq->transports[i],
&fd);
- if (fd == -1 || !upstream)
+ if (!upstream)
continue;
+
+ if (fd == -1) {
+ if (_getdns_EMFILE)
+ return STUB_TRY_AGAIN_LATER;
+ return -1;
+ }
netreq->transport_current = i;
netreq->upstream = upstream;
netreq->keepalive_sent = 0;
+
+ DEBUG_STUB("%s %-35s: MSG: %p found upstream %p with transport %d, fd: %d\n", STUB_DEBUG_SCHEDULE, __FUNC__, (void*)netreq, (void *)upstream, (int)netreq->transports[i], fd);
return fd;
}
/* Handle better, will give generic error*/
- DEBUG_STUB("%s %-35s: MSG: %p No valid upstream! \n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq);
+ DEBUG_STUB("%s %-35s: MSG: %p No valid upstream! \n", STUB_DEBUG_SCHEDULE, __FUNC__, (void*)netreq);
+ _getdns_context_log(netreq->owner->context, GETDNS_LOG_UPSTREAM_STATS, GETDNS_LOG_DEBUG,
+ "*FAILURE* no valid transports or upstreams available!\n");
return -1;
}
@@ -1783,12 +2101,13 @@ upstream_find_for_netreq(getdns_network_req *netreq)
static int
fallback_on_write(getdns_network_req *netreq)
{
+ uint64_t now_ms = 0;
/* Deal with UDP one day*/
- DEBUG_STUB("%s %-35s: MSG: %p FALLING BACK \n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq);
+ DEBUG_STUB("%s %-35s: MSG: %p FALLING BACK \n", STUB_DEBUG_SCHEDULE, __FUNC__, (void*)netreq);
/* Try to find a fallback transport*/
- getdns_return_t result = _getdns_submit_stub_request(netreq);
+ getdns_return_t result = _getdns_submit_stub_request(netreq, &now_ms);
if (result != GETDNS_RETURN_GOOD)
return STUB_TCP_ERROR;
@@ -1799,10 +2118,10 @@ fallback_on_write(getdns_network_req *netreq)
}
static void
-upstream_reschedule_events(getdns_upstream *upstream, size_t idle_timeout) {
+upstream_reschedule_events(getdns_upstream *upstream, uint64_t idle_timeout) {
DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_SCHEDULE,
- __FUNCTION__, upstream->fd);
+ __FUNC__, upstream->fd);
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
if (!upstream->write_queue && upstream->event.write_cb) {
upstream->event.write_cb = NULL;
@@ -1821,7 +2140,13 @@ upstream_reschedule_events(getdns_upstream *upstream, size_t idle_timeout) {
upstream->fd, TIMEOUT_FOREVER, &upstream->event);
else {
DEBUG_STUB("%s %-35s: FD: %d Connection idle - timeout is %d\n",
- STUB_DEBUG_SCHEDULE, __FUNCTION__, upstream->fd, (int)idle_timeout);
+ STUB_DEBUG_SCHEDULE, __FUNC__, upstream->fd, (int)idle_timeout);
+ /* TODO: Schedule a read also anyway,
+ * to digest timed out answers.
+ * Dont forget to schedule with upstream->fd then!
+ *
+ * upstream->event.read_cb = upstream_read_cb;
+ */
upstream->event.timeout_cb = upstream_idle_timeout_cb;
if (upstream->conn_state != GETDNS_CONN_OPEN)
idle_timeout = 0;
@@ -1833,7 +2158,7 @@ upstream_reschedule_events(getdns_upstream *upstream, size_t idle_timeout) {
static void
upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
{
- DEBUG_STUB("%s %-35s: MSG: %p (schedule event)\n", STUB_DEBUG_SCHEDULE, __FUNCTION__, netreq);
+ DEBUG_STUB("%s %-35s: MSG: %p (schedule event)\n", STUB_DEBUG_SCHEDULE, __FUNC__, (void*)netreq);
/* We have a connected socket and a global event loop */
assert(upstream->fd >= 0);
assert(upstream->loop);
@@ -1852,8 +2177,8 @@ upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
if (upstream->queries_sent == 0) {
/* Set a timeout on the upstream so we can catch failed setup*/
upstream->event.timeout_cb = upstream_setup_timeout_cb;
- GETDNS_SCHEDULE_EVENT(upstream->loop,
- upstream->fd, netreq->owner->context->timeout / 2,
+ GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd,
+ _getdns_ms_until_expiry(netreq->owner->expires)/2,
&upstream->event);
} else {
GETDNS_SCHEDULE_EVENT(upstream->loop,
@@ -1882,28 +2207,38 @@ upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
}
getdns_return_t
-_getdns_submit_stub_request(getdns_network_req *netreq)
+_getdns_submit_stub_request(getdns_network_req *netreq, uint64_t *now_ms)
{
- DEBUG_STUB("%s %-35s: MSG: %p TYPE: %d\n", STUB_DEBUG_ENTRY, __FUNCTION__,
- netreq, netreq->request_type);
int fd = -1;
- getdns_dns_req *dnsreq = netreq->owner;
+ getdns_dns_req *dnsreq;
+ getdns_context *context;
+
+ DEBUG_STUB("%s %-35s: MSG: %p TYPE: %d\n", STUB_DEBUG_ENTRY, __FUNC__,
+ (void*)netreq, netreq->request_type);
+
+ dnsreq = netreq->owner;
+ context = dnsreq->context;
/* This does a best effort to get a initial fd.
* All other set up is done async*/
fd = upstream_find_for_netreq(netreq);
if (fd == -1)
- /* Handle better, will give unhelpful error is some cases */
- return GETDNS_RETURN_GENERIC_ERROR;
+ return GETDNS_RETURN_NO_UPSTREAM_AVAILABLE;
- getdns_transport_list_t transport =
- netreq->transports[netreq->transport_current];
- switch(transport) {
+ else if (fd == STUB_TRY_AGAIN_LATER) {
+ _getdns_netreq_change_state(netreq, NET_REQ_NOT_SENT);
+ netreq->node.key = netreq;
+ if (_getdns_rbtree_insert(
+ &context->pending_netreqs, &netreq->node))
+ return GETDNS_RETURN_GOOD;
+ return GETDNS_RETURN_NO_UPSTREAM_AVAILABLE;
+ }
+ switch(netreq->transports[netreq->transport_current]) {
case GETDNS_TRANSPORT_UDP:
netreq->fd = fd;
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
- GETDNS_SCHEDULE_EVENT(
- dnsreq->loop, netreq->fd, dnsreq->context->timeout,
+ GETDNS_SCHEDULE_EVENT(dnsreq->loop, netreq->fd,
+ _getdns_ms_until_expiry2(dnsreq->expires, now_ms),
getdns_eventloop_event_init(&netreq->event, netreq,
NULL, stub_udp_write_cb, stub_timeout_cb));
return GETDNS_RETURN_GOOD;
@@ -1977,7 +2312,7 @@ _getdns_submit_stub_request(getdns_network_req *netreq)
*/
GETDNS_SCHEDULE_EVENT(
dnsreq->loop, -1,
- dnsreq->context->timeout,
+ _getdns_ms_until_expiry2(dnsreq->expires, now_ms),
getdns_eventloop_event_init(
&netreq->event, netreq, NULL, NULL,
stub_timeout_cb));
diff --git a/src/stub.h b/src/stub.h
index 41aa629a..da45eded 100644
--- a/src/stub.h
+++ b/src/stub.h
@@ -37,7 +37,8 @@
#include "getdns/getdns.h"
#include "types-internal.h"
-getdns_return_t _getdns_submit_stub_request(getdns_network_req *netreq);
+getdns_return_t _getdns_submit_stub_request(
+ getdns_network_req *netreq, uint64_t *now_ms);
void _getdns_cancel_stub_request(getdns_network_req *netreq);
diff --git a/src/sync.c b/src/sync.c
index d100afb8..75f8cca3 100644
--- a/src/sync.c
+++ b/src/sync.c
@@ -123,18 +123,22 @@ getdns_sync_data_cleanup(getdns_sync_data *data)
* synchronous request.
*/
GETDNS_CLEAR_EVENT(upstream->loop, &upstream->event);
- (*upstream->event.timeout_cb)(upstream->event.userarg);
-
- /* This should have cleared the event */
- assert(!upstream->event.read_cb &&
- !upstream->event.write_cb &&
- !upstream->event.timeout_cb);
+ if (upstream->conn_state != GETDNS_CONN_OPEN ||
+ upstream->keepalive_timeout == 0)
+ (*upstream->event.timeout_cb)(upstream->event.userarg);
}
upstream->loop = data->context->extension;
upstream->is_sync_loop = 0;
if (upstream->event.read_cb || upstream->event.write_cb)
GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd,
TIMEOUT_FOREVER, &upstream->event);
+
+ else if (upstream->event.timeout_cb &&
+ upstream->conn_state == GETDNS_CONN_OPEN &&
+ upstream->keepalive_timeout != 0) {
+ GETDNS_SCHEDULE_EVENT(upstream->loop, upstream->fd,
+ upstream->keepalive_timeout, &upstream->event);
+ }
}
}
@@ -151,6 +155,7 @@ getdns_sync_cb(getdns_context *context, getdns_callback_type_t callback_type,
getdns_dict *response, void *userarg, getdns_transaction_t transaction_id)
{
getdns_sync_data *data = (getdns_sync_data *)userarg;
+ (void)context; (void)callback_type; (void)transaction_id;
assert(data);
diff --git a/src/test/Makefile.in b/src/test/Makefile.in
index d0cf2450..9d4dad00 100644
--- a/src/test/Makefile.in
+++ b/src/test/Makefile.in
@@ -57,7 +57,8 @@ CHECK_EVENT_PROG=@CHECK_EVENT_PROG@
CHECK_EV_PROG=@CHECK_EV_PROG@
CC=@CC@
-CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@
+CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@ $(XTRA_CFLAGS)
+WPEDANTICFLAG=@WPEDANTICFLAG@
LDFLAGS=-L.. @LDFLAGS@
LDLIBS=../libgetdns.la @LIBS@
CHECK_LIBS=@CHECK_LIBS@
@@ -79,53 +80,53 @@ PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync
.SUFFIXES: .c .o .a .lo .h
.c.o:
- $(CC) $(CFLAGS) -c $< -o $@
+ $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $< -o $@
.c.lo:
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $< -o $@
default: all
all: $(PROGRAMS)
$(ALL_OBJS):
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$(@:.lo=.c) -o $@
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $(srcdir)/$(@:.lo=.c) -o $@
$(NON_C99_OBJS):
- $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -c $(srcdir)/$(@:.lo=.c) -o $@
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -c $(srcdir)/$(@:.lo=.c) -o $@
tests_dict: tests_dict.lo testmessages.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_dict.lo testmessages.lo
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_dict.lo testmessages.lo
tests_list: tests_list.lo testmessages.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_list.lo testmessages.lo
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_list.lo testmessages.lo
tests_namespaces: tests_namespaces.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_namespaces.lo
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_namespaces.lo
tests_stub_async: tests_stub_async.lo testmessages.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_async.lo testmessages.lo
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_async.lo testmessages.lo
tests_stub_sync: tests_stub_sync.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_sync.lo
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_sync.lo
check_getdns_common: check_getdns_common.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.lo
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.lo
check_getdns: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) $(CHECK_LIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo
check_getdns_event: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo ../libgetdns_ext_event.la
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) ../libgetdns_ext_event.la $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS)
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo $(LDFLAGS) $(LDLIBS) $(CHECK_LIBS) ../libgetdns_ext_event.la $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS)
check_getdns_uv: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo ../libgetdns_ext_uv.la
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) ../libgetdns_ext_uv.la $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS)
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo $(LDFLAGS) $(LDLIBS) $(CHECK_LIBS) ../libgetdns_ext_uv.la $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS)
check_getdns_ev: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo ../libgetdns_ext_ev.la
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS)
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo $(LDFLAGS) $(LDLIBS) $(CHECK_LIBS) ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS)
scratchpad: scratchpad.lo
- $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ scratchpad.lo $(LDFLAGS) $(LDLIBS)
+ $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ scratchpad.lo $(LDFLAGS) $(LDLIBS)
scratchpad.lo: scratchpad.c
@@ -147,13 +148,28 @@ nolibcheck:
@echo "***"
@false
-test: $(NOLIBCHECK) all
- (cd $(srcdir)/../.. && find . -type f -executable -and \( -name "*.[ch]" -or -name "*.html" -or -name "*.in" -or -name "*.good" -or -name "*.ac" \) | awk 'BEGIN{e=0}{print("ERROR! Executable bit found on", $$0);e=1}END{exit(e)}')
+test_noeventloop: $(NOLIBCHECK) all
+ rm -f $(CHECK_GETDNS).failed
+ GETDNS_TEST_PORT=43210 CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_GETDNS).log" ./$(CHECK_GETDNS) || echo "$(CHECK_GETDNS) failed" >> $(CHECK_GETDNS).failed
+
+test_libevent: $(NOLIBCHECK) all
+ rm -f $(CHECK_EVENT_PROG).failed
+ if test $(have_libevent) = 1 ; then GETDNS_TEST_PORT=44321 CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_EVENT_PROG).log" ./$(CHECK_EVENT_PROG) || echo "$(CHECK_EVENT_PROG) failed" >> $(CHECK_EVENT_PROG).failed; fi
+
+test_libev: $(NOLIBCHECK) all
+ rm -f $(CHECK_EV_PROG).failed
+ if test $(have_libev) = 1 ; then GETDNS_TEST_PORT=45432 CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_EV_PROG).log" ./$(CHECK_EV_PROG) || echo "$(CHECK_EV_PROG) failed" >> $(CHECK_EV_PROG).failed; fi
+
+test_libuv: $(NOLIBCHECK) all
+ rm -f $(CHECK_UV_PROG).failed
+ if test $(have_libev) = 1 ; then GETDNS_TEST_PORT=46543 CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_UV_PROG).log" ./$(CHECK_UV_PROG) || echo "$(CHECK_UV_PROG) failed" >> $(CHECK_UV_PROG).failed; fi
+
+test: test_noeventloop test_libevent test_libev test_libuv
rm -f fails
- CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_GETDNS).log" ./$(CHECK_GETDNS) || echo "$(CHECK_GETDNS) failed" >> fails
- if test $(have_libevent) = 1 ; then CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_EVENT_PROG).log" ./$(CHECK_EVENT_PROG) || echo "$(CHECK_EVENT_PROG) failed" >> fails; fi
- if test $(have_libev) = 1 ; then CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_EV_PROG).log" ./$(CHECK_EV_PROG) || echo "$(CHECK_EV_PROG) failed" >> fails; fi
- if test $(have_libuv) = 1 ; then CK_TIMEOUT_MULTIPLIER=2 CK_LOG_FILE_NAME="$(CHECK_UV_PROG).log" ./$(CHECK_UV_PROG) || echo "$(CHECK_UV_PROG) failed" >> fails; fi
+ if test -f $(CHECK_GETDNS).failed ; then cat $(CHECK_GETDNS).failed >> fails ; fi
+ if test -f $(CHECK_EVENT_PROG).failed ; then cat $(CHECK_EVENT_PROG).failed >> fails ; fi
+ if test -f $(CHECK_EV_PROG).failed ; then cat $(CHECK_EV_PROG).failed >> fails ; fi
+ if test -f $(CHECK_UV_PROG).failed ; then cat $(CHECK_UV_PROG).failed >> fails ; fi
test ! -e fails
@echo "All tests OK"
diff --git a/src/test/check_getdns.c b/src/test/check_getdns.c
index e5974d1d..a437374d 100644
--- a/src/test/check_getdns.c
+++ b/src/test/check_getdns.c
@@ -30,7 +30,14 @@
#include
#include
#include
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#endif
#include
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
#include "getdns/getdns.h"
#include "check_getdns_common.h"
#include "check_getdns_address.h"
@@ -75,7 +82,7 @@
int
-main (int argc, char** argv)
+main ()
{
int number_failed;
SRunner *sr ;
diff --git a/src/test/check_getdns_address.h b/src/test/check_getdns_address.h
index 65f76b8b..f898bdd8 100644
--- a/src/test/check_getdns_address.h
+++ b/src/test/check_getdns_address.h
@@ -149,6 +149,7 @@
* rcode = 0
*/
void verify_getdns_address_6(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_address_6 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -157,7 +158,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_address(context, "google.com", NULL,
- verify_getdns_address_6, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
@@ -183,6 +184,7 @@
* ancount = 1 (number of records in ANSWER section)
*/
void verify_getdns_address_7(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_address_7 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -191,7 +193,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_address(context, "localhost", NULL,
- verify_getdns_address_7, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
@@ -213,6 +215,7 @@
* rcode = 3 (NXDOMAIN)
*/
void verify_getdns_address_8(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_address_8 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -221,8 +224,8 @@
EVENT_BASE_CREATE;
- ASSERT_RC(getdns_address(context, "hostnamedoesntexist", NULL,
- verify_getdns_address_8, &transaction_id, callbackfn),
+ ASSERT_RC(getdns_address(context, "hostnamedoesntexist.", NULL,
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
diff --git a/src/test/check_getdns_cancel_callback.h b/src/test/check_getdns_cancel_callback.h
index 7ad31b46..facf31bc 100644
--- a/src/test/check_getdns_cancel_callback.h
+++ b/src/test/check_getdns_cancel_callback.h
@@ -55,6 +55,7 @@
* expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
*/
void verify_getdns_cancel_callback(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_cancel_callback };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@@ -65,7 +66,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
- verify_getdns_cancel_callback, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -86,6 +87,7 @@
* expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
*/
void verify_getdns_cancel_callback(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_cancel_callback };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@@ -96,7 +98,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
- verify_getdns_cancel_callback, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -133,7 +135,8 @@
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
- getdns_transaction_t transaction_id_array[10] = {};
+ getdns_transaction_t transaction_id_array[10]
+ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
int odd = 0;
int even = 0;
@@ -212,7 +215,8 @@
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
- getdns_transaction_t transaction_id_array[10] = {};
+ getdns_transaction_t transaction_id_array[10]
+ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
int odd = 0;
int even = 0;
@@ -295,7 +299,8 @@
struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
struct getdns_dict *address = NULL;
getdns_transaction_t transaction_id = 0;
- getdns_transaction_t transaction_id_array[10] = {};
+ getdns_transaction_t transaction_id_array[10]
+ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
int odd = 0;
int even = 0;
@@ -381,7 +386,8 @@
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
- getdns_transaction_t transaction_id_array[10] = {};
+ getdns_transaction_t transaction_id_array[10]
+ = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
int odd = 0;
int even = 0;
@@ -451,6 +457,8 @@
void *userarg,
getdns_transaction_t transaction_id)
{
+ (void)context; (void)response; (void)userarg;
+
callback_called++;
if(callback_type == GETDNS_CALLBACK_CANCEL)
@@ -483,6 +491,7 @@
*/
void verify_getdns_cancel_callback(struct extracted_response *ex_response)
{
+ (void)ex_response;
/*
* increment callback_called global to prove callback was called.
*/
diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c
index 79f177a9..8fe9f8c6 100644
--- a/src/test/check_getdns_common.c
+++ b/src/test/check_getdns_common.c
@@ -29,7 +29,14 @@
#include
#include
#include
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#endif
#include
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
#include "getdns/getdns.h"
#include "config.h"
#include "check_getdns_common.h"
@@ -320,6 +327,7 @@ void destroy_callbackfn(struct getdns_context *context,
void *userarg,
getdns_transaction_t transaction_id) {
int* flag = (int*)userarg;
+ (void)callback_type; (void)transaction_id;
*flag = 1;
getdns_dict_destroy(response);
getdns_context_destroy(context);
@@ -338,7 +346,8 @@ void callbackfn(struct getdns_context *context,
getdns_transaction_t transaction_id)
{
typedef void (*fn_ptr)(struct extracted_response *ex_response);
- fn_ptr fn = userarg;
+ fn_ptr fn = ((fn_cont *)userarg)->fn;
+ (void)context; (void)transaction_id;
/*
* If userarg is NULL, either a negative test case
@@ -378,7 +387,7 @@ void callbackfn(struct getdns_context *context,
void update_callbackfn(struct getdns_context *context,
getdns_context_code_t changed_item)
{
-
+ (void)context;
ck_assert_msg(changed_item == expected_changed_item,
"Expected changed_item == %d, got %d",
changed_item, expected_changed_item);
diff --git a/src/test/check_getdns_common.h b/src/test/check_getdns_common.h
index e2d77f44..6fb3b555 100644
--- a/src/test/check_getdns_common.h
+++ b/src/test/check_getdns_common.h
@@ -211,6 +211,10 @@
struct getdns_dict *response,
void *userarg,
getdns_transaction_t transaction_id);
+
+ typedef struct fn_cont {
+ void (*fn)(struct extracted_response *ex_response);
+ } fn_cont;
/*
* callbackfn is the callback function given to all
* asynchronous query tests. It is expected to only
diff --git a/src/test/check_getdns_context_create.h b/src/test/check_getdns_context_create.h
index eb965200..11188198 100644
--- a/src/test/check_getdns_context_create.h
+++ b/src/test/check_getdns_context_create.h
@@ -55,9 +55,13 @@
* GETDNS_RETURN_GOOD
*/
struct getdns_context *context = NULL;
+ getdns_append_name_t append_name;
CONTEXT_CREATE(TRUE);
// TODO: Do something here to verify set_from_os = TRUE
+ getdns_context_set_append_name(context, GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST);
+ getdns_context_get_append_name(context, &append_name);
+ ck_assert_msg(append_name == GETDNS_APPEND_NAME_TO_SINGLE_LABEL_FIRST, "suffix is not correct");
CONTEXT_DESTROY;
}
END_TEST
diff --git a/src/test/check_getdns_context_destroy.h b/src/test/check_getdns_context_destroy.h
index 52b28456..65a0a8c3 100644
--- a/src/test/check_getdns_context_destroy.h
+++ b/src/test/check_getdns_context_destroy.h
@@ -68,6 +68,7 @@
* expect: callback should be called before getdns_context_destroy() returns
*/
void verify_getdns_context_destroy(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_context_destroy };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@@ -78,7 +79,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
- verify_getdns_context_destroy, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -95,6 +96,7 @@
* expect: callback should be called before getdns_context_destroy() returns
*/
void verify_getdns_context_destroy(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_context_destroy };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@@ -105,7 +107,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_address(context, "google.com", NULL,
- verify_getdns_context_destroy, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
@@ -122,6 +124,7 @@
* expect: callback should be called before getdns_context_destroy() returns
*/
void verify_getdns_context_destroy(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_context_destroy };
struct getdns_context *context = NULL;
void* eventloop = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
@@ -141,7 +144,7 @@
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
ASSERT_RC(getdns_hostname(context, address, NULL,
- verify_getdns_context_destroy, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
@@ -159,6 +162,7 @@
* expect: callback should be called before getdns_context_destroy() returns
*/
void verify_getdns_context_destroy(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_context_destroy };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@@ -169,7 +173,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_service(context, "google.com", NULL,
- verify_getdns_context_destroy, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_service()");
RUN_EVENT_LOOP;
@@ -267,6 +271,7 @@
void verify_getdns_context_destroy(struct extracted_response *ex_response)
{
+ (void)ex_response;
/*
* Sleep for a second to make getdns_context_destroy() wait.
*/
diff --git a/src/test/check_getdns_context_set_context_update_callback.h b/src/test/check_getdns_context_set_context_update_callback.h
index d816a149..1694905f 100644
--- a/src/test/check_getdns_context_set_context_update_callback.h
+++ b/src/test/check_getdns_context_set_context_update_callback.h
@@ -111,6 +111,8 @@
*/
struct getdns_context *context = NULL;
getdns_namespace_t namespace_arr[2] = {GETDNS_NAMESPACE_DNS, GETDNS_NAMESPACE_LOCALNAMES};
+ size_t count;
+ getdns_namespace_t *namespaces;
CONTEXT_CREATE(TRUE);
ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
@@ -118,8 +120,12 @@
expected_changed_item = GETDNS_CONTEXT_CODE_NAMESPACES;
- ASSERT_RC(getdns_context_set_namespaces(context, 2,namespace_arr),
+ ASSERT_RC(getdns_context_set_namespaces(context, 2, namespace_arr),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_namespaces()");
+ ASSERT_RC(getdns_context_get_namespaces(context, &count, &namespaces),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_namespaces()");
+ ck_assert_msg(count == 2 && namespaces[0] == 500 && namespaces[1] == 501, "namespaces are not correctly set");
+
CONTEXT_DESTROY;
@@ -207,6 +213,7 @@
* expect: GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS
*/
struct getdns_context *context = NULL;
+ getdns_redirects_t redir;
CONTEXT_CREATE(TRUE);
ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
@@ -215,6 +222,8 @@
expected_changed_item = GETDNS_CONTEXT_CODE_FOLLOW_REDIRECTS;
(void) getdns_context_set_follow_redirects(context, GETDNS_REDIRECTS_DO_NOT_FOLLOW);
+ (void) getdns_context_get_follow_redirects(context, &redir);
+ ck_assert_msg(redir == GETDNS_REDIRECTS_DO_NOT_FOLLOW, "getdns_context_get_follow_redirects failed");
CONTEXT_DESTROY;
@@ -301,6 +310,8 @@
* expect: GETDNS_CONTEXT_CODE_EDNS_EXTENDED_RCODE
*/
struct getdns_context *context = NULL;
+ uint8_t extended_rcode;
+
CONTEXT_CREATE(TRUE);
ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
@@ -310,6 +321,9 @@
ASSERT_RC(getdns_context_set_edns_extended_rcode(context, 1),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_extended_rcode()");
+ ASSERT_RC(getdns_context_get_edns_extended_rcode(context, &extended_rcode),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_edns_extended_rcode()");
+ ck_assert_msg(extended_rcode == 1, "extended_rcode should be 1, got %d", (int)extended_rcode);
CONTEXT_DESTROY;
@@ -325,6 +339,8 @@
* expect: GETDNS_CONTEXT_CODE_EDNS_VERSION
*/
struct getdns_context *context = NULL;
+ uint8_t version;
+
CONTEXT_CREATE(TRUE);
ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
@@ -334,6 +350,9 @@
ASSERT_RC(getdns_context_set_edns_version(context, 1),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_version()");
+ ASSERT_RC(getdns_context_get_edns_version(context, &version),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_edns_version()");
+ ck_assert_msg(version == 1, "version should be 1, got %d", (int)version);
CONTEXT_DESTROY;
@@ -373,6 +392,8 @@
* expect: GETDNS_CONTEXT_CODE_EDNS_CLIENT_SUBNET_PRIVATE
*/
struct getdns_context *context = NULL;
+ uint8_t client_subnet_private;
+
CONTEXT_CREATE(TRUE);
ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
@@ -382,6 +403,9 @@
ASSERT_RC(getdns_context_set_edns_client_subnet_private(context, 1),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_client_subnet_private()");
+ ASSERT_RC(getdns_context_get_edns_client_subnet_private(context, &client_subnet_private),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_edns_client_subnet_private()");
+ ck_assert_msg(client_subnet_private == 1, "client_subnet_private should be 1, got %d", (int)client_subnet_private);
CONTEXT_DESTROY;
@@ -397,6 +421,8 @@
* expect: GETDNS_CONTEXT_CODE_TLS_QUERY_PADDING_BLOCKSIZE
*/
struct getdns_context *context = NULL;
+ uint16_t pad;
+
CONTEXT_CREATE(TRUE);
ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
@@ -406,6 +432,9 @@
ASSERT_RC(getdns_context_set_tls_query_padding_blocksize(context, 1400),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_tls_query_padding_blocksize()");
+ ASSERT_RC(getdns_context_get_tls_query_padding_blocksize(context, &pad),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_tls_query_padding_blocksize()");
+ ck_assert_msg(pad == 1400, "padding_blocksize should be 1400 but got %d", (int) pad);
CONTEXT_DESTROY;
@@ -434,6 +463,33 @@
}
END_TEST
+
+ START_TEST (getdns_context_set_context_update_callback_23)
+ {
+ /*
+ * expect: GETDNS_RETURN_GOOD
+ */
+
+ struct getdns_context *context = NULL;
+ uint8_t round_robin;
+
+ CONTEXT_CREATE(TRUE);
+
+ ASSERT_RC(getdns_context_set_context_update_callback(context, update_callbackfn),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_context_update_callback()");
+
+ expected_changed_item = GETDNS_CONTEXT_CODE_ROUND_ROBIN_UPSTREAMS;
+
+ ASSERT_RC(getdns_context_set_round_robin_upstreams(context, 1),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_round_robin_upstream()");
+ ASSERT_RC(getdns_context_get_round_robin_upstreams(context, &round_robin),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_round_robin_upstream()");
+ ck_assert_msg( round_robin == 1, "round_robin should be 1, got %d", (int)round_robin);
+
+ CONTEXT_DESTROY;
+
+ }
+ END_TEST
Suite *
getdns_context_set_context_update_callback_suite (void)
@@ -462,6 +518,7 @@
tcase_add_test(tc_pos, getdns_context_set_context_update_callback_20);
tcase_add_test(tc_pos, getdns_context_set_context_update_callback_21);
tcase_add_test(tc_pos, getdns_context_set_context_update_callback_22);
+ tcase_add_test(tc_pos, getdns_context_set_context_update_callback_23);
suite_add_tcase(s, tc_pos);
return s;
diff --git a/src/test/check_getdns_context_set_dns_transport.h b/src/test/check_getdns_context_set_dns_transport.h
index fba6c195..f76ee74b 100644
--- a/src/test/check_getdns_context_set_dns_transport.h
+++ b/src/test/check_getdns_context_set_dns_transport.h
@@ -39,7 +39,7 @@
{
/*
* context is NULL
- * expect: GETDNS_RETURN_BAD_CONTEXT
+ * expect: GETDNS_RETURN_INVALID_PARAMETER
*/
struct getdns_context *context = NULL;
@@ -47,7 +47,12 @@
ASSERT_RC(getdns_context_set_dns_transport(context, value),
GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_dns_transport()");
-
+
+ ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
+ GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
+
+ ASSERT_RC(getdns_context_unset_edns_maximum_udp_payload_size(context),
+ GETDNS_RETURN_INVALID_PARAMETER, "Return code from getdns_context_unset_edns_maximum_udp_payload_size()");
}
END_TEST
@@ -55,6 +60,7 @@
{
/*
* value is an undefined transport value
+ * do_bit is not correct
* expect: GETDNS_RETURN_CONTEXT_UPDATE_FAIL
*/
@@ -66,6 +72,9 @@
ASSERT_RC(getdns_context_set_dns_transport(context, 233),
GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_dns_transport()");
+ ASSERT_RC(getdns_context_set_edns_do_bit(context, 5),
+ GETDNS_RETURN_CONTEXT_UPDATE_FAIL, "Return code from getdns_context_set_edns_do_bit()");
+
CONTEXT_DESTROY;
}
@@ -132,6 +141,9 @@
uint32_t tc;
uint32_t transport;
uint32_t type;
+ uint16_t payload_size;
+ uint8_t do_bit;
+ getdns_transport_t trans;
/* Note that stricly this test just establishes that the requested transport
and the reported transport are consistent, it does not guarentee which
@@ -147,10 +159,22 @@
/* Request a response that should be truncated over UDP */
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_UDP_ONLY),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
+ ASSERT_RC(getdns_context_get_dns_transport(context, &trans),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_dns_transport()");
+ ck_assert_msg(trans == 541, "dns_transport should be 541(GETDNS_TRANSPORT_UDP_ONLY) but got %d", (int)trans);
+
+
ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
- GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
+ ASSERT_RC(getdns_context_get_edns_maximum_udp_payload_size(context, &payload_size),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_edns_maximum_udp_payload_size()");
+ ck_assert_msg(payload_size == 512, "payload_size should be 512, got %d", (int)payload_size);
+
ASSERT_RC(getdns_context_set_edns_do_bit(context, 1),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_do_bit()");
+ ASSERT_RC(getdns_context_get_edns_do_bit(context, &do_bit),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_edns_do_bit()");
+ ck_assert_msg(do_bit == 1, "do_bit should be 1, got %d", (int)do_bit);
ASSERT_RC(getdns_general_sync(context, "large.getdnsapi.net", GETDNS_RRTYPE_TXT, extensions, &response),
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
@@ -192,6 +216,9 @@
GETDNS_RETURN_GOOD, "Failed to extract \"tc\"");
ASSERT_RC(tc, 0, "Packet trucated - not as expected");
+ ASSERT_RC(getdns_context_unset_edns_maximum_udp_payload_size(context),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_unset_edns_maximum_udp_payload_size()");
+
CONTEXT_DESTROY;
}
@@ -261,7 +288,9 @@
* suspect them to be a bit more reliable.
*/
struct getdns_list *root_servers = getdns_list_create();
+ struct getdns_list *root_servers2 = getdns_list_create();
struct getdns_bindata nlnetlabs_root = { 4, (void *)"\xB9\x31\x8D\x25" };
+ struct getdns_bindata *answer = NULL;
uint32_t status;
uint32_t type;
@@ -277,10 +306,17 @@
/* Re-do over TCP */
ASSERT_RC(getdns_dict_set_int(extensions,"return_call_reporting", GETDNS_EXTENSION_TRUE),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
- ASSERT_RC(getdns_list_set_bindata(root_servers,0,&nlnetlabs_root),
+ ASSERT_RC(getdns_list_set_bindata(root_servers, 0, &nlnetlabs_root),
GETDNS_RETURN_GOOD, "Return code from getdns_list_set_bindata()");
+
ASSERT_RC(getdns_context_set_dns_root_servers(context, root_servers),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_root_servers()");
+ ASSERT_RC(getdns_context_get_dns_root_servers(context, &root_servers2),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_dns_root_servers()");
+ ASSERT_RC(getdns_list_get_bindata(root_servers2, 0, &answer),
+ GETDNS_RETURN_GOOD, "Return code from getdns_list_get_bindata()");
+ ck_assert_msg(strncmp((char *)answer->data, (char *)nlnetlabs_root.data, 4) == 0,
+ "Expected answer data to be 185.49.141.37");
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_TCP_ONLY),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
@@ -348,6 +384,60 @@
}
END_TEST
+ START_TEST (getdns_context_set_dns_transport_recursing_9)
+ {
+ /*
+ * Check TLS
+ */
+ struct getdns_context *context = NULL;
+ getdns_resolution_t resolution_type;
+ getdns_transport_list_t transport_list[1];
+ getdns_transport_list_t *transport_list2;
+ size_t count;
+ getdns_tls_authentication_t auth;
+ uint16_t backoff;
+ uint16_t retries;
+
+ transport_list[0] = GETDNS_TRANSPORT_TLS;
+
+ CONTEXT_CREATE(TRUE);
+
+ ASSERT_RC(getdns_context_set_resolution_type(context, GETDNS_RESOLUTION_STUB),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_resolution_type()");
+ ASSERT_RC(getdns_context_get_resolution_type(context, &resolution_type),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_resolution_type()");
+ ck_assert_msg(resolution_type == GETDNS_RESOLUTION_STUB, "resolution_type should be stub (520), got %d", (int)resolution_type);
+
+ ASSERT_RC(getdns_context_set_dns_transport_list(context, 1, transport_list),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport_list()");
+ ASSERT_RC(getdns_context_get_dns_transport_list(context, &count, &transport_list2),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_dns_transport_list()");
+ ck_assert_msg(transport_list2[0] == GETDNS_TRANSPORT_TLS, "transport_list should be 1202 but got %d", (int) transport_list2[0]);
+
+ ASSERT_RC(getdns_context_set_tls_authentication(context, GETDNS_AUTHENTICATION_REQUIRED),
+ GETDNS_RETURN_GOOD, "Return cond from getdns_context_set_tls_authentication()");
+ ASSERT_RC(getdns_context_get_tls_authentication(context, &auth),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_tls_authentication()");
+ ck_assert_msg(auth == 1301, "tls_authentication should be 1301, but got %d", (int) auth);
+
+ ASSERT_RC(getdns_context_set_tls_backoff_time(context, 1000),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_tls_backoff_time()");
+ ASSERT_RC(getdns_context_get_tls_backoff_time(context, &backoff),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_tls_backoff_time()");
+ ck_assert_msg(backoff == 1000, "backoff should be 1000, but got %d", (int) backoff);
+
+ ASSERT_RC(getdns_context_set_tls_connection_retries(context, 5),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_tls_connection_retries()");
+ ASSERT_RC(getdns_context_get_tls_connection_retries(context, &retries),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_tls_connection_retries()");
+ ck_assert_msg(retries == 5, "retries should be 5 but got %d", (int) retries);
+
+ /*TODO: should extend the test */
+ CONTEXT_DESTROY;
+
+ }
+ END_TEST
+
@@ -372,7 +462,8 @@
tcase_add_test(tc_pos, getdns_context_set_dns_transport_recursing_6);
tcase_add_test(tc_pos, getdns_context_set_dns_transport_recursing_7);
tcase_add_test(tc_pos, getdns_context_set_dns_transport_recursing_8);
- /* TODO: TLS... */
+ /* TLS */
+ tcase_add_test(tc_pos, getdns_context_set_dns_transport_recursing_9);
suite_add_tcase(s, tc_pos);
diff --git a/src/test/check_getdns_context_set_timeout.c b/src/test/check_getdns_context_set_timeout.c
index f588445a..edc0f346 100644
--- a/src/test/check_getdns_context_set_timeout.c
+++ b/src/test/check_getdns_context_set_timeout.c
@@ -94,15 +94,21 @@ END_TEST
START_TEST (getdns_context_set_idle_timeout_2)
{
/*
- * timeout is 0
+ * timeout is 0 and then 100
* expect: GETDNS_RETURN_GOOD
*/
struct getdns_context *context = NULL;
+ uint64_t time;
CONTEXT_CREATE(TRUE);
ASSERT_RC(getdns_context_set_idle_timeout(context, 0),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()");
+ ASSERT_RC(getdns_context_set_idle_timeout(context, 100),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()");
+ ASSERT_RC(getdns_context_get_idle_timeout(context, &time),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_set_timeout()");
+ ck_assert_msg(time == 100, "idle_timeout should be 100, got %d", (int)time);
CONTEXT_DESTROY;
@@ -114,6 +120,23 @@ END_TEST
#define GETDNS_STR_ADDRESS_TYPE "address_type"
#define GETDNS_STR_ADDRESS_DATA "address_data"
#define GETDNS_STR_PORT "port"
+#define TEST_PORT 43210
+
+static uint16_t get_test_port(void)
+{
+ char *test_port_str;
+ uint16_t test_port;
+ struct timeval tv;
+
+ if (!(test_port_str = getenv("GETDNS_TEST_PORT")) ||
+ !(test_port = (uint16_t)atoi(test_port_str)))
+ test_port = TEST_PORT;
+
+ (void)gettimeofday(&tv, NULL);
+ srandom((int)getpid() + (int)tv.tv_usec);
+ test_port += random() % 1000;
+ return test_port;
+}
/* utilities to start a junk udp listener */
typedef struct timeout_thread_data {
@@ -243,6 +266,7 @@ void timeout_3_cb(struct getdns_context *context,
getdns_callback_type_t callback_type,
struct getdns_dict * response,
void *userarg, getdns_transaction_t transaction_id) {
+ (void)response; (void)transaction_id;
timeout_thread_data *tdata = (timeout_thread_data*)userarg;
tdata->num_callbacks++;
if (callback_type == GETDNS_CALLBACK_TIMEOUT) {
@@ -280,7 +304,8 @@ START_TEST (getdns_context_set_timeout_3)
t_data.running = 0;
t_data.num_callbacks = 0;
t_data.num_timeouts = 0;
- t_data.port = 43210;
+ uint64_t timeout;
+ t_data.port = get_test_port();
pthread_create(&thread, NULL, run_server, (void *)&t_data);
@@ -300,7 +325,7 @@ START_TEST (getdns_context_set_timeout_3)
bindata.data = (uint8_t*) &local_addr;
ASSERT_RC(getdns_dict_set_bindata(server_dict, GETDNS_STR_ADDRESS_DATA, &bindata),
GETDNS_RETURN_GOOD, "set addr bindata");
- ASSERT_RC(getdns_dict_set_int(server_dict, GETDNS_STR_PORT, 43210),
+ ASSERT_RC(getdns_dict_set_int(server_dict, GETDNS_STR_PORT, t_data.port),
GETDNS_RETURN_GOOD, "set addr port");
upstream_list = getdns_list_create_with_context(context);
@@ -323,6 +348,10 @@ START_TEST (getdns_context_set_timeout_3)
RUN_EVENT_LOOP;
+ ASSERT_RC(getdns_context_get_timeout(context, &timeout),
+ GETDNS_RETURN_GOOD, "Return code from getdns_context_get_timeout()");
+ ck_assert_msg(timeout == 500, "timeout should be 500, got %d", (int)timeout);
+
CONTEXT_DESTROY;
t_data.running = 0;
diff --git a/src/test/check_getdns_context_set_timeout.h b/src/test/check_getdns_context_set_timeout.h
index 6aabb198..fe89ee0f 100644
--- a/src/test/check_getdns_context_set_timeout.h
+++ b/src/test/check_getdns_context_set_timeout.h
@@ -27,7 +27,14 @@
#ifndef _check_getdns_context_set_timeout_h_
#define _check_getdns_context_set_timeout_h_
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#endif
#include
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
Suite *
getdns_context_set_timeout_suite (void);
diff --git a/src/test/check_getdns_dict_get_names.h b/src/test/check_getdns_dict_get_names.h
index 46f06f0a..0881ad0f 100644
--- a/src/test/check_getdns_dict_get_names.h
+++ b/src/test/check_getdns_dict_get_names.h
@@ -79,7 +79,7 @@
struct getdns_list *answer = NULL;
char *keys[3] = { "ten", "eleven", "twelve" };
uint32_t values[3] = { 10, 11, 12 };
- int i;
+ size_t i;
size_t length;
struct getdns_bindata *key = NULL;
char string_buffer[20] = "";
diff --git a/src/test/check_getdns_general.h b/src/test/check_getdns_general.h
index 6a19bdfb..f073cd86 100644
--- a/src/test/check_getdns_general.h
+++ b/src/test/check_getdns_general.h
@@ -151,6 +151,7 @@
* ancount = 0 (number of records in ANSWER section)
*/
void verify_getdns_general_6(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_general_6 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -159,7 +160,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", 0, NULL,
- verify_getdns_general_6, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -184,6 +185,7 @@
* ancount = 0 (number of records in ANSWER section)
*/
void verify_getdns_general_7(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_general_7 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -192,7 +194,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", 65279, NULL,
- verify_getdns_general_7, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -218,6 +220,7 @@
* and equals number of A records ("type": 1) in "answer" list
*/
void verify_getdns_general_8(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_general_8 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -226,7 +229,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
- verify_getdns_general_8, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -252,6 +255,7 @@
* and equals number of AAAA records ("type": 28) in "answer" list
*/
void verify_getdns_general_9(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_general_9 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -260,7 +264,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_AAAA, NULL,
- verify_getdns_general_9, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -287,6 +291,7 @@
* and SOA record ("type": 6) present in "authority" list
*/
void verify_getdns_general_10(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_general_10 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -296,7 +301,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_TXT, NULL,
- verify_getdns_general_10, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -322,6 +327,7 @@
* ancount = 0 (number of records in ANSWER section)
*/
void verify_getdns_general_11(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_general_11 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -330,7 +336,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "willem.getdnsapi.net", GETDNS_RRTYPE_MX, NULL,
- verify_getdns_general_11, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@@ -356,6 +362,7 @@
* and equals number of A records ("type": 1) in "answer" list
*/
void verify_getdns_general_12(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_general_12 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -364,7 +371,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
- verify_getdns_general_12, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
diff --git a/src/test/check_getdns_hostname.h b/src/test/check_getdns_hostname.h
index 461ad373..7193fec9 100644
--- a/src/test/check_getdns_hostname.h
+++ b/src/test/check_getdns_hostname.h
@@ -315,6 +315,7 @@
* expect: response with correct hostname
*/
void verify_getdns_hostname_10(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_hostname_10 };
struct getdns_context *context = NULL;
struct getdns_dict *address = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
@@ -333,7 +334,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_hostname(context, address, NULL,
- verify_getdns_hostname_10, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
RUN_EVENT_LOOP;
@@ -356,6 +357,7 @@
* expect: response with no hostname
*/
void verify_getdns_hostname_11(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_hostname_11 };
struct getdns_context *context = NULL;
struct getdns_dict *address = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
@@ -374,7 +376,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_hostname(context, address, NULL,
- verify_getdns_hostname_11, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
RUN_EVENT_LOOP;
@@ -398,6 +400,7 @@
* expect: response with correct hostname
*/
void verify_getdns_hostname_12(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_hostname_12 };
struct getdns_context *context = NULL;
struct getdns_dict *address = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv6" };
@@ -419,7 +422,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_hostname(context, address, NULL,
- verify_getdns_hostname_12, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
RUN_EVENT_LOOP;
@@ -442,6 +445,7 @@
* expect: response with no hostname
*/
void verify_getdns_hostname_13(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_hostname_13 };
struct getdns_context *context = NULL;
struct getdns_dict *address = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv6" };
@@ -460,7 +464,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_hostname(context, address, NULL,
- verify_getdns_hostname_13, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
RUN_EVENT_LOOP;
diff --git a/src/test/check_getdns_libev.c b/src/test/check_getdns_libev.c
index 9120cf5a..ffdc6e22 100644
--- a/src/test/check_getdns_libev.c
+++ b/src/test/check_getdns_libev.c
@@ -41,11 +41,19 @@
#else
#include
#endif
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#endif
#include
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
#include "check_getdns_common.h"
void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
struct ev_loop* loop = (struct ev_loop*) eventloop;
+ (void)context;
ev_run(loop, 0);
}
diff --git a/src/test/check_getdns_libevent.c b/src/test/check_getdns_libevent.c
index 304f42ef..ee59854b 100644
--- a/src/test/check_getdns_libevent.c
+++ b/src/test/check_getdns_libevent.c
@@ -37,11 +37,19 @@
#include "getdns/getdns_ext_libevent.h"
#include "check_getdns_libevent.h"
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#endif
#include
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
#include "check_getdns_common.h"
void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
struct event_base* base = (struct event_base*) eventloop;
+ (void)context;
event_base_dispatch(base);
}
diff --git a/src/test/check_getdns_libuv.c b/src/test/check_getdns_libuv.c
index 3d830445..7aa88b51 100644
--- a/src/test/check_getdns_libuv.c
+++ b/src/test/check_getdns_libuv.c
@@ -37,11 +37,19 @@
#include "getdns/getdns_ext_libuv.h"
#include
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#endif
#include
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
#include "check_getdns_common.h"
void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
uv_loop_t* loop = (uv_loop_t*) eventloop;
+ (void)context;
uv_run(loop, UV_RUN_DEFAULT);
}
diff --git a/src/test/check_getdns_pretty_print_dict.h b/src/test/check_getdns_pretty_print_dict.h
index 08aec6c1..6dc6d189 100644
--- a/src/test/check_getdns_pretty_print_dict.h
+++ b/src/test/check_getdns_pretty_print_dict.h
@@ -88,6 +88,68 @@ static const char pretty_expected[] = "{\n"
" ]\n"
"}";
+static const char pretty_expected2[] = "{\n"
+" \"bindata\":\"bindata\",\n"
+" \"dict\":\n"
+" {\n"
+" \"bindata\":\"bindata\",\n"
+" \"dict\":\n"
+" {\n"
+" \"bindata\":\"bindata\",\n"
+" \"dict\":\n"
+" {\n"
+" \"int\": 4\n"
+" },\n"
+" \"int\": 3,\n"
+" \"list\":\n"
+" [\n"
+" 5\n"
+" ]\n"
+" },\n"
+" \"int\": 2,\n"
+" \"list\":\n"
+" [\n"
+" 6,\n"
+" \"bindata\",\n"
+" {\n"
+" \"bindata\":\"bindata\"\n"
+" },\n"
+" [\n"
+" \"bindata\"\n"
+" ]\n"
+" ]\n"
+" },\n"
+" \"int\": 1,\n"
+" \"list\":\n"
+" [\n"
+" 7,\n"
+" \"bindata\",\n"
+" {\n"
+" \"bindata\":\"bindata\",\n"
+" \"dict\":\n"
+" {\n"
+" \"int\": 9\n"
+" },\n"
+" \"int\": 8,\n"
+" \"list\":\n"
+" [\n"
+" 10\n"
+" ]\n"
+" },\n"
+" [\n"
+" 11,\n"
+" \"bindata\",\n"
+" {\n"
+" \"bindata\":\"bindata\"\n"
+" },\n"
+" [\n"
+" \"bindata\"\n"
+" ]\n"
+" ]\n"
+" ]\n"
+"}";
+
+
/*
**************************************************************************
* *
@@ -267,6 +329,11 @@ static const char pretty_expected[] = "{\n"
ck_assert_msg(strcmp(pretty_expected, pretty) == 0,
"Expected:\n%s\ngot:\n%s\n", pretty_expected, pretty);
+ pretty = getdns_print_json_dict(dict1, 1);
+ ck_assert_msg(pretty != NULL, "NULL returned by getdns_print_json_dict()");
+ ck_assert_msg(strcmp(pretty_expected2, pretty) == 0,
+ "Expected:\n%s\ngot:\n%s\n", pretty_expected2, pretty);
+
/*
* Destroy all of the sub-dicts and sub-lists
*/
diff --git a/src/test/check_getdns_selectloop.c b/src/test/check_getdns_selectloop.c
index b80f1ffd..c315b30c 100644
--- a/src/test/check_getdns_selectloop.c
+++ b/src/test/check_getdns_selectloop.c
@@ -37,9 +37,11 @@
#include "getdns/getdns_extra.h"
void run_event_loop_impl(struct getdns_context* context, void* eventloop) {
+ (void)eventloop;
getdns_context_run(context);
}
void* create_eventloop_impl(struct getdns_context* context) {
+ (void)context;
return NULL;
}
diff --git a/src/test/check_getdns_service.h b/src/test/check_getdns_service.h
index c9545c0c..c93cab0e 100644
--- a/src/test/check_getdns_service.h
+++ b/src/test/check_getdns_service.h
@@ -148,6 +148,7 @@
* expect: NXDOMAIN response (with SOA record)
*/
void verify_getdns_service_7(struct extracted_response *ex_response);
+ fn_cont fn_ref = { verify_getdns_service_7 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@@ -157,7 +158,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_service(context, "nitinsinghit.com", NULL,
- verify_getdns_address_8, &transaction_id, callbackfn),
+ &fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_service()");
RUN_EVENT_LOOP;
diff --git a/src/test/check_getdns_service_sync.h b/src/test/check_getdns_service_sync.h
index 09c48f9c..17273e24 100644
--- a/src/test/check_getdns_service_sync.h
+++ b/src/test/check_getdns_service_sync.h
@@ -124,7 +124,7 @@
*/
struct getdns_context *context = NULL;
struct getdns_dict *response = NULL;
- const char *name = "labelsizeofsixtythreecharacterscom";
+ const char *name = "labelsizeofsixtythreecharacterscom.";
CONTEXT_CREATE(TRUE);
diff --git a/src/test/check_getdns_transport.c b/src/test/check_getdns_transport.c
index 7d97c27c..300abc4d 100644
--- a/src/test/check_getdns_transport.c
+++ b/src/test/check_getdns_transport.c
@@ -35,6 +35,8 @@
#include
#include
#include
+#include
+#include
#define GETDNS_STR_IPV4 "IPv4"
@@ -42,7 +44,23 @@
#define GETDNS_STR_ADDRESS_TYPE "address_type"
#define GETDNS_STR_ADDRESS_DATA "address_data"
#define GETDNS_STR_PORT "port"
-#define TEST_PORT 43210
+#define TEST_PORT 42100
+
+static uint16_t get_test_port(void)
+{
+ char *test_port_str;
+ uint16_t test_port;
+ struct timeval tv;
+
+ if (!(test_port_str = getenv("GETDNS_TEST_PORT")) ||
+ !(test_port = (uint16_t)atoi(test_port_str)))
+ test_port = TEST_PORT;
+
+ (void)gettimeofday(&tv, NULL);
+ srandom((int)getpid() + (int)tv.tv_usec);
+ test_port += random() % 1000;
+ return test_port;
+}
/* utilities to start a junk listener */
typedef struct transport_thread_data {
@@ -193,6 +211,8 @@ void transport_cb(struct getdns_context *context,
struct getdns_dict * response,
void *userarg, getdns_transaction_t transaction_id) {
/* Don't really care about the answer*/
+ (void)context; (void)callback_type; (void)response;
+ (void)userarg; (void)transaction_id;
return;
}
@@ -217,7 +237,7 @@ START_TEST(getdns_transport_udp_sync) {
t_data.running = 0;
t_data.udp_count = 0;
t_data.tcp_count = 0;
- t_data.port = TEST_PORT;
+ t_data.port = get_test_port();
pthread_create(&thread, NULL, run_transport_server, (void *) &t_data);
@@ -291,7 +311,7 @@ START_TEST(getdns_transport_tcp_sync) {
t_data.running = 0;
t_data.udp_count = 0;
t_data.tcp_count = 0;
- t_data.port = TEST_PORT;
+ t_data.port = get_test_port();
pthread_create(&thread, NULL, run_transport_server, (void *) &t_data);
@@ -365,7 +385,7 @@ START_TEST(getdns_transport_udp_async) {
t_data.running = 0;
t_data.udp_count = 0;
t_data.tcp_count = 0;
- t_data.port = TEST_PORT;
+ t_data.port = get_test_port();
pthread_create(&thread, NULL, run_transport_server, (void *) &t_data);
@@ -443,7 +463,7 @@ START_TEST(getdns_transport_tcp_async) {
t_data.running = 0;
t_data.udp_count = 0;
t_data.tcp_count = 0;
- t_data.port = TEST_PORT;
+ t_data.port = get_test_port();
pthread_create(&thread, NULL, run_transport_server, (void *) &t_data);
@@ -509,7 +529,7 @@ getdns_transport_suite(void) {
/* Note that the exact number of messages received depends on if a trust
* anchor is configured so these tests just check that no messages are
- * received on the wrong transport and at least one is recieved on the
+ * received on the wrong transport and at least one is received on the
* expected transport */
/* Positive test cases */
diff --git a/src/test/check_getdns_transport.h b/src/test/check_getdns_transport.h
index 6da58405..a5496a27 100644
--- a/src/test/check_getdns_transport.h
+++ b/src/test/check_getdns_transport.h
@@ -27,7 +27,14 @@
#ifndef _check_getdns_transport_h_
#define _check_getdns_transport_h_
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
+#endif
#include
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
Suite *
getdns_transport_suite (void);
diff --git a/src/test/tests_dict.c b/src/test/tests_dict.c
index 4be804f5..963ba7b4 100644
--- a/src/test/tests_dict.c
+++ b/src/test/tests_dict.c
@@ -214,7 +214,7 @@ tst_getnames(void)
size_t index;
size_t llen;
uint32_t ansint;
- int i;
+ size_t i;
getdns_return_t result;
getdns_data_type dtype;
struct getdns_dict *dict = NULL;
@@ -508,7 +508,7 @@ tst_create(void)
* runs unit tests against list management routines
*/
int
-main(int argc, char *argv[])
+main()
{
tstmsg_prog_begin("tests_dict");
diff --git a/src/test/tests_list.c b/src/test/tests_list.c
index c8a68bd8..ab9a98cf 100644
--- a/src/test/tests_list.c
+++ b/src/test/tests_list.c
@@ -404,7 +404,7 @@ tst_create(void)
* runs unit tests against list management routines
*/
int
-main(int argc, char *argv[])
+main()
{
tstmsg_prog_begin("tests_list");
diff --git a/src/test/tests_stub_async.c b/src/test/tests_stub_async.c
index a5b3c995..79a8029c 100644
--- a/src/test/tests_stub_async.c
+++ b/src/test/tests_stub_async.c
@@ -57,6 +57,8 @@ this_callbackfn(struct getdns_context *this_context,
struct getdns_dict *this_response,
void *this_userarg, getdns_transaction_t this_transaction_id)
{
+ (void)this_context; (void)this_userarg;
+
if (this_callback_type == GETDNS_CALLBACK_COMPLETE) { /* This is a callback with data */
char *res = getdns_pretty_print_dict(this_response);
fprintf(stdout, "%s\n", res);
diff --git a/src/test/tests_transports.sh b/src/test/tests_transports.sh
index 13e5b6b6..99acfc40 100755
--- a/src/test/tests_transports.sh
+++ b/src/test/tests_transports.sh
@@ -5,25 +5,72 @@ SERVER_IP="8.8.8.8"
SERVER_IPv6="2001:4860:4860::8888"
TLS_SERVER_IP="185.49.141.38~getdnsapi.net"
TLS_SERVER_IPv6="2a04:b900:0:100::38~getdnsapi.net"
+TLS_SERVER_SS_IP="184.105.193.78~tls-dns-u.odvr.dns-oarc.net" #Self signed cert
TLS_SERVER_KEY="foxZRnIh9gZpWnl+zEiKa0EJ2rdCGroMWm02gaxSc9S="
+TLS_SERVER_SS_KEY="pOXrpUt9kgPgbWxBFFcBTbRH2heo2wHwXp1fd4AEVXI="
TLS_SERVER_WRONG_KEY="foxZRnIh9gZpWnl+zEiKa0EJ2rdCGroMWm02gaxSc1S="
GOOD_RESULT_SYNC="Status was: At least one response was returned"
-GOOD_RESULT_ASYNC="successfull"
+GOOD_RESULT_ASYNC="successful"
BAD_RESULT_SYNC="1 'Generic error'"
BAD_RESULT_ASYNC="callback_type of 703"
+NUM_ARGS=3
GOOD_COUNT=0
FAIL_COUNT=0
+
+check_auth () {
+ local my_auth_ok=0;
+ auth_result=`echo $1 | sed 's/.*tls_auth_status\": .*//'`
+ if [[ $2 == "-" ]] ; then
+ my_auth_ok=1;
+ fi
+ if [[ $2 == "N" ]] && [[ $auth_result == "None" ]]; then
+ my_auth_ok=1;
+ fi
+ if [[ $2 == "F" ]] && [[ $auth_result == "Failed" ]]; then
+ my_auth_ok=1;
+ fi
+ if [[ $2 == "S" ]] && [[ $auth_result == "Success" ]]; then
+ my_auth_ok=1;
+ fi
+ echo $my_auth_ok;
+}
+
+check_trans () {
+ local my_trans_ok=0;
+ trans_result=`echo $1 | sed "s/.*\"transport\": GETDNS_TRANSPORT_//" | sed 's/ }.*//' | sed 's/,.*//'`
+ if [[ $2 == "U" ]] && [[ $trans_result == "UDP" ]]; then
+ my_trans_ok=1;
+ fi
+ if [[ $2 == "T" ]] && [[ $trans_result == "TCP" ]]; then
+ my_trans_ok=1;
+ fi
+ if [[ $2 == "L" ]] && [[ $trans_result == "TLS" ]]; then
+ my_trans_ok=1;
+ fi
+ echo $my_trans_ok;
+}
+
check_good () {
- result=`echo $1 | grep "Response code was: GOOD." | tail -1 | sed 's/ All done.'// | sed 's/Response code was: GOOD. '//`
+ auth_ok=0;
+ result_ok=0;
+ trans_ok=0;
+ result=`echo $1 | sed 's/ All done.'// | sed 's/.*Response code was: GOOD. '//`
async_success=`echo $result | grep -c "$GOOD_RESULT_ASYNC"`
if [[ $result =~ $GOOD_RESULT_SYNC ]] || [[ $async_success =~ 1 ]]; then
- (( GOOD_COUNT++ ))
- echo -n "PASS: "
- else
- (( FAIL_COUNT++ ))
- echo "FAIL (RESULT): " $1
- echo -n "FAIL: "
+ result_ok=1;
+ fi
+ if [[ $result_ok == 1 ]] ; then
+ trans_ok=$(check_trans "$1" "$2")
+ auth_ok=$(check_auth "$1" "$3")
+ fi
+ if [[ $result_ok == 1 ]] && [[ $auth_ok == 1 ]] && [[ $trans_ok == 1 ]]; then
+ (( GOOD_COUNT++ ))
+ echo -n "PASS: "
+ else
+ (( FAIL_COUNT++ ))
+ echo "FAIL (RESULT): Result: $result Auth: $auth_ok Trans: $trans_ok"
+ echo -n "FAIL: "
fi
}
@@ -80,30 +127,38 @@ while getopts ":p:s:t:k:idh" opt; do
done
TLS_SERVER_IP_NO_NAME=`echo ${TLS_SERVER_IP%~*}`
+TLS_SERVER_SS_IP_NO_NAME=`echo ${TLS_SERVER_SS_IP%~*}`
TLS_SERVER_IP_WRONG_NAME=`echo ${TLS_SERVER_IP::${#TLS_SERVER_IP}-1}`
+NUM_GOOD_QUERIES=7
GOOD_QUERIES=(
-"-s -A -q getdnsapi.net -l U @${SERVER_IP} "
-"-s -A -q getdnsapi.net -l T @${SERVER_IP} "
-"-s -A -q getdnsapi.net -l L @${TLS_SERVER_IP_NO_NAME}"
-"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP}"
-"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME} -K pin-sha256=\"${TLS_SERVER_KEY}\""
-"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP} -K pin-sha256=\"${TLS_SERVER_KEY}\""
-"-s -G -q DNSKEY getdnsapi.net -l U @${SERVER_IP} -b 512 -D")
+"-s -A getdnsapi.net -l U @${SERVER_IP}" "U" "-"
+"-s -A getdnsapi.net -l T @${SERVER_IP}" "T" "-"
+"-s -A getdnsapi.net -l L @${TLS_SERVER_IP_NO_NAME}" "L" "N"
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP}" "L" "S"
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME} -K pin-sha256=\"${TLS_SERVER_KEY}\"" "L" "S"
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP} -K pin-sha256=\"${TLS_SERVER_KEY}\"" "L" "S"
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_SS_IP_NO_NAME} -K pin-sha256=\"${TLS_SERVER_SS_KEY}\"" "L" "S"
+"-s -G DNSKEY getdnsapi.net -l U @${SERVER_IP} -b 512 -D" "U" "-")
+NUM_GOOD_FB_QUERIES=6
GOOD_FALLBACK_QUERIES=(
-"-s -A -q getdnsapi.net -l LT @${SERVER_IP}"
-"-s -A -q getdnsapi.net -l LT @${SERVER_IP}"
-"-s -A -q getdnsapi.net -l LT @${TLS_SERVER_IP_NO_NAME}"
-"-s -A -q getdnsapi.net -l LT -m @${TLS_SERVER_IP_NO_NAME}"
-"-s -A -q getdnsapi.net -l L @${SERVER_IP} @${TLS_SERVER_IP_NO_NAME}"
-"-s -G -q DNSKEY getdnsapi.net -l UT @${SERVER_IP} -b 512 -D")
+"-s -A getdnsapi.net -l LU @${SERVER_IP}" "U" "-"
+"-s -A getdnsapi.net -l LT @${SERVER_IP}" "T" "-"
+"-s -A getdnsapi.net -l LT @${TLS_SERVER_IP_NO_NAME}" "L" "N"
+"-s -A getdnsapi.net -l LT -m @${TLS_SERVER_IP_NO_NAME}" "L" "N"
+"-s -A getdnsapi.net -l L @${SERVER_IP} @${TLS_SERVER_IP_NO_NAME}" "L" "-"
+"-s -G DNSKEY getdnsapi.net -l UT @${SERVER_IP} -b 512 -D" "T" "-")
NOT_AVAILABLE_QUERIES=(
-"-s -A -q getdnsapi.net -l L @${SERVER_IP}"
-"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_WRONG_NAME}"
-"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME}"
-"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME} -K pin-sha256=\"${TLS_SERVER_WRONG_KEY}\"")
+"-s -A getdnsapi.net -l L @${SERVER_IP}"
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP_WRONG_NAME}"
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME}"
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME} -K pin-sha256=\"${TLS_SERVER_WRONG_KEY}\""
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP} -K pin-sha256=\"${TLS_SERVER_WRONG_KEY}\""
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP_WRONG_NAME} -K pin-sha256=\"${TLS_SERVER_KEY}\""
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_IP_WRONG_NAME} -K pin-sha256=\"${TLS_SERVER_WRONG_KEY}\""
+"-s -A getdnsapi.net -l L -m @${TLS_SERVER_SS_IP} -K pin-sha256=\"${TLS_SERVER_SS_KEY}\"")
echo "Starting transport test"
@@ -118,22 +173,22 @@ for (( i = 0; i < 2; i+=1 )); do
fi
echo "*Success cases:"
- for (( j = 0; j < ${#GOOD_QUERIES[@]}; j+=1 )); do
- check_good "`$DIR/getdns_query $SYNC_MODE ${GOOD_QUERIES[${j}]} 2>/dev/null`"
- echo "getdns_query $SYNC_MODE ${GOOD_QUERIES[${j}]}"
- (( COUNT++ ))
+ for (( j = 0; j < $NUM_GOOD_QUERIES; j+=1 )); do
+ check_good "`$DIR/getdns_query -V +return_call_reporting $SYNC_MODE ${GOOD_QUERIES[$j*$NUM_ARGS]} 2>/dev/null`" ${GOOD_QUERIES[$((j*NUM_ARGS))+1]} ${GOOD_QUERIES[$((j*NUM_ARGS))+2]}
+ echo "getdns_query $SYNC_MODE ${GOOD_QUERIES[$j*$NUM_ARGS]}"
+ (( COUNT++ ))
done
echo "*Success fallback cases:"
- for (( j = 0; j < ${#GOOD_FALLBACK_QUERIES[@]}; j+=1 )); do
- check_good "`$DIR/getdns_query $SYNC_MODE ${GOOD_FALLBACK_QUERIES[${j}]} 2>/dev/null`"
- echo "getdns_query $SYNC_MODE ${GOOD_FALLBACK_QUERIES[${j}]}"
- (( COUNT++ ))
+ for (( j = 0; j < $NUM_GOOD_FB_QUERIES; j+=1 )); do
+ check_good "`$DIR/getdns_query -V +return_call_reporting $SYNC_MODE ${GOOD_FALLBACK_QUERIES[$j*$NUM_ARGS]} 2>/dev/null`" ${GOOD_FALLBACK_QUERIES[$((j*NUM_ARGS))+1]} ${GOOD_FALLBACK_QUERIES[$((j*NUM_ARGS))+2]}
+ echo "getdns_query $SYNC_MODE ${GOOD_FALLBACK_QUERIES[$j*$NUM_ARGS]} TESTS: ${GOOD_FALLBACK_QUERIES[$((j*NUM_ARGS))+1]} ${GOOD_FALLBACK_QUERIES[$((j*NUM_ARGS))+2]}"
+ (( COUNT++ ))
done
-
+
echo "*Transport not available cases:"
for (( j = 0; j < ${#NOT_AVAILABLE_QUERIES[@]}; j+=1 )); do
- check_bad "`$DIR/getdns_query $SYNC_MODE ${NOT_AVAILABLE_QUERIES[${j}]} 2>&1`"
+ check_bad "`$DIR/getdns_query -V $SYNC_MODE ${NOT_AVAILABLE_QUERIES[${j}]} 2>&1`"
echo "getdns_query $SYNC_MODE ${NOT_AVAILABLE_QUERIES[${j}]}"
(( COUNT++ ))
done
@@ -141,4 +196,4 @@ done
echo
echo "Finished transport test: did $COUNT queries, $GOOD_COUNT passes, $FAIL_COUNT failures"
-echo
\ No newline at end of file
+echo
diff --git a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.dsc b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.dsc
new file mode 100644
index 00000000..b2101c47
--- /dev/null
+++ b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.dsc
@@ -0,0 +1,16 @@
+BaseName: 070-coding-practice
+Version: 1.0
+Description: Check for non-recommended coding practices
+CreationDate: ma 20 mrt 2017 15:55:19 CET
+Maintainer: Willem Toorop
+Category:
+Component:
+CmdDepends:
+Depends:
+Help:
+Pre: 070-coding-practice.pre
+Post:
+Test: 070-coding-practice.test
+AuxFiles:
+Passed:
+Failure:
diff --git a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.pre b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.pre
new file mode 100644
index 00000000..150497af
--- /dev/null
+++ b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.pre
@@ -0,0 +1,14 @@
+# #-- 070-coding-practice.pre--#
+# source the master var file when it's there
+if [ -f ../.tpkg.var.master ]
+then
+ source ../.tpkg.var.master
+else
+ (
+ cd ..
+ [ -f "${TPKG_SRCDIR}/setup-env.sh" ] \
+ && sh "${TPKG_SRCDIR}/setup-env.sh"
+ ) && source ../.tpkg.var.master
+fi
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
diff --git a/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test
new file mode 100644
index 00000000..ae4b12fa
--- /dev/null
+++ b/src/test/tpkg/070-coding-practice.tpkg/070-coding-practice.test
@@ -0,0 +1,58 @@
+# #-- 070-coding-practice.test --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+
+rm -f report.txt
+(
+ cd ${SRCROOT}
+ find . -type f -executable -and \( -name "*.[ch]" -or -name "*.html" -or -name "*.in" -or -name "*.good" -or -name "*.ac" \) | sed 's/^/*** ERROR! Executable bit found on /g'
+) >> report.txt
+(
+ cd ${SRCROOT}/src
+ if [ `grep '[^!=]=[ ][ ]*NET_REQ_' *.[ch] */*.[ch] | wc -l` -gt 1 ]
+ then
+ echo "*** "
+ echo "*** Setting getdns_network_req->state should be done via"
+ echo "*** _getdns_netreq_change_state() only, for anticipating"
+ echo "*** running out of filedescriptors (sockets) and for the"
+ echo "*** limit_outstanding_queries feature."
+ echo "*** "
+ grep -n '[^!=]=[ ][ ]*NET_REQ_' *.[ch] */*.[ch] | \
+ grep -v '^request-internal.c:[12][0-9][0-9]: *net_req->state = NET_REQ_NOT_SENT;$'
+ echo ""
+ fi
+) >> report.txt
+(
+ cd ${SRCROOT}/src
+ if [ `grep '__FUNCTION__' *.[ch] */*.[ch] | wc -l` -gt 0 ]
+ then
+ echo "*** "
+ echo "*** Use __FUNC__ instead of __FUNCTION__ for portability"
+ echo "*** __FUNC__ is aliases in config.h to name to be used"
+ echo "*** for the system with a #define"
+ echo "*** "
+ grep -n '__FUNCTION__' *.[ch] */*.[ch]
+ echo ""
+ fi
+) >> report.txt
+(
+ cd ${SRCROOT}/src
+ if [ `grep '^#define[ ]*INTERCEPT_COM_DS[ ]*1' stub.c | wc -l` -gt 0 ]
+ then
+ echo "*** "
+ echo "*** The repo contained the COM DS queries interception"
+ echo "*** with TLS transports turned on, this should be off"
+ echo "*** "
+ grep -n '^#define[ ]INTERCEPT_COM_DS[ ]*1' stub.c
+ echo ""
+ fi
+) >> report.txt
+
+
+if [ -s report.txt ]
+then
+ cat report.txt
+ false
+fi
diff --git a/src/test/tpkg/080-iana-rr-types.tpkg/080-iana-rr-types.dsc b/src/test/tpkg/080-iana-rr-types.tpkg/080-iana-rr-types.dsc
new file mode 100644
index 00000000..9276794f
--- /dev/null
+++ b/src/test/tpkg/080-iana-rr-types.tpkg/080-iana-rr-types.dsc
@@ -0,0 +1,15 @@
+BaseName: 080-iana-rr-types
+Version: 1.0
+Description: Fetch dns-parameters.xml from iana and check all RR types
+CreationDate: di 2 mei 2017 15:11:53 CEST
+Maintainer: Willem Toorop
+Category:
+Component:
+Depends:
+CmdDepends: wget, grep
+Pre:
+Post:
+Test: 080-iana-rr-types.test
+AuxFiles:
+Passed:
+Failure:
diff --git a/src/test/tpkg/080-iana-rr-types.tpkg/080-iana-rr-types.test b/src/test/tpkg/080-iana-rr-types.tpkg/080-iana-rr-types.test
new file mode 100644
index 00000000..8605a6cf
--- /dev/null
+++ b/src/test/tpkg/080-iana-rr-types.tpkg/080-iana-rr-types.test
@@ -0,0 +1,51 @@
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+# svnserve resets the path, you may need to adjust it, like this:
+PATH=$PATH:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:.
+
+# first arg is the build dir
+TPKG_BUILD=$1
+PARAM_XML="dns-parameters.xml"
+PARAM_URL="http://www.iana.org/assignments/dns-parameters/$PARAM_XML"
+
+if [ -f $PARAM_XML ]
+then
+ mv $PARAM_XML ${PARAM_XML}.aandekant
+fi
+if which wget
+then
+ wget "$PARAM_URL"
+elif ! ( echo quit | ftp "$PARAM_URL" )
+then
+ echo "Don't have wget or ftp to get $PARAM_URL"
+ exit -1
+fi
+
+EXIT_STATUS=0
+
+for TYPE_VAL in `awk '/[^<>]*<\/type>/{ a=$1; getline; b=$1; print a""b }' dns-parameters.xml | sed -e 's///g' -e 's/<\/type>//g' -e 's//:/g' -e 's/<\/value>//g'|egrep -v '^(Unassigned|Private|Reserved)'`
+do
+ TYPE=${TYPE_VAL%:*}
+ VALUE=${TYPE_VAL#*:}
+ case "x$TYPE" in
+ x\*) TYPE="ANY"
+ ;;
+ xNSAP-PTR) TYPE="NSAP_PTR"
+ ;;
+ esac
+ if ! grep -q "LDNS_RR_TYPE_${TYPE} = ${VALUE}" ${SRCROOT}/src/gldns/rrdef.h
+ then
+ echo "RR type ${TYPE} (value ${VALUE}) not in rrdef.h"
+ EXIT_STATUS=1
+ fi
+ if ! grep -q "GETDNS_RRTYPE_${TYPE}[ ][ ]*${VALUE}" ${SRCROOT}/src/getdns/getdns.h.in
+ then
+ echo "RR type ${TYPE} (value ${VALUE}) not in getdns.h.in"
+ EXIT_STATUS=1
+ fi
+done
+
+exit $EXIT_STATUS
+
diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.test b/src/test/tpkg/100-compile.tpkg/100-compile.test
index e527192b..aeb9e084 100644
--- a/src/test/tpkg/100-compile.tpkg/100-compile.test
+++ b/src/test/tpkg/100-compile.tpkg/100-compile.test
@@ -5,4 +5,4 @@
[ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build"
-make
+make XTRA_CFLAGS='-Werror' -j 4
diff --git a/src/test/tpkg/105-install.tpkg/105-install.test b/src/test/tpkg/105-install.tpkg/105-install.test
index 7e94ce6e..16ccbfd2 100644
--- a/src/test/tpkg/105-install.tpkg/105-install.test
+++ b/src/test/tpkg/105-install.tpkg/105-install.test
@@ -5,4 +5,4 @@
[ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build"
-make install
+make -j 4 install
diff --git a/src/test/tpkg/110-link.tpkg/110-link.test b/src/test/tpkg/110-link.tpkg/110-link.test
index 424c9074..305132fb 100644
--- a/src/test/tpkg/110-link.tpkg/110-link.test
+++ b/src/test/tpkg/110-link.tpkg/110-link.test
@@ -5,6 +5,6 @@
[ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build"
-make getdns_query \
+make -j 4 getdns_query \
&& echo "export GETDNS_QUERY=\"${BUILDDIR}/build/src/tools/getdns_query\"" \
>> ../.tpkg.var.master
diff --git a/src/test/tpkg/115-install-linked.tpkg/115-install-linked.test b/src/test/tpkg/115-install-linked.tpkg/115-install-linked.test
index 7480aa03..550052b4 100644
--- a/src/test/tpkg/115-install-linked.tpkg/115-install-linked.test
+++ b/src/test/tpkg/115-install-linked.tpkg/115-install-linked.test
@@ -5,4 +5,4 @@
[ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build"
-make install-getdns_query
+make -j 4 install-getdns_query
diff --git a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test
index 369379c4..4b983110 100644
--- a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test
+++ b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test
@@ -5,4 +5,4 @@
[ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build-stub-only"
-make
+make XTRA_CFLAGS='-Werror' -j 4
diff --git a/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.test b/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.test
index 94aaf626..23e786cb 100644
--- a/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.test
+++ b/src/test/tpkg/210-stub-only-link.tpkg/210-stub-only-link.test
@@ -5,6 +5,6 @@
[ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build-stub-only"
-make getdns_query \
+make -j 4 getdns_query \
&& echo "export GETDNS_STUB_QUERY=\"${BUILDDIR}/build-stub-only/src/tools/getdns_query\"" \
>> ../.tpkg.var.master
diff --git a/src/test/tpkg/225-stub-only-valgrind-checks.tpkg/225-stub-only-valgrind-checks.dsc b/src/test/tpkg/225-stub-only-valgrind-checks.tpkg/225-stub-only-valgrind-checks.dsc
index d845ad44..7167a541 100644
--- a/src/test/tpkg/225-stub-only-valgrind-checks.tpkg/225-stub-only-valgrind-checks.dsc
+++ b/src/test/tpkg/225-stub-only-valgrind-checks.tpkg/225-stub-only-valgrind-checks.dsc
@@ -6,7 +6,7 @@ Maintainer: Willem Toorop
Category:
Component:
CmdDepends: valgrind
-Depends: 110-link.tpkg
+Depends: 210-stub-only-link.tpkg
Help:
Pre:
Post:
diff --git a/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.test b/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.test
index 1dee289d..5122d39a 100644
--- a/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.test
+++ b/src/test/tpkg/230-stub-only-run-unit-tests.tpkg/230-stub-only-run-unit-tests.test
@@ -5,4 +5,4 @@
[ -f .tpkg.var.test ] && source .tpkg.var.test
cd "${BUILDDIR}/build-stub-only"
-make test
+make -j 4 test
diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c
index 16933760..a8d16c6a 100644
--- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c
+++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.c
@@ -27,6 +27,14 @@ void print_list(getdns_list *rr_list)
free(str);
}
+void print_json_list(getdns_list *rr_list, int pretty)
+{
+ char *str = getdns_print_json_list(rr_list, pretty);
+ printf("%s\n", str);
+ free(str);
+}
+
+
void print_wire(uint8_t *wire, size_t wire_len)
{
size_t pos, i;
@@ -70,6 +78,7 @@ int main(int argc, char const * const argv[])
FILE *in;
uint8_t wire_buf[8200];
size_t i;
+ size_t uavailable;
int available;
char str_buf[10000];
int str_len = sizeof(str_buf);
@@ -253,6 +262,7 @@ int main(int argc, char const * const argv[])
fclose(in);
print_list(rr_list);
+ print_json_list(rr_list, 1);
/* Fill the wire_buf with wireformat RR's in rr_list
@@ -300,15 +310,20 @@ int main(int argc, char const * const argv[])
* Then fill a string buffer with those rr_dicts.
*/
available = wire - wire_buf;
+ if (available < 0) {
+ fprintf(stderr, "Negative sized buffer!\n");
+ exit(EXIT_FAILURE);
+ }
+ uavailable = available;
wire = wire_buf;
str = str_buf;
str_len = sizeof(str_buf);
- while (available > 0 && str_len > 0) {
+ while (uavailable > 0 && str_len > 0) {
rr_dict = NULL;
if ((r = getdns_wire2rr_dict_scan(
- (const uint8_t **)&wire, &available, &rr_dict)))
+ (const uint8_t **)&wire, &uavailable, &rr_dict)))
FAIL_r("getdns_wire2rr_dict_scan");
if ((r = getdns_rr_dict2str_scan(rr_dict, &str, &str_len)))
diff --git a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good
index 47278b10..b1acbd46 100644
--- a/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good
+++ b/src/test/tpkg/260-conversion-functions.tpkg/260-conversion-functions.good
@@ -1478,6 +1478,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.
"algorithm": 10,
"gateway_type": 0,
"precedence": 2,
+ "public_key": ,
"rdata_raw":
},
"ttl": 30,
@@ -1536,6 +1537,7 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.
"algorithm": 10,
"gateway_type": 0,
"precedence": 2,
+ "public_key": ,
"rdata_raw":
},
"ttl": 30,
@@ -1629,6 +1631,1537 @@ apl.net-dns.org. 3600 IN APL 1:192.168.42.0/26 1:192.168.42.64/26 !1:192.168.42.
"type": GETDNS_RRTYPE_TXT
}
]
+[
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "expire": 345600,
+ "minimum": 300,
+ "mname":"ns.nlnetlabs.nl.",
+ "rdata_raw":[2,110,115,9,110,108,110,101,116,108,97,98,115,2,110,108,0,8,115,121,115,97,100,109,105,110,9,110,108,110,101,116,108,97,98,115,2,110,108,0,120,27,181,72,0,0,1,194,0,0,2,88,0,5,70,0,0,0,1,44],
+ "refresh": 450,
+ "retry": 600,
+ "rname":"sysadmin.nlnetlabs.nl.",
+ "serial": 2015081800
+ },
+ "ttl": 30,
+ "type": 6
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "nsdname":"ns.nlnetlabs.nl.",
+ "rdata_raw":"ns.nlnetlabs.nl."
+ },
+ "ttl": 30,
+ "type": 2
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "nsdname":"ns.hactrn.net.",
+ "rdata_raw":"ns.hactrn.net."
+ },
+ "ttl": 30,
+ "type": 2
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "nsdname":"mcvax.nlnet.nl.",
+ "rdata_raw":"mcvax.nlnet.nl."
+ },
+ "ttl": 30,
+ "type": 2
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "nsdname":"sec2.authdns.ripe.net.",
+ "rdata_raw":"sec2.authdns.ripe.net."
+ },
+ "ttl": 30,
+ "type": 2
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "ipv4_address":"185.49.140.22",
+ "rdata_raw":[185,49,140,22]
+ },
+ "ttl": 30,
+ "type": 1
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "ipv6_address":"2a04:b900::2:0:0:22",
+ "rdata_raw":[42,4,185,0,0,0,0,0,0,2,0,0,0,0,0,34]
+ },
+ "ttl": 30,
+ "type": 28
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "exchange":"dicht.nlnetlabs.nl.",
+ "preference": 10,
+ "rdata_raw":[0,10,5,100,105,99,104,116,9,110,108,110,101,116,108,97,98,115,2,110,108,0]
+ },
+ "ttl": 30,
+ "type": 15
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "exchange":"mcvax.nlnet.nl.",
+ "preference": 20,
+ "rdata_raw":[0,20,5,109,99,118,97,120,5,110,108,110,101,116,2,110,108,0]
+ },
+ "ttl": 30,
+ "type": 15
+ },
+ {
+ "class": 1,
+ "name":"net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[16,78,101,116,58,58,68,78,83,32,32,100,111,109,97,105,110],
+ "txt_strings":
+ [
+ "Net::DNS domain"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"_443._tcp.net-dns.org.",
+ "rdata":
+ {
+ "certificate_association_data":[39,76,111,150,201,136,92,128,80,232,160,90,209,195,22,44,29,81,117,44,53,182,25,100,116,227,240,90,211,28,217,35],
+ "certificate_usage": 3,
+ "matching_type": 1,
+ "rdata_raw":[3,1,1,39,76,111,150,201,136,92,128,80,232,160,90,209,195,22,44,29,81,117,44,53,182,25,100,116,227,240,90,211,28,217,35],
+ "selector": 1
+ },
+ "ttl": 30,
+ "type": 52
+ },
+ {
+ "class": 1,
+ "name":"_443._tcp.www.net-dns.org.",
+ "rdata":
+ {
+ "certificate_association_data":[39,76,111,150,201,136,92,128,80,232,160,90,209,195,22,44,29,81,117,44,53,182,25,100,116,227,240,90,211,28,217,35],
+ "certificate_usage": 3,
+ "matching_type": 1,
+ "rdata_raw":[3,1,1,39,76,111,150,201,136,92,128,80,232,160,90,209,195,22,44,29,81,117,44,53,182,25,100,116,227,240,90,211,28,217,35],
+ "selector": 1
+ },
+ "ttl": 30,
+ "type": 52
+ },
+ {
+ "class": 1,
+ "name":"dynup.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[7,102,111,111,70,111,111,50,9,66,108,97,32,59,32,70,111,111],
+ "txt_strings":
+ [
+ "fooFoo2",
+ "Bla ; Foo"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"lists.net-dns.org.",
+ "rdata":
+ {
+ "ipv4_address":"63.209.15.196",
+ "rdata_raw":[63,209,15,196]
+ },
+ "ttl": 30,
+ "type": 1
+ },
+ {
+ "class": 1,
+ "name":"localhost.net-dns.org.",
+ "rdata":
+ {
+ "ipv4_address":"127.0.0.1",
+ "rdata_raw":[127,0,0,1]
+ },
+ "ttl": 30,
+ "type": 1
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,49,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 1 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,50,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 2 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,51,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 3 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,52,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 4 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,53,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 5 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,54,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 6 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,55,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 7 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,56,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 8 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[62,65,110,100,32,108,105,110,101,32,57,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 9 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,48,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 10 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,49,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 11 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,50,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 12 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,51,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 13 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,52,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 14 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,53,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 15 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,54,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 16 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,55,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 17 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,56,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 18 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,49,57,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 19 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,48,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 20 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,49,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 21 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,50,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 22 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,51,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 23 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,53,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 25 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,54,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 26 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,55,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 27 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,56,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 28 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,50,57,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 29 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,48,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 30 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,49,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 31 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,50,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 32 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,51,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 33 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,52,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 34 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,53,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 35 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,54,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 36 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,55,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 37 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,56,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 38 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,51,57,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 39 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,48,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 40 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,49,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 41 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,50,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 42 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,51,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 43 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,52,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 44 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,53,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 45 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,54,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 46 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,55,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 47 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,56,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 48 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,52,57,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 49 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,48,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 50 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,49,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 51 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,50,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 52 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,51,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 53 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,52,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 54 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,53,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 55 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,54,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 56 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,55,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 57 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,56,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 58 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,53,57,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 59 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[63,65,110,100,32,108,105,110,101,32,54,48,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 60 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[64,65,110,100,32,108,105,110,101,32,50,50,52,32,111,102,32,97,108,32,115,111,114,116,115,32,111,102,32,99,114,97,112,32,116,104,97,116,32,119,105,108,108,32,106,117,115,116,32,102,105,108,108,32,116,104,101,32,112,97,99,107,101,116,32],
+ "txt_strings":
+ [
+ "And line 224 of al sorts of crap that will just fill the packet "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"overflow.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[69,65,110,32,105,110,99,114,101,97,100,105,98,108,121,32,108,97,114,103,101,32,97,110,115,119,101,114,32,115,101,99,116,105,111,110,32,116,104,97,116,32,119,105,108,108,32,108,101,97,100,32,116,111,32,112,97,99,107,101,116,32,111,118,101,114,102,108,111,119],
+ "txt_strings":
+ [
+ "An increadibly large answer section that will lead to packet overflow"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"t.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[49,84,104,101,32,110,97,109,101,115,32,119,105,116,104,105,110,32,116,104,105,115,32,100,111,109,97,105,110,32,97,114,101,32,117,115,101,100,32,102,111,114,32,116,101,115,116,105,110,103],
+ "txt_strings":
+ [
+ "The names within this domain are used for testing"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"a.t.net-dns.org.",
+ "rdata":
+ {
+ "ipv4_address":"10.0.1.128",
+ "rdata_raw":[10,0,1,128]
+ },
+ "ttl": 30,
+ "type": 1
+ },
+ {
+ "class": 1,
+ "name":"a2.t.net-dns.org.",
+ "rdata":
+ {
+ "ipv4_address":"10.0.1.129",
+ "rdata_raw":[10,0,1,129]
+ },
+ "ttl": 30,
+ "type": 1
+ },
+ {
+ "class": 1,
+ "name":"cname.t.net-dns.org.",
+ "rdata":
+ {
+ "cname":"a.t.net-dns.org.",
+ "rdata_raw":"a.t.net-dns.org."
+ },
+ "ttl": 30,
+ "type": 5
+ },
+ {
+ "class": 1,
+ "name":"mx.t.net-dns.org.",
+ "rdata":
+ {
+ "exchange":"a.t.net-dns.org.",
+ "preference": 10,
+ "rdata_raw":[0,10,1,97,1,116,7,110,101,116,45,100,110,115,3,111,114,103,0]
+ },
+ "ttl": 30,
+ "type": 15
+ },
+ {
+ "class": 1,
+ "name":"mx2.t.net-dns.org.",
+ "rdata":
+ {
+ "exchange":"a.t.net-dns.org.",
+ "preference": 10,
+ "rdata_raw":[0,10,1,97,1,116,7,110,101,116,45,100,110,115,3,111,114,103,0]
+ },
+ "ttl": 30,
+ "type": 15
+ },
+ {
+ "class": 1,
+ "name":"mx2.t.net-dns.org.",
+ "rdata":
+ {
+ "exchange":"a2.t.net-dns.org.",
+ "preference": 15,
+ "rdata_raw":[0,15,2,97,50,1,116,7,110,101,116,45,100,110,115,3,111,114,103,0]
+ },
+ "ttl": 30,
+ "type": 15
+ },
+ {
+ "class": 1,
+ "name":"txt.t.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[7,78,101,116,45,68,78,83],
+ "txt_strings":
+ [
+ "Net-DNS"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"txt2.t.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[26,78,101,116,45,68,78,83,59,32,99,111,109,112,108,105,99,97,116,101,100,32,36,116,117,102,102,33,115,111,114,116,32,111,102,32,34,32,116,101,120,116,59,32,97,110,100,32,98,105,110,97,114,121,32,0,32,100,97,116,97],
+ "txt_strings":
+ [
+ "Net-DNS; complicated $tuff",
+ [115,111,114,116,32,111,102,32,34,32,116,101,120,116,59,32,97,110,100,32,98,105,110,97,114,121,32,0,32,100,97,116,97]
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"connection-test.t.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[22,99,111,110,110,101,99,116,105,111,110,45,116,101,115,116,32,115,117,99,99,101,115],
+ "txt_strings":
+ [
+ "connection-test succes"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"txt-utf8.t.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[9,229,143,164,230,177,160,227,130,132,12,232,155,153,233,163,155,232,190,188,227,130,128,9,230,176,180,227,129,174,233,159,179],
+ "txt_strings":
+ [
+ [229,143,164,230,177,160,227,130,132],
+ [232,155,153,233,163,155,232,190,188,227,130,128],
+ [230,176,180,227,129,174,233,159,179]
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"txt-utf8-bin.t.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[9,229,143,164,230,177,160,227,130,132,12,232,155,153,233,163,155,232,190,188,227,130,128,9,230,176,180,227,129,174,233,159,179],
+ "txt_strings":
+ [
+ [229,143,164,230,177,160,227,130,132],
+ [232,155,153,233,163,155,232,190,188,227,130,128],
+ [230,176,180,227,129,174,233,159,179]
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"a.few.empty.non.terminals.t.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[1,97,3,102,101,119,5,101,109,112,116,121,3,110,111,110,9,116,101,114,109,105,110,97,108,115],
+ "txt_strings":
+ [
+ "a",
+ "few",
+ "empty",
+ "non",
+ "terminals"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"a.few.empty.non.terminals.t.net-dns.org.",
+ "rdata":
+ {
+ "ipv4_address":"185.49.140.22",
+ "rdata_raw":[185,49,140,22]
+ },
+ "ttl": 30,
+ "type": 1
+ },
+ {
+ "class": 1,
+ "name":"a.few.empty.non.terminals.t.net-dns.org.",
+ "rdata":
+ {
+ "ipv6_address":"2a04:b900::2:0:0:22",
+ "rdata_raw":[42,4,185,0,0,0,0,0,0,2,0,0,0,0,0,34]
+ },
+ "ttl": 30,
+ "type": 28
+ },
+ {
+ "class": 1,
+ "name":"yx1.cname.t.net-dns.org.",
+ "rdata":
+ {
+ "cname":"-.t.net-dns.org.",
+ "rdata_raw":"-.t.net-dns.org."
+ },
+ "ttl": 30,
+ "type": 5
+ },
+ {
+ "class": 1,
+ "name":"yx2.cname.t.net-dns.org.",
+ "rdata":
+ {
+ "cname":"a-a.t.net-dns.org.",
+ "rdata_raw":"a-a.t.net-dns.org."
+ },
+ "ttl": 30,
+ "type": 5
+ },
+ {
+ "class": 1,
+ "name":"yx3.cname.t.net-dns.org.",
+ "rdata":
+ {
+ "cname":"a\..t.net-dns.org.",
+ "rdata_raw":"a\..t.net-dns.org."
+ },
+ "ttl": 30,
+ "type": 5
+ },
+ {
+ "class": 1,
+ "name":"yx4.cname.t.net-dns.org.",
+ "rdata":
+ {
+ "cname":"a\000.t.net-dns.org.",
+ "rdata_raw":"a\000.t.net-dns.org."
+ },
+ "ttl": 30,
+ "type": 5
+ },
+ {
+ "class": 1,
+ "name":"nx1.cname.t.net-dns.org.",
+ "rdata":
+ {
+ "cname":"does.not.exist.t.net-dns.org.",
+ "rdata_raw":"does.not.exist.t.net-dns.org."
+ },
+ "ttl": 30,
+ "type": 5
+ },
+ {
+ "class": 1,
+ "name":"nx2.cname.t.net-dns.org.",
+ "rdata":
+ {
+ "cname":"empty.non.terminals.t.net-dns.org.",
+ "rdata_raw":"empty.non.terminals.t.net-dns.org."
+ },
+ "ttl": 30,
+ "type": 5
+ },
+ {
+ "class": 1,
+ "name":"www.net-dns.org.",
+ "rdata":
+ {
+ "ipv4_address":"185.49.140.22",
+ "rdata_raw":[185,49,140,22]
+ },
+ "ttl": 30,
+ "type": 1
+ },
+ {
+ "class": 1,
+ "name":"www.net-dns.org.",
+ "rdata":
+ {
+ "ipv6_address":"2a04:b900::2:0:0:22",
+ "rdata_raw":[42,4,185,0,0,0,0,0,0,2,0,0,0,0,0,34]
+ },
+ "ttl": 30,
+ "type": 28
+ },
+ {
+ "class": 1,
+ "name":"apl.net-dns.org.",
+ "rdata":
+ {
+ "apitems":
+ [
+ {
+ "address_family": 1,
+ "afdpart":[192,168,42],
+ "n": 0,
+ "prefix": 26
+ },
+ {
+ "address_family": 1,
+ "afdpart":[192,168,42,64],
+ "n": 0,
+ "prefix": 26
+ },
+ {
+ "address_family": 1,
+ "afdpart":[192,168,42,128],
+ "n": 1,
+ "prefix": 25
+ },
+ {
+ "address_family": 1,
+ "afdpart":[224],
+ "n": 0,
+ "prefix": 4
+ },
+ {
+ "address_family": 2,
+ "afdpart":[255],
+ "n": 0,
+ "prefix": 8
+ }
+ ],
+ "rdata_raw":[0,1,26,3,192,168,42,0,1,26,4,192,168,42,64,0,1,25,132,192,168,42,128,0,1,4,1,224,0,2,8,1,255]
+ },
+ "ttl": 30,
+ "type": 42
+ },
+ {
+ "class": 1,
+ "name":"ipseckey0.net-dns.org.",
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway_type": 0,
+ "precedence": 2,
+ "public_key":[1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1],
+ "rdata_raw":[10,0,2,1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1]
+ },
+ "ttl": 30,
+ "type": 45
+ },
+ {
+ "class": 1,
+ "name":"ipseckey1.net-dns.org.",
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway":[192,0,2,38],
+ "gateway_type": 1,
+ "precedence": 2,
+ "public_key":[1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1],
+ "rdata_raw":[10,1,2,192,0,2,38,1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1]
+ },
+ "ttl": 30,
+ "type": 45
+ },
+ {
+ "class": 1,
+ "name":"ipseckey2.net-dns.org.",
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway":[32,1,13,184,0,0,128,2,0,0,0,0,32,0,0,1],
+ "gateway_type": 2,
+ "precedence": 2,
+ "public_key":[1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1],
+ "rdata_raw":[10,2,2,32,1,13,184,0,0,128,2,0,0,0,0,32,0,0,1,1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1]
+ },
+ "ttl": 30,
+ "type": 45
+ },
+ {
+ "class": 1,
+ "name":"ipseckey3.net-dns.org.",
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway":"mygateway.example.com.",
+ "gateway_type": 3,
+ "precedence": 2,
+ "public_key":[1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1],
+ "rdata_raw":[10,3,2,9,109,121,103,97,116,101,119,97,121,7,101,120,97,109,112,108,101,3,99,111,109,0,1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1]
+ },
+ "ttl": 30,
+ "type": 45
+ },
+ {
+ "class": 1,
+ "name":"ipseckey.net-dns.org.",
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway_type": 0,
+ "precedence": 2,
+ "public_key":[1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1],
+ "rdata_raw":[10,0,2,1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1]
+ },
+ "ttl": 30,
+ "type": 45
+ },
+ {
+ "class": 1,
+ "name":"ipseckey.net-dns.org.",
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway":[192,0,2,38],
+ "gateway_type": 1,
+ "precedence": 2,
+ "public_key":[1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1],
+ "rdata_raw":[10,1,2,192,0,2,38,1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1]
+ },
+ "ttl": 30,
+ "type": 45
+ },
+ {
+ "class": 1,
+ "name":"ipseckey.net-dns.org.",
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway":[32,1,13,184,0,0,128,2,0,0,0,0,32,0,0,1],
+ "gateway_type": 2,
+ "precedence": 2,
+ "public_key":[1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1],
+ "rdata_raw":[10,2,2,32,1,13,184,0,0,128,2,0,0,0,0,32,0,0,1,1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1]
+ },
+ "ttl": 30,
+ "type": 45
+ },
+ {
+ "class": 1,
+ "name":"ipseckey.net-dns.org.",
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway":"mygateway.example.com.",
+ "gateway_type": 3,
+ "precedence": 2,
+ "public_key":[1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1],
+ "rdata_raw":[10,3,2,9,109,121,103,97,116,101,119,97,121,7,101,120,97,109,112,108,101,3,99,111,109,0,1,3,81,83,121,134,237,53,83,59,96,100,71,142,238,178,123,91,215,77,174,20,155,110,129,186,58,5,33,175,130,171,120,1]
+ },
+ "ttl": 30,
+ "type": 45
+ },
+ {
+ "class": 1,
+ "name":"default._domainkey.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[253,118,61,68,75,73,77,49,59,32,114,61,112,111,115,116,109,97,115,116,101,114,59,32,103,61,42,59,32,107,61,114,115,97,59,32,112,61,77,73,71,102,77,65,48,71,67,83,113,71,83,73,98,51,68,81,69,66,65,81,85,65,65,52,71,78,65,68,67,66,105,81,75,66,103,81,68,86,71,47,108,102,70,53,71,116,80,108,77,79,99,83,71,110,102,98,112,53,117,43,69,87,77,43,79,79,103,47,102,54,81,109,98,68,88,79,87,47,122,75,81,107,82,73,82,73,90,43,66,116,102,83,89,99,104,80,56,77,101,70,80,102,77,118,85,90,116,100,82,80,122,67,87,103,49,71,55,79,100,68,55,113,97,84,85,113,99,54,107,86,56,52,111,110,54,47,56,107,80,86,77,103,100,68,76,121,76,108,50,68,101,85,47,76,116,115,57,104,102,86,72,86,68,83,112,87,117,67,104,119,68,65,70,88,110,98,110,87,56,106,112,112,53,52,122,117,111,102,57,79,73,98,87,83,87,73,120,90,113,76,76,56,102,108,103,79,115,81,73,68,65,81,65,66],
+ "txt_strings":
+ [
+ "v=DKIM1; r=postmaster; g=*; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDVG/lfF5GtPlMOcSGnfbp5u+EWM+OOg/f6QmbDXOW/zKQkRIRIZ+BtfSYchP8MeFPfMvUZtdRPzCWg1G7OdD7qaTUqc6kV84on6/8kPVMgdDLyLl2DeU/Lts9hfVHVDSpWuChwDAFXnbnW8jpp54zuof9OIbWSWIxZqLL8flgOsQIDAQAB"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"2.3.3.updates.spamassassin.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[8,49,52,49,56,50,49,57,32],
+ "txt_strings":
+ [
+ "1418219 "
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ },
+ {
+ "class": 1,
+ "name":"mirrors.updates.spamassassin.net-dns.org.",
+ "rdata":
+ {
+ "rdata_raw":[60,104,116,116,112,58,47,47,97,110,111,110,121,109,111,117,115,64,115,112,97,109,97,115,115,97,115,115,105,110,46,97,112,97,99,104,101,46,111,114,103,47,117,112,100,97,116,101,115,47,77,73,82,82,79,82,69,68,46,66,89],
+ "txt_strings":
+ [
+ "http://anonymous@spamassassin.apache.org/updates/MIRRORED.BY"
+ ]
+ },
+ "ttl": 30,
+ "type": 16
+ }
+]
record 0, available buffer space: 8117
record 1, available buffer space: 8077
record 2, available buffer space: 8039
diff --git a/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.Makefile b/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.Makefile
new file mode 100644
index 00000000..c297df6d
--- /dev/null
+++ b/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.Makefile
@@ -0,0 +1,15 @@
+builddir = @BUILDDIR@
+testname = @TPKG_NAME@
+LIBTOOL = $(builddir)/libtool
+
+CFLAGS=-I$(builddir)/src
+LDLIBS=$(builddir)/src/libgetdns.la
+
+.SUFFIXES: .c .o .a .lo .h
+
+.c.lo:
+ $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@
+
+$(testname): $(testname).lo
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDLIBS) $(LDFLAGS) -o $(testname) $(testname).lo
+
diff --git a/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.c b/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.c
new file mode 100644
index 00000000..176d3c6e
--- /dev/null
+++ b/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.c
@@ -0,0 +1,127 @@
+#include
+#include
+#include
+#include
+#include
+
+#define FAIL(...) do { \
+ fprintf(stderr, "ERROR in %s:%d, ", __FILE__, __LINE__); \
+ fprintf(stderr, __VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ exit(EXIT_FAILURE); \
+ } while (0)
+
+#define FAIL_r(function_name) FAIL( "%s returned %d: %s", function_name \
+ , (int)r, getdns_get_errorstr_by_id(r));
+
+void print_dict(getdns_dict *rr_dict)
+{
+ char *str = getdns_pretty_print_dict(rr_dict);
+ printf("%s\n", str);
+ free(str);
+}
+
+void print_list(getdns_list *rr_list)
+{
+ char *str = getdns_pretty_print_list(rr_list);
+ printf("%s\n", str);
+ free(str);
+}
+
+void print_wire(uint8_t *wire, size_t wire_len)
+{
+ size_t pos, i;
+
+ for (pos = 0; pos < wire_len; pos += 16) {
+ printf("%.4zx", pos);
+ for (i = 0; i < 16; i++) {
+ if (i % 8 == 0)
+ printf(" ");
+ if (pos + i < wire_len)
+ printf(" %.2x", (int)wire[pos + i]);
+ else
+ printf(" ");
+ }
+ printf(" ");
+ for (i = 0; i < 16; i++) {
+ if (i % 8 == 0)
+ printf(" ");
+ if (pos + i < wire_len && isprint(wire[pos + i]))
+ printf("%c", wire[pos + i]);
+ else
+ printf(".");
+ }
+ printf("\n");
+ }
+}
+
+
+int main(int argc, char const * const argv[])
+{
+ getdns_return_t r;
+ getdns_list *rr_list;
+ FILE *in;
+ uint8_t wirebuf[16384];
+ uint8_t *bufptr = wirebuf;
+ int bufsz = sizeof(wirebuf);
+ int msgsz;
+ size_t rr_list_len;
+ getdns_dict *rr_dict;
+ size_t i;
+ getdns_dict *msg_dict;
+ char *msg_str;
+
+ if (!(in = fopen(argv[1], "r")))
+ FAIL("Could not fopen %s\n", argv[1]);
+
+ if ((r = getdns_fp2rr_list(in, &rr_list, NULL, 0)))
+ FAIL_r("getdns_fp2rr_list");
+
+ fclose(in);
+
+ print_list(rr_list);
+
+ if ((r = getdns_list_get_length(rr_list, &rr_list_len)))
+ FAIL_r("getdns_list_get_length");
+
+ *bufptr++ = 0; *bufptr++ = 0;
+ *bufptr++ = 0; *bufptr++ = 0;
+ *bufptr++ = 0; *bufptr++ = 0;
+ *(uint16_t *)bufptr = htons((uint16_t)rr_list_len); bufptr += 2;
+ *bufptr++ = 0; *bufptr++ = 0;
+ *bufptr++ = 0; *bufptr++ = 0;
+ bufsz -= 12;
+
+ for (i = 0; i < rr_list_len; i++) {
+ if ((r = getdns_list_get_dict(rr_list, i, &rr_dict)))
+ FAIL_r("getdns_list_get_dict");
+
+ if ((r = getdns_dict_remove_name(rr_dict, "/rdata/rdata_raw")))
+ FAIL_r("getdns_dict_remove_name");
+
+ if ((r = getdns_rr_dict2wire_scan(rr_dict, &bufptr, &bufsz))) {
+ char *rr_dict_str = getdns_pretty_print_dict(rr_dict);
+ fprintf(stderr, "getdns_rr_dict2wire_scan failed: %s"
+ " with rr_dict %s\n"
+ , getdns_get_errorstr_by_id(r)
+ , rr_dict_str );
+ free(rr_dict_str);
+ }
+
+ /* printf("bufptr: %p, bufsz: %d\n", bufptr, bufsz); */
+ }
+ msgsz = sizeof(wirebuf) - bufsz;
+
+ if ((r = getdns_wire2msg_dict(wirebuf, msgsz, &msg_dict)))
+ FAIL_r("getdns_wire2msg_dict");
+
+ if ((r = getdns_msg_dict2str(msg_dict, &msg_str)))
+ FAIL_r("getdns_msg_dict2str");
+
+ printf("%s\n", msg_str);
+
+ free(msg_str);
+ getdns_dict_destroy(msg_dict);
+ getdns_list_destroy(rr_list);
+ exit(EXIT_SUCCESS);
+}
diff --git a/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.dsc b/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.dsc
new file mode 100644
index 00000000..ea49490e
--- /dev/null
+++ b/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.dsc
@@ -0,0 +1,16 @@
+BaseName: 265-supported-rrs
+Version: 1.0
+Description: Test supported resource records
+CreationDate: do 20 apr 2017 11:31:29 CEST
+Maintainer: Hoda Rohani
+Category:
+Component:
+CmdDepends:
+Depends: 200-stub-only-compile.tpkg
+Help:
+Pre: 265-supported-rrs.pre
+Post:
+Test: 265-supported-rrs.test
+AuxFiles:
+Passed:
+Failure:
diff --git a/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.good b/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.good
new file mode 100644
index 00000000..6db36868
--- /dev/null
+++ b/src/test/tpkg/265-supported-rrs.tpkg/265-supported-rrs.good
@@ -0,0 +1,1112 @@
+[
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "expire": 345600,
+ "minimum": 300,
+ "mname": ,
+ "rdata_raw": ,
+ "refresh": 450,
+ "retry": 600,
+ "rname": ,
+ "serial": 2015081800
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_SOA
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "nsdname": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_NS
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "ipv4_address": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_A
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "ipv6_address": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_AAAA
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "exchange": ,
+ "preference": 10,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_MX
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "rdata_raw": ,
+ "txt_strings":
+ [
+
+ ]
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_TXT
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "ipv4_address": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_A
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "ipv4_address": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_A
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "ipv6_address": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_AAAA
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "hostname": ,
+ "rdata_raw": ,
+ "subtype": 12
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_AFSDB
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "apitems":
+ [
+ {
+ "address_family": 1,
+ "afdpart": ,
+ "n": 0,
+ "prefix": 26
+ },
+ {
+ "address_family": 1,
+ "afdpart": ,
+ "n": 0,
+ "prefix": 26
+ },
+ {
+ "address_family": 1,
+ "afdpart": ,
+ "n": 1,
+ "prefix": 25
+ },
+ {
+ "address_family": 1,
+ "afdpart": ,
+ "n": 0,
+ "prefix": 4
+ },
+ {
+ "address_family": 2,
+ "afdpart": ,
+ "n": 0,
+ "prefix": 8
+ }
+ ],
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_APL
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "format": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_ATMA
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "flags": 0,
+ "rdata_raw": ,
+ "tag": ,
+ "value":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_CAA
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 5,
+ "flags": 256,
+ "protocol": 3,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_CDNSKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 3,
+ "digest": ,
+ "digest_type": 1,
+ "key_tag": 13026,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_CDS
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 1,
+ "certificate_or_crl": ,
+ "key_tag": 65535,
+ "rdata_raw": ,
+ "type": GETDNS_RRTYPE_A
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_CERT
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "cname": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_CNAME
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "flags": 3,
+ "rdata_raw": ,
+ "serial": 66,
+ "type_bit_maps":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_CSYNC
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "dhcid_opaque": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_DHCID
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 3,
+ "digest": ,
+ "digest_type": 1,
+ "key_tag": 13026,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_DLV
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "rdata_raw": ,
+ "target":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_DNAME
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 5,
+ "flags": 256,
+ "protocol": 3,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_DNSKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 3,
+ "digest": ,
+ "digest_type": 1,
+ "key_tag": 13026,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_DS
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "endpoint_identifier": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_EID
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "eui48_address": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_EUI48
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "eui64_address": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_EUI64
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "altitude": ,
+ "latitude": ,
+ "longitude": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_GPOS
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "cpu": ,
+ "os": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_HINFO
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "hit": ,
+ "pk_algorithm": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_HIP
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway_type": 0,
+ "precedence": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_IPSECKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway": ,
+ "gateway_type": 1,
+ "precedence": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_IPSECKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway": ,
+ "gateway_type": 2,
+ "precedence": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_IPSECKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway": ,
+ "gateway_type": 3,
+ "precedence": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_IPSECKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway_type": 0,
+ "precedence": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_IPSECKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway": ,
+ "gateway_type": 1,
+ "precedence": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_IPSECKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway": ,
+ "gateway_type": 2,
+ "precedence": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_IPSECKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "algorithm": 10,
+ "gateway": ,
+ "gateway_type": 3,
+ "precedence": 2,
+ "public_key": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_IPSECKEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "isdn_address": ,
+ "rdata_raw": ,
+ "sa":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_ISDN
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "key_obsolete": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_KEY
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "exchanger": ,
+ "preference": 10,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_KX
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "loc_obsolete": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_LOC
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "fqdn": ,
+ "preference": 10,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_LP
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "locator32": ,
+ "preference": 10,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_L32
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "locator64": ,
+ "preference": 10,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_L64
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name": ,
+ "rdata":
+ {
+ "madname": ,
+ "rdata_raw":
+ },
+ "ttl": 30,
+ "type": GETDNS_RRTYPE_MB
+ },
+ {
+ "class": GETDNS_RRCLASS_IN,
+ "name":