mirror of https://github.com/getdnsapi/getdns.git
Merge branch 'develop' into devel/1.1.0
This commit is contained in:
commit
f1c44dc15c
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
* 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
|
||||
|
|
14
Makefile.in
14
Makefile.in
|
@ -150,18 +150,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 >$@
|
||||
|
|
43
README.md
43
README.md
|
@ -19,6 +19,8 @@ Traditional access to DNS data from applications has several limitations:
|
|||
|
||||
* 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 a 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.
|
||||
|
@ -73,9 +75,13 @@ If you want to make use of the configuration files that utilise a JSON-like form
|
|||
|
||||
before building.
|
||||
|
||||
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
|
||||
As well as building the getdns library 2 other tools are installed by default by the above process:
|
||||
|
||||
* getdns_query: a command line test script wrapper for getdns
|
||||
* stubby: a experimental DNS Privacy enabled client
|
||||
|
||||
Note: If you only want to build stubby, then use the `--enable-stub-only` and `--without-libidn` options when running 'configure'.
|
||||
|
||||
# make getdns_query
|
||||
|
||||
## Minimizing dependencies
|
||||
|
||||
|
@ -83,7 +89,7 @@ If you want to use the getdns_query command line wrapper script for testing or t
|
|||
* 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.
|
||||
|
||||
|
@ -91,6 +97,18 @@ The implementation works with a variety of event loops, each built as a separate
|
|||
* [libuv](https://github.com/joyent/libuv)
|
||||
* [libev](http://software.schmorp.de/pkg/libev.html)
|
||||
|
||||
## Stubby
|
||||
|
||||
* Stubby is an experimental implementation of a DNS Privacy enabled stub resolver. It is currently suitable for advanced/technical users - all feedback is welcome! Also see [dnsprivacy.org](https://dnsprivacy.org) for more information on DNS Privacy and stubby.
|
||||
* By default stubby will attempt to use 'Opportunistic' Privacy for DNS queries.
|
||||
* A sample configuration file is available in the source code (src/tools/stubby.conf) which uses 'Strict' Privacy and some of the available test DNS Privacy servers to resolve queries. Note these servers are test servers that offer no service guarantees. The location of a configuration file can be specified with the '-C' flag
|
||||
* RECOMMENDED: Minimal logging output from Stubby is available (e.g. which servers are used and connection level statistics) by also using the '--enable-debug-daemon' flag when running 'configure'.
|
||||
|
||||
To use stubby
|
||||
* Start stubby from the command line
|
||||
* Test it by doing, for example, 'dig @127.0.0.1 www.example.com'
|
||||
* Alter the default DNS resolvers on your system to point at localhost (127.0.0.1, ::1)
|
||||
|
||||
## Regression Tests
|
||||
|
||||
A suite of regression tests are included with the library, if you make changes or just
|
||||
|
@ -124,7 +142,7 @@ We have a [getdns users list](https://getdnsapi.net/mailman/listinfo/users) for
|
|||
|
||||
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/Bug Reports
|
||||
# Tickets and Bug Reports
|
||||
|
||||
Tickets and bug reports should be reported via the [GitHub issues list](https://github.com/getdnsapi/getdns/issues).
|
||||
|
||||
|
@ -179,7 +197,18 @@ Stub mode does not support:
|
|||
|
||||
# Known Issues
|
||||
|
||||
* None
|
||||
* The synchronous lookup functions will not work when new file descriptors
|
||||
needed for the lookup will be larger than `FD_SETSIZE`. This is because
|
||||
the synchronous functions use a "default" event loop under the hood
|
||||
which is based on `select()` and thus inherits the limits that `select()` has.
|
||||
|
||||
If you need only slightly more file descriptors, it is possible to enlarge
|
||||
the `FD_SETSIZE` with the `--with-fd-setsize=`*`size`* flag to `configure`.
|
||||
|
||||
To resolve, use the asynchronous functions with an event loop extension for
|
||||
libevent, libev or libuv. Note that the asynchronous functions will have
|
||||
the same problem when used in combination with `getdns_context_run()`, which
|
||||
also uses the default event loop.
|
||||
|
||||
# Supported Platforms
|
||||
|
||||
|
@ -203,7 +232,7 @@ 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
|
||||
means that the packaging platform requires ruby 2.1.0. There are other ways to
|
||||
|
@ -261,7 +290,7 @@ 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.2j
|
||||
* libidn
|
||||
|
|
54
configure.ac
54
configure.ac
|
@ -96,9 +96,16 @@ 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"],[],[])
|
||||
AC_SUBST(WPEDANTICFLAG)
|
||||
AC_SUBST(WNOERRORFLAG)
|
||||
|
||||
case "$host_os" in
|
||||
linux* ) CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE"
|
||||
|
@ -256,7 +263,7 @@ fi
|
|||
AC_CHECK_HEADERS([openssl/conf.h],,, [AC_INCLUDES_DEFAULT])
|
||||
AC_CHECK_HEADERS([openssl/engine.h],,, [AC_INCLUDES_DEFAULT])
|
||||
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])
|
||||
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])
|
||||
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
|
||||
|
@ -443,39 +450,38 @@ 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(all-drafts, AC_HELP_STRING([--enable-all-drafts], [No drafts in this release]))
|
||||
case "$enable_all_drafts" in
|
||||
yes)
|
||||
enable_draft_dnssec_roadblock_avoidance=yes
|
||||
enable_draft_edns_cookies=yes
|
||||
;;
|
||||
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.])
|
||||
|
@ -964,6 +970,14 @@ fi
|
|||
#---- check for pthreads library
|
||||
AC_SEARCH_LIBS([pthread_mutex_init],[pthread],[AC_DEFINE([HAVE_PTHREADS], [1], [Have pthreads library])], [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
|
||||
|
@ -1080,6 +1094,12 @@ AC_DEFINE_UNQUOTED([MAX_CNAME_REFERRALS], [100], [The maximum number of cname re
|
|||
|
||||
AH_BOTTOM([
|
||||
|
||||
#ifdef HAVE___FUNC__
|
||||
#define __FUNC__ __func__
|
||||
#else
|
||||
#define __FUNC__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
#ifdef GETDNS_ON_WINDOWS
|
||||
/* On windows it is allowed to increase the FD_SETSIZE
|
||||
* (and nescessary to make our custom eventloop work)
|
||||
|
|
|
@ -149,24 +149,16 @@ depend:
|
|||
|
||||
# Dependencies for the examples
|
||||
example-all-functions.lo example-all-functions.o: $(srcdir)/example-all-functions.c $(srcdir)/getdns_libevent.h \
|
||||
../../src/config.h \
|
||||
../../src/getdns/getdns.h \
|
||||
$(srcdir)/../../src/getdns/getdns_ext_libevent.h \
|
||||
../../src/getdns/getdns_extra.h
|
||||
example-reverse.lo example-reverse.o: $(srcdir)/example-reverse.c $(srcdir)/getdns_libevent.h \
|
||||
../../src/config.h \
|
||||
../../src/getdns/getdns.h \
|
||||
$(srcdir)/../../src/getdns/getdns_ext_libevent.h \
|
||||
../../src/config.h ../../src/getdns/getdns.h \
|
||||
$(srcdir)/../../src/getdns/getdns_ext_libevent.h ../../src/getdns/getdns_extra.h
|
||||
example-reverse.lo example-reverse.o: $(srcdir)/example-reverse.c $(srcdir)/getdns_libevent.h ../../src/config.h \
|
||||
../../src/getdns/getdns.h $(srcdir)/../../src/getdns/getdns_ext_libevent.h \
|
||||
../../src/getdns/getdns_extra.h
|
||||
example-simple-answers.lo example-simple-answers.o: $(srcdir)/example-simple-answers.c $(srcdir)/getdns_libevent.h \
|
||||
../../src/config.h \
|
||||
../../src/getdns/getdns.h \
|
||||
$(srcdir)/../../src/getdns/getdns_ext_libevent.h \
|
||||
../../src/getdns/getdns_extra.h
|
||||
../../src/config.h ../../src/getdns/getdns.h \
|
||||
$(srcdir)/../../src/getdns/getdns_ext_libevent.h ../../src/getdns/getdns_extra.h
|
||||
example-synchronous.lo example-synchronous.o: $(srcdir)/example-synchronous.c $(srcdir)/getdns_core_only.h \
|
||||
../../src/getdns/getdns.h
|
||||
example-tree.lo example-tree.o: $(srcdir)/example-tree.c $(srcdir)/getdns_libevent.h \
|
||||
../../src/config.h \
|
||||
../../src/getdns/getdns.h \
|
||||
$(srcdir)/../../src/getdns/getdns_ext_libevent.h \
|
||||
example-tree.lo example-tree.o: $(srcdir)/example-tree.c $(srcdir)/getdns_libevent.h ../../src/config.h \
|
||||
../../src/getdns/getdns.h $(srcdir)/../../src/getdns/getdns_ext_libevent.h \
|
||||
../../src/getdns/getdns_extra.h
|
||||
|
|
337
src/Makefile.in
337
src/Makefile.in
|
@ -48,7 +48,9 @@ srcdir = @srcdir@
|
|||
LIBTOOL = ../libtool
|
||||
|
||||
CC=@CC@
|
||||
CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@
|
||||
CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@ $(XTRA_CFLAGS)
|
||||
WPEDANTICFLAG=@WPEDANTICFLAG@
|
||||
WNOERRORFLAG=@WNOERRORFLAG@
|
||||
LDFLAGS=@LDFLAGS@ @LIBS@
|
||||
|
||||
EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@
|
||||
|
@ -65,7 +67,8 @@ C99COMPATFLAGS=@C99COMPATFLAGS@
|
|||
|
||||
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
|
||||
|
@ -85,38 +88,38 @@ 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)
|
||||
|
||||
$(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) -m 755 -d $(DESTDIR)$(includedir)
|
||||
|
@ -139,19 +142,18 @@ uninstall:
|
|||
if test $(have_libev) = 1; then $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(EXTENSION_LIBEV_LIB) ; fi
|
||||
|
||||
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
|
||||
|
||||
$(LIBTOOL) --tag=CC --mode=link $(CC) -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
|
||||
|
||||
test: all
|
||||
cd test && $(MAKE) $@
|
||||
|
@ -211,207 +213,132 @@ depend:
|
|||
FORCE:
|
||||
|
||||
# Dependencies for gldns, utils, the extensions and compat functions
|
||||
const-info.lo const-info.o: $(srcdir)/const-info.c \
|
||||
getdns/getdns.h \
|
||||
getdns/getdns_extra.h \
|
||||
$(srcdir)/const-info.h
|
||||
context.lo context.o: $(srcdir)/context.c \
|
||||
config.h \
|
||||
$(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 \
|
||||
const-info.lo const-info.o: $(srcdir)/const-info.c getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/const-info.h
|
||||
context.lo context.o: $(srcdir)/context.c config.h $(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 \
|
||||
getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.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
|
||||
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)/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
|
||||
dict.lo dict.o: $(srcdir)/dict.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 \
|
||||
convert.lo convert.o: $(srcdir)/convert.c config.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.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/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
|
||||
dict.lo dict.o: $(srcdir)/dict.c config.h $(srcdir)/types-internal.h getdns/getdns.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h \
|
||||
$(srcdir)/context.h $(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.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
|
||||
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 \
|
||||
dnssec.lo dnssec.o: $(srcdir)/dnssec.c config.h $(srcdir)/debug.h getdns/getdns.h $(srcdir)/context.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.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
|
||||
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
|
||||
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 \
|
||||
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
|
||||
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
|
||||
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)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/dict.h \
|
||||
$(srcdir)/convert.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
|
||||
rr-iter.lo rr-iter.o: $(srcdir)/rr-iter.c $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
|
||||
config.h \
|
||||
getdns/getdns.h \
|
||||
general.lo general.o: $(srcdir)/general.c config.h $(srcdir)/general.h getdns/getdns.h $(srcdir)/types-internal.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/ub_loop.h $(srcdir)/debug.h \
|
||||
$(srcdir)/gldns/wire2str.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h config.h \
|
||||
getdns/getdns_extra.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)/mdns.h
|
||||
list.lo list.o: $(srcdir)/list.c $(srcdir)/types-internal.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
getdns/getdns.h $(srcdir)/util/rbtree.h $(srcdir)/util-internal.h config.h $(srcdir)/context.h \
|
||||
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.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
|
||||
mdns.lo mdns.o: $(srcdir)/mdns.c config.h $(srcdir)/debug.h $(srcdir)/context.h getdns/getdns.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h $(srcdir)/ub_loop.h \
|
||||
$(srcdir)/server.h $(srcdir)/general.h $(srcdir)/gldns/pkthdr.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \
|
||||
$(srcdir)/gldns/gbuffer.h $(srcdir)/mdns.h
|
||||
pubkey-pinning.lo pubkey-pinning.o: $(srcdir)/pubkey-pinning.c config.h $(srcdir)/debug.h getdns/getdns.h \
|
||||
$(srcdir)/context.h getdns/getdns.h getdns/getdns_extra.h $(srcdir)/types-internal.h \
|
||||
$(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h config.h \
|
||||
getdns/getdns_extra.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
|
||||
request-internal.lo request-internal.o: $(srcdir)/request-internal.c config.h $(srcdir)/types-internal.h \
|
||||
getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h config.h \
|
||||
getdns/getdns_extra.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/rrdef.h $(srcdir)/gldns/str2wire.h \
|
||||
$(srcdir)/gldns/rrdef.h $(srcdir)/dict.h $(srcdir)/convert.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 getdns/getdns.h \
|
||||
$(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/default_eventloop.h config.h \
|
||||
getdns/getdns_extra.h $(srcdir)/ub_loop.h $(srcdir)/debug.h $(srcdir)/server.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 \
|
||||
$(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/rrdef.h
|
||||
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
|
||||
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-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 \
|
||||
server.lo server.o: $(srcdir)/server.c config.h getdns/getdns_extra.h getdns/getdns.h \
|
||||
$(srcdir)/context.h getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.h $(srcdir)/ub_loop.h \
|
||||
$(srcdir)/debug.h $(srcdir)/server.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 getdns/getdns.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 config.h getdns/getdns_extra.h $(srcdir)/ub_loop.h \
|
||||
$(srcdir)/server.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 \
|
||||
getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/extension/default_eventloop.h config.h getdns/getdns_extra.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)/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
|
||||
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 \
|
||||
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
|
||||
gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/gbuffer.h
|
||||
keyraw.lo keyraw.o: $(srcdir)/gldns/keyraw.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/keyraw.h $(srcdir)/gldns/rrdef.h
|
||||
parse.lo parse.o: $(srcdir)/gldns/parse.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h
|
||||
parseutil.lo parseutil.o: $(srcdir)/gldns/parseutil.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/parseutil.h
|
||||
rrdef.lo rrdef.o: $(srcdir)/gldns/rrdef.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/rrdef.h $(srcdir)/gldns/parseutil.h
|
||||
str2wire.lo str2wire.o: $(srcdir)/gldns/str2wire.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h
|
||||
wire2str.lo wire2str.o: $(srcdir)/gldns/wire2str.c \
|
||||
config.h \
|
||||
$(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/pkthdr.h \
|
||||
$(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/keyraw.h
|
||||
arc4_lock.lo arc4_lock.o: $(srcdir)/compat/arc4_lock.c \
|
||||
config.h
|
||||
arc4random.lo arc4random.o: $(srcdir)/compat/arc4random.c \
|
||||
config.h \
|
||||
$(srcdir)/compat/chacha_private.h
|
||||
arc4random_uniform.lo arc4random_uniform.o: $(srcdir)/compat/arc4random_uniform.c \
|
||||
config.h
|
||||
explicit_bzero.lo explicit_bzero.o: $(srcdir)/compat/explicit_bzero.c \
|
||||
config.h
|
||||
getentropy_linux.lo getentropy_linux.o: $(srcdir)/compat/getentropy_linux.c \
|
||||
config.h
|
||||
getentropy_osx.lo getentropy_osx.o: $(srcdir)/compat/getentropy_osx.c \
|
||||
config.h
|
||||
getentropy_solaris.lo getentropy_solaris.o: $(srcdir)/compat/getentropy_solaris.c \
|
||||
config.h
|
||||
getentropy_win.lo getentropy_win.o: $(srcdir)/compat/getentropy_win.c
|
||||
inet_ntop.lo inet_ntop.o: $(srcdir)/compat/inet_ntop.c \
|
||||
config.h
|
||||
inet_pton.lo inet_pton.o: $(srcdir)/compat/inet_pton.c \
|
||||
config.h
|
||||
sha512.lo sha512.o: $(srcdir)/compat/sha512.c \
|
||||
config.h
|
||||
strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c \
|
||||
config.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
|
||||
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
|
||||
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 \
|
||||
ub_loop.lo ub_loop.o: $(srcdir)/ub_loop.c $(srcdir)/ub_loop.h config.h getdns/getdns.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.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
|
||||
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
|
||||
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
|
||||
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 getdns/getdns_extra.h getdns/getdns.h \
|
||||
$(srcdir)/list.h $(srcdir)/util-internal.h $(srcdir)/context.h $(srcdir)/extension/default_eventloop.h config.h \
|
||||
getdns/getdns_extra.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
|
||||
version.lo version.o: version.c
|
||||
gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c config.h $(srcdir)/gldns/gbuffer.h
|
||||
keyraw.lo keyraw.o: $(srcdir)/gldns/keyraw.c config.h $(srcdir)/gldns/keyraw.h $(srcdir)/gldns/rrdef.h
|
||||
parse.lo parse.o: $(srcdir)/gldns/parse.c config.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h \
|
||||
$(srcdir)/gldns/gbuffer.h
|
||||
parseutil.lo parseutil.o: $(srcdir)/gldns/parseutil.c config.h $(srcdir)/gldns/parseutil.h
|
||||
rrdef.lo rrdef.o: $(srcdir)/gldns/rrdef.c config.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/parseutil.h
|
||||
str2wire.lo str2wire.o: $(srcdir)/gldns/str2wire.c config.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \
|
||||
$(srcdir)/gldns/wire2str.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h
|
||||
wire2str.lo wire2str.o: $(srcdir)/gldns/wire2str.c config.h $(srcdir)/gldns/wire2str.h $(srcdir)/gldns/str2wire.h \
|
||||
$(srcdir)/gldns/rrdef.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/parseutil.h $(srcdir)/gldns/gbuffer.h \
|
||||
$(srcdir)/gldns/keyraw.h
|
||||
arc4_lock.lo arc4_lock.o: $(srcdir)/compat/arc4_lock.c config.h
|
||||
arc4random.lo arc4random.o: $(srcdir)/compat/arc4random.c config.h $(srcdir)/compat/chacha_private.h
|
||||
arc4random_uniform.lo arc4random_uniform.o: $(srcdir)/compat/arc4random_uniform.c config.h
|
||||
explicit_bzero.lo explicit_bzero.o: $(srcdir)/compat/explicit_bzero.c config.h
|
||||
getentropy_linux.lo getentropy_linux.o: $(srcdir)/compat/getentropy_linux.c config.h
|
||||
getentropy_osx.lo getentropy_osx.o: $(srcdir)/compat/getentropy_osx.c config.h
|
||||
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 config.h
|
||||
sha512.lo sha512.o: $(srcdir)/compat/sha512.c config.h
|
||||
strlcpy.lo strlcpy.o: $(srcdir)/compat/strlcpy.c config.h
|
||||
rbtree.lo rbtree.o: $(srcdir)/util/rbtree.c config.h $(srcdir)/util/log.h $(srcdir)/debug.h config.h \
|
||||
$(srcdir)/util/fptr_wlist.h $(srcdir)/util/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 config.h $(srcdir)/gldns/rrdef.h $(srcdir)/gldns/keyraw.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 config.h \
|
||||
$(srcdir)/extension/default_eventloop.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
$(srcdir)/debug.h config.h $(srcdir)/types-internal.h getdns/getdns.h getdns/getdns_extra.h \
|
||||
$(srcdir)/util/rbtree.h
|
||||
libev.lo libev.o: $(srcdir)/extension/libev.c config.h $(srcdir)/types-internal.h getdns/getdns.h \
|
||||
getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/getdns/getdns_ext_libev.h getdns/getdns_extra.h
|
||||
libevent.lo libevent.o: $(srcdir)/extension/libevent.c config.h $(srcdir)/types-internal.h \
|
||||
getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/getdns/getdns_ext_libevent.h getdns/getdns_extra.h
|
||||
libuv.lo libuv.o: $(srcdir)/extension/libuv.c config.h $(srcdir)/debug.h config.h $(srcdir)/types-internal.h \
|
||||
getdns/getdns.h getdns/getdns_extra.h getdns/getdns.h $(srcdir)/util/rbtree.h \
|
||||
$(srcdir)/getdns/getdns_ext_libuv.h getdns/getdns_extra.h
|
||||
|
|
|
@ -48,9 +48,65 @@ 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 windows-(or at least non pthread) specific lock routines here */
|
||||
/* XXX - add non pthread specific lock routines here */
|
||||
void _ARC4_LOCK(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
#ifndef GETDNS_ON_WINDOWS
|
||||
#include <sys/mman.h>
|
||||
#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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2016 Christian Huitema <huitema@huitema.net>
|
||||
*
|
||||
* 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 */
|
|
@ -188,6 +188,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 },
|
||||
|
|
126
src/context.c
126
src/context.c
|
@ -62,6 +62,11 @@ typedef unsigned short in_port_t;
|
|||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_PTHREADS
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "config.h"
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
#include <unbound.h>
|
||||
|
@ -88,6 +93,11 @@ typedef unsigned short in_port_t;
|
|||
upstream. Using 1 hour for all transports - based on RFC7858 value for for TLS.*/
|
||||
#define BACKOFF_RETRY 3600
|
||||
|
||||
#ifdef HAVE_PTHREADS
|
||||
static pthread_mutex_t ssl_init_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
#endif
|
||||
static bool ssl_init=false;
|
||||
|
||||
void *plain_mem_funcs_user_arg = MF_PLAIN;
|
||||
|
||||
typedef struct host_name_addrs {
|
||||
|
@ -155,7 +165,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
|
||||
|
@ -184,7 +194,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;
|
||||
}
|
||||
|
@ -196,7 +206,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;
|
||||
|
@ -204,7 +214,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;
|
||||
|
@ -440,7 +450,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;
|
||||
|
||||
|
@ -682,7 +692,13 @@ _getdns_upstreams_dereference(getdns_upstreams *upstreams)
|
|||
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);
|
||||
|
@ -693,15 +709,6 @@ _getdns_upstreams_dereference(getdns_upstreams *upstreams)
|
|||
GETDNS_FREE(upstreams->mf, upstreams);
|
||||
}
|
||||
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
static char*
|
||||
getdns_auth_str_array[] = {
|
||||
GETDNS_STR_AUTH_NONE,
|
||||
GETDNS_STR_AUTH_FAILED,
|
||||
GETDNS_STR_AUTH_OK
|
||||
};
|
||||
#endif
|
||||
|
||||
void
|
||||
_getdns_upstream_shutdown(getdns_upstream *upstream)
|
||||
{
|
||||
|
@ -716,14 +723,19 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
|
|||
if (upstream->tls_auth_state > upstream->best_tls_auth_state)
|
||||
upstream->best_tls_auth_state = upstream->tls_auth_state;
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
DEBUG_DAEMON("%s %s : Conn closed: Conn stats - Resp=%d,Timeouts=%d,Auth=%s,Keepalive(ms)=%d\n",
|
||||
DEBUG_DAEMON("%s %s : Conn closed : Transport=%s - Resp=%d,Timeouts=%d,Auth=%s,Keepalive(ms)=%d\n",
|
||||
STUB_DEBUG_DAEMON, upstream->addr_str,
|
||||
(upstream->transport == GETDNS_TRANSPORT_TLS ? "TLS" : "TCP"),
|
||||
(int)upstream->responses_received, (int)upstream->responses_timeouts,
|
||||
getdns_auth_str_array[upstream->tls_auth_state], (int)upstream->keepalive_timeout);
|
||||
DEBUG_DAEMON("%s %s : Upstream stats - Resp=%d,Timeouts=%d,Best_auth=%s,Conns=%d,Conn_fails=%d,Conn_shutdowns=%d,Backoffs=%d\n",
|
||||
_getdns_auth_str(upstream->tls_auth_state), (int)upstream->keepalive_timeout);
|
||||
DEBUG_DAEMON("%s %s : Upstream stats: Transport=%s - Resp=%d,Timeouts=%d,Best_auth=%s\n",
|
||||
STUB_DEBUG_DAEMON, upstream->addr_str,
|
||||
(upstream->transport == GETDNS_TRANSPORT_TLS ? "TLS" : "TCP"),
|
||||
(int)upstream->total_responses, (int)upstream->total_timeouts,
|
||||
getdns_auth_str_array[upstream->best_tls_auth_state],
|
||||
_getdns_auth_str(upstream->best_tls_auth_state));
|
||||
DEBUG_DAEMON("%s %s : Upstream stats: Transport=%s - Conns=%d,Conn_fails=%d,Conn_shutdowns=%d,Backoffs=%d\n",
|
||||
STUB_DEBUG_DAEMON, 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);
|
||||
#endif
|
||||
|
@ -750,7 +762,7 @@ _getdns_upstream_shutdown(getdns_upstream *upstream)
|
|||
upstream->conn_shutdowns = 0;
|
||||
upstream->conn_backoffs++;
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
DEBUG_DAEMON("%s %s : !Backing off this upstream - will retry as new upstream at %s\n",
|
||||
DEBUG_DAEMON("%s %s : !Backing off this upstream - Will retry as new upstream at %s",
|
||||
STUB_DEBUG_DAEMON, upstream->addr_str,
|
||||
asctime(gmtime(&upstream->conn_retry_time)));
|
||||
#endif
|
||||
|
@ -770,7 +782,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*/
|
||||
|
@ -779,8 +795,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;
|
||||
}
|
||||
|
@ -829,7 +848,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];
|
||||
}
|
||||
|
@ -900,6 +919,8 @@ upstream_init(getdns_upstream *upstream,
|
|||
/* How is this upstream doing on UDP? */
|
||||
upstream->to_retry = 2;
|
||||
upstream->back_off = 1;
|
||||
upstream->udp_responses = 0;
|
||||
upstream->udp_timeouts = 0;
|
||||
|
||||
/* For sharing a socket to this upstream with TCP */
|
||||
upstream->fd = -1;
|
||||
|
@ -1013,6 +1034,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 =
|
||||
|
@ -1045,15 +1067,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++) {
|
||||
|
@ -1070,11 +1093,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)) {
|
||||
|
@ -1412,8 +1436,21 @@ getdns_context_create_with_extended_memory_functions(
|
|||
/* 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_PTHREADS
|
||||
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_PTHREADS
|
||||
pthread_mutex_unlock(&ssl_init_lock);
|
||||
#else
|
||||
/* XXX implement Windows-style unlock here */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
result->unbound_ctx = NULL;
|
||||
|
@ -1619,7 +1656,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))
|
||||
|
@ -1633,7 +1670,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
|
||||
|
@ -1776,12 +1813,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);
|
||||
|
@ -1991,11 +2033,13 @@ getdns_context_set_tls_authentication(getdns_context *context,
|
|||
return GETDNS_RETURN_GOOD;
|
||||
} /* getdns_context_set_tls_authentication_list */
|
||||
|
||||
#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
|
||||
*
|
||||
|
@ -2005,7 +2049,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,
|
||||
|
@ -2309,7 +2355,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)
|
||||
|
@ -2377,11 +2423,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
|
||||
*
|
||||
|
@ -2391,7 +2439,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);
|
||||
|
@ -2659,6 +2709,7 @@ error:
|
|||
} /* getdns_context_set_upstream_recursive_servers */
|
||||
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
static void
|
||||
set_ub_edns_maximum_udp_payload_size(struct getdns_context* context,
|
||||
int value) {
|
||||
|
@ -2666,6 +2717,7 @@ set_ub_edns_maximum_udp_payload_size(struct getdns_context* context,
|
|||
if (value >= 512 && value <= 65535)
|
||||
set_ub_number_opt(context, "edns-buffer-size:", (uint16_t)value);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* getdns_context_set_edns_maximum_udp_payload_size
|
||||
|
@ -2682,7 +2734,9 @@ getdns_context_set_edns_maximum_udp_payload_size(struct getdns_context *context,
|
|||
if (value < 512)
|
||||
value = 512;
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
set_ub_edns_maximum_udp_payload_size(context, value);
|
||||
#endif
|
||||
if (value != context->edns_maximum_udp_payload_size) {
|
||||
context->edns_maximum_udp_payload_size = value;
|
||||
dispatch_updated(context,
|
||||
|
@ -3069,7 +3123,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);
|
||||
|
@ -3547,7 +3601,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;
|
||||
|
|
|
@ -131,6 +131,8 @@ typedef struct getdns_upstream {
|
|||
/* How is this upstream doing over UDP? */
|
||||
int to_retry;
|
||||
int back_off;
|
||||
size_t udp_responses;
|
||||
size_t udp_timeouts;
|
||||
|
||||
/* For stateful upstreams, need to share the connection and track the
|
||||
activity on the connection */
|
||||
|
@ -222,7 +224,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;
|
||||
|
@ -307,19 +309,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;
|
||||
|
||||
/*
|
||||
|
|
|
@ -57,8 +57,14 @@
|
|||
#include "convert.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* stuff to make it compile pedantically */
|
||||
#define UNUSED_PARAM(x) ((void)(x))
|
||||
/* strdup is marked deprecated by the Windows compiler */
|
||||
#ifndef STRDUP
|
||||
#ifdef GETDNS_ON_WINDOWS
|
||||
#define STRDUP(x) _strdup(x)
|
||||
#else
|
||||
#define STRDUP(x) strdup(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
getdns_return_t
|
||||
getdns_convert_dns_name_to_fqdn(
|
||||
|
@ -154,6 +160,7 @@ getdns_convert_ulabel_to_alabel(const char *ulabel)
|
|||
free(prepped2);
|
||||
return buf;
|
||||
#else
|
||||
(void)ulabel;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
@ -183,6 +190,7 @@ getdns_convert_alabel_to_ulabel(const char *alabel)
|
|||
}
|
||||
return buf;
|
||||
#else
|
||||
(void)alabel;
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
@ -204,7 +212,7 @@ getdns_display_ip_address(const struct getdns_bindata
|
|||
buff,
|
||||
256);
|
||||
if (ipStr) {
|
||||
return strdup(ipStr);
|
||||
return STRDUP(ipStr);
|
||||
}
|
||||
} else if (bindata_of_ipv4_or_ipv6_address->size == 16) {
|
||||
const char *ipStr = inet_ntop(AF_INET6,
|
||||
|
@ -212,7 +220,7 @@ getdns_display_ip_address(const struct getdns_bindata
|
|||
buff,
|
||||
256);
|
||||
if (ipStr) {
|
||||
return strdup(ipStr);
|
||||
return STRDUP(ipStr);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
@ -1186,7 +1194,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);
|
||||
|
@ -1199,7 +1207,8 @@ static int _jsmn_get_ipdict(struct mem_funcs *mf, const char *js, jsmntok_t *t,
|
|||
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 ||
|
||||
|
@ -1240,8 +1249,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);
|
||||
|
@ -1257,7 +1267,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);
|
||||
|
@ -1287,7 +1297,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);
|
||||
|
@ -1310,14 +1320,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);
|
||||
|
@ -1327,13 +1336,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);
|
||||
|
@ -1367,7 +1375,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;
|
||||
|
||||
|
@ -1387,7 +1396,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(
|
||||
|
@ -1445,7 +1454,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)
|
||||
|
@ -1524,8 +1534,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;
|
||||
}
|
||||
|
|
28
src/debug.h
28
src/debug.h
|
@ -47,6 +47,21 @@
|
|||
#define STUB_DEBUG_CLEANUP "--- CLEANUP: "
|
||||
#define STUB_DEBUG_DAEMON "GETDNS_DAEMON: "
|
||||
|
||||
#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; \
|
||||
|
@ -58,6 +73,7 @@
|
|||
fprintf(stderr, "[%s.%.6d] ", buf, (int)tv.tv_usec); \
|
||||
fprintf(stderr, __VA_ARGS__); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#define DEBUG_NL(...) do { \
|
||||
struct timeval tv; \
|
||||
|
@ -110,5 +126,17 @@
|
|||
#define DEBUG_SERVER(...) DEBUG_OFF(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define MDNS_DEBUG_ENTRY "-> MDNS ENTRY: "
|
||||
#define MDNS_DEBUG_READ "-- MDNS READ: "
|
||||
#define MDNS_DEBUG_WRITE "-- MDNS WRITE: "
|
||||
#define MDNS_DEBUG_CLEANUP "-- MDNS CLEANUP:"
|
||||
|
||||
#if defined(MDNS_DEBUG) && MDNS_DEBUG
|
||||
#include <time.h>
|
||||
#define DEBUG_MDNS(...) DEBUG_ON(__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_MDNS(...) DEBUG_OFF(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* debug.h */
|
||||
|
|
21
src/dict.c
21
src/dict.c
|
@ -54,7 +54,7 @@
|
|||
|
||||
|
||||
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 +65,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 ((unsigned)(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++)
|
||||
|
@ -735,14 +735,13 @@ _getdns_bindata_is_dname(getdns_bindata *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 +886,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;
|
||||
|
||||
|
@ -1096,7 +1095,7 @@ getdns_pp_dict(gldns_buffer * buf, size_t indent,
|
|||
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;
|
||||
|
@ -1189,7 +1188,7 @@ getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict)
|
|||
|
||||
gldns_buffer_init_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 *
|
||||
|
@ -1223,7 +1222,7 @@ getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list)
|
|||
|
||||
gldns_buffer_init_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 *
|
||||
|
@ -1258,7 +1257,7 @@ getdns_snprint_json_dict(
|
|||
|
||||
gldns_buffer_init_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 *
|
||||
|
@ -1293,7 +1292,7 @@ getdns_snprint_json_list(
|
|||
|
||||
gldns_buffer_init_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 */
|
||||
|
|
21
src/dnssec.c
21
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;
|
||||
|
||||
|
@ -559,7 +559,7 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf,
|
|||
if (! _dname_is_parent(*label, head->rrset.name))
|
||||
break;
|
||||
}
|
||||
if (label - labels > max_labels) {
|
||||
if ((unsigned)(label - labels) > max_labels) {
|
||||
max_labels = label - labels;
|
||||
max_head = head;
|
||||
}
|
||||
|
@ -616,6 +616,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 +862,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
|
||||
}
|
||||
|
@ -1089,6 +1095,9 @@ static void val_chain_node_soa_cb(getdns_dns_req *dnsreq)
|
|||
_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
|
||||
|
@ -1314,7 +1323,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 +1635,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 +1880,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);
|
||||
|
|
|
@ -25,21 +25,25 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "extension/default_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
|
||||
|
@ -50,7 +54,7 @@ default_eventloop_schedule(getdns_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;
|
||||
|
@ -71,18 +75,17 @@ default_eventloop_schedule(getdns_eventloop *loop,
|
|||
if (default_loop->fd_events[fd] == event) {
|
||||
DEBUG_SCHED("WARNING: Event %p not cleared "
|
||||
"before being rescheduled!\n"
|
||||
, default_loop->fd_events[fd]);
|
||||
, (void *)default_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 *)default_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;
|
||||
|
||||
event->ev = (void *)(intptr_t)(fd + 1);
|
||||
DEBUG_SCHED( "scheduled read/write at %d\n", fd);
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
@ -101,9 +104,8 @@ default_eventloop_schedule(getdns_eventloop *loop,
|
|||
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;
|
||||
|
||||
default_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;
|
||||
}
|
||||
|
@ -121,10 +123,10 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
|
|||
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) {
|
||||
|
@ -132,7 +134,7 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
|
|||
if (default_loop->timeout_events[i] != event)
|
||||
DEBUG_SCHED( "ERROR: Different/wrong event present at "
|
||||
"timeout slot: %p!\n"
|
||||
, default_loop->timeout_events[i]);
|
||||
, (void *)default_loop->timeout_events[i]);
|
||||
#endif
|
||||
default_loop->timeout_events[i] = NULL;
|
||||
} else {
|
||||
|
@ -140,7 +142,7 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
|
|||
if (default_loop->fd_events[i] != event)
|
||||
DEBUG_SCHED( "ERROR: Different/wrong event present at "
|
||||
"fd slot: %p!\n"
|
||||
, default_loop->fd_events[i]);
|
||||
, (void *)default_loop->fd_events[i]);
|
||||
#endif
|
||||
default_loop->fd_events[i] = NULL;
|
||||
}
|
||||
|
@ -151,26 +153,36 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event)
|
|||
static void
|
||||
default_eventloop_cleanup(getdns_eventloop *loop)
|
||||
{
|
||||
(void)loop;
|
||||
}
|
||||
|
||||
static void
|
||||
default_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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -181,7 +193,7 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking)
|
|||
|
||||
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;
|
||||
|
||||
|
@ -200,7 +212,7 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking)
|
|||
else if (default_loop->timeout_times[i] < timeout)
|
||||
timeout = default_loop->timeout_times[i];
|
||||
}
|
||||
for (fd = 0; fd < FD_SETSIZE; fd++) {
|
||||
for (fd = 0; fd < (int)FD_SETSIZE; fd++) {
|
||||
if (!default_loop->fd_events[fd])
|
||||
continue;
|
||||
if (default_loop->fd_events[fd]->read_cb)
|
||||
|
@ -212,23 +224,23 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking)
|
|||
if (default_loop->fd_timeout_times[fd] < timeout)
|
||||
timeout = default_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);
|
||||
}
|
||||
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++) {
|
||||
for (fd = 0; fd < (int)FD_SETSIZE; fd++) {
|
||||
if (default_loop->fd_events[fd] &&
|
||||
default_loop->fd_events[fd]->read_cb &&
|
||||
FD_ISSET(fd, &readfds))
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "dnssec.h"
|
||||
#include "stub.h"
|
||||
#include "dict.h"
|
||||
#include "mdns.h"
|
||||
|
||||
/* cancel, cleanup and send timeout to callback */
|
||||
static void
|
||||
|
@ -476,6 +477,28 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
|
|||
( 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)))
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
}
|
||||
}
|
||||
/* 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
|
||||
|
|
|
@ -485,6 +485,7 @@ 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
|
||||
/** @}
|
||||
*/
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -693,7 +693,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;
|
||||
}
|
||||
|
@ -1369,7 +1369,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;
|
||||
|
@ -1932,7 +1932,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 +2000,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;
|
||||
|
|
|
@ -668,7 +668,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 +789,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++);
|
||||
|
@ -1983,10 +1984,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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,361 @@
|
|||
/*
|
||||
* Functions for MDNS resolving.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Christian Huitema <huitema@huitema.net>
|
||||
*
|
||||
* 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 "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)
|
||||
#endif
|
||||
|
||||
uint64_t _getdns_get_time_as_uintt64();
|
||||
|
||||
/*
|
||||
* Constants defined in RFC 6762
|
||||
*/
|
||||
|
||||
#define MDNS_MCAST_IPV4_LONG 0xE00000FB /* 224.0.0.251 */
|
||||
#define MDNS_MCAST_PORT 5353
|
||||
|
||||
/*
|
||||
* TODO: When we start supporting IPv6 with MDNS, need to define this:
|
||||
* 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',
|
||||
7, 'i', 'p', 'v', '6',
|
||||
4, 'a', 'r', 'p', 'a', 0 };
|
||||
static uint8_t mdns_suffix_9_e_f_ip6_arpa[] = {
|
||||
1, '9', 1, 'e', 1, 'f',
|
||||
7, 'i', 'p', 'v', '6',
|
||||
4, 'a', 'r', 'p', 'a', 0 };
|
||||
static uint8_t mdns_suffix_a_e_f_ip6_arpa[] = {
|
||||
1, 'a', 1, 'e', 1, 'f',
|
||||
7, 'i', 'p', 'v', '6',
|
||||
4, 'a', 'r', 'p', 'a', 0 };
|
||||
static uint8_t mdns_suffix_b_e_f_ip6_arpa[] = {
|
||||
1, 'b', 1, 'e', 1, 'f',
|
||||
7, 'i', 'p', 'v', '6',
|
||||
4, 'a', 'r', 'p', 'a', 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, __FUNCTION__, netreq);
|
||||
getdns_dns_req *dnsreq = netreq->owner;
|
||||
|
||||
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
|
||||
|
||||
GETDNS_NULL_FREE(dnsreq->context->mf, netreq->tcp.read_buf);
|
||||
}
|
||||
|
||||
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, __FUNCTION__, 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
|
||||
netreq->state = 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 */
|
||||
/**************************/
|
||||
|
||||
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,
|
||||
__FUNCTION__, 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) != netreq->query_id)
|
||||
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();
|
||||
netreq->state = 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,
|
||||
__FUNCTION__, netreq);
|
||||
|
||||
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
|
||||
|
||||
netreq->debug_start_time = _getdns_get_time_as_uintt64();
|
||||
netreq->debug_udp = 1;
|
||||
netreq->query_id = (uint16_t) arc4random();
|
||||
GLDNS_ID_SET(netreq->query, netreq->query_id);
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
/* 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, dnsreq->context->timeout,
|
||||
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, __FUNCTION__,
|
||||
netreq, netreq->request_type);
|
||||
int fd = -1;
|
||||
getdns_dns_req *dnsreq = netreq->owner;
|
||||
|
||||
/* 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, dnsreq->context->timeout,
|
||||
getdns_eventloop_event_init(&netreq->event, netreq,
|
||||
NULL, mdns_udp_write_cb, mdns_timeout_cb));
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 */
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Functions for MDNS resolving.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2016 Christian Huitema <huitema@huitema.net>
|
||||
*
|
||||
* 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"
|
||||
|
||||
getdns_return_t
|
||||
_getdns_submit_mdns_request(getdns_network_req *netreq);
|
||||
|
||||
getdns_return_t
|
||||
_getdns_mdns_namespace_check(getdns_dns_req *dnsreq);
|
||||
#endif /* HAVE_MDNS_SUPPORT */
|
||||
|
||||
#endif /* MDNS_H */
|
|
@ -97,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 };
|
||||
|
@ -382,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;
|
||||
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;
|
||||
|
||||
|
@ -407,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(X509_STORE_CTX_get0_untrusted(store)); 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(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);
|
||||
|
@ -442,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;
|
||||
|
|
|
@ -65,20 +65,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;
|
||||
|
@ -262,10 +262,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,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 +474,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 +491,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 +548,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 +565,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 +573,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 +614,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;
|
||||
|
@ -939,7 +939,7 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
|
|||
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);
|
||||
|
||||
|
@ -950,7 +950,7 @@ _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);
|
||||
|
||||
|
|
311
src/rr-dict.c
311
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
|
||||
|
@ -107,6 +108,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
|
||||
|
@ -335,6 +337,7 @@ 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;
|
||||
|
@ -397,6 +400,7 @@ static _getdns_rdf_special hip_pk_algorithm = {
|
|||
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;
|
||||
|
@ -429,7 +433,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;
|
||||
}
|
||||
|
@ -467,6 +471,7 @@ 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);
|
||||
|
@ -501,7 +506,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;
|
||||
}
|
||||
|
@ -537,222 +542,222 @@ static _getdns_rdf_special hip_public_key = {
|
|||
|
||||
|
||||
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 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 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 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 },
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
21
src/server.c
21
src/server.c
|
@ -108,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;
|
||||
|
@ -359,7 +359,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 = read(conn->fd, conn->read_pos, conn->to_read)) < 0) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||
return; /* Come back to do the read later */
|
||||
|
||||
|
@ -655,7 +655,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];
|
||||
|
||||
|
@ -666,7 +666,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)
|
||||
|
@ -749,9 +749,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 */
|
||||
|
@ -809,10 +809,9 @@ getdns_return_t getdns_context_set_listen_addresses(
|
|||
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, <func>, %p)\n",
|
||||
(void *)context, (void *)listen_addresses);
|
||||
|
||||
listen_addresses);
|
||||
if (!(mf = &context->mf))
|
||||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
|
||||
|
@ -849,7 +848,7 @@ getdns_return_t getdns_context_set_listen_addresses(
|
|||
_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;
|
||||
|
|
226
src/stub.c
226
src/stub.c
|
@ -86,7 +86,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 +96,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 +252,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 */
|
||||
|
@ -343,7 +343,7 @@ process_keepalive(
|
|||
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 recieved: %d ms\n",
|
||||
STUB_DEBUG_READ, __FUNCTION__, upstream->fd,
|
||||
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;
|
||||
|
@ -355,7 +355,7 @@ process_keepalive(
|
|||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +385,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;
|
||||
|
||||
|
@ -398,6 +398,7 @@ 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;
|
||||
|
@ -413,12 +414,18 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport)
|
|||
}
|
||||
}
|
||||
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;
|
||||
|
@ -474,7 +481,7 @@ 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;
|
||||
|
@ -483,7 +490,7 @@ stub_cleanup(getdns_network_req *netreq)
|
|||
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) */
|
||||
|
@ -514,7 +521,7 @@ 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);
|
||||
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
|
||||
|
@ -555,9 +562,15 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -565,12 +578,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;
|
||||
/* Handle upstream*/
|
||||
if (netreq->fd >= 0) {
|
||||
#ifdef USE_WINSOCK
|
||||
closesocket(netreq->fd);
|
||||
#else
|
||||
close(netreq->fd);
|
||||
#endif
|
||||
netreq->upstream->udp_timeouts++;
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
if (netreq->upstream->udp_timeouts % 100 == 0)
|
||||
DEBUG_DAEMON("%s %s : Upstream stats: Transport=UDP - Resp=%d,Timeouts=%d\n",
|
||||
STUB_DEBUG_DAEMON, netreq->upstream->addr_str,
|
||||
(int)netreq->upstream->udp_responses, (int)netreq->upstream->udp_timeouts);
|
||||
#endif
|
||||
stub_next_upstream(netreq);
|
||||
} else {
|
||||
netreq->upstream->responses_timeouts++;
|
||||
|
@ -588,7 +612,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;
|
||||
|
@ -601,7 +625,7 @@ upstream_setup_timeout_cb(void *userarg)
|
|||
{
|
||||
getdns_upstream *upstream = (getdns_upstream *)userarg;
|
||||
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);
|
||||
|
||||
|
@ -619,7 +643,7 @@ upstream_setup_timeout_cb(void *userarg)
|
|||
ret = select(upstream->fd+1, NULL, &fds, NULL, &tval);
|
||||
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);
|
||||
}
|
||||
|
@ -647,7 +671,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
|
||||
|
@ -656,7 +680,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;
|
||||
|
@ -739,7 +763,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;
|
||||
|
@ -764,12 +788,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.
|
||||
|
@ -791,8 +815,13 @@ 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;
|
||||
|
@ -830,48 +859,65 @@ 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
|
||||
|
||||
/* First deal with the hostname authentication done by OpenSSL. */
|
||||
#ifdef X509_V_ERR_HOSTNAME_MISMATCH
|
||||
/*Report if error is hostname mismatch*/
|
||||
if (upstream && upstream->tls_fallback_ok && err == X509_V_ERR_HOSTNAME_MISMATCH) {
|
||||
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, __FUNCTION__, upstream->fd);
|
||||
upstream->tls_auth_state = GETDNS_AUTH_FAILED;
|
||||
}
|
||||
STUB_DEBUG_SETUP_TLS, __FUNC__, upstream->fd);
|
||||
#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 {
|
||||
/* If we _only_ had a pinset and it is good then force succesful
|
||||
authentication when the cert self-signed */
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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*
|
||||
|
@ -904,7 +950,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*/
|
||||
|
@ -915,7 +961,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;
|
||||
}
|
||||
|
@ -929,27 +975,27 @@ 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);
|
||||
|
@ -964,7 +1010,7 @@ tls_create_object(getdns_dns_req *dnsreq, int fd, getdns_upstream *upstream)
|
|||
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,
|
||||
__FUNCTION__);
|
||||
__FUNC__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -975,7 +1021,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();
|
||||
|
@ -1001,7 +1047,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;
|
||||
}
|
||||
|
@ -1012,8 +1058,9 @@ tls_do_handshake(getdns_upstream *upstream)
|
|||
/* 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 %d. Session is %s.\n",
|
||||
STUB_DEBUG_SETUP_TLS, __FUNCTION__, upstream->fd, upstream->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);
|
||||
|
@ -1188,7 +1235,7 @@ 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;
|
||||
|
@ -1224,12 +1271,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;
|
||||
}
|
||||
|
@ -1237,6 +1284,7 @@ _getdns_get_time_as_uintt64() {
|
|||
return now;
|
||||
}
|
||||
|
||||
|
||||
/**************************/
|
||||
/* UDP callback functions */
|
||||
/**************************/
|
||||
|
@ -1249,7 +1297,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);
|
||||
__FUNC__, (void*)netreq);
|
||||
|
||||
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
|
||||
|
||||
|
@ -1274,11 +1322,15 @@ stub_udp_read_cb(void *userarg)
|
|||
upstream, netreq->response, read))
|
||||
return; /* Client cookie didn't match? */
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
closesocket(netreq->fd);
|
||||
#else
|
||||
close(netreq->fd);
|
||||
netreq->fd = -1;
|
||||
#endif
|
||||
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 =
|
||||
|
@ -1302,6 +1354,14 @@ stub_udp_read_cb(void *userarg)
|
|||
dnsreq->upstreams->current_udp = 0;
|
||||
netreq->debug_end_time = _getdns_get_time_as_uintt64();
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
upstream->udp_responses++;
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
if (upstream->udp_responses == 1 ||
|
||||
upstream->udp_responses % 100 == 0)
|
||||
DEBUG_DAEMON("%s %s : Upstream stats: Transport=UDP - Resp=%d,Timeouts=%d\n",
|
||||
STUB_DEBUG_DAEMON, upstream->addr_str,
|
||||
(int)upstream->udp_responses, (int)upstream->udp_timeouts);
|
||||
#endif
|
||||
_getdns_check_dns_req_complete(dnsreq);
|
||||
}
|
||||
|
||||
|
@ -1312,7 +1372,7 @@ stub_udp_write_cb(void *userarg)
|
|||
getdns_dns_req *dnsreq = netreq->owner;
|
||||
size_t pkt_len;
|
||||
DEBUG_STUB("%s %-35s: MSG: %p \n", STUB_DEBUG_WRITE,
|
||||
__FUNCTION__, netreq);
|
||||
__FUNC__, (void *)netreq);
|
||||
|
||||
GETDNS_CLEAR_EVENT(dnsreq->loop, &netreq->event);
|
||||
|
||||
|
@ -1339,7 +1399,11 @@ stub_udp_write_cb(void *userarg)
|
|||
netreq->fd, (const void *)netreq->query, pkt_len, 0,
|
||||
(struct sockaddr *)&netreq->upstream->addr,
|
||||
netreq->upstream->addr_len)) {
|
||||
#ifdef USE_WINSOCK
|
||||
closesocket(netreq->fd);
|
||||
#else
|
||||
close(netreq->fd);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
GETDNS_SCHEDULE_EVENT(
|
||||
|
@ -1374,7 +1438,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;
|
||||
|
@ -1415,7 +1479,7 @@ upstream_read_cb(void *userarg)
|
|||
}
|
||||
|
||||
DEBUG_STUB("%s %-35s: MSG: %p (read)\n",
|
||||
STUB_DEBUG_READ, __FUNCTION__, netreq);
|
||||
STUB_DEBUG_READ, __FUNC__, (void*)netreq);
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
netreq->response = upstream->tcp.read_buf;
|
||||
netreq->response_len =
|
||||
|
@ -1496,7 +1560,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)
|
||||
|
@ -1520,14 +1584,19 @@ upstream_write_cb(void *userarg)
|
|||
/* 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);
|
||||
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);
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
DEBUG_DAEMON("%s %s : Conn closed : Transport=%s - *Failure*\n",
|
||||
STUB_DEBUG_DAEMON, upstream->addr_str,
|
||||
(upstream->transport == GETDNS_TRANSPORT_TLS ? "TLS" : "TCP"));
|
||||
#endif
|
||||
if (fallback_on_write(netreq) == STUB_TCP_ERROR) {
|
||||
/* TODO: Need new state to report transport unavailable*/
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
|
@ -1672,7 +1741,7 @@ upstream_select_stateful(getdns_network_req *netreq, getdns_transport_list_t tra
|
|||
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 upstreams %d %d\n", STUB_DEBUG_SETUP,
|
||||
__FUNCTION__, (int)i, (int)upstreams->upstreams[i].conn_state);
|
||||
__FUNC__, (int)i, (int)upstreams->upstreams[i].conn_state);
|
||||
if (upstream_valid(&upstreams->upstreams[i], transport, netreq)) {
|
||||
upstream = &upstreams->upstreams[i];
|
||||
break;
|
||||
|
@ -1731,7 +1800,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:
|
||||
|
@ -1758,21 +1827,26 @@ 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;
|
||||
}
|
||||
upstream->tls_hs_state = GETDNS_HS_WRITE;
|
||||
}
|
||||
upstream->conn_state = GETDNS_CONN_SETUP;
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
DEBUG_DAEMON("%s %s : Conn init : Transport=%s - Profile=%s\n", STUB_DEBUG_DAEMON,
|
||||
upstream->addr_str, transport == GETDNS_TRANSPORT_TLS ? "TLS":"TCP",
|
||||
dnsreq->context->tls_auth_min == GETDNS_AUTHENTICATION_NONE ? "Opportunistic":"Strict");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
/* Nothing to do*/
|
||||
}
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
DEBUG_DAEMON("%s %s : Conn init\n",
|
||||
STUB_DEBUG_DAEMON, upstream->addr_str);
|
||||
#endif
|
||||
return fd;
|
||||
}
|
||||
|
||||
|
@ -1800,7 +1874,7 @@ upstream_find_for_transport(getdns_network_req *netreq,
|
|||
*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, __FUNCTION__, *fd, upstream,
|
||||
STUB_DEBUG_SETUP, __FUNC__, *fd, (void*)upstream,
|
||||
(int)(upstream - netreq->owner->context->upstreams->upstreams));
|
||||
}
|
||||
return upstream;
|
||||
|
@ -1824,7 +1898,11 @@ upstream_find_for_netreq(getdns_network_req *netreq)
|
|||
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);
|
||||
#if defined(DAEMON_DEBUG) && DAEMON_DEBUG
|
||||
DEBUG_DAEMON("%s *FAILURE* no valid transports or upstreams available!\n",
|
||||
STUB_DEBUG_DAEMON);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -1837,7 +1915,7 @@ fallback_on_write(getdns_network_req *netreq)
|
|||
{
|
||||
|
||||
/* 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);
|
||||
|
@ -1851,10 +1929,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;
|
||||
|
@ -1873,7 +1951,7 @@ 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);
|
||||
upstream->event.timeout_cb = upstream_idle_timeout_cb;
|
||||
if (upstream->conn_state != GETDNS_CONN_OPEN)
|
||||
idle_timeout = 0;
|
||||
|
@ -1885,7 +1963,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);
|
||||
|
@ -1936,8 +2014,8 @@ upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq)
|
|||
getdns_return_t
|
||||
_getdns_submit_stub_request(getdns_network_req *netreq)
|
||||
{
|
||||
DEBUG_STUB("%s %-35s: MSG: %p TYPE: %d\n", STUB_DEBUG_ENTRY, __FUNCTION__,
|
||||
netreq, netreq->request_type);
|
||||
DEBUG_STUB("%s %-35s: MSG: %p TYPE: %d\n", STUB_DEBUG_ENTRY, __FUNC__,
|
||||
(void*)netreq, netreq->request_type);
|
||||
int fd = -1;
|
||||
getdns_dns_req *dnsreq = netreq->owner;
|
||||
|
||||
|
|
|
@ -151,6 +151,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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -215,13 +216,10 @@ depend:
|
|||
.PHONY: clean test
|
||||
|
||||
# Dependencies for the unit tests
|
||||
check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_address.h $(srcdir)/check_getdns_address_sync.h \
|
||||
$(srcdir)/check_getdns_cancel_callback.h $(srcdir)/check_getdns_context_create.h \
|
||||
$(srcdir)/check_getdns_context_destroy.h \
|
||||
check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c ../getdns/getdns.h $(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns_extra.h $(srcdir)/check_getdns_address.h \
|
||||
$(srcdir)/check_getdns_address_sync.h $(srcdir)/check_getdns_cancel_callback.h \
|
||||
$(srcdir)/check_getdns_context_create.h $(srcdir)/check_getdns_context_destroy.h \
|
||||
$(srcdir)/check_getdns_context_set_context_update_callback.h \
|
||||
$(srcdir)/check_getdns_context_set_dns_transport.h \
|
||||
$(srcdir)/check_getdns_context_set_timeout.h \
|
||||
|
@ -241,58 +239,34 @@ check_getdns.lo check_getdns.o: $(srcdir)/check_getdns.c \
|
|||
$(srcdir)/check_getdns_list_get_list.h $(srcdir)/check_getdns_pretty_print_dict.h \
|
||||
$(srcdir)/check_getdns_service.h $(srcdir)/check_getdns_service_sync.h \
|
||||
$(srcdir)/check_getdns_transport.h
|
||||
check_getdns_common.lo check_getdns_common.o: $(srcdir)/check_getdns_common.c \
|
||||
../getdns/getdns.h \
|
||||
../config.h \
|
||||
$(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns_extra.h \
|
||||
check_getdns_common.lo check_getdns_common.o: $(srcdir)/check_getdns_common.c ../getdns/getdns.h \
|
||||
../config.h $(srcdir)/check_getdns_common.h ../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_eventloop.h
|
||||
check_getdns_context_set_timeout.lo check_getdns_context_set_timeout.o: $(srcdir)/check_getdns_context_set_timeout.c \
|
||||
$(srcdir)/check_getdns_context_set_timeout.h $(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
../getdns/getdns.h ../getdns/getdns_extra.h
|
||||
check_getdns_libev.lo check_getdns_libev.o: $(srcdir)/check_getdns_libev.c $(srcdir)/check_getdns_eventloop.h \
|
||||
../config.h \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/../getdns/getdns_ext_libev.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_common.h
|
||||
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libev.h \
|
||||
../getdns/getdns_extra.h $(srcdir)/check_getdns_common.h
|
||||
check_getdns_libevent.lo check_getdns_libevent.o: $(srcdir)/check_getdns_libevent.c $(srcdir)/check_getdns_eventloop.h \
|
||||
../config.h \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/../getdns/getdns_ext_libevent.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_libevent.h $(srcdir)/check_getdns_common.h
|
||||
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libevent.h \
|
||||
../getdns/getdns_extra.h $(srcdir)/check_getdns_libevent.h $(srcdir)/check_getdns_common.h
|
||||
check_getdns_libuv.lo check_getdns_libuv.o: $(srcdir)/check_getdns_libuv.c $(srcdir)/check_getdns_eventloop.h \
|
||||
../config.h \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/../getdns/getdns_ext_libuv.h \
|
||||
../getdns/getdns_extra.h \
|
||||
$(srcdir)/check_getdns_common.h
|
||||
../config.h ../getdns/getdns.h $(srcdir)/../getdns/getdns_ext_libuv.h \
|
||||
../getdns/getdns_extra.h $(srcdir)/check_getdns_common.h
|
||||
check_getdns_selectloop.lo check_getdns_selectloop.o: $(srcdir)/check_getdns_selectloop.c \
|
||||
$(srcdir)/check_getdns_eventloop.h \
|
||||
../config.h \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/check_getdns_eventloop.h ../config.h ../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
check_getdns_transport.lo check_getdns_transport.o: $(srcdir)/check_getdns_transport.c \
|
||||
$(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_common.h \
|
||||
../getdns/getdns.h \
|
||||
$(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_common.h ../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
scratchpad.template.lo scratchpad.template.o: scratchpad.template.c \
|
||||
../getdns/getdns.h \
|
||||
scratchpad.template.lo scratchpad.template.o: scratchpad.template.c ../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
testmessages.lo testmessages.o: $(srcdir)/testmessages.c $(srcdir)/testmessages.h
|
||||
tests_dict.lo tests_dict.o: $(srcdir)/tests_dict.c $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h
|
||||
tests_list.lo tests_list.o: $(srcdir)/tests_list.c $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h
|
||||
tests_namespaces.lo tests_namespaces.o: $(srcdir)/tests_namespaces.c $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h
|
||||
tests_stub_async.lo tests_stub_async.o: $(srcdir)/tests_stub_async.c \
|
||||
../config.h \
|
||||
$(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
tests_stub_sync.lo tests_stub_sync.o: $(srcdir)/tests_stub_sync.c $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h \
|
||||
tests_dict.lo tests_dict.o: $(srcdir)/tests_dict.c $(srcdir)/testmessages.h ../getdns/getdns.h
|
||||
tests_list.lo tests_list.o: $(srcdir)/tests_list.c $(srcdir)/testmessages.h ../getdns/getdns.h
|
||||
tests_namespaces.lo tests_namespaces.o: $(srcdir)/tests_namespaces.c $(srcdir)/testmessages.h ../getdns/getdns.h
|
||||
tests_stub_async.lo tests_stub_async.o: $(srcdir)/tests_stub_async.c ../config.h $(srcdir)/testmessages.h \
|
||||
../getdns/getdns.h ../getdns/getdns_extra.h
|
||||
tests_stub_sync.lo tests_stub_sync.o: $(srcdir)/tests_stub_sync.c $(srcdir)/testmessages.h ../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
|
||||
|
||||
int
|
||||
main (int argc, char** argv)
|
||||
main ()
|
||||
{
|
||||
int number_failed;
|
||||
SRunner *sr ;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -320,6 +320,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 +339,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 +380,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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -243,6 +243,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) {
|
||||
|
|
|
@ -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] = "";
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -193,6 +193,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
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\": <bindata of "//' | sed 's/\">.*//'`
|
||||
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,19 +173,19 @@ 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 +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 +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`"
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
cd "${BUILDDIR}/build"
|
||||
make
|
||||
make XTRA_CFLAGS='-Werror'
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
cd "${BUILDDIR}/build-stub-only"
|
||||
make
|
||||
make XTRA_CFLAGS='-Werror'
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
rm -fr "${BUILDDIR}/build-event-loops"
|
||||
mkdir "${BUILDDIR}/build-event-loops"
|
||||
cd "${BUILDDIR}/build-event-loops"
|
||||
"${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libev --with-libuv \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libev \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libuv \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libev --with-libuv \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libev \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libuv
|
||||
"${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libev --with-libuv \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libev \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libuv \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libev --with-libuv \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libevent \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libev \
|
||||
|| "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libuv
|
||||
|
|
|
@ -5,4 +5,4 @@
|
|||
[ -f .tpkg.var.test ] && source .tpkg.var.test
|
||||
|
||||
cd "${BUILDDIR}/build-event-loops"
|
||||
make
|
||||
make XTRA_CFLAGS=-Werror
|
||||
|
|
|
@ -15,7 +15,7 @@ LCOV_MERGE=""
|
|||
for TEST_PKG in ${SRCDIR}/*.tpkg
|
||||
do
|
||||
# when we run our test, we need to compile with profiling
|
||||
CFLAGS="-fprofile-arcs -ftest-coverage -O0" "${TPKG}" $* exe "${TEST_PKG}"
|
||||
LDFLAGS="-lgcov --coverage" CFLAGS="-fprofile-arcs -ftest-coverage -O0" "${TPKG}" $* exe "${TEST_PKG}"
|
||||
# after the test is complete, we need to collect the coverage data
|
||||
INFO_FILE=`echo $TEST_PKG | sed 's/.tpkg$//'`.info
|
||||
geninfo $SRCDIR/.. -o $INFO_FILE
|
||||
|
|
|
@ -40,7 +40,8 @@ LIBTOOL = ../../libtool
|
|||
srcdir = @srcdir@
|
||||
|
||||
CC=@CC@
|
||||
CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@
|
||||
WPEDANTICFLAG=@WPEDANTICFLAG@
|
||||
CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@ $(WPEDANTICFLAG) $(XTRA_CFLAGS)
|
||||
LDFLAGS=-L.. @LDFLAGS@
|
||||
LDLIBS=../libgetdns.la @LIBS@
|
||||
|
||||
|
@ -112,8 +113,5 @@ depend:
|
|||
.PHONY: clean test
|
||||
|
||||
# Dependencies for getdns_query
|
||||
getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c \
|
||||
../config.h \
|
||||
$(srcdir)/../debug.h \
|
||||
../getdns/getdns.h \
|
||||
../getdns/getdns_extra.h
|
||||
getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c ../config.h $(srcdir)/../debug.h ../config.h \
|
||||
../getdns/getdns.h ../getdns/getdns_extra.h
|
||||
|
|
|
@ -51,8 +51,11 @@ typedef unsigned short in_port_t;
|
|||
static int i_am_stubby = 0;
|
||||
static const char *default_stubby_config =
|
||||
"{ resolution_type: GETDNS_RESOLUTION_STUB"
|
||||
", dns_transport_list: [ GETDNS_TRANSPORT_TLS, GETDNS_TRANSPORT_UDP, GETDNS_TRANSPORT_TCP ]"
|
||||
", idle_timeout: 10000"
|
||||
", listen_addresses: [ 127.0.0.1@53, 0::1@53 ]"
|
||||
", tls_query_padding_blocksize: 256"
|
||||
", edns_client_subnet_private : 1"
|
||||
"}";
|
||||
static int clear_listen_list_on_arg = 0;
|
||||
#ifndef GETDNS_ON_WINDOWS
|
||||
|
@ -129,8 +132,8 @@ static int get_rrclass(const char *t)
|
|||
}
|
||||
|
||||
static getdns_return_t
|
||||
fill_transport_list(getdns_context *context, char *transport_list_str,
|
||||
getdns_transport_list_t *transports, size_t *transport_count)
|
||||
fill_transport_list(char *transport_list_str,
|
||||
getdns_transport_list_t *transports, size_t *transport_count)
|
||||
{
|
||||
size_t max_transports = *transport_count;
|
||||
*transport_count = 0;
|
||||
|
@ -161,13 +164,19 @@ print_usage(FILE *out, const char *progname)
|
|||
{
|
||||
fprintf(out, "usage: %s [<option> ...] \\\n"
|
||||
"\t[@<upstream> ...] [+<extension> ...] [\'{ <settings> }\'] [<name>] [<type>]\n", progname);
|
||||
fprintf(out, "\ndefault mode: "
|
||||
if (!i_am_stubby) {
|
||||
fprintf(out, "\ndefault mode: "
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
"recursive"
|
||||
"recursive"
|
||||
#else
|
||||
"stub"
|
||||
"stub"
|
||||
#endif
|
||||
", synchronous resolution of NS record\n\t\tusing UDP with TCP fallback\n");
|
||||
", synchronous resolution of NS record\n\t\tusing UDP with TCP fallback\n");
|
||||
}
|
||||
else {
|
||||
fprintf(out, "\ndefault mode: "
|
||||
"stub, asynchronous resolution \n\t\tusing TLS with UDP then TCP fallback\n");
|
||||
}
|
||||
fprintf(out, "\nupstreams: @<ip>[%%<scope_id>][@<port>][#<tls port>][~<tls name>][^<tsig spec>]");
|
||||
fprintf(out, "\n <ip>@<port> may be given as <IPv4>:<port>");
|
||||
fprintf(out, "\n or \'[\'<IPv6>[%%<scope_id>]\']\':<port> too\n");
|
||||
|
@ -192,10 +201,12 @@ print_usage(FILE *out, const char *progname)
|
|||
fprintf(out, "\t+0\t\t\tClear all extensions\n");
|
||||
fprintf(out, "\nsettings in json dict format (like outputted by -i option).\n");
|
||||
fprintf(out, "\noptions:\n");
|
||||
fprintf(out, "\t-a\tPerform asynchronous resolution "
|
||||
"(default = synchronous)\n");
|
||||
fprintf(out, "\t-A\taddress lookup (<type> is ignored)\n");
|
||||
fprintf(out, "\t-B\tBatch mode. Schedule all messages before processing responses.\n");
|
||||
if (!i_am_stubby) {
|
||||
fprintf(out, "\t-a\tPerform asynchronous resolution "
|
||||
"(default = synchronous)\n");
|
||||
fprintf(out, "\t-A\taddress lookup (<type> is ignored)\n");
|
||||
fprintf(out, "\t-B\tBatch mode. Schedule all messages before processing responses.\n");
|
||||
}
|
||||
fprintf(out, "\t-b <bufsize>\tSet edns0 max_udp_payload size\n");
|
||||
fprintf(out, "\t-c\tSend Client Subnet privacy request\n");
|
||||
fprintf(out, "\t-C\t<filename>\n");
|
||||
|
@ -209,17 +220,21 @@ print_usage(FILE *out, const char *progname)
|
|||
fprintf(out, "\t-D\tSet edns0 do bit\n");
|
||||
fprintf(out, "\t-d\tclear edns0 do bit\n");
|
||||
fprintf(out, "\t-e <idle_timeout>\tSet idle timeout in miliseconds\n");
|
||||
fprintf(out, "\t-F <filename>\tread the queries from the specified file\n");
|
||||
if (!i_am_stubby)
|
||||
fprintf(out, "\t-F <filename>\tread the queries from the specified file\n");
|
||||
fprintf(out, "\t-f <filename>\tRead DNSSEC trust anchors from <filename>\n");
|
||||
#ifndef GETDNS_ON_WINDOWS
|
||||
if (i_am_stubby)
|
||||
fprintf(out, "\t-g\tRun stubby in background (default is foreground)\n");
|
||||
#endif
|
||||
fprintf(out, "\t-G\tgeneral lookup\n");
|
||||
fprintf(out, "\t-H\thostname lookup. (<name> must be an IP address; <type> is ignored)\n");
|
||||
if (!i_am_stubby) {
|
||||
fprintf(out, "\t-G\tgeneral lookup\n");
|
||||
fprintf(out, "\t-H\thostname lookup. (<name> must be an IP address; <type> is ignored)\n");
|
||||
}
|
||||
fprintf(out, "\t-h\tPrint this help\n");
|
||||
fprintf(out, "\t-i\tPrint api information\n");
|
||||
fprintf(out, "\t-I\tInteractive mode (> 1 queries on same context)\n");
|
||||
if (!i_am_stubby)
|
||||
fprintf(out, "\t-I\tInteractive mode (> 1 queries on same context)\n");
|
||||
fprintf(out, "\t-j\tOutput json response dict\n");
|
||||
fprintf(out, "\t-J\tPretty print json response dict\n");
|
||||
fprintf(out, "\t-k\tPrint root trust anchors\n");
|
||||
|
@ -235,8 +250,10 @@ print_usage(FILE *out, const char *progname)
|
|||
fprintf(out, "\t-R <filename>\tRead root hints from <filename>\n");
|
||||
fprintf(out, "\t-s\tSet stub resolution type%s\n"
|
||||
, i_am_stubby ? "" : "(default = recursing)" );
|
||||
fprintf(out, "\t-S\tservice lookup (<type> is ignored)\n");
|
||||
if (!i_am_stubby)
|
||||
fprintf(out, "\t-S\tservice lookup (<type> is ignored)\n");
|
||||
fprintf(out, "\t-t <timeout>\tSet timeout in miliseconds\n");
|
||||
fprintf(out, "\t-v\tPrint getdns release version\n");
|
||||
fprintf(out, "\t-x\tDo not follow redirects\n");
|
||||
fprintf(out, "\t-X\tFollow redirects (default)\n");
|
||||
|
||||
|
@ -353,6 +370,7 @@ void callback(getdns_context *context, getdns_callback_type_t callback_type,
|
|||
getdns_dict *response, void *userarg, getdns_transaction_t trans_id)
|
||||
{
|
||||
char *response_str;
|
||||
(void)context; (void)userarg;
|
||||
|
||||
/* This is a callback with data */;
|
||||
if (response && !quiet && (response_str = json ?
|
||||
|
@ -520,7 +538,7 @@ int parse_config_file(const char *fn, int report_open_failure)
|
|||
return GETDNS_RETURN_MEMORY_ERROR;
|
||||
}
|
||||
rewind(fh);
|
||||
if (fread(config_file, 1, config_file_sz, fh) != config_file_sz) {
|
||||
if (fread(config_file, 1, config_file_sz, fh) != (size_t)config_file_sz) {
|
||||
fprintf( stderr, "An error occurred while reading \"%s\": %s\n"
|
||||
, fn, strerror(errno));
|
||||
fclose(fh);
|
||||
|
@ -536,7 +554,8 @@ int parse_config_file(const char *fn, int report_open_failure)
|
|||
getdns_return_t parse_args(int argc, char **argv)
|
||||
{
|
||||
getdns_return_t r = GETDNS_RETURN_GOOD;
|
||||
size_t i, j, klass;
|
||||
size_t j;
|
||||
int i, klass;
|
||||
char *arg, *c, *endptr;
|
||||
int t, print_api_info = 0, print_trust_anchors = 0;
|
||||
getdns_list *upstream_list = NULL;
|
||||
|
@ -840,6 +859,9 @@ getdns_return_t parse_args(int argc, char **argv)
|
|||
getdns_context_set_timeout(
|
||||
context, timeout);
|
||||
goto next;
|
||||
case 'v':
|
||||
fprintf(stdout, "Version %s\n", GETDNS_VERSION);
|
||||
return CONTINUE;
|
||||
case 'x':
|
||||
getdns_context_set_follow_redirects(
|
||||
context, GETDNS_REDIRECTS_DO_NOT_FOLLOW);
|
||||
|
@ -937,7 +959,7 @@ getdns_return_t parse_args(int argc, char **argv)
|
|||
}
|
||||
getdns_transport_list_t transports[10];
|
||||
size_t transport_count = sizeof(transports);
|
||||
if ((r = fill_transport_list(context, argv[i], transports, &transport_count)) ||
|
||||
if ((r = fill_transport_list(argv[i], transports, &transport_count)) ||
|
||||
(r = getdns_context_set_dns_transport_list(context,
|
||||
transport_count, transports))){
|
||||
fprintf(stderr, "Could not set transports\n");
|
||||
|
@ -1019,13 +1041,13 @@ next: ;
|
|||
if (pubkey_pinset && upstream_count) {
|
||||
getdns_dict *upstream;
|
||||
/* apply the accumulated pubkey pinset to all upstreams: */
|
||||
for (i = 0; i < upstream_count; i++) {
|
||||
if (r = getdns_list_get_dict(upstream_list, i, &upstream), r) {
|
||||
fprintf(stderr, "Failed to get upstream "PRIsz" when adding pinset\n", i);
|
||||
for (j = 0; j < upstream_count; j++) {
|
||||
if (r = getdns_list_get_dict(upstream_list, j, &upstream), r) {
|
||||
fprintf(stderr, "Failed to get upstream "PRIsz" when adding pinset\n", j);
|
||||
return r;
|
||||
}
|
||||
if (r = getdns_dict_set_list(upstream, "tls_pubkey_pinset", pubkey_pinset), r) {
|
||||
fprintf(stderr, "Failed to set pubkey pinset on upstream "PRIsz"\n", i);
|
||||
fprintf(stderr, "Failed to set pubkey pinset on upstream "PRIsz"\n", j);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
@ -1345,11 +1367,13 @@ static void request_cb(
|
|||
qname_str = unknown_qname;
|
||||
|
||||
DEBUG_SERVER("reply for: %p %"PRIu64" %d (edns0: %d, do: %d, ad: %d,"
|
||||
" cd: %d, qname: %s)\n", msg, transaction_id, (int)callback_type,
|
||||
" cd: %d, qname: %s)\n", (void *)msg, transaction_id, (int)callback_type,
|
||||
msg->has_edns0, msg->do_bit, msg->ad_bit, msg->cd_bit, qname_str);
|
||||
|
||||
if (qname_str != unknown_qname)
|
||||
free(qname_str);
|
||||
#else
|
||||
(void)transaction_id;
|
||||
#endif
|
||||
assert(msg);
|
||||
|
||||
|
@ -1560,7 +1584,7 @@ static void incoming_request_handler(getdns_context *context,
|
|||
getdns_get_errorstr_by_id(r));
|
||||
else {
|
||||
DEBUG_SERVER("scheduled: %p %"PRIu64" for %s %d\n",
|
||||
msg, transaction_id, qname_str, (int)qtype);
|
||||
(void *)msg, transaction_id, qname_str, (int)qtype);
|
||||
free(qname_str);
|
||||
return;
|
||||
}
|
||||
|
@ -1631,12 +1655,14 @@ main(int argc, char **argv)
|
|||
goto done_destroy_context;
|
||||
}
|
||||
if (i_am_stubby) {
|
||||
int n_chars = snprintf( home_stubby_conf_fn
|
||||
, sizeof(home_stubby_conf_fn)
|
||||
, "%s/.stubby.conf"
|
||||
, getenv("HOME")
|
||||
);
|
||||
(void) parse_config(default_stubby_config);
|
||||
(void) parse_config_file("/etc/stubby.conf", 0);
|
||||
if (snprintf( home_stubby_conf_fn, sizeof(home_stubby_conf_fn)
|
||||
, "%s/.stubby.conf", getenv("HOME")
|
||||
) < sizeof(home_stubby_conf_fn)) {
|
||||
|
||||
if (n_chars > 0 && n_chars < (int)sizeof(home_stubby_conf_fn)){
|
||||
(void) parse_config_file(home_stubby_conf_fn, 0);
|
||||
}
|
||||
clear_listen_list_on_arg = 1;
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
{ resolution_type: GETDNS_RESOLUTION_STUB
|
||||
, dns_transport_list: [ GETDNS_TRANSPORT_TLS ]
|
||||
, upstream_recursive_servers:
|
||||
[ { address_data: 145.100.185.15
|
||||
, tls_auth_name: "dnsovertls.sinodun.com"
|
||||
, tls_pubkey_pinset:
|
||||
[ { digest: "sha256"
|
||||
, value: 0xA132D34D34C181765337C70B83E3697B9524DDDB05A7118B43C0284033D5A0CC
|
||||
} ]
|
||||
},
|
||||
{ address_data: 145.100.185.16
|
||||
, tls_auth_name: "dnsovertls1.sinodun.com"
|
||||
, tls_pubkey_pinset:
|
||||
[ { digest: "sha256"
|
||||
, value: 0x659B41EB08DCC70EE9D624E6219C76EE31954DA1548B0C8519EAE5228CB24150
|
||||
} ]
|
||||
},
|
||||
{ address_data: 185.49.141.38
|
||||
, tls_auth_name: "getdnsapi.net"
|
||||
, tls_pubkey_pinset:
|
||||
[ { digest: "sha256"
|
||||
, value: 0x7e8c59467221f606695a797ecc488a6b4109dab7421aba0c5a6d3681ac5273d4
|
||||
} ]
|
||||
},
|
||||
{ address_data: 2001:610:1:40ba:145:100:185:15
|
||||
, tls_auth_name: "dnsovertls.sinodun.com"
|
||||
, tls_pubkey_pinset:
|
||||
[ { digest: "sha256"
|
||||
, value: 0xA132D34D34C181765337C70B83E3697B9524DDDB05A7118B43C0284033D5A0CC
|
||||
} ]
|
||||
},
|
||||
{ address_data: 2001:610:1:40ba:145:100:185:16
|
||||
, tls_auth_name: "dnsovertls1.sinodun.com"
|
||||
, tls_pubkey_pinset:
|
||||
[ { digest: "sha256"
|
||||
, value: 0x659B41EB08DCC70EE9D624E6219C76EE31954DA1548B0C8519EAE5228CB24150
|
||||
} ]
|
||||
},
|
||||
{ address_data: 2a04:b900:0:100::38
|
||||
, tls_auth_name: "getdnsapi.net"
|
||||
, tls_pubkey_pinset:
|
||||
[ { digest: "sha256"
|
||||
, value: 0x7e8c59467221f606695a797ecc488a6b4109dab7421aba0c5a6d3681ac5273d4
|
||||
} ]
|
||||
},
|
||||
{ address_data: 184.105.193.78
|
||||
, tls_pubkey_pinset:
|
||||
[ { digest: "sha256"
|
||||
, value: 0xA4E5EBA54B7D9203E06D6C411457014DB447DA17A8DB01F05E9D5F7780045572
|
||||
} ]
|
||||
},
|
||||
{ address_data: 2620:ff:c000:0:1::64:25
|
||||
, tls_pubkey_pinset:
|
||||
[ { digest: "sha256"
|
||||
, value: 0xA4E5EBA54B7D9203E06D6C411457014DB447DA17A8DB01F05E9D5F7780045572
|
||||
} ]
|
||||
}
|
||||
]
|
||||
, tls_authentication: GETDNS_AUTHENTICATION_REQUIRED
|
||||
, tls_query_padding_blocksize: 256
|
||||
, edns_client_subnet_private : 1
|
||||
, listen_addresses: [ 127.0.0.1, 0::1 ]
|
||||
, idle_timeout: 10000
|
||||
}
|
|
@ -119,7 +119,7 @@ struct getdns_upstream;
|
|||
#define GETDNS_STR_KEY_NSCOUNT "nscount"
|
||||
#define GETDNS_STR_KEY_ARCOUNT "arcount"
|
||||
|
||||
#define TIMEOUT_FOREVER ((int64_t)-1)
|
||||
#define TIMEOUT_FOREVER ((uint64_t)0xFFFFFFFFFFFFFFFF)
|
||||
#define ASSERT_UNREACHABLE 0
|
||||
|
||||
#define GETDNS_TRANSPORTS_MAX 3
|
||||
|
@ -287,29 +287,29 @@ typedef struct getdns_dns_req {
|
|||
getdns_append_name_t append_name;
|
||||
const uint8_t *suffix;
|
||||
size_t suffix_len;
|
||||
int suffix_appended : 1;
|
||||
unsigned suffix_appended : 1;
|
||||
|
||||
/* canceled flag */
|
||||
int canceled : 1;
|
||||
unsigned canceled : 1;
|
||||
|
||||
/* request extensions */
|
||||
int dnssec_return_status : 1;
|
||||
int dnssec_return_only_secure : 1;
|
||||
int dnssec_return_all_statuses : 1;
|
||||
int dnssec_return_validation_chain : 1;
|
||||
int dnssec_return_full_validation_chain : 1;
|
||||
unsigned dnssec_return_status : 1;
|
||||
unsigned dnssec_return_only_secure : 1;
|
||||
unsigned dnssec_return_all_statuses : 1;
|
||||
unsigned dnssec_return_validation_chain : 1;
|
||||
unsigned dnssec_return_full_validation_chain : 1;
|
||||
#ifdef DNSSEC_ROADBLOCK_AVOIDANCE
|
||||
int dnssec_roadblock_avoidance : 1;
|
||||
int avoid_dnssec_roadblocks : 1;
|
||||
unsigned dnssec_roadblock_avoidance : 1;
|
||||
unsigned avoid_dnssec_roadblocks : 1;
|
||||
#endif
|
||||
int edns_cookies : 1;
|
||||
int edns_client_subnet_private : 1;
|
||||
int return_call_reporting : 1;
|
||||
int add_warning_for_bad_dns : 1;
|
||||
unsigned edns_cookies : 1;
|
||||
unsigned edns_client_subnet_private : 1;
|
||||
unsigned return_call_reporting : 1;
|
||||
unsigned add_warning_for_bad_dns : 1;
|
||||
|
||||
/* Internally used by return_validation_chain */
|
||||
int dnssec_ok_checking_disabled : 1;
|
||||
int is_sync_request : 1;
|
||||
unsigned dnssec_ok_checking_disabled : 1;
|
||||
unsigned is_sync_request : 1;
|
||||
|
||||
/* The validating and freed variables are used to make sure a single
|
||||
* code path is followed while processing a DNS request, even when
|
||||
|
@ -319,7 +319,7 @@ typedef struct getdns_dns_req {
|
|||
* validating is touched by _getdns_get_validation_chain only and
|
||||
* freed is touched by _getdns_submit_netreq only
|
||||
*/
|
||||
int validating : 1;
|
||||
unsigned validating : 1;
|
||||
int *freed;
|
||||
|
||||
uint16_t tls_query_padding_blocksize;
|
||||
|
@ -423,5 +423,7 @@ void _getdns_network_validate_tsig(getdns_network_req *req);
|
|||
|
||||
void _getdns_netreq_reinit(getdns_network_req *netreq);
|
||||
|
||||
const char * _getdns_auth_str(getdns_auth_state_t auth);
|
||||
|
||||
#endif
|
||||
/* types-internal.h */
|
||||
|
|
|
@ -115,9 +115,9 @@ typedef struct my_event {
|
|||
} my_event;
|
||||
|
||||
#define AS_UB_LOOP(x) \
|
||||
(((union {struct ub_event_base* a; _getdns_ub_loop* b;})x).b)
|
||||
((_getdns_ub_loop *)(x))
|
||||
#define AS_MY_EVENT(x) \
|
||||
(((union {struct ub_event* a; my_event* b;})x).b)
|
||||
((my_event *)(x))
|
||||
|
||||
static void my_event_base_free(struct ub_event_base* base)
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ static int my_event_base_loopexit(struct ub_event_base* base, struct timeval* tv
|
|||
static void clear_my_event(my_event *ev)
|
||||
{
|
||||
DEBUG_SCHED("UB_LOOP: to clear %p(%d, %d, %"PRIu64"), total: %d\n"
|
||||
, ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events);
|
||||
, (void *)ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events);
|
||||
(ev)->loop->extension->vmt->clear((ev)->loop->extension, &(ev)->gev);
|
||||
(ev)->added = 0;
|
||||
if ((ev)->active) {
|
||||
|
@ -157,7 +157,7 @@ static void clear_my_event(my_event *ev)
|
|||
(ev)->active = NULL;
|
||||
}
|
||||
DEBUG_SCHED("UB_LOOP: %p(%d, %d, %"PRIu64") cleared, total: %d\n"
|
||||
, ev, ev->fd, ev->bits, ev->timeout, --ev->loop->n_events);
|
||||
, (void *)ev, ev->fd, ev->bits, ev->timeout, --ev->loop->n_events);
|
||||
}
|
||||
|
||||
static getdns_return_t schedule_my_event(my_event *ev)
|
||||
|
@ -165,16 +165,16 @@ static getdns_return_t schedule_my_event(my_event *ev)
|
|||
getdns_return_t r;
|
||||
|
||||
DEBUG_SCHED("UB_LOOP: to schedule %p(%d, %d, %"PRIu64"), total: %d\n"
|
||||
, ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events);
|
||||
, (void *)ev, ev->fd, ev->bits, ev->timeout, ev->loop->n_events);
|
||||
if (ev->gev.read_cb || ev->gev.write_cb || ev->gev.timeout_cb) {
|
||||
if ((r = ev->loop->extension->vmt->schedule(
|
||||
ev->loop->extension, ev->fd, ev->timeout, &ev->gev))) {
|
||||
DEBUG_SCHED("UB_LOOP ERROR: scheduling event: %p\n", ev);
|
||||
DEBUG_SCHED("UB_LOOP ERROR: scheduling event: %p\n", (void *)ev);
|
||||
return r;
|
||||
}
|
||||
ev->added = 1;
|
||||
DEBUG_SCHED("UB_LOOP: event %p(%d, %d, %"PRIu64") scheduled, "
|
||||
"total: %d\n", ev, ev->fd, ev->bits, ev->timeout
|
||||
"total: %d\n", (void *)ev, ev->fd, ev->bits, ev->timeout
|
||||
, ++ev->loop->n_events);
|
||||
}
|
||||
return GETDNS_RETURN_GOOD;
|
||||
|
@ -353,6 +353,7 @@ static int my_timer_del(struct ub_event* ev)
|
|||
|
||||
static int my_signal_add(struct ub_event* ub_ev, struct timeval* tv)
|
||||
{
|
||||
(void)ub_ev; (void)tv;
|
||||
/* Only unbound daaemon workers use signals */
|
||||
DEBUG_SCHED("UB_LOOP ERROR: signal_add()\n");
|
||||
return -1;
|
||||
|
@ -360,6 +361,7 @@ static int my_signal_add(struct ub_event* ub_ev, struct timeval* tv)
|
|||
|
||||
static int my_signal_del(struct ub_event* ub_ev)
|
||||
{
|
||||
(void)ub_ev;
|
||||
/* Only unbound daaemon workers use signals */
|
||||
DEBUG_SCHED("UB_LOOP ERROR: signal_del()\n");
|
||||
return -1;
|
||||
|
@ -412,7 +414,7 @@ static struct ub_event* my_event_new(struct ub_event_base* base, int fd,
|
|||
ev->added = 0;
|
||||
ev->fd = fd;
|
||||
ev->bits = bits;
|
||||
ev->timeout = (uint64_t)-1;
|
||||
ev->timeout = TIMEOUT_FOREVER;
|
||||
ev->cb = cb;
|
||||
ev->arg = arg;
|
||||
#ifdef USE_WINSOCK
|
||||
|
|
|
@ -838,6 +838,16 @@ _getdns_create_call_reporting_dict(
|
|||
was actually used for the last successful query.*/
|
||||
if (transport == GETDNS_TRANSPORT_TCP && netreq->debug_udp == 1) {
|
||||
transport = GETDNS_TRANSPORT_UDP;
|
||||
if (getdns_dict_set_int( netreq_debug, "udp_responses_for_this_upstream",
|
||||
netreq->upstream->udp_responses)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
if (getdns_dict_set_int( netreq_debug, "udp_timeouts_for_this_upstream",
|
||||
netreq->upstream->udp_timeouts)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (getdns_dict_set_int( netreq_debug, "transport", transport)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
|
@ -858,16 +868,38 @@ _getdns_create_call_reporting_dict(
|
|||
return NULL;
|
||||
}
|
||||
}
|
||||
/* The running totals are only updated when a connection is closed.
|
||||
Since it is open as we have just used it, calcualte the value on the fly */
|
||||
if (getdns_dict_set_int( netreq_debug, "responses_on_this_connection",
|
||||
netreq->upstream->responses_received)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
if (getdns_dict_set_int( netreq_debug, "timeouts_on_this_connection",
|
||||
netreq->upstream->responses_timeouts)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
if (getdns_dict_set_int( netreq_debug, "responses_for_this_upstream",
|
||||
netreq->upstream->responses_received +
|
||||
netreq->upstream->total_responses)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
if (getdns_dict_set_int( netreq_debug, "timeouts_for_this_upstream",
|
||||
netreq->upstream->responses_timeouts +
|
||||
netreq->upstream->total_timeouts)) {
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (netreq->upstream->transport != GETDNS_TRANSPORT_TLS)
|
||||
return netreq_debug;
|
||||
|
||||
/* Only include the auth status if TLS was used */
|
||||
/* TODO: output all 3 options */
|
||||
if (getdns_dict_util_set_string(netreq_debug, "tls_auth_status",
|
||||
netreq->debug_tls_auth_status == GETDNS_AUTH_OK ?
|
||||
"OK: Server authenticated":"FAILED or NOT TRIED: Server not authenticated")){
|
||||
_getdns_auth_str(netreq->debug_tls_auth_status))){
|
||||
|
||||
getdns_dict_destroy(netreq_debug);
|
||||
return NULL;
|
||||
|
@ -891,7 +923,7 @@ static int _srv_cmp(const void *a, const void *b)
|
|||
|
||||
static void _rfc2782_sort(_srv_rr *start, _srv_rr *end)
|
||||
{
|
||||
int running_sum, n;
|
||||
uint32_t running_sum, n;
|
||||
_srv_rr *i, *j, swap;
|
||||
|
||||
/* First move all SRVs with weight 0 to the beginning of the list */
|
||||
|
@ -1254,6 +1286,8 @@ getdns_return_t
|
|||
getdns_apply_network_result(getdns_network_req* netreq,
|
||||
int rcode, void *pkt, int pkt_len, int sec, char* why_bogus)
|
||||
{
|
||||
(void)why_bogus;
|
||||
|
||||
netreq->dnssec_status = sec == 0 ? GETDNS_DNSSEC_INSECURE
|
||||
: sec == 2 ? GETDNS_DNSSEC_SECURE
|
||||
: GETDNS_DNSSEC_BOGUS;
|
||||
|
@ -1380,7 +1414,8 @@ static void _getdns_reply2wire_buf(gldns_buffer *buf, getdns_dict *reply)
|
|||
{
|
||||
getdns_dict *rr_dict, *q_dict, *h_dict;
|
||||
getdns_list *section;
|
||||
size_t i, pkt_start, ancount, nscount;
|
||||
size_t i, pkt_start;
|
||||
uint16_t ancount, nscount;
|
||||
uint32_t qtype, qclass = GETDNS_RRCLASS_IN, rcode = GETDNS_RCODE_NOERROR;
|
||||
getdns_bindata *qname;
|
||||
|
||||
|
@ -1434,7 +1469,8 @@ static void _getdns_reply2wire_buf(gldns_buffer *buf, getdns_dict *reply)
|
|||
static void _getdns_list2wire_buf(gldns_buffer *buf, getdns_list *l)
|
||||
{
|
||||
getdns_dict *rr_dict;
|
||||
size_t i, pkt_start, ancount;
|
||||
size_t i, pkt_start;
|
||||
uint16_t ancount;
|
||||
uint32_t qtype, qclass = GETDNS_RRCLASS_IN;
|
||||
getdns_bindata *qname;
|
||||
|
||||
|
@ -1526,4 +1562,14 @@ void _getdns_wire2list(uint8_t *pkt, size_t pkt_len, getdns_list *l)
|
|||
}
|
||||
}
|
||||
|
||||
const char * _getdns_auth_str(getdns_auth_state_t auth) {
|
||||
static const char*
|
||||
getdns_auth_str_array[] = {
|
||||
GETDNS_STR_AUTH_NONE,
|
||||
GETDNS_STR_AUTH_FAILED,
|
||||
GETDNS_STR_AUTH_OK
|
||||
};
|
||||
return getdns_auth_str_array[auth];
|
||||
}
|
||||
|
||||
/* util-internal.c */
|
||||
|
|
|
@ -230,6 +230,7 @@ log_crypto_error(const char* str, unsigned long e)
|
|||
ERR_error_string_n(e, buf, sizeof(buf));
|
||||
/* buf now contains */
|
||||
/* error:[error code]:[library name]:[function name]:[reason string] */
|
||||
(void)str;
|
||||
log_err("%s crypto %s", str, buf);
|
||||
}
|
||||
|
||||
|
@ -262,8 +263,12 @@ setup_dsa_sig(unsigned char** sig, unsigned int* len)
|
|||
dsasig = DSA_SIG_new();
|
||||
if(!dsasig) return 0;
|
||||
|
||||
#ifdef HAVE_DSA_SIG_SET0
|
||||
if(!DSA_SIG_set0(dsasig, R, S)) return 0;
|
||||
#else
|
||||
dsasig->r = R;
|
||||
dsasig->s = S;
|
||||
#endif
|
||||
*sig = NULL;
|
||||
newlen = i2d_DSA_SIG(dsasig, sig);
|
||||
if(newlen < 0) {
|
||||
|
@ -404,7 +409,11 @@ setup_key_digest(int algo, EVP_PKEY** evp_key, const EVP_MD** digest_type,
|
|||
"EVP_PKEY_assign_DSA failed");
|
||||
return 0;
|
||||
}
|
||||
#ifdef HAVE_EVP_DSS1
|
||||
*digest_type = EVP_dss1();
|
||||
#else
|
||||
*digest_type = EVP_sha1();
|
||||
#endif
|
||||
|
||||
break;
|
||||
#endif /* USE_DSA */
|
||||
|
|
Loading…
Reference in New Issue